From neelk at brick.cswv.com Sat Mar 4 17:53:43 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 4 Mar 2000 22:53:43 GMT Subject: Python advocacy References: <38BEE429.179D4865@prescod.net> <1e6xz1s.uuanez7qwj3oN%bparsia@email.unc.edu> Message-ID: Quinn Dunkan wrote: > On Sat, 4 Mar 2000 00:37:06 -0500, Bijan Parsia > wrote: > >And poor Dylan, which sold it's soul to mixfix only to be doomed to > >obscurity, in the general world, and scorn from its progeniters. > > I don't quite understand... gwydion dylan seems to be moving along, > and ex-harlequin dylan enjoys a company (functional objects) focused > around its improvement. I'm having fun with Dylan, at any rate, and expect to continue using it for a long time to come. > Guess it would help if I knew what mixfix was... Not really; he just means Algolish (Algolic? Algolaceous?) syntax, like so: define method fact(n :: ) => (result :: ) if (n = 0) 1 else n * fact(n - 1) end if; end method fact; rather than Lispy fully-parenthesized syntax. Neel From lf11 at deletethistomailme.andonet.com Wed Mar 15 09:15:08 2000 From: lf11 at deletethistomailme.andonet.com (lf11 at deletethistomailme.andonet.com) Date: Wed, 15 Mar 2000 09:15:08 -0500 Subject: Executing Applications References: <8amup2$eka$1@news.kersur.net> Message-ID: <8ao5i0$33q$1@news.kersur.net> Thanks! I guess I missed it while looking through the online manual.... -lf In article , "Kevin Cazabon" wrote: > os.system() will execute commands in the native OS command line. > > Kevin. > wrote in message > news:8amup2$eka$1 at news.kersur.net... >> How can I execute non-python scripts and applications from within a Python > script? >> >> Something along the lines of exec in Bash, or exec() and system() in Perl. >> >> Thanks! >> >> -lf > > From robin at jessikat.demon.co.uk Tue Mar 28 17:21:15 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 28 Mar 2000 23:21:15 +0100 Subject: else clauses in while and for loops References: <38DD2EE3.C7F3CB54@webamused.com> <8boe2k$gmh$1@inputplus.demon.co.uk> Message-ID: In article , Fredrik Lundh writes >Robin Becker wrote: >> >or maybe we could use all that energy to work on >> >something more important? >> >> I guess a lot of perfectly working programs will get broken by the >> removed bugs in the upcoming 1.6. Anyhow saying it's not a real need >> isn't the same as demanding it be removed. I find this usage a bit of a >> mis-feature, but I'm not pushing for uniqueness of expression as some >> do. > >none of the changes in 1.6 will require rewriting possibly large >sections of code. > > > > Perhaps not, but anyone using append(1,2,3,4) will get bitten. Presumably there are other mis-features waiting to bite. If nothing changes what's the point? -- Robin Becker From emile at fenx.com Sat Mar 4 15:28:57 2000 From: emile at fenx.com (Emile van Sebille) Date: Sat, 4 Mar 2000 12:28:57 -0800 Subject: Python and MS Excel References: Message-ID: <008701bf8618$4914cbe0$01ffffc0@worldnet.att.net> The tutorial's at: http://www.python.org/windows/win32com/COMTutorial/index.htm Also, check out the client side com quick start: http://www.python.org/windows/win32com/QuickStartClientCom.html http://www.python.org/windows/win32com is the home page. HTH, Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Scott Barron Newsgroups: comp.lang.python To: Sent: Saturday, March 04, 2000 11:24 AM Subject: Python and MS Excel > Hi all, > > Does anyone have a link to a tutorial on creating/using Excel spreadsheets > with Python? > > Thanks, > Scott > -- > http://www.python.org/mailman/listinfo/python-list > From tbryan at python.net Sun Mar 5 00:03:35 2000 From: tbryan at python.net (Thomas A. Bryan) Date: Sun, 05 Mar 2000 00:03:35 -0500 Subject: Elementry question on indeces References: <00030419362708.02808@quadra.teleo.net> Message-ID: <38C1EAA7.4F48FC57@python.net> Rick wrote: [..in a reply to an answer to a sequence slicing question..] > > OK, got it....thanks. > > I would question why it's done this way, but I guess I should read on. I often find it convenient that Lst[x:z] covers the same elements as does Lst[x:y] and Lst[y:z] for any indices 0 <= x <= y <= z <= len(Lst). Perhaps you'll come to like this feature when you start using it more often in your Python programs. Python-was-designed-for-my-convenience--ly yours ---Tom From dana at mmi.oz.net Wed Mar 22 14:55:11 2000 From: dana at mmi.oz.net (Dana Booth) Date: 22 Mar 2000 19:55:11 GMT Subject: readline() Message-ID: <8bb8ev$4p0$0@216.39.141.36> I have a small proggie that reads through the mailspool, looking for lines containing keywords. If the mailbox contains mime encoded attachements, or for some other reason is very large, it seems to take quite a long time. The util uses readline() and the re.search. Is readline() not very efficiant? I know that Perl is really the ticket for most text processing utils that require anything more than Awk, and in this case it's much faster, but the Python util goes on to do much more, and I didn't want to call on Perl just for a textfile read. Anyway, I'm pretty new to Python, is there a better way to analyze textfiles? Or is the re.search slowing it down? -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From effbot at telia.com Tue Mar 14 11:15:28 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 14 Mar 2000 16:15:28 GMT Subject: Simple string formatting question References: <8alnfm$em0$1@nntp6.atl.mindspring.net> Message-ID: Aahz Maruch wrote: > There are many ways; here's the simplest: > > print '%5.3f %5.3f %5.3f 1i' % (temp_list[0], temp_list[1], > temp_list[2], temp_list.index(min(temp_list))+1) > > Python is smart enough to know that a comma means that the line can't > end. We generally recommend that you indent the continuation line. footnote: it's not the comma, it's the open parenthesis. From effbot at telia.com Fri Mar 31 16:33:59 2000 From: effbot at telia.com (Fredrik Lundh) Date: Fri, 31 Mar 2000 21:33:59 GMT Subject: Determining Ethernet HW Address References: <38E51410.2DFBD7CF@bellatlantic.net> Message-ID: Steve Holden wrote > I suspect that what was being suggested here was the use of the Ethernet > address in the creation of GUIs (globally-unique identifiers). For such > an identifier to be globally unique it requires two components. you mean GUID, I hope (or UUID, depending on you who you ask) > One is a portion specific to the locale in which it is created, which > is what guarantees the global uniqueness. An Ethernet identifier would > do quite nicely for this purpose. only if you don't really care about privacy issues, of course... From rjamesjr at earthlink.net Thu Mar 30 00:58:14 2000 From: rjamesjr at earthlink.net (Rich James) Date: Thu, 30 Mar 2000 05:58:14 GMT Subject: Where is the Tools directory supposed to be??? Message-ID: <38E2E8BD.F86F80C9@earthlink.net> Well, I'm befuddled. I've looked everywhere for the Tools directory in my file system and can't locate it. Actually, what I am looking for is webchecher.py, which I understand lives in the Tools/webchecker directory. Anyhow, none of that exists on my Redhat 6.0 system. I've checked www.python.org, but could not locate any information there on this. Also, I checked the RPMs at rufus.w3.org and found none that contained either Tools or webchecker. And, I've searched usenet using deja.com to no avail. What am I missing? I'm sure the answer is obvious and stupid, but I sure can't seem to figure it out. Thanks for any and all help! -- War is just one more big government program. -- Joseph Sobran --- Rich James rjamesjr at earthlink.net From rhicks at nospam.rma.edu Wed Mar 22 20:43:34 2000 From: rhicks at nospam.rma.edu (Robert Hicks) Date: Thu, 23 Mar 2000 01:43:34 GMT Subject: Tkinter Documentation References: <38D934CA.6AE0292F@maptel.es> Message-ID: Python and Tkinter programming by John E Grayson http://www.manning.com/grayson Fantastic!!! Bob "Oscar Bosca" wrote in message news:38D934CA.6AE0292F at maptel.es... > Hi all ! > > My question is very simple. > Where could I find the most complete documentation about Tkinter? I > have the Fredik Lundh's book but it looks incomplete. > > Thanks in advance. > Oscar. > From greg at perceval.be Fri Mar 3 10:29:47 2000 From: greg at perceval.be (Gregoire Welraeds) Date: Fri, 3 Mar 2000 16:29:47 +0100 (CET) Subject: MIMETOOLS QUESTION In-Reply-To: Message-ID: According to the Library reference doc, on page 244 (section 12.7) the package tool define a Message(fp[,seekable]). Wel, very cool... but what are fp and seekable after all ? All I want is to parse a MIME header from a string read on a socket... I found that, except for the tutorial, there is a lack of example in the python documentation. Python is not a strong typed language so it's pretty difficult to find the meaning of some arguments used in the API. Maybe Guido could take some example of the Faqts site to put them in the doc... Guido ? -- Life is not fair But the root password helps -- Gregoire Welraeds greg at perceval.be Perceval Development team ------------------------------------------------------------------------------- Perceval Technologies sa/nv Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels general information: info at perceval.net BELGIUM technical information: helpdesk at perceval.net URL: http://www.perceval.be/ ------------------------------------------------------------------------------- From mikael at isy.liu.se Wed Mar 1 04:20:22 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 01 Mar 2000 10:20:22 +0100 (MET) Subject: Empty String in HREF Args and cgi.py In-Reply-To: <38BCA532.CB2D275D@worldnet.att.net> Message-ID: On 01-Mar-00 Joseph C. Kopec wrote: > Is it possible to put an empty string ("" -- not a blank space) in a URL > argument list? For instance, in > > "/cgi-bin/myscript?val1=one&val2=XXX&val3=three" > > what should be in place of XXX for val2 to be an empty string? Is there > an HTML character entity for an empty string (as opposed to for a > space)? Would "" or '' work? Or should I just leave XXX blank, like > "...val2=&val3=three". Thanks in advance. I've used empty strings successfully. But then, I've written the code that decodes the argument myself. I've not used any magic modules, since I wrote that code before I was aware of the massive variety of modules available. I say: Give it a try! /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-Mar-00 Time: 10:15:46 This message was sent by XF-Mail. ----------------------------------------------------------------------- From tomng92 at sympatico.ca Sun Mar 19 21:23:14 2000 From: tomng92 at sympatico.ca (Thanh Nguyen) Date: Mon, 20 Mar 2000 02:23:14 GMT Subject: Newbie: Can Python replace unix scripts ? Message-ID: I am from the win32 world and about to do some unix programming. I am scared stiff of the csh scripts because they are in my point of view, unreadable. Can Python spare me of that csh scripting ? Or may be somebody point me to some other scripting language that are more user friendly than those unix scripting languages ? thanks. From mwh21 at cam.ac.uk Thu Mar 2 06:46:47 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Mar 2000 11:46:47 +0000 Subject: Get dictionary-keys used to format a string References: <38BE41F9.F2E9297A@inka.de> Message-ID: Michael =?iso-8859-1?Q?Str=F6der?= writes: > Hence the example from the Python docs: > > '%(language)s has %(count)03d quote types.' % vars() > > I would like to extract the keys in the formatting string to a list. > Well I can parse it myself but is there a built-in function to > extract a list/tuple of the dictionary keys, e.g. > ['language','count'] in this case? > Don't think so, sorry. Cheers, M. -- very few people approach me in real life and insist on proving they are drooling idiots. -- Erik Naggum, comp.lang.lisp From c.kotsokalis at noc.ntua.gr Sat Mar 18 15:42:58 2000 From: c.kotsokalis at noc.ntua.gr (Constantinos A. Kotsokalis) Date: 18 Mar 2000 20:42:58 GMT Subject: Detecting if Linux Program Running References: <38D3E018.A705C7EC@worldnet.att.net> Message-ID: On Sat, 18 Mar 2000 20:03:29 GMT, Joseph C. Kopec wrote: >Is there any easy way using Python under Linux to detect whether a >particular executable is running? Thanks in advance. The easiest but not reliable way should be lock files (i.e. files you usually find under /var/run). Process creates file, process checks for file, story goes on. Actually this technique is practiced by a whole lot of applications no matter if they are written in Python or some other language. I repeat though, it's not a reliable method. -- Constantinos A. Kotsokalis || c.kotsokalis at noc.ntua.gr National Technical University of Athens Network Management Center Tel. No: +30 1 7721861 From moshez at math.huji.ac.il Wed Mar 1 13:35:35 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 1 Mar 2000 20:35:35 +0200 (IST) Subject: A comp.lang.python code snippet archive? In-Reply-To: <200002291944.UAA29289@dionysus.fw.cuci.nl> Message-ID: On Tue, 29 Feb 2000, Hans Nowak wrote: > Maybe some kind of "Python code detector" could be helpful, if only for a > first rough scan of all the messages. I have no idea how to do this though. > (In Perl it's easy, you simply check if the number of $'s is above > average... ) Maybe it should look for reserved words like def or > import? But a snippet is not guaranteed to include those words, and a > message which does use them is not guaranteed to have Python code. =/ > > Ideas, anyone? Yes: why not have a pysnippets at something.something, which you can CC on any message, and have it automatically appear in a snippets page? I know I wouldn't mind adding the CC: for snippets I post. -- Moshe Zadka . INTERNET: Learn what you know. Share what you don't. From anderbj at my-deja.com Tue Mar 7 04:27:23 2000 From: anderbj at my-deja.com (anderbj at my-deja.com) Date: Tue, 07 Mar 2000 09:27:23 GMT Subject: Problems with python in asp Message-ID: <8a2i1o$an2$1@nnrp1.deja.com> Hi Maybe this is very trivial, but I hope you folks can give me a hand anyway. I'm trying to use python with asp and run this code on IIS 4.0 The installation and configuration of IIS with the python script engine is correct and works fine. That is I can run .py files and some .asp files containing python. Finally here's the prob. <%@ LANGUAGE = Python %> <% import string %> <% category = Request.QueryString("cat") if category == "mainmenu": #Line 10 %> <%= category %> <% else: %> <%= category %> The variable category contains the parameter (I've used the win32traceutil to confirm that). This code generates the errormsg below. I've tried several different ways to cope with this prob, and two problems keep coming up: I can't check if category equals "somestring" and there is problems with the if condition. Hope you guys have a solution for this Thanks in advance Bj?rn ##Errormsg Python ActiveX Scripting Engine error '80020009' invalid syntax /SCRIPTS/di.asp, line 10 Sent via Deja.com http://www.deja.com/ Before you buy. From _spam_sux_tdfunk at _spam_sux_nettally.com Tue Mar 14 16:36:33 2000 From: _spam_sux_tdfunk at _spam_sux_nettally.com (Tom Funk) Date: Tue, 14 Mar 2000 16:36:33 -0500 Subject: UserList.__getslice__(): copy.copy(self.data) vs. self.__class__(self.data). Message-ID: In the Python Reference Manual, Section 3.3.5, "Additional methods for emulation of sequence types", we find the following entry: ... __getslice__ (self, i, j) Called to implement evaluation of self[i:j]. The returned object should be of the same type as self. Note that missing i or j in the slice expression are replaced by zero or sys.maxint, respectively, and no further transformations on the indices is performed. The interpretation of negative indices and indices larger than the length of the sequence is up to the method. ... The current implementation of UserList.__getslice__(), looks like this: def __getslice__(self, i, j): i = max(i, 0); j = max(j, 0) userlist = self.__class__() userlist.data[:] = self.data[i:j] return userlist Though this follows the guidelines outlined in the reference manual, it has an interesting side effect: it instantiates a new object of the same class but it loses the current values of all attributes. Is this desireable behavior? Personally, I don't believe that it is. My thinking is that the current internal state of the class should pass to the newly instantiated object. I think a better implementation would be: def __getslice__(self, i, j): i = max(i, 0); j = max(j, 0) userlist = copy.copy(self) userlist.data[:] = self.data[i:j] return userlist Also, should the i and j arguments be "adjusted" before being used to access the list in self.data? Again, in the Python Reference Manual, section 5.3.3 "Slicings," we find: The lower and upper bound expressions, if present, must evaluate to plain integers; defaults are zero and the sequence's length, respectively. If either bound is negative, the sequence's length is added to it. So, the runtime normalizes negative numbers so that small-enough (large enough??) negative numbers start counting from the end of the sequence. i.e., aList[-1] returns the last element in the aList. As currently written, UserList converts to zero any negative numbers that would otherwise raise an IndexError. The resulting behavior is that a slice is returned rather than an IndexError being raised, thus: >>> ul=UserList.UserList([0,1,2,3,4]) >>> ul[-1] # last element 4 >>> ul[-3:-1] # 3rd- and 2nd-to-the-last elements [2,3] >>> ul[-10] # calls UserList__getitem__(self,i) Traceback (innermost last): File "", line 1, in ? File "UserList.py", line 29, in __getitem__ def __delitem__(self, i): del self.data[i] IndexError: list index out of range >>> ul[-10:-1] # should raise IndexError [0, 1, 2, 3] >>> Again, at least to me, this behavior seems to be to be inconsistent with a "real" list object. I think this is a better implementation: def __getslice__(self, i, j): userlist = copy.copy(self) userlist.data[:] = self.data[i:j] return userlist I'd be more than happy to implement these changes (there are a couple of places where self.__class__() is called and where method arguments are normalized to zero) and submit the context diffs -- unless I'm overwhelmed with arguments to the contrary. Since UserList.py is part of the standard distribution, and could break existing code if changes are made, I wanted to bounce this off of the community before proceeding. I'm using UserList in a current project and I've already implemented these changes into a NewUserList class. Submitting context diffs would be a piece of cake. Any feedback? Should I proceed? -- -=< tom >=- Thomas D. Funk (tdfunk at asd-web.com) | "Software is the lever Software Engineering Consultant | Archimedes was searching for" Advanced Systems Design, Tallahassee FL. | From mhammond at skippinet.com.au Wed Mar 15 04:39:32 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 15 Mar 2000 09:39:32 GMT Subject: Debugging? References: <9JFz4.19$GJ3.1756@news7.onvoy.net> Message-ID: "chris davis" wrote in message news:9JFz4.19$GJ3.1756 at news7.onvoy.net... > Ok, I just need to know the best way to debug my python scripts? If this is > a stupid question, I apologize, but I currently use IDLE and it's completely > useless when it comes to debugging. It locks up on both my window and Linux > machines and doesn't set break points! Is there another way? another IDE? > anything? If there isn't that's fines, I can wait until IDLE is fully > developed, but I just don't want to waste my time searching. I believe the only other graphical debugger available for Python today is Pythonwin. Mark. From alex at somewhere.round.here Tue Mar 28 15:54:05 2000 From: alex at somewhere.round.here (Alex) Date: 28 Mar 2000 15:54:05 -0500 Subject: Switch a terminal to gud-mode Message-ID: Hi. In emacs, I would like to be able to switch a py-shell buffer to gud-mode when I enter the python debugger, and then switch back to comint-mode when I drop back to the shell. Has anyone else attempted anything like this? Alex. From phd at phd.russ.ru Wed Mar 1 11:04:37 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 1 Mar 2000 16:04:37 +0000 (GMT) Subject: no pyc file In-Reply-To: <89jdnr$sg8$1@netnews.upenn.edu> Message-ID: On Wed, 1 Mar 2000, Samuel Nicolary wrote: > Is there a reason why a pyc file would not be created upon execution of my > script? PYC files aren't created for scripts - only for imported modules. But if modules do not have their .pyc's too - check for directory permissions... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From mwh21 at cam.ac.uk Fri Mar 17 04:12:19 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 17 Mar 2000 09:12:19 +0000 Subject: Project opinions please References: <38d1801d.356312540@news-server.columbus.rr.com> Message-ID: toth.22 at osu.edu (CT) writes: > What I need, is some advice on how to approach this project, what type > of issues will I need to consider, where should I start(#1 question > acutally) and what other things I will need to learn... Well, it's probably best to start small, ie. write a module that something very simple. I generally work with an emacs buffer containing the file I'm working on and an xterm containing a Python interpreter that I use to test it. Then write the other modules to do what you want, and write the daemon that does all these things at the right time, and you're done. HTH, Michael -- very few people approach me in real life and insist on proving they are drooling idiots. -- Erik Naggum, comp.lang.lisp From jstok at bluedog.apana.org.au Sat Mar 25 05:55:18 2000 From: jstok at bluedog.apana.org.au (Jason Stokes) Date: Sat, 25 Mar 2000 21:55:18 +1100 Subject: else clauses in while and for loops References: Message-ID: Tomek Lisowski wrote in message ... >Hi! > >Which is the reason for else clauses in while and for loops? >From the Python language reference, section 7.2: A break statement executed in the first suite terminates the loop without executing the else clause's suite. And from 7.3: A break statement executed in the first suite terminates the loop without executing the else clause's suite. A continue statement executed in the first suite skips the rest of the suite and continues with the next item, or with the else clause if there was no next item. From daniels at mindspring.com Mon Mar 13 21:35:49 2000 From: daniels at mindspring.com (Alan Daniels) Date: 14 Mar 2000 02:35:49 GMT Subject: Python good for translating GUI built in Java? References: <8ajmb7$8cs$1@once.cirl.uoregon.edu> Message-ID: On 13 Mar 2000 13:24:55 -0800, the infinitely wise Matthew L. Ginsberg (ginsberg at once.cirl.uoregon.edu) spoke forth to us, saying... >I've got a GUI application currently written in Java; it's about 16000 >lines. It does a reasonable amount of computation, but Java is such a >badly supported language that I'm thinking about porting it to >something else. Any language I use should be supported in both >Windows (where my customers are) and linux (where I am). It needs to >be reasonably fast, and reasonably good at all the usual windows >things -- file selection dialogs, popup menus, image manipulation, etc >etc. Another choice you should look at for a Python GUI is 'wxPython', available at: http://alldunn.com/wxPython This is a Python wrapper for 'wxWindows', a C++ GUI library which is cross-platform between Win32 and GTK. I've found it very enjoyable to use (and easier than Tkinter), and portability between Windows and Linux is *flawless*. Also, its coverage of various widget types is very thorough. You should take a look at it before deciding. BTW, just curious: What is it in Java that you find "badly supported"? I have my own compliants about Java, but lack of APIs or 3rd-party support aren't among them. Then-again-Python-has-a-%-sprintf-operator-and-Java-doesn'tly yours, Alan. -- ======================= Alan Daniels daniels at mindspring.com daniels at cc.gatech.edu From claird at starbase.neosoft.com Fri Mar 3 10:57:49 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 3 Mar 2000 09:57:49 -0600 Subject: Splitting comp.lang.python References: <019601bf843c$b216b500$0201a8c0@spkydomain> <38BF1E16.7AD5FE93@mincom.com> Message-ID: <3572DB0C6C3EE456.0F7DD462C78FAF91.B661EE7244D9906C@lp.airnews.net> In article <38BF1E16.7AD5FE93 at mincom.com>, John Farrell wrote: . . . >I would also like to see a newsgroup for people who are working on the >Python implementation, but I can't think of a good name for it. . . . "[T]he Python implementation"?!? My rough extrapolations lead me to conclude that somewhere near the year 2037 there'll be more Python implmentations than there are Python programmers -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From ginsberg at once.cirl.uoregon.edu Mon Mar 13 16:24:55 2000 From: ginsberg at once.cirl.uoregon.edu (Matthew L. Ginsberg) Date: 13 Mar 2000 13:24:55 -0800 Subject: Python good for translating GUI built in Java? Message-ID: <8ajmb7$8cs$1@once.cirl.uoregon.edu> My apologies for asking what is surely a well-known question in this forum. I've got a GUI application currently written in Java; it's about 16000 lines. It does a reasonable amount of computation, but Java is such a badly supported language that I'm thinking about porting it to something else. Any language I use should be supported in both Windows (where my customers are) and linux (where I am). It needs to be reasonably fast, and reasonably good at all the usual windows things -- file selection dialogs, popup menus, image manipulation, etc etc. Would Python be a reasonable choice? Thanks for any advice! Matt Ginsberg From prestonlanders at my-deja.com Mon Mar 13 16:28:51 2000 From: prestonlanders at my-deja.com (Preston Landers) Date: Mon, 13 Mar 2000 21:28:51 GMT Subject: Choice Of Language (was: Python Advocacy) References: Message-ID: <8ajmib$elo$1@nnrp1.deja.com> Well, I currently do 100% of my current professional development in Python. So there's at least enough in the language to keep me busy in a full time back-end development job. Actually, this may change in the future as I'll likely be doing more work in Java (particularly a Swing application) but that's okay because Java's not half bad, and there is always the opportunity to squeeze JPython in there. JPython actually is quite nice for testing Java classes, I understand. PS If you want to know where I work you'll have to email me directly. thanks, ---Preston In article , "Don Tuttle" wrote: > I have never programmed for a living. (I enjoy it way too much to ever do > that! ) So let me ask all you folks that do. What percentage of > your paid, professional time do you get to use Python? -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From dana at mmi.oz.net Fri Mar 17 14:35:57 2000 From: dana at mmi.oz.net (Dana Booth) Date: 17 Mar 2000 19:35:57 GMT Subject: MySQLModule???? Message-ID: <8au1et$fc7$0@216.39.141.36> What am I doing wrong???? Okay, a couple of weeks ago, I tried to build the MySQLModule on an OpenBSD (2.5) computer. I get errors, "lvalue required" in lines 384, 1125, and 1147 of the source. I tried to build it on a Linux (Mandrake 6.0) and received the very same error. Today, I tried to build it on Windows (Visual C++), and the very same errors. I can get by in C, and I looked at the source, but not having done it, it's difficult to debug. I can't be the only one to have this happen! Please, if one of you know what I'm doing wrong, tell me! -- ----- Dana Booth Tacoma, Wa., USA key at pgpkeys.mit.edu:11371 From aa8vb at yahoo.com Wed Mar 29 16:52:45 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 29 Mar 2000 16:52:45 -0500 Subject: Purify & Python - problems In-Reply-To: References: <20000329122020.A979022@vislab.epa.gov> Message-ID: <20000329165245.A981111@vislab.epa.gov> Jeff Senn: |Randall Hopper writes: |> > python |> Segmentation fault (core dumped) |> |> It fails right away, core dumping while doing a legitimate sprintf. |> Anyone hit this before? |... |> ABR: Array bounds read: | |Since it is a *read* that is failing it probably has nothing to do |with the sprintf -- you've probably managed to have DATE or TIME |#defined to something other than a (pointer to a) null-terminated |readable string when you compiled modules/getbuildinfo.c.... Given what I'd tried beforehand, I was pretty sure it wasn't a value problem. Inserting dummy printfs before the sprintf would core dump it as well. It looked like a dynamic linking problem. Turns out that purify doesn't want to work on IRIX o32 binaries anymore (been a while since I'd used it on IRIX). It appeared to purify the exec with no problems, but the simplest "hello world" program produces similar purify output when compiled o32. Switch hello-world to n32, and it works. Thanks, -- Randall Hopper aa8vb at yahoo.com From bhoel at starship.python.net Mon Mar 27 16:01:48 2000 From: bhoel at starship.python.net (Berthold Höllmann) Date: 27 Mar 2000 23:01:48 +0200 Subject: Bug in module time: localization? References: <16600602@oberon.noris.de> <16600605@oberon.noris.de> Message-ID: "hartmut Goebel" writes: > Berthold H?llmann (bhoel at starship.python.net) schrieb: > ... > > I will try this workaround. But I still wonder why Python ignores my > environment settings?! It's no workaround. Programs only honour the locale settings if you tell them so. An when you write Python Programs, and want to use the locale settings, you have to tell it. An you do this with the locale module. Cheers Berthold -- bhoel at starship.python.net / http://starship.python.net/crew/bhoel/ It is unlawful to use this email address for unsolicited ads (USC Title 47 Sec.227). I will assess a US$500 charge for reviewing and deleting each unsolicited ad. From jeffk at jdkoftinoff.com Wed Mar 1 20:22:51 2000 From: jeffk at jdkoftinoff.com (Jeff Koftinoff) Date: Wed, 1 Mar 2000 17:22:51 -0800 (PST) Subject: Postgres+Python+Win32 ? In-Reply-To: <38BDC0D0.CC9B18F8@exceptionalminds.com> Message-ID: On Wed, 1 Mar 2000, Timothy Grant wrote: > Jeff Koftinoff wrote: > > > > Hi. > > > > I have a linux box running postgresql and python, and am able to access the > > database remotely from another linux box. Now I want to be able to access the > > remote postgresql database from a win32 box running python. I found someplace > > the postgresql client DLL library from win32, but has anyone made a pgsql or > > whatever for win32? > > Having just been through this, I believe that the easiest solution would > be to use ODBC. You can download a PostgreSQL ODBC driver from the > PostgresSQL ftp site, and then use either the ODBC module that ships > with the Win32 extensions to Python, or download the excellent mxODBC > and use it. > > I have successfully been able to code with mxODBC/Tkinter and had the > code developed on my Linux box run pretty much immediately on a Win box. > Thanks for the info! But what is the best way to use odbc with postgresql under linux with python (because of course I prefer using linux, i just need portability)... best regards jeff -- Jeff Koftinoff http://www.jdkoftinoff.com/ From kc5tja at garnet.armored.net Mon Mar 20 21:53:49 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 21 Mar 2000 02:53:49 GMT Subject: Forth like interpreter References: <158801bf8bdc$08516040$6401a8c0@dorb> <53YA4.637$jX3.10074@typhoon.nyroc.rr.com> <425A5D00B0F916D1.7920112131B1A88A.D3428C8A56515B00@lp.airnews.net> Message-ID: In article , William Tanksley wrote: >Here, have some cycles of reversed kielbasa. And ten (10 (0xa (101010b))) 101010b is 2+8+32, or 42, not 10. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From cpr at emsoftware.com Mon Mar 27 09:13:58 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Mon, 27 Mar 2000 14:13:58 GMT Subject: JPython vs. Javascript? References: <38DF007A.64AFBE6E@tamu.edu> Message-ID: I think you're conflating Javascript with Java. They're completely different beasts. Javascript is most often used embedded in web pages to do client-related (DHTML) work (what it sounds like you want to do), usually mucking with the HTML of a given page dynamically. Javascript (in this case) is built in to the browser, and (in modern browsers, e.g., IE 4/5, NS 4) can be used to do some fairly complex things. Java applets (and thus JPython applets) usually run in a little "visual sandbox" (to say nothing of their file system sandbox), i.e., a rectangular portion of a web page. They can't really do the kinds of things that Javascript scripts can do, in terms of augmenting the overall UI of a web page. -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com "Kojo Idrissa" wrote in message news:38DF007A.64AFBE6E at tamu.edu... > Hello all. I am new to Python and I've got a question (surprise). I'm > teaching myself Python, but I'm also thinking about doing some stuff > with Javascript to add some functionality to some web-pages (surveys, > on-line tests, allowing people to interact through the web and "respond" > to a site). > > My question is this: How do JPython/Java applets compare with > Javascript from a functionality standpoint? I'm thinking it would be > nice to not worry about learning another language and get more mileage > out of my knowledge of Python by using JPython to turn Python code into > Java applets. I'm just not sure of the pros and cons. My guess is that > it's probably more an Applet vs. Javascript question, but I'm not sure. > Any insight would be appreciated. From a.eyre at optichrome.com Fri Mar 3 11:59:55 2000 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 3 Mar 2000 16:59:55 -0000 Subject: Checking Python version in a program In-Reply-To: Message-ID: <000301bf8531$e651de80$3acbd9c2@optichrome.com> > oh, I thought I was more of a BBFH. at least > compared to the Eloquent Bot From Boston ;-) I've always suspected you were, in fact, a bot. ;) Wondering-if-you-share-any-base-classes-with-tim-bot-ly y'rs Adrian From donn at u.washington.edu Fri Mar 17 19:14:57 2000 From: donn at u.washington.edu (Donn Cave) Date: 18 Mar 2000 00:14:57 GMT Subject: system calls to sh References: <38D295F8.C88CD9E4@stsci.edu> Message-ID: <8auhq1$obu$1@nntp6.u.washington.edu> Quoth "Kia A. Arab" : | I can't seem to affect environment variables using os.system calls. I | don't know if this makes a difference, but the variables are set in c | shell. I try to unset them from a python script like so: | | os.system('unset MY_VAR') | os.system('export MY_VAR') | os.system('echo $MY_VAR') # not unset! Each system() call forks its own shell process to execute the command, so each is a sort of miniature script. It modifies its own environment, and when it exits that environment is forgotten. I assume your environment variable was inherited from Python, that's what would happen normally. Python's os.environ allows you to look at the environment as a dictionary, and you can modify variables and see the result in the system() - os.environ['MY_VAR'] = 'new value' os.system('printenv MY_VAR') But unfortunately it's kind of hack that synchronizes the environment with os.environ, changing the former when the latter is changed, and while you can update a variable, you can't delete one. If you really want to do it, the system() call is really a pretty simple wrapper around a few more capable functions. def esystem(cmd): pid = os.fork() if pid: p, s = os.waitpid(pid, 0) return (s >> 8) & 0x7f else: os.execve('/bin/sh', ('sh', '-c', cmd), os.environ) os._exit(111) (Hope I remember that right!) This gives the shell command a copy of the environment you modify, so deletion works. Donn Cave, donn at u.washington.edu From ndev42 at yahoo.com Fri Mar 10 04:56:19 2000 From: ndev42 at yahoo.com (Nicolas Devillard) Date: Fri, 10 Mar 2000 01:56:19 -0800 (PST) Subject: Python, SWIG and pointers Message-ID: <20000310095619.19928.qmail@web3606.mail.yahoo.com> I have a C library and I have to make bindings to Python using SWIG. The problem I have is: how to handle pointers to pointers? If I have the following data struct in C: typedef struct _OBJ_ { ... } obj ; And the associated constructor, used as: obj * b ; a = new_obj() ; Then there are functions expecting a pointer to a pointer to struct for modification, something like: modify_obj(&a); The SWIG-generated binding for new_obj() will return an opaque object that is compatible with a pointer to obj, but how do I pass it in Python to modify_obj(), that is expecting a pointer to this opaque object? Do I need to declare some type conversion by hand or is there a way to make SWIG aware of that kind of pointer to pointer? Thanks for helping -- Nicolas __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com From junkster at nospam.rochester.rr.com Mon Mar 13 19:27:22 2000 From: junkster at nospam.rochester.rr.com (Benjamin Schollnick) Date: Tue, 14 Mar 2000 00:27:22 GMT Subject: Server program w/Plugins? Anyone have suggestions for improvements? Message-ID: Folks, In my quest for the "perfect" server design.... I came up with a plugin system, that works fine.... But I'm wondering if there is a easier way to do this....: Plugin's are structured like this, with filename of PORTx.PY, where X is 0..Max port number (I.e. port1, port37, etc) Any suggestions & improvements are welcome. This server system will probably join the "Auto Update System", and "Time Server / client" on Source forge once I polish it up some more. - Benjamin ---------------------------- def startup (): print "starting port 001" def port_number(): return 1 def return_data( connection ): return 'port1' #print "port 001 imported" -------------------------- There server, reads the local directory, and imports the files.... Builds a table with the address's of the functions.... -------------------------- import os import select from socket import * import string import struct import sys import time def run_command (text): exec (text) # # Find the Port*.py files in the current directory # def define_port_packages (): importthese = [] filelist = os.listdir ('./') for name in filelist: if (string.upper(name[0:4]) == 'PORT') and (string.upper(os.path.splitext(name)[1]) == '.PY'): importthese.append (os.path.splitext(name)[0]) return importthese # # Import the Port*.py files # def import_packages ( importthese ): import_command = "import " imported_data = [] for name in importthese: exec (import_command + name) import_details = "tempdata = ("+name + ".port_number, "+name+".return_data)" exec (import_details) imported_data.append (tempdata) try: import_details = name+".startup()" exec (import_details) except: print name+" does not have a startup function" return imported_data files = define_port_packages() data = import_packages ( files ) # # Bind the port(s) # sock_list = [] for count in range(0, len(data)): sock_list.append (socket (AF_INET, SOCK_STREAM)) sock_list[len(sock_list)-1].bind ('', data[count][0]() ) sock_list[len(sock_list)-1].listen(5) sock_list[len(sock_list)-1].setblocking(0) while 1: for count in range(0, len(sock_list) ): temp_connection = [] temp_connection.append(sock_list[count]) ready_read, ready_write, in_error = select.select(temp_connection, temp_connection, temp_connection, 1) for conn in ready_read: goodconnection = (conn, addr) = conn.accept() conn.send (data[count][1]( conn ) ) conn.close() #time.sleep(1) -------------------------------------- Bonus, here's the Time Server rewritten as a plugin. import configf import struct import sys import time import tji_logfile def port_number(): port_id_number = 37 return port_id_number def port_name(): name_of_port = "Date/Time" return name_of_port def timeserver_calculation(): total = configf.return_epoch()+ time.time() return total def return_data( connection ): ft = timeserver_calculation() lt = long(ft) packed = struct.pack("!L", lt) return packed if __name__ == "__main__": pass ==================================================== (Remove "NoSpam" to Email me) ==================================================== Please feel free to copy any and or all of this sig. A little something for spam bots: root at localhost postmaster at localhost admin at localhost abuse at localhost postmaster at 127.0.0.1 Chairman William Kennard: bkennard at fcc.gov Commissioner Susan Ness: sness at fcc.gov Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov Commissioner Michael Powell: mpowell at fcc.gov Commissioner Gloria Tristani: gtristan at fcc.gov consumerline at ftc.gov fccinfo at fcc.gov ssegal at fcc.gov From ljoramo.list at nickads.com Tue Mar 28 18:46:38 2000 From: ljoramo.list at nickads.com (Lee Joramo) Date: Tue, 28 Mar 2000 16:46:38 -0700 Subject: Installing pgsql (PostgreSQL Interface) results in swig errors Message-ID: I am having problems installing pgsql on Cobalt RAQ3 system. (Essentially, a modified Redhat installation). I think that I now have the paths in config.cache correctly setup, but when I do "make" I get the following results: ------ (cd swigsrc; make; cd ..) make[1]: Entering directory `/home/sites/site1/users/ljoramo/temp/pgsql/swigsrc' swig -python -shadow -I/usr/include/pgsql pgsqldb.i make[1]: swig: Command not found make[1]: *** [pgsqldb_module.c] Error 127 make[1]: Leaving directory `/home/sites/site1/users/ljoramo/temp/pgsql/swigsrc' gcc -fpic -g -O2 -I/usr/include/python1.5 -I/usr/include/python1.5 -DHAVE_CONFIG_H -c ./pgsqldb_wrap.c ./pgsqldb_wrap.c:320: parse error before `(' make: *** [pgsqldb_wrap.o] Error 1 ------ I have looked for information related to "swig" in the various python list archives and get the feeling that it is a program that I do not have on my system. But I could find nothing definitive. I have searched by system for swig and found nothing. Thanks -- Lee A. Joramo ljoramo at nickads.com The Nickel Want Ads www.nickads.com Internet Manager 970-242-5555 -- Onward and Upward! Lee A. Joramo }}-----> Cowboy on the Electronic Frontier lee at joramo.com Alamar Ranch - Palisade - Colorado ThreeRivers|Eagle|UCD|D&D|TNC|DX|Mac|221B|Cannondale|Deutsch From Jan.Kybic at epfl.ch Wed Mar 8 13:45:29 2000 From: Jan.Kybic at epfl.ch (Jan Kybic) Date: 08 Mar 2000 19:45:29 +0100 Subject: Delivering dynamic content using cgi module References: <01BF88F3.E49BCEF0.shichang@icubed.com> Message-ID: > Assume a single dynamically generated document as following: > ... >
Hello
> > Content-Type: image/gif > > < ---open a .gif file, read data, and print it to stdout --> > > Content-Type: image/pjpeg > > < ---open a .jpg file, read data, and print it to stdout --> > > > How to deliver it using CGI? A simple example script would be very helpful. I am not posting an example code because mine is too long and application specific. But roughly the idea of my approach is to send a document like:
Hello
and to write the two image files on a disk or in a database (which can be kept in memory. The browser will issue requests for the two images to your webserver which must be intelligent enough to serve them - from a disk file or from a database. For this, you need customizable web server - I used threaded version of BaseHTTPServer with a request handler from CGIHTTPServer. I use a timer to delete the temporary files after certain delay. Hope this helps Jan -- ------------------------------------------------------------------------- Jan Kybic BIG IOA DMT EPFL Lausanne, Switzerland http://bigwww.epfl.ch/kybic tel. work +41 (21) 693 5142 For PGP key see my WWW page. From sholden at bellatlantic.net Wed Mar 1 12:44:11 2000 From: sholden at bellatlantic.net (Steve Holden) Date: Wed, 01 Mar 2000 17:44:11 GMT Subject: Newbie: Reading textfiles References: <8EEABCE7DLutzSchroeeraltavist@139.174.2.56> Message-ID: <38BD56EC.BE9603AE@bellatlantic.net> The first call to readline() which returns an empty string indicates you have hit the end of the file. Empty lines in the file are returned as strings with the newline still in them. Don't forget that every line you actually read has the newline in it, too! Unless the files are too large to consider this, the readlines() file method is easier to use. But you've probably already rejected this by the way you state your question. regards Steve "Lutz Schr?er" wrote: > > Hi, > > after looking for a"clever" solution for reading a text file line by line > from the beginning to the end for the whole day, I have to ask this > ridiculous newbie question: > > How do I read a textfile line by line and catch the eof? > > Latz -- "If computing ever stops being fun, I'll stop doing it" From mhammond at skippinet.com.au Wed Mar 8 17:12:37 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 08 Mar 2000 22:12:37 GMT Subject: Odd COM problems with VC References: <8a6cq6$421$1@nnrp1.deja.com> Message-ID: wrote in message news:8a6cq6$421$1 at nnrp1.deja.com... > I'm trying to use Python's COM facilities to > control a build in Visual C++. > I've run into some problems that don't make sense > to me at all (not surprising, > since I don't know COM). Hopefully Roger's code has got you on the right track. > But here's the odd thing: > from this point on, no matter what I type at the > PythonWin prompt, a dialog appears > that says: > > 'The topic does not exist. Contact your > application vendor for an updated > Help file (129)' hehe - I just responded to this bug 30 seconds ago - it is a bug in the interactive window (Pythonwin thinks you have selected the COM error line, and is attempting to open the help topic for you) - try removing the last error line with the mouse. Mark. From greg at perceval.be Sat Mar 4 16:53:56 2000 From: greg at perceval.be (Gregoire Welraeds) Date: Sat, 4 Mar 2000 22:53:56 +0100 (CET) Subject: MIMETOOLS QUESTION In-Reply-To: Message-ID: In reply to the message of Fredrik Lundh sent on Mar 3 (see below) : > fwiw, there's plenty of cookbooks out there. here are a few: Ok... but it could be very smart if basic example could be inserted in the (how should I call it ... official ?) doc. And have advanced topics and discussion in other resources. Any reaction ? -- Life is not fair But the root password helps -- Gregoire Welraeds greg at perceval.be Perceval Development team ------------------------------------------------------------------------------- Perceval Technologies sa/nv Tel: +32-2-6409194 Rue Tenbosch, 9 Fax: +32-2-6403154 B-1000 Brussels general information: info at perceval.net BELGIUM technical information: helpdesk at perceval.net URL: http://www.perceval.be/ ------------------------------------------------------------------------------- On Fri, 3 Mar 2000, Fredrik Lundh wrote: > Date: Fri, 03 Mar 2000 19:39:51 GMT > From: Fredrik Lundh > To: python-list at python.org > Newsgroups: comp.lang.python > Subject: Re: MIMETOOLS QUESTION > > Gregoire Welraeds wrote: > > According to the Library reference doc, on page 244 (section 12.7) the > > package tool define a Message(fp[,seekable]). Wel, very cool... but what > > are fp and seekable after all ? > > the copy I have points out that mimetools.Message is a sub- > class of rfc822.Message. the arguments are well explained > in that chapter... > > > All I want is to parse a MIME header from a string read on a socket... > > the Message takes any file object which properly implements > "readline". you can use StringIO to access your string as if > it were a file -- or in this case, you can use "makefile" on the > socket to wrap the socket itself in a file object. > > > I found that, except for the tutorial, there is a lack of example in the > > python documentation. Python is not a strong typed language so it's pretty > > difficult to find the meaning of some arguments used in the API. > > > > Maybe Guido could take some example of the Faqts site to put them in the > > doc... Guido ? > > better make that "Fred" > > fwiw, there's plenty of cookbooks out there. here are a few: > > + Python Annotated Archives (by Martin Brown): > > http://www.python.org/psa/bookstore > > 50+ sample scripts from various sources; extensive > annotations by the author. massive piece of work. > > + Programming with Python (by Tim Altom): > > http://www.python.org/psa/bookstore > > have only browsed it, but it appears to be a budget > version of the annotated archives. early reviewers > seem to think it's no good, so you may wish to check > it out in a bookstore before buying it. > > + The Python Grimoire (by Andrew Kuchling): > > http://starship.python.net/crew/amk/grimoire/ > > work in progress; sample scripts from various (mostly > unattributed?) sources; sorted by task. (like martin's > book, this seems to contain some eff-bot code, so it > cannot be all bad ;-) > > + (the eff-bot guide to) The Standard Python Library, > eMatter edition (by Fredrik Lundh): > > http://www.pythonware.com/people/fredrik/librarybook.htm > > 320 sample scripts, sorted by standard library module. > more code and less annotations than the others (after > all, python code is supposed to be easy to read ;-). > > > > > -- > http://www.python.org/mailman/listinfo/python-list > > From alex at somewhere.round.here Tue Mar 28 18:33:32 2000 From: alex at somewhere.round.here (Alex) Date: 28 Mar 2000 18:33:32 -0500 Subject: Exec with loops References: <8breac$39i$1@nnrp1.deja.com> Message-ID: Sorry, looks like my example was excessively complex. Alex. From neilh at hare.net.au Thu Mar 23 18:50:05 2000 From: neilh at hare.net.au (Neil Hodgson) Date: Fri, 24 Mar 2000 10:50:05 +1100 Subject: Python tutorial/comparison for C++ programmer References: <8b956c$9tn$1@nnrp1.deja.com> <077C600D9F281A4D.487194D3E94C88DA.D53DE68986E89418@lp.airnews.net> <8bcr2a$b76$1@nnrp1.deja.com> Message-ID: <011a01bf9522$8af39870$3cdd3fcb@neil> > Maybe I overstated the case a little, and it's true that all those > CDROMs with py152.tgz on them won't disappear, but two bad things > certainly would happen. All current venues for Python help (such as > this newsgroup) would be rendered instantly useless by the huge influx > of MSPy newbies, making today's newbies look like tenured brain > surgeons. One of the main directions in Python, and certainly a topic that Guido is very involved with is to make Python a better language for new users. CP4E is Computer Programming for /Everybody/ and that includes (and possibly should be particularly targetted at) 'MSPy newbies'. I would be only too happy to use a Microsoft implementation of Python. I might even pay for it. MSPy features that I would like to see include: 1) Integration into the same Visual Studio I am used to for developing C++. 2) Extensive documentation of the Windows Python extensions. 3) A faster implementation. Microsoft were prepared to put effort into ensuring Perl worked well on NT. How much effort might they be prepared to expend to say "Python runs 3 times faster on NT as Linux". Neil From effbot at telia.com Wed Mar 8 13:39:46 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 08 Mar 2000 18:39:46 GMT Subject: Python 1.6 and Python 3000's new features? References: <01BF88FC.654E7540.shichang@icubed.com> Message-ID: Shichang Zhao wrote: > Could someone point me where I can find Python 3000 new feature list? nope. it's not designed yet. for some ideas that might end up in Py3K, skip over to www.python.org and read Guido's presentation at the houston conference: http://www.foretec.com/python/workshops/1998-11/proceedings.html also read Guido's paper on CP4E: http://www.python.org/doc/essays/cp4e.html when you've done that, I can assure you that your guess is as good as mine (not as good as Guido's, of course, but he's got a time machine ;-) ... for the time being, I think everyone is better off if they think of "Python 3000" as a phrase used by Python developers when they really mean "what if we wouldn't have to care so much about back- wards compatibility"... or maybe "once we find some spare time" (heck, I don't think anyone knows exactly what 1.6 will contain yet, and there will most likely be a 1.7 after that ;-) From quinn at mono.ugcs.caltech.edu Tue Mar 7 00:39:48 2000 From: quinn at mono.ugcs.caltech.edu (Quinn Dunkan) Date: 7 Mar 2000 05:39:48 GMT Subject: sigchld vs. os.popen, os.command, etc. Message-ID: Ok, I know this is more of a general unix question, but when I set a handler for sigchld, it causes any library function which makes a child and wants to wiat() on it throw an IOError because my handler has already wait()ed. Is there any better solution than simply wrapping all such calls in try: ... except IOError: pass ? From moshez at math.huji.ac.il Sat Mar 4 08:11:10 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 4 Mar 2000 15:11:10 +0200 (IST) Subject: Self Nanny Message-ID: This egoless nanny check that every method has a first argument named "self". Please use it and enjoy! -------------- selfnanny.py ----------------------- #!/usr/local/bin/python import parser, symbol, types def check_file(file): return check_string(file.read()) def check_string(s): return check_ast(parser.suite(s)) def check_ast(ast): return check_tuple(ast.totuple(1)) # retain line numbers def check_tuple(tup, classname=None): if type(tup) != types.TupleType: return [] problems = [] if tup[0] == symbol.funcdef: if classname is not None: args = get_function_args(tup) if not args or args[0] != 'self': funcname, funcline = tup[2][1:] problems.append((funcline, funcname, classname)) classname = None if tup[0] == symbol.classdef: classname = tup[2][1] for t in tup[1:]: problems.extend(check_tuple(t, classname)) return problems def get_function_args(tup): ret = [] for t in tup[1:]: if t[0] == symbol.parameters: parameters = t arglist = () for t in parameters[1:]: if t[0] == symbol.varargslist: arglist = t for arg in arglist[1:]: if arg[0] == symbol.fpdef: ret.append(arg[1][1]) return ret def format_problem(problem): s = 'line %d: method %s in class %s missing first argument "self"' return s % problem def print_problems(problems): for problem in problems: print format_problem(problem) def nanny(filename): print_problems(check_file(open(filename))) if __name__=='__main__': import sys for filename in sys.argv[1:]: nanny(filename) --------------- selfnanny.py ------------------------------ -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html From jbekesi at my-deja.com Thu Mar 30 03:22:38 2000 From: jbekesi at my-deja.com (jbekesi at my-deja.com) Date: Thu, 30 Mar 2000 08:22:38 GMT Subject: PyGimp for Win32? Message-ID: <8bv2s1$5p9$1@nnrp1.deja.com> Hi folks, has anybody ventured to port the pygimp extension to win32-Systems? (Yes, I know, the Gimp on Win32 is *a bit* scratchy, but alas, this my production evironment ;-( Janos BEKESI Sent via Deja.com http://www.deja.com/ Before you buy. From cjc26 at nospam.cornell.edu Wed Mar 15 21:49:39 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Thu, 16 Mar 2000 02:49:39 GMT Subject: Chat system References: Message-ID: Pada Wed, 15 Mar 2000 15:36:04 -0500, Chris Armstrong bilang: | Another thing about the chat system: I need for it to be able to constantly | stream in new content while still being able to type in your message and | send it whenever you want. I know some programs like IRC clients do | this without having two processes (one for the streaming content and | one for the input). Oh, and one more thing, this'll all be using curses, | if it matters. You can do this using select() (in the "select" module :). You pass select three lists of file descriptors that you're waiting to do something with. One list is for files you're waiting to read from, another is for files you want to write to, and the third is for error conditions. Select blocks until one or more of those file descriptors are actually ready, or an error occurs on the one of the files you are watching for errors. You can also set a timeout if you need to. So, for what you want to do, you would call select inside an infinite loop. The arguments would be the socket you are listening to, and the file descriptor for stdin. Thus either data coming in on the socket, or a user pressing a key, will cause select to return the appropriate file desc.; from there your program can figure out what to do next. So you would do something like: soc=socket.fileno() in=sys.stdin.fileno() while 1: r, w, e = select([soc, in], [], [soc, in]) for fd in r: # process input Also, there's the asyncore module, which is a higher-level interface to all of this. -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ "IS I yes wardrobe yield [the] evaluation." member of A.H.M.A.D. From sada7681 at mail.usyd.edu.au Thu Mar 2 20:03:32 2000 From: sada7681 at mail.usyd.edu.au (Steven Adams) Date: Fri, 3 Mar 2000 12:03:32 +1100 Subject: dealing with a proxy References: <89mr33$4je$1@news1.wire.net.au> Message-ID: <89n2vq$8hi$1@news1.wire.net.au> hmm, I think I've found it, do i first: h = httplib.HTTP(proxyhost, proxyport) then send requests h.putrequest('GET', 'http://somehwere.somedomain') is there a better method? Steven Adams wrote in message news:89mr33$4je$1 at news1.wire.net.au... > Hi all, > > how do I format my request to get an url/socket when there is a proxy in the > middle? > > I can connect fine when there is no proxy, but I'm not sure what needs to be > done when there is, does the rquest need to be phrased differently, or do I > need to call some other function beforehand? > > any tips? > > thanks, Steven > > From milesrizzo at hotmail.com Thu Mar 23 16:18:57 2000 From: milesrizzo at hotmail.com (Miles Rizzo) Date: Thu, 23 Mar 2000 16:18:57 -0500 Subject: Problem Embedding PythonWin in VC++ 6 Message-ID: Oh, yeah- when I try this in a console app I get the message "Can not setup interpreter state, as current state is invalid". "Miles Rizzo" wrote in message news:... > Ok, I'm really new to Python (thought it was just a big snake until this > week). I've gone throught the tuturial and now I'm trying to embed a Python > script in an MFC app using VC 6.0. I followed > the instructions in "Using Pythonwin in an external project" > (http://www.python.org/windows/pythonwin/EmbeddingWin32ui.html) but my > application crashes. The DLL loads and the address of the function is found > but calling the Win32uiApplicationInit function causes a crash. > > I'd appreciate any suggestions. Thanks. > > milesrizzo at hotmail.com > -------------------------------------------------- > CTESTApp theApp; > > class MyGlueClass : public Win32uiHostGlue > > // I don't have any methods yet. > }; > > MyGlueClass glue; > > BOOL CTESTApp::InitInstance() { > Win32uiHostGlue glue; > . > glue.DynamicApplicationInit("import pytest", > "c:\\winnt\\profiles\\mgr\\desktop"); > . > } > > inline BOOL Win32uiHostGlue::RegisterModule(const char *fname, const char > *moduleName) { > . > BOOL (__cdecl *pfnInit)(Win32uiHostGlue *, char *, const char *)=NULL; > pfnInit = (BOOL (__cdecl *)(Win32uiHostGlue *, char *, const char > *))GetProcAddress(hMod, "Win32uiApplicationInit"); > BOOL rc; > if (pfnInit) > rc = (*pfnInit)(this, (char *)cmd, additionalPaths); // <<<----- The > app crashes on this call > . > } > > > > > From s.schwarzer at ndh.net Fri Mar 3 18:03:02 2000 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Sat, 04 Mar 2000 00:03:02 +0100 Subject: Parsing of nested tags Message-ID: <38C044A6.266944C3@ndh.net> Hello :-) Some time ago I have written one of the zillion programs that read some kind of format file(s) and make HTML from them. The program is able to convert <> to italic text or <> to text. However, currently I can't convert <>>> to italic text. The relevant code is -----8<--------------------------------------------------------------- ###################################################################### # perform substitutions # <>, url_text defaults to url link_pattern = re.compile( '(?si)<>' ) def make_link( matchobj ): url, url_text = matchobj.groups() if not url_text: # use url as url_text by default url_text = url url, url_text = map( string.strip, [ url, url_text ] ) return string.join( ( html_format.link_format[ 0 ], url, html_format.link_format[ 1 ], url_text, html_format.link_format[ 2 ] ), '' ) # evaluate some formatting in the text to legal code def make_html( text ): # order matters, - conversion to links has to be come first text = re.sub( link_pattern, make_link, text ) text = re.sub( r'<<(\S+)\s(.*?)>>', r'<\1>\2', text ) text = re.sub( r'(?i)(.*?)', r'\1', text ) text = re.sub( r'(?i)(.*?)', r'\1', text ) text = re.sub( r'(?i)(.*?)', r'\1', text ) return text -----8<--------------------------------------------------------------- Now the question: Which is the best way to enable parsing of recursive parsing as mentioned in the example above? So far I have thought of two ways. One may be to extend the regular expression(s), but this is already cumbersome to read. The other possibility would be to scan the string and replace <<...>> occurences which don't contain <<, perhaps multiple times, until all patterns are substituted. I hope there is an easy way that I simply have overlooked 8-) . Any suggestions are appreciated. Thank you in advance :) . Stefan From robin at jessikat.demon.co.uk Fri Mar 3 18:44:59 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Fri, 3 Mar 2000 23:44:59 +0000 Subject: comp.lang.python: more traffic than ever before References: Message-ID: In article , Fredrik Lundh writes >this month, comp.lang.python has seen nearly >50% more posts than any month before: ... the funny thing is this thread is one of the biggest. - Meta threads are clearly dangerous-ly yrs- Robin Becker From tony.mcdonald at ncl.ac.uk Mon Mar 20 03:06:55 2000 From: tony.mcdonald at ncl.ac.uk (Tony McDonald) Date: Mon, 20 Mar 2000 08:06:55 +0000 Subject: need fast parser for comma/space delimited numbers References: Message-ID: In article , Alex wrote: > > what pystones are you getting on your Sparc 10? > > athena% ./src/Python-1.5.1/Lib/test/pystone.py > Pystone(1.1) time for 10000 passes = 3.06 > This machine benchmarks at 3267.97 pystones/second > > I have never used pystone before, so please let me know if this is the > right way. Noone has bothered to upgrade python for a while around > here, but if you can't get the figures from anyone else, I can > temporarily install the latest python and run pystone on that, too. > > Hope this helps. > > Alex That seems the right way to use it Alex. Thanks for taking the time out to do that - I'm going to have a little look around our systems here and do some snooping. Our most powerful Sun box (Enterprise 450) if I remember rightly) gets 4500 pystones. I believe that there is a small performance gain in using 1.5.2 so perhaps you ought to upgrade? thanks again, tone. From clopez at abo.fi Tue Mar 7 12:37:07 2000 From: clopez at abo.fi (Cesar Lopez) Date: Tue, 07 Mar 2000 19:37:07 +0200 Subject: Building device drivers for an embedded python VM Message-ID: <38C53E43.11FD0DE8@abo.fi> Hi, I'm working in Building device drivers for an embedded python VM as my final project of my Computers Science career. I?m working with an SH-1 Hitachi Evaluation Board, and with an embedded python VM library, that other guy recompile to run pythons programs in it. I?m building a method that allows pythons programs access to the devices tha we have connected in our embedded system. First a want design a little driver that allow us light on/off a green led that it is connected to our system. I have build the driver in C, I tested it and works properly. Then I have build an external module for my python VM, that I have installed in a Linux machine. This led-module call to my modify C driver and only print on/off when I call led.Setup(1) or led.Setup(0). To build the interface between C/Python I have used SWIG to generate the wrap file. To compile this ledmodule as static I have use Makefile.pre.in. I?ve built a develop directory, I?ve copied this Makefile.pre.in file in it, I? ve created a Setup file and I?ve insert led.c, led_wrap.c and led.h source code, too. //Setup *static* led led.c led_wrap.c With my Linux machine all works properly, but when I try to build the same using the embedded python version I?ve some problems compiling. Here is the code of my led driver. //led.h int Setup(int state); // state = 1 --> ON ; state = 0 --> OFF int _state; // Defining communication with the device, Port, Adress, configuration registers and so on ... #define PBIOR (*(volatile short int *) (0x5ffffc6)) #define PBCR1 (*(volatile short int *) (0x5ffffcc)) #define PBCR2 (*(volatile short int *) (0x5ffffce)) #define PBDR (*(volatile short int *) (0x5ffffc2)) //led.c #include "led.h" int Setup(int state) { PBIOR |= 0x8000; // Set the bit for output PBCR1 &= ~0xc000; // Make it a normal I/0 switch (state){ case 1:{ PBDR |= 0x8000; // Set the LED on // printf("on\n"); _state=1; // to read the state of the led return 0; } case 0:{ PBDR &= 0x0000; // Set the LED off // printf("off\n"); _state=0; return 0; } default: return 1; // Error: Invalid code } //switch } To generate the wrap file I use swig: swig -python led.i //led.i %module led %{ #include "led.h" %} extern int Setup(int state); extern int _state; Do you know if I need include in led.i the port device defines that I?ve included in led.h?, How can I do it? After I have get the led_wrap.c file, I want to build a new embedded python library that runs in my embedded system with the led device driver include in it. So that I do the same like I did with my python Linux VM. I have built a develop directory, I?ve copy the same files. And I run: make -f Makefile.pre.in Makefile VERSION=1.5 installdir=/home/cesar/Python-1.5.1-raul In /home/cesar/Python-1.5.1-raul I?ve a copy of the embedded python source and develope code that Raul Parra develop. This make command gen some files like: sedscript, Makefile.pre, Makefile and config.c .... I modify the Makefile to use the sh-hms-gcc compiler and sh-hms-ranlib. I deleted some libraries references like -lsocket -lieee -ldl ...... Finally to try to get the static link I run "make python" and then the first time I got an error similar like this: "python.o unrecogniced type code" to solve it I have recompile /Modules/python.c with sh-hms-gcc and install int in (prefix)/lib/python1.5/config But Now when I run "make python" again I get this error bash-2.02$ make python sh-hms-gcc \ /home/cesar/Python-1.5.1-raul/lib/python1.5/config/python.o config.o lib.a /home/cesar/Python-1.5.1-raul/lib/python1.5/config/libpython1.5.a \ -lm -lgcc \ -o python /home/cesar/Python-1.5.1-raul/lib/python1.5/config/python.o(.text+0x28):python.c: undefined reference to `Py_Main' config.o(.data+0xc):config.c: undefined reference to `initregex' config.o(.data+0x14):config.c: undefined reference to `initpcre' config.o(.data+0x1c):config.c: undefined reference to `initposix' config.o(.data+0x24):config.c: undefined reference to `initsignal' config.o(.data+0x2c):config.c: undefined reference to `initarray' config.o(.data+0x34):config.c: undefined reference to `initcmath' config.o(.data+0x3c):config.c: undefined reference to `initmath' config.o(.data+0x44):config.c: undefined reference to `initstrop' config.o(.data+0x4c):config.c: undefined reference to `initstruct' config.o(.data+0x54):config.c: undefined reference to `inittime' config.o(.data+0x5c):config.c: undefined reference to `initoperator' config.o(.data+0x64):config.c: undefined reference to `initfcntl' config.o(.data+0x6c):config.c: undefined reference to `initpwd' config.o(.data+0x74):config.c: undefined reference to `initgrp' config.o(.data+0x7c):config.c: undefined reference to `initselect' config.o(.data+0x84):config.c: undefined reference to `initsocket' config.o(.data+0x8c):config.c: undefined reference to `initerrno' config.o(.data+0x94):config.c: undefined reference to `initmd5' config.o(.data+0x9c):config.c: undefined reference to `initrotor' config.o(.data+0xa4):config.c: undefined reference to `initbinascii' config.o(.data+0xac):config.c: undefined reference to `initparser' config.o(.data+0xb4):config.c: undefined reference to `initcStringIO' config.o(.data+0xbc):config.c: undefined reference to `initcPickle' make: *** [python] Error 1 So if someone of you are working in somethin similar, or now how to compile corectly a new version of python for other architecture, when you have a previous installed one. Please help me!! Best Regards. Cesar Lopez Saenz. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias.huening at univie.ac.at Thu Mar 9 05:59:32 2000 From: matthias.huening at univie.ac.at (Matthias Huening) Date: Thu, 9 Mar 2000 11:59:32 +0100 Subject: creating instances of classes? References: <003501bf89ac$e41c3fa0$2801000a@iel.ie> Message-ID: <8a80a9$8cv8$2@www.univie.ac.at> Shaun Hogan wrote: >i want the code below to tell me the current time & date when i execute it, >i dont know how to make an instace of telltime though, can anyone correct >if for me. class telltime: def __init__(self): import time z = time.time() # you can of cours change the format... self.time = time.strftime("%H:%M", time.localtime(z)) self.date= time.strftime("%d.%m.%Y", time.localtime(z)) def op(self): print self.time print self.date t=telltime() t.op() Cheers, Matthias - - - - - matthias.huening at univie.ac.at http://www.ned.univie.ac.at/ From effbot at telia.com Wed Mar 1 13:07:12 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 01 Mar 2000 18:07:12 GMT Subject: Splitting comp.lang.python References: Message-ID: Mikael Olofsson wrote: > Not necessarily exactly those subgroups, but definitely something in > that direction, yes. Based on my first post in this thread, I come up > with the following > > c.l.py General > c.l.py.gui GUI > c.l.py.os os/platform dependent issues > c.l.py.db DataBase handling > c.l.py.advocacy Whitespace and such c.l.py.whine.whine.whine? now wait, that's my mail box! (sorry. please ignore me ;-) From joacim at home.se Fri Mar 17 09:52:52 2000 From: joacim at home.se (JJ) Date: Fri, 17 Mar 2000 15:52:52 +0100 Subject: Java editor for Python Message-ID: <8atgsd$ava$1@vg170.it.volvo.se> Hi! Anyone who knows where to find an editor written in Java with syntax color highlighting? It's a VERY big plus if there is a java bean and/or source code available. // Joacim From darrell at dorb.com Sun Mar 19 12:39:27 2000 From: darrell at dorb.com (Darrell) Date: Sun, 19 Mar 2000 17:39:27 GMT Subject: Java editor for Python References: <8atgsd$ava$1@vg170.it.volvo.se> <8b32nh$r86$1@kopp.stud.ntnu.no> Message-ID: [Magnus Lie Hetland] > Darrell wrote in message > > > > Java ? Java ! > > We don't do no stinking JAVA! > > Who are you talking about? Are you saying that JPython is inferior to > CPython? > I don't really think the implementation platform should matter, as long as > we > are talking about programming in Python... As you can probably see, the > subject > is "Java editor for Python", not "Java editor for Java" ;) > > I have asked the same question before (that time without getting an > answer) - > in my case because I would like syntax colouring and indenting instead of a > simple > text field when embedding JPython as a scripting language in Java > applications. > > Please - don't turn comp.lang.python into another comp.lang.perl.misc or the > like... > Or, if that is inevitable with the growth of the volume in this newsgroup, > let's at least > keep up the friendly and helpful tone as long as we can - please? > Sorry if this was taken seriously. It was meant to be funny. Humm, Is there some kind of thing like :) or :-> that I should add when making fun of a stuff? --Darrell From grant at nowhere. Fri Mar 3 14:53:07 2000 From: grant at nowhere. (Grant Edwards) Date: Fri, 03 Mar 2000 19:53:07 GMT Subject: Remote Inbox inspector & mail-forwarder References: Message-ID: In article , Nikolai Kirsebom wrote: >I've made a small (and simple) module which makes it possible to inspect a >remote Inbox and also have selected received mail-items forwarded to your >home e-mail address. > >Module uses python COM extension and the mxDateTime module. These must be >installed. If it sounds interesting, have a look and use it if you want to >(and are allowed to). I've written a mail-forwarder also. After it runs for a couple days, checking my inbox every minute or so, I get a COM error about insufficient storage available. Seen anything like that? -- Grant Edwards grante Yow! If Robert Di Niro at assassinates Walter Slezak, visi.com will Jodie Foster marry Bonzo?? From effbot at telia.com Tue Mar 28 18:42:12 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 28 Mar 2000 23:42:12 GMT Subject: Python - Next Release Questions References: <00f401bf990d$b4317d30$5ddd3fcb@neil> Message-ID: Neil Hodgson wrote: > > Call me an egotistical eurocentric what-have-you, but I'd just as > > soon be given a choice, not given UTF-16 only. > > Is the new support UTF-16? I though it was only going to be UCS-2. I > would much prefer to see UTF-16 as it has a better chance of acceptance in > East Asian work but it may be extra work for now. the string type stores unicode characters as 16-bit unsigned integers. escape codes are currently not supported. however, the unicode package supports pluggable converters. here's a list of converters in the current release: ascii cp037 cp1006 cp1026 cp1250 cp1251 cp1252 cp1253 cp1254 cp1255 cp1256 cp1257 cp1258 cp424 cp437 cp500 cp737 cp775 cp850 cp852 cp855 cp856 cp857 cp860 cp861 cp862 cp863 cp864 cp865 cp866 cp869 cp874 cp875 iso8859-1 iso8859-10 iso8859-13 iso8859-14 iso8859-15 iso8859-2 iso8859-3 iso8859-4 iso8859-5 iso8859-6 iso8859-7 iso8859-8 iso8859-9 koi8-r latin-1 mac-cyrillic mac-greek mac-iceland mac-latin2 mac-roman mac-turkish raw-unicode-escape unicode-escape unicode-internal utf-16 utf-16-be utf-16-le utf-8 From kcazabon at home.com Tue Mar 21 21:56:59 2000 From: kcazabon at home.com (Kevin Cazabon) Date: Wed, 22 Mar 2000 02:56:59 GMT Subject: PIL text on SGI References: <38D7AAD0.5E6343A8@nih.gov> Message-ID: <%DWB4.62654$Dv1.651780@news1.rdc1.bc.home.com> Try the following... It just makes a new image with text on it, and returns it. It "should" work on all systems, provided you have a valid PIL font. If you need PIL fonts, I have some posted at: http://members.home.com/lenticular If this doesn't work... well then, there's a problem. Maybe something to do with an SGI build of PIL. I think Fred's out of touch for a few days, but he'd be the one to ask about that. ########################################### import Image, Imagefont, Imagedraw def testFont(font, text = "@ABC123abc", show = 0): # figure out how large the test image will be im = Image.new("1", (1,1)) font = Imagefont.load(font) draw = Imagedraw.Draw(im) draw.setfont(font) draw.setink(0) textsize = draw.textsize(text) textsize = (textsize[0] + 10, textsize[1] + 10) # create the test image im = Image.new("1", textsize, (1)) draw = Imagedraw.Draw(im) draw.setfont(font) draw.setink(0) draw.text((5,5), text) # show it, or return it if show == 1: im.show() return 0 else: return im im = testfont(fontfilename, "Whatever text you want to see") im.save(wherever) ######################################## "James Vincent" wrote in message news:38D7AAD0.5E6343A8 at nih.gov... > Hello, > > > Does anyone have success using PIL to create text in an image > on an SGI? I am able to do everything correctly under Linux, but under > IRIX 6.5.6 > I get no exceptions, but also no text in any image of any type. Lines, > rectangles, > colors all work, just not text. Any help is appreciated. > > Jim > > > -- > > > James Vincent > jjv5 at nih.gov From gmcm at hypernet.com Tue Mar 21 17:00:23 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 21 Mar 2000 17:00:23 -0500 Subject: Load a module twice ... or not ??? In-Reply-To: <38D7E509.71124F30@swissonline.ch> Message-ID: <1258446470-36947599@hypernet.com> With all due respect, Philip, your questions were answered as they were asked. If you don't care and aren't bothered, why did you ask? > Gordon McMillan wrote: > > > Philip Payne writes: > > > > > Can anyone by any chance give me a definitive explanation to the > > > following (Python 1.5.2). > > > > > > In the book 'Internet Programming with Python', by Watters, van Rossum > > > and Ahlstrom, in the section 'How to Load a Module Twice, and Why You > > > Shouldn't', on page 199/200 (my edition, anyway), it states that you > > > shouldn't have module interrelationships that result in a module > > > running as a main program and also being imported by another module in > > > the same interpreter. > > > > Here's the simple example: > > --module A > > import B > > a = 1 > > if __name__ == '__main__': > > global a > > a = 2 > > B.doit() > > --module B > > import A > > def doit(): > > print A.a > > --------- > > If you run A, it will print "1". > > Gordon, the example may be simple but with global variables you are really > having to try quite hard. I don't write code that does anything like this. All > I do is have a module A.py that might be: > def f1(): ... > def f2(): ... > class C1: ... > def main(): > c = C1() > c.GO() > if __name__ == '__main__' : main() > that runs as a main program in the PyApache-embedded interpreter. Then I have > another module B.py that imports A just in order to use the function f1() > defined there. B.py might be: > import A > def f3(): ... > class C2: ... includes references to A.f1() ... > def main(): > c = C2() > c.GO() > B also runs as a main program in the same interpreter 'session' as A did, > since I don't kill the interpreter between Apache requests, but I really don't > see why I should have any problems. All the examples I've seen so far involve > global variables in one form or another. I don't use global variables except > for performance reasons to cache database data between Apache requests and > these globals are only set once. What mystified me in WvRA's book was the > references to classes being defined twice. I mean, so what if they are??? > > > > > > > > Since I don't, in practice, encounter any problems doing what WvRA say I > > > shouldn't do, is this in fact an issue? Is the above quote relevant to > > > current Python versions?? And if so, can someone tell me in detail under > > > what circumstances there might be a problem? > > > > Yes (you're lucky); yes; see above. > > > > - Gordon > > -- > http://www.python.org/mailman/listinfo/python-list - Gordon From kens at sightreader.com Thu Mar 23 00:02:16 2000 From: kens at sightreader.com (Ken Seehof) Date: Wed, 22 Mar 2000 21:02:16 -0800 Subject: Threading and Conditions References: <1258344150-880350@hypernet.com> Message-ID: <38D9A558.A4C8E2E@sightreader.com> Gordon McMillan wrote: > Ken Seehof wrote: > > > Gordon McMillan wrote: > > > > > Ken Seehof wrote: > > > > > > . . . > > > > Unfortunately, the documentation is inadequate. Does anyone know of a > > > > whole sample program using conditions? > > > > > > The test code at the bottom of the module. > > > > That's the inadequate documentation I was talking about. This "example"would > > be much better if it showed the whole interaction, including creating the > > threads and conditions. An example should be a working script that > > demonstrates a feature. Anyway, I did manage to get it to work. > > > > Here's the "example": > > > > # Consume one item > > cv.acquire() > > while not an_item_is_available(): > > cv.wait() > > get_an_available_item() > > cv.release() > > > > # Produce one item > > cv.acquire() > > make_an_item_available() > > cv.notify() > > cv.release() > > Where did you get your threading module? For 1.5.2, the test > code begins at line 550 and extends to the end (line 638) and > is a complete test program. The lines you quote aren't even > part of it. > > - Gordon I was looking at the help file, not the module. However perhaps I -should- have been looking at the module. The _test() function you are refering to is exactly what I needed. - Ken From johann at physics.berkeley.edu Tue Mar 21 20:07:37 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 21 Mar 2000 17:07:37 -0800 Subject: stackless, uthreads, and GUIs Message-ID: Hi, I was wondering if anyone has experimented with using stackless to implement guis. I haven't played with the package much myself (yet), but it seems like you could write something nice using continuations to implement dialog boxes, and so on. I know most real GUIs use threads, but real OS threads are such a PITA to get to compile (in my experience), that I'd like other options. I'm mostly just playing with this idea for now. Is it a reasonable direction in which to be thinking? Any accessible references? -- Johann Hibschman johann at physics.berkeley.edu From rjroy at takingcontrol.com Wed Mar 15 19:30:28 2000 From: rjroy at takingcontrol.com (Robert Roy) Date: Thu, 16 Mar 2000 00:30:28 GMT Subject: Where to put files for public download? References: <02ea01bf8e10$53bed720$3d3dfc80@spkydomain> Message-ID: <38d02a5f.850510718@news1.on.sympatico.ca> On Tue, 14 Mar 2000 17:51:40 -0600, "David Fisher" wrote: >Hi, >I posted some code for accessing ports on windows a couple of weeks ago, and >since then a couple of more people have asked about ports in the newsgroup >(why can't people take five minutes to search the archives first, sheesh!). >Anyhow, it got me thinking about putting the binary somewhere for people to >download. So my question is where should I look for a place to put files to >be downloaded with ftp/http? Especially python related files. > >Yes, I have read the page on contributed software at the Python home page >(consider the irony if I hadn't!). The thing is I don't have a web page or >a ftp server, and I don't really want to go to the trouble of setting one up >if I don't have to. Since putting a file in anonymous ftp at python.org is >a last resort, I guess I'm looking for a second-to-last resort. > >Thanks in advance, >David > > Or perhaps submit it to the Python snippets collection if that is an appropriate place for it. http://tor.dhs.org/~zephyrfalcon/snippets/index.html From a.eyre at optichrome.com Mon Mar 20 08:55:53 2000 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 20 Mar 2000 13:55:53 -0000 Subject: binary to decimal conversion In-Reply-To: <38D3EFF7.2D30C814@webamused.com> Message-ID: <000501bf9274$02367c10$3acbd9c2@optichrome.com> >> This morning I wrote a function that takes a binary number as a string >> and converts it to an integer. There must be a way to optimize this >> function, anyone have some tips? >> [snip] > Yes, use string.atoi > >>> import string > >>> string.atoi("110", 2) > 6 > [snip] ...or in the latest CVS Python (what will become v1.6), you can use int(): Python 1.5.2+ (#0, Feb 1 2000, 13:53:38) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> int("101010", 2) 42 I-always-thought-there-was-something-fundamentally-wrong-with-the-universe-l y y'rs ----------------------------------------------------------------- Adrian Eyre - http://www.optichrome.com From cookedm at physics.mcmaster.ca Mon Mar 20 19:58:45 2000 From: cookedm at physics.mcmaster.ca (David M. Cooke) Date: 20 Mar 2000 19:58:45 -0500 Subject: IDLE and Tkinter References: Message-ID: Eddie Maddox writes: > I'm using Mandrake 7.0. "No module named Tkinter". I've tried some of what > I've read on this, but can't figure out exactly what path to put with what > variable, etc. > > Thanks for any help. > ------------------ > Eddie Maddox > eddie at mngovsci.com > You probably haven't installed the tkinter rpm. -- |>|\/|< ---------------------------------------------------------------------------- David M. Cooke cookedm at mcmaster.ca From cpr at emsoftware.com Mon Mar 27 15:52:01 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Mon, 27 Mar 2000 20:52:01 GMT Subject: Language forks (was: Python tutorial/comparison for C++ programmer) References: <5FF7ED1C1C902C69.0E5D50066AC4B434.CE45BE37438DE91A@lp.airnews.net> <38DFA08C.4142A22@bellatlantic.net> Message-ID: A cynical view of ODBC's appearance might be (I was there, indirectly) that Borland had already proposed a competing (and working) standard, and MS wanted to regain control of that situation. Naw. -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com "Steve Holden" wrote in message news:38DFA08C.4142A22 at bellatlantic.net... > In Microsoft's defense (what, me? this must be my good deed for > the week) we should remember that they DO have occasional good > ideas such as ODBC. I'm aware it has shortcomings, but it's > made multi-platform database systems a practical reality. > > And, of course, mxODBC (among others) brings these benefits > to the Python world too. > > The thing that freaks me about Microsoft is the bringing to > market of products that were clearly designed by people (?) > with minimal industry experience, full of kluges and not at > all orthogonal in design. Then they were implemented by a > further bunch of fresh graduates. And instead of writing these > deviations off as bad idea Microsoft actually DEFENDS them. > > Just goes to show how difficult it is to find and retain good > staff, I suppose. > > How unlike the recent "Multi-argument append() was a bad > idea, so it's being removed" decision. > > regards > Steve > > Mark Hammond wrote: > > > > "Grant Edwards" wrote in message > > news:slrn8dt5fb.bin.nobody at isis.visi.com... > > > Cameron Laird wrote: > > > > > > > > how does it happen that CPython and JPython > > > > happily co-exist? > > > > > > Because they've decided to? The goal of one is not to kill the > > other. That > > > can rarely be said of MS's attitude towards other entities in the SW > > world. > > > MS seems to actively attempt to diverge from standards in order to > > try to > > > kill off those standards and establish their own dominance. > > > > This also works in reverse - I think it would be accurate to say that > > the rest of the industry is very suspicious of MS, and very relucant > > to work with MS or embrace their standard deviations - even on the > > (possibly rare) occasions when it is a necessary and well designed > > extension. > > > > Don't forget that CPython also made concessions to JPython - wanting > > to work with each other cuts both ways... > > > > Mark. > > -- > "If computing ever stops being fun, I'll stop doing it" From mhammond at skippinet.com.au Thu Mar 16 17:03:23 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 16 Mar 2000 22:03:23 GMT Subject: problems using COM with Visual C References: <8ara42$pks$1@nirvana.sr.hp.com> Message-ID: This exact same question was asked about 2 weeks ago - check Deja News, as you will find a helpful response from Roger Burnham. Mark. "Jim Kerr" wrote in message news:8ara42$pks$1 at nirvana.sr.hp.com... > I'm trying to use Python's COM facilities to control a build in Visual > C++. > I've run into some problems that don't make sense to me at all (not > surprising, > since I don't know COM). > > Here's the script I have so far: > > # Open and manipulate a Visual C++ project > > from win32com.client import Dispatch > vc=Dispatch("MSDEV.Application") > vc.Visible=1 > vc.Documents.Open(r"C:\src\Workspace.dsw") > projlist = vc.Projects > ap = vc.ActiveProject() > > So far, so good; ap has the value 'MainApp', as it should. But if I > try to set the active project (from PythonWin) > > >>> vc.ActiveProject = 'Persist' > > ... it doesn't fly: > > Traceback (innermost last): > File "", line 1, in ? > File "C:\Program Files\Python\win32com\client\dynamic.py", line 413, in > __setattr__ > self._oleobj_.Invoke(self._olerepr_.propMap[attr].dispid, 0, > pythoncom.DISPATCH_PROPERTYPUT, 0, value) > com_error: (-2147352567, 'Exception occurred.', (61837, 'Microsoft Visual > C++', 'Unable to write read-only property.', > 'C:\\PROGRA~1\\MICROS~3\\COMMON\\MSDEV98\\BIN\\MSDEV.HLP', 455053, 0), None) > > The MSDEV documentation sure implies that ActiveProject is writable, so > this > error seems kind of confusing. > > So anyway, I'm doing something wrong... I can accept that. But here's the > odd thing: > from this point on, no matter what I type at the PythonWin prompt, a dialog > appears > that says: > > 'The topic does not exist. Contact your application vendor for an updated > Help file (129)' > > The only cure that I've found for this is to quit and restart PythonWin. > > Has anyone out there slayed these dragons before? > > FWIW, here are some OS and Python specifics: > NT 4.0, Service Pack 5 > PythonWin build 125 > > Thanks for the help! > > -Jim > > > From mss at transas.com Mon Mar 27 08:03:23 2000 From: mss at transas.com (Michael Sobolev) Date: 27 Mar 2000 17:03:23 +0400 Subject: Python 3000 Message-ID: <8bnm6r$nh1$1@anguish.transas.com> I do not know whether this is a proper place to ask this question. :) When I got Python 3000 sources (from CVS) and tried to build it, I saw that it uses VERSION="1.5" all the time. Is it by design? I mean this prevents me from direct installing this new version as it's going to replace the files from existing python 1.5.2... -- Mike From Vladimir.Marangozov at inrialpes.fr Sat Mar 11 13:52:27 2000 From: Vladimir.Marangozov at inrialpes.fr (Vladimir Marangozov) Date: Sat, 11 Mar 2000 19:52:27 +0100 Subject: Unicode patches checked in References: <200003110020.TAA17777@eric.cnri.reston.va.us> Message-ID: <38CA95EB.A234BA99@inrialpes.fr> Michael Hudson wrote: > > Guido van Rossum writes: > > > [cool news] > > I don't know if this is the place to mention this, but the encodings > directory isn't begin installed; this Trivial One-Line Patch fixes > that: > Michael, please forward this TOLP to patches at python.org. (and don't forget to attach the USD -- usual std disclaimer :-) -- Vladimir MARANGOZOV | Vladimir.Marangozov at inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From cjc26 at nospam.cornell.edu Sat Mar 18 19:22:18 2000 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: Sun, 19 Mar 2000 00:22:18 GMT Subject: binary to decimal conversion References: Message-ID: I would do the following: def btoi(num): output = 0 for bit in range(len(num)): output = output << 1 if num[bit] == '1': output = output + 1 return output That lets you get rid of the call to reverse(), and all the extra variables. * Moshe Zadka menulis: | On 18 Mar 2000, Michael Esveldt wrote: | | > This morning I wrote a function that takes a binary number as a string | > and converts it to an integer. There must be a way to optimize this | > function, anyone have some tips? | > | > def btoi(num): | > output = 0 | > col = range(len(num)) | > col.reverse() | current_power = 1 | > for bit in range(len(num)): | > output = output + pow(2,col[bit])*int(num[bit]) | Better: | if num[bit] == '1': | output = output+current_power | current_power = current_power << 1 | | Or try some list functions: | | powers = map(pow, [2]*len(num), range(len(num))) | return reduce(operator.add, map(operator.mult, powers, map(int, num))) | | (You can calculate powers in advance, and just take slices) | -- | Moshe Zadka . | http://www.oreilly.com/news/prescod_0300.html | http://www.linux.org.il -- we put the penguin in .com | | -- cliff crawford -><- http://www.people.cornell.edu/pages/cjc26/ "IS I yes wardrobe yield [the] evaluation." member of A.H.M.A.D. From moshez at math.huji.ac.il Mon Mar 13 20:00:18 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 14 Mar 2000 03:00:18 +0200 (IST) Subject: Stackless/microthreads merge news In-Reply-To: Message-ID: On 13 Mar 2000, Konrad Hinsen wrote: > wware at world.std.com (Will Ware) writes: > > > The kind of thing you're looking for would involve interrupting the > > physical processor rather than the Python VM. Unfortunately, all your > > Indeed. But what then are the applications for which one might > profitably use microthreads? It has to be Python code with no lengthy > C code execution nor any potentially blocking I/O. Can you really > get a measurable performance advantage over the standard OS threading? > I'd expect that the interpreter overhead should be more important than > the threading overhead. Or is it memory efficiency that you are aiming > for? What if you write a MOO-like universe? Few operations access IO (the database is synched to the disk in a seperate micro-thread, which does block other threads occasionally, but it happens once per day), but 1000 threads might be a bit hard on an OS. -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From claird at starbase.neosoft.com Thu Mar 23 23:12:36 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Mar 2000 22:12:36 -0600 Subject: Python tutorial/comparison for C++ programmer References: <8bcr2a$b76$1@nnrp1.deja.com> Message-ID: In article , Will Ware wrote: >Michael Hudson (mwh21 at cam.ac.uk) wrote: . . . >In the former domain, unfortunately, Microsoft has a lot of experience >and if it deemed the effort worthwhile, it probably could "win", i.e. do >real damage to Python as a useful language. Luckily, Python is not yet a >sufficiently large blip on their radar to merit that effort. . . . Python is on the Microsoft radar. Microsoft doesn't choose to do it damage now. Maybe it'll even help. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From bozon at natur.cuni.cz Fri Mar 17 08:39:54 2000 From: bozon at natur.cuni.cz (Michal Bozon) Date: Fri, 17 Mar 2000 14:39:54 +0100 Subject: Python 3000 In-Reply-To: References: Message-ID: On 16 Mar 2000, Justin Sheehy wrote: > Michal Bozon writes: > > > I'm afraid that Python 3000 will be commercial. > > What made you think that? > > > What about you? > > I am as commercial as I need to be in order to pay the bills. > :-)) I meant if you think so too, no if you are commercial. > -Justin > > > > > From williman at adinet.com.uy Thu Mar 16 10:16:05 2000 From: williman at adinet.com.uy (williman) Date: Thu, 16 Mar 2000 12:16:05 -0300 Subject: question Message-ID: <3.0.5.32.20000316121605.007a19e0@adinet.com.uy> 16/03/2000 I don?t know nothing of program's languages. I want to know to program in a language, so that I try to do it with Python. I download Python 152 and the editor Zeus for windows. Some one told me that in others program's languages I do a program, I save it, then I compile and after that I run it. Yesterday, I did a program. It name is operatio.py. I would like to know, step by step: 1) How can I run it? 2) Which program I must use? Isn't easy for me to find that. Because to do a program, I must study so much, but I can't find that in the tutorial I download in www.python.org. Thank you very much. From aa8vb at yahoo.com Mon Mar 6 06:47:07 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 6 Mar 2000 06:47:07 -0500 Subject: [XML-SIG] Re: XML DTD for Python source? In-Reply-To: References: <002701bf8560$351b4f00$3e2a08d1@idsonline.com> Message-ID: <20000306064707.A2115@vislab.epa.gov> gvwilson at nevex.com: |> Thomas Passin wrote: |> |> Well, for one thing it [using XML to store program source] would make |> it easier to make a "folding" editor. | |Yup. I used the folding editor that came with occam for a couple of |years; it was the only thing about the system I liked :-). I definitely agree that foldering source editing is useful. That's why I use Ken Manheimer's outdent.el for Emacs (http://www.python.org/emacs/). Collapsable Python blocks, block skips, etc. -- Randall Hopper aa8vb at yahoo.com From jlouder at wfu.edu Thu Mar 2 17:11:31 2000 From: jlouder at wfu.edu (Joe Louderback) Date: 2 Mar 2000 22:11:31 GMT Subject: Worthless (was RE: functional programming) References: <000e01bf8193$d9b8b640$f0a2143f@tim> Message-ID: <89mouj$6bg@f1n1.spenet.wfu.edu> Tim Peters (tim_one at email.msn.com) wrote: > No, but some of its core hardware was salvaged from the MU5 dataflow > machine built at the University of Manchester. [ . . . ] Have I suddenly wandered into comp.arts.stanislaw-lem ;-) Oh well, back to Mueller and Jones matrices. -- Come let us hasten to a higher plane, | Joe Louderback | Where dyads tread the fairy fields of Venn, | jlouder at wfu.edu | Their indices bedecked from one to n, +-----------------------| Comingled in an endless Markov chain! -- S. Lem, _The Cyberiad_ | From see_plus_plus at my-deja.com Fri Mar 3 05:13:48 2000 From: see_plus_plus at my-deja.com (see_plus_plus at my-deja.com) Date: Fri, 03 Mar 2000 10:13:48 GMT Subject: C++ / Java / Python (was Status of C++) References: <38bf4389.272576531@news.mindspring.com> Message-ID: <89o38r$5q2$1@nnrp1.deja.com> Another voice about the truth of C++, bravo! In fact even Larry Wall acknowledged in his Onion speech that in the end C++ will win! For non critical & low performance applications any of these Perl/Tcl/Python is good enough, but for real industrial strength applications, C++ is first choice. cpp In article <38bf4389.272576531 at news.mindspring.com>, dickjoe_nospam_ at mindspring.com wrote: > You, dear Sir, are sadly misinformed. > > I (with others) have written an industrial-strength image server > completely in (portable) C++. Multi-threaded, scalable, extensible. > Runs under NT, Solaris, Linux. > Our server (the released version) never crashes, and does not degrade. > It is designed for use by large numbers of clients accessing > large numbers of images. Our server handles huge datasets -- > e.g. random-access of images up to a 1,000,000 pixels squared. > I have 15 yrs. exp. in C / C++. Some Forth, Lisp, Java, Python (and > assember, ugh!) > > Java you say? I laugh in your face. C++ is one of the most sought- > after skills for "serious" programming (see below). > Don't assume that companies you speak to know what they are > talking about. I do know there is a very high demand for C++. > As far as Java, yes it is the "flavor of the week", > but check out Python for something much superior, > and much less hyped, and public domain too. > However don't think of it as suitable for Application-level > programming (there may be exceptions to this rule) > > C++ is pretty much the default choice for "serious" software, and > in that I incude "system" and "application" programming. > Anything that runs on a server should not use java. > > What language do you think is used to write some of the > most complex systems around? The phone company needs switching > software. Have you heard of ATT/Bell Labs? Have you heard > of Bjarne Stroustrup? You may want to inform him that his skills > are antiquated and he better brush up on his Java if he wants > to be competitive in the industry, whatever industry it is you are > referring to. > > I call the kind of programming you are referring to > "client-side" or "applet" or "plugin" programming. Don't attempt to > write e.g. PhotoShop in Java. Don't attempt to write a web server in > java. Don't expect java to work well in next-gen architectures. > C++ does not have these problems. > > Java is NOT an alternative to C++. > Python IS an alternative to Java (except for lack of browser support) > Lisp (its myriad flavors) has it adherents and there are lots > of other languages as well that all have their advantages and > drawbacks. I am not interested in language flame wars > and I am always suspicious of the "over-sell" and the > "marketing-driven" solutions, as well as anything which > is not standardized and made public-domain. > I do not like the idea of having to wait for Sun to fix (one of the > many) fatal flaws, or to get around to writing a VM for a new > platform. I have read that a port of the python system to a 64-bit > architecture took a single afternoon. > That is not to say that Java may not win out over Python and others, > much like MS-DOS won out over CPM. > > If you want to program your palm pilot use Python, not Java (in my > opinion). If you want to target serious "new" development become a C++ > whiz. Participate in free software projects. Get linux, apache, gcc, > etc. Read code until the room swims. And yes, you may need to > settle for less to get years of "real-world" C++ experience before > you can land the sweet "all-new, all-C++" projects. > > Good luck! > > On 22 Jan 2000 05:08:27 -0500, "Gaurav Sareen" > wrote: > > >I dont want to start a meaningless debate but want to simply know where C++ > >stands in the industry. > > > >As far as I am told, most companies are using Java for application level > >programming while plain old C for system level programming; C++ is more or > >less extinct. There is still some C++ work going on on old projects due to > >inertia but very few people favor C++ for new work. > > > >What I am concerned with is that C++ would be relegated to the COBOL level, > >with lot of maintenance, migration to do but with very little new > >development. A programmer like me who is intermediate in C++ but zero in > >Java can only hope to work on such maintenance etc. > > > >Here of course I am not interested in knowing whether C++ is better than > >Java but whether I have at least equal career oppurtunity as any good Java > >programmer or not. > > > > > > [ Send an empty e-mail to c++-help at netlab.cs.rpi.edu for info ] > > [ about comp.lang.c++.moderated. First time posters: do this! ] > > > > Sent via Deja.com http://www.deja.com/ Before you buy. From jstok at bluedog.apana.org.au Wed Mar 1 19:59:25 2000 From: jstok at bluedog.apana.org.au (Jason Stokes) Date: Thu, 2 Mar 2000 11:59:25 +1100 Subject: Email/Newsgroup client? References: Message-ID: <54jv4.37280$3b6.171918@ozemail.com.au> Joel Lucsy wrote in message ... >Are there any that work with win32 I'm working on a quick port (translation, really, since it breaks with most of the code) of Pygmy for WxWindows. Development has slowed up because WxWindows is a very difficult toolkit to master. Pygmy is pretty basic, but workable. That will be done very, very soon. From sholden at bellatlantic.net Mon Mar 27 17:18:47 2000 From: sholden at bellatlantic.net (Steve Holden) Date: Mon, 27 Mar 2000 22:18:47 GMT Subject: Language forks (was: Python tutorial/comparison for C++ programmer) References: <5FF7ED1C1C902C69.0E5D50066AC4B434.CE45BE37438DE91A@lp.airnews.net> <38DFA08C.4142A22@bellatlantic.net> Message-ID: <38DFDE5D.4149077@bellatlantic.net> Chris Ryland wrote: > > A cynical view of ODBC's appearance might be (I was there, indirectly) that > Borland had already proposed a competing (and working) standard, and MS > wanted to regain control of that situation. > > Naw. > -- > Cheers! > / Chris Ryland, President / Em Software, Inc. / In many ways the Borland/IBM IDAPI interface promised better access than ODBC. But it lost out because of the muscle that was lined up behind ODBC. IDAPI allowed server-side as well as client-side drivers, making multi-database joins easier than with ODBC. It also had botha SQL *and* a row-based access method. Sadly it was a victim of Borland's uncertainties, and as far as I know nobody seriously supports it nowadays. Pretty much like Sun's NeWS, which lost out big time to X Window just because it was a proprietary Sun technology: effectiveness and suitability just aren't selection criteria. Hail to the pointy-haired people! regards Steve > "Steve Holden" wrote in message > news:38DFA08C.4142A22 at bellatlantic.net... > > In Microsoft's defense (what, me? this must be my good deed for > > the week) we should remember that they DO have occasional good > > ideas such as ODBC. I'm aware it has shortcomings, but it's > > made multi-platform database systems a practical reality. > > > > And, of course, mxODBC (among others) brings these benefits > > to the Python world too. > > [etc.] -- "If computing ever stops being fun, I'll stop doing it" From aahz at netcom.com Mon Mar 6 23:40:28 2000 From: aahz at netcom.com (Aahz Maruch) Date: 7 Mar 2000 04:40:28 GMT Subject: PyApache, SSL, Python and Apache References: <8a1k4e$lgv$1@nnrp1.deja.com> Message-ID: <8a217s$v39$1@nntp6.atl.mindspring.net> In article <8a1k4e$lgv$1 at nnrp1.deja.com>, wrote: > >I'm running in an HPUX 11 environment. I have Apache 1.3.9 + SSL installed >and running. I have Python 1.5.2 + SSL also installed and running. I'm trying >to install PyApache to improve performance on some Python scripts we're >using, and am getting some errors. > >The module, mod_pyapache.so, compiles fine(without errors), but when I try to >start the apache server with the appropriate LoadModule, it craps out, and >httpsd refuses to start. I don't think this is related to your problem, but I'm a little curious why you're compiling to a ".so" when the standard extension for HPUX is ".sl". -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I wonder what they do with all the fat they harvest from fat farms From neilh at hare.net.au Fri Mar 3 08:04:20 2000 From: neilh at hare.net.au (Neil Hodgson) Date: Sat, 4 Mar 2000 00:04:20 +1100 Subject: PythonWin working, but stuck on first script :-( References: Message-ID: <013e01bf8510$fee402f0$01646464@computer> > def maiin(): > ... > if __name__=='__main__': > main() You spelled "main" wrong when defining it. >>> Traceback (innermost last): File "C:\Program Files\Python\Pythonwin\pywin\framework\intpyapp.py", line 305, in OnViewOptions ... This seems to happen if you are operating in a directory other than the default start up directory and something you need did not get initialised. Try starting PythonWin, opening up the the View | Options dialog, press OK and then open and run your code. I really should work out a repro case for this so we can get Mark to fix it. Neil From mjackson at wc.eso.mc.xerox.com Wed Mar 1 10:12:06 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 1 Mar 2000 15:12:06 GMT Subject: Splitting comp.lang.python References: <20000301151034.A4873@nl.linux.org> Message-ID: <89jc06$bfb$1@news.wrc.xerox.com> Gerrit Holl writes: > Perl uses: > > comp.lang.perl.announce > comp.lang.perl.misc > comp.lang.perl.tk > comp.lang.perl.modules > comp.lang.perl > comp.lang.perl.moderated > > Maybe it's a good idea too do something like that on c.l.py. comp.lang.perl isn't real, having been replaced by comp.lang.perl.misc. Looking at my local newsspool suggests that of the rest only comp.lang.perl.modules can be having much effect on the traffic in comp.lang.perl.misc. And I suspect that comp.lang.perl.moderated addresses problems that comp.lang.python doesn't currently have (although this might change in future). Returning to Python, IMO a viable newgroup proposal should be based on examination of current traffic and the identification a small (1-3) set of easily-characterized subtopics which in aggregate comprise a significant fraction (say 1/3) of cl.py at present. I don't see them, but as I personally find the current state quite manageable I'm not highly motivated to look more deeply. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson With software, unusual conditions come up all the time; seemingly impossible conditions take a little longer. - Watts Humphrey From mbarre at mac.com Fri Mar 10 17:11:26 2000 From: mbarre at mac.com (Matthew Barre) Date: Fri, 10 Mar 2000 16:11:26 -0600 Subject: config'in apache for python References: <00030923081607.01104@quadra.teleo.net> <00031013480609.01378@quadra.teleo.net> Message-ID: > Did you turn on the executable bit on your scripts? I sure did..I tried several different varities including chmod 0755, chmod a+x, and chmod +x. That's why I'm really puzzled. Matt From Boris.Ottlewski at NOSPAMsystemsoft.de Thu Mar 9 10:02:04 2000 From: Boris.Ottlewski at NOSPAMsystemsoft.de (Boris Ottlewski) Date: Thu, 9 Mar 2000 16:02:04 +0100 Subject: Getting the error in embedded python Message-ID: <38c7bc91$0$22621@businessnews.de.uu.net> Hi, I just run a simple script with a syntax error: int res = PyRun_SimpleString("import this_module_does_not exist"); if (res!=0) { if (PyErr_Occurred()) { //never happens } } I never get an PyErr_Occured. Also when I do PyErr_Fetch its empty. (res is -1 if I got an error). Why is that so? How do I get the error message? regards, Boris Ottlewski From mhammond at skippinet.com.au Wed Mar 8 17:08:37 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 08 Mar 2000 22:08:37 GMT Subject: PythonCOM / Word97 error/feature References: <38c66a09.6616954@news.mch.sni.de> Message-ID: It may actually be Pythonwin getting too smart with the error lines. If you double-click on a COM traceback that nominates a help file, it is opened. However, I think there has been a bug since the introduction of Scintilla. Try deleting the exception line in the interactive window!!! Or try the same thing from python.exe instead of pythonwin. Mark. "Nikolai Kirsebom" wrote in message news:38c66a09.6616954 at news.mch.sni.de... > Have a strange observation - could anyone explain what is going on > (where). > > Start PythonWin and using COM start Word97. Write some text in Word > and executes the command: > > doc.Content() > > in the interactive window in PythonWin. Content is presented ok. > Then, open the Spelling and Grammar (F7) dialog box in Word. While > this dialog box is shown, reenter the same command in PythonWin. > > Get the following com-error: > com_error: (-2146823683, 'OLE error 0x800a11fd', (0, 'Microsoft Word', > 'This method or property is not available because the proofing dialog > box is active.', 'wdmain8.hlp', 37373, -2146823683), None) > > which is ok. However if I now close the dialog (spelling) and > reexecute the command, the helpfile for VBA (wdmian8.hlp) is opened - > actually any command to the server results in the VBA helpfile being > presented. Also - it seems that the interactive window 'hangs' on the > opening (and ultimately closing) of the help window. > > This behaviour seems to be particular for the 'spelling dialog'. > Doing the same operation with 'insert file' dialog will result in > another com-error, but the system will operate as expected after > closing down the 'insert file' dialog. > > ANY IDEAS / COMMENTS. > > Nikolai > From matz at netlab.co.jp Tue Mar 7 22:10:39 2000 From: matz at netlab.co.jp (Yukihiro Matsumoto) Date: 08 Mar 2000 12:10:39 +0900 Subject: Python advocacy References: <38BEE429.179D4865@prescod.net> <38BF1990.CAA71DE6@prescod.net> <38BF6169.46FC6A66@netgate.net> <38C0153A.8C277AEA@prescod.net> <38C22B8D.B2D31196@netgate.net> <38C411E8.AF8D2CA9@prescod.net> <3d1z5myc7l.fsf@amarok.cnri.reston.va.us> Message-ID: <878zzuyx5c.fsf@ev.netlab.co.jp> akuchlin at mems-exchange.org (Andrew M. Kuchling) writes: |(This is why I think the Ruby people are being too grandiose in their |claims. If Python and Perl haven't killed off Tcl, and Java hasn't |killed off Python and Perl, it's unlikely that Ruby is going to manage |any of those feats. Ruby certainly can form a healthy community of |its own and prosper alongside these other languages, of course.) Are we? I consider myself as a provider of alternative, not killer, nor replacement. Of course I know people tend to be grandiose in advocacy, even Pythoneers. matz. From edcjones at erols.com Fri Mar 31 15:08:57 2000 From: edcjones at erols.com (Edward C. Jones) Date: Fri, 31 Mar 2000 15:08:57 -0500 Subject: Are newlines sometimes required at end of Python code? Message-ID: <38E505D9.61F2AB05@erols.com> Why does this piece of code work: s~=~"""for~i~in~range(3):\n~~~~x~=~i\n""" exec~s while this one doesn't: s~=~"""for~i~in~range(3):\n~~~~x~=~i""" exec~s I have replaced all the spaces in the code by "~". From olivier at scripps.edu Wed Mar 1 10:28:37 2000 From: olivier at scripps.edu (Olivier Roche) Date: Wed, 01 Mar 2000 07:28:37 -0800 Subject: MySQLmodule synthax error Message-ID: <38BD3724.B5E35F7E@scripps.edu> Hi, I have just download the last version of MySQLmodule which compile with MySQL 3.22.30, but i have still a slight problem with the synthax. I would like to create several tables in a loop, but i raise a MySQLmodule error. Here is the failed script: for lines in TextFile('/DB_scripts/complex.txt'): code = split(lines)[0] dock = code + '-dock' if dock in tables: DBH['drop table ' + dock] ## Create the table DBH["create table %s (Structure_ID VARCHAR(20) NOT NULL, \ Rms REAL NOT NULL, Energy_charmm REAL NOT NULL)" % dock] MySQL.error: You have an error in your SQL syntax near '-dock (Structure_ID VARCHAR(20) NOT NULL, Rms REAL NOT NULL, Energy_charmm REAL' at line 1 I try also: DBH["create table" + dock + " (Structure_ID VARCHAR(20) NOT NULL, \ Rms REAL NOT NULL, Energy_charmm REAL NOT NULL)"] Same error. Any advices will be very welcome. Thank you Olivier From bozon at natur.cuni.cz Mon Mar 13 13:45:30 2000 From: bozon at natur.cuni.cz (Michal Bozon) Date: Mon, 13 Mar 2000 19:45:30 +0100 Subject: forgetting () after function In-Reply-To: <38CD2C25.B2FAA1A8@stsci.edu> References: <38CD2C25.B2FAA1A8@stsci.edu> Message-ID: > > I've noticed that if you inadvertantly omit the () at the end of a > function call (that does not need params), python just ignores it, no > warning, no nothing. Does anyone know of a way to catch this somehow to > avoid insidious logic errors that could result, or protect your program > from blowing up down the line? > If you have a function without arguments, e.g. f(), and you type: >>> g = f it means, that g is not a result of function f, but it is also a function. So you can type >>> v = g() this is same as >>> v = f() Michal Bozon Faculty of Science, Charles Univ., Prague, Czech Rep. bozon at natur.cuni.cz http://www.natur.cuni.cz/~bozon From robin at jessikat.demon.co.uk Wed Mar 29 18:06:35 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 30 Mar 2000 00:06:35 +0100 Subject: Microthreads is now available In-Reply-To: <38E1FAC8.6E5F21DA@tismer.com> References: <94iVvEApja44EwdC@jessikat.demon.co.uk> <38E1FAC8.6E5F21DA@tismer.com> Message-ID: In message <38E1FAC8.6E5F21DA at tismer.com>, Christian Tismer writes ... thanks for your response. I guess I should get into uthreads or medusa for reasons to be stackless >> user acceptance. Should I download the source to get further >> information? > >No. The sources are hard to understand, and they describe >the implementation, not the usage. There are no examples >at the moment, since they all need a rewrite. >A collection of useful stuff is in preparation. > >There is a principal problem with this stuff: It makes no sense >to explain in depth how and why continuations work, since this >is nothing for more than just a few interested people. >Most users would only use applications, like generators, >coroutines, and microthreads. That means, I don't have to >supply documentaiton of the inner nuts and bolts, but I >have to provide complete, tested applications like the above. > >I think the Microthreads have good documentation and >give enough motivation to make use of SLP. I could not >delay the release any longer, since MThreads are ready >since 3 weeks, and they rely completely on SLP now. >I could have included the uthreads package into the >distribution, but this is Will Ware's kid which I cannot >simply stick into my dist, unless he tells me to do so. > >The continuation module has quite complete >documentation via docstrings, now. > >Sam Rushing is working on a new design of coroutines. >I didn't want to provide the old code examples any longer. >Code examples will appear on the website as they evolve, >and some will go into the binary release's demo section. > >ciao - chris > -- Robin Becker From cgw at alum.mit.edu Wed Mar 29 18:13:03 2000 From: cgw at alum.mit.edu (Charles G Waldman) Date: Wed, 29 Mar 2000 17:13:03 -0600 Subject: Philosophical long integer question... References: <38E23160.B16860C2@bioreason.com> Message-ID: <8bu2lv$q7u$1@info3.fnal.gov> In article <38E23160.B16860C2 at bioreason.com>, Brian Kelley wrote: > In the same vein as should 1/2 equal 0.5: > > should (1 << 1000) produce a long int? (It currently produces 0 on a > machine with 32 bit integers) Yes, IMO, int operations shouldn't overflow, they should automatically promote to long. (And 1/2 should be 0.5, but I realize that won't ever change unless I donate $1,000,000 to the Python Consortium. And maybe not even then. But it's a moot point, because I'm not that rich) And-the-square-root-of-minus-1-is-called-I-not-J'ly yrs, cgw From ccurvey at bellatlantic.net Sun Mar 19 17:35:17 2000 From: ccurvey at bellatlantic.net (Chris Curvey) Date: Sun, 19 Mar 2000 22:35:17 GMT Subject: newbie to shelves Message-ID: <38D5580F.17FDB115@bellatlantic.net> Hi all, I have a simple program: import shelve dbase = shelve.open("foo") This runs fine the first time, and dutifully creates a file named "foo". But anytime after that, I get an error "anydbm.error: db type could not be determined" The OS "file" command says that "foo" is a "Berkeley DB: 2.X Hash/Little Endian (Version 5)". I'm running on Red Hat 6.1. Any idea what I'm doing wrong? The online docs, and the O'Reilly book aren't leading me anywhere. I checked for a FAQ in this group, but didn't see one. Thanks in advance! -Chris From gerrit at nl.linux.org Wed Mar 1 05:55:14 2000 From: gerrit at nl.linux.org (Gerrit Holl) Date: Wed, 1 Mar 2000 11:55:14 +0100 Subject: Using sequence indexes greater than 2^32 on 64 bit computers In-Reply-To: <38BCF2B7.7C7CE947@arakne.com>; from jean.hemmi@arakne.com on Wed, Mar 01, 2000 at 10:36:39AM +0000 References: <38BCF2B7.7C7CE947@arakne.com> Message-ID: <20000301115514.C29825@nl.linux.org> > Hello, > > We're using a custom python sequence type on which we need to pass index > > values greater than 2^32 (64 bit integers)... In Python 1.6, this is possible. In PYthon 1.5.2., it's not. IIRC, Python 1.6 is expected this summer. regards, Gerrit. -- -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From gmcm at hypernet.com Tue Mar 28 10:33:20 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 28 Mar 2000 10:33:20 -0500 Subject: Example of proper handling of threadstate/interplock for low level C thread In-Reply-To: <%u3E4.46$YD4.11039@news.pacbell.net> Message-ID: <1257864891-26168581@hypernet.com> Grant Munsey writes: > I read the API manual on threading and am still a little confused about > what I have to do to protect the interpreter when a low level C based > thread gets control of an app and wants to .... say do a > Py_RunSimpleString(). > > Can anyone point me to some source examples that handle threads that > are not started by the Python interpreter? There's a few words of explanation at the bottom of the 2nd page of http://www.mcmillan-inc.com/embed.html This is really a summary of some long-winded and confusing dialogue on the thread SIG from about last June. In practical terms, I've only had to dip my toes into this area of Python once, and I found something simple that worked for me. IIRC, there's a CEnterLeavePython (C++) class in Mark Hammond's Win32 extensions (source download) that does the right thing (may not have the name right). - Gordon From jslove at mindspring.com Mon Mar 6 22:20:54 2000 From: jslove at mindspring.com (Jay Love) Date: Mon, 06 Mar 2000 22:20:54 -0500 Subject: Extension C module References: <89vbcb$10i$1@nnrp1.deja.com> Message-ID: <38C47596.9060508@mindspring.com> vmarkwart at my-deja.com wrote: > Hi, > A couple of strange things. The extension module I'm (attempting) to > write (Borland's C++ Builder 4) has a couple of little flaws. > > When I include > Py_INCREF(Py_None); > return Py_None; > in a procedure which returns no value, it compiles correctly but > returns a memory exception error when imported and run, and crashes > Python (not a happy sight). When I leave those lines out and return an > empty string the function can be called happily from Python, but > returns an unloved, unwanted empty string. Any ideas on what I'm doing > wrong.? > > Also, I have another function which returns a dictionary of values, eg > >>> import pytools > >>> pytools.volumeInfo("f:\\") > {'filenameUnicode': 'supported', 'filenameMaxLength': '255', > 'volumeName': 'SYS', 'filenameCase': 'preserved', 'volumeCompression': > 'compressed', 'filenameCompression': 'supported', 'volumeSerialNumber': > '1628725518', 'filesystemName': 'NWFS', 'filenameCaseSensitivity': > 'caseSensitive', 'filesystemACLs': 'supported'} > > In interactive mode everything looks fine, but when run in a script it > comes back with the error: > Traceback (innermost last): > File "", line 1, in ? File "pytoolstest.py", line 32, in ? vinfo = > pytools.volumeInfo(drive) TypeError: argument 1: expected string without > null bytes, string found Any clues as to where to start looking? I've > commented out virtually everything in the function, and I still get the > error. If anyone wants the sourcecode, please email me at > vmarkwart at hotmail.com Cheers Victor Sent via Deja.com > http://www.deja.com/ Before you buy. > I'm working through the same problem right now. Same situation, when I call Py_INCREF(Py_None), it segfaults. I'm using Borland C++ 5.02 and Borland Builder 3. Same deal with both compilers. I started writing my main extension module without realizing this problem, so I started a new module with just one test function. After much trial and error, I got the test function to run without segfaulting, but I can't figure out what magical set of compiler switches did it. One thing I did was use the standard python import library, but run COFF2OMF on it, to convert from MSVC format to Borland format. After that I set something in the Builder setup that got it to work on the test extension, but I can't get it going on my real extension. I suspect it was the library change that did it, but I'm not sure. Anybody out there who can help? Jay Love From meh9 at cornell.edu Mon Mar 20 15:00:15 2000 From: meh9 at cornell.edu (Matthew Hirsch) Date: Mon, 20 Mar 2000 15:00:15 -0500 Subject: Simple tuple question References: <38D665E4.230EB189@cs.nmt.edu> Message-ID: Thanks, That's what I was looking for. Matt In article <38D665E4.230EB189 at cs.nmt.edu>, Jeff Shipman wrote: > Well, there are two ways you can go about it: > > if type(a) == type(()): > print 'yes' > > -or- > > import types > > if type(a) == types.TupleType: > print 'yes' > > Matthew Hirsch wrote: > > > > Hi All, > > > > If I have a tuple a=(1,2,3) > > > > how do I test that this is a tuple? From tiddlerdeja at my-deja.com Tue Mar 21 04:21:01 2000 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Tue, 21 Mar 2000 09:21:01 GMT Subject: file manipulation and write permission Message-ID: <8b7etk$tr5$1@nnrp1.deja.com> I trying to manipulate a whole load of files. However I don't have write permission on all the files (I do have ownership of them). Can some tell me how I make a file writeable in a Python script? A solution that would work in JPython1.1 would also be great! Any help appreciated. Sent via Deja.com http://www.deja.com/ Before you buy. From invalid.address at 127.0.0.1 Sun Mar 19 15:05:44 2000 From: invalid.address at 127.0.0.1 (David) Date: Sun, 19 Mar 2000 20:05:44 GMT Subject: Request for suggestions: a Workflow application References: <6D8A17398E28D3119F860090274DD7DB4985A6@pces.cadlab.it> <8b1ehn$e6t$1@bunyip.cc.uq.edu.au> Message-ID: <38d53171.56301831@news.telus.net> Very cool, both vivtek's and Alessandro's ideas. A year or so ago, I was heading toward doing the same sort of thing, but ended up needed to focus my attention elsewhere. My goal was to create a document-sharing/locking system operated through EMail, so that my workteam could edit documents without stepping on each others' toes (or, at least, less often; EMail does have that lagtime error risk). I'll be glad to help betatest, proof code and suchlike. Mail me at dpriest at corelcity.com -- and, yes, that's my spam-filtering email, so you'd best make the subject line really obviously non-spam. :) On Sun, 19 Mar 2000 12:32:01 +1000, "Chui Tey" wrote: >Keep an eye on this... > >http://www.vivtek.com/wftk > >Alessandro Bottoni wrote in message >news:6D8A17398E28D3119F860090274DD7DB4985A6 at pces.cadlab.it... >> I have to write a typical workflow, e-mail-based, application and I wonder >> which (Python) tools I can use. >> >> The task is as follows: >> 1) I have a group (or a "sequence") of mail boxes. One of the boxes >> represent the common "entry point" for all the messages coming from the >> outside. >> 2) Associated to the "entry point" mail box, there is a script that parses >> the incoming messages. >> 3) Depending on the content of the message, the program performs an >action. >> For example it send a copy of the message to someone else, maybe after >> having changed it a little bit. >> 4) Associated to any other mail box, there is a script that process the >> incoming message in a similar way. >> 5) The path from a box to another is defined in an external database. >> >> I wonder: >> 1) Which mail server (or list server) can I use? SendMail? MailMan? >ListSrv? >> Majordomo? (of course, I'm able to modify a free, Python based program if >> needed...) >> 2) Is there any program that fit this task (a wheel worth not to >> reinvent...)? >> 3) Is there any (obscure?) Python module that can help me in writing this >> program, beside the POP3 and SMTP modules? >> >> Thanks. >> >> -------------------------------- >> Alessandro Bottoni >> (Alessandro.Bottoni at Think3.com) >> (alessandro.bottoni at libero.it) >> Web Programmer >> Think3 inc. >> (www.think3.com) >> >> > From bjorn at roguewave.com Wed Mar 22 14:37:52 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 22 Mar 2000 12:37:52 -0700 Subject: determining type References: <8batqm$7ou$1@nnrp1.deja.com> Message-ID: <38D92110.89E99794@roguewave.com> How about the pprint module? -- bjorn sp00fD wrote: > > I'm writing a program in which I've got a couple of dictionaries that > I'd like to output to a file, but I'd like it to be "pretty". I'm > trying to write a function to format the dictionary so that when I > print it, rather than looking like {'foo' : 'bar', 'who' : 'what'}, it > looks like > { > 'foo' : 'bar', > 'who' : 'what', > } > The way that I'm trying to do this is to create a string and loop > through the dict.keys(), appending to the string. The problem is that > if it's not a string, but an integer (the key or value) I don't want it > quoted obviously (I'm adding the quotes manually \"%s\"). > How do I determine if it's a string or int. I've tried: > if type(key) == "": > but that doesn't seem to work. How do I do this? > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list From farber at cpan.org Tue Mar 14 12:12:22 2000 From: farber at cpan.org (Alex Farber) Date: Tue, 14 Mar 2000 18:12:22 +0100 Subject: completion on tab? References: <38CE498E.49ED03F4@cpan.org> <14542.28552.715751.260151@malibu.aero.org> Message-ID: <38CE72F6.864EBCD8@cpan.org> Jeff Collins wrote: > The module rlcompleter provides this functionality by > making use of the readline module. Thank you and sorry - I have found the answer in the FAQ at http://www.python.org/doc/FAQ.html#3.29 (that's why I have cancelled my original posting). Regards /Alex From c.evans at clear.net.nz Sun Mar 19 06:56:47 2000 From: c.evans at clear.net.nz (Carey Evans) Date: 19 Mar 2000 23:56:47 +1200 Subject: Problems reading fra sys.stdin and later on duing raw_input References: <84zorxah26.fsf@perm.geografik.dk> Message-ID: <87r9d7fa0w.fsf@psyche.evansnet> Peter Kristensen writes: > I want to read a file from sys.stdin and then later on do a > raw_input. But I get an error because sys.stdin is closed after the > file is read. [...] > pkr at perm:~> echo -n "test" | /tmp/x.py stdin is still open, but it's connected to the output of echo, not the terminal. This is a limitation of any Unix program run in a pipeline this way. Some solutions I can see are: * Put the data in a file and pass the name of the file to your script, then open that file: lines = open(sys.argv[1]).readlines() This is probably the nicest solution, and the least prone to making wierd things happen if your script gets run differently. * Open /dev/tty to replace sys.stdin: sys.stdin = open('/dev/tty') a = raw_input('Prompt: ') * Redirect stdin to another file handle when you run your script, and read from that: sys.stdin = os.fdopen(3) a = raw_input('Prompt: ') $ (echo -n test | ./x.py) 3<&0 -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "*South Park* is another movie straight from the smoking pits of Hell." - http://www.capalert.com/capreports/southpark.htm From greg at cosc.canterbury.ac.nz Tue Mar 21 22:42:04 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 22 Mar 2000 15:42:04 +1200 Subject: Q: organizing classes in modules References: <38D794CD.6F2824A9@elara.tripos.com> Message-ID: <38D8410C.11EA0824@cosc.canterbury.ac.nz> Stephan Reiling wrote: > I looked into what I can do in the __init__.py file of the module. The only > thing I could figure out was to put something like the following there: > > from Class1 import * > from Class2 import * > ... > > Which according to what I have read is not a good idea As long as you intend all the names defined in the Class1, Class2 etc. submodules to appear in the package namespace, it doesn't do any great harm here. The advice against using "import *" applies when you're importing from some module that you don't know the full contents of. One reason is to prevent you from accidentally importing some name that clashes with another one you've already got. In this case, you're in control of both modules, so you can make sure that there are no clashes. The other reason for not using "import *" is that it makes it harder to trace where names are coming from. That could be a concern here, but as long as there is a clear relationship between the class name and the module it comes from (as there obviously is in your case) it's not going to be a serious problem. Nevertheless, you can easily avoid using "import *" if you want: from Class1 import Class1 from Class2 import Class2 etc. > and also seems to increase startup time. That's because it forces all the submodules to be loaded when the package is first imported, rather than waiting until one of the submodules is referenced. If your submodules are all closely related, so that using one of them requires all or most of the others as well, the user is going to have to wait for them to load anyway. On the other hand, if your submodules are independent and the user is likely to want to load only some of them, and startup time is a problem, you may be forced to put up with the more verbose importing syntax. > (And what happens if Class1 and Class2 cross-reference each other, That's no problem as long as you make the cross-references in the right way, e.g. in Class1.py you say import Class2 and then refer to Class2.Class2 wherever needed. > or one of my classes has to be a singleton) class _Singleton: ... Singleton = _Singleton() Names beginning with "_" are ignored by "import *", so only Singleton will be imported into the main package. Hope that helps, -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | A citizen of NewZealandCorp, a | Christchurch, New Zealand | wholly-owned subsidiary of USA Inc. | greg at cosc.canterbury.ac.nz +--------------------------------------+ From effbot at telia.com Sun Mar 12 11:05:37 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 12 Mar 2000 16:05:37 GMT Subject: Anyone using Curses with Python on NT? References: <38c6ea4b_4@news1.prserv.net> Message-ID: Michael Appelmans wrote: > I have a project that requires text mode screens for telnet application. I > thought of doing it in Python to make it interesting but the console mode > would require some form curses library. here's a small library which implements a thin layer on top of Windows' console API: http://w1.132.telia.com/~u13208596/console.htm From tf at malcolmsmith.net Fri Mar 3 18:42:42 2000 From: tf at malcolmsmith.net (tf at malcolmsmith.net) Date: Sat, 4 Mar 2000 1:42:42 +0200 Subject: IDLE and Tkinter Message-ID: IDLE and Tkinter Hi guys, I'd love to try IDLE, but am having a bit of trouble with Tkinter. I *tried* to follow the instructions on the site under "Tkinker Troubleshooting". I can get to the "make install" stage, when I get this: /python: error in loading shared libraries libtk8.3.so: cannot open shared object file: No such file or directory make: *** [libinstall] Error 127 Ok, I'm not editing something correctly... -tom From terekhov at emc.com Thu Mar 2 13:24:08 2000 From: terekhov at emc.com (Mikhail Terekhov) Date: Thu, 02 Mar 2000 13:24:08 -0500 Subject: Postgres+Python+Win32 ? References: Message-ID: <38BEB1C8.E1E8AF15@emc.com> Hi, I've built _pg.pyd for PostgreSQL 6.5.3. If you interested, I can send it to you. Mike Jeff Koftinoff wrote: > > Hi. > > I have a linux box running postgresql and python, and am able to access the > database remotely from another linux box. Now I want to be able to access the > remote postgresql database from a win32 box running python. I found someplace > the postgresql client DLL library from win32, but has anyone made a pgsql or > whatever for win32? > > Thanks in advance > > Jeff > jeffk at jdkoftinoff.com From haskin at ptway.com Sat Mar 11 14:48:54 2000 From: haskin at ptway.com (Brian Haskin) Date: Sat, 11 Mar 2000 11:48:54 -0800 Subject: Stackless/microthreads merge news References: <38CA510A.749F@letterror.com> Message-ID: <38CAA326.C016DA15@ptway.com> Just van Rossum wrote: > > Fredrik Lundh wrote: > > > > Brent Fulgham wrote: > > > Has any thought been given to making the generic Python > > > use the Stackless implementation? > > > > definitely! > > > > personally, I hope that microthreads will be stackless > > Python's true killer app, and that we will see a merge > > in 1.7. but that's me ;-) > > Let me second that... I read the microthread document, and I'm very > impressed indeed. > > Apparently one of Guido's doubts about stackless is that it seems > impossible (or merely hard?) to replicate in JPython. Personally I think > it would be a shame if the limitations of one particular Python > implementation imposes restrictions on others. After all, JPython > implemented features that are hard to implement in CPython, so why > should CPython's development be held back because of JPython? > > I want stackless in 1.6... > > Just Ditto. Although I have a feeling getting stackless into 1.6 would be just a 'little' difficult. Brian Haskin From alex at somewhere.round.here Fri Mar 17 18:19:42 2000 From: alex at somewhere.round.here (Alex) Date: 17 Mar 2000 18:19:42 -0500 Subject: Good Site on Classes References: <38D293A3.C0B52A24@nmt.edu> <38D2B0FE.72777AEE@nmt.edu> Message-ID: > What i am trying to do is have one class get information from another > class. Can you be more specific? Alex. From neelk at brick.cswv.com Wed Mar 15 17:56:45 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 15 Mar 2000 22:56:45 GMT Subject: "builtin" methods References: <38CFD94A.EA1A08C4@flashmail.com> Message-ID: Jp Calderone wrote: > > Is there a list of all the "__xxx__" functions (eg __cmp__, __len__) > somewhere? See the Python Reference Manual, Section 3.3: Special Method Names. Neel From vetler at ifi.uio.no Sun Mar 26 04:26:18 2000 From: vetler at ifi.uio.no (Vetle Roeim) Date: 26 Mar 2000 11:26:18 +0200 Subject: Python tutorial/comparison for C++ programmer References: <8bicur$jnt$2@news1.xs4all.nl> Message-ID: [Boudewijn Rempt] > > Well, it's probably not directly relevant, but I took a C++ tutorial > > and translated it into a Python tutorial. The original was meant for > > beginning C++/Qt developers. Taking a look at: > > > > http://www.valdyas.org/python/tutorial.html > > > > can't hurt ;-). [tom-main at REMOVEME.home.com] > I tried the link but it didn't work. er.. yes it does. vr From gmcm at hypernet.com Thu Mar 16 09:05:32 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 16 Mar 2000 09:05:32 -0500 Subject: AST structures and memory leaks In-Reply-To: Message-ID: <1258906958-9249420@hypernet.com> Robin Becker wrote: > I want to have an AST container A contain instances of B and would like > the instances to know who contains them, but can't seem to avoid memory > leaks. > > The general structure is > > class A: > def __init__(self): > self.list=[] > def add(self,b1): > self.list.append(b) > > class B: > def __init__(self,owner): > self.owner=owner > > a=A() > a.add(B(a)) > > which is clearly loopy :) > > Is there any way to find the 'owner' of an instance? The general case would probably be: class AST: def __init__(self, owner, kids=None): self.owner = owner self.kids = kids if kids is None: self.kids = [] def add(self, kid): self.kids.append(kid) def cleanup(self): for kid in self.kids: kid.cleanup() self.owner = None ...which obviously requires an explicit call to root.cleanup() when you're done. I-suppose-I-could-charge-Andy-for-that--ly y'rs - Gordon From mlh at idi.ntnu.no Sun Mar 19 12:31:43 2000 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 19 Mar 2000 18:31:43 +0100 Subject: Code basics References: Message-ID: <8b32v1$rfk$1@kopp.stud.ntnu.no> Moshe Zadka wrote in message news:Pine.GSO.4.10.10003171839240.12462-100000 at sundial... > On Fri, 17 Mar 2000, JJ wrote: > > > I'm a C/C++/Java programmer and wonder how to make "code blocks" in Python. > > > > Please translate this to Python: > > while notDone: > int chip = this.getNumberOfSomething() > if chip == 0: > print "Tjohoo" > else: > print "Oh no!" > > With the customary 1.5 factor of LOCs reduce promised Actually - if you remove the illegal "int", then the reduction would be even greater, if you don't count the necessary whitespace which you have omittet ;) -- Magnus Lie Hetland magnus @ hetland . org From akuchlin at mems-exchange.org Tue Mar 28 16:48:02 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 28 Mar 2000 16:48:02 -0500 Subject: Perfect hash generator Message-ID: <3du2hqwyul.fsf@amarok.cnri.reston.va.us> I've written an amusing little hack, a script that generates perfect minimal hash functions. Perfect hash functions are commonly used in cases where you have some fixed number of symbols, and want to distinguish between them without having to do string comparisons. For example, compilers often use perfect hashes for the set of keywords in the language they support, so they can do 'token = perfecthash(string) ; switch (token) {...}'. The perfect_hash.py script outputs Python code for the perfect hash that looks like this: f1 = lambda key: hash('Xk6mtQxP9w' + str(key)) % 15 f2 = lambda key: hash('DrCEzy4RWs' + str(key)) % 15 G = [ 0, 1, 0, 9, 2, 10, 3, 7, 11, 6, 14, 13, 2, 8, 0, ] def perfecthash(key): return (G[ f1(key) ] + G[ f2(key) ] ) % 15 In this case, perfecthash('January') == 1, perfecthash('October') == 10, and so forth. Where do the numbers come from? They're magic! [1] A Web page for the code is at: http://starship.python.net/crew/amk/python/code/perfect-hash.html Comments & suggestions welcomed! [1] The magic incantations are explained in "Optimal algorithms for minimal perfect hashing", G. Havas, B.S. Majewski. ftp://ftp.csee.uq.oz.au/pub/Publications/Techreports/department/TR0234.dvi.gz Pretty elegant algorithm... -- A.M. Kuchling http://starship.python.net/crew/amk/ She was no longer Delight, and the blossoms had already begun to fall in her domain, becoming smudged and formless colours, and she had no one to talk to... -- Delight becomes Delirium, in SANDMAN #42: "Brief Lives:2" From effbot at telia.com Mon Mar 27 19:25:30 2000 From: effbot at telia.com (Fredrik Lundh) Date: 27 Mar 2000 18:25:30 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Mar 27) Message-ID: <531B7A1447F41DB4.59CA52C7EF898133.62ED2257DEDF9F8E@lp.airnews.net> ComputerWorld Canada: 'Python Puts the Squeeze' http://www.itworldcanada.com/cw/archive/cw16-05/cw_wtemplate.cfm?filename=c165sb1.htm UCSC Extension: Python Programming Course http://www.ucsc-extension.edu/knowledge_is_timeless/qd/softlist.taf?function=detail New releases: Stacey Verner: POVTalk -- a natural language based 3D scene generator: http://homepages.ihug.co.nz/~synopsis/computing/main.html FourThought: new versions of 4DOM, 4XPath and 4XSLT. http://fourthought.com/4Suite/4DOM/ http://fourthought.com/4Suite/4XPath/ http://fourthought.com/4Suite/4XSLT/ Georg Mischler: Python for Autocad (release 0.2) http://www.deja.com/=dnc/getdoc.xp?AN=597100850 Duncan Grisby: omniORB for Python (pre-release 2) http://www.deja.com/=dnc/getdoc.xp?AN=596902633 Hints, tips, and other useful stuff seen on the newsgroup: Gordon McMillan: How to implement synchronized blocks in Python: http://www.deja.com/=dnc/getdoc.xp?AN=598532061 Fredrik Lundh: How to figure out the event name inside a Tkinter event callback: http://www.deja.com/=dnc/getdoc.xp?AN=597839028 Michael Hudson: How to calculate SHA hashes: http://www.deja.com/=dnc/getdoc.xp?AN=598658648 Fredrik Lundh: An Asynchronous Whois Client: http://www.deja.com/=dnc/getdoc.xp?AN=598407343 Travis Oliphant: Signal Processing with Numerical Python http://www.deja.com/=dnc/getdoc.xp?AN=597424795 Tim Peters: Citizens, Virgins, and Turds -- all you ever wanted to know about Python's dictionary implementation: http://www.deja.com/=dnc/getdoc.xp?AN=597157519 And finally, Steven Majewski tells us the true story behind the Python SPAM conferences: http://www.deja.com/=dnc/getdoc.xp?AN=598401775 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org eff-bot's complements this digest with his daily python url http://hem.passagen.se/eff/url.htm Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium The Vaults of Parnassus ambitiously collects Python resources http://www.vex.net/~x/parnassus/ Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. http://www.egroups.com/list/python-url-leads/ 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 wtanksle at dolphin.openprojects.net Tue Mar 21 17:31:59 2000 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Tue, 21 Mar 2000 22:31:59 GMT Subject: what is easier to learn first?... References: <8b861c$ecn$1@nnrp1.deja.com> Message-ID: On Tue, 21 Mar 2000 18:11:57 GMT, Grant Edwards wrote: >In article <8b861c$ecn$1 at nnrp1.deja.com>, kgec at my-deja.com wrote: >>> After learning Python, I would recommend Scheme, Modula-3, or >>> Smalltalk. >>I'd be interested in your reasons for recommending Scheme. >>Part of the reason, no doubt, was that I'd been working with >>imperative languages of one sort or another since the 1960s. Is >>your thinking that the original poster should get some >>experience with functional languages before he begins to >>develop programming habits and preferences? >Sure. Scheme requires you think differently: functional and/or >recursive rather than imperative loops. Smalltalk is yet >another world-view (message passing). Modula-3 is a >strongly-typed, statically-lexically-scoped imperative >language. Scheme and Python, by all means; but replace Smalltalk with ML and Modula-3 with Java. If you can, replace Scheme with Lisp, on the principle that Lisp is much more likely to be useful on the job. >Learning Python, Scheme, Modula-3 and Smalltalk will give you a >nice broad view of programming (four decent examples of four >different paradigms) and make you learn to think in different >ways, which is A Good Thing(TM). Um... Those languages are almost identical. Even with my additions, the only language which really stands out is ML. If you want a broad base of knowledge, try this: - Python (learn this first) - Haskell/ML - Prolog/Mercury - Forth/Joy - APL/J/K You have one starter language (and it's generally useful as well), one strongly typed purely functional applicative language, one logical declarative language, one functional concatenative language, and one combinative array language. It's also good to learn either Lisp or Ada, to see what a language with a really complete library is like. But at this point, of course, you want to learn all of the languages in the world, and there's not much to stop you, especially if you're a 'bot (like Tim) or immortal (like Sam). >Then, if you actually want a job, I guess you can learn C++ or >something. The problem is, after learning Python, Scheme, >Smalltalk, and M3, you realize how utterly messed-up C++ is, >and you'll be miserable using it. ;) Grin. >Grant Edwards grante Yow! Darling, my ELBOW -- -William "Billy" Tanksley From grant at nowhere. Thu Mar 23 17:59:00 2000 From: grant at nowhere. (Grant Edwards) Date: Thu, 23 Mar 2000 22:59:00 GMT Subject: Pointers References: <38D00DCE.9740380F@be-research.ucsd.edu> <38DA9F8C.E9133C71@be-research.ucsd.edu> Message-ID: In article <38DA9F8C.E9133C71 at be-research.ucsd.edu>, Curtis Jensen wrote: >Python does work on a reference setup, but it's not exactly >like pointers. For example: >>>> a = 5 >>>> b = a >>>> a = 3 >>>> print b >5 > >If b were a pointer to b then print b would return 3, not 5. No, b isn't a pointer to a. b is a pointer to whatever a was pointing to when the assignment a = b was made. It's the same as pointers in C: const int object5 = 5; const int object3 = 3; a = &object5; b = a; a = &object3; b points to object5, and a points to object3. *a == 3 and *b == 5 just like Python. >There is the problem of mutable types and immutable types here, >but the same thing occurs if you use a mutable type. So, >pointers and python referances are not the same. I'm afraid I still don't see how they're different. -- Grant Edwards grante Yow! I want the presidency at so bad I can already taste visi.com the hors d'oeuvres. From quinn at ngwee.ugcs.caltech.edu Wed Mar 29 15:22:09 2000 From: quinn at ngwee.ugcs.caltech.edu (Quinn Dunkan) Date: 29 Mar 2000 20:22:09 GMT Subject: lambda References: <20000329063753.20711.cpmta@c000.sfo.cp.net> Message-ID: On 28 Mar 2000 22:37:53 -0800, Falknor wrote: >Hmm, what exactly is the use of lambda? It just isn't clickin for some >reason.... Are they just syntactical candy (such as the ternary operator ?: >in C++ is syntactical candy..) or what. *ponders* Anyone who could explain >it, and gimme a little example would have my thanx. :) f = lambda x: x * 2 is the same as def f(x): return x * 2 In other words, lambda is just another way of writing `def' except that it doesn't have to be named and you can only put an expression in it (return is implicit). It's intended to be a shorthand to write small functions easier, but that's all it is: a shorthand. This is unlike, say, scheme, where it is the *only* way to define functions. Remember, in python, a function is just another type, like integers and strings and classes. Classes use Classname() as a type constructor, strings use ""s, and functions use def and lambda. It's useful for HOFs (higher-order functions) which want a function as an arg, like map, filter, and reduce. From mhammond at skippinet.com.au Sat Mar 25 03:21:54 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 25 Mar 2000 08:21:54 GMT Subject: Problem Embedding PythonWin in VC++ 6 References: Message-ID: "Miles Rizzo" wrote in message news:A99C4E4230CD7B23.4ACDFE2CFC2E7039.0451184D836BA62E at lp.airnews.net ... > > script in an MFC app using VC 6.0. I followed > > the instructions in "Using Pythonwin in an external project" > > (http://www.python.org/windows/pythonwin/EmbeddingWin32ui.html) but my > > application crashes. The DLL loads and the address of the function is > found > > but calling the Win32uiApplicationInit function causes a crash. That doc is very old. Just look at pythonwin.cpp - it is less than 150 lines of code (including blanks and comments). You will note that InitApplication() is where the DynamicApplicationInit() call now lives, and InitInstance() simply calls glue.InitInstance(). Mark. From mlauer at trollinger-fe.rz.uni-frankfurt.de Mon Mar 20 05:35:20 2000 From: mlauer at trollinger-fe.rz.uni-frankfurt.de (mlauer at trollinger-fe.rz.uni-frankfurt.de) Date: 20 Mar 2000 11:35:20 +0100 Subject: Which CORBA binding ? References: <38d5d5fa@nntp.server.uni-frankfurt.de> <87n1nux9q2.fsf@parus.parus.no> Message-ID: <38d5fee8@nntp.server.uni-frankfurt.de> Hi. Thanks for the quick answer. > Well, you can get some work done with ORBit-python. Bugs are being > shaken out at a fast rate. But it doesn't use the CORBA standard for Python > bindings. What problems could arise of this ? > It isn't able to compile IDL to stubs and skeletons, but > imports it on the fly. This is quite fast, and does away with the need > to locate the stubs and skeletons, but it can obviously be a > bottleneck in some applications. Agreed, but for me it sounds like a great feature. > pyOrbit isn't able to compile IDL yet. You have to handcraft Python > stubs and skeletons around the C versions. Ok, then ORBit-python sounds better for me. > Are you interested in CORBA/Python in general or just for the GNOME > environment? in general. I've done some stuff in c++ with MICO (http://www.mico.org) which now shall work together with some python clients and servers. Best regards, Mickey. -- Regards & Gruesse from Mickey @ http://www.Vanille.de --------------------------------------------------------- How could anyone know me - when I don't even know myself ? From darrell at dorb.com Sun Mar 12 11:02:24 2000 From: darrell at dorb.com (Darrell) Date: Sun, 12 Mar 2000 16:02:24 GMT Subject: Forth like interpreter References: <158801bf8bdc$08516040$6401a8c0@dorb> Message-ID: "Will Ware" wrote. > > Isn't it fun? I've written them in assembly language for 6809 > and a Texas Instruments DSP, and one or two in C, and here's > one in Java (source included): > http://world.std.com/~wware/agj/ag.html > Nothing like graphics and a cool subject to really impress! Wonder if Forth interpreters are like one of the first software life forms to take hold in new environments? The slowest one I ever wrote ran in Dbase2. > Too much of this, and you'll start appreciating just how nice > it is to have a reasonably smart compiler around (like the one > in Python). Something like "Why jump out of a perfectly good airplane" ? It's interesting to think about Stackless Python and Forth. I think Forth hackers have be dealing with continuations for years. Task schedulers swap out the (dataStack, returnStack, pc) and you have threads. Want a continuation, make a copy of these data structures and save them. --Darrell From python-list at teleo.net Thu Mar 9 11:42:05 2000 From: python-list at teleo.net (Patrick Phalen) Date: Thu, 9 Mar 2000 08:42:05 -0800 Subject: FTP hangs on close In-Reply-To: References: Message-ID: <00030908433401.01047@quadra.teleo.net> [Oleg Broytmann, on Thu, 09 Mar 2000] :: Yes, I found that too. But I never saw an HTTP URL where my robot would :: always hangs. It hangs sometimes on one URL, being run after few days it :: would hangs on other URL... :: But there are some FTP URLs where my robot *always* hangs... :( :: (ftp://starship.python.net is one of these bad sites :) Are you behind NAT? Some servers won't accept PASV connection attempts. From r-stadhe at online.no Sun Mar 26 09:42:18 2000 From: r-stadhe at online.no (RCS) Date: Sun, 26 Mar 2000 16:42:18 +0200 Subject: Memory leak in wxPython? References: <38DA870C.FBEC108F@hassler.de> Message-ID: I'm using Windows 98, 2nd edition. I have gotten feed-back from other users of wxPython that Windows NT does not leak any memory, however. I have tested the routines on several Windows 98 machines, and the memory loss is consistent. Regards, RCS Gerald Klix wrote in message news:38DA870C.FBEC108F at hassler.de... > Rolf C Stadheim wrote: > > > Are there any memory issues in Python I should be aware of (correct clean-up > > after using modules ect)? > > > > I'm loosing "massive" amounts of memory for every opening/closing of a > > python application with wxPython (between 0.2 and 0.8 MB for every > > opening/closing)! > > > > I have testet several scripts on two machines, and everytime there is loss > > of memory. > > > > This memory cannot be reclaimed in any other way than rebooting the machine. > > > > Too bad, since I was on my way to implement wxPython in a commercial > > application. > > > > I'm hoping, however, that the fault lies with me, and if so, what could it > > be? > > > > Rolf C Stadheim > > Which OS do you use? > From a_kaklis at pat.forthnet.gr Thu Mar 9 07:43:24 2000 From: a_kaklis at pat.forthnet.gr (ÊáêëÞò Áíôþíéïò) Date: Thu, 9 Mar 2000 14:43:24 +0200 Subject: Distutils Message-ID: <8a86k3$ke2$1@medousa.forthnet.gr> I run Python on a Win98 machine. I'm totally new to Python. I don't know how to install Distutils. Or even how to run it. Please help me. Thank you From python-list at teleo.net Fri Mar 3 19:29:55 2000 From: python-list at teleo.net (Patrick Phalen) Date: Fri, 3 Mar 2000 16:29:55 -0800 Subject: Programmatically Getting Process ID In-Reply-To: References: Message-ID: <00030317025200.02808@quadra.teleo.net> [Samuel A. Falvo II, on Fri, 03 Mar 2000] :: Is there a way that I can programmatically obtain a process ID for a :: particularly named process? For example, I'd like to be able to do this: :: :: pid = get_pid_of( "radiusd" ) :: kill( pid, SIGHUP ) :: :: What would get_pid_of() be defined as? How about: def get_pid_of(name): thispid = os.getpid() # in case script has the search string in its name cmd = "%s%s" % ('ps -ef | grep ', name) procs = os.popen(cmd).readlines() for line in procs: g = string.split(line) try: pid = g[1] except IndexError: print 'oops' raise SystemExit else: pid = int(pid) if pid == thispid: pass else: os.kill(pid, SIGHUP) figuring out how to keep from delivering an error to stdout for child processes is left as an exercise for those less lazy than I From echeverria at interactiva.cl Sun Mar 19 07:14:29 2000 From: echeverria at interactiva.cl (Cristian Echeverria) Date: Sun, 19 Mar 2000 08:14:29 -0400 Subject: id() trickery References: Message-ID: <38d4c3d9@omega> > Could someone tell me why the value returned by id(), which is just an > int, says type(), is acting a little fruity for me? If a and b hold the > same integer, shouldn't they have the same value for id()? And why do > > >>> a = b # and > >>> a = b + 0 > > have two different effects? Id() return something like the current address of an object. a = b means that a and b are the same objects, if then you write b = 100 print a, will print 100 a = b + 0, then the operation "+" return a new object changing the name binding to "a" From robin at jessikat.demon.co.uk Thu Mar 16 09:45:28 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 16 Mar 2000 14:45:28 +0000 Subject: AST structures and memory leaks In-Reply-To: <1258906958-9249420@hypernet.com> References: <1258906958-9249420@hypernet.com> Message-ID: In message <1258906958-9249420 at hypernet.com>, Gordon McMillan writes >Robin Becker wrote: > > .... >> Is there any way to find the 'owner' of an instance? > >The general case would probably be: > >class AST: > def __init__(self, owner, kids=None): > self.owner = owner > self.kids = kids > if kids is None: > self.kids = [] > def add(self, kid): > self.kids.append(kid) > def cleanup(self): > for kid in self.kids: > kid.cleanup() > self.owner = None > >...which obviously requires an explicit call to root.cleanup() >when you're done. > >I-suppose-I-could-charge-Andy-for-that--ly y'rs > >- Gordon I already had the obvious programmer failing solution :( I was hoping for some super meta programming solution which avoids the cycle somehow. Andy doesn't want to use acquisition which would probably solve the problem in a pinch. -- Robin Becker From corg at copernic.com Fri Mar 10 11:56:36 2000 From: corg at copernic.com (Gaetan Corneau) Date: Fri, 10 Mar 2000 11:56:36 -0500 Subject: File question Message-ID: Hi, I just want to read a file's attributes (particularly the read-only attribute). Is there a function somewhere for that? Thanks, ______________________________________________________ Gaetan Corneau Software Developer Copernic Technologies inc. http://www.copernic.com E-mail: corg at copernic.com ______________________________________________________ "Tu l'as trop ?cras?, C?sar, ce Port Salut" -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/B/MU d- s+:++ a C++ UL+ P--- W+ N- K- W++ t-- !5 X- R+ tv-- b++ DI++ G e++ h---- r+++ y++++ ------END GEEK CODE BLOCK------ From phd at phd.russ.ru Fri Mar 24 06:31:59 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 24 Mar 2000 11:31:59 +0000 (GMT) Subject: Python drives me mad... In-Reply-To: <38d63af7$0$29755@businessnews.de.uu.net> Message-ID: On Mon, 20 Mar 2000, Boris Ottlewski wrote: > FILE *stream; > char temp[8192]; > new_stdout = PyFile_FromString("c:\\freopen.out", "w"); > PySys_SetObject("stdout", new_stdout); > file://PySys_SetObject("stderr", new_stdout); > int res = PyRun_SimpleString("print 2\n"); > Py_XDECREF(new_stdout); > > This should print the "2" to the redirected stdout which is c:\freopen.out. > But the file is empty!!!!!!!!!! and...I cant delete it, it is still locked > (shouldnt Py_XDECREF close it?) No, it shouldn't. There are more links to the object (2 links from sys module; these links are created by you, do you remember?) Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From parkw at better.net Mon Mar 27 16:51:49 2000 From: parkw at better.net (William Park) Date: Mon, 27 Mar 2000 16:51:49 -0500 Subject: else clauses in while and for loops In-Reply-To: <8boe2k$gmh$1@inputplus.demon.co.uk>; from ralph@inputplus.demon.co.uk on Mon, Mar 27, 2000 at 08:50:44PM +0100 References: <38DD2EE3.C7F3CB54@webamused.com> <8boe2k$gmh$1@inputplus.demon.co.uk> Message-ID: <20000327165149.A1525@better.net> On Mon, Mar 27, 2000 at 08:50:44PM +0100, Ralph Corderoy wrote: > > > Please give some examples showing the real need for else clauses in > > > this context. > > > > def lookup(stringList, word): > > """Finds the first instance of word in stringList. Returns -1 if not > > found""" > > i = 0 > > while i < len(stringList): > > if stringList[i] == word: > > break > > i = i + 1 > > else: > > # is only executed if we never hit that break > > return -1 > > return i > > I don't think that is a real need. Wouldn't it normally be written to > return ASAP rather than jump through hoops. > > def lookup(stringList, word): > i = 0 > while i < len(stringList): > if stringList[i] == word: > return i > i = i + 1 > return -1 > > Ralph. True. But, using "else" avoids having to deal with a local variable to find out how it left the loop. --William From cmcurtin at interhack.net Sat Mar 4 22:54:16 2000 From: cmcurtin at interhack.net (Matt Curtin) Date: 04 Mar 2000 22:54:16 -0500 Subject: Best book to learn Python? References: Message-ID: >>>>> "Snoopy" == Snoopy :-)) writes: Snoopy> There is a New Book which supposed to be a very good one for Snoopy> Beginners. It is expected to be available Snoopy> March-21. Published by "SAMS". The Title is: "Teach Snoopy> Yourself Python In 24-Hours" I haven't seen the text at all, so I cannot comment on it specifically. (I also know that this isn't Alan's book.) Don't let the title fool you. Learning Python in 24 hours is a task that couldn't be reasonably undertaken by anyone but someone who is already an expert programmer and those books tend not to be targeted for that audience. A more realistic view of what is necessary to be a good programmer can be found on Peter Norvig's site, http://www.norvig.com/21-days.html. -- Matt Curtin cmcurtin at interhack.net http://www.interhack.net/people/cmcurtin/ From gvwilson at nevex.com Sat Mar 11 10:50:41 2000 From: gvwilson at nevex.com (Greg Wilson) Date: Sat, 11 Mar 2000 10:50:41 -0500 Subject: What is the Python mainstream for the GUI Lib ..?? References: <8ad724$lpb$1@bw107zhb.bluewin.ch> Message-ID: > Markus Meng wrote: > >...before investing serious amount > >of time in one GUI-Lib, I would like to 'feel' which GUI-LIB > >will be used mostly from the python-users in the near future... >"Cameron Laird" wrote> . > Tkinter. > Beyond that, no one knows. It's part of the Python character > that, as you noted, there are several bindings available, they're > all quite usable, practitioners mildly spar over their merits, > and their ultimate destinies remain obscure. Greg Wilson writes: ...which is a real pain for those of us who are trying to persuade people that Python is a credible solution to their problems... From arnold at dstc.edu.au Fri Mar 31 20:59:43 2000 From: arnold at dstc.edu.au (David Arnold) Date: Sat, 01 Apr 2000 11:59:43 +1000 Subject: Python 1.6 alpha 1 released In-Reply-To: Your message of "Fri, 31 Mar 2000 18:25:41 MST." <38E55015.3907B68A@roguewave.com> Message-ID: <200004010159.LAA00403@piglet.dstc.edu.au> -->"Bjorn" == Bjorn Pettersen writes: Bjorn> Some of us have jobs that doesn't involve administering Bjorn> servers, and fixing things when they break, but rather Bjorn> working on getting the next release of the software we can Bjorn> charge for out the door. The more time I spend on fixing Bjorn> compatibility issues in Python scripts, the less time I spend Bjorn> on "real" work. you have been using incorrect arguments. the fact that they worked was unfortunate because it leads to circumstances like this. but the time you have spent on these emails would have been enough to run a simple script over your code to fix the problem ... ;-) the more strict the library interfaces are, the better IMHO. d From claird at starbase.neosoft.com Fri Mar 24 10:52:44 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 24 Mar 2000 09:52:44 -0600 Subject: what is easier to learn first?... References: Message-ID: In article , Grant Edwards wrote: . . . >I don't know how many painfully boring hours I spent many years >ago in a numerical analysis class learning ways of finding >Eigen values and Eigen vectors. Something I never had to do >before or since. I can only presume that somebody who does . . . Just as there are different languages for different minds ... My own reaction is that computational linear algebra is so beautiful that rendering it boring should be a felony. Personally, I see eigenvalues everywhere-- planting onions, coding HTML, changing flat tires. I understand that not everyone shares that perspective. Given a bit more leisure, I'm sure I can tie this back in to the Python-for-education threads. Not this morn- ing, though. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From sblakey at freei.net Tue Mar 21 16:04:03 2000 From: sblakey at freei.net (sblakey at freei.net) Date: Tue, 21 Mar 2000 13:04:03 -0800 (PST) Subject: Thread limitations and SocketServer? Message-ID: <20000321210042.1BFF01CDB9@dinsdale.python.org> I am running a SocketServer on a Linux box (/prov/version is Linux version 2.2.13 (root at ooc3) (gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)) #2 SMP Wed Dec 29 07:57:42 PST 1999) and am running into a thread-related problem. Once this server is hit with a heavy enough load, the following traceback begins to appear with alarming frequencey: Traceback (innermost last): File "/usr/lib/python1.5/SocketServer.py", line 213, in handle_request self.process_request(request, client_address) File "/usr/lib/python1.5/SocketServer.py", line 321, in process_request (request, client_address)) error: can't start new thread The offending section of the SocketServer module seems innocuous enough: def process_request(self, request, client_address): """Start a new thread to process the request.""" import thread thread.start_new_thread(self.finish_request, (request, client_address)) Obviously some internal limitation on the number of concurrent threads is being reached. My question is: is this problwm solvable within python? Is this a limitation of the python thread implementatio, or will I need to dive down deeper to the underlying pthreads? Will I have the same problem if I rework the server to use asyncore instead of SocketServer? From torppa at polykoira.megabaud.fi Tue Mar 21 08:35:52 2000 From: torppa at polykoira.megabaud.fi (Jarkko Torppa) Date: 21 Mar 2000 13:35:52 GMT Subject: file manipulation and write permission References: <8b7etk$tr5$1@nnrp1.deja.com> Message-ID: <8b7tro$2q1$1@news.kolumbus.fi> In article <8b7etk$tr5$1 at nnrp1.deja.com>, tiddlerdeja at my-deja.com wrote: >I trying to manipulate a whole load of files. However I don't have >write permission on all the files (I do have ownership of them). > >Can some tell me how I make a file writeable in a Python script? You want os.chmod() something like import os,stat def mkwrite(fp): os.chmod(fp,os.stat(fp)[stat.ST_MODE] | stat.S_IRWXU) should work, not sure if stat.S_IRWXU is allways defined. >A solution that would work in JPython1.1 would also be great! Dunno about that, but I would try that same snippet first. -- Jarkko Torppa torppa at staff.megabaud.fi Megabaud Internet-palvelut From derek at ooc.com.au Sun Mar 26 19:13:29 2000 From: derek at ooc.com.au (Derek Thomson) Date: Mon, 27 Mar 2000 10:13:29 +1000 Subject: regular expressions questions References: <11A17AA2B9EAD111BCEA00A0C9B4179305321B0A@molach.origin.ea.com> <38D6DDAA.F69F3BEC@ooc.com.au> <3d3dpiejnj.fsf@amarok.cnri.reston.va.us> Message-ID: <38DEA7A9.CB1C324F@ooc.com.au> "Andrew M. Kuchling" wrote: > > "Darrell" writes: > > [Derek Thomson] > > > [ And now, at last, Perl 5.6 allows regexes to refer to other regexes. So > > >now we > > > can uses regexes to parse balanced expressions like matching parenthesis. > > Actually, this was an experimental feature in Perl5.005. Search > the perlre documentation for the (?{ code }) construct. > > > >No doubt this will appear in Python's re module before long. ] > > This is highly unlikely, because last time around we couldn't come up > with a way to do this that wasn't impressively ugly. See the thread > starting with this July 1998 article: > > > The general tenor of opinion seemed to be that, if you want to parse > expressions, use a real parser generator, and we certainly have enough > of those for Python. Really? I couldn't find anything that was even half as good as Perl's Parse::RecDescent, after doing some searching from python.org. Links? > Adding a feature to regexes for this produces > difficult-to-read code -- you need a pretty intimate knowledge of > exactly how the computer tries matches and then backtracks -- and > makes the matching engine more complicated. So this feature is almost > certainly not going to be added. (Elegant patches to add a new > feature, of course, can often reverse theoretical objections.) There is a large class of parsing applications for which writing an entire grammar is overkill (or too much CS background is needed for the user. cp4e?), but in which being able to match balanced subexpressions is necessary and useful. We'll just have to stick to Perl for those, I guess. I'm sure a decent syntax could be devised with a little thought. After all, the named subexpression idea is very good, and a great improvement over Perl's numbering system ie $1, $2 etc. Regards, Derek From alan.gauld at gssec.bt.co.uk Thu Mar 2 09:32:12 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Thu, 02 Mar 2000 14:32:12 +0000 Subject: Best book to learn Python? References: Message-ID: <38BE7B6C.CA08BFCF@gssec.bt.co.uk> Snoopy :-)) wrote: > There is a New Book which supposed to be a very good one for Beginners. It > is expected to be available March-21. Published by "SAMS". > The Title is: "Teach Yourself Python In 24-Hours" > The Author is: Alan Gauld. If that's what it says it's wrong! This is Ivan's book. I have a Web tutor for begoinners (and am publishing an enhanced version as a book hopefully later this year) but TYP in 24H is Ivan not me! > He also has a Tutorial called "Learning To Program" > which I found very good. Thanks for that, it is mine! > You can get it at the following Site: > http://www.python.org/doc/Intros.html Or directly at: http://www.crosswinds.net/~agauld/ (No adverts on this one!) Giving-credit-where-credit-is-due'ly yrs, Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From bjorn at roguewave.com Mon Mar 20 12:57:20 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Mon, 20 Mar 2000 10:57:20 -0700 Subject: Pascal int() References: <1258726940-20077342@hypernet.com> Message-ID: <38D66680.316F21D1@roguewave.com> Gordon McMillan wrote: > [...] > I can assure you that no Python god, archangel, angel, > seraphim or cherubim would ever write anything but > a = a + 1 > > - Gordon ... of course, if P3K changed the meaning of 5 from "the object 5" to "a constructor for an Integer class, setting the value to 5" you could do all kinds of fun things, including: a = 5 a.inc() And even though it would be backwards compatible, I don't really have high hopes for it being accepted (change? we don't need no stinking change ;-) -- bjorn From thehaas at my-deja.com Mon Mar 6 23:20:21 2000 From: thehaas at my-deja.com (thehaas at my-deja.com) Date: Tue, 07 Mar 2000 04:20:21 GMT Subject: uploading a binary file with ftplib Message-ID: <8a2022$ttd$1@nnrp1.deja.com> I've submitted this to python.faqts.com, but no one has answered. So I'm asking it here. . . I'm trying to upload a binary file to a site using ftplib. I can log in successfully and do "cd dir_name", but cannot figure out how to upload the file. The standard Python module documentation seems a bit cryptic to me in this case (though it is usually quite good). This is the command I have used: ftp.storbinary('stor ravine.pyc',open('ravine.pyc','r').read(),2) And this is my result: Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/ftplib.py", line 366, in storbinary buf = fp.read(blocksize) AttributeError: 'string' object has no attribute 'read' Anyone have any insight? Thanks a lot, - mikeh Sent via Deja.com http://www.deja.com/ Before you buy. From phawkins at spamnotconnact.com Sat Mar 4 20:58:55 2000 From: phawkins at spamnotconnact.com (Patricia Hawkins) Date: 04 Mar 2000 20:58:55 -0500 Subject: CGI Scripts References: Message-ID: >>>>> "AME" == Anders M Eriksson writes: AME> First I would add two 'debug' lines to the script AME> sys.stderr = sys.stdout AME> print "Content-Type: text/plain\n" ... AME> One thing I have noticed is that if I get an error/exception in the AME> script then I get somekind of default blank HTML-page. Or you could read documentation in cgi.py and follow the debugging suggestions contained therein: ................. Fortunately, once you have managed to get your script to execute *some* code, it is easy to catch exceptions and cause a traceback to be printed. The test() function below in this module is an example. Here are the rules: 1. Import the traceback module (before entering the try-except!) 2. Make sure you finish printing the headers and the blank line early 3. Assign sys.stderr to sys.stdout 3. Wrap all remaining code in a try-except statement 4. In the except clause, call traceback.print_exc() For example: import sys import traceback print "Content-type: text/html" print sys.stderr = sys.stdout try: ...your code here... except: print "\n\n
"
                traceback.print_exc()

Notes: The assignment to sys.stderr is needed because the traceback
prints to sys.stderr.  The print "\n\n
" statement is necessary to
disable the word wrapping in HTML.

If you suspect that there may be a problem in importing the traceback
module, you can use an even more robust approach (which only uses
built-in modules):

        import sys
        sys.stderr = sys.stdout
        print "Content-type: text/plain"
        print
        ...your code here...

This relies on the Python interpreter to print the traceback.  The
content type of the output is set to plain text, which disables all
HTML processing.  If your script works, the raw HTML will be displayed
by your client.  If it raises an exception, most likely after the
first two lines have been printed, a traceback will be displayed.
Because no HTML interpretation is going on, the traceback will
readable.

When all else fails, you may want to insert calls to log() to your
program or even to a copy of the cgi.py file.  Note that this requires
you to set cgi.logfile to the name of a world-writable file before the
first call to log() is made!

-- 
Patricia

Successfully verbose user of speech recognition software.


From tjreedy at udel.edu  Tue Mar 28 18:00:29 2000
From: tjreedy at udel.edu (Terry Reedy)
Date: Tue, 28 Mar 2000 18:00:29 -0500
Subject: __getattr__ / __setattr__ - infinite recursion!?
References: <0yMD4.624$HG1.20784@nnrp1.uunet.ca>
Message-ID: <8brdgr$7qn$1@news.udel.edu>

"Warren Postma"  wrote in message
news:0yMD4.624$HG1.20784 at nnrp1.uunet.ca...
>
>
> Okay my first attempt at a "static type checking object" for Python blows
> up, probably
> a stack overflow, probably due to infinite recursion or some such
thing....

Yes.  Within __setattr__(), you should use explicit references to
self.__dict__[attribute]
instead of self.attribute, which may lead to recursive calls to
__setatttr__.  Probably ditto for __getattr__.

> # "type objects"
> int_type       = type(0)
> string_type    = type("X")
> float_type     = type(0.1)

You can also use 'type' module ('import type' or 'from type import *'),
which supplies IntType, etc, including some types that most people would
have difficulty creating innocuous instances of.

>     def keyname(self):
>         return self.keyname

self.keyname will always directly reference the attribute (fine by me)
instead of this 'get' method.

Terry J. Reedy







From drew.csillag at starmedia.net  Mon Mar  6 09:54:24 2000
From: drew.csillag at starmedia.net (Andrew Csillag)
Date: Mon, 06 Mar 2000 09:54:24 -0500
Subject: Supporting #line directives 
Message-ID: <38C3C6A0.456900CB@starmedia.net>

I've lately been using python as a target language for various purposes
and I was wondering if anybody has thought of supporting something like
C's #line directives which would make it possible to (without hacking an
exception renderer to badly) show the lines from the original source
file and not the generated python code.  Looking at the existing code it
would appear to be nontrivial to implement (or a patch would have been
attached ).

Or am I the only one?

TIA,
Drew
-- 
print(lambda(q,p):'pmt:$%0.2f'%(q*p/(p-1)))((lambda(a,r,n),t:(a*r/
t,pow(1+r/t,n*12)))(map(input,('amt:','%rate:','years:')),1200.0))



From exarkun at flashmail.com  Thu Mar 23 12:32:00 2000
From: exarkun at flashmail.com (Jp Calderone)
Date: Thu, 23 Mar 2000 17:32:00 +0000
Subject: xmllib default value question
Message-ID: <38DA5510.75C77425@flashmail.com>

I'm using the xmllib toread in configuration files, but I don't 
quite understand how default values are supposed to be accessed.
I've created the tag_ dictionaries, and I'm pretty
sure the XML is correct, but I keep getting KeyErrors when I
try to look up the name of the value in the attribute dictionary.
Here's the basic code (and xml):



class ConfigParser(xmllib.XMLParser):

   tag_network = {'default': 'no'}
   tag_access = {'order': 'allow deny'}
   tag_allow = {'host': '*', 'port': '*'}
   tag_deny = {'host': '*', 'port': '*'}

   def start_allow(self, attr):
	self.value = (attr['host'], attr['port'])



   
	...
]>


	


 As far as I can tell, this should invoke the start_allow()
method with a dictionary something like 
{'host': 'somehost.com', 'port': '*'} but the single line in
start_allow raises a KeyError on port.  Anyone know why/how
to fix this?

 Thanks in advance, jp

-- 
Where a calculator on the ENIAC is equipped with 18,000 vacuum tubes and
weighs 30 tons, computers in the future may have only 1,000 vacuum tubes
and
weigh only 1.5 tons.    -- Popular Mechanics, March 1949
--
 5:26pm up 16 days, 23:55, 3 users, load average: 0.14, 0.06, 0.01


From cpr at emsoftware.com  Thu Mar 30 12:18:13 2000
From: cpr at emsoftware.com (Chris Ryland)
Date: Thu, 30 Mar 2000 17:18:13 GMT
Subject: parsing CSV files with quotes
References: 
Message-ID: 

Warren--

Since I've written a CSV/TSV scanning module (in C) for one of our products,
I'd recommend a simple state machine scanner. The rules are more complex
than meets the eye, if you really want to handle all the random cases that
dumb programs like Access or Excel output.

I've thought about providing a Python wrapper for this scanning wrapper (and
will eventually). If you want to do it yourself, I'd be happy to send you
the C code.
--
Cheers!
/ Chris Ryland, President / Em Software, Inc. / www.emsoftware.com
- - -
"Warren Postma"  wrote in message
news:BDLE4.1642$HG1.47883 at nnrp1.uunet.ca...
> Suppose I have a CSV file where line 1 is the column names, and lines 2..n
> are comma separated variables, where all String fields are quoted like
this:
>
> ID, NAME, AGE
> 1, "Postma, Warren", 30
> 2, "Twain, Shania",  31
> 3, "Nelson, Willy",  57
> 4, "Austin, \"Stone Cold\" Steve", 34
>
> So, the obvious thing I tried is:
>
> import string
> >>> print string.splitfields("4, \"Austin, \\\"Stone Cold\\\" Steve,
> 34",",")
> ['4', ' "Austin', ' \\"Stone Cold\\" Steve', ' 34']
>
> Hmm. Interesting. So I tried this:
>
> >>> print string.splitfields(r'4, "Austin, \"Stone Cold\" Steve", 34')
> ['4,', '"Austin,', '\\"Stone', 'Cold\\"', 'Steve",', '34']
>
> I'm getting close, I can feel it!
>
> The Rules:
>
> 1. All integer and other fields are output as ascii.
> 2. String fields have quotes. Commas are allowed inside the quotes.
> 3. Quotes inside quotes are escaped by a backslash
> 4. Backslashes are themselves quoted by a backslash
>
> Is this complex enough that I basically need the "parser" module of
Python?
>
> Problem is I'm scared of it. Anyone got any Parser Tutorials Howtos/Links?
>
> Or is this beasty solveable by judicious use of Regular Expressions?
>
> While I'm taking up bandwidth, I'll ask another silly question:
>
> Is there a "compressed dbShelve" out there anywhere? In this case I just
> want to store arrays and dictionaries of built-in Python types, in a
> compressed manner, in a bsd database. Anyone heard of something like this?
>
> Warren
>
>




From gerrit at nl.linux.org  Wed Mar  1 09:30:16 2000
From: gerrit at nl.linux.org (Gerrit Holl)
Date: Wed, 1 Mar 2000 15:30:16 +0100
Subject: Tkinter vs. wxPython (was: Which GUI?)
In-Reply-To: <200003011407.JAA06150@smtp2.andrew.cmu.edu>; from geek+@cmu.edu on Wed, Mar 01, 2000 at 09:07:23AM -0500
References:   <5l3dqjckt5.fsf_-_@eric.cnri.reston.va.us>  <200003011407.JAA06150@smtp2.andrew.cmu.edu>
Message-ID: <20000301153016.C4873@nl.linux.org>


> Then  writes: spoke up and said:
> > For fun with buggy user code in Tkinter, try:
> > 
> > import Tkinter
> > b=Tkinter.Button()
> > b.pack()
> > l=Tkinter.Label()
> > l.grid()

Guido did *not* write this. Can you try to quote better in the future,
please?



regards,
Gerrit.

-- 
-----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com
Version: 3.12
GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE?
Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y
-----END GEEK CODE BLOCK-----



From dogboy777 at my-deja.com  Fri Mar  3 09:41:08 2000
From: dogboy777 at my-deja.com (dogboy777 at my-deja.com)
Date: Fri, 03 Mar 2000 14:41:08 GMT
Subject: Path Puzzles
Message-ID: <89oiu3$ggk$1@nnrp1.deja.com>

I've started using Steve Purcell's wonderful PyUnit test framework, and I've
run into a problem with paths and modules.  I want to store all of my test
modules, test files,  in a subdirectory.  What that means is that if, for
example, I have a module called command.py and an associated testing module
called tcommand.py, I need to import command. py into tcommand.py. 
tcommand.py needs to know to look for command.py in tcommand.py's parent
directory.

So far, I've kludged the problem by setting PYTHONPATH in DOS before I run
the script from DOS or Linux (we use Samba to map our Win95 clients to our
Linux server).	This works, but it means that every time I create a new
project which will have its own test subdirectory, I've got to change
PYTHONPATH.  There's got to be a better way, right?

The other wierd little problem I ran into was that when I created parser.py
and commands.py, their testing modules freaked and refused to call them: 
self.commands = commands.Commands()  would return an "attribute error:
Commands".  However, when I renamed commands.py to jcommands.py and parser.py
to jparser.py, it worked fine.	Is this because Python already has modules
further up the PYTHONPATH called parser.py and command.py, or did I goof up
in some other way?

Thanks,
Anders Schneiderman
National Journal Daily Briefings
Technology Production Manager


Sent via Deja.com http://www.deja.com/
Before you buy.


From cgw at fnal.gov  Mon Mar 27 12:56:03 2000
From: cgw at fnal.gov (Charles G Waldman)
Date: Mon, 27 Mar 2000 11:56:03 -0600 (CST)
Subject: __getattr__/__setattr__ - infinite recursion
Message-ID: <14559.41139.403304.673925@buffalo.fnal.gov>

There are several problems in the script you've posted, below find a
corrected version with the changed lines marked with ##Change

Here's an explanation of the changes:

Change 1:  You raise "Error" but don't define it anywhere.  You must
           create it either as a string, or as an Exception object.

Change 2:  You had "self.reset_to_defaults(self)", one self too many.

Change 3:  This is the main point.  You have no way to init your
           class, because setting the initial attributes - "attrs",
	   "values" and "keyname" - goes through the validation
	   mechanism, which doesn't make sense for these attributes,
	   since the validation mechanism can't be used until
	   these attributes are set up.
	   In general, if you have a setattr hook and need to set 
	   some instance attributes while avoiding this hook, you can do
	   self.__dict__[key] = value, instead of self.key = value
	   
Change 4:  I just hate to see "except:" in code... you should always
           name the exceptions you're looking for, if at all possible.
	   Otherwise debugging becomes impossible - you have a
	   mismatched paren or something, instead of getting a
	   SyntaxError you fall into the unqualified "except:" clause.
	

	

#---------------------------------------------------------------------
# Why does this blow up Python?
#---------------------------------------------------------------------

import os, sys, string, pprint

# "type objects"
int_type       = type(0)
string_type    = type("X")
float_type     = type(0.1)

# required field flags?
required = 1
optional = 0

Error = "Error"  ### Change 1

# Class with strict type checking and a single key:
class zdb_rec:
    def __init__(self, pattern_dict=None, keyname=None):
        "create an object with a strict pattern of required values to make up a type"
        self.set_valid(pattern_dict)
        self.keyname = keyname
        self.reset_to_defaults()  #####Change 2

    def set_valid(self,pattern_dict):
        self.attrs = pattern_dict

    def set_keyname(self,keyname):
        self.keyname = keyname

    def reset_to_defaults(self):
        # fill in default values for each attribute
        self.values = {}
        for x in self.attrs.keys():
            self.values[x] = self.attrs[x][2]

    def keyname(self):
        return self.keyname

    def key(self):
        return self.values[self.keyname]

      # setattr does typesafety check:
    def __setattr__(self,name,value):
        "custom __setattr_ with typesafety check" 
        if name in ('attrs','keyname','values'):  ##Change 3
            self.__dict__[name]=value             ##Change 3
            return                                ##Change 3
            
        try:
            if (value == None) and (not self.attrs[name][1]):
                self.values[name] = None
            else:
                if (type(value) == self.attrs[name][1]):
                    self.values[name] = value
                else:
                    raise Error, "Invalid type in assignment"+`type(value)`
        except KeyError: ######Change 4
            raise Error, "Invalid attribute "+`name`
            
    def __getattr__(self,name):
        try:
            return self.values[name]
        except KeyError: ######Change 4
            raise Error, "Invalid attribute "+`name`

    def attr_count(self):
        return len(self.attrs)

    def validate(self):
        "raises an exception if validation fails, ie requird field not provided"
        for x in self.attrs.keys():
            if self.attrs[x][1]:
                if self.values[x] == None:
                    raise Error, "validate() failed - required field not set"

# "Person Database Schema":
person_attributes = {
 # attribute    type          required?   initialvalue
     "name":    (string_type,    required,  ""),
     "address": (string_type,    required,  ""),
     "age":     (int_type,       required,  0 ),
}


x = zdb_rec(person_attributes,"name")

print "done"





From adustman at comstar.net  Tue Mar  7 15:37:52 2000
From: adustman at comstar.net (Andy Dustman)
Date: Tue, 07 Mar 2000 20:37:52 GMT
Subject: mysql for win98
In-Reply-To: <5Ybx4.6$i17.7664@news.nyc.globix.net>
References: <5Ybx4.6$i17.7664@news.nyc.globix.net>
Message-ID: 

On Tue, 7 Mar 2000, Meshulam Gill wrote:

> Where can I find mysql module for win98?

It's not supported, but supposedly if you follow the README.windows
instructions, it does work.

http://starship.python.net/crew/adustman/MySQLdb.py 

-- 
andy dustman       |     programmer/analyst     |      comstar.net, inc.
telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d
"Therefore, sweet knights, if you may doubt your strength or courage, 
come no further, for death awaits you all, with nasty, big, pointy teeth!"



From tuttledon at hotmail.com  Tue Mar 21 22:59:50 2000
From: tuttledon at hotmail.com (Don Tuttle)
Date: Wed, 22 Mar 2000 03:59:50 GMT
Subject: Does Guido Have A Will? (The legal kind )
References:  <38d80737.2362399@news.uswest.net>
Message-ID: 

[Andrew Pann]
> Believe it or not, this is actually addressed, sorta, in the (a) FAQ.
> Check it out:  http://www.python.org/doc/FAQ.html#2.7

Thanks!  I'd forgotten I'd read this.  After re-reading the various FAQ's
and reading between the lines, it's reassuring to know that Guido's
consciousness will live on forever in a military supercomputer at Langley.
<0.5 wink>

Don





From phd at phd.russ.ru  Wed Mar  1 11:06:53 2000
From: phd at phd.russ.ru (Oleg Broytmann)
Date: Wed, 1 Mar 2000 16:06:53 +0000 (GMT)
Subject: MySQLmodule synthax error
In-Reply-To: <38BD3724.B5E35F7E@scripps.edu>
Message-ID: 

On Wed, 1 Mar 2000, Olivier Roche wrote:
> MySQL.error: You have an error in your SQL syntax near '-dock

   I guess MySQL does not like table names with hyphen. Replace it with
underscore.

Oleg.
---- 
    Oleg Broytmann      Foundation for Effective Policies      phd at phd.russ.ru
           Programmers don't die, they just GOSUB without RETURN.




From moshez at math.huji.ac.il  Sat Mar 18 10:44:26 2000
From: moshez at math.huji.ac.il (Moshe Zadka)
Date: Sat, 18 Mar 2000 17:44:26 +0200 (IST)
Subject: Tokenizing a string
In-Reply-To: <38D38FC2.E7C211BA@hampshire.edu>
Message-ID: 

On Sat, 18 Mar 2000, Michael Dartt wrote:

> I've got a string I'd like to tokenize, but it's not in a file, and it'd
> be rather inefficient to write it to a file just to tokenize it.  Is
> there any function I can use to pass this string to
> tokenize.tokenize()?  

Use StringIO or cStringIO, or just use split('\n') on it, and write a
small class to get out the lines.

--
Moshe Zadka . 
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com




From embed at geocities.com  Thu Mar 30 11:50:27 2000
From: embed at geocities.com (Warren Postma)
Date: Thu, 30 Mar 2000 11:50:27 -0500
Subject: parsing CSV files with quotes
Message-ID: 

Suppose I have a CSV file where line 1 is the column names, and lines 2..n
are comma separated variables, where all String fields are quoted like this:

ID, NAME, AGE
1, "Postma, Warren", 30
2, "Twain, Shania",  31
3, "Nelson, Willy",  57
4, "Austin, \"Stone Cold\" Steve", 34

So, the obvious thing I tried is:

import string
>>> print string.splitfields("4, \"Austin, \\\"Stone Cold\\\" Steve,
34",",")
['4', ' "Austin', ' \\"Stone Cold\\" Steve', ' 34']

Hmm. Interesting. So I tried this:

>>> print string.splitfields(r'4, "Austin, \"Stone Cold\" Steve", 34')
['4,', '"Austin,', '\\"Stone', 'Cold\\"', 'Steve",', '34']

I'm getting close, I can feel it!

The Rules:

1. All integer and other fields are output as ascii.
2. String fields have quotes. Commas are allowed inside the quotes.
3. Quotes inside quotes are escaped by a backslash
4. Backslashes are themselves quoted by a backslash

Is this complex enough that I basically need the "parser" module of Python?

Problem is I'm scared of it. Anyone got any Parser Tutorials Howtos/Links?

Or is this beasty solveable by judicious use of Regular Expressions?

While I'm taking up bandwidth, I'll ask another silly question:

Is there a "compressed dbShelve" out there anywhere? In this case I just
want to store arrays and dictionaries of built-in Python types, in a
compressed manner, in a bsd database. Anyone heard of something like this?

Warren




From kc5tja at garnet.armored.net  Mon Mar 20 08:16:49 2000
From: kc5tja at garnet.armored.net (Samuel A. Falvo II)
Date: 20 Mar 2000 13:16:49 GMT
Subject: Forth like interpreter
References: <158801bf8bdc$08516040$6401a8c0@dorb>  <53YA4.637$jX3.10074@typhoon.nyroc.rr.com>  <425A5D00B0F916D1.7920112131B1A88A.D3428C8A56515B00@lp.airnews.net>
Message-ID: 

In article
<425A5D00B0F916D1.7920112131B1A88A.D3428C8A56515B00 at lp.airnews.net>, Tres
Seaver wrote:

>Forth was the first "brain-bender" language I learned, and the one which
>caused me to learn assembler.  I still credit Forth with making me Lisp-
>impaired, via a kind of hysteresis.

Odd.  Forth is precisely what enabled me to learn Lisp.  Forth is a reverse
Lisp of sorts:

(defun cmpint (x y)
  (cond ((< x y) -1)
        ((= x y) 0)
	(T 1)))

: cmpint ( x y -- f )
  2DUP < IF
    2DROP -1
  ELSE
    = IF
      0
    ELSE
      1
    THEN
  THEN ;

-- 
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA


From just at letterror.com  Wed Mar 15 04:51:38 2000
From: just at letterror.com (Just van Rossum)
Date: Wed, 15 Mar 2000 10:51:38 +0100
Subject: Debugging?
In-Reply-To: 
References: <9JFz4.19$GJ3.1756@news7.onvoy.net>
Message-ID: 

At 9:39 AM +0000 15-03-2000, Mark Hammond wrote:
>I believe the only other graphical debugger available for Python today
>is Pythonwin.

Hey! Not true! The MacPythonIDE has had a (good!) graphical debugger for at
least three years ;-)
(yeah yeah, not relevant to the original poster, but still...)

Just





From godzilla at netmeg.net  Sat Mar 18 13:39:39 2000
From: godzilla at netmeg.net (Les Schaffer)
Date: Sat, 18 Mar 2000 13:39:39 -0500 (EST)
Subject: need fast parser for comma/space delimited numbers
In-Reply-To: <1258719576-20520305@hypernet.com>
References: 
	<1258719576-20520305@hypernet.com>
Message-ID: <14547.52587.788622.143477@gargle.gargle.HOWL>

> Um, I hate to tell you, but... oh, nevermind .

what .... he was refering to black beauties?????? (what is speed
called on the street these days?????)

> Absolutely. This cheap trick is frequently worth 30% to 60% in a
> moderate to tight loop.

this is great. probably worth more to me than this stinking csv parser
;-)


> I *think* I recall that int / float were somewhat faster, but I
> can't be sure. The major thing here is to get away from extra
> function calls. Flatten your loop as much as possible - function
> calls are (relatively) expensive.

yeah. tahts next on  the list.

les



From hnowak at cuci.nl  Mon Mar 20 17:59:28 2000
From: hnowak at cuci.nl (Hans Nowak)
Date: Mon, 20 Mar 2000 23:59:28 +0100
Subject: Reverse of hex()
In-Reply-To: 
Message-ID: <200003202300.XAA22330@dionysus.fw.cuci.nl>

On 20 Mar 00, at 11:43, Gaetan Corneau wrote:

> Hi, 
> 
> I'm looking for the reverse of the hex built-in function: is there any?

You can use eval:

>>> eval('0xf')
15

Or maybe:

>>> string.atoi('0xf', 16)
15

HTH,

--Hans Nowak (zephyrfalcon at hvision.nl)
Homepage: http://www.hvision.nl/~ivnowa/newsite/
Python questions? See http://tor.dhs.org/~zephyrfalcon/snippets
You call me a masterless man. You are wrong. I am my own master.



From jamarijr at hotmail.com  Thu Mar 30 15:37:20 2000
From: jamarijr at hotmail.com (Arinté)
Date: Thu, 30 Mar 2000 20:37:20 GMT
Subject: Function override?
Message-ID: <8c0dtu$lr3$1@nnrp1.deja.com>

I have a class similar to this:

class over:
   somefun(self, bakeint):
      ...
   somefun(self, bakeStr):

If the user uses a string then I want to use the 2nd one, else an
Integer then use the 1st one?

How can I get this?  And what is this call in c, the word escapes me
right now.


Sent via Deja.com http://www.deja.com/
Before you buy.


From aa8vb at yahoo.com  Thu Mar  2 13:47:34 2000
From: aa8vb at yahoo.com (Randall Hopper)
Date: Thu, 2 Mar 2000 13:47:34 -0500
Subject: XML-RPC
In-Reply-To: <89i4eq$snm$1@nnrp1.deja.com>
References: <88aka3$mn4$0@216.39.162.232> <89i4eq$snm$1@nnrp1.deja.com>
Message-ID: <20000302134734.A3900361@vislab.epa.gov>

Lisa:
 |In the page http://www.pythonware.com/products/xmlrpc/, there is a
 |mention that 0.9.9 of xml-rpc would have been out by dec.99, and I would
 |like to know if anyone has any info as to where to find that thing?
 |
 |BTW, is there any info online, - anywhere, - that can link me to more
 |info regarding xml, the standard, the tutorial, and such?

For XML in general, you can pull alot out of search engines real quick.
But here are a few I had bookmarked to get you going.

-- 
Randall Hopper
aa8vb at yahoo.com


     http://www.python.org/sigs/xml-sig/
        Python XML SIG
     http://www.python.org/topics/xml/
        Python.org Recommended XML resources

     http://xml.org/
        XML.ORG
     http://www.xml.com/
        XML.COM On-line Magazine
     http://www.w3.org/XML/
        W3.ORG:  XML
     http://msdn.microsoft.com/xml/default.asp
        MSDN Online: XML Developer Center
     http://www.schema.net/
        SCHEMA.NET: The XML Schema Site
     http://www.oasis-open.org/cover/xml.html
        Oasis: XML
     http://www.xml.com/xml/pub/axml/axmlintro.html
        XML.COM:  The Annotated XML Spec
     http://pdbeam.uwaterloo.ca/~rlander/XML_Tutorial/
        Generally Markup: XML Resources
     http://pdbeam.uwaterloo.ca/~rlander/Introduction_XML/
        Introduction to XML (York University)
     http://www.xml.com/xml/pub/98/10/guide1.html
        XML.COM:  What is XML?
     http://www.sun.com.au/sjug/pres/xml/JavaAndXML/seminar.html
        Java & XML: 1 + 1 > 2
     http://www.wdvl.com/Authoring/Languages/XML/Tutorials/
        WDVL: XML Articles and Tutorials
     http://www.oasis-open.org/cover/
        The SGML/XML Web Page - Home Page
     http://www.stud.ifi.uio.no/~lmariusg/linker/XMLtools.html
        Free XML software
     http://www.zdnet.com/devhead/stories/articles/0,4413,2138258,00.html
        XML Authoring Tools
     http://www.xmlhack.com/
        xmlhack: developer news from the XML community
     http://www.ibm.com/developer/xml/
        developerWorks : XML : overview
     http://www.xmlbooks.com/
        Charles F. Goldfarb's XMLbooks.com
     http://metalab.unc.edu/xml/books.html
        XML Book List
     http://www.xml.com/xml/pub/1999/01/3dml/3dml.html
        3DML
     http://www.web3d.org/news/x3d/index.html
        X3D Documents
     http://www.w3.org/Graphics/SVG/
        W3C Scalable Vector Graphic s (SVG)
     http://www.deja.com/=dnc/[ST_rn=ps]/getdoc.xp?AN=509294232
        NETNEWS:  GIS and XML
     http://www.informatics.sintef.no/UML2XML/
        GI Browser (Prototype GIS XML import/export facility
     http://www.lists.ic.ac.uk/hypermail/xml-dev
        XML-Dev Mailing List Archives
     http://xdev.datachannel.com
        DataChannel XML Resource Center
     http://www.flixml.org
        Flix B Movie Guide (created in XML with HOW-TO)
     http://www.stg.brown.edu/~sjd/xlinkintro.html
        Introduction to XML Linking
     http://metalab.unc.edu/xml/books/bible
        "The XML Bible" book, on-line
     http://www.textuality.com/xml
        Textuality XML Pages (w/ FAQ)
     http://www.w3.org/XML/Activity.html
        XML On-going Activities



From jimn at minusen.force9.co.uk  Mon Mar 27 14:02:59 2000
From: jimn at minusen.force9.co.uk (Jim Nicholson)
Date: Mon, 27 Mar 2000 20:02:59 +0100
Subject: Newbie - help in opening and reading a file from >>>
References: 
Message-ID: <39bob8.eq9.ln@minusen.minusen.net>

Dan Howard wrote:
> Hi
> I've just installed 1.5 on my Windows 98Se system
> I'm trying to execute the following-
> >>>f=open('C:\Autoexec.bat')
f=open('C:\\Autoexec.bat')
> and I get a no such directory or file error
python was looking for a file with the BEL character in it '\A' which of
course doesn't exist.  Remember you need to escape your backslashes to
prevent them being interpreted as beginning a character code.

Jim




From R.Brodie at rl.ac.uk  Wed Mar 15 07:26:33 2000
From: R.Brodie at rl.ac.uk (Richard Brodie)
Date: Wed, 15 Mar 2000 12:26:33 -0000
Subject: read NT registry with python
References: <8alo1n$tdc$1@nnrp1.deja.com>  <8ansn6$ece$1@nnrp1.deja.com>
Message-ID: <8anvhr$1756@newton.cc.rl.ac.uk>

 wrote in message news:8ansn6$ece$1 at nnrp1.deja.com...

> [HKEY_LOCAL_MACHINE\SOFTWARE\WOF]
>
> [HKEY_LOCAL_MACHINE\SOFTWARE\ABC\PlusSoftware]
> "AdminPassword"="Admin"

import win32api
from win32con import *

k=win32api.RegOpenKeyEx(HKEY_LOCAL_MACHINE,
'SOFTWARE\\ABC\\PlusSoftware',0,KEY_QUERY_VALUE)

win32api.RegQueryValueEx('AdminPassword')




From te at first.gmd.de  Thu Mar 30 03:57:28 2000
From: te at first.gmd.de (Thilo Ernst)
Date: Thu, 30 Mar 2000 10:57:28 +0200
Subject: Rational-Rose and Python ...
References: <8bt5fh$p2t$1@news.urz.uni-heidelberg.de>  <8btgsg$fnf$1@news1.xs4all.nl>
Message-ID: <38E316F8.C90C23A8@first.gmd.de>

Boudewijn Rempt wrote:

> In sum, I think that an IDE which offers a class browser, an object

> browser, a simple diagramming tool, an editor that allows rich text
> comments and hyperlinks in the source, and a decent debugger are all
> that's needed. Basically, give me many views of the source, and I'm happy

Sounds like BoaConstructor, doesn't it? ClassBrowser, UMLView feature, ...

- Thilo



Return-Path: 
Delivered-To: python-list at python.org
Received: from mail.inhh.de (mail.inhh.net [62.96.208.2])
	by dinsdale.python.org (Postfix) with ESMTP id 84D921CD52
	for ; Wed, 29 Mar 2000 11:02:43 -0500 (EST)
Received: (from ms at localhost)
	by mail.inhh.de (8.9.1a/8.9.1) id SAA04572
	for python-list at python.org; Wed, 29 Mar 2000 18:05:42 +0200 (MET DST)
Date: Wed, 29 Mar 2000 18:05:42 +0200 (MET DST)
From: Marek Schneider - AIS 
Message-Id: <200003291605.SAA04572 at mail.inhh.de>
Subject: How to build shared Python binaries under Solaris 7 (sparc) ?
Content-Type: text
Sender: python-list-admin at python.org
Errors-To: python-list-admin at python.org
X-BeenThere: python-list at python.org
X-Mailman-Version: 2.0beta1
Precedence: bulk
List-Id: General discussion list for the Python programming language 

Hello ;)

Solaris 7 (sparc) / gcc 2.95 / Python-1.5.2

I have tried my luck es follows:
---
#!/bin/sh
./configure --prefix=/www/local/python --enable-shared --disable-static --with-solaris
gmake
gmake test
(some messages follows:
 test test_zlib skipped -- an optional feature could not be imported
 test test_gzip skipped -- an optional feature could not be imported
 . .  .
 42 tests OK.
 19 tests skipped: test_al test_audioop test_bsddb test_cd test_cl test_crypt test_dbm test_dl test_gdbm test_gl
 test_gzip test_imageop test_imgfile test_nis test_rgbimg test_sunaudiodev test_thread test_timing test_zlib

 zlib and gzip are installed in /www/local or /usr/local
)
---

and further:
---
gmake install
(some messages follows:
 . .  .
 cd Modules;  gmake OPT="-g -O2" VERSION="1.5" \
                prefix="/www/local/python" exec_prefix="/www/local/python" \
                sharedmods
 gmake[1]: Entering directory `/www/ssamp/Python-1.5.2/Modules'
 gmake[1]: Nothing to be done for `sharedmods'.
 gmake[1]: Leaving directory `/www/ssamp/Python-1.5.2/Modules'
 ./install-sh -c -m 644 Modules/config.c /www/local/python/lib/python1.5/config/config.c
 ./install-sh -c -m 644 Modules/python.o /www/local/python/lib/python1.5/config/python.o
 . . .
 cd Modules; gmake \
                OPT="-g -O2" \
                VERSION="1.5" \
                SO=".so" \
                LDSHARED="ld -G" \
                CCSHARED="" \
                LINKFORSHARED="" \
                DESTSHARED="/www/local/python/lib/python1.5/lib-dynload" \
                prefix="/www/local/python" \
                exec_prefix="/www/local/python" \
                sharedinstall
 gmake[1]: Entering directory `/www/ssamp/Python-1.5.2/Modules'
 for i in X ; do \
                if test $i != X; \
                then ./../install-sh -c -m 555 $i /www/local/python/lib/python1.5/lib-dynload/$i; \
                fi; \
        done
 gmake[1]: Leaving directory `/www/ssamp/Python-1.5.2/Modules'
 . .  .
)
---

ldd python1.5 (in /www/local/python/bin) showsas follows:
$ ldd python1.5
        libsocket.so.1 =>        /usr/lib/libsocket.so.1
        libnsl.so.1 =>   /usr/lib/libnsl.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1
        libm.so.1 =>     /usr/lib/libm.so.1
        libc.so.1 =>     /usr/lib/libc.so.1
        libmp.so.2 =>    /usr/lib/libmp.so.2
 So far it seems to be OK ... 

BUT conf.pdflib.sh
---
      #!/bin/sh
      ./configure --prefix=/www/local \
                  --enable-shared --disable-static \
                  --with-perl=/www/local/perl/bin/perl \
                  --with-py=/www/local/python \
                  --with-tifflib=/www/local/lib \
                  --with-zlib=/www/local/lib \
                  --with-pnglib=/www/local/lib
---

could NOT recognize the presens of python1.5 ;(((
---
checking for Python header files... /www/local/python/include/python1.5
checking for python... no
. .  .
_____________________________________________________________
For your convenience, here's a summary of configure's results
(none of these features is required for using PDFlib with C):

Support for shared libraries:           yes
C++ language binding for PDFlib:        yes
Java language binding for PDFlib:       yes
Perl language binding for PDFlib:       yes
Python language binding for PDFlib:     no
Tcl language binding for PDFlib:        no
TIFF image support for PDFlib:          yes
PNG image support for PDFlib:           yes
Zlib compression support for PDFlib:    yes
---

Do you have ANY Idea why ?

thank you in adwance !

best regards from Hamburg,
Marek Schneider




From wlfraed at ix.netcom.com  Fri Mar 24 00:10:07 2000
From: wlfraed at ix.netcom.com (Dennis Lee Bieber)
Date: Thu, 23 Mar 2000 21:10:07 -0800
Subject: Object oriented design question: classes with mulitiple functions or  multiple classes?
References: <38D446D8.1B1E2801@exceptionalminds.com> <200003232202.RAA06052@tor.dhs.org>
Message-ID: 

On Thu, 23 Mar 2000 17:02:00 -0500, Blake Winton 
declaimed the following in comp.lang.python:

> long.  Then it was a total mess.  So the company refactored it so
> that each function was a "Command" (a separate class, containing a
> single "execute" method), and since then, whenever the client has
> wanted to add new functionality, all we had to do was add another
> class, and test it, instead of making our "Blob" class even bigger,
> and having to re-test everything.
>
	Sounds a bit like what happened in the OO design class the
company put a lot of us through a few years ago. One exercise was to
OO-design (can one use that as a verb?) a calculator.

	Somehow, I managed to persuade the team I was on to 1) use RPN
notation, and 2) put the logic to do any operation into the "key"
itself, instead of creating an ALU that did everything in response to
"key messages"

	The design meant that adding a new "key" only required adding
(or subclassing) a class for the operation. Even the numbers were done
this way -- ask display/register for current content, append key-value
to content, return to display/register...

--
 > ============================================================== <
 >   wlfraed at ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed at dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <


From r.barendregt at village.uunet.be  Mon Mar 20 15:47:00 2000
From: r.barendregt at village.uunet.be (Robin Barendregt)
Date: Mon, 20 Mar 2000 20:47:00 GMT
Subject: Question about instance creation
Message-ID: <38d68c10.41363791@news.pandora.be>

Hi all,

This is my first ever post to a newsgroup, so if I'm breaking every
rule, please forgive me :)
I'm a python newbie and am trying to create instances of a class that
can have a changing base class. A code example should clarify
(questions follow after code snippet):

File class1.py contains:

from class2 import *

class Class1:
    def __init__(self, arg = "no arg given"):
        print 'Class1 init'
        print arg
        self.var1 = 'this is var1'

    def method1(self):
        print "this is method1"		
		
class Class2:
    def __init__(self):
        print 'Class2 init'
        self.var2 = 'this is var2'
		
    def method2(self):
        print "this is method2"
		
class Class3(Class1, Class2):
    def __init__(self):
        Class1.__init__(self)
        Class2.__init__(self)
        print 'Class3 init'
        c = DynamicClass(Class1, "arg given")
        print c
        self.var3 = 'this is var3'

    def method3(self):
        print "this is method3"
		
if __name__ == '__main__':
    c = Class3()

And file class2.py contains:

class DummyClass:
    def __init__(self):
        pass

BaseAlias = DummyClass

class DynamicClass:
    def __init__(self, newAlias, *args):
        global BaseAlias
        BaseAlias = newAlias
        apply(BaseAlias, args)

class DerivedClass(BaseAlias):
    def __init__(self, *args):
        apply(BaseAlias.__init__, (self,) + args)


I want the var c in Class3.__init__ to contain and instance of the
class given as 1st argument to DynamicClass. I tried using return in
the DerivedClass.__init__ but I get an exception saying I should
return None in an __init__. How can I accomplish this?

Oh, and thanks for reading :)

Robin Barendregt.


From newsbunny at noether.freeserve.co.uk  Sun Mar  5 12:04:01 2000
From: newsbunny at noether.freeserve.co.uk (Martin P Holland)
Date: Sun, 5 Mar 2000 17:04:01 +0000
Subject: my first real program blows up, can someone tell me why?
References: <38c28b4f$0$40286@news.execpc.com>
Message-ID: 

On Sun, 05 Mar 2000 10:26:05 -0600,
Jerry F. Davis  wrote:

>	x = sys.argv[1]
>	print 'now doing fib(', x, ')'
>	fib(x)

x is a string not an integer, so in the while loop
in your function you are asking if an integer is <
a string.

fib(int(x))

will fix it but you might want to use a try: except:
to catch when the command line isn't an integer.
Play with the interpreter to discover which exception
you should catch.

atb
Martin

-- 
http://www.noether.freeserve.co.uk
http://www.kppp-archive.freeserve.co.uk

 




From ezra at pagic.net  Mon Mar 27 07:15:54 2000
From: ezra at pagic.net (ezra)
Date: Mon, 27 Mar 2000 20:15:54 +0800
Subject: binary to decimal conversion
References: <8b0r07$r5u$0@216.39.162.232> 
Message-ID: <38DF50FA.60ABAA04@pagic.net>

>

I write three functions:
import string

#-------------------------------
__doc__ = 'Data convert function.   written by ezra.\012'

def Int2Bin(di):
     chars = ['0','1']
     do = ''
     q = 0
     while di >= 2:
          q = di % 2
          do = chars[q] + do
          di = di / 2
     do = chars[di] + do
     if len(do)%4 >= 1 and len(do)%4 <= 3 : do = '0'*(4 - len(do)%4) + do
     return do
# End of def Int2Bin(di)


def Int2Oct(di):
     chars = ['0','1','2','3','4','5','6','7']
     do = ''
     q = 0
     while di >= 8:
          q = di % 8
          do = chars[q] + do
          di = di / 8
     do = chars[di] + do
     if len(do)%2 == 1 : do = '0' + do
     return do
# End of def Int2Oct(di)


def Int2Hex(di):
     chars =
['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F']
     do = ''
     q = 0
     while di >= 16:
          q = di % 16
          do = chars[q] + do
          di = di / 16
     do = chars[di] + do
     if len(do)%2 == 1 : do = '0' + do
     return do
# End of def Int2Hex(di)

#-------------------------------

--
???(Wei-Neng Hung)
?????????????,??????????
High-Speed Communication and Computing Laboratory,NCU
E-mail : ezra at csie.ncu.edu.tw




From rmuschall.fih at t-online.de  Fri Mar 31 14:41:51 2000
From: rmuschall.fih at t-online.de (Ralf Muschall)
Date: Fri, 31 Mar 2000 21:41:51 +0200
Subject: Philosophical long integer question...
References: <38E23160.B16860C2@bioreason.com> <38E3C327.96C077C5@t-online.de> <38E48F00.2D9BD07E@bioreason.com>
Message-ID: <38E4FF7F.26DC54F0@t-online.de>

Brian Kelley schrieb:

> I hadn't thought about this approach.  Currently python will not promote

This is acceptable for me, and probably gives the fastest code.
Haskell uses the same approach (and it is disputed there as well).

> unless forced.  What if the procedure was reversed?  Promote unless
This might be easier for newbies. Lisp uses this approach (almost
-- fixnums and bignums are diferent types, and promotion causes a
type change when necessary).

> this what you mean?
It is a possibility. Whether it is needed depends on whether python
is slow enough to justify the introduction of C-based int32 etc.
Otherwise just making a class int32 and having the constructor
(and maybe other methods) bitwise_and_ing it's argument with
2^32-1 would suffice.

> certainly would affect a lot of code...)
It might break code which silently assumes that ints live in
the ring Z/(2^32*Z) -- that's why I mentioned crypto hackers.

Ralf


From victor at idaccr.org  Wed Mar 22 11:45:24 2000
From: victor at idaccr.org (Victor S. Miller)
Date: Wed, 22 Mar 2000 16:45:24 GMT
Subject: AOL PFC's?
Message-ID: 

Does anyone have any programs that can read (and maybe write) AOL
PFC's (personal filing cabinets)?  These are the things that store
mail folders, address books, and who knows what else.
-- 
Victor S. Miller     | " ... Meanwhile, those of us who can compute can hardly
victor at idaccr.org    | be expected to keep writing papers saying 'I can do the
CCR, Princeton, NJ   | following useless calculation in 2 seconds', and indeed
    08540 USA        | what editor would publish them?"  -- Oliver Atkin


From tchur at bigpond.com  Sun Mar 26 07:07:01 2000
From: tchur at bigpond.com (Tim Churches)
Date: Sun, 26 Mar 2000 22:07:01 +1000
Subject: Project proposal: The Gestalt System (using Python)
Message-ID: <38DDFD65.F660FECB@bigpond.com>

The Gestalt System project aims to develop a free, Open Source,
object-oriented software framework which makes use of other free, Open
Source software tools for the purposes of managing, analysing, and
reporting on quantitative data in a manner which is suited to modern,
networked computing environments in which processor, memory, and storage
resources are abundant but time is scarce and requirements are forever
changing. 

The Gestalt System may be of particular interest to Python users and
developers because we propose to use Python as both the main development
and end-user language for the project.

Full details of the project proposal can be found in the Gestalt System
Manifesto which is available at http://gestalt-system.sourceforge.net 

We welcome any comments or suggestions you may have on the project
proposal - please send them to
gestalt-system-discuss at lists.sourceforge.net 

You might want to subscribe to this list or to the low-volume
gestalt-system-news list in order to receive announcements. Please see
the project Web page at http://gestalt-system.sourceforge.net for
details of how to subscribe.

If you wish your feedback to be kept private, you can respond to the
authors of the project proposal: Tim Churches at tchur at bigpond.com and
Karsten M. Self at kmself at ix.netcom.com

Please note that the Reply-To address of this message is set to
gestalt-system-discuss at lists.sourceforge.net which means that your reply
will by default be distributed to all subscribers to this list. You may
wish to change the address to tchur at bigpond.com and/or
kmself at ix.netcom.com if you prefer that your reply remain confidential.

Regards,

Tim Churches (tchur at bigpond.com)
 and 
Karsten M. Self (kmself at ix.netcom.com)



From Richard.Jones at fulcrum.com.au  Thu Mar 16 19:22:49 2000
From: Richard.Jones at fulcrum.com.au (Richard Jones)
Date: Fri, 17 Mar 2000 11:22:49 +1100
Subject: Pointers 
In-Reply-To: Message from Curtis Jensen of 2000-Mar-16 15:54:13,
            <38D17425.C983EE23@be-research.ucsd.edu> 
Message-ID: <200003170022.LAA03719@envy.fulcrum.com.au>

[Curtis Jensen]
> I need a slightly different twist now.  Somthing like:
> 
> >>> d = {'A':0,'B':0}
> >>> c = {'A': -> (Pointer to) d['A']}
> >>> print c['A']
> 0
> >>> d['A'] = 10
> >>> print c['A']
> 10

   You are asking far too much of the standard dictionary type :)

   You'll either need to use one of the hacks described by other posters which 
involves using a mutable proxy entry for the dictionary items - such as a list 
or an instance or a proxy class of your own rolling. The other option that's 
immediately obvious to me is for you to extend the dictionary class (via 
UserDict) to provide the semantics you're after.

   Actually, the proxy class is a kinda neat idea and was hinted at by another 
poster (though I've lost that post now):

>>> class Pointer:
...  def __init__(self, dict, item):
...   self.dict = dict
...   self.item = item
...  def __getattr__(self, attr):
...   if attr == 'value':
...    return self.dict[self.item] 
...   raise AttributeError, attr
...  def __setattr__(self, attr, value):
...   if attr == 'value':
...    self.dict[self.item] = value
...   else:
..    self.__dict__[attr] = value
... 
>>> d = {'A':0,'B':0}
>>> a = {'A': Pointer(d, 'A')}
>>> print a['A'] 
<__main__.Pointer instance at 80d8e60>
>>> print a['A'].value
0
>>> d['A'] = 10
>>> print a['A'].value
10
>>> a['A'].value = 20
>>> print d['A']
20
>>> 


    At this point, I'd be taking a serious look at your actual requirements and 
debating whether builtin dictionaries are really what you want to be using. 
You've got complete freedom to create any type of class you need - don't limit 
your thinking by sticking to the builtin types!



        Richard





From BgPorter at NOacmSPAM.org  Fri Mar  3 17:31:36 2000
From: BgPorter at NOacmSPAM.org (Brett g Porter)
Date: Fri, 03 Mar 2000 22:31:36 GMT
Subject: Python advocacy
References: <8wQv4.33688$pN1.381485@news1.rdc1.nj.home.com> <38BEE429.179D4865@prescod.net>  <38BF1990.CAA71DE6@prescod.net> <38BF6169.46FC6A66@netgate.net> <89p2kd$1arc$1@nntp6.u.washington.edu>  
Message-ID: 

"Fredrik Lundh"  wrote in message
news:VNVv4.40$y3.187028992 at newsb.telia.net...
> Brett g Porter wrote:
> > Obviously, Paul is entitled to his view that the cost of proficiency in
> C++
> > is too high. As a proficient C++ programmer, I have to disagree. I can't
> > imagine writing industrial-strength apps solely in Python.
>
> what if Python would grow a type system?
>
> and an industrial-strength compiler, on top of that?
>
> is there *anything* you can do in C++ that you
> couldn't express in a typed version of Python?
Hmmm, interesting.

At this point I'm still biased by 10 years of C / 5 years of C++ as opposed
to ~1 year of Python.  I'd certainly like to give it a try. I'd be happier
right now if I had a tighter/more transparent Python->C++->Python connection

If I could generate the same quality of code in Python, and had the same
caliber of development/debugging tools, maybe.









From moshez at math.huji.ac.il  Tue Mar  7 00:56:20 2000
From: moshez at math.huji.ac.il (Moshe Zadka)
Date: Tue, 7 Mar 2000 07:56:20 +0200 (IST)
Subject: HELP: restore my faith in Python
In-Reply-To: 
Message-ID: 

On 6 Mar 2000, Neel Krishnaswami wrote:

> > Ahh, it's time to include extensions of the rational field. Let's get
> > more abstract. Abstraction is beautiful! And we need to represent 
> > transcendental numbers consistently aswell.
> 
> Is this possible? I've forgotten most of my analysis, but I was under
> the impression that you could divide the continuum as follows:
> 
>   o Rationals -- eg 2/3. Countably infinite.
>   o Algebraic irrationals -- eg sqrt(2). Countably infinite.
>   o Transcendental numbers -- everything else. Uncountably infinite.

Yes, but you can only "talk about" a countable number of them: the
constructive reals.

Definition:
A real number x is constructive (wlog assume that 0<=x<1, otherwise take
x%1) iff there's a recursive function f s.t.

	f(n)==0 iff the n'th bit in the binary expansion of x is 0

Or, in other words:
     oo
x = sigma [(1/2)**n]*f(n)
     1

Exercise: find an example of a non-constructive real. (It's easy: there
are uncountably many of them, as opposed to a countable number of
constructive reals)

> but the full transcendentals are just plain impossible. 

Constructive trancendentals are possible. If you don't mind never knowing
if a calculating some bit sticks your program in an infinite loop (halting
problem anyone?)

--
Moshe Zadka . 
http://www.oreilly.com/news/prescod_0300.html




From jean.hemmi at arakne.com  Wed Mar  1 05:36:39 2000
From: jean.hemmi at arakne.com (Jean Hemmi)
Date: Wed, 01 Mar 2000 10:36:39 +0000
Subject: Using sequence indexes greater than 2^32 on 64 bit computers
Message-ID: <38BCF2B7.7C7CE947@arakne.com>

Hello,

We're using a custom python sequence type on which we need to pass index

values greater than 2^32 (64 bit integers)...

We modified the definition of the sequence fonctions, so that they'd
accept
a long as parameter, instead of an int, but the interpreter still
truncates
the index values to the first 32 bits...

We made a workaround with special methods (slice_get(), slice_set(),
item_get(), item_set()), but the limitation prevents us from using the
build-in features (both the[] notation and the operator functions - e.g.

operator.getitem().

I believe this is a portage problem.
Shouldn't the 'off_t' type be used, instead of 'int' for all parameters
and
types describing index values ?

64 bit computer and the use of multi-terabyte systems / multi-gigabytes
files are coming around...
Is there any plan for fixing the problem ?

Thanks,

Frederic Giacometti
Arakne
fred at arakne.com



From echuck at mindspring.com  Wed Mar  1 16:48:07 2000
From: echuck at mindspring.com (Chuck Esterbrook)
Date: Wed, 01 Mar 2000 16:48:07 -0500
Subject: Most common #! format
Message-ID: <38BD9017.4A2B5941@mindspring.com>

What's the most common #! format?

#!python
#!/usr/local/bin/python
#!/usr/bin/env python

or something else?


-Chuck


From torsten.hoermann at telekom.de  Thu Mar 30 08:59:52 2000
From: torsten.hoermann at telekom.de (Torsten Hörmann)
Date: Thu, 30 Mar 2000 15:59:52 +0200
Subject: extending python: c++ problem
Message-ID: <8bvmko$gki1@mailgate1b.telekom.de>

Does anyone know about the following problem and have a solution?
I've written a python extension using c++. No Problems with msvc, but on
HPUX with aCC. When importing the , the python interpreter can
not find the "initmod" function in the created lib. Error message:

>>> import mod
Traceback (innermost last):
  File "", line 1, in ?
ImportError: dynamic module does not define init function (initmod)
>>>

For compling and linking i have used the makefile.pre.in from the
python-distribution (no errors/warnings while building the mod.sl)
My Lib is a little more complex, but the following small lib demonstrates
this problem (it is a example from earlier posting in this newsgroup):

/*testmod.cpp*/
#include 

#include  // this include causes the error message; without,
there is no problem

static PyObject * mod_getsub(PyObject * self, PyObject * args)
{
    printf("worked\n");
    Py_INCREF(Py_None);
    return Py_None;
}

static PyMethodDef modMethods[] = {
    {"work", mod_getsub, METH_VARARGS},
    {NULL, NULL}
};


extern "C"
void initmod()
{
   (void) Py_InitModule ("mod", modMethods);
}

I have spend some hours with trying some ways to avoid this include, but now
i dont have any more ideas.
Can anyone help me????

Thanks Torsten





From embed at geocities.com  Fri Mar 31 09:35:18 2000
From: embed at geocities.com (Warren Postma)
Date: Fri, 31 Mar 2000 09:35:18 -0500
Subject: examples for HTMLgen
References: <14564.28003.931035.44380@gargle.gargle.HOWL>
Message-ID: 

> I know there is Zope, but that's too much. So what about picking the files
> into a directory like list, then sort that list in different ways and
> display it with HTMLGen???



  Hmm. I sense .... Confusion.


I think ZOPE is the niftiest thing since sliced bread. IN the off chance
that you haven't actually played with it, I'll just urge you to give it half
a chance.

Especially on Win32 using it's own built-in web-server it's extremely easy
to install. Even on my RH 6.1 Linux Box where it involved installing a few
RPMS and tweaking Apache's configuration to get it working through PCGI, it
took me less than half an hour to get it going.

After that, learning some basic DTML stuff took a few hours. It was worth
it. It was just like discovering Python all over, except now I have two
tools, Python for normal client side development, and Zope for generating
HTML, which uses Python objects in the background to gather and format the
data, and the DTML layer is just a thin presentation layer with ability to
handle HTML forms for gathering input from users, and so on.  If you haven't
tried it already, please do, it's so cool it's addictive.

Sorry, don't know any HTMLgen example links.

Warren




From rhicks at nospam.rma.edu  Fri Mar 17 19:31:28 2000
From: rhicks at nospam.rma.edu (Robert Hicks)
Date: Sat, 18 Mar 2000 00:31:28 GMT
Subject: Anyone working on IDLE or PythonWin for CE?
References: 
Message-ID: 

I have no problem running the demos on mine. I have a NINO handheld.

Bob

"Warren Postma"  wrote in message
news:qouA4.35130$Jz3.342199 at nnrp1.uunet.ca...
> Is Python for CE 1.5.2 too broken (unicode support, etc) to support an IDE
> onboard a Windows CE machine?  I can't even get the CE Task Bar Demo to
run
> on my machine (HP 620 LX). I'd like to mess with Python for CE more but it
> seems pretty much 'alpha quality'.
>
> Anyone?
>
> Warren
>
>




From dmost at magna.com.au  Tue Mar 14 00:02:53 2000
From: dmost at magna.com.au (dmost at magna.com.au)
Date: Tue, 14 Mar 2000 05:02:53 GMT
Subject: Job Offer: Python/Zope developer required in Manhattan
Message-ID: <8akh5s$1t3$1@nnrp1.deja.com>

We are looking for an experienced developer to work in Manhattan.
Applicants should have approximately 5 years experience working with OO
concepts in langauges such as python, c++ or java.
Applicants should be knowlegable in Python programming and in the Zope
application server, although a talented applicant willing to learn Zope
will also be acceptable.
Applicants should be comfortable with SQL and relational databases.
The job will entail work with Zope, but not exclusively so. There may
also be work involving java servlets, xml, xslt, and other technologies.
Pay is competetive.
--------------------
Damien Morton
Senior Programmer
Dennis Interactive
(212) 372 3829


Sent via Deja.com http://www.deja.com/
Before you buy.


From gherman at darwin.in-berlin.de  Thu Mar 16 05:01:37 2000
From: gherman at darwin.in-berlin.de (Dinu C. Gherman)
Date: Thu, 16 Mar 2000 11:01:37 +0100
Subject: Tagging engines like PyFontify for other languages?
Message-ID: <38D0B101.1683912@darwin.in-berlin.de>

Hello,

I'm wondering if there are any Python tagging engines like 
Just van Rossum's PyFontify for languages other than Python?

That is, I'm looking for a Python module that is able to scan 
source code in, say, C, C++, Java, Perl or SQL (DDL/DML) and 
return a list of tags and positions in some way similar to 
what PyFontify is doing for Python.

Thank you in advance for any hints!

Regards,

Dinu

-- 
Dinu C. Gherman
................................................................
"The thing about Linux or open software in general is that 
it actually tries to move software from being witchcraft to 
being a science," [...] "A lot of the programs you see today 
are actually put together by shamans, and you just take it and 
if the computer crashes you walk around it three times... and 
maybe it's OK." (Linus Thorvalds, LinuxWorld 2000, NYC)


From lenny at squiggie.com  Thu Mar 16 19:17:35 2000
From: lenny at squiggie.com (Lenny Self)
Date: Thu, 16 Mar 2000 16:17:35 -0800
Subject: Cookie module
References:  
Message-ID: 

Oops. I goofed on the last post.

Your code should read:

ck = Cookie.SmartCookie()
ck.load(os.environ["HTTP_COOKIE"])
L = ck("ogin").value

Sorry.

Good luck, once again.

    -- Lenny Self
        lenny at squiggie.com

"Lenny Self"  wrote in message
news:BOeA4.932$pR.37158 at news.uswest.net...
> I believe your problem is that you do not the the 'get' in your call.  The
> call should look like this:
>
> ck = Cookie.SmartCookie(os.environ["HTTP_COOKIE"])
> L = ck("ogin").value
>
> Good luck.
>
>     -- Lenny Self
>         lenny at squiggie.com
>
> "Akhar"  wrote in message
> news:JjeA4.200$x24.24089 at weber.videotron.net...
> > I tried your cookie module it works fine under the python interpreter
but
> > when I use it on my web site it gives me an error I am trying to use:
> > ck = Cookie.SmartCookie(os.environ.get("HTTP_COOKIE",""))
> > L = ck.get("ogin").value
> > but it tells me
> > httpd: [Tue Mar 14 17:46:03 2000] [error] [client 192.168.0.2] Premature
> end
> > of
> > script headers: /var/www/cgi-bin/mail/msg.py
> >   File "/var/www/cgi-bin/mail/msg.py", line 20
> >     L = ck.get("ogin").value
> >     ^
> > SyntaxError: invalid syntax
> > httpd: [Tue Mar 14 17:50:43 2000] [error] [client 192.168.0.2] Premature
> end
> > of
> > script headers: /var/www/cgi-bin/mail/msg.py
> > So how can I get the info stored in a cookie from one form to another??
> >
> > Regards,
> > Akhar
> >
> > Note: do you of any good crypto module to encrypt and decrypt passwords?
> >
> >
> >
>
>




From ImranG at btinternet.com  Wed Mar  8 17:13:08 2000
From: ImranG at btinternet.com (Imran)
Date: Wed, 08 Mar 2000 22:13:08 +0000
Subject: Python (Mildly Humourous)
Message-ID: <4gjdcs846qb75s9pfeh9f29nqlul2jpgri@4ax.com>

I've been trying to get my college to install Python seeing as they already have
Basic, Pascal, Cobol, and VB, but when you've technical support like this what
do you do :-)

(Names and Domain deleted to protect the guilty)

Read the message bottom up as the reply is top-posted.

> From: *** ******** <*********@staff.**********.ac.uk>
> To: '10077583' <10077583@**********.ac.uk>
> Subject: RE: Interpreters on the Network
> Date: 07 March 2000 15:55
> 
> Hello,
> 
> To interpret what?
> 
> 
> *** ********
> 
> Technical Support Manager,S**** D**** College
> 
> 
> 
> -----Original Message-----
> From: 10077583 [mailto:10077583@**********.ac.uk]
> Sent: 07 March 2000 15:51
> To: *********@STAFF.**********.AC.UK
> Subject: Interpreters on the Network
> 
> 
> Hi,
> 
> Is there any chance of getting a Python and/or a Tcl/Tk interpreter
> available on the Network ?
> 
> Thanks,
> 
> Imran Ghory

Any suggestions how such as reply should be responded to ?

Imran
-- 
BTInternet FAQ v2.0 (Unofficial)
http://redrival.com/btifaq/

Sign the Linux Driver Petition
http://www.libranet.com/petition.html


From andy.georges at rug.ac.be  Thu Mar  2 03:20:03 2000
From: andy.georges at rug.ac.be (Andy Georges)
Date: Thu, 02 Mar 2000 09:20:03 +0100
Subject: A comp.lang.python code snippet archive?
References:  <200002281844.TAA19752@dionysus.fw.cuci.nl>
Message-ID: <38BE2433.8B4B033A@rug.ac.be>

Hans Nowak wrote:
> 
Hello,

> I would like to know:
> * if it's still worthwile to continue this site

Yes, please do. 

andy


==========================================================================
Dept. of Applied Mathematics and Computer Science, University of Ghent
Krijgslaan 281 - S9, B - 9000 Ghent, Belgium
Phone: +32-9-264.47.66, Fax: +32-9-264.49.95
E-mail: andy.georges at rug.ac.be 
==========================================================================


From gerrit at nl.linux.org  Fri Mar 31 16:27:26 2000
From: gerrit at nl.linux.org (gerrit at nl.linux.org)
Date: Fri, 31 Mar 2000 23:27:26 +0200
Subject: Advice requested: GUI project beginning
In-Reply-To: <8c0dpv$djc$1@nntp6.u.washington.edu>; from owen@astroNOJNK.washington.edu.invalid on Thu, Mar 30, 2000 at 12:35:09PM -0800
References: <8c0dpv$djc$1@nntp6.u.washington.edu>
Message-ID: <20000331232725.A3807@nl.linux.org>


> What Python windowing environment do you recommend for a new project? 
> wxPython? Tkinter? Java (via JPython)? (Is there anything else?). I'd 
> prefer something that is easy to use and scalable.


http://www.nl.linux.org/~gerrit/gui.html

regards,
Gerrit.

-- 
1011001 1101111 1110101 1110010 1110011 0101100
1000111 1100101 1110010 1110010 1101001 1110100



From alan.gauld at gssec.bt.co.uk  Mon Mar  6 07:25:38 2000
From: alan.gauld at gssec.bt.co.uk (Alan Gauld)
Date: Mon, 06 Mar 2000 12:25:38 +0000
Subject: C++ / Java / Python (was Status of C++)
References: <38bf4389.272576531@news.mindspring.com>
Message-ID: <38C3A3C2.A692AF05@gssec.bt.co.uk>

Just to pick up a small point...


> >What I am concerned with is that C++ would be relegated to 
> the COBOL level, with lot of maintenance, migration to do 
> but with very little new development. 

This is plain wrong.
There are lots of new COBOL projects around and a recent 
Gartner(?) survey showed that the majority of the new code 
being written worldwide is still in COBOL - something 
like 25% was the figure I saw. (Remember that every 
single COBOL project produces a LOT of code!)

India is the second biggest software producer in the 
world and an awful lot of the stuff done there is sub 
contracted COBOL... BTW They can do pretty mean C++ too 
if that's what you need but they go with the market, 
there's very little language snobbery there :-)

Alan G.
-- 
=================================================
This post represents the views of the author 
and does not necessarily accurately represent 
the views of BT.


From morbid at doesnotlikespam.inet.net.nz  Fri Mar 31 07:06:12 2000
From: morbid at doesnotlikespam.inet.net.nz (Morbid Curiosity)
Date: Fri, 31 Mar 2000 12:06:12 GMT
Subject: lambda
References: <20000329063753.20711.cpmta@c000.sfo.cp.net> <38e1d27a.27069487@news.inet.net.nz> <9sj4esgeh2i9emc4p249ksrj04u1bdm7ur@4ax.com> <8bv7k3$h7e$1@readme.uio.no> 
Message-ID: <38e49499.1173061@news.inet.net.nz>

On Thu, 30 Mar 2000 16:26:43 -0500, Joey Gibson
 wrote:
>||| > It took me a while to 'get' lambdas at first too. They are most useful
>||| > (IMO) when paired with map(), filter() and reject(). These functions take
>||| 
>||| Where did you find reject()?
>
>	D'ooh! I work in Smalltalk also, and that is one of its collection
>messages. Sorry. Python doesn't have one.

You're not thinking of reduce(), are you?

Morbid



From orlov at diasoft.ru  Wed Mar  1 08:57:44 2000
From: orlov at diasoft.ru (Oleg Orlov)
Date: Wed, 1 Mar 2000 16:57:44 +0300
Subject: Win32 KeyboardInterrupt
References: <38BD0AF8.50097EA4@nipltd.com>
Message-ID: <89j7da$2utb$1@gavrilo.mtu.ru>

import sys

def Worker(argv):
  while 1:
    pass

try:
  if __name__ =='__main__':
    Worker(sys.argv)
except KeyboardInterrupt:
  print "Saving state..."

Works for me. May be Worker() spawn another thread and sleep?

-----------
Oleg Orlov





From rob at hooft.net  Fri Mar  3 03:02:01 2000
From: rob at hooft.net (Rob W. W. Hooft)
Date: 03 Mar 2000 09:02:01 +0100
Subject: Tkinter vs. wxPython (was: Which GUI?)
References:   <5l3dqjckt5.fsf_-_@eric.cnri.reston.va.us>  
Message-ID: 

>>>>> "FL" == Fredrik Lundh  writes:

 FL> Rob W. W. Hooft  wrote:
 >> For fun with buggy user code in Tkinter, try:
 >> 
 >> import Tkinter
 >> b=Tkinter.Button()
 >> b.pack()
 >> l=Tkinter.Label()
 >> l.grid()

 FL> not to mention this highly annoying
 FL> Python bug:

 FL> while 1:
 FL>   pass

I've been bothered by that one as well :-), but at least a Control-C will
get you out with a nice stack trace to help you locate the problem. The
buggy user code I cited is a bit more involved:

 - It hangs, but Control-C won't kill it, so you can't get a stackdump....
 - b and l might be instantiated by completely different objects in
   different modules in the program, and just happen to have the same
   parent window.

These two features together make this very hard to debug.

Rob
-- 
=====   rob at hooft.net          http://www.xs4all.nl/~hooft/rob/  =====
=====   R&D, Nonius BV, Delft  http://www.nonius.nl/             =====
===== PGPid 0xFA19277D ========================== Use Linux! =========


From alex at somewhere.round.here  Wed Mar 29 11:40:42 2000
From: alex at somewhere.round.here (Alex)
Date: 29 Mar 2000 11:40:42 -0500
Subject: Incompatibility between socket and httplib in python CVS build.
Message-ID: 

Hi.  Running python httplib.py currently gives the following error
message:

arc% python httplib.py
testing HTTP...
Traceback (innermost last):
  File "httplib.py", line 272, in ?
    test()
  File "httplib.py", line 238, in test
    h.connect(host)
  File "httplib.py", line 112, in connect
    self.sock.connect(host, port)
TypeError: connect requires exactly 1 argument; 2 given


My python version is

'1.5.2+ (#7, Mar 29 2000, 11:20:40)  [GCC egcs-2.91.66 19990314/Linux
(egcs-1.1.2 release)]'

And emacs gives the CVS versions of httplib.py and socketmodule.c as
1.14 and 1.98

Alex.


From phil at river-bank.demon.co.uk  Tue Mar 28 12:03:46 2000
From: phil at river-bank.demon.co.uk (Phil Thompson)
Date: Tue, 28 Mar 2000 18:03:46 +0100
Subject: ANNOUNCE: PyQt/PyKDE v0.11 (Python Bindings)
Message-ID: <954263081.1503502440@news.demon.co.uk>

I've put v0.11 of my Python bindings for Qt and KDE in the usual place at:

http://www.river-bank.demon.co.uk/software

The main change is support for the new Qt v2.0.x widgets.  PyQt will also
compile with Qt v2.1.0-beta3, but the new Qt v2.1.x widgets are not yet
supported.

There are no visible changes to PyKDE - KDE 2 is not yet supported.

Hopefully, RPMs will follow soon.

Phil


From JGRAVES3 at austin.rr.com  Fri Mar 17 10:24:10 2000
From: JGRAVES3 at austin.rr.com (Jay Graves)
Date: Fri, 17 Mar 2000 15:24:10 GMT
Subject: Java editor for Python
References: <8atgsd$ava$1@vg170.it.volvo.se>
Message-ID: 

JJ wrote in message <8atgsd$ava$1 at vg170.it.volvo.se>...
>Hi!
>Anyone who knows where to find an editor written in Java with syntax color
>highlighting?
>It's a VERY big plus if there is a java bean and/or source code available.


http://jedit.sourceforge.net/

hth
Jay




From jstok at bluedog.apana.org.au  Tue Mar 21 01:22:17 2000
From: jstok at bluedog.apana.org.au (Jason Stokes)
Date: Tue, 21 Mar 2000 17:22:17 +1100
Subject: what is easier to learn first?...
References: 
Message-ID: 

Collin Greene wrote in message ...
>C+/+ or python or perl, I need an unbiased opionion here.

You expect an unbiased opinion on comp.lang.python.

>I have  NO
>programming experiance. thanks for your time.
>greene at hctc.com


Haskell.

Oh, Ok, Python.  Without doubt.  Perl and C++ are both baroque, complicated,
dense languages.   Python code is far cleaner.






From eq3pvl at eq.uc.pt  Mon Mar 20 05:41:01 2000
From: eq3pvl at eq.uc.pt (Pedro Vale Lima)
Date: Mon, 20 Mar 2000 10:41:01 +0000
Subject: mod_perl and mod_python, is perl better for that task?
Message-ID: <38D6003D.7DF3AE89@eq.uc.pt>

Hi,

The concept of mod_perl is great for building sites with huge traffic,
the only really disavantage is
perl :-)

After looking (at a glimpse) for a similar mod_python I found PyApache
but it seems not to be very
used in the community.

Is python not well suited for webserver embedding? Or is just because
mod_perl has a better web
maintainer :-) ?

pvl



From mfletch at tpresence.com  Wed Mar  1 13:00:57 2000
From: mfletch at tpresence.com (Mike Fletcher)
Date: Wed, 1 Mar 2000 13:00:57 -0500 
Subject: Newbie: Reading textfiles
Message-ID: 

First approach:

file = open( filename )
line = file.readline()
while line:
	doprocessing( line )
	line = file.readline()


Second approach:

import fileinput
file = fileinput.FileInput( filename )
for line in file:
	doprocessing(line)

HTH,
Mike
-----Original Message-----
From: Lutz.Schroeer at altavista.net [mailto:Lutz.Schroeer at altavista.net]
Sent: Wednesday, March 01, 2000 11:18 AM
To: python-list at python.org
Subject: Newbie: Reading textfiles


Hi,

after looking for a"clever" solution for reading a text file line by line 
from the beginning to the end for the whole day, I have to ask this 
ridiculous newbie question:

How do I read a textfile line by line and catch the eof?

Latz
-- 
http://www.python.org/mailman/listinfo/python-list

-- 
http://www.python.org/mailman/listinfo/python-list



From bparsia at email.unc.edu  Sat Mar  4 00:37:06 2000
From: bparsia at email.unc.edu (Bijan Parsia)
Date: Sat, 4 Mar 2000 00:37:06 -0500
Subject: Python advocacy
References: <38BEE429.179D4865@prescod.net> 
Message-ID: <1e6xz1s.uuanez7qwj3oN%bparsia@email.unc.edu>

Don Tuttle  wrote:

> Paul Prescod  wrote in message
> news:38BEE429.179D4865 at prescod.net...
> > O'Reilly asked to publish something I had written for my homepage about
> > Python.
> >
> > http://www.oreilly.com/
> >
> > I'm somewhat nervous about the flamage I'll get, but c'est la vie.
> 
> I bow before man with big, big gonads! 
[snip]

I'm afraid you're mistaken, since only last month I ran Paul through a
gonad reduction program...

They-don't-call-it-*Small*talk-for-nothing-ly y'rs,
Bijan Parsia

P.S. With apologies to Paul. And his gonands, of course, but I do
presume that they're, er, "man enough" to take a joke ;)

P.P.S. Please notice my manfully refraining from commenting on Paul's
comments on Smaltalk in that article. Especially since they were, to a
quibbler like myself, not *exactly* correct. But hey, it's an advocacy
piece. And he certainly did try to be nice :)

P.P.P.S. I notice that my newsreader (the very fine MacSoup) will
complain if my sig's too large or I have to much quoted material, but
cares not a whit if most of my article is in the P.S.s!

P.P.P.P.S It was certainly a much better article than that wretched Ruby
one, though I do detect a slight tension between these quotes:
        "C++ and Perl only make sense if you have a particular 
        programming background" 
and 
        "Python merges many of Smalltalk's ideas with a syntax that is 
        more likely to appeal to C, C++ and Java programmers".
I rather suspect it appeals more to Pascal and Modula-2 programmers :)
And poor Dylan, which sold it's soul to mixfix only to be doomed to
obscurity, in the general world, and scorn from its progeniters.


From mikael at isy.liu.se  Fri Mar 24 05:35:37 2000
From: mikael at isy.liu.se (Mikael Olofsson)
Date: Fri, 24 Mar 2000 11:35:37 +0100 (MET)
Subject: Newbie: White space
In-Reply-To: <8beg15$fdp$1@yeppa.connect.com.au>
Message-ID: 

On 24-Mar-00 Ryan Abrahams wrote:
 >  They should really put out a list of these, cause all newsgroups seem to
 >  have their own version of them :) ahahaha

You probably will enjoy the acronym finder at 

  http://www.acronymfinder.com/

/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:    24-Mar-00
Time:    11:33:37

This message was sent by XF-Mail.
-----------------------------------------------------------------------


From yawyi at gmx.de  Thu Mar  2 13:52:14 2000
From: yawyi at gmx.de (Johannes Stezenbach)
Date: Thu, 2 Mar 2000 19:52:14 +0100
Subject: Get dictionary-keys used to format a string
References: <38BE41F9.F2E9297A@inka.de>
Message-ID: <38beb8c4$0$18180@personalnews.de.uu.net>

Michael Str?der  wrote:

>'%(language)s has %(count)03d quote types.' % vars()
>
>I would like to extract the keys in the formatting string to a list.
>Well I can parse it myself but is there a built-in function to
>extract a list/tuple of the dictionary keys, e.g.
>['language','count'] in this case?

Try something like this:

------------
class GrabKeys:
    def __init__(self):
        self.keys = []
    def __getitem__(self, name):
        self.keys.append(name)
        return 0 # 0 is apparently compatible with all % format characters

gk = GrabKeys()

'%(language)s has %(count)03d quote types.' % gk

print gk.keys
------------

HTH,
Johannes



From daniels at mindspring.com  Wed Mar 15 21:22:05 2000
From: daniels at mindspring.com (Alan Daniels)
Date: 16 Mar 2000 02:22:05 GMT
Subject: Pointers
References: <200003152244.JAA27546@envy.fulcrum.com.au>
Message-ID: 

On Thu, 16 Mar 2000 09:44:45 +1100, the infinitely wise Richard Jones
(Richard.Jones at fulcrum.com.au) spoke forth to us, saying...

[snip...]
>In Python, the things you have come to know as variables are best
>thought of as "labels" for objects. In old-fashioned
>pointer-language-speak, they're about as equivalent to references or
>pointers as you're going to get.

For the benefit of the original poster, I'd like to also add that in
Python, whenever you invoke any of the comparison operators, you're
comparing the objects underneath, *not* the pointer values. Example:

>>> a = [1, 2, 3]
>>> b = [1, 2, 3]
>>> id(a)
135065392
>>> id(b)
134921328
>>> if a == b: print "True."
...
True.

See? Even though a and b are different objects (as shown by calling
"id" on them and getting different numbers), they evaluate to the
same, and that's why "True" prints out. Hope this helps.

-- 
=======================
Alan Daniels
daniels at mindspring.com
daniels at cc.gatech.edu


From deirdre at deirdre.net  Tue Mar 14 13:27:50 2000
From: deirdre at deirdre.net (Deirdre Saoirse)
Date: Tue, 14 Mar 2000 10:27:50 -0800 (PST)
Subject: Wash. D.C. Area: DCPIGgies, Mar. 13
In-Reply-To: <5qvu4.8333$al3.110244@newsc.telia.net>
Message-ID: 

On Mon, 28 Feb 2000, Fredrik Lundh wrote:

> > Can we add to the agenda:
> >
> > * Changing the name from "piggies" to something more respectable.
> 
> old topic:
> 
> http://www.deja.com/=dnc/viewthread.xp?AN=514428490
> 
> (start with John Landahls post -- the stuff
> above that one is from alt.pets.guinea-pigs ;-)

(somewhat belated in that I hadn't been reading on this topic)

One wonders, if John Landahl was so interested in forming a Python group
in San Francisco, why he never showed up to BayPIGgies (afaik) or signed
up for the mailing list.

Anyhow, my apologies to anyone without a sense of humor for using PIG, but
I was also thinking of the old Forth Interest Groups, aka FIGs.

-- 
_Deirdre   *   http://www.linuxcabal.org   *   http://www.deirdre.net
"During my service in the United States Congress, I took the initiative in
creating the Internet." -- Al Gore
"If Al Gore invented the internet, I invented spell check." -- Dan Quayle




From jpet at eskimo.com  Wed Mar  1 03:43:57 2000
From: jpet at eskimo.com (Jeff Petkau)
Date: Wed, 01 Mar 2000 08:43:57 GMT
Subject: Phython as In-Game scripting language
References: <20000222211406.41743.qmail@hotmail.com> <891g7l$cf8$1@nnrp1.deja.com> <893u76$46l$1@nnrp1.deja.com> <38b66215@news.xtml.co.uk> <20000225153511.19694.qmail@hotmail.com> <1e6rnn8.j4tz1uj8dlv4N@gershwin.bio.ic.ac.uk>
Message-ID: 

> > Shawn LeBlanc  wrote:
> > As a slightly off topic question, which other languages like
> > Python could be embedded efficently in a game project? I've
> > seen that several games use Lua (Grim Fandango), and there's
> > got to be other games that use embedded languages. What
> > would be the advantages and disadvantages of using Python
> > in a game?
>
> IIRC, the first-person shooter set in the Star Wars universe (the name
> escapes me - Dark Forces?), uses internal scripting extensively.

A couple of years ago I was working on a commercial RPG
where we tried using Python for the script language. Eventually
we switched to Java for a couple of reasons. My experiences:

* Python was very easy to integrate with C/C++, which is a big
deal for game coding. Java was a pain. [And Scheme is both
slow and painful, and I really wish I didn't have to use it on
my Visor 'cause it's really hard to write a closing paren in Graffiti,
it always comes out as a question mark. Um, where was I...]

* Java is pretty fast, so we were able to do almost everything in
it, and only had to go to C++ for collision detection and rendering.
Python is pretty slow; it would be best to limit it to scripting the
high-level actor behavior.

Incidentally, if stackless Python or microthreads had existed
back then, we probably would have stuck with Python. I'm still
waiting for the day when there will be a programming language
as good for describing actors and state machines as Simula was
25 years ago. (Scheme has the language power but was disqualified
when a blood test found high levels of parentheses.)

I actually considered implementing continuations in Python, but
then we switched to Java so I implemented them there instead.
One of my silliest experiments ever.

--Jeff


ps. We switched to Java for three reasons:
- Speed

- We wanted to standardize on a language internally, across some
  other projects, and the other projects didn't like Python because
  of the whitespace thing.

- I really wanted something like microthreads, and implementing them
  in Java as a .class file postprocessor seemed like a nifty project.

pps. Eventually the game got cancelled, no doubt because I
spent too much time fooling with script languages instead
of actually making a game. Sigh.

I'll stop rambling now.





From aa8vb at yahoo.com  Mon Mar  6 06:56:40 2000
From: aa8vb at yahoo.com (Randall Hopper)
Date: Mon, 6 Mar 2000 06:56:40 -0500
Subject: IDLE and Tkinter
In-Reply-To: 
References: 
Message-ID: <20000306065640.B2115@vislab.epa.gov>

tf at malcolmsmith.net:
 |IDLE and Tkinter
 |
 |I'd love to try IDLE, but am having a bit of trouble with Tkinter.  I
 |*tried* to follow the instructions on the site under "Tkinker
 |Troubleshooting". I can get to the "make install" stage, when I get this:
 |
 |/python: error in loading shared libraries
 |libtk8.3.so: cannot open shared object file: No such file or directory
 |make: *** [libinstall] Error 127
 |
 |Ok, I'm not editing something correctly... 

What flavor of UNIX are you on?

The short answer is that Python wasn't built with the path to one of its
shared libraries (libtk8.3.so).  The loader doesn't find this library in
its default search path, so it can't load python.

If you're on a UNIX that supports it (most do), a quick fix (hack) is to do
a:

   setenv LD_LIBRARY_PATH /usr/local/lib

or wherever your libtk8.3.so lives.  (Note that if your shell is sh'ish
[ksh/bash/etc.] you'll use:  "export LD_LIBRARY_PATH=/usr/local/lib").
Then run python.  If it works, that's your problem.

The solution on most OSs is to compile in the path to libtk.  On other OSs,
you're responsible for adding that directory into the system ldconfig path.
Send us your OS and folks on the list can figure out which it is.

-- 
Randall Hopper
aa8vb at yahoo.com



From embed at geocities.com  Tue Mar 28 13:16:20 2000
From: embed at geocities.com (Warren Postma)
Date: Tue, 28 Mar 2000 13:16:20 -0500
Subject: Python - Next Release Questions
References:    
Message-ID: <6I6E4.934$HG1.29212@nnrp1.uunet.ca>

>
> UTF-8 != ASCII.
>
> (and I doubt people in the US and the UK make up
> 99% of all Unix users -- the rest of us tend to use
> 8-bit character sets that are definitely not UTF-8
> compatible...)

Thou hast indeed caught me flat footed!

I confess I thought UTF-8 was a clever renaming/co-opting of ASCII. You
know, embrace and extend, kinda like Microsoft....

Warren





From jeffp at crusoe.net  Sat Mar 18 14:51:37 2000
From: jeffp at crusoe.net (Jeff Pinyan)
Date: Sat, 18 Mar 2000 19:51:37 GMT
Subject: id() trickery
Message-ID: 

Well, I've broken my brain again.  Could someone explain this to me?

>>> a = id(1)
>>> a, id(1)
(732968, 732968)
>>> b = id(1)
>>> b, id(1)
(732968, 732968)
>>> a,b,id(a),id(b)
(732968, 732968, 732236, 732212)
>>> a = b + 0
>>> a,b,id(a),id(b)
(732968, 732968, 732188, 732212)
>>> a = b
>>> a,b,id(a),id(b)
(732968, 732968, 732212, 732212)
>>> a = b + 0
>>> a,b,id(a),id(b)
(732968, 732968, 732188, 732212)

Could someone tell me why the value returned by id(), which is just an
int, says type(), is acting a little fruity for me?  If a and b hold the
same integer, shouldn't they have the same value for id()?  And why do

>>> a = b # and
>>> a = b + 0

have two different effects?

-- 
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve             japhy at pobox.com
http://www.pobox.com/~japhy/                  http://pinyaj.stu.rpi.edu/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/



From gregj at pobox.com  Tue Mar 21 04:59:26 2000
From: gregj at pobox.com (Greg Jorgensen)
Date: Tue, 21 Mar 2000 01:59:26 -0800
Subject: Request for suggestions: a Workflow application
References: <6D8A17398E28D3119F860090274DD7DB4985A6@pces.cadlab.it> <8b1ehn$e6t$1@bunyip.cc.uq.edu.au> <38d53171.56301831@news.telus.net> <8b7gci$j4p$1@bunyip.cc.uq.edu.au>
Message-ID: 

"Chui Tey"  wrote in message
news:8b7gci$j4p$1 at bunyip.cc.uq.edu.au...
> There was a project around involving serverless version control. Basically
> using email/other mechanisms. I don't have the link anymore sorry.

I think you mean Code Co-op from Reliable Software.

    http://www.relisoft.com/co_op/

I've been using it at work and so far it's worked as expected.

Greg Jorgensen
gregj at pobox.com





From effbot at telia.com  Sat Mar 11 16:19:16 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Sat, 11 Mar 2000 21:19:16 GMT
Subject: event loops and Python?
References:   
Message-ID: 

Kragen Sitaker  wrote:
> >just call mainloop(), and off you go.
>
> Looks like that calls a mainloop() method on a Tk toplevel.  This is
> bad if you're not running in X.

sorry, failed to parse that.  Tkinter uses X windows on Unix,
native toolkits on Mac and Windows.  the event loop works
in the same way on all platforms.  what's the problem here?






From godzilla at netmeg.net  Sat Mar 25 09:09:58 2000
From: godzilla at netmeg.net (Les Schaffer)
Date: Sat, 25 Mar 2000 14:09:58 GMT
Subject: Where to install C extensions?
References: <8bfvsi$u44$1@netnews.upenn.edu> <38DB8AD7.92AF1B8C@abo.fi> <8bglb5$vbn$1@netnews.upenn.edu>
Message-ID: 

/usr/lib/python1.5/site-packages holds all my 3-rd party
extensions. its also in my my sys.path.

les schaffer


From prestonlanders at my-deja.com  Thu Mar 30 13:21:00 2000
From: prestonlanders at my-deja.com (Preston Landers)
Date: Thu, 30 Mar 2000 18:21:00 GMT
Subject: Python and Java
References: <38e26893@wwwproxy3.westgroup.com>
Message-ID: <8c05to$cg8$1@nnrp1.deja.com>

Give it a look:

http://www.xmlrpc.com/

In article <38e26893 at wwwproxy3.westgroup.com>,
"Chris Lada"  wrote:
> We have been writing an application in Python and are faced with a
delimma.
> We have to talk to a Java-based interface. Is there any alternatives
to
> writing yet another interface in JPython ?

--
|| Preston Landers  ||


Sent via Deja.com http://www.deja.com/
Before you buy.


From claird at starbase.neosoft.com  Sat Mar 25 22:39:40 2000
From: claird at starbase.neosoft.com (Cameron Laird)
Date: 25 Mar 2000 21:39:40 -0600
Subject: Python Journal
References: <8bj8uf$3to@journal.concentric.net>
Message-ID: <88F1FCE07EF80A9B.CEA57A7F1805869F.CA1DBF693A16AD2C@lp.airnews.net>

In article <8bj8uf$3to at journal.concentric.net>,
Andres M. Hidalgo  wrote:
>Anyone know of any magazine publication dedicated to the python community
>like the ones
>dedicated to perl (Perl Journal) or Linux (Linux Journal) ???.
			.
			.
			.
Something with a name like *Python Journal* ?
-- 

Cameron Laird 
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html


From gmcm at hypernet.com  Wed Mar 15 09:51:39 2000
From: gmcm at hypernet.com (Gordon McMillan)
Date: Wed, 15 Mar 2000 09:51:39 -0500
Subject: How to make a *.pyd or a DLL of several modules?
In-Reply-To: <953124408.460317@newsmaster-04.atnet.at>
Message-ID: <1258990592-4218892@hypernet.com>

Harald Angelow writes:

> I have several Python modules and want to put them into a PYD or into a DLL.
> Freezing only supports executeables, so how can i make one DLL of these
> modules?

You want to freeze them? I'm sure you can do it with the 
frozen code in a dll, but frozen modules need to be listed in a 
table in the executable, so having the code in a dll won't help 
you any.

Maybe you want something like:
http://starship.python.net/crew/gmcm/archives.html

> Importing that DLL should be the same like importing all Modules.

I suppose you could play games with "from x import *", but I 
believe you'd regret it. If they are all user-accessible, then 
each should be imported explicitly by the user, or one should 
play the role of gateway to the others.

- Gordon



From rwgk at my-deja.com  Tue Mar  7 22:36:33 2000
From: rwgk at my-deja.com (rwgk at my-deja.com)
Date: Wed, 08 Mar 2000 03:36:33 GMT
Subject: PyArg_ParseTuple() & Py_DECREF()
References: <89ph17$7si$1@nnrp1.deja.com>
Message-ID: <8a4hs1$p9v$1@nnrp1.deja.com>

For the records: The answer is actually here:
http://www.python.org/doc/current/ext/parseTuple.html
I am not sure why I missed it before.
Ralf


In article <89ph17$7si$1 at nnrp1.deja.com>,
  rwgk at my-deja.com wrote:
> Consider the following two lines of source code at the
> beginning of a C extension function:
>
>   PyObject *O;
>   if (! PyArg_ParseTuple(args, "O", &O)) return NULL;
>
> Is it necessary to call Py_DECREF(O) before leaving the
> extension function?
>
> Thanks!
>         Ralf
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.


From aahz at netcom.com  Mon Mar  6 00:51:31 2000
From: aahz at netcom.com (Aahz Maruch)
Date: 6 Mar 2000 05:51:31 GMT
Subject: A comp.lang.python code snippet archive?
References:  <200002281844.TAA19752@dionysus.fw.cuci.nl>
Message-ID: <89vh13$6t5$1@nntp6.atl.mindspring.net>

In article <200002281844.TAA19752 at dionysus.fw.cuci.nl>,
Hans Nowak  wrote:
>
>* what kind of improvements I could make (a search engine would be cool but 
>I don't know much about CGI)

You don't need CGI.  See http://www.searchbutton.com/

(And, yes, I do work for them.)
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

I wonder what they do with all the fat they harvest from fat farms


From nobody at nowhere.nohow  Fri Mar 31 18:24:18 2000
From: nobody at nowhere.nohow (Grant Edwards)
Date: Fri, 31 Mar 2000 23:24:18 GMT
Subject: Paid to work in Python? (was: Re: Choice Of Language)
References:  <8ajmib$elo$1@nnrp1.deja.com> <8c3ats$b5f$1@nntp.Stanford.EDU>
Message-ID: 

In article <8c3ats$b5f$1 at nntp.Stanford.EDU>, Amit Patel wrote:

>I do 100% of my professional development in Python, too.  Google's
>using a lot of Python and C++, and fortunately I get to do my work in
>Python.  :-)
>
>I should post Google's Python-related job openings to
>          http://www.python.org/Jobs.html

Pointless tanget: Is it just me, or is Google really the last usable search
engine?

-- 
Grant Edwards                   grante             Yow!  Is it FUN to be
                                  at               a MIDGET?
                               visi.com            


From toth.22 at osu.edu  Thu Mar 16 19:46:25 2000
From: toth.22 at osu.edu (CT)
Date: Fri, 17 Mar 2000 00:46:25 GMT
Subject: Project opinions please
Message-ID: <38d1801d.356312540@news-server.columbus.rr.com>

			

Hi folks,


I've been thinking lately of creating a python program that does a
number of automated tasks. Currently, I have to do all these manually.

1) Anyalize common logs for irregularties (errors, hack attempts,
etc...)

2) Check  programs on the server that access the network and generate
a log of their activity

3) Monitor ports to see what kind activity is occuring (hack attempts,
probes, etc...)

The user could tell the program what to look for, where to look, and
to how often to look.


I would like the agent/daemon to all the above on a user-defined
scheduled basis, and then email the results to the user.


Now, I realize this has been done before, but I want to do this myself
to help me learn some aspects of the python language and also because
I think it would be fun.

What I need, is some advice on how to approach this project, what type
of issues will I need to consider, where should I start(#1 question
acutally) and what other things I will need to learn...

Thanks for reading,
CT




From godzilla at netmeg.net  Sun Mar 19 20:20:39 2000
From: godzilla at netmeg.net (Les Schaffer)
Date: Mon, 20 Mar 2000 01:20:39 GMT
Subject: need fast parser for comma/space delimited numbers
References:  <87vh2ic2v6.fsf@lumen.med.iupui.edu>  <87wvmy7fjw.fsf@lumen.med.iupui.edu>
Message-ID: 

Mike Miller said:

> It checks that the number of fields in each non-comment line is
> constant.  I think that part would be fairly simple to remove.

sorry, i probably wasnt clear.

what i meant was that i have to read in a few hundred files at a time,
each file has equal length rows, but the number of columns varies
__from file to file__.

les


From timo at alum.mit.edu  Sat Mar 11 00:22:43 2000
From: timo at alum.mit.edu (Timothy O'Malley)
Date: Sat, 11 Mar 2000 00:22:43 -0500
Subject: Cookie module segmentation fault
References: <8a91fh$2kg$1@nnrp1.deja.com>
Message-ID: <110320000022433928%timo@alum.mit.edu>

hola.

In article <8a91fh$2kg$1 at nnrp1.deja.com>, Dan wrote:
> I recently ran upon a case where the cookie module was seg faulting on
> me.  
[..]
> --------------------------------
> import cookie
> a = 'Searches="jszXm!\\011Search#952590835.437"'
> cookie.Cookie(a)
> --------------------------------

As other posters note, the segmentation fault comes from the cPickle
module.  If you are using literal strings as your cookie values,
Cookie.py (now at version 2.24 or so) includes a way to skip the
cPickle parsing step:

     cookie.SimpleCookie(a)

See the Cookie.py module documentation for more information.


From gidon at norealaddress.ch  Mon Mar  6 05:40:00 2000
From: gidon at norealaddress.ch (Gidon Friedman)
Date: Mon, 06 Mar 2000 11:40:00 +0100
Subject: compile on aix 4.3
Message-ID: <38C38B00.3E44D373@norealaddress.ch>

hi to all

i get this problem with my first time installation of the latest python
source, i'd appreciate any hint:
-------------------------snip------------------
# ./configure
creating cache ./config.cache
checking MACHDEP... aix4
checking CCC...
checking for --without-gcc... no
checking for gcc... cc
checking whether the C compiler (cc  ) works...
------------------and now it hangs forever----------

thankx

gidon





From amused at webamused.com  Tue Mar 21 22:55:23 2000
From: amused at webamused.com (Joshua Macy)
Date: Wed, 22 Mar 2000 03:55:23 GMT
Subject: Embedding Python in a MUD
References: <38D7EAA8.6863DEE3@classic-games.com> 
Message-ID: <38D84126.BE5EB4EB@webamused.com>

Will Ware wrote:
> 
> Greg Miller (gmiller at classic-games.com) wrote:
> > I'm considering Python as an in-mud scripting language.
> 
> I'm interested in this. I want to do something similar. 

 You might want to check out MOOP in the Vaults of Parnassus.  MOOP is a
MUD/MOO that not only used Python as its scripting language, but is
written entirely in Python.

  Joshua


From greg at cosc.canterbury.ac.nz  Tue Mar 21 23:17:40 2000
From: greg at cosc.canterbury.ac.nz (Greg Ewing)
Date: Wed, 22 Mar 2000 16:17:40 +1200
Subject: binary to decimal conversion
References: <8b0r07$r5u$0@216.39.162.232> 
Message-ID: <38D84964.7B479DD@cosc.canterbury.ac.nz>

Michal Bozon wrote:
> 
> def btoi(num, o="0", i="1"):
>     def powL(a, e): # can handle BIG numbers (long)
>        ...
>     c = [o, i]
>     output = 0
>     for i in range(len(num)):
>         output = output+c.index(num[-i-1])*powL(2, i)

Calculating 2^n from scratch for each bit is a tad wasteful.
How about

  def btoi(num):
    result = 0L
    bit = 1L
    n = len(num)
    while n:
      n = n - 1
      if num[n] == "1":
        result = result + bit
      bit = bit << 1
    if result <= sys.maxint:
      return int(result)
    else:
      return result
    
-- 
Greg Ewing, Computer Science Dept,
+--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+


From pj at sgi.com  Wed Mar  1 17:34:53 2000
From: pj at sgi.com (Paul Jackson)
Date: 1 Mar 2000 22:34:53 GMT
Subject: Most common #! format
References: <38BD9017.4A2B5941@mindspring.com>
Message-ID: <89k5ud$e8fsj@fido.engr.sgi.com>

Don't know which is the most common, but:

    #!python

is a likely candidate for the least common.  

That's because this '#!' interpreter syntax requires the
full path (or at least a path relative to the current working
directory) of the interpreter.

That is, it doesn't to $PATH (execvp or execlp) path searches.

--

See also a thread in comp.lang.python, late April 1988,
entitled:

    Advantages of #!/bin/env python?

which discusses the pros and cons of these alternatives.
-- 

=======================================================================
I won't rest till it's the best ...	   Software Production Engineer
Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj


From spamfranke at bigfoot.de  Tue Mar 14 20:38:03 2000
From: spamfranke at bigfoot.de (Stefan Franke)
Date: Wed, 15 Mar 2000 01:38:03 GMT
Subject: Should Python documentation for __class__ be improved?
References: 
Message-ID: <38d1e896.8004769@news.btx.dtag.de>

On Tue, 14 Mar 2000 18:28:51 -0500, Tom Funk
<_spam_sux_tdfunk at _spam_sux_nettally.com> wrote:

>  o  when called it creates a new instance of the class  
>     i.e., 
>
>         c=Class(arg,...) 
>
>      is the same as 
>
>         c=self.__class__(arg,...)
>
>(Pretty cool stuff, Guido! :-)

Hmm, is this case, yes, but not generally: 

  c=self.__class__(arg,...)

creates an instance of self's class even in derived classes,
(descendants of 'Class') whereas 

  c=Class(arg,...) 

creates only instances of 'Class' itself. This trick makes Guido's
implementation even a bit cooler than you'd figured out by now..

>So, what __class__ *really* is, is: 

a reference to a *class object*, which is a first order object like
integers, strings and functions too. That means they can be assigned
or passed as parameters/return values or computed by an expression
like any other value in Python.

Regards,
Stefan



From pinard at iro.umontreal.ca  Mon Mar 27 12:19:39 2000
From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=)
Date: 27 Mar 2000 12:19:39 -0500
Subject: TrueType file handling
Message-ID: 

Hi, people.

I barely started writing Python code for handling TrueType files.  I'm
telling you in hope that we avoid duplicating efforts.  If you know that
this has already been done, please tell me and give me pointers.  If you
are interested in what comes out of this, tell me, and I'll keep you posted.

-- 
Fran?ois Pinard   http://www.iro.umontreal.ca/~pinard





From jim_kerr at agilent.com  Thu Mar 16 13:46:15 2000
From: jim_kerr at agilent.com (Jim Kerr)
Date: Thu, 16 Mar 2000 10:46:15 -0800
Subject: problems using COM with Visual C
Message-ID: <8ara42$pks$1@nirvana.sr.hp.com>

  I'm trying to use Python's COM facilities to control a build in Visual
C++.
I've run into some problems that don't make sense to me at all (not
surprising,
since I don't know COM).

  Here's the script I have so far:

     # Open and manipulate a Visual C++ project

     from win32com.client import Dispatch
     vc=Dispatch("MSDEV.Application")
     vc.Visible=1
     vc.Documents.Open(r"C:\src\Workspace.dsw")
     projlist = vc.Projects
     ap = vc.ActiveProject()

  So far, so good; ap has the value 'MainApp', as it should. But if I
try to set the active project (from PythonWin)

    >>> vc.ActiveProject = 'Persist'

... it doesn't fly:

Traceback (innermost last):
  File "", line 1, in ?
  File "C:\Program Files\Python\win32com\client\dynamic.py", line 413, in
__setattr__
    self._oleobj_.Invoke(self._olerepr_.propMap[attr].dispid, 0,
pythoncom.DISPATCH_PROPERTYPUT, 0, value)
com_error: (-2147352567, 'Exception occurred.', (61837, 'Microsoft Visual
C++', 'Unable to write read-only property.',
'C:\\PROGRA~1\\MICROS~3\\COMMON\\MSDEV98\\BIN\\MSDEV.HLP', 455053, 0), None)

  The MSDEV documentation sure implies that ActiveProject is writable, so
this
error seems kind of confusing.

  So anyway, I'm doing something wrong... I can accept that. But here's the
odd thing:
from this point on, no matter what I type at the PythonWin prompt, a dialog
appears
that says:

  'The topic does not exist. Contact your application vendor for an updated
   Help file (129)'

  The only cure that I've found for this is to quit and restart PythonWin.

  Has anyone out there slayed these dragons before?

  FWIW, here are some OS and Python specifics:
    NT 4.0, Service Pack 5
    PythonWin build 125

  Thanks for the help!

-Jim





From herzog at online.de  Mon Mar  6 12:08:18 2000
From: herzog at online.de (Bernhard Herzog)
Date: 06 Mar 2000 18:08:18 +0100
Subject: HELP: restore my faith in Python
References: <38C00D46.8CC5BA67@americasm10.nt.com> <38C373C4.3EBB62D8@sightreader.com> 
Message-ID: 

grant at nowhere. (Grant Edwards) writes:

> If you want to round to the nearest integer, then use
> int(x+0.5).  That's been idiomatic in programming for longer
> than I've been around.

Unfortunately, it might produce incorrect results for negative x, at
least on some systems which truncate towards 0 and towards -infinity:

Python 1.5.2 (#1, Nov 13 1999, 12:17:58)  [GCC egcs-2.91.66 19990314/Linux (egcs- on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> x = -0.9
>>> int(x + 0.5)
0
>>> x = +0.9
>>> int(x + 0.5)
1

A better solution is to round() first.

-- 
Bernhard Herzog   | Sketch, a drawing program for Unix
herzog at online.de  | http://sketch.sourceforge.net/


From hanche at math.ntnu.no  Fri Mar  3 13:33:26 2000
From: hanche at math.ntnu.no (Harald Hanche-Olsen)
Date: 03 Mar 2000 13:33:26 -0500
Subject: C++ / Java / Python (was Status of C++)
References: <38bf4389.272576531@news.mindspring.com>
Message-ID: 

+ dickjoe_nospam_ at mindspring.com:

| You, dear Sir, are sadly misinformed.
| 
| I (with others) have written an industrial-strength image server
| completely in (portable) C++. [...]
| 
| Java you say? I laugh in your face. C++ is one of the most sought-
| after skills for "serious" programming (see below). [...]
| 
| C++ is pretty much the default choice for "serious" software, and
| in that I incude "system" and "application" programming.

I am glad you write "serious" in quotes.  You see, I have a little bit
of a problem understanding what people mean when they use that word,
but mostly it seems to mean large, complex, time consuming.

To help me in my own research, I tend to write a bunch of small
programs.  My latest one, to help me explore some PDE solutions, is
less than a thousand lines of python, using numpy and a small
extension written in C, plus a Tkinter piece for the visualization
bit.  It's a bit slow, but it works well enough for my purposes.  By
the time the program has served its purpose (hopefully having helped
my understand what's going on with this equation), it will probably
have used at most a few hours of CPU time and a few weeks of my time.
This program may not be "serious", but I assure you it's serious.

Trying to write this beast in C++ in order to cut the CPU time used
from hours to minutes would likely have increased my own time
expenditure from weeks to months - clearly an extremely bad bargain.

I wonder how much software out there is of this type - serious but not
"serious"?  So this is my wish for the day:  That people would stop
using the word "serious" merely to distinguish big, complex, CPU
intensive projects from those where programmer time is by far the most
important constraint (which also includes myriads of system
administration scripts, the other big category of small programs that
I find myself writing).

I am not saying that you don't understand this - on the contrary, it
seems that you do, at least if one reads between the lines a bit,
particularly as you *do* advocate python for some uses.  But I see the
idea of C++ as the *only* solution to *every* problem bandied around
too much, and I think that does a great disservice to the large (?)
number of people who, like me, need to write bunches of little
programs to solve their very real (and serious, thank you very much)
problems.

| Anything that runs on a server should not use java.

And why not?  Not every server carries a heavy load.

| Java is NOT an alternative to C++.
| Python IS an alternative to Java (except for lack of browser support)

On the contrary, I think both can be an alternative to C++, but you
need of course to consider the tradeoffs between programmer time and
other resource constraints.

| Lisp (its myriad flavors) has it adherents

Indeed, Common Lisp combines advantages in terms of programmer
productivity with the potential for very good efficiency (all modern
commercial CL systems can compile to native machine code).
Unfortunately, it has lost the popularity war, at least for now.

| I am not interested in language flame wars

Neither am I, and I hope I haven't contributed to one.  And I don't
really have any quarrels with you either.  I just wish you and others
would avoid that s-word.

serious-but-not-deadly-so-ly y'rs,
-- 
* Harald Hanche-Olsen     
- "There arises from a bad and unapt formation of words
   a wonderful obstruction to the mind."  - Francis Bacon


From alex at somewhere.round.here  Tue Mar 28 18:30:15 2000
From: alex at somewhere.round.here (Alex)
Date: 28 Mar 2000 18:30:15 -0500
Subject: Exec with loops
References: <8breac$39i$1@nnrp1.deja.com>
Message-ID: 

> Anybody know how to use exec to run code containing arbitrarily
> complex loops? Thanks.

This'll probably do the trick:

>>> s = '''for i in 10 * [None]:
  print 'Hi there'
'''
... ... >>> 
>>> t = compile (s, 'string', 'exec')
>>> exec (t)
Hi there
Hi there
Hi there
Hi there
Hi there
Hi there
Hi there
Hi there
Hi there
Hi there
>>> 

Alex.


From shogan at iel.ie  Tue Mar 14 10:32:26 2000
From: shogan at iel.ie (Shaun Hogan)
Date: Tue, 14 Mar 2000 15:32:26 -0000
Subject: what is the equivalent of scanf in python?
Message-ID: <021501bf8dca$80530d60$2801000a@iel.ie>

this may seem like a easy/strange question, but for the life of me i cant
remember:
what is the equivalent of scanf in python?
what code would i need to ask a user to input 2 numbers
then output the result?
Bewilderdly yours
Shaun






From ez4glNOezSPAM at hotmail.com.invalid  Tue Mar  7 17:01:19 2000
From: ez4glNOezSPAM at hotmail.com.invalid (ez4gl)
Date: Tue, 07 Mar 2000 14:01:19 -0800
Subject: Python scripting engine for ASP
Message-ID: <0721e130.1fa10121@usw-ex0103-023.remarq.com>

I may soon be going to work in a Microsoft shop (not that I'm in
an open source shop now), but want to sneak Python in as my ASP
programming language -- can anybody direct me to where I might
find the necessary scripting engine?

Thanks in advance

George


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



From tom-main at REMOVEME.home.com  Sat Mar 25 16:54:42 2000
From: tom-main at REMOVEME.home.com (Tom)
Date: Sat, 25 Mar 2000 21:54:42 GMT
Subject: Python tutorial/comparison for C++ programmer
References:  <8bicur$jnt$2@news1.xs4all.nl>
Message-ID: 

I tried the link but it didn't work.

Tom.

"Boudewijn Rempt"  wrote in message
news:8bicur$jnt$2 at news1.xs4all.nl...
> Tom  wrote:
>
> > I'm a C++/MFC programmer and I'm interested in learning Python.
>
> > Are there any Python language resources geared to C++ programmers?  I
guess
> > I'm looking for something that would compare the syntax, concepts, etc.
of
> > the two languages, eg. how do the object models differ.
>
> > (I've already found Mark Hammond's Win32/MFC Python stuff.)
>
> Well, it's probably not directly relevant, but I took a C++ tutorial
> and translated it into a Python tutorial. The original was meant for
> beginning C++/Qt developers. Taking a look at:
>
> http://www.valdyas.org/python/tutorial.html
>
> can't hurt ;-).
>
> --
>
> Boudewijn Rempt  | http://www.valdyas.org




From cobrien at Radix.Net  Mon Mar 27 16:41:50 2000
From: cobrien at Radix.Net (Cary O'Brien)
Date: 27 Mar 2000 16:41:50 -0500
Subject: Zope
References: <69sudsokeqsk8iaes7jdrjpd24nfkm9r61@4ax.com>
Message-ID: <8bokiu$akp$1@saltmine.radix.net>

In article <69sudsokeqsk8iaes7jdrjpd24nfkm9r61 at 4ax.com>,
Anders M Eriksson   wrote:
>Hello!
>
>I have some questions about Zope and I thought I ask them before
>spending alot of time reading the documentation.
>
>
>
>
>Can I install zope on a apache system WITHOUT being root? My ISP is
>running apache on a Solaris 5.6 system.
>

Yup.  It will be easier if python >= 1.52 is already installed.  If
not you will have to build that in your own directory.  Check the
./configure --help output to see what flags to set.

Zope, by default, binds to unprivileged ports, so you can run it
just fine.  

>I want to create a system that lets any user create his own User Data
>Record. The user data record will contain data about the user, e.g.
>Name, email address, etc. This record should only be editable by the
>user (and admin) with somekind of login. This user data must then be
>searchable! Listings on all or some of the data should be able to
>present in different sorting orders, e.g. Lastname, country, etc.
>
>Is Zope suited for this kind of system?

Absolutely.  The big question is whether or not you want 
your system backed by a RDBMS or not.  But zope is happy
either way.

>Maybe someone already has created a system like this?
>

See http://www.zope.org for more details.  You probably
want to get on the zope mailing list. Start with the digest,
this is a high volume list.

-- cary






From wilson at mclachlan.com.au  Thu Mar 16 18:06:25 2000
From: wilson at mclachlan.com.au (Wilson Fletcher)
Date: 16 Mar 2000 23:06:25 GMT
Subject: Assigning output from a simple python statement
References: <01bf8f1f$a611b640$3201a8c0@wraith.mclachlan.com.au> 
Message-ID: <01bf8fa4$9407a240$3201a8c0@wraith.mclachlan.com.au>


Michael Hudson  wrote in article
...
> "Wilson Fletcher"  writes:
> 
[...]
> 
> I leave out my usual "do you really want to `exec' things you don't
> know everything about" comment, I think.
> 

hehehe, I didn't say I didn't know the source, only that I couldn't be sure
of the code.



From eq3pvl at eq.uc.pt  Mon Mar 27 04:37:18 2000
From: eq3pvl at eq.uc.pt (Pedro Vale Lima)
Date: Mon, 27 Mar 2000 09:37:18 +0000
Subject: Scripting language poll at linux.com
Message-ID: <38DF2BCE.291B7D81@eq.uc.pt>

There is a Scripting language poll at
http://www.linux.com/polls/index.phtml

Go and and show them who rulez.




From tuttledon at hotmail.com  Tue Mar  7 20:27:36 2000
From: tuttledon at hotmail.com (Don Tuttle)
Date: Wed, 08 Mar 2000 01:27:36 GMT
Subject: Python performance
References:  
Message-ID: 

I've  moved this question to "Is it Python or is it C ?"




From effbot at telia.com  Tue Mar 14 11:02:56 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Tue, 14 Mar 2000 16:02:56 GMT
Subject: Problem with tkinter & spawning processes
References: <8ale7h$bl$1@news1.sunrise.ch>
Message-ID: 

nathan  wrote:
> I've programmed a GUI with Tkinter and I've started  it with the
> mainloop() as usual.  Now, I want to start a new process from
> the GUI, by pressing a button.
>
> I've tried with:
> os.system('"C:\Program Files\Python\Python.exe" -i test.py')
>
> The new process starts fine (standard output on the DOS cmmand
> prompt) nd I cannot do anything more.
>
> It seems that the new started process blocks the mainloop() thread

the os.system call doesn't return until the new process
has terminated.

> How can avoid this?

this might work:

    os.system('start "C:\Program Files\Python\Python.exe" -i test.py')

or you could use os.spawn(os.P_NOWAIT, ...).  see
http://www.deja.com/=dnc/getdoc.xp?AN=589728736

(tweaking that script to support a wait/nowait flag is
left as an exercise for the reader)








From quinn at hedono.ugcs.caltech.edu  Tue Mar  7 20:54:50 2000
From: quinn at hedono.ugcs.caltech.edu (Quinn Dunkan)
Date: 8 Mar 2000 01:54:50 GMT
Subject: sigchld vs. os.popen, os.command, etc.
References:  <8a3cj5$15bg$1@nntp6.u.washington.edu> <38C572CC.90C3BA6@endea.demon.nl>
Message-ID: 

On Tue, 07 Mar 2000 22:21:16 +0100, Niels Diepeveen 
wrote:
>Donn Cave schreef:
>
>> It's too bad select() can't wait for processes along with I/O, that
>> would be a nice solution in some cases.
>
>What if you pass the write end of an unused pipe to the child process?
>When the child terminates it will be closed and select() will return
>ready on the read end. At least that is what I would expect.

Hmm, that's a clever idea, but I wound up polling with waitpid + WNOHANG,
which seems simpler and more synchronous anyway (and fits nicely into a 15-sec
event loop).

Hmm, I wonder why we can't just have a waitpid()-like call with a timeout and
multiple pids...  I guess you could set an alarm and waitpid(-1) or
something...


From clopez at abo.fi  Mon Mar 20 13:34:48 2000
From: clopez at abo.fi (Cesar Lopez)
Date: Mon, 20 Mar 2000 20:34:48 +0200
Subject: How do I debug embedded python code?
Message-ID: <38D66F47.E96304D4@abo.fi>

I have to call a python module from a C program, and I don?t know how to
debug this python code.

main
{

......

 co = (PyCodeObject *)v;
 v = PyEval_EvalCode(co, d, d);



}

Where co it is a buffer with the python code of a python program:

test.py

import led
led.Setup(1)



From claird at starbase.neosoft.com  Tue Mar  7 13:14:54 2000
From: claird at starbase.neosoft.com (Cameron Laird)
Date: 7 Mar 2000 12:14:54 -0600
Subject: Python advocacy
References: <8wQv4.33688$pN1.381485@news1.rdc1.nj.home.com> <89p2kd$1arc$1@nntp6.u.washington.edu>  <38C411A1.B552C42@prescod.net>
Message-ID: <01DCAB3E36313BC3.A8B11C96704C6225.0408D4A80634DAF4@lp.airnews.net>

In article <38C411A1.B552C42 at prescod.net>,
Paul Prescod   wrote:
			.
		[Maybe Java can be
		used for everything;
		in any case, Tcl is
		crap]
			.
			.
>Then a language like Python comes along which subsumes the abilities of
>(at least) TCL, Perl, Visual Basic and ten thousand macro languages. It
>is my assertion that there are no large, complex problems that can be
>solved more easily in any of those languages than in Python with a
>suitable library and (in the case of VB) development environment.
			.
			.
			.
>choosing our programming languages for us. Yes, you can use sh and VBA
>for tiny little programs but isn't it just one damn more thing to learn?
>Is it worth learning another language to reduce a 10 line program into
>1?
>
>Given that Python offers us an opportunity to avoid the code
>fragmentation caused by all of these little fragmented language
>communities (Perl for text processing, TCL for Unix GUIs, VB for Windows
>GUIs, other Basic variants for macros), it is only natural to ask if it
>can also swallow the huge category of tasks being done with Java (we'll
>leave C and FORTRAN alone for now...). If Sun succeeds in making Java
			.
			.
			.
> 1. that the one complex feature we still cannot profitably strip out is
>type safety -- if we strip that out we won't be able to build big,
>complex systems (sound familiar?) or at least efficient systems
>
> 2. that there is no good way to introduce this feature into an
>erstwhile dynamically typed language
>
>I am told by those in the know that Common Lisp disproves both of these
>assertions. You can get fast code and complex systems from a language
>with an optional "add-later" type declaration system. In fact, people
>write large, complex systems in competely dynamic Lisps, Smalltalks and
>low and behold, Python. The people writing the largest systems seem the
>least inclined to argue that the lack of a static type system is
>limiting them.
>
>It is debatably the case that static type checking systems help people
>to write code that scales to large systems. It is indisputably clear
>that it can help the readability of the code. It is relatively clear
>that it also helps the performance without massively complicating the
>implementation. That's why Python is likely to eventually grow a static
>type system. Then we can shove another sock in mouth of the apologists
>for languages that are not good at one thing or another.
>
>Can there be one language that does everything? Everything? Possibly
			.
			.
			.
>> Obviously, Paul is entitled to his view that the cost of proficiency in C++
>> is too high. As a proficient C++ programmer, I have to disagree. I  can't
>> imagine writing industrial-strength apps solely in Python (and I do mean
>> industrial -- I've got applications running in steel mills).
>
>To be honest with you, if I was required to write an application that
>was going to run in a steel mill, and I was not constrained by memory or
>CPU (which you often would be) then I would choose a dynamically typed
>language with automatic memory management and pointer safety over a
>statically typed language without, any day. Tbe safe I would probably
>use a language like Java or Eiffel with both, just to be safe.
>Seriously, where reliability is an issue, C++ would be at the bottom of
>my list. Dr. Watson's frequent appearance on Windows NT desktops is a
>testament to C++'s reliability.
			.
			.
			.
Paul and I could happily go off in a corner and split hairs
for--well, for a long time.  I disagree with several claims
about Tcl, Java, ...; those who truly care about the details
are welcome, as usual, to ask.

I'll decorate a few of his more central points, though:
1.  Sun's not going to make Java a success.  I
    think Sun still intends that, but hasn't
    the capacity.

    IBM probably *will* make Java a success.
2.  I have no idea whether Java will make it in
    the embedded world.  My current expectation
    is that the project of porting Java every-
    where's going to collapse in a sorry heap.
    Maybe it'll work.  I'm unconvinced.
3.  Type safety is a tiny and essentially ir-
    relevant part of what it really takes to
    build big, complex systems.  I know you
    know this.  It needs to be repeated.
4.  Do NOT buy into the nonsense, even for a
    moment, that C and C++ are "better supported
    by tools".  They *require* tools to compensate
    for their burdens of memory management, ...
    That's the whole story.
5.  We're not far away from a time when people
    will say, "Controlling a steel mill/submarine/
    power plant/refinery/... with C++ codings?
    Are you serious?  That would be like, well,
    like, driving a car without having the children
    buckled into seat belts."  Yup.  We did it for
    a lot of years.  There's a much better way.
6.  Complex systems never work, anyway.
7.  Complex systems have a shot of working when
    they're constructed from reliable parts.  The
    winning languages of the '90s were those that
    played well with other technologies.
8.  Ada and Eiffel:  they're safe.
9.  As much as Paul wants to do everything with one
    language, I'm probably as strong on the other
    side in looking for a way to accomodate lots of
    different languages.
10.  If I had to choose only one language, it would
    definitely be Python.  It's not really ready,
    though, without Unicode ...
11.  It's the libraries.  Syntax--piffle!

I'm probably still better at C than anything else.  I can
process signals and respond to external ports and maintain
complex data structures and so on without leaking memory or
violating array bounds or confusing argument lists.  I'm an
anachronism, though.  I might as well be knapping flints.
Industrial customers are better off with any of several
other languages, although they don't yet realize it.

My most important point:  yes, we lose some benefits when
moving away from C and C++.  With very few exceptions, those
are costs we can afford, in comparison with the greater
benefits brought by other modern languages.  Don't get stuck
waiting for alternatives which are "perfect".
-- 

Cameron Laird 
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html


From see_plus_plus at my-deja.com  Wed Mar  8 00:04:12 2000
From: see_plus_plus at my-deja.com (see_plus_plus at my-deja.com)
Date: Wed, 08 Mar 2000 05:04:12 GMT
Subject: Python performance
References: <200003080330.OAA01737@nexus.csse.monash.edu.au>
Message-ID: <8a4n0a$spu$1@nnrp1.deja.com>

Not only the feathers were ruffled but somebody even fell out of his
tree without any technical & commercial counter pointer.

Whenever somebody writes a spreadsheet program in Python that outsells
MS Excel, C can be considered as obsolete.

cpp


Sent via Deja.com http://www.deja.com/
Before you buy.


From donn at u.washington.edu  Tue Mar  7 19:39:27 2000
From: donn at u.washington.edu (Donn Cave)
Date: 8 Mar 2000 00:39:27 GMT
Subject: sigchld vs. os.popen, os.command, etc.
References: <38C572CC.90C3BA6@endea.demon.nl>  <8a3cj5$15bg$1@nntp6.u.washington.edu>
Message-ID: <8a47fv$9jk$1@nntp6.u.washington.edu>

Quoth Niels Diepeveen :
| Donn Cave schreef:
|> It's too bad select() can't wait for processes along with I/O, that
|> would be a nice solution in some cases.
|
| What if you pass the write end of an unused pipe to the child process?
| When the child terminates it will be closed and select() will return
| ready on the read end. At least that is what I would expect.

Yes, that's worth trying.

	Donn Cave, University Computing Services, University of Washington
	donn at u.washington.edu


From greglandrum at earthlink.net  Mon Mar  6 08:47:01 2000
From: greglandrum at earthlink.net (greg Landrum)
Date: Mon, 06 Mar 2000 13:47:01 GMT
Subject: Choice Of Language (was: Python Advocacy)
References: 
Message-ID: <38C3B7AF.FCCD13EA@earthlink.net>

Don Tuttle wrote:
> 
> I have never programmed for a living.  (I enjoy it way too much to ever do
> that! )  So let me ask all you folks that do.  What percentage of
> your paid, professional time do you get to use Python?
> 

I'm (happily) at about 90-95%

-greg

-- 

greg Landrum (greglandrum at earthlink.net)
Software Carpenter/Computational Chemist


From vetler at ifi.uio.no  Sun Mar  5 11:03:04 2000
From: vetler at ifi.uio.no (Vetle Roeim)
Date: 05 Mar 2000 17:03:04 +0100
Subject: Choice Of Language (was: Python Advocacy)
References: 
Message-ID: 

* Don Tuttle
> [Ran]
> > No,  the project manager chooses the language(s) according to the needs
> > of the project and the availability of programmers and other resources.
> 
> I have never programmed for a living.  (I enjoy it way too much to ever do
> that! )  So let me ask all you folks that do.  What percentage of
> your paid, professional time do you get to use Python?

It's possible to get *paid* for programming? 
Where? ;-)


it's-possible-to-do-it-for-a-living
  -without-getting-paid-for-it--ly y'rs, vr

-- 
Vetle Roeim 
Graduate Student 
Departement of Informatics, University of Oslo, Norway


From mbarre at mac.com  Tue Mar  7 21:43:57 2000
From: mbarre at mac.com (Matthew Barre)
Date: Tue, 07 Mar 2000 20:43:57 -0600
Subject: newbie simple exec problems
References: 
Message-ID: 

That works, thank you. What do I need to do to get it to work for cgi? Can I
just put ~user/cgi-bin/.cgi.py?



-Matt
---------
"Ray! When someone asks you if you're a god, you say YES!!" -Winston Zedmore

> From: Michael Hudson 
> Organization: University of Cambridge, England
> Newsgroups: comp.lang.python
> Date: 08 Mar 2000 00:15:52 +0000
> Subject: Re: newbie simple exec problems
> 
> Matthew Barre  writes:
> 
>> I have been learning python on my mac, and I just setup a RH6.1 box on my
>> little LAN to practice Python as a cgi tool etc. Well the cgi thing has me
>> completely baffled and right now I can't even get a Hello World script to
>> run at the prompt ie:
>> 
>> $hello.py
>> bash:unrecognized command
>> 
>> I have tried chmod 0755 hello.py and
>> chmod a+x hello.py
>> 
>> The first line of the file is
>> #!/usr/bin/python
>> 
>> which is where I checked and that's where python is. I'm baffled. Right now
>> if I try to get a cgi the browser just prints the script...ack...what am I
>> doing wrong?
>> 
>> -Matt
>> ---------
>> "Ray! When someone asks you if you're a god, you say YES!!" -Winston Zedmore
>> 
> 
> Try
> 
> $ ./hello.py
> 
> `.' may well not be on your $PATH...
> 
> HTH, HAND
> Michael
> 
> -- 
> very few people approach me in real life and insist on proving they are
> drooling idiots.                         -- Erik Naggum, comp.lang.lisp



From mhammond at skippinet.com.au  Wed Mar 15 16:50:16 2000
From: mhammond at skippinet.com.au (Mark Hammond)
Date: Wed, 15 Mar 2000 21:50:16 GMT
Subject: win32ui.GetActiveWindow() problem
References: 
Message-ID: 

"Michal Bozon"  wrote in message
news:Pine.OSF.4.10.10003151652400.19621-100000 at prfdec.natur.cuni.cz...
> On Tue, 14 Mar 2000, Robin Becker wrote:

>  I use Pythonwin build 125 that I think is newest.

128 is the newest public release, but only at
http://starship.python.net/crew/mhammond

(129 just got released to registered users  - source code folding and
multi-views of the same source :-)

Mark.





From mwh21 at cam.ac.uk  Mon Mar  6 12:03:19 2000
From: mwh21 at cam.ac.uk (Michael Hudson)
Date: 06 Mar 2000 17:03:19 +0000
Subject: Self Nanny
References: 
Message-ID: 

Gaetan Corneau  writes:

> Would programmers who have a background in a language other than C++ really
> miss "self" in the method declarations? 


As I understand it, it's not there to make your life easier (or
harder), it's there because Python doesn't have declarations.

I tried to explain this in this article:

http://x37.deja.com/getdoc.xp?AN=588006439

and another that doesn't seem to be on deja...

Cheers,
M.

-- 
very few people approach me in real life and insist on proving they are
drooling idiots.                         -- Erik Naggum, comp.lang.lisp


From paulb at infercor.no  Wed Mar  8 06:03:21 2000
From: paulb at infercor.no (Paul Boddie)
Date: Wed, 08 Mar 2000 12:03:21 +0100
Subject: Splitting comp.lang.python
References:  <20000301105629.A4323@nl.linux.org>
Message-ID: <38C63379.423947D9@infercor.no>

gerrit at nl.linux.org wrote:
> 
> 4000 messages in 29 days is a lot. it's 138 messages a day. Previous
> discussions on splitting c.l.py always ended up in jokes and just
> disappeared; I want to resurrect an informal discussion on wheter
> to split the newsgroup or not; an RFD should be posted, of course,
> but IANAL: does anyone have time to create an RFD?
> 
>     I propose to split c.l.py in a technical part and a non-technical part.

I think any proposal has to take into account the following factors:

  * How obvious it is to decide where to post messages. If you're a new user,
    is it obvious where to post your message? Consider that new users may do a
    quick, desperate search for a newsgroup and, given that their news feed
    may be unreliable or that they're doing a search for newsgroups on
    deja.com, find only comp.lang.python and not the hypothetical
    comp.lang.python.newuser.

  * How well the traffic is split between the new groups. Many suggestions
    have only shown how good people are at classifying topics rather than the
    suitability of those classifications. It might be possible to create a
    new group for each of the SIG topics, but how popular are each of those
    topics?

  * How encompassing the topic of a particular group is. As I pointed out in
    an earlier message, it is not particularly desirable to have many groups
    where the majority of messages are cross-posted to other groups.
    Discussions tend to appear and disappear as people become tempted to "move"
    threads between groups.

  * Whether a group is really going to help people, or allow meaningful
    discussion to take place. Advocacy groups rarely allow either activity to
    go on.

One thing to remember is that as users become more technically competent, the
more likely it is that they will be able to subscribe to special interest
mailing lists and manage these interests appropriately. The issue here is
whether newsgroups are really necessary for such users or whether mailing lists
are enough.

what-are-we-trying-to-achieve-with-newsgroups-anyway?-ly-y'rs,

Paul


From cpr at emsoftware.com  Wed Mar 15 14:36:05 2000
From: cpr at emsoftware.com (Chris Ryland)
Date: Wed, 15 Mar 2000 19:36:05 GMT
Subject: Loop performance disappearance
References: <38CF938F.D56437EA@helsinki.fet> 
Message-ID: 

I always assumed (perhaps being too much of a newbie) that

for i in range(n):
   :

would automatically be recognized by the compiler and turned into a simple
loop control using i alone (like turning it into an xrange, I guess). Seems
simple enough and common enough that it should be automatic, no? (Forgive
any massive display of ignorance here.)

--
Cheers!
/ Chris Ryland, President / Em Software, Inc. / www.emsoftware.com
"Remco Gerlich"  wrote in message
news:slrn8cva9a.aj8.scarblac-spamtrap at flits104-37.flits.rug.nl...
> Mikael Johansson wrote in comp.lang.python:
> > I was just wondering what the reason for the huge performance decrease
> > in a loop execution when the number of steps exceeds some critical value
> > is. To give an example:
> >
> > for i in range(loops):
> >     pass
> >
> > If loops=500 000 (space added for clarity) the "program" executes in ~2
> > secs on my machine. But if loops is set to 5 000 000, the execution time
> > rises to substantially more than tenfold (I terminated it after one
> > minute). However the CPU-load is quite small, most of the time is spent
> > disk swapping like crazy!
>
> That's because range(loops) is a list. It actually has to construct a list
> that size, and then walks through it. 5 million doesn't fit in your memory
> and it starts swapping.
>
> > Any ideas of the reason for this, work-arounds?
>
> Use xrange instead of range. xrange doesn't return a list, but an object
> that generates values on demand, simulating a list. Slightly slower, but
> doesn't need the memory.
>
> --
> Remco Gerlich,  scarblac at pino.selwerd.nl
>   Murphy's Rules, "Which is why you get 'em so cheap":
>    In SPI's Universe, the sword is prohibited from use at any combat
>    range.




From shichang at icubed.com  Fri Mar 10 17:36:52 2000
From: shichang at icubed.com (Shichang Zhao)
Date: Fri, 10 Mar 2000 22:36:52 -0000
Subject: Anti- Re: De-compiler for *.pyc files
Message-ID: <01BF8AE1.22230BA0.shichang@icubed.com>

If I make a product using Python, that means someone gonna be able to 
decompile it and peek the source? Than how do I protect my private part? 
(no misunderstanding, I am a person supporting Open Source, but you know, 
if you work for other companies, they may not like the idear)



-----Original Message-----
From:	Michael Hudson [SMTP:mwh21 at cam.ac.uk]
Sent:	Friday, March 10, 2000 10:00 PM
To:	python-list at python.org
Subject:	Re: De-compiler for *.pyc files

"Zarkon & Zena"  writes:

> Does anyone have a "decompiler" that I can use to re-create the original
> *.py scripts from the "compiled" *.pyc files?
> I am stuck trying to make changes to some legacy Python code that I do 
not
> have the source for.
> Any help or suggestions would be greatly appreciated.

Do to www.google.com, type "decompyle" into the box, and then hit "I'm
feeling lucky".

Warning: It probably won't work.  But it's worth a try.

Failing that, you can just use the `dis' module on the functions and
work out what they do by hand, which is not very hard, but very
tedious.

Cheers,
M.

--
very few people approach me in real life and insist on proving they are
drooling idiots.                         -- Erik Naggum, comp.lang.lisp
--
http://www.python.org/mailman/listinfo/python-list




From markx.daley at intel.com  Thu Mar 23 10:21:13 2000
From: markx.daley at intel.com (Daley, MarkX)
Date: Thu, 23 Mar 2000 07:21:13 -0800
Subject: Jack-pot
Message-ID: 

No, I got a large number of identical listings as well.

- Mark

-----Original Message-----
From: Mikael Olofsson [mailto:mikael at isy.liu.se]
Sent: Thursday, March 23, 2000 1:37 AM
To: python-list at python.org
Subject: Jack-pot


Gosh, what's up? Suddenly I get several copies of each posting to 
c.l.py. I follow the group through its mailing list. Am I the only
one having this problem?

split-ends-ly y'rs

/Mikael

-----------------------------------------------------------------------
E-Mail:  Mikael Olofsson 
WWW:     http://www.dtr.isy.liu.se/dtr/staff/mikael
Phone:   +46 - (0)13 - 28 1343
Telefax: +46 - (0)13 - 28 1339
Date:    23-Mar-00
Time:    10:33:27

This message was sent by XF-Mail.
-----------------------------------------------------------------------






From nascheme at enme.ucalgary.ca  Wed Mar 29 14:43:06 2000
From: nascheme at enme.ucalgary.ca (Neil Schemenauer)
Date: Wed, 29 Mar 2000 19:43:06 GMT
Subject: socket.connect() and socket.bind() change
References:  <20000329195448.O3140@coltronix.com>
Message-ID: 

I think this change is going to break a lot of code.  The example
in the documentation used to use:

    s.bind(host, port)

and

    s.connect(host, port)

Unlike the append() change I would consider this to be changing a
documented interface.  All of my socket code will be broken by
this change.  Anyone else?


    Neil



From alex at somewhere.round.here  Mon Mar 27 12:16:17 2000
From: alex at somewhere.round.here (Alex)
Date: 27 Mar 2000 12:16:17 -0500
Subject: Strict Type Checking Objects in Python
References: 
Message-ID: 

> type_string = type("a") # what is the official "name" of the string
>                         # type anyways!?

from types import StringType

assert type ('') == StringType

Alex.


From effbot at telia.com  Wed Mar  1 17:09:05 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Wed, 1 Mar 2000 23:09:05 +0100
Subject: will python 3000 break my code?
References:  <040701bf83c5$5b296a20$34aab5d4@hagrid> 
Message-ID: <042801bf83ca$c3a0f000$34aab5d4@hagrid>

Daniel wrote:
>    |     3. be impossible to identify by automatic tools.
>    |     Tim's excellent checkappend.py can spot many
>    |     cases, but not all.
> 
> Actually, this isn't true (that it's impossible).
> If you really like, i'll take a few days of my spring break and write one
> guaranteed to catch every single case. 

how about this one:

    foo = list.append
    for bar in range(100):
        foo(bar, bar, bar)

or this one:

    class Foo:
        def __init__(self):
            self.setup()
            self.add = self.list.append
        def setup(self):
            self.list = []

    foo = Foo()
    foo.add(bar, bar, bar)






From avflinsch at att.net  Tue Mar 21 12:33:19 2000
From: avflinsch at att.net (aflinsch)
Date: Tue, 21 Mar 2000 11:33:19 -0600
Subject: how to 'scanf' in python
References: <006201bf9326$e9cb0520$2801000a@iel.ie>
Message-ID: <38D7B25F.C0579BA5@att.net>

Shaun Hogan wrote:
> 
> ok lads, im trying to figure our how to 'scanf' in python, but the code
> below isnt working properly, can anyone tell me what im doing wrong??
> 
> def rl():
>     line="how you doin"
>     import sys
>     line=sys.stdin.readline()
>     x, y = string.split(line[:-1])
>     x, y = int(x), int(y)
>     print x,y
> 


try 

def rl():
    line="how you doin"
    import sys, string
    line=sys.stdin.readline()
    x, y = string.split(line[:-1])
    x, y = int(x), int(y)
    print x,y


From effbot at telia.com  Wed Mar 29 19:21:49 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Thu, 30 Mar 2000 00:21:49 GMT
Subject: Python equivalent of "lynx -dump"?
References: <20000330001154.28633.qmail@web2106.mail.yahoo.com>
Message-ID: 

lewst  wrote:
> > An all Python solution is a little bit more complicated:
> >
> > import htmllib, formatter
> >
> > p =
htmllib.HTMLParser(formatter.AbstractFormatter(formatter.DumbWriter()))
> > f = open('test.html')
> > p.feed(f.read())
> > p.close()
> > f.close()
>
> Yes, but how can I store the output of "p.feed(f.read())" in a
> variable such as `data' like I'm doing above with lynxcmd.  Your
> code writes everything out to the terminal.

did you read the fine manual?

    http://www.python.org/doc/current/lib/writer-impls.html

    DumbWriter ([file[, maxcol = 72]])

    Simple writer class which writes output on the file object
    passed in as file or, if file is omitted, on standard output.

in your case, using a StringIO file object is probably the best
solution:

    import StringIO

    file = StringIO.StringIO()

    # build formatting pipeline
    w = formatter.DumbWriter(file)
    f = formatter.AbstractFormatter(w)
    p = htmllib.HTMLParser(f)

    ...

    data = file.getvalue()








From bjorn at roguewave.com  Sun Mar  5 17:32:55 2000
From: bjorn at roguewave.com (Bjorn Pettersen)
Date: Sun, 05 Mar 2000 15:32:55 -0700
Subject: req: OO SQL gen module?
References: 
Message-ID: <38C2E097.BA3C38E8@roguewave.com>

A while ago I was attempting to swig a c++ library that did exactly this, but
ran into problems when I couldn't overload the individual comparison operators
for a python class, e.g. consider (assuming Table.__getitem__() returns a Column
object):

    t = Table('foo')
    s = Select( t['col1'], t['col2'] )
    s.where( t['col3'] > 5 )  # oops, not possible

back when I was doing this, people were saying comparison operator overloads
would be implemented in 1.6, but I don't know if that has happened...

-- bjorn


Greg Wilson wrote:

> [apologies if this is a repeated post --- ISP problems]
>
> I am looking for a module that does for SQL what Perl's CGI.pm, Python's
> HTMLgen, and DOM libraries in various languages do for HTML and XML.  Right
> now, both Perl and Python require me to manipulate SQL at the string level.
> Tools like CGI.pm, HTMLgen, and DOM, on the other hand, let me manipulate
> trees at the semantic level, and then translate the tree structure into text
> when necessary. This seems like the right way to build, store, and
> manipulate SQL queries.
>
> If anyone has done something like this (in any language), I'd be grateful
> for pointers or references. Please mail me directly (gvwilson at nevex dot
> com), as I am not a regular reader of all of these groups.
>
> Thanks,
> Greg
>
> --
> http://www.python.org/mailman/listinfo/python-list




From neelk at brick.cswv.com  Thu Mar  2 20:25:12 2000
From: neelk at brick.cswv.com (Neel Krishnaswami)
Date: 3 Mar 2000 01:25:12 GMT
Subject: XML DTD for Python source?
References:    
Message-ID: 

Greg Wilson  wrote:
> > "Neel Krishnaswami"  wrote
> > Can I ask what the purpose of this utility would be?

I've rearranged your response a bit, so that I can answer the
interesting part first. :)

> Most of the data I deal with these days is either in XML, or headed
> that way. [...] I'm interested in exploring what would happen if I
> could do with programs what I do with hypertext:
>
> - apply a DTD to switch between Scheme-style parenthesizing, Python-style
>   indentation, or C-style bracing
> 
> - embed arbitrary information (images, optimization hints for the
>   compiler, etc.) in a way that third-party browsers and processors
>   can handle (specially-formatted comments are *not* the answer)
>
> One of the big motivations for my interest is that I don't expect
> kids my niece's age to put up with glass typewriters as a
> programming environment. They're already building web pages with
> images, their choices of color, etc.  Existing IDEs mostly just put
> lipstick on this particular toad...
>
> ...and then define a standard for specially-formatted comments that
> contain URLs and other enriched information, and turn the little
> parser into a browser plug-in so that it can translate .py files on
> the fly, and... That might be the only way forward, but I am
> interested in exploring what happens if we finally do to our
> programs what we're done to everyone else's documents :-).

I have looked into building a rich structuring editor, and let me tell
you, this is a MUCH bigger can of worms than you realize. It's bigger
than I realize, too, even though I think building a high-quality
programming environment could easily generate a dozen PhD theses along
the way. XML might be a useful interchange format, but IMO it doesn't
really help solve the core difficulties in this enterprise.

The two big problems surrounding building a good DE are:

o I have a program, and I want multiple views of and means of changing
  it.

o My program changes over time, with changes made by myself and
  others. I want to be able to understand and manage these changes. 

Simple examples of the first sort of tool are the "tags" program that
Unix programmers use to find function definitions, and Javadoc. A
moderately sophisticated example might be cweb, Knuth's literate
programming tool, or a form-painting GUI builder. Some extremely
sophisticated examples might be the Smalltalk refactoring code
browser, and PLT Scheme's static dataflow analyzer MrSpidey.

A simple example of the second sort of tool would be the "undo"
functionality in editors. A moderately complex version of is CVS. An
extremely sophisticated example of the second is using a database to
get fine-grained version control of the objects in a Smalltalk image.

Some things you should play with/look at are:

o Allegro Common Lisp 
o Visual Age Smalltalk

  These two are worth studying, because they show the level of 
  reflectivity and self-understanding a system needs in order to
  adequately answer the programmer's questions about the system,
  and to learn where the state of the art already is.

o Berkeley's Ensemble project

  This is an attempt to build an advanced multilingual development
  environment, with support for things like flagging the programmer
  if the code s/he's writing has incorrect syntax or doesn't type
  check, showing diagrams of hyperlinked class hierarchies, and so
  on, plus using an ODB to get persistent versioning and ACIDity
  for your code. There are a lot of good papers and theses available
  on the website -- I recommend it highly.

Note: I'm not saying this isn't worth doing -- quite the contrary! I'm
just saying that a) doing the Right Thing is one hell of a lot of
work, and b) your analyzer has to understand both the program and the
programming language to say very much useful about it.

> > what would an XML representation for Scheme programs look like?
>
> I don't know, but I don't think it would look like the token-level
> representation you posted.  I think it would look more like an XML
> encoding of an abstract syntax tree (AST).  
 
Hah! You fell for my trick question. :)

Seriously, you *can't* store arbitrary Scheme code in semantically
rich XML, because predicting whether you can finish reading a Scheme
program is equivalent to the Halting Problem. Scheme's hygienic macro
system is Turing complete, and you can rebind the symbols bound to the
special forms. It's like a document that can add and delete element
declarations to and from its DTD.

The same is somewhat true of Python, though less forcefully. It's
probably not possible to change they syntactic structure of Python,
but you can't really very infer much semantics from that, short of
actually running the program. For example, consider the __import__
hook. Doing an import can conceivably change nearly anything in the
Python environment.

It's a lot like type-safety: in order to build a language that can be
type-checked, you have to accept that there are good programs that
that your typesystem can't assign a type to.

[I think this analogy can actually be pushed further than I thought,
because if you think of a DTD as defining a datatype, then wanting to
store some semantics of the program in the XML means that you are
trying to guarantee that the program has the "type" defined by the
DTD. You will either have to accept that the XML is sometimes wrong,
or sometimes have to reject vaild programs. Neat!]


Neel


From effbot at telia.com  Mon Mar 13 18:28:39 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Mon, 13 Mar 2000 23:28:39 GMT
Subject: Forth like interpreter
References: <158801bf8bdc$08516040$6401a8c0@dorb>     <38CC03A9.6461C7D6@tismer.com> 
Message-ID: 

Samuel A. Falvo II wrote:
> >It may count for Forth, but for Python this is very fast.
>
> For any language that uses threaded interpretation in this manner, this
type
> of overhead *ALWAYS* counts.

umm.  do you seriously think that the best way to
speed things up is to go find something that takes
less than one percent of the execution time, and
work very hard on making that little part run a few
percent faster?

> What I'd like to know, though, is what kind of performance boost would one
> (theoretically) get if Python switched from its current switch-threading
to
> token, direct threading?

very close to zero, on most modern platforms.






From kragen at dnaco.net  Mon Mar  6 22:23:33 2000
From: kragen at dnaco.net (Kragen Sitaker)
Date: Tue, 07 Mar 2000 03:23:33 GMT
Subject: Python for non-programmers
References:  <3prrbskd8a3tmhmr8a4bnrcf2ft8k52k29@4ax.com>  
Message-ID: 

In article ,
Neel Krishnaswami  wrote:
>Kragen Sitaker  wrote:
>> The Scheme-as-CS-101 crowd seems to think that it's a good idea to
>> put off the whole mutability thing until later --- just have names
>> and values, and don't worry about mutation until later.
>
>My own experience matches that -- when I was introduced to functions,
>they were explained to me as basically substitutions. That is, if I
>had
>
>  (define (square x) (* x x))

I am guessing from this example that you were taught from SICP, at
MIT.  (Your mention of "problem sets" and your email address also
suggest this.)

Obviously 6.001 is at least somewhat successful at teaching MIT
students basic CS --- and, at that, some really heavy stuff considering
that it's just a first-semester CS class.

The question is, I guess, is it equally successful at teaching
programming to people who are too dumb or uneducated to get into MIT?
Indications seem to be "yes", but it's hard for me to say.

>I *hated* mutation, simply because I needed to start thinking about
>the deeply bizarre (to the novice me) and extraneous notion of
>"environments". I didn't see what they had to do with my program *at
>all*, and as far I was concerned they were an ad-hoc invention created
>to make me fail my problem sets.

At least the ad-hoc part is true.  I think they are an ad-hoc invention
created to make computers economically feasible with the technology of
the 1940s.

>I think it's possible for a total novice to handle a language with
>either mutation (eg BASIC), or functions (eg Scheme), but not both at
>once. That will confuse them unless they are sharper than I was when
>starting out -- I honestly have no idea how people were able to learn
>how to program with Pascal. ;)

Very slowly, and they generally remain confused for a long time.

Python is probably not a great language for teaching functional
programming.  Writing numerical functions gets boring in a hurry, and
Python's aggregate data structures are all messy and inefficient to
deal with without mutation.

Python is probably a good language for teaching procedural programming.

I'll post a flaming rant about why CP4E is uber-important some other
time.
-- 
       Kragen Sitaker     
The Internet stock bubble didn't burst on 1999-11-08.  Hurrah!

The power didn't go out on 2000-01-01 either.  :)


From effbot at telia.com  Fri Mar  3 14:39:51 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Fri, 03 Mar 2000 19:39:51 GMT
Subject: MIMETOOLS QUESTION
References: 
Message-ID: 

Gregoire Welraeds  wrote:
> According to the Library reference doc, on page 244 (section 12.7) the
> package tool define a Message(fp[,seekable]). Wel, very cool... but what
> are fp and seekable after all ?

the copy I have points out that mimetools.Message is a sub-
class of rfc822.Message.  the arguments are well explained
in that chapter...

> All I want is to parse a MIME header from a string read on a socket...

the Message takes any file object which properly implements
"readline".  you can use StringIO to access your string as if
it were a file -- or in this case, you can use "makefile" on the
socket to wrap the socket itself in a file object.

> I found that, except for the tutorial, there is a lack of example in the
> python documentation. Python is not a strong typed language so it's pretty
> difficult to find the meaning of some arguments used in the API.
>
> Maybe Guido could take some example of the Faqts site to put them in the
> doc... Guido ?

better make that "Fred"

fwiw, there's plenty of cookbooks out there.  here are a few:

+ Python Annotated Archives (by Martin Brown):

    http://www.python.org/psa/bookstore

  50+ sample scripts from various sources; extensive
  annotations by the author.  massive piece of work.

+ Programming with Python (by Tim Altom):

    http://www.python.org/psa/bookstore

  have only browsed it, but it appears to be a budget
  version of the annotated archives.  early reviewers
  seem to think it's no good, so you may wish to check
  it out in a bookstore before buying it.

+ The Python Grimoire (by Andrew Kuchling):

    http://starship.python.net/crew/amk/grimoire/

  work in progress; sample scripts from various (mostly
  unattributed?) sources; sorted by task.  (like martin's
  book, this seems to contain some eff-bot code, so it
  cannot be all bad ;-)

+ (the eff-bot guide to) The Standard Python Library,
  eMatter edition (by Fredrik Lundh):

    http://www.pythonware.com/people/fredrik/librarybook.htm

  320 sample scripts, sorted by standard library module.
  more code and less annotations than the others (after
  all, python code is supposed to be easy to read ;-).






From dworkin at ccs.neu.edu  Sun Mar  5 12:15:28 2000
From: dworkin at ccs.neu.edu (Justin Sheehy)
Date: 05 Mar 2000 12:15:28 -0500
Subject: my first real program blows up, can someone tell me why?
In-Reply-To: "Jerry F. Davis"'s message of "Sun, 05 Mar 2000 10:26:05 -0600"
References: <38c28b4f$0$40286@news.execpc.com>
Message-ID: 

"Jerry F. Davis"  writes:

> I read the tutorial and tried a variation on what i saw there. and it
> blew up, with a integer overflow. can someone tell me why?

You aren't converting the argument to a string.

The line that reads:

x = sys.argv[1]

should read:

x = int(sys.argv[1])

With that change, your program should only overflow if you try to pass 
an argument that is... hm, one larger than the last fibonacci number
preceding your system's maximum integer.

If you wish to make your program able to handle arbitrarily large
arguments, you should modify it to use Python's long data type.

-Justin

 



From Peter.Desaulniers at pahv.xerox.com  Wed Mar  8 16:59:03 2000
From: Peter.Desaulniers at pahv.xerox.com (Desaulniers, Peter)
Date: Wed, 8 Mar 2000 13:59:03 -0800 
Subject: HELP: Python.exe Application Error using Extensions on Win2000
Message-ID: <51B8ABCE456FD111899900805F6FD6EE071E90C2@mercury.ADOC.xerox.com>

Hello Fellow Pythoners,

I hope this is the appropriate list for this type of request.

The architecture is a python method that make a call into a C extension
which in turn loads a 3rd party DLL (via LoadLibrary and later
FreeLibrary).  A Py_Object is created in the extension which includes a
member object obtained from a call into the DLL. The Py_Object is returned
to the python method.  The python method then makes calls to the methods on
the 3rd party object via the Py_Object.  The code works fine. Everything
happens as is should then the error occurs at the very end when its cleaning
up. 

I am getting a Python.exe Application error indicating that I am trying to
"write" to an unacceptable memory location on a Win2000 system.  The exact
same code works fine on WinNT 4.0.   I have determined that it is occurring
during the Python cleanup as the Python process is shutting down. This is
confirmed by doing an os._exit(0) as the last line in the top level module
being executed (to prevent the clean up, the problem still occurs with a
sys.exit(0) in the same location).  So, something changed in Win2000 that is
instigating this problem.

If I skip the use of the extension altogether and let the rest of the python
method to work without the feature obtained from the 3rd party DLL then I
get no problem indicating that it is the use of the C extension that is
causing the error.

The extension has a dealloc method  for the Py_Object which gets called by
python.  The dealloc method frees allocated memory and DECREFs objects. The
dealloc is called and does complete before the error occurs.  The problem
occurs whether dealloc is allowed to do its stuff or not (e.g. returning at
the beginning of the dealloc method).  

Has anyone seen a similiar problem with the use of C extensions and / or 3rd
party DLLs on Win2000? And if so, how did you resolve the problem?

Or, in a more general sense, has anyone discovered some less than obvious
things (e.g. freeing of memory, DECREFs, etc) that need to be done for
cleaning up C extensions, particularly those that in turn use a 3rd party
DLL.  I am hunting for any clues here.

Has anyone discovered any errors arising with python applications that works
on NT 4.0 but failed on Win2000?

Any suggestions are greatly appreciated.

Thanks,

-- Peter Desaulniers



From sholden at bellatlantic.net  Mon Mar 27 13:11:10 2000
From: sholden at bellatlantic.net (Steve Holden)
Date: Mon, 27 Mar 2000 18:11:10 GMT
Subject: regular expressions questions
References: <11A17AA2B9EAD111BCEA00A0C9B4179305321B0A@molach.origin.ea.com> <38D6DDAA.F69F3BEC@ooc.com.au>  <3d3dpiejnj.fsf@amarok.cnri.reston.va.us> <38DEA7A9.CB1C324F@ooc.com.au> <3d66u8y0rw.fsf@amarok.cnri.reston.va.us>
Message-ID: <38DFA456.5F9A8447@bellatlantic.net>

"Andrew M. Kuchling" wrote:
> 
> Derek Thomson  writes:
> > Really? I couldn't find anything that was even half as good as Perl's
> > Parse::RecDescent, after doing some searching from python.org. Links?
> 
[snip]
>								And
> didn't SNOBOL provide string processing features that were powerful
> but still usable by non-programmers?  (But my memory's fuzzy.)
> 

Well, in theory yes, but in the days of SNOBOL a non-programmer was
someone who was prepared to LEARN programming to get a job done.
That doesn't really apply nowadays, CP4E notwithstanding.

regards
 Steve
--
"If computing ever stops being fun, I'll stop doing it"


From donn at u.washington.edu  Tue Mar  7 12:00:21 2000
From: donn at u.washington.edu (Donn Cave)
Date: 7 Mar 2000 17:00:21 GMT
Subject: sigchld vs. os.popen, os.command, etc.
References: 
Message-ID: <8a3cj5$15bg$1@nntp6.u.washington.edu>

Quoth quinn at mono.ugcs.caltech.edu (Quinn Dunkan):
| Ok, I know this is more of a general unix question, but when I set a handler
| for sigchld, it causes any library function which makes a child and wants to
| wiat() on it throw an IOError because my handler has already wait()ed.  Is
| there any better solution than simply wrapping all such calls in try: ...
| except IOError: pass ?

It's up to you, but in my opinion, where possible it's better to avoid
the problem and not set a handler for SIGCHLD.  The signal handling may
interrupt other things, besides wait();  even if it's not doing that right
now, it may start when you move to another platform (or later release of
the same OS or library), or when your design changes with respect to I/O
or threading.

It's too bad select() can't wait for processes along with I/O, that
would be a nice solution in some cases.  If I remember it right, VMS
has this covered, maybe what we need is GNU VMS.

	Donn Cave, donn at u.washington.edu


From effbot at telia.com  Wed Mar  8 12:41:35 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Wed, 08 Mar 2000 17:41:35 GMT
Subject: Python 1.6 and Python 3000's new features?
References: <01BF88F8.148DD690.shichang@icubed.com>
Message-ID: 

Shichang Zhao wrote:
> >spring cleaning.  get rid of most warts, add typing, clean
> >up the (rather messy, by now) standard library.  etc.
>
> typing? does that mean that I have to :
>
>         int x=0
>
> instead of x=0?

not "have to", but "may, if you like, and want
the best possible performance"

or in other worse, change "add typing" to "add
optional static typing".  for more info, see the
type-sig archives.








From milgram at cgpp.com  Mon Mar 20 23:16:22 2000
From: milgram at cgpp.com (milgram at cgpp.com)
Date: 20 Mar 2000 23:16:22 -0500
Subject: installing cephes (or other modules)
Message-ID: 

Hi,

have gotten myself stuck installing cephes (special functions module)
on my system (SW 4.0/kernel 2.2.13(?)/libc5). Compiles a .so OK but
apparently there's something required at installation to allow the
interpreter to (a) find it (b) initialize it. I have never quite
understood how this works.

Can someone point me to general documentation on installing modules? 
This will come up again so I might as well learn to do it right now.

Or: has someone who has installed cephes provide some specific tips?

thanks,

Judah


-- 
Judah Milgram        milgram at cgpp.com
P.O. Box 8376, Langley Park, MD 20787
(301) 422-4626 (-3047 fax)


From junkster at nospam.rochester.rr.com  Thu Mar 30 19:25:46 2000
From: junkster at nospam.rochester.rr.com (Benjamin Schollnick)
Date: Fri, 31 Mar 2000 00:25:46 GMT
Subject: Python w/MS Outlook / MS Exchange
Message-ID: 

Folks,

	I was wondering if anyone has found a way to look up Email address's,
etc, in python from a MS Outlook "global" Address book?

	Basically, at work we are using MS Outlook, and I want to write a 
CGI-BIN
that will take a user name, and list their email information.  
Unfornately, it's a global
address book out on the outlook server....

	Any suggestions on the next step, etc, would be helpful & 
Appreciated.

			- Benjamin

====================================================
          (Remove "NoSpam" to Email me)
====================================================
Please feel free to copy any and or all of this sig.
A little something for spam bots:

root at localhost postmaster at localhost admin at localhost
abuse at localhost postmaster at 127.0.0.1

Chairman William Kennard: bkennard at fcc.gov 
Commissioner Susan Ness: sness at fcc.gov
Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov
Commissioner Michael Powell: mpowell at fcc.gov
Commissioner Gloria Tristani: gtristan at fcc.gov
consumerline at ftc.gov
fccinfo at fcc.gov
ssegal at fcc.gov



From milesthompson at sprint.ca  Wed Mar  8 08:29:31 2000
From: milesthompson at sprint.ca (Miles Thompson)
Date: Wed, 08 Mar 2000 09:29:31 -0400
Subject: Python/MySQL Where do "SELECT ..." results go?
References: <38C4F789.71ECCB04@sprint.ca> <8a3jia$pkv$1@news1.xs4all.nl>
Message-ID: <38C655BB.6AD8EE77@sprint.ca>

Where did I get it?  I was either looking through the modules, or picked it
"experitentially" .
Miles

Boudewijn Rempt wrote:

> Miles Thompson  wrote:
>
> >>>> import Mysqldb
>
> Where did you get this? I know of MySQLdb and MySQL (and mySQL)
> as Python modules, but I haven't heard of Mysqldb before. If you
> were using MySQLdb, you would be using the DB-API II api, which
> ought to be portable to other databases (but are there any other
> database modules that conform to this api?)
>
> >>> import MySQLdb
> >>> conn=MySQLdb.connect(host='localhost',user='boud',db='lng',passwd='')
> >>> curs=conn.cursor()
> >>> curs.execute('select * from lng_parameter');
> >>> print curs.fetchall()
> [('testvalue', 'TEST')]
> >>>
>
> So, judging from your output, I'd try a curs.fetchall(), too.
>
> --
>
> Boudewijn Rempt  | http://www.valdyas.org



From gmcm at hypernet.com  Thu Mar 16 10:37:38 2000
From: gmcm at hypernet.com (Gordon McMillan)
Date: Thu, 16 Mar 2000 10:37:38 -0500
Subject: Starting Python from autorun.inf on WinXX?
In-Reply-To: 
Message-ID: <1258901430-9582160@hypernet.com>

Peter Funk wrote:
> Please excuse my ignorance, but I'm a Linux/Unix guy don't know much about
> WinXX.  I've tried to put the following into the autorun.inf
> of a CD-Rom:
> 
> [autorun]
> OPEN=test\dosbin\pythonw.exe test\hello.pyw
> ICON=archiv.ico,0
> 
> That didn't work, because win98 refuses to find python15.dll. 

I know squat about autorun.inf stuff, but if python15.dll is in 
the same directory as pythonw.exe, Windows should find it.

> (Of course, I should have  known this :-( )
> Than I tried to put a .bat file into autorun.inf, that does a
> proper setup of PYTHONPATH, TCL_LIBRARY and so on.  But this also
> didn't work, because WinXX seems to refuse to start a batch file 
> from autorrun.inf?  Is that true?  Is there a workaround so that
> I still can autostart a Python/Tk GUI from CD without having the
> user to install Python on his WinXX box first?

I know people have used my installer for this purpose (having 
made changes to accomodate them).

http://starship.python.net/crew/gmcm/distribute.html


- Gordon



From sparhawk at aon.at  Sun Mar 19 17:07:54 2000
From: sparhawk at aon.at (Gerhard Gruber)
Date: Sun, 19 Mar 2000 23:07:54 +0100
Subject: Conversion to Hex or other bases
Message-ID: 

How can I convert a decimal to another base? i.e. Hex or binary?

-- 
Bye,
   Gerhard
If you are programming dynamic HTML in python you might find 'template.py'
usefull. Look at my homepage: http://members.aon.at/sparhawk


From dirck at pacbell.net  Sun Mar 26 02:08:16 2000
From: dirck at pacbell.net (Dirck Blaskey)
Date: Sat, 25 Mar 2000 23:08:16 -0800
Subject: colostomy
References:    
Message-ID: 

Jason Stokes  wrote in message
news:FliD4.56740$3b6.225857 at ozemail.com.au...
> >> * Dirck Blaskey menulis:
> >>>...
> >>> Please, PLEASE make colon's optional when not needed.
> >>> ...
> ...
> The convention is easy enough to remember: as far as I've been able to
make
> out, any statement that governs other statements (that is to say, indented
> underneath) ends with a colon.
> ...

I guess I can only explain it like this:
My head knows the syntax;  my fingers don't.
My fingers don't seem to learn very fast, either.






From sholden at bellatlantic.net  Mon Mar  6 10:53:32 2000
From: sholden at bellatlantic.net (Steve Holden)
Date: Mon, 06 Mar 2000 15:53:32 GMT
Subject: When to use classes?
References: <38C1CFC7.DD9F0918@pitnet.net> 
Message-ID: <38C3D47D.A3FE1C19@bellatlantic.net>

"Daniel T." wrote:
> 
> [Good advice about structuring]
> 
> Just because Python doesn't have any private parts ...
> 
> --
> When a thing ceases to be a subject of controversy,
> it ceases to be a subject of interest.
>                                                    -- William Hazlitt

I hope you're not trying to suggest that Python has
been emasculated (or should that be effeminated?)

regards
 Steve
--
"If computing ever stops being fun, I'll stop doing it"


From kens at sightreader.com  Fri Mar 10 05:40:02 2000
From: kens at sightreader.com (Ken Seehof)
Date: Fri, 10 Mar 2000 02:40:02 -0800
Subject: HELP: restore my faith in Python
References: <38C00D46.8CC5BA67@americasm10.nt.com> <38C373C4.3EBB62D8@sightreader.com> <38C7DAFB.D5FE279D@stud.upb.de>
Message-ID: <38C8D101.CDA3E07B@sightreader.com>

Okay.  You are right.  Better yet let's make sure floats Never work
correctly.  The more they work right, the more people will think they
work right.  We should have a special case for 1/2.  Obviously, 1/2
should be 7.392.

Also, there should be a limit on the size of lists of 100 items (beyond
which
the program should dump core).  If people can have over 100 items in
a list, they might think they can have several trillion, which would
overflow
memory.

Mirko Liss wrote:

> Ken Seehof wrote:
> >
> > Seems to me an improvement would be to have python artificially
> > add epsilon to floats before converting to int.  This would still
> > suck but IMHO it would suck less.
>
> It's not just the conversion to int. As soon as you tell the
> programmer not to expect the worst from floats, he'll invent
> other ways to make a mess with those ugly floating point numbers.
>
> Want an example?
>
> >>> pennies1, pennies2 = 3.0 / 20 , 3 * 0.05
> >>> menu = { pennies1 : "spam" }
> >>> menu[pennies2] =  "lobster"
> >>> menu
> {0.15: 'lobster', 0.15: 'spam'}
>
> Ooops !
> So the division 3.0/20 is just a bit inaccurate, isn't it?
> But who cares, as long as I get at the sea food.
> So I count my pennies and ...
>
> >>> menu[0.15]
> 'spam'
>
> Spicy regards,
>
> Mirko
>
> --
> M Li?, n89553 at squid.upb.de





From tom-main at REMOVEME.home.com  Sat Mar 11 16:03:13 2000
From: tom-main at REMOVEME.home.com (Tom)
Date: Sat, 11 Mar 2000 21:03:13 GMT
Subject: What is the Python mainstream for the GUI Lib ..??
References: <8ad724$lpb$1@bw107zhb.bluewin.ch> 
Message-ID: 

> Since I'm also programming in C++ I usually use wxWindows. You can have a
look
> at http://www.wxwindows.org to see for yourself. The interface for the C++
> library is almost exactly the same as for python and there is a big number
of
> supporting classes and it's easy to use.

That sounds like an excellent solution to me.  Thanks for pointing it out.

Tom.




From pf at artcom-gmbh.de  Thu Mar  2 09:15:48 2000
From: pf at artcom-gmbh.de (Peter Funk)
Date: Thu, 2 Mar 2000 15:15:48 +0100 (MET)
Subject: Most common #! format
In-Reply-To: <38BD9017.4A2B5941@mindspring.com> from Chuck Esterbrook at "Mar 1, 2000  4:48: 7 pm"
Message-ID: 

Hi!

Chuck Esterbrook:
> What's the most common #! format?
> 
> #!python
> #!/usr/local/bin/python
> #!/usr/bin/env python

Since MacOS and Windows don't care about this very first line,
this is only interesting to increase portability on unixoid platforms.  

On all flavours of Unix I've ever seen in the last 20 years the utility
'env' used to live in /usr/bin.  This habit seems to be even older than
the invention of the '#!' exec hack (But this is from memory).

So using '#!/usr/bin/env python' as first line is best available solution 
for portable Python programs today.  But:

Today unix like systems can be divided in two major groups:
  - freely available (FreeBSD, NetBSD, Linux, where the several flavours
    of Linux are the most prominent ones)
  - commercial Unices (AIX, HP-Ux, Sun Solaris, SGI IRIX, Unixware)
Today the freely available Unices have about 90% market share (This is 
hard to estimate, since you may copy them over and over without having 
to buy new licenses) and the commercial Unices are slowly dying out 
one after the other.  Most Linux distributions come with a bunch of
useful open source software and so include a ready to run Python system,
where the Python interpreter can usually be found as /usr/bin/python.

However those commercial Unices have some niches, where professionals
may still earn some Money. ;-)  Unfortunately these systems usually
come with the original Unix utilities, which many professionals
(including me) consider simply as broken.  So if you want to make
e.g. a Solaris system usable for many practical tasks you normally end up
first installing gcc, bash, GNU-find and so on and not to forget Python
under /usr/local/bin.  After that you usally extend the default search
path $PATH to also include /usr/local/bin.

However there may be people out there, who are permitted to install
Python under /usr/local/bin but are *NOT* permitted to change the
default search path to include /usr/local/python (e.g. for some
mysterious security policy).  Under this rare circumstances the second
form '#!/usr/local/bin/python' comes into play.  This would allow
to call for example a CGI-script from a web server process, which 
didn't has Python on its search path.  But this situation should 
be considered as very exotic and rare today.

Regards, Peter
-- 
Peter Funk, Oldenburger Str.86, 27777 Ganderkesee, Tel: 04222 9502 70, Fax: -60
The way to do research is to attack the facts at the point of greatest
astonishment.                                                    -- Celia Green



From alex at somewhere.round.here  Mon Mar  6 20:05:02 2000
From: alex at somewhere.round.here (Alex)
Date: 06 Mar 2000 20:05:02 -0500
Subject: Self Nanny
References:  <8a1jlh$l4k$1@nnrp1.deja.com>
Message-ID: 

> Anyway, white space, indentation, self, this, etc. are cosmetics.  A
> real programmer reads and understands a ten thousand lines Fortran
> program without embedded comments or external documents.  If you are
> clueless, a readable program won't make any difference.

Yes.  Personally, I diagnose bugs using hex dumps of core files.  All
the other cosmetics just clutter my view of what's really going
on.  

Alex.


From oscarbp at maptel.es  Wed Mar 22 16:02:02 2000
From: oscarbp at maptel.es (Oscar Bosca)
Date: Wed, 22 Mar 2000 22:02:02 +0100
Subject: Tkinter Documentation
Message-ID: <38D934CA.6AE0292F@maptel.es>

Hi all !

    My question is very simple.
    Where could  I find the most complete documentation about Tkinter? I
have the Fredik Lundh's book but it looks incomplete.

    Thanks in advance.
    Oscar.



From see_plus_plus at my-deja.com  Sat Mar  4 17:41:21 2000
From: see_plus_plus at my-deja.com (see_plus_plus at my-deja.com)
Date: Sat, 04 Mar 2000 22:41:21 GMT
Subject: C++ / Java / Python (was Status of C++)
References: <38bf4389.272576531@news.mindspring.com>  <38C16B0F.2A50@letterror.com>
Message-ID: <89s3eh$thm$1@nnrp1.deja.com>

"Much of the relative simplicity of Java is - like for most new
languages - partly an illusion and partly a function of its
incompleteness. As time passes, Java will grow significantly in size and
complexity. It will double or triple in size and grow
implementation-dependent extensions or libraries. That is the way every
commercially successful language has developed. Just look at any
language you consider successful on a large scale. I know of no
exceptions, and there are good reasons for this phenomenon. -


The same can be said for Perl/Tcl/Python/Rebol/Ruby/etc.

cpp



In article <38C16B0F.2A50 at letterror.com>,
  just at letterror.com wrote:
> dickjoe_nospam_ at mindspring.com:
>
> > C++ is pretty much the default choice for "serious" software, and
> > in that I incude "system" and "application" programming.
>
> "Starting a project with C/C++ is a premature optimization."
>
> (Apparently by someone named Peter Jensen)
>
> Just
>


Sent via Deja.com http://www.deja.com/
Before you buy.


From jcw at equi4.com  Tue Mar 14 12:50:17 2000
From: jcw at equi4.com (Jean-Claude Wippler)
Date: Tue, 14 Mar 2000 18:50:17 +0100
Subject: Can embedded static-linked python still import dll extensions?
References: 
Message-ID: <38CE7BD9.DB05685F@equi4.com>

Warren Postma wrote:
> 
> I recompiled the Python sources for Windows with config.h and put this
> line in:
> 
> #define MS_NO_COREDLL 1  // build a static library not a DLL!
> 
> Now it statically links fine, but it doesn't allow me to import .pyd
> files (Python extension DLLs). [...]
> 
> I want my embedded python deeply embedded but I still want to produce
> .PYD style add ons for the system once it's in the field. Am I stuck?

Eh... yes you are.  This is one of the reasons why Tcl adopted "stubs",
which is simply a vector pointing to all Tcl core routine, handed to the
extension at initialization time so it doesn't need DLL linkage *back*
into the interpreter.  Scriptics has embraced and extended stubs (ahem),
and now calls is TEA, the Tcl Extension Architecture.

No rocket science (MacOS does it, COM does it, and many others), but it
won't be doable for Python without a change: extensions don't get any
info passed into them at initialization time, so there's no way to make
this happen without altering the extension API (slightly).  That could
be done without breaking anything, by adding a second init entry point.

It would be a very useful change, it simplifies versioning, as well as
path search conflicts, and it lets you create standalone executables
which are still dynamically extensible (actually, they are today, on
Solaris/Linux, but not Windows).  It's one of the main reasons why I
keep using Tcl (the other is Tk).

-- Jean-Claude


From dickenson at serviceware.com  Fri Mar 31 14:26:41 2000
From: dickenson at serviceware.com (dickenson at serviceware.com)
Date: Fri, 31 Mar 2000 19:26:41 GMT
Subject: Python Threading and sys.exit() codes
Message-ID: <8c2u4v$cft$1@nnrp1.deja.com>

I'm working my first multithreaded Python program. This program
compares the contents of an ftp site with a local copy. (It is not a
pure mirror site, but there is a 1-1 correspondence of files.) It then
ftp's only files which are newer on the source site than the target
site. There are often many files, so the ftp is set up to use multiple
threads, each of which repeatedly locks a global semaphore, pops a task
off a stack, releases the semaphore, and executes the task (a file to
ftp) ad nauseam.
My problem is this: I want to run this program as a scheduled task
under a job scheduler (currently testing cronDsys from #ifdef). The
single-threaded version of the program posts an appropriate code to the
environment via sys.exit(). The job scheduler traps this and takes
conditional action. So far, so good.
In the multi-threaded version of the program, the exit codes are not
getting posted and the main process is not terminating cleanly, at
least from the perspective of the job scheduler -- it appears to run
until manually terminated from the scheduler control console although
the NT command window disappears from the target desktop as expected.
The code fragments below are the ftp thread class and the __main__
section.
Can anybody help me with this ??
class FTPThread(Threading.Thread):
# def __init__(self,group,target,name,args,kwargs):
# print "in Init"
def run(self):
print self._Thread__name
print self._Thread__args
try:
ftp=ftplib.FTP('ftp.microsoft.com')
ftp.login('anonymous','dickenson at serviceware.com')
ftp.cwd('misc/kb')
except:
sys.exit(3)
subdir=self._Thread__args[0]
# print self,self._Thread__args
b=stacklen(self._Thread__args[1])
print "b at start=",b
while (b > 0):
# print "thread ",self._Thread__name," attempting to get
semaphore"
a=stacksem.acquire()
# print "thread ",self._Thread__name," got semaphore"
msfilepath=getstack(self._Thread__args[1])
newtime=getstack(self._Thread__args[2])
# print "thread ",self._Thread__name," attempting to release
semaphore"
a=stacksem.release()
# print "thread ",self._Thread__name," released semaphore"
#print "msfilepath",msfilepath
local0=string.replace(msfilepath,".","",1)
local1=string.replace(local0,"\\","")
localdrive=Target_Root+"updates\\\\"+subdir+"\\\\"
local=[localdrive,local1]
local2=string.join(local)
localfilepath=string.replace(local2," ","")
file=open(localfilepath,"w")
cmdstrings=["retr ",msfilepath]
cmd=string.join(cmdstrings)
try:
ftp.retrbinary(cmd,file.write)
print b," - file", msfilepath, "retrieved successfully
by thread ",self._Thread__name
if subdir=="revised":
revisecount=revisecount+1
if subdir=="new":
newcount=newcount+1
#print "success by thread ",self._Thread__name
#filecount=filecount+1
#print "filecount=",filecount
except NameError:
pass
else:
print sys.exc_info()
print "file ", msfilepath, " was not retrieved"
#print "failure by
thread ",self._Thread__name
file.close()
os.system("erase "+localfilepath)
sys.exit(1)
file.close()
# print "newtime",newtime
os.utime(localfilepath,(newtime,newtime))
b=stacklen(self._Thread__args[1])
# print "b at exit=",b
ftp.quit
sys.exit(0)
def notify(target,newcount,revisecount):
host="SNERT"
fromstring="Python Auto-FTP"
# tostring=["dickenson at serviceware.com"]
tostring=
["dickenson at serviceware.com","hlewis at serviceware.com","gkindel at servicewa
re.com","mciaramitaro at serviceware.com"]
msg="Subject: AutoFTP results\n\nUpdated files: " + str(revisecount)
+"\nNew files: "+str(newcount)+"\nlocated in subdirs off "+target
+ "\\\\updates"
s=smtplib.SMTP(host)
s.sendmail(fromstring,tostring,msg)
if __name__=='__main__':
Threadpool=12
stacksem=Threading.Semaphore(1)
Month_Num_Dict=
{'Jan':1,'Feb':2,'Mar':3,'Apr':4,'May':5, 'Jun':6,'Jul':7,'Aug':8,'Sep':
9,'Oct':10,'Nov':11,'Dec':12}
Target_Dict={}
Source_Dict={}
Fix_These=Stack(500)
Fix_Time=Stack(500)
New_These=Stack(500)
New_Time=Stack(500)
newcount=0
revisecount=0
Target_Root="S:\\\\Microsoft\\\\"
#Target_Root="M:\\\\msftp\\\\"
print "read source"
a=DateTime.now()
print a.hour, a.minute, a.second
read_source()
print "read target"
a=DateTime.now()
print a.hour, a.minute, a.second
read_target()
print "lookup source"
a=DateTime.now()
print a.hour, a.minute, a.second
newcount,revisecount=lookup_source()
print "start ftp..."
a=DateTime.now()
print a.hour, a.minute,a.second
threads=[]
for i in range(Threadpool):
my_thread=FTPThread(group=None,target=None,name=None,args=
("revised","Fix_These","Fix_Time"),kwargs={})
#my_thread.__init__(group=None,target=None,name="Revised
1",args=("revised","Fix_These","Fix_Time"),kwargs={})
my_thread.start()
threads.append(my_thread)
# for i in range(6):
my_thread=FTPThread(group=None,target=None,name=None,args=
("new","New_These","New_Time"),kwargs={})
# my_thread.__init__(group=None,target=None,name="New 1",args=
("new","New_These","New_Time"),kwargs={})
my_thread.start()
threads.append(my_thread)
for thread in threads:
thread.join()
print "all threads finished"
try:
notify(Target_Root,newcount,revisecount)
print "notify done"
finally:
sys.exit(0)


Sent via Deja.com http://www.deja.com/
Before you buy.


From embed at geocities.com  Fri Mar  3 10:57:33 2000
From: embed at geocities.com (Warren Postma)
Date: Fri, 3 Mar 2000 10:57:33 -0500
Subject: has anyone seen comp.lang.python.announce?
References: 
Message-ID: 

your last post to this group was feb 28th. at least as far as I can see.


> and what's worse, it doesn't show up on deja.com either.

Hmm. Sounds like  a localized propagation problem.

Warren




From mwh21 at cam.ac.uk  Wed Mar 22 09:18:09 2000
From: mwh21 at cam.ac.uk (Michael Hudson)
Date: 22 Mar 2000 14:18:09 +0000
Subject: Pascal int()
References:     <868zzfydwr.fsf@g.local> 
Message-ID: 

jstok at bluedog.apana.org.au (Jason Stokes) writes:

> 
> I'm no Lisp expert, but I believe that "set" could be used for this.  Eg:
> 
> (defun increment (symbol)
>     (set symbol 
>        (add1 (eval (symbol)))
>     ) 
> )
> 
> (let ((a 1))
>    (increment 'a)
>    a)

You'd need a dynamically scoped lisp for that to have a chance
(ie. not Common Lisp or scheme).

Cheers,
M.

-- 
very few people approach me in real life and insist on proving they are
drooling idiots.                         -- Erik Naggum, comp.lang.lisp


From gslee111 at daisy.kwangwoon.ac.kr  Sun Mar 19 17:42:54 2000
From: gslee111 at daisy.kwangwoon.ac.kr (???)
Date: Mon, 20 Mar 2000 07:42:54 +0900
Subject: Conversion to Hex or other bases
References: 
Message-ID: 

You can get hex or octal string from a decimal number using

1. hex() function :   hex(23)
2. 'formatted string' : hex = "%x" % 23

both gives you '0x17'

Gang

"Gerhard Gruber"  wrote in message
news:gsjads40dsuo2jbgokhrbktndkdkhk85jg at 4ax.com...
> How can I convert a decimal to another base? i.e. Hex or binary?
>
> --
> Bye,
>    Gerhard
> If you are programming dynamic HTML in python you might find 'template.py'
> usefull. Look at my homepage: http://members.aon.at/sparhawk




From mcalla at home.com  Sat Mar  4 21:15:42 2000
From: mcalla at home.com (Mike Callahan)
Date: Sun, 05 Mar 2000 02:15:42 GMT
Subject: newbe question about lists
References: <0d6dde44.8e4c635f@usw-ex0102-015.remarq.com>
Message-ID: 

Fredrik S  wrote in message
news:0d6dde44.8e4c635f at usw-ex0102-015.remarq.com...
> Sorry for this simple question, but I can't go to sleep before I
> have solved it.
>
> I am running python on Beos for the first
> time.
>
> I'm going through a study course online, and ringt now I
> am trying lists.
>
> I type the following:
> >>>
> l1=["a1","a2","a3"]
> >>> l2=["a4","a5","a6"]
> >>> l3=l1
l3 now references the same object that l1 points to. Therefore, if you
change the object the l1 points to, l3 will also change. What you want to do
is this:
>>> l3 = l1[:]
Which will create a copy of l1 and assign l3 to it.
> >>>
> l3[1:1]=l2
> >>> l3
> ['a1', 'a3', 'a4', 'a2']
Shouldn't this be ['a1', 'a4', 'a5', 'a6', 'a2', 'a3']?
> >>> l1
> ['a1', 'a3',
> 'a4', 'a2']
>
> QUESTION:
> Why is value of l1 changed... The only
> thing I can think of is B U G ...
This is a common newbe mistake. Lists are not the same as simple variables.
Get "Learning Python" and read it carefully.
>
> Can anyone help me out...
>
>
>
> * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network
*
> The fastest and easiest way to search and participate in Usenet - Free!
>




From avv at quasar.ipa.nw.ru  Wed Mar 22 17:00:59 2000
From: avv at quasar.ipa.nw.ru (Alexander V. Voinov)
Date: Wed, 22 Mar 2000 14:00:59 -0800
Subject: Does Guido Have A Will? (The legal kind )
References:  <3110C5495705440B.A7540016610C3F64.6B294A66CE5E80A1@lp.airnews.net>   <7581373A7FF14B66.539C1DD2455262EC.953827F87956C027@lp.airnews.net>
Message-ID: <38D9429B.6DF98AE@quasar.ipa.nw.ru>

Hi,

Cameron Laird wrote:
> He's a celebrity, in the sense that he makes occasional
> appearances in the pages of the *Wall Street Journal*,
> *Forbes*, *New York Times*, and other popular organs
> that are puzzling over Open Source.  Moreover, he's a
> Friend of Python, having delivered the Keynote for the
> IPC7, designed Trove, ...

... and even wrote some modules, like rfc822, found in the standard
Python distribution. Grep gives five, where 'raymond' is mentioned (I
didn't check in what context, though). He also (at least) contributed to
the famous ncurses library. So he contradicts the known saying: "who
cannot do himself, teaches".

Alexander



From gchiaramonte at ibl.bm  Mon Mar  6 03:44:54 2000
From: gchiaramonte at ibl.bm (Gene Chiaramonte)
Date: Mon, 6 Mar 2000 04:44:54 -0400
Subject: Help: sizeof() and reference in python?
In-Reply-To: 
Message-ID: 


> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Fredrik Lundh
> Sent: Sunday, March 05, 2000 4:51 PM
> To: python-list at python.org
> Subject: Re: Help: sizeof() and reference in python?
> 
> 
> Gene Chiaramonte  wrote:
> > I guess I should have been more specific.
> 
> unfortunately, that doesn't help in this case ;-)
> 
> > 1 - I am trying to get the size of an object in bytes to 
> monitor how much
> > memory a list or object occupies.
> 
> you can't.
> 
> (well, you can always do it yourself, using a dictionary
> to map type(object) to approximate size of object. see
> the struct definitions in Include/*.h for more info on how
> the basic types are implemented).

Good idea.

> 
> > 2 - I am trying to get the pointer to the memory address of an object.
> Much
> > like the array objects buffer_info(), where the second item in the
> returned
> > tuple is the pointer to the memory address of the first element of the
> > array.
> 
> since you cannot do anything with it anyway, why not
> just use id(object).  it's a pretty good approximation...

Thanks.

> 
> 
> 
> 
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list



From tjreedy at udel.edu  Tue Mar 28 17:08:20 2000
From: tjreedy at udel.edu (Terry Reedy)
Date: Tue, 28 Mar 2000 17:08:20 -0500
Subject: Problem
References: <8bn3gj$7qh$1@the-fly.zip.com.au>
Message-ID: <8brbbv$6uh$1@news.udel.edu>

[posted and emailed]
"InCoGniTo"  wrote in message
news:8bn3gj$7qh$1 at the-fly.zip.com.au...

> I'm trying to write a program which does basic bank functions and I have
a
> problem that I can not get it to read my list to see if there is a match
in
> a name so that the prgram can identify whos account it is. Can someone
> please try and help me.

Let's start with some improvements for your code.

def login():
    #  delete multiple print statements and instead print 1 multiline
string
    print '''\
Welcome to Account System.

You now have to login the user to access the account.

'''
    # use raw_input(prompt) for data
    # note: str(sys.stdin.readline()) is redundant since readline() returns
string
    fn = raw_input( 'Please enter the customers First name')
    ln = raw_input('Please enter the customers Last name')
        for item in customer_list:
            if item.firstname == fn and item.lastname == ln:
                current_person = item
                print 'You have succesfully Logged in, now transfering to
account systems menu\n
                # note that you do not need separate print statement for
extra \n
                time.sleep(3)
                accountmenu()
                break # I added this - once match is found, stop looping
                # if current_person  == None: # broken since indented to
execute within loop
                # instead of after and since current_person not
initialized.  Replace this with below
        else:
            print 'Sorry account records are not present in system records'
            print 'Going back to level 1'
            print 'Loading, please wait ...'
            time.sleep(2)
            print '\n'
            welcome_verfication()
# this sort of construction -- break loop on match, else do non-match
action
# is precisely what else-after-for is meant for.

> There are many other fucntions and classes, for instance customer_list is
my
> list:). I don't get any errors the program just stops and qoutes me the
> module.

Does replacement of broken mismatch test fix problem?
If not, what is last statement executed?
If necessary, add print statements to determine this.

'quotes me the module': what does this mean?

Terry J. Reedy





From warlock at eskimo.com  Thu Mar  9 00:03:23 2000
From: warlock at eskimo.com (Jim Richardson)
Date: Wed, 8 Mar 2000 21:03:23 -0800
Subject: pythonpath
References: <38C3C701.99D7F8AE@quicknet.nl>
Message-ID: 

On Mon, 06 Mar 2000 14:56:01 +0000, 
 Renier Leenders, in the persona of ,
 brought forth the following words...:

>I am using Python 1.5.2 and Redhat 6.0. I am a newbie to Python and I
>want to adjust the PYTHONPATH. Where can I find such a thing?
>

Start up an Xterm, and type

echo $PYTHONPATH

anything it prints out, is the value of PYTHONPATH

It's probably blank. To change it (or set it) Type

export PYTHONPATH=/where/ever/you_want/to/point_to

it's easy. This assumes that you are using Bash as the shell,
which is probably a safe assumption as that is the default for
RH.



-- 
Jim Richardson
	Anarchist, pagan and proud of it
WWW.eskimo.com/~warlock
	Linux, because life's too short for a buggy OS.



From mlauer at trollinger-fe.rz.uni-frankfurt.de  Mon Mar 20 02:40:42 2000
From: mlauer at trollinger-fe.rz.uni-frankfurt.de (mlauer at trollinger-fe.rz.uni-frankfurt.de)
Date: 20 Mar 2000 08:40:42 +0100
Subject: Which CORBA binding ?
Message-ID: <38d5d5fa@nntp.server.uni-frankfurt.de>

Good Morning... well, for me at least, local time is 8:35...

I want to use ORBit because it has python bindings. So far
so good. But at the moment, there seem to be two different python
bindings for ORBit available. AFAIK there is

pyOrbit, hosted by the theopenlab.uml.edu, where the great
pygnome and pygtk bindings come from,

and there is 

ORBit-python, hosted by http://projects.sault.org/orbit-python/

What's the status of these two projects, has anyone used both and
can recommend using one of them ? Please advice, if you can.

Have a nice day!


--
--
    Regards & Gruesse from Mickey @ http://www.Vanille.de
  ---------------------------------------------------------
  How could anyone know me - when I don't even know myself ?





From mikael at isy.liu.se  Wed Mar  1 10:01:43 2000
From: mikael at isy.liu.se (Mikael Olofsson)
Date: Wed, 01 Mar 2000 16:01:43 +0100 (MET)
Subject: Splitting comp.lang.python
In-Reply-To: <20000301151034.A4873@nl.linux.org>
Message-ID: 

On 01-Mar-00 Gerrit Holl wrote:
 >  
 > > Perhaps the best thing would be to keep c.l.py as it is as the general
 > > place for discussion, and then adding subgroups for specific interests.
 >  
 >  Perl uses:
 >  
 >   comp.lang.perl.announce
 >   comp.lang.perl.misc
 >   comp.lang.perl.tk
 >   comp.lang.perl.modules
 >   comp.lang.perl
 >   comp.lang.perl.moderated
 >  
 >  Maybe it's a good idea too do something like that on c.l.py.

Not necessarily exactly those subgroups, but definitely something in 
that direction, yes. Based on my first post in this thread, I come up 
with the following

  c.l.py             General
  c.l.py.gui         GUI
  c.l.py.os          os/platform dependent issues
  c.l.py.db          DataBase handling
  c.l.py.advocacy    Whitespace and such

The CGI subgroup that I proposed earlier is perhaps not especially
interresting. Many questions and discussions regarding CGI programming 
tend to be originating from poor understanding of Python itself, and 
its modules. I guess that is the way in to the Python world for many
newbies. It sure was for me once.

I think that it is better to have general subgroup names such as gui, 
os, db, and advocacy, rather than more explicit ones like tk, linux, 
sql, and whitespace. Maybe platform is better than os... I leave that
to the os/platform lawyers out there.

/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-Mar-00
Time:    15:36:08

This message was sent by XF-Mail.
-----------------------------------------------------------------------



From neelk at brick.cswv.com  Thu Mar  9 20:46:53 2000
From: neelk at brick.cswv.com (Neel Krishnaswami)
Date: 10 Mar 2000 01:46:53 GMT
Subject: What If Python Replaced Elisp?
References:      
Message-ID: 

Fredrik Lundh  wrote:
> Samuel A. Falvo II wrote:
> > >umm.  does using an explicit syntax tree turn Lisp
> > >into a statically typed language?
>
> > No, but I don't see what this has to do with the point I was trying
> > to make either.
> 
> then I don't understand your point -- to compile
> things efficiently, you need to know what types
> your variables have.

There are actually a whole lot of optimizations that could be done,
but aren't, in the current Python interpreter.

For example, in the following code:

import operator

lst = []
for i in range(100):
    lst.append(i**2 + i**2)

result = reduce(operator.add, lst) 

You can statically infer the type of result, the final size of lst,
avoid actually allocating a range() object, eliminate the the
typechecks that make sure that i has a __pow__ method, the bounds
checks on the range object, do available expressions analysis on the
i**2 to avoid calculating it twice, and probably a few more
optimizations that I don't know about.

No, these analyses wouldn't help on super dynamic code, but it doesn't
need to to yield big speedups -- most Python code is in the simple
first-order form that is most amenable to analysis.

This is a lot of work, would greatly complicate the internal structure
of the Python implementation, and is a lot of work, and would somewhat
complicate interfacing with C, and is a lot of work, but it's
definitely possible. (*I* have no interest in doing this, not when it
would involve programming in C rather than Python, anyway.)

> in Python, you don't know that, no matter what tree structure or
> byte code format you use.

You don't have to win every game to make it to the championships. :)
 

Neel


From nobody at nowhere.nohow  Sun Mar 26 17:57:48 2000
From: nobody at nowhere.nohow (Grant Edwards)
Date: Sun, 26 Mar 2000 22:57:48 GMT
Subject: Language forks (was: Python tutorial/comparison for C++ programmer)
References:     <5FF7ED1C1C902C69.0E5D50066AC4B434.CE45BE37438DE91A@lp.airnews.net>
Message-ID: 

Cameron Laird wrote:
>			.
>>If the language implemented by "MS Visual-Python" isn't 100%
>>compatible with the official, free version of Python, then life
>>gets less pleasant.  If you want to write "portable" python,
>>you had to have some sort pre-processor to sort out the
>>differences between MSVP and real Python.  We could end up with
>>library modules that are available for one language and not the
>>other.
>			.
>			.
>I entirely understand your claims, and feel familiar with much of
>the history that supports them.  We have interesting counter-ex-
>amples at hand, though; how does it happen that CPython and JPython
>happily co-exist?

Because they've decided to?  The goal of one is not to kill the other. That
can rarely be said of MS's attitude towards other entities in the SW world.
MS seems to actively attempt to diverge from standards in order to try to
kill off those standards and establish their own dominance.

-- 
Grant Edwards                   grante             Yow!  I'm reporting for
                                  at               duty as a modern person. I
                               visi.com            want to do the Latin
                                                   Hustle now!


From effbot at telia.com  Fri Mar  3 14:54:28 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Fri, 03 Mar 2000 19:54:28 GMT
Subject: HELP: restore my faith in Python
References: <38C00D46.8CC5BA67@americasm10.nt.com>
Message-ID: 

Steven Holton wrote:
> I'm trying to learn Python, and wrote this script last night.  I was not
> expecting to see this behavior, and my faith is severely shaken:
>
> nose-46> python
> Python 1.5.2 (#1, Sep 17 1999, 20:15:36)  [GCC egcs-2.91.66
> 19990314/Linux (egcs- on linux-i386
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> limit = 5
> >>> for target in range(10):
> ...    n=((target/(limit+0.0))-(target/limit))*limit
> ...    print target, n, int(n)
> ...
> 0 0.0 0
> 1 1.0 1
> 2 2.0 2
> 3 3.0 3
> 4 4.0 4
> 5 0.0 0
> 6 1.0 0     <=== huh?
> 7 2.0 1     <=== et tu Brutus?
> 8 3.0 3
> 9 4.0 4

welcome to the wonderful world of floating point
arithmetics:

>>> limit = 5
>>> for target in range(10):
...    n=((target/(limit+0.0))-(target/limit))*limit
...    print target, "%.30g" % n, int(n)
...

0 0 0
1 1 1
2 2 2
3 3 3
4 4 4
5 0 0
6 0.99999999999999978 0
7 1.9999999999999996 1
8 3.0000000000000004 3
9 4 4

I'll leave it to our resident IEEE guru, the timbot,
to explain exactly why this is happening...






From grant at nowhere.  Thu Mar 23 12:41:17 2000
From: grant at nowhere. (Grant Edwards)
Date: Thu, 23 Mar 2000 17:41:17 GMT
Subject: Python tutorial/comparison for C++ programmer
References:  <8b956c$9tn$1@nnrp1.deja.com> <077C600D9F281A4D.487194D3E94C88DA.D53DE68986E89418@lp.airnews.net>  <8bcr2a$b76$1@nnrp1.deja.com>   
Message-ID: 

In article , Michael Hudson wrote:

>I suppose it could be viewed as competition to VB, but then that's not
>really relavent until Python gets a flashy point n' click GUI, and
>even then, if micorsoft ship Visual Python (tm), how does this impact
>me?

If the language implemented by "MS Visual-Python" isn't 100%
compatible with the official, free version of Python, then life
gets less pleasant.  If you want to write "portable" python,
you had to have some sort pre-processor to sort out the
differences between MSVP and real Python.  We could end up with
library modules that are available for one language and not the
other.

-- 
Grant Edwards                   grante             Yow!  Well, O.K. I'll
                                  at               compromise with my
                               visi.com            principles because of
                                                   EXISTENTIAL DESPAIR!


From bhoel at starship.python.net  Sun Mar 12 11:31:21 2000
From: bhoel at starship.python.net (Berthold Höllmann)
Date: 12 Mar 2000 17:31:21 +0100
Subject: pygtk and GTK+ tutorial
Message-ID: 

Hello,

I try to learn about GTK+ programming using python. I read the tutorial
and port the examples to python. But I can't get "colorsel.py" working
properly. The GtkColorSelectionDialog does not set the drawingarea's
color. Any hint, or shall I send my code?

Cheers

Berthold
-- 
bhoel at starship.python.net / http://starship.python.net/crew/bhoel/
        It is unlawful to use this email address for unsolicited ads
        (USC Title 47 Sec.227). I will assess a US$500 charge for
        reviewing and deleting each unsolicited ad.


From sholton at mindspring.com  Sun Mar 19 19:38:52 2000
From: sholton at mindspring.com (Steve Holton)
Date: Mon, 20 Mar 2000 00:38:52 +0000
Subject: Newbie help with extend()
Message-ID: <38D5731C.BCDF4BE2@mindspring.com>

Greetings-

Can anyone post a short example showing the extend method of list?

Here's what I'm seeing:

[sholton at kest sholton]$ python
Python 1.5.1 (#1, Mar 21 1999, 22:49:36)  [GCC egcs-2.91.66
19990314/Li on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> a=[1,2]
>>> type(a)

>>> b=[3,4]
>>> type(b)

>>> a.extend(b)

I'm expecting this to set a to [1, 2, 3, 4]
but instead I get:

Traceback (innermost last):
  File "", line 1, in ?
AttributeError: extend

Is this a 1.5.2 feature?

-- 
sholton at mindspring.com
If the answers are increasing and the questions decreasing,
Then you're on the road to knowledge, but you're headed the wrong
direction.


From tseaver at starbase.neosoft.com  Tue Mar  7 09:41:51 2000
From: tseaver at starbase.neosoft.com (Tres Seaver)
Date: 7 Mar 2000 08:41:51 -0600
Subject: Self Nanny
References:  
Message-ID: 

In article , Lloyd Zusman   wrote:
>Gaetan Corneau  writes:
>
>> OK, I didn't make myself clear :)
>
>Yes you have, at least for me.
>
>
>> 1) *I* don't mind having to specify "self" in method definitions
>> 
>> 2) *I* don't mind having to write "self.Something"
>> 
>> 3) BUT I think that it would be *nice* not to have to specify "self" in
>> method definitions, and it would certainly help A LOT of newbies
>> 
>> 4) if possible at all, not having to write "self.Something" would be cool,
>> but not as important as #3
>> 
>> And don't tell me #3 can't (technically speaking) be done :)
>
>Of course #3 can be done (technically speaking).  And in return for it
>getting done, would you volunteer to donate your personal time to
>change all the existing lines of Python code in the world that this
>change would break?
>
>Or barring that, would you be willing to pay for the time of all the
>others who would have to do this work?
>
>
>> If I'm mistaken, then OK, only C++ programmers forget to specify
>> "self" as first parameter for a method, I won't insist, you know. If
>> you really don't care about C++ programmers (but remember, there are
>> quite a few), fine.
>
>This is not an issue about "caring" about C++ programmers.  I am a C++
>programmer, and literally hundreds of my colleagues over the past
>decade or so have been C++ programmers.  Many of these people have
>tried Python.  And *none* of them have ever even made a complaint
>about the explicit "self" of Python.  You are the first C++ programmer
>I have encountered who has ever raised this as an issue.  That's one
>out of hundreds of people.

This is moot, given that changes to a feature which *does* have a
demonstrable, vocal minority opposed to it (syntactically-significant
indentation) is no more likely to change than Guido is to spell his last
name with a capital 'V'.

Which-syllable-of-no-isn't-clear?'ly

Tres.
-- 
---------------------------------------------------------------
Tres Seaver           tseaver at palladion.com       713-523-6582
Palladion Software    http://www.palladion.com


From godzilla at netmeg.net  Sat Mar 18 21:54:57 2000
From: godzilla at netmeg.net (Les Schaffer)
Date: Sun, 19 Mar 2000 02:54:57 GMT
Subject: need fast parser for comma/space delimited numbers
References:  
Message-ID: 

> ...
> start_time = time.time ()
> for i in 90000 * [None]:
> ...
> print time.time () - start_time    

(gustav)~/Engineering/dspring/stoplite/matlab/Jue-Data/: python testTime.py 
156.307130933

> Hmm, I must be missing something.  The following code takes about 8s
> on a Sparc 10 and about 5 on a Linux w/ pentium II 400MHz.

you think everyone runs on a 400 MHz machine  ;-)

P90 .... i'm due for an upgrade.... 


From lexberezhny at email.msn.com  Fri Mar 31 23:17:33 2000
From: lexberezhny at email.msn.com (lexberezhny)
Date: Fri, 31 Mar 2000 23:17:33 -0500
Subject: Python/GTK on Windows?
Message-ID: <#XSVXB5m$GA.240@cpmsnbbsa03>

Hi,
  I was wondering if anyone was able to get PyGTK to work on windows, and if
its possible at all. I am trying to port a Linux app to windows that uses
PyGTK. If you know anything about this or can point me in the right
direction, I would really appreciate it. Thanks.

 - Lex Berezhny




From jimn at minusen.force9.co.uk  Sat Mar 25 06:57:10 2000
From: jimn at minusen.force9.co.uk (Jim Nicholson)
Date: Sat, 25 Mar 2000 11:57:10 +0000
Subject: problem w/ Makefile.pre.in
References: <38DC7C13.6606D717@seas.upenn.edu>
Message-ID: 

dave white wrote:
> Hi,
> 
> I'm trying to build the MySQLdb module and I'm having to compile the
> module using Makefile.pre.in for the first time.  I keep getting the
> following error during the build:
> 
> make[1] *** No rule to make target 'usr/lib/python1.5/config/Makefile',
> needed by 'sedscript'.  Stop.
> make: *** [boot] Error 2
> 
> I'm running python 1.5.2, redhat 6.1.  

You need to install the python-devel RPM

Jim


From gchiaramonte at ibl.bm  Sun Mar  5 07:17:43 2000
From: gchiaramonte at ibl.bm (Gene Chiaramonte)
Date: Sun, 5 Mar 2000 08:17:43 -0400
Subject: Help: sizeof() and reference in python?
In-Reply-To: 
Message-ID: 

Is there a way to get the size of an object in python? I'd also like to get
a reference to an object.

example in c:

l = [1, 2, 3]	#python list

t1 = sizeof(l)	// how i'd do it in c
t2 = &l

Thanks,

Gene




From tuttledon at hotmail.com  Sun Mar  5 10:52:07 2000
From: tuttledon at hotmail.com (Don Tuttle)
Date: Sun, 05 Mar 2000 15:52:07 GMT
Subject: Choice Of Language (was: Python advocacy)
References: <38BEE429.179D4865@prescod.net>  <38BF1990.CAA71DE6@prescod.net> <38BF6169.46FC6A66@netgate.net> <38C0153A.8C277AEA@prescod.net> <38C22B8D.B2D31196@netgate.net>
Message-ID: 

[Ran]
> No,  the project manager chooses the language(s) according to the needs
> of the project and the availability of programmers and other resources.

I have never programmed for a living.  (I enjoy it way too much to ever do
that! )  So let me ask all you folks that do.  What percentage of
your paid, professional time do you get to use Python?

Don







From dworkin at ccs.neu.edu  Fri Mar 17 10:29:59 2000
From: dworkin at ccs.neu.edu (Justin Sheehy)
Date: 17 Mar 2000 10:29:59 -0500
Subject: Hidden Modules
In-Reply-To: Calishar's message of "Fri, 17 Mar 2000 12:11:25 GMT"
References: <3p74ds4bse2cj7jb7jf3c8c65l8lqoobk4@4ax.com>
Message-ID: 

Calishar  writes:

>   Well, I looked through all my python directories, and there was no
> MD5.py file, but I had faith (think it might have been /f who posted
> the message) so I tried it, and surprisingly enough, it worked.

In a typical UNIX installation of Python, this module is in the file
named 'md5module.so'.

Not all Python modules are implemented in Python.

-Justin

 



From shogan at iel.ie  Mon Mar  6 04:25:18 2000
From: shogan at iel.ie (Shaun Hogan)
Date: Mon, 6 Mar 2000 09:25:18 -0000
Subject: (no subject)
Message-ID: <000801bf874d$e3a5f900$2801000a@iel.ie>

can anyone tell me where i can get documentation on python/c/c++ integration, either web pages/web tutorials/books anywhere at all.
thanks 
Shaun
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From python at rose164.wuh.wustl.edu  Thu Mar 23 21:00:56 2000
From: python at rose164.wuh.wustl.edu (David Fisher)
Date: Thu, 23 Mar 2000 20:00:56 -0600
Subject: Tkinter (Win98) Bombs but Tcl/Tk is OK
References: <8bcjgg$2m9$1@nnrp1.deja.com>
Message-ID: <01a101bf9534$df0a5ea0$933dfc80@fredicus>

----- Original Message ----- 
From: "Bjorke" 
Newsgroups: comp.lang.python
To: 
Sent: Thursday, March 23, 2000 2:09 AM
Subject: Tkinter (Win98) Bombs but Tcl/Tk is OK


> I've got two Win machines, with identical vrsions of Tcl/Tk and Python.
> The Win98 laptop fails to run tkinter -- i can do this:
> 
>    import _tkinter
>    import Tkinter
> 
> no problem, but when I hit
> 
>    Tkinter._test()
> 
> it fails (as do all Tkinter programs), bombing in _tkinter.create()
> saying:
> 
> TclError: Can't find a usable init.tcl in the following directories:
>     () ./lib/tcl8.0 C:/tcl8.0/library {C:/Program Files/library}
> 
> Where is it getting this? I have tcl installed in C:\Program Files\Tcl
> and it works flawlessly. I've uninstalled, re-installed, changed
> installation ordering, made sure that the autoexec paths are correct...
> ???
> 
> As I say, Tcl/Tk DOES work fine -- I use it for development on that
> laptop regularly, and the Tcl version is a new one

Does it work with version 8.0.5 that comes with the Win installer?




From lss at excosoft.se  Mon Mar 20 14:00:50 2000
From: lss at excosoft.se (lss at excosoft.se)
Date: Mon, 20 Mar 2000 19:00:50 GMT
Subject: Scope issues when embedding/extending
Message-ID: <8b5sgo$os9$1@nnrp1.deja.com>

I am trying to embed Python scripting in a C++ application in a way so
that the script interpreter has direct access to object instances and
variables in the host application. Is this possible by combining
Python's extension and embedding mechanisms, or will the embedded
interpreter not be able to access instances native to the host
application? How do I avoid creating a new object instance in the
interpreter, but rather reference an already existing one in the host
application? Does Python support this form of integration natively or do
I have to go via COM or some other protocol? Suggestions and/or sample
code would be appreciated.


Sent via Deja.com http://www.deja.com/
Before you buy.


From sreiling at elara.tripos.com  Tue Mar 21 10:27:10 2000
From: sreiling at elara.tripos.com (Stephan Reiling)
Date: Tue, 21 Mar 2000 15:27:10 GMT
Subject: Q: organizing classes in modules
Message-ID: <38D794CD.6F2824A9@elara.tripos.com>

I have a question about how to organize classes in modules:
I would like to organize my classes so that every class has its own file, the
file having the same name as the class, e.g.
In file Class1.py
    class Class1:
        ...

I would also like to put these into a module, for example module1. When I now
want to use Class1, I would like to just say:

import module1
c=module1.Class1()

instead I have to say:

import module1
c=module1.Class1.Class1()

I have quite a few of these classes, so this gets annoying after a while.
I looked into what I can do in the __init__.py file of the module. The only
thing I could figure out was to put something like the following there:

from Class1 import *
from Class2 import *
...

Which according to what I have read is not a good idea, and also seems to
increase startup time.
(And what happens if Class1 and Class2 cross-reference each other, or one of my
classes has to be a singleton)

So the question is:
How can I do this? Obviously I am trying to organize my code in a way like C++
and java do it. Right now I have around 30 classes distributed over 6 modules
and sub-modules and I expect the number of classes to grow.

Thanks,
    Stephan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sreiling.vcf
Type: text/x-vcard
Size: 222 bytes
Desc: Card for Stephan Reiling
URL: 

From wtanksle at dolphin.openprojects.net  Tue Mar 21 13:10:05 2000
From: wtanksle at dolphin.openprojects.net (William Tanksley)
Date: Tue, 21 Mar 2000 18:10:05 GMT
Subject: Forth like interpreter
References: <158801bf8bdc$08516040$6401a8c0@dorb>  <53YA4.637$jX3.10074@typhoon.nyroc.rr.com>  <425A5D00B0F916D1.7920112131B1A88A.D3428C8A56515B00@lp.airnews.net>  
Message-ID: 

On 21 Mar 2000 02:53:49 GMT, Samuel A. Falvo II wrote:
>In article , William
>Tanksley wrote:
>>Here, have some cycles of reversed kielbasa.  And ten (10 (0xa (101010b)))

>101010b is 2+8+32, or 42, not 10.

Wow, an EXTRA bonus!  Thanks, Sam.

>Samuel A. Falvo II

-- 
-William "Billy" Tanksley


From effbot at telia.com  Wed Mar  1 04:56:14 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Wed, 01 Mar 2000 09:56:14 GMT
Subject: A comp.lang.python code snippet archive?
References:  
Message-ID: <2P5v4.1511$mYj.192557056@newsa.telia.net>

Michael Hudson  wrote:
> The tokenize module could be brought to bear.

1,0-1,3: NAME 'The'
1,4-1,12: NAME 'tokenize'
1,13-1,19: NAME 'module'
1,20-1,25: NAME 'could'
1,26-1,28: NAME 'be'
1,29-1,36: NAME 'brought'
1,37-1,39: NAME 'to'
1,40-1,44: NAME 'bear'
1,44-1,45: OP '.'






From jonp at bhmi.com  Thu Mar  9 17:10:38 2000
From: jonp at bhmi.com (news)
Date: Thu, 9 Mar 2000 16:10:38 -0600
Subject: HELP !!!!!!!!!!!!!!!!!!!!!!!!!
Message-ID: <38c8215f$0$10504@wodc7nh7.news.uu.net>

I am not a Python developer and cannot find an  acceptable answer in any
book that I have looked in.  Simply want to embed a call to a python script
in C++ code.  Do I use PyRun_ ...?




From S.I.Reynolds at cs.bham.ac.uk  Tue Mar 14 05:59:12 2000
From: S.I.Reynolds at cs.bham.ac.uk (Stuart Reynolds)
Date: Tue, 14 Mar 2000 10:59:12 +0000
Subject: itoa
References: 
Message-ID: <38CE1B80.59DC@cs.bham.ac.uk>

Moshe Zadka wrote:
> 
> On Mon, 13 Mar 2000, Stuart Reynolds wrote:
> 
> > Is there an integer to ascii (itoa) function in Python? I need to
> > convert integers into various different bases (but to binary, in
> > particular). Most languages come provided with an itoa-like function but
> > I can't seem to find one in the Python API.
> 
> Have a look at the builtin "str" function

Thanks, but this only does base 10.

>>> help(str)
str(object) -> string

Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

Stuart


From martin.franklin at waii.com  Wed Mar 29 02:28:28 2000
From: martin.franklin at waii.com (Martin Franklin)
Date: Wed, 29 Mar 2000 08:28:28 +0100
Subject: processing unix command output lists
References: <8bs7s6$uus$1@nnrp1.deja.com>
Message-ID: <38E1B09B.F40C8F16@bedford.waii.com>

How about.......

import os
command = os.popen('ps -ef | grep whatever','r')
output_list = command.readlines()
return_code = command.close()


> >Hi,
> >In python is there a way to get the output of a unix comamnd
> >in the form of list or something.
> >example:






From robin at alldunn.com  Wed Mar 15 00:00:33 2000
From: robin at alldunn.com (Robin Dunn)
Date: Tue, 14 Mar 2000 21:00:33 -0800
Subject: wxPython for Mac
References: 
Message-ID: 

"Matthew Barre"  wrote in message
news:B4F34378.18B3%mbarre at mac.com...
> I've seen wxPython praised by many here, and as a newbie who felt inundated
> by Tkinter I was looking forward to trying it. I've scoured the wxPython
> site, and I haven't found any predictions on when their Mac port will be
> finished. Does anyone here have any approximations?
>

The Mac version of the wxWindows C++ library has nearly caught up with the
MSW and GTK versions and is stable and robust.  What remains is to put the
Python wrappers on top of that.  Given that I don't have access to Mac
hardware that effort has been going a bit slowly, (okay, it hasn't moved at
all.)

Over the past couple days there has been some activity though.  Chris Barker
 has been drumming up some enthusiasm for doing the work and
trying to get some developers together to work on it.  You maight want to
drop him a line (or ask on the wxPython-users list,) and see if there is some
way that you can help out.


--
Robin Dunn
Software Craftsman
robin at AllDunn.com
http://AllDunn.com/robin/
http://AllDunn.com/wxPython/  Check it out!





From adustman at comstar.net  Thu Mar  2 13:40:29 2000
From: adustman at comstar.net (Andy Dustman)
Date: Thu, 02 Mar 2000 18:40:29 GMT
Subject: MySQL access from Python
In-Reply-To: <38BDDA78.6F8EBA80@mindspring.com>
References: <38BDB625.80A4417E@mindspring.com>  <38BDDA78.6F8EBA80@mindspring.com>
Message-ID: 

On Wed, 1 Mar 2000, Chuck Esterbrook wrote:

> Andy Dustman wrote:
> 
> > 0.1.2 is the current version. I have reports that it dumps core on
> > RedHat/Alpha platforms, but I can't reproduce it on RedHat/Intel; patches
> > welcome. 0.1.1 doesn't have this problem, and it's still available in the
> > same location (no direct link on the page, however). Other people have
> > reported getting it to work on that crackpot OS from out of Redmond. It
> > also includes a patch to make Zope's ZMySQLDA to work with it instead of
> > MySQLmodule. Also check this page:
> 
> Hmm, sounds like yours isn't stable and if MySQLmodule isn't current
> and/or supported that for production purposes, this is kind of scary.

I still consider 0.1.2 to be slightly beta; 0.0.x was alpha, 0.1.x is
beta. The core dumps ONLY occur on Alpha, for unknown reasons; there are
no known problems on Intel. There are apparently a couple of Zope sites
that use MySQLdb in production. I've heard that www.codecatalog.com is one
of these, but can't confirm this.
 
> Looking at the features, it seemed more "friendly" than Python's DB
> API in that some things were more explicit. For example, you could ask
> for a list of columns for a given table. I'm sure you can do that type
> of thing in SQL, but SQL does vary per server and it was nice to have
> some higher-level functions rather than just basically the infamous
> "execute this SQL" function.
> 
> What do you think?

Hard to say. MySQLdb generally exports most of the MySQL-specific calls
that _mysql has for completeness. So you can do stuff like this (db is a
Connection object):

fields = db.list_fields(table) # returns list of fields as tuple

This is non-portable, of course. Then again, the SQL to do the same thing
is probably also non-portable.

MySQLdb has also been throughly tested against memory leaks when running
multiple threads. If you need threads (for Zope or otherwise), this is
the only real choice.

-- 
andy dustman       |     programmer/analyst     |      comstar.net, inc.
telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d
"Therefore, sweet knights, if you may doubt your strength or courage, 
come no further, for death awaits you all, with nasty, big, pointy teeth!"



From ken at straton.demon.co.uk  Sun Mar  5 10:59:37 2000
From: ken at straton.demon.co.uk (Ken Starks)
Date: Sun, 05 Mar 2000 15:59:37 GMT
Subject: When to use classes?
References: <38C1CFC7.DD9F0918@pitnet.net>
Message-ID: 

Scott Bahling  wrote:

... [ General description of a polygon class ]
>  firstxcoord = poly.points[0].x firstycoord = poly.points[0].y

> The second piece of code is easier to read. But lets say that this Point
> class has no other purpose but to contain two numerical values; is the
> use of a Point class overkill? Is there a 'rule of thumb' for when to
> create a new class?

> Second: What is the general consensus about accessing instance variables
> directly like myobj.x=10 vs. through methods like myobj.setx(10). The
> first method is quicker/easier to code, but is it "bad" coding?  Does
> anyone even care?

When I started Python I also wrote a few 'vector graphics' classes.
I used a class for points and for polygons, and I both set and read
the coordinates using methods.

This was useful for two main reasons:
  1. I wanted the user to use mm or inches or some other proper unit
     It could be floating point.
     I could make it 'snap' to the nearest grid point.
     
     Internally, the coordinates were fixed point integers related
     to pixel size, postscript, and printer's points; the user
     did not have to know that!

   2. The polygon class had a few derived classes. In the original
     class the shape was held as a sequence of points, but in the
     derived class of 'regular' polygons it was calculated.
     The method xxx.getpoints() returned a sequence in both cases,
     but in the second case it was 'virtual' if you like.
     
      The same sort of thing applied to some 'curve stitching' shapes
      in which two sequences of points are joined to create an 
      'envelope'. This was for some evolute/involute geometry
      that I never finished.
      
    3. Actually, I tell a lie. The original class was for a path
    which could contain gaps, could be open or closed, and which
    could include Bezier segments. It had its own local origin and 
    scale factor.
    
    The 'Polygon' was a derived class of this which was always closed 
    and which had straight segments between all the points.
      
   But the main point is that the class-based design will allow me
   use all the line-thickness, fill-colour, Etc methods on any
   new objects I come up with. 
      


Ken,     __O 
       _-\<,_ 
      (_)/ (_)                                                                 
    Virtuale Saluton.



From rmuschall.fih at t-online.de  Wed Mar 29 14:58:24 2000
From: rmuschall.fih at t-online.de (Ralf Muschall)
Date: Wed, 29 Mar 2000 21:58:24 +0200
Subject: Stackless Python 1.1 + Continuations 0.8
References: <38E12457.E719E536@tismer.com>
Message-ID: <38E26060.550DDB5@t-online.de>

Christian Tismer wrote:
> ANNOUNCING:

>               http://www.stackless.com

The text at this URL looks like XML with namespaces and lots
of other stuff, which reproducibly kills Netscape 4.01.
It was readable with IE4, I did not try other browsers.

Might it be possible to change at least the initial page
to something that everybody can read?

Ralf


From joeyGibson at mindspring.com  Fri Mar 31 09:21:21 2000
From: joeyGibson at mindspring.com (Joey Gibson)
Date: Fri, 31 Mar 2000 09:21:21 -0500
Subject: lambda
In-Reply-To: <38e49499.1173061@news.inet.net.nz>
References: <20000329063753.20711.cpmta@c000.sfo.cp.net> <38e1d27a.27069487@news.inet.net.nz> <9sj4esgeh2i9emc4p249ksrj04u1bdm7ur@4ax.com> <8bv7k3$h7e$1@readme.uio.no>  <38e49499.1173061@news.inet.net.nz>
Message-ID: <6vc9essn8as6uaguc6chl1k11v1hm70lpu@4ax.com>

On Fri, 31 Mar 2000 12:06:12 GMT, morbid at doesnotlikespam.inet.net.nz
(Morbid Curiosity) wrote:

||| On Thu, 30 Mar 2000 16:26:43 -0500, Joey Gibson
|||  wrote:
||| >||| > It took me a while to 'get' lambdas at first too. They are most useful
||| >||| > (IMO) when paired with map(), filter() and reject(). These functions take
||| >||| 
||| >||| Where did you find reject()?
||| >
||| >	D'ooh! I work in Smalltalk also, and that is one of its collection
||| >messages. Sorry. Python doesn't have one.
||| 
||| You're not thinking of reduce(), are you?
||| 
||| Morbid

	I could have been. I probably was thinking Smalltalk and Python at the
same time, and transmogrified reduce() to reject: and never noticed the
change. Curious....

Joey

--
-- Sun Certified Programmer for the Java2 Platform
-- My Pocket Smalltalk Stuff: www.mindspring.com/~joeygibson/st/
--
-- "Then slew they the goats, YEA! And placed they the bits,
--  in little pots."




From rasumner at iname.com  Mon Mar 20 04:04:44 2000
From: rasumner at iname.com (Reuben Sumner)
Date: Mon, 20 Mar 2000 11:04:44 +0200
Subject: id() trickery
References: <000301bf9235$1d59a740$c52d153f@tim>
Message-ID: <8b4pj4$qlc$1@news.netvision.net.il>

Tim Peters wrote in message <000301bf9235$1d59a740$c52d153f at tim>...
>but the converse doesn't hold.  For brownie points, figure out the expected
>number of iterations before this program produces some output:


Approximately 82,137.
For brownie points calculate the expected number of iterations before the
program produces some output if the check "if hash2float[h] != x" is
removed.

Reuben




From markx.daley at intel.com  Fri Mar 24 16:47:14 2000
From: markx.daley at intel.com (Daley, MarkX)
Date: Fri, 24 Mar 2000 13:47:14 -0800
Subject: Python executables?
Message-ID: 

I read through some of the documentation for Python, and maybe I just
haven't found it yet, but is there a way to make a Python .py file
executable?  I am running Windows NT 4.0, and every time I try that, I get a
DOS window for a couple of seconds, then nothing.  I have my Python
directory in my path.

Regards,

Mark Daley




Return-Path: 
Delivered-To: python-list at python.org
Received: from ebony.nesc.epa.gov (ebony.nesc.epa.gov [134.67.65.43])
	by dinsdale.python.org (Postfix) with ESMTP id 4E0C61CD15
	for ; Wed,  8 Mar 2000 07:07:18 -0500 (EST)
Received: from ralph.rtpnc.epa.gov (ralph.rtpnc.epa.gov [134.67.66.44]) by ebony.nesc.epa.gov (980427.SGI.8.8.8/980728.SGI.AUTOCF) via ESMTP id HAA17571 for <@ebony.nesc.epa.gov:python-list at python.org>; Wed, 8 Mar 2000 07:09:16 -0500 (EST)
Received: (from rhh at localhost) by ralph.rtpnc.epa.gov (980427.SGI.8.8.8/980728.SGI.AUTOCF) id HAA06136 for python-list at python.org; Wed, 8 Mar 2000 07:09:16 -0500 (EST)
Resent-Message-Id: <200003081209.HAA06136 at ralph.rtpnc.epa.gov>
Received: from relay02.esat.net (192.111.39.21) by mta101.mail.yahoo.com with
 SMTP; 8 Mar 2000 10:33:25 -0000
Received: from (iel.ie) [193.120.149.250] by relay02.esat.net with smtp id
 12SdmL-0008AY-00; Wed, 08 Mar 2000 10:33:24 +0000
Received: from shogan.iel.ie by iel.ie with SMTP (MDaemon.v2.7.SP5.R)
 for ; Wed, 08 Mar 2000 09:55:34 +0000
Date: Wed, 8 Mar 2000 09:54:43 -0000
From: "Shaun Hogan" 
Subject: Re: how does SWIG work? how do i make a python module out of a c
 function?
To: 
Reply-To: shogan at iel.ie
Message-id: <018601bf88e4$54068e20$2801000a at iel.ie>
MIME-version: 1.0
X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Mailer: Microsoft Outlook Express 5.00.2314.1300
Content-type: text/plain; charset="iso-8859-1"
Content-transfer-encoding: 7bit
X-Priority: 3
X-MSMail-priority: Normal
X-Apparently-To: aa8vb at yahoo.com via web1004.mail.yahoo.com
X-Track2: 2
X-Track: 1: 40
X-MDaemon-Deliver-To: aa8vb at yahoo.com
X-Return-Path: shogan at iel.ie
References: <012201bf8857$fa33e320$2801000a at iel.ie>
 <20000307141108.A113511 at vislab.epa.gov>
Resent-From: rhh at ebony.nesc.epa.gov
Resent-Date: Wed, 8 Mar 2000 07:09:16 -0500
Resent-To: python-list at python.org
Resent-Sender: rhh at ralph.rtpnc.epa.gov
Sender: python-list-admin at python.org
Errors-To: python-list-admin at python.org
X-BeenThere: python-list at python.org
X-Mailman-Version: 2.0beta1
Precedence: bulk
List-Id: General discussion list for the Python programming language 

hi again,
i downloaded the 'swig1_3a2_tar' file from
http://download.sourceforge.net/swig/, i was wondering how i make it work or
what do i do with all the files now ive down loaded them. i cant open any of
the files because i have no program associated with them, what program do i
need to view the files? i tried droping them into notepad but that didnt
work?
thanks for your help.
Shaun.


----- Original Message -----
From: Randall Hopper 
To: Shaun Hogan 
Cc: python 
Sent: Tuesday, March 07, 2000 7:11 PM
Subject: Re: how does SWIG work? how do i make a python module out of a c
function?


> Shaun Hogan:
>
>  |
>  |
>  |  |http-equiv=3DContent-Type>
>  |
>  |
>
> Hi.  First, turn off HTML in your mailer (Microsoft Outlook Express I
> gather).  You'll get more replies.  Many folks ignore or filter out posts
> formatted with HTML.
>
>  |   looking at [1]www.swig.org/tutorial.html
>  |
>  |   i can see that this looks like what i need to do, however according
to
>  |   the tutorial "you need to write an "interface file" which is the
input
>  |   to SWIG.", then it gives an example interface file which looks okay
to
>  |   me to do, but my question is.....what application do i use to write
>  |   this"interface file"?,
>
> It's a text file.  So you can use any ASCII text editor you wish.  Since
> you're on an MSWin box, use MSVC++, notepad, edit, whatever (just so long
> as it's a text file when you're done).
>
>  |   and what do i do with it when its wrote?,
>
> You run "swig" on it.  SWIG generates wrapper code (in C, for example) and
> optionally Python wrapper classes (.py) if you tell it to.  E.g. on UNIX:
>
>      swig -shadow -python -I/my/includes -o stuff.i
>
>  |   and what do i do with it when its wrote?
>
> Link the wrapper code with the code it's wrapping, and then load it into
> Python using a standard "import " statement.  I could tell you
> about UNIX, but you'll need to read the docs for MSWin directions.  This
> should all be in the SWIG docs:
>
>      http://sourceforge.net/project/?group_id=1645
>      http://download.sourceforge.net/swig/
>
> See the Doc/ tree in the package.
>
>  |   how do i know if i have written it correctly?
>
> Call your wrapped methods and test them?
>
>  |   further down the page it shows (apparently) how to turn c code into a
>  |   python module for Irix.....i dont know what that is, im using IDLE
and
>  |   windows.
>
> See:
>    http://starship.python.net/crew/mhammond/win32/BuildingExtensions.html
>
>
>  |   can anyone help me, ive been stuck with this problem for a week...and
>  |   im going mad trying to figure it out.
>
> I'm not sure what you're stuck on yet.  Do you have an error message or
> code snippet that's relevent?
>
> --
> Randall Hopper
> aa8vb at yahoo.com
>
>




From: "Zarkon & Zena" 
Newsgroups: comp.lang.python
References:    
Subject: Re: De-compiler for *.pyc files
Lines: 1104
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2919.6600
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
Message-ID: 
Date: Sun, 12 Mar 2000 08:27:09 -0700
NNTP-Posting-Host: 63.225.7.6
X-Trace: news.uswest.net 952874934 63.225.7.6 (Sun, 12 Mar 2000 09:28:54 CST)
NNTP-Posting-Date: Sun, 12 Mar 2000 09:28:54 CST
Path: news!uunet!ffx.uu.net!news3!logbridge.uoregon.edu!news-out.uswest.net!news.uswest.net.POSTED!not-for-mail
Xref: news comp.lang.python:87846
To: python-list at python.org
Sender: python-list-admin at python.org
Errors-To: python-list-admin at python.org
X-BeenThere: python-list at python.org
X-Mailman-Version: 2.0beta1
Precedence: bulk
List-Id: General discussion list for the Python programming language 

Ok, I think I am starting to get there... Here is what I get when I try it:

PythonWin 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Portions Copyright 1994-1999 Mark Hammond (MHammond at skippinet.com.au)
>>> import doc
>>> import hack
>>> import Command
>>> import ApplyLocation
>>> dir(ApplyLocation)
['ApplyLocation', 'Command', 'DSExceptions', '__builtins__', '__doc__',
'__file__', '__name__']
>>> hack.dis(ApplyLocation.Command)
Traceback (innermost last):
  File "", line 0, in ?
  File "C:\Program Files\Python\Lib\hack.py", line 289, in dis
    dis.disco(c)
  File "dis.py", line 55, in disassemble
    code = co.co_code
AttributeError: co_code
>>>

I am assuming that the function names are being returned by the "dir"
command.
I have attached the files in case you have the time to look at them.

Thanks for your help and ideas.

-Walt



"Michael Hudson"  wrote in message
news:m3n1o5bhe4.fsf at atrus.jesus.cam.ac.uk...
> "Zarkon & Zena"  writes:
>
> > Ok, I have played with "dis" module a little bit, but don't I need to
know
> > the names of the functions inside the *.pyc file before I can get at
them?
>
> Oh that's easy:
>
> Python 1.5.2+ (#13, Jan 14 2000, 09:26:45)
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import string
> >>> dir(string)
> ['_StringType', '__builtins__', '__doc__', '__file__', '__name__',
> '_apply', '_float', '_idmap', '_idmapL', '_int', '_long', 'atof',
> 'atof_error', 'atoi', 'atoi_error', 'atol', 'atol_error',
> 'capitalize', 'capwords', 'center', ...
>
> or
>
> def getfuncs(module):
>     r = []
>     for f in module.__dict__.values():
>         if type(f) is type(getfuncs):
>            r.append( f )
>     return f
>
> or something like that.
>
> I suggest a close reading of the langauge reference if you intend to
> poke around on this level.
>
> HTH,
> M.
>
> --
> very few people approach me in real life and insist on proving they are
> drooling idiots.                         -- Erik Naggum, comp.lang.lisp


begin 666 ApplyLocation.pyc
MF4X-"LE<(SAC``````,```!S,P```'\``'\(`&L``&P```%_"0!K`0!:`0!_
M"P!D``!E``!F`0!D`0"$``"#``!96@(`9 (`4R@#````4QO
M8V%T:6]N8P`````!``(`4QO8V%T:6]N+G!Y7,#`````'P``&D!`&D(`&\:``%_'P!\``!I`0!I
M#0!\``!I!0"#`0`!;A8``7\A`'0.`&D/`'P``&D!`(,!`((!`&0``%,H`P``
M`$YS"@```'9D9E]R97-U;'1S!0```'=R:71E*! ```!S! ```'-E;&9S!P``
M`'-E6QE7,-````07!P;'E,;V-A=&EO
M;@L`7,$````:6-O;G,$````3F]N92@$````7,(````7U]I;FET7U\,`',,`````P$,`0P!#P$<`1T"
M8P$``0`!``,`7,#````7,!````/P@`71H;VX at +4\*"B(B(B *(" @($%U=&]M871I
M8R!0>71H;VX at 1&]C=6UE;G1A=&EO;B!I;B!(5$U,"@H@(" @5&AI2!O;FQY($A4
M34P@:7,@2!M86ME('5S92!O9B!T:&4@' G
M6YA;6EC86QL>0H@(" @9&5F:6YE9"!C;V1E("AL:6ME(&-O9&4@:6X@
M:68N+BYE;'-E+BXN+6-L875S97,I(&ES(&YO="!P87)S960N"@H@(" @5&AE
M(&1O8RUS=')I;F=S(&%R92!P0H@(" @8V]N=&%I;B!S<&5C:6%L(&-H87)A8W1E6]U(&AA=F4@=&\*(" @(" @:6YC;'5D92!S:6YG;&4@;V-C=7)E;F-E2!I;G1O"B @(" @('1H92!(5$U,+69I;&4@>6]U
M(&AA=F4@=&\@8F4 at 8V%R969U;"!A8F]U="!U6]U6)E($D@2!(5$U,"B @(" @("!I;B!M>2!C=7)R96YT(&1O8RUS=')I;F=S(&%N
M>7=A>5T*(" @("T at 8V]D92!C;W5L9"!B92!M861E(&9A2!U71H;VXN;W)G(&9OF5D($A434P@=F5R7EO=7(@4'ET:&]N('-C
M2 H9&]W;FQO
M861A8FQE(&9R;VT@;7D at 4'ET:&]N('!A9V5S(&]N('-T87)S:&EP*0H*(" @
M($AI&5S('1O('1H92!R96=E
M>'!S("AT:&%N:W,@=&\@5&EM(%!E=&5R' @=&\@
M;F]T(&)R96%K(&-O9&4 at 870@8V]M;65N=',*(" @(" @(" @(" H=&AI&5D(&)U9R!T:&%T(&-U="!A=V%Y(&9I2!O9B!+
M96ET:"!$879I9'-O;BD["B @(" @(" @(" @861D960@)V\G(&%S(&QI7, at 879A:6QA
M8FQE(&9R;VT@;7D at 4'ET:&]N('!A9V5S. at H*(" @(" @(" @("!H='1P.B\O
M2!-87)C+4%N9')E($QE;6)U2P@
M86YD(&1I2!I7!O2!A;F0 at 8G5I;&0 at 86X*:6YT
M97)N86P@;V)J96-T('-T2!O;FQY($A434P@:7,@"YC;VUP:6QE*"=<*" J7"EC;&%S%]F=6YC=&EO;B ](')E9V5X+F-O;7!I;&4H)UPH
M("I<*61E9B K7"A;7B@@72M<*2 J)PH@(" @(" @(" @(" @(" @(" @(" @
M(" @(" @)RA<*%PH6UXH*5U%]M971H
M;V0@/2!R>%]F=6YC=&EO;@IR>%]B;V1Y:6YD96YT(#T@(%QN72(%QN72"YC;VUP
M:6QE*"<@*E]?=F5R7"=<(ETK7"E;7"=<
M(ETG*0HC(&-A8VAE('-O;64 at 8V]M;6]N('!A" ](')E9V5X+F-O;7!I;&4H%]P87)TF4@/2 X"@HC('-O
M;64 at 9V]B86P@;W!T:6]N7!O
M3)H=&UL+G!Y+ H)"2,@=7-E('1H:7,@=F5R'0@:&%S('1O(&)E
M(&EN9&5N=&5D(&)Y(&EN9&5N="!S<&%C97,*"2H@=&5X="!M=7-T(&)E(%1!
M0BUF2!D969I;F5D(&]B:F5C=', at +2T@=7-I;F<*"2 @
M:68G" ](')X7W!A)RMS:2LG9G)O;2!)RMS:2LG6UX at 7&Y=)PH)"YC;VUP
M:6QE*')S*0H)'1;7!E
M6RTQ72 ]/2 G("7!E6SHM,5T*"6Q;+3%=6S%=(#T@=" C
M('1H92!L87-T('!A'0I"B @("!L(#T@
M;6%P*'1U<&QE+&PI"B,@(" @<')I;G0@)RHJ(')E='5R;FEN9R!W:71H('!A
M'1;" ](')X7V)O9'EI;F1E;G0*(" @(&EF(')X+G-E87)C:"AT97AT+'-T
M87)T*2 A/2 M,3H*"6$L8B ](')X+G)E9W-;,5T*"7)E='5R;B!B+6$*(" @
M(&5L6)E('1H97)E(&%R92!N;R!N97<@;&EN97,@;&5F=" H
M92YG+B!A="!T:&4 at 96YD(&]F(&$@9FEL92D*"7)X(#T@6EN9&5N
M=%\R"@EI9B!R>"YS96%R8V at H=&5X="QS=&%R="D@(3T at +3$Z"@D@(" @82QB
M(#T@'0I. at H*
M(" @("(B(B!S=6)S=&ET=71E('-U8B!F;W(@979E'0L9FEN9"D*(" @(')E='5R;B!S=')I;F6QE(&YE=VQI;F5S(&5V97)Y=VAE'0I"B @("!R971U'0I"@ID
M968 at 97-C87!E7VQO;F=?'0L)UPB
M7")<(B'1R86-T7V1O8U]S=')I;F71H;VXM
M9F%S:&EO;B!O9B!N86UI;F<@=&AI;F=S"B @(" B(B(*"B @("!T(#T at 9&]C
M+FYA;64*(" @('=H:6QE(&1O8RYO=VYE'0 at 87, at 82!D;V,M'0@/2!T
M97AT"@H@(" @9&5F(%]?&%M<&QE. at H*"2 @(" @(", at 9&5F('5N97-C87!E
M7VQO;F=?'0L)UPB7")<(B'0I. at D)"2,*"2 @(" @(" @;" ]('-T2X*"@D@(" @*B!)9B!Y;W4@<&QA;B!T;R!P=70@=F5R8F%T
M:6T at 2%1-3"UC;V1E(&EN;&EN92!T:&5N('EO=2!C86X*"2 @(" @('5S92!T
M:&ES('-Y;G1A>"!6]U
M)VQL(&AA=F4@=&\@;&]O:PH)(" @(" @870@=&AE('-O=7)C92!C;V1E('1O
M(&9I;F0@;W5T(&AO=R!I="!W;W)KD$M6C M.4 N)5PM72M<*2D$M6C M.4 N)5PM7"\_)BL]?ETK7"DG+ H@(" @(" @(" @(" @
M(" @(" @(" @(" G/$$@2%)%1CTB:'1T<#HO+UQ<,2(^:'1T<#HO+UQ<,3PO
M03XG+'0I"@ET(#T@D$M6C M.4 N
M)5PM7"\_)BL]?ETK7"DG+ H@(" @(" @(" @(" @(" @(" @(" @(" G/$$@
M2%)%1CTB9G1P.B\O7%PQ(CYF=' Z+R]<7#$\+T$^)RQT*0H*"70@/2 G/% ^
M("5S(#PO4#XG("4@= H*"7)E='5R;B!T"@IC;&%S"QS>2QO=VYE"QS>2D*"7-E;&8N;W=N97(@/2!O=VYE<@H)%]C;&%S"YM871C:"AT97AT+'-X*0H):68@'1; H)"YG2UI;F1E;G0*"7-E;&8N
M8F]D>6EN9&5N=" ](&-A;&-?8F]D>6EN9&5N="AT97AT+'-T87)T*0H)(R!B
M5TL'0L"QS=&%R="MY+'-E;&8I*0H)"65L:68@='EP
M92 ]/2 G8VQA'0L"QS=&%R="MY
M+'-E;&8I*0H)"65L:68@='EP92 ]/2 G(R7!E(#T]("=<(EPB7"(G. at H)"2 @
M(" C(&=O="!A(&1O8RUS=')I;F<*"0D@(" @&-E<'0 at 4&%R"QS>2QO=VYE'0@(" @+2!O2P at 8G)O:V5N(&EN=&\@<&%R=',*
M"2(B(@H@(" @(" @('-E;&8N=&5X=" ]('1E>'0*"7-E;&8N'0L'1;"YG'0L2QT>7!E(&EN('-E;&8N<&%R=',Z
M"@D):68@('1Y<&4@/3T@)V1E9B7!E(#T]("=C;&%S
M7!E(#T]("'1;#IS=&%R="MY72DL'0L#IS>5T at 9F]R(&$@;65T:&]D
M(&1E9FEN:71I;VX at 86YD(&%L;"!I=',*"2 @("!M96UB97)S.R!I;G-T86YC
M92UV87)I86)L97,Z"@D@(" @*B!T97AT(" @("T@;W)I9VEN86P at 8V]D90H)
M(" @("H@'0@=VAE2P at 8G)O:V5N(&EN=&\@<&%R=',*"2(B(@H@(" @(" @('-E
M;&8N=&5X=" ]('1E>'0*"7-E;&8N#IS>5TI"@EI9B!S=&%R=" \(# Z"@D@(" @(R!W92=V92!G
M;W0 at 82!P#IS>5T*"2 @("!R86ES92!087)S945R'1;6EN9&5N="D*(PEP2QT>7!E(&EN('-E;&8N<&%R
M=',Z"@D):68@('1Y<&4@/3T@)V1E9B7!E(#T]("=C
M;&%S7!E(#T]("'1;#IS=&%R="MY72DL71H;VX@;6]D=6QE"@D@(" @*B!O=VYE
M2P at 8G)O:V5N(&EN
M=&\@<&%R=',*"2(B(@H)(R!R96%D(&9I;&4L(&5X<&%N9"!T86)S+"!F:7@@
M;&EN92!BF4I"@ES
M96QF+G1E>'0@/2!F:7A?;&EN96)R96%K'0I"@ES96QF+G1E
M>'0@/2!E'1;+3$Z72 A/2 G7&XG. at H)(" @('-E;&8N
M=&5X=" ]('-E;&8N=&5X=" K("=<;B<*"7-E;&8N;F%M92 ](&]S+G!A=&@N
M0H)2QT>7!E(&EN('-E;&8N<&%R=',Z"@D):68@
M('1Y<&4@/3T@)V1E9B2QS96QF*2D*"0EE;&EF('1Y<&4@/3T@)V-L87-S)SH*"0D@(" @(R!G
M;W0 at 82!C;&%S'0L>"QY+'-E;&8I*0H)"65L:68@='EP92 ]/2 G(R7!E(#T]
M("=<(EPB7"(G. at H)"2 @(" C(&=O="!A(&1O8RUS=')I;F<*"0D@(" @#IY72DL'1R86-T7W9E5T*"2 @("!P2" ]('-E;&8N;F%M92LG+FED>"YH=&UL)PH)"MS96QF+FEN9&5X+"!H H);W5T<'5T(#T@(B(B"@D@(" @
M(" @(" @(" \2%1-3#X*"0D@(" @/$A%040^"@D)(" @(#Q4251,13Y$;V-)
M;F1E>#HZ4')O:F5C=#HZ)7,\+U1)5$Q%/@H)"2 @(" \345402!.04U%/2)+
M15E73U)$4R(@0T].5$5.5#TB)7,L(&EN9&5X+"!D;V-U;65N=&%T:6]N+"!P
M>71H;VXB/@H)"2 @(" \+TA%040^"@D)(" @(#Q"3T19($)'0T],3U(](T9&
M1D9&1CX*"0D@(B(B("4@*'-E;&8N;F%M92P@"MS96QF+F-O
M;G1E;G0K7 H)"0D)(" @(" G(R"MS96QF+F-O;G1E;G0K7 H)"0D@
M(" @(""YW
M"YC;&]S92 at I"@D*"2,@;6%K92!C;VYT96YT
M+69I;&4*"7!R:6YT("71H
M;VXL(&1O8RUT;V]L(CX*"0D@(" @/"](14%$/@H)"2 @(" \0D]$62!"1T-/
M3$]2/2-&1D9&1D8^"@D)("(B(B E("AS96QF+FYA;64L H*(" @('!R:6YT("=$;V,M
M5&]O;"!6)RM?7W9E7,N87)G=BD@/" S. at H)<')I;G0@)U-Y;G1A>#HG+'-Y" \<')O:F5C="UN86UE/B!C;VYT86EN:6YG)PH)<')I;G0@)W1H
M92!D;V,M"P@:68G
M"@EP&ET*"D*
M(" @('!R:6YT("=7;W)K:6YG(&]N('!R;VIE8W0Z)RQS>7,N87)G=ELQ72PG
M" ]('-Y" ]("7)I9VAT(&)Y($UA2P@;6]D:69Y+"!A;F0@
M9&ES=')I8G5T92!T:&ES('-O9G1W87)E(&%N9 T*(" @(&ET2!I2!G7)I9VAT(&YO=&EC92!A;F0@
M=&AI7!O
M&%M:6YE#0IC;V1E(&9R;VT@:6YS:61E(&%N(&EN=&5R86-T:79E(&EN=&5R
M<')E=&5R('-E2!D;V,@0T*&-E<'1I;VX@:&5L<&5R3H-"@EP(%TG*0T*#0ID968@7,N;6%X:6YT#0H);" ](&UA<"AE
M>'!A;F1T86)S+&PI#0H)9F]R(&D@:6X@"QI;F1E;G0]:6YD96YT
M.B!X6VEN9&5N=#I=+&Q;,3I=*0T*(" @(&5L&1E<'1H/3(L;&5V96P]
M,"P-"@D at 24Y$14Y4/4E.1$5.5"DZ#0H-"B @(" B(B(@&1E<'1H+&QE=F5L*0T*(" @('-H
M;W=A='1R*&,L)U]?871T&1E<'1H. at T*"7)E='5R;@T*#0H@(" @9F]R
M('@@:6X@:71E;7,Z#0H)=')Y. at T*"2 @("!A(#T at 9V5T871T&-E<'1I;VXJ)PT*"6EF(&QE;BAR*2 ^(#0P. at T*"2 @("!R
M(#T@"QR
M*0T*#0ID968@3H-"@EX
M(#T at 9V5T871T&1E<'1H. at T*"7)E='5R;@T*#0H@(" @&1E<'1H
M+&QE=F5L*0T*#0ID968@&1E<'1H. at T*"7)E='5R;@T*#0H@(" @:68@
M;F]T(&ET96US. at T*"7!R:6YT(""!I;B!I=&5M&-E<'1I;VXJ)PT*"6EF(&QE;BAR*2 ^(#0P. at T*"2 @("!R
M(#T@&1E<'1H. at T*"7)E='5R;@T*#0H@(" @:68@;F]T(&ET96US. at T*"7!R
M:6YT("2D-"@EE>&-E<'0Z#0H)(" @(&L@/2 G*F5X8V5P=&EO;BHG#0H)
M:68@;&5N*&LI(#X at -# Z#0H)(" @(&L@/2!K6SHT,%TK)R N+BXG#0H)=')Y
M. at T*"2 @("!V(#T@&-E<'0Z#0H)(" @('8@/2 G
M*F5X8V5P=&EO;BHG#0H)(" @('9A;'5E(#T at 3F]N90T*"6EF(&QE;BAV*2 ^
M(#0P. at T*"2 @("!V(#T@=ELZ-#!=*R<@+BXN)PT*"6EF(&QE=F5L(#P@;6%X
M9&5P=&@@86YD('9A;'5E(&ES(&YO="!.;VYE. at T*"2 @("!P7!E*&,I(#T]
M('1Y<&5S+E-T7!E2!A8V-U
M&5C(&,@:6X@;F%M97-P86-E#0H@(" @
M96QS93H-"@EI;7!O&5C(&,@:6X at 7U]M86EN7U\N
M7U]D:6-T7U\-"@T*9&5F('=H>2 at I.@T*#0H@(" @(B(B('=H>2 at I("TM('-H
M;W<@;&]C86QS('1H870 at 8V%U'0-"@EF2!P7,N;6]D=6QE7,N;6]D=6QE
Delivered-To: python-list at python.org
Received: from ebony.nesc.epa.gov (ebony.nesc.epa.gov [134.67.65.43])
	by dinsdale.python.org (Postfix) with ESMTP id 8199B1CD0D
	for ; Wed,  8 Mar 2000 07:07:09 -0500 (EST)
Received: from ralph.rtpnc.epa.gov (ralph.rtpnc.epa.gov [134.67.66.44]) by ebony.nesc.epa.gov (980427.SGI.8.8.8/980728.SGI.AUTOCF) via ESMTP id HAA17562 for <@ebony.nesc.epa.gov:python-list at python.org>; Wed, 8 Mar 2000 07:09:07 -0500 (EST)
Received: (from rhh at localhost) by ralph.rtpnc.epa.gov (980427.SGI.8.8.8/980728.SGI.AUTOCF) id HAA06113 for python-list at python.org; Wed, 8 Mar 2000 07:09:07 -0500 (EST)
Resent-Message-Id: <200003081209.HAA06113 at ralph.rtpnc.epa.gov>
Received: from relay02.esat.net (192.111.39.21) by mta101.mail.yahoo.com with
 SMTP; 8 Mar 2000 10:30:44 -0000
Received: from (iel.ie) [193.120.149.250] by relay02.esat.net with smtp id
 12SdjU-00081s-00; Wed, 08 Mar 2000 10:30:29 +0000
Received: from shogan.iel.ie by iel.ie with SMTP (MDaemon.v2.7.SP5.R)
 for ; Wed, 08 Mar 2000 09:29:46 +0000
Date: Wed, 8 Mar 2000 09:28:55 -0000
From: "Shaun Hogan" 
Subject: Re: how does SWIG work? how do i make a python module out of a c
 function?
To: 
Reply-To: shogan at iel.ie
Message-id: <016a01bf88e0$b9663bc0$2801000a at iel.ie>
MIME-version: 1.0
X-MIMEOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
X-Mailer: Microsoft Outlook Express 5.00.2314.1300
Content-type: text/plain; charset="iso-8859-1"
Content-transfer-encoding: 7bit
X-Priority: 3
X-MSMail-priority: Normal
X-Apparently-To: aa8vb at yahoo.com via web1001.mail.yahoo.com
X-Track2: 2
X-Track: 1: 40
X-MDaemon-Deliver-To: aa8vb at yahoo.com
X-Return-Path: shogan at iel.ie
References: <012201bf8857$fa33e320$2801000a at iel.ie>
 <20000307141108.A113511 at vislab.epa.gov>
Resent-From: rhh at ebony.nesc.epa.gov
Resent-Date: Wed, 8 Mar 2000 07:09:07 -0500
Resent-To: python-list at python.org
Resent-Sender: rhh at ralph.rtpnc.epa.gov
Sender: python-list-admin at python.org
Errors-To: python-list-admin at python.org
X-BeenThere: python-list at python.org
X-Mailman-Version: 2.0beta1
Precedence: bulk
List-Id: General discussion list for the Python programming language 

hi there,
thanks for your help, the problem i refered to that i was stuck on is:


below is the c file 'tester.c', what im trying to do is:
write python script that does the equivalent to the following : i.e.,
creates the C++ object created in this function (the "writeThisInPython"
function) and then calls the same 2 methods called here, i.e., getName() and
getNumber().

if anyone has any ideas on how i can figure out how TODO these 2 problems,
could they please let me know.
thanks
Shaun

/*----------------------
tester.c
----------------------*/

#include 
#include "Subscriber.h"

void writeThisInPython(void);
void callPythonFromHere(void);

void main(void)
{
 writeThisInPython();
 callPythonFromHere();
}

// TO-DO 1 : write python script that does the equivalent to the following :
// i.e., creates the C++ object created in this function and then calls
// the same 2 methods called here, i.e., getName() and getNumber()

void writeThisInPython(void)
{
 Subscriber subscriber("Mick McCarthy", 99);

 cout << "Subscriber Name   : " << subscriber.getName() << endl;
 cout << "Subscriber Number : " << subscriber.getNumber() << endl;
}

void callPythonFromHere(void)
{
 Subscriber subscriber("Mick McCarthy", 99);

 cout << "Subscriber Name   : " << subscriber.getName() << endl;
 cout << "Subscriber Number : " << subscriber.getNumber() << endl;

 // TO-DO 2 : call python code from here to write the above details
 // to a file (format doesn't matter)
}

----------------------------------------------------------------------------
------------------------
----- Original Message -----
From: Randall Hopper 
To: Shaun Hogan 
Cc: python 
Sent: Tuesday, March 07, 2000 7:11 PM
Subject: Re: how does SWIG work? how do i make a python module out of a c
function?


> Shaun Hogan:
>
>  |
>  |
>  |  |http-equiv=3DContent-Type>
>  |
>  |
>
> Hi.  First, turn off HTML in your mailer (Microsoft Outlook Express I
> gather).  You'll get more replies.  Many folks ignore or filter out posts
> formatted with HTML.
>
>  |   looking at [1]www.swig.org/tutorial.html
>  |
>  |   i can see that this looks like what i need to do, however according
to
>  |   the tutorial "you need to write an "interface file" which is the
input
>  |   to SWIG.", then it gives an example interface file which looks okay
to
>  |   me to do, but my question is.....what application do i use to write
>  |   this"interface file"?,
>
> It's a text file.  So you can use any ASCII text editor you wish.  Since
> you're on an MSWin box, use MSVC++, notepad, edit, whatever (just so long
> as it's a text file when you're done).
>
>  |   and what do i do with it when its wrote?,
>
> You run "swig" on it.  SWIG generates wrapper code (in C, for example) and
> optionally Python wrapper classes (.py) if you tell it to.  E.g. on UNIX:
>
>      swig -shadow -python -I/my/includes -o stuff.i
>
>  |   and what do i do with it when its wrote?
>
> Link the wrapper code with the code it's wrapping, and then load it into
> Python using a standard "import " statement.  I could tell you
> about UNIX, but you'll need to read the docs for MSWin directions.  This
> should all be in the SWIG docs:
>
>      http://sourceforge.net/project/?group_id=1645
>      http://download.sourceforge.net/swig/
>
> See the Doc/ tree in the package.
>
>  |   how do i know if i have written it correctly?
>
> Call your wrapped methods and test them?
>
>  |   further down the page it shows (apparently) how to turn c code into a
>  |   python module for Irix.....i dont know what that is, im using IDLE
and
>  |   windows.
>
> See:
>    http://starship.python.net/crew/mhammond/win32/BuildingExtensions.html
>
>
>  |   can anyone help me, ive been stuck with this problem for a week...and
>  |   im going mad trying to figure it out.
>
> I'm not sure what you're stuck on yet.  Do you have an error message or
> code snippet that's relevent?
>
> --
> Randall Hopper
> aa8vb at yahoo.com
>
>





From effbot at telia.com  Thu Mar 30 15:52:21 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Thu, 30 Mar 2000 20:52:21 GMT
Subject: Tk novice question
References: <38E3ACDD.D7D0918B@westlakefinancial.com>
Message-ID: <98PE4.409$n68.188469760@newsb.telia.net>

Joseph Santaniello wrote:
> How do I trap window close events for a given window? I want to (after a
> window is closed by hitting the X or equiv) to cycle through a list of
> spawned windows, but I don't ever know when my window gets closed. Where
> should I look for info on how to do this?

http://www.pythonware.com/library/tkinter/introduction/events-and-bindings.h
tm
=> protocols






From darrell at dorb.com  Sat Mar 11 23:32:53 2000
From: darrell at dorb.com (Darrell)
Date: Sat, 11 Mar 2000 20:32:53 -0800
Subject: Forth like interpreter
Message-ID: <158801bf8bdc$08516040$6401a8c0@dorb>

Wrote a Forth like interpreter in Python.
Probably useless but it gave me something to do today.
http://www.dorb.com/darrell/forth/forth.py

Kragen Sitaker mentioned in "What if Python Replaced Elisp" that Forth
compilers were easy. He's right!

I only did one branching instruction "if" and an assortment of other words.

The compile phase could generate Python byte code or for real crazies
assembler. Real Forth often comes with an assembler built in. So I can see
how some version of Lisp might compile to assembler.

--Darrell







From hamlet at en.com  Tue Mar 28 22:35:53 2000
From: hamlet at en.com (hamlet at en.com)
Date: Wed, 29 Mar 2000 03:35:53 GMT
Subject: US v Microsoft
Message-ID: <38e17b68$0$1374@news.voyager.net>

I think that what many people lose sight of in defending Microsoft is
that any concentration of power of this magnitude has the potential
for being abused. I think that this litigation has been very broadly
based and courageous; I respect the government lawyers for using the
rule of law to attempt to check the tyrannical exercise of power.

I also think that Microsoft has already suffered great reverses in the
court of public opinion, especially expert opinion. It is incumbent on
those of us who have expert knowledge to marshall that knowledge in
the service of fair play.

In one sense, the points raised in this litigation have been made moot
by certain technical advances, most notably the open source movement.
The unavoidable reality is that these developments have come about in
spite of the concerted efforts of Microsoft the thwart them. That, I
believe , gives the lie to any claim of Microsoft to be an
"innovator."


From effbot at telia.com  Sun Mar 12 08:59:19 2000
From: effbot at telia.com (Fredrik Lundh)
Date: Sun, 12 Mar 2000 13:59:19 GMT
Subject: Sharing XMLRPC w/ my neighbors
References: <5650A1190E4FD111BC7E0000F8034D26A0F372@huina.oceanic.com>
Message-ID: 

Doug Stanfield  wrote:
> There exists this group of folks who work in ways completely foreign to
me.
> They're known as the IS department and stoke an AS400 with something
called
> RPG-II to do billing .  It would be very useful if they could use
one
> of my interfaces, but I don't know how to tell them what to do.  They want
> to hear something on the order of "Open a socket..." and I jumped at using
> the xmlrpclib precisely to hide those mungy details.

maybe they can run Java on their boxes?  several
Java client libraries are available from:

    http://www.xmlrpc.com/

(alternatively, if RPG-II supports XML and HTTP in some
way, it shouldn't be that hard to implement a small portion
of the XML-RPC spec.  you'll find the specification on the
above site as well).






From hnowak at cuci.nl  Fri Mar 24 01:11:49 2000
From: hnowak at cuci.nl (Hans Nowak)
Date: Fri, 24 Mar 2000 07:11:49 +0100
Subject: file / string problem?
In-Reply-To: 
Message-ID: <200003240612.GAA27838@dionysus.fw.cuci.nl>


On 24 Mar 00, at 0:27, Todd Palmer wrote:

> I new to python and I'm having a problem writing a binary string to a
> file.  I'm using the zipfile.py module and getting the data from the zip
> file and writing it to a file object.  The string returned from the
> zipfile.read() function is the correct size, but when I write it to disk,
> the file on the disk is the wrong size and corrupted.  Any ideas?  Do I
> have to do something special with binary data in strings?
> 
> Code:
> 
> import zipfile
> 
> z = zipfile.ZipFile('D:\\tmp\\esbdates.zip')
> try:
>  # read the binary data into a string
>    S = z.read('esbdates.hlp')
>  # note len(S) here returns 362588 which is correct  as per 
>  # zipfile.py AND winzip
>  f = open('D:\\tmp\\esbdates.hlp', 'w')

Try 'wb' rather than 'w'...

Blessed be,

--Hans Nowak (zephyrfalcon at hvision.nl)
Homepage: http://www.hvision.nl/~ivnowa/newsite/
Python questions? See http://tor.dhs.org/~zephyrfalcon/snippets
You call me a masterless man. You are wrong. I am my own master.



From shogan at iel.ie  Tue Mar  7 12:10:02 2000
From: shogan at iel.ie (Shaun Hogan)
Date: Tue, 7 Mar 2000 17:10:02 -0000
Subject: how does SWIG work? how do i make a python module out of a c function?
Message-ID: <012201bf8857$fa33e320$2801000a@iel.ie>

as you may have seen from previous postings i need to embed some c code in a python script (make a python module out of a c function) and i dont know how.
looking at www.swig.org/tutorial.html
i can see that this looks like what i need to do, however according to the tutorial  "you need to write an "interface file" which is the input to SWIG.", then it gives an example interface file which looks okay to me to do, but my question is.....what application do i use to write this"interface file"?, and what do i do with it when its wrote?, how do i know if i have written it correctly? how do i get it to work in the script, and get the function to do what its supposed to?
 
further down the page it shows (apparently) how to turn c code into a python module for Irix.....i dont know what that is, im using IDLE and windows.
can anyone help me, ive been stuck with this problem for a week...and im going mad trying to figure it out.
Thanks 
Shaun   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 

From claird at starbase.neosoft.com  Thu Mar  2 23:06:41 2000
From: claird at starbase.neosoft.com (Cameron Laird)
Date: 2 Mar 2000 22:06:41 -0600
Subject: Most common #! format
References: 
Message-ID: 

In article ,
Peter Funk  wrote:
>Hi!
>
>Chuck Esterbrook:
>> What's the most common #! format?
>> 
>> #!python
>> #!/usr/local/bin/python
>> #!/usr/bin/env python
>
>Since MacOS and Windows don't care about this very first line,
>this is only interesting to increase portability on unixoid platforms.  
Windows' command.com also supports analogous hackery,
yielding .bat sources which can act either as inde-
pendent executables or as well-formed Pyscripts.  I
have an allergic reaction to the syntactic contortions
involved, so I'll not give an example now.  Maybe we
should include one in the FAQ, though ...
			.
		[sage counsel on
		various more-or-
		less pertinent
		topics]
			.
			.
>mysterious security policy).  Under this rare circumstances the second
>form '#!/usr/local/bin/python' comes into play.  This would allow
>to call for example a CGI-script from a web server process, which 
>didn't has Python on its search path.  But this situation should 
>be considered as very exotic and rare today.
You just don't travel in the right (or wrong) circles
enough.  There are sites where ... well, I'll sum-
marize this way:  #! composition is like GUI toolkit
selection, in that different circumstances lead rea-
sonable people to different choices.  There's no one
right first-line.

Note that 
also explains the 
  #! /bin/sh
  """:"
  exec python $0 ${1+"$@"}
  """                       
alternative which I favor.

Exercise for those designing a c.l.p reorganization:
should this thread take a home in .platform, .question,
.cgi, ...?
			.
			.
			.
-- 

Cameron Laird 
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html


From shogan at iel.ie  Fri Mar 10 12:26:32 2000
From: shogan at iel.ie (Shaun Hogan)
Date: Fri, 10 Mar 2000 17:26:32 -0000
Subject: c/python integration
Message-ID: <012c01bf8ab5$c6fdd1e0$2801000a@iel.ie>

right so, heres my problem,
i have this c code (below) and i want to call the functions getname() and
getnumber() from within the python interpreter, can anyone give me the code
i need or tell me how to do it pls
Thanks
Shaun



#define debug
/* #undef debug*/ // Uncomment this to compile with python
#ifndef debug
    #include "Python.h"
#else
    #include 
    #include 
#endif /*ndef debug */


typedef struct
{
    char name [100];
    int number;
}subscriber ;

int get_number (subscriber s);

char * get_name (subscriber s)
{
    char *t = (char *) malloc (sizeof (char) * 100);
    strcpy (t, s.name);
    return t;
}


#ifdef debug
int main (void)
{
    get_sub_details();

}
#endif /*debug*/

int get_number (subscriber s)
{
    return s.number;
}

#ifndef debug
Py_Object * get_sub_details (Py_Object *, Py_Object *)
#else
int get_sub_details(void)
#endif  /*debug */
{
    // this is one of the functions exported
    // to Python
    // For testing , create a sub object here
    subscriber test = {"Shaun", 100};
    printf ("name %s \t age %d\n", get_name (test) , get_number(test));
}





From markx.daley at intel.com  Thu Mar 23 10:58:35 2000
From: markx.daley at intel.com (Daley, MarkX)
Date: Thu, 23 Mar 2000 07:58:35 -0800
Subject: List limitations?
Message-ID: 

OK, here's a good one:

I am using this glorious little piece of code, which I will explain in
detail:

def collect():
	familyname = ['name1', 'name2', 'name3', 'name4', 'name5', 'name6',
'name7', 'name8', 'name9', 'name10', 'name11', 'name12']
	servername = ['server1', 'server2']
	sql_date = time.strftime('%Y'+"-"+'%m'+"-"+'%d
%H'+":"+'%M'+":"+'%S', time.localtime(time1[0]))
	current_date = time.strftime('%Y'+"-"+'%m'+"-"+'%d
%H'+":"+'%M'+":"+'%S', time.localtime(time2[0]))
	file_date = time.strftime('%m'+"_"+'%d'+"_"+'%Y',
time.localtime(time.time()))
	for index in servername:
		dbc = odbc.odbc(index+'/username/password')
		crsr = dbc.cursor()
		for name in familyname:
			crsr.execute("""select * from subtestlist\n\
where (errorcode<>'null'\n\
AND familyname='"""+name+"""'\n\
AND Packagestarttime>'"""+sql_date+"""'\n\
AND Packagestarttime<='"""+current_date+"""');""")
			result = crsr.fetchall()
			for item in range(len(result)):
				data1, data2, data3, data4, data5, data6,
data7, data8, data9, data10, data11, data12, data13, data14, data15, data16,
data17 = result[item]
				data10 = time.ctime(data10)
				data11 = time.ctime(data11)
				result[item] = (data1, data2, data3, data4,
data5, data6, data7, data8, data9, data10, data11, data12, data13, data14,
data15, data16, data17)
			mylist = result[:]
			f = open(index+'_'+name+'_'+file_date+'.txt','a')
			for item in mylist:
				f.write(`item`+'\n')
			f.close()

What this does is connect to a server and pull data from it based on each
family name in the familyname list, using an SQL query.  Conceivably, this
code should connect to server1 and pull data for all familynames and write
that data to a file, server_familyname_date.  Then it should connect to
server2 and do the same.  However, when it connects to server 2, it isn't
pulling the familynames from the familyname list correctly.  Instead, it is
pulling single character strings, like a, b, e, g, h, r, S (these are the
actual strings, which may or may not have some bearing on one of my
familyname entries, I haven't been able to verify).  Has anyone else seen
problem remotely related to this?  Any help is appreciated.

Regards,

Mark Daley




From TBryan at UTS.Itron.com  Sun Mar  5 20:19:29 2000
From: TBryan at UTS.Itron.com (Tom Bryan)
Date: Sun, 05 Mar 2000 20:19:29 -0500
Subject: Parsing SQL-Files
References: <38C02CC0.23D2DBA3@weihenstephan.org>
Message-ID: <38C307A1.9B7B546@UTS.Itron.com>

"Dr. Peter Stoehr" wrote:

> I have more than 100.000 lines of SQL code forming a script to create a
> database. Unfortunately, there is no documentation. That's why I'm
> thinking about writing a python based script that parses all the SQL
> statement. 

I did something similar, but it's very limited and special-case.

I had a huge script of "create table" statements but no ER Diagram for 
an Oracle database.  I wrote a script to pull the information about all 
of the tables into Python and to write out (using HTMLgen) a web page 
with all of the tables and columns with many links within the page.

If you want to use it as a starting point for your program, I could 
post it tomorrow.  Let me know if you're interested.

---Tom


From effbot at telia.com  Sun Mar  5 22:24:32 2000
From: effbot at telia.com (Fredrik Lundh)
Date: 5 Mar 2000 21:24:32 -0600
Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Mar  5)
Message-ID: <06B081C4E2C91FF2.AF83611DE3B513A3.B8442F0447C73E32@lp.airnews.net>

    Major New Internet Portal Python Powered!
        http://www.filibuster.org

    On the edu-sig, David Scherer reminds us what CP4E (and
    Python) is all about:
        http://www.python.org/pipermail/edu-sig/2000-February/000098.html
    "CP4E *is* about computers.  It's about the incredibly
    versatile machines sitting on all our desks, and (soon)
    in our pockets and around our wrists and in our clothing
    and cars and walls.  It's about giving ordinary people
    some real control over those objects, the basic tools
    they will need to learn more about them, and the freedom
    to change or extend software that isn't right for them."

    New guidelines for patch contributions:
        http://www.python.org/patches/

    Python's CVS repository can be accessed via the web
        http://cvs.python.org/

    The edu-sig deals with everything related to using Python
    in education (except, perhaps, whether Python should remain
    case sensitive or not).  Great discussions, this far:
        http://www.deja.com/getdoc.xp?AN=580836413
        http://www.python.org/sigs/edu-sig/ 

    The import-sig will design a new architecture for the import
    facilities in Python (to better support embedding, archives,
    installers, etc):
        http://www.deja.com/getdoc.xp?AN=581571482
        http://www.python.org/sigs/import-sig/

    New Python consortium members that we forgot to mention in
    last week's "Python-URL!"
        ASTi: http://www.asti.com
        BeOpen: http://www.beopen.com

    Danny Yee reviews Dave Beazley's Python Essential Reference:
        http://www.deja.com/getdoc.xp?AN=582232970
        http://www.anatomy.usyd.edu.au/danny/book-reviews/h/Python_Reference.html

    How do I add subject lines to mails sent via smtplib?
        Q: http://www.deja.com/getdoc.xp?AN=582370142
        A: http://www.deja.com/getdoc.xp?AN=582411857

    What's wrong with execfile and local variables?
        Q: http://www.deja.com/getdoc.xp?AN=581374635
        A: http://www.deja.com/getdoc.xp?AN=581374636
        A: http://www.deja.com/getdoc.xp?AN=581843072

    How do I best prepare a Python?
        A: http://www.deja.com/getdoc.xp?AN=581198835

    New releases of plotting software
        http://www.deja.com/getdoc.xp?AN=581191243 (gdchart)
        http://www.deja.com/getdoc.xp?AN=582314930 (pxDislin)

    And to round off this week's URL, here's Python poetry
        http://www.deja.com/getdoc.xp?AN=581006163


========================================================================

Everything you want is probably one or two clicks away in these pages:

      Python.org's Python Language Website is the center of Pythonia
          http://www.python.org

      eff-bot's complements this digest with his daily python url
          http://hem.passagen.se/eff/url.htm

      Much of Python's real work takes place on Special-Interest Group
          mailing lists http://www.python.org/sigs/

      Python Consortium emerges as an independent nexus of activity
          http://www.python.org/consortium

      The Vaults of Parnassus ambitiously collects Python resources
          http://www.vex.net/~x/parnassus/   

      Python To-Do List anticipates some of Python's future direction
          http://www.python.org/cgi-bin/todo.py

      Python Journal is at work on its second issue
          http://www.pythonjournal.com

      Links2Go is a new semi-automated link collection; it's impressive
      what AI can generate
          http://www.links2go.com/search?search=python

      Archive probing trick of the trade:
          http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python


Previous - (U)se the (R)esource, (L)uke! - messages are listed here:
  http://purl.org/thecliff/python/url.html
or
  http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21


Suggestions/corrections for next week's posting are always welcome.
  http://www.egroups.com/list/python-url-leads/

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 sanjay08544 at yahoo.com  Thu Mar  2 19:09:02 2000
From: sanjay08544 at yahoo.com (sanjay pradeep)
Date: Thu, 2 Mar 2000 16:09:02 -0800 (PST)
Subject: printing problem
Message-ID: <20000303000902.27956.qmail@web1702.mail.yahoo.com>

hi i want to grab 3 characters and print
them out as they are entered with no space in
between. the following program waits till
all 3 characters are printed, and then prints,
which is close to what i want but not quite.
	

#!/usr/local/bin/python
#  import posix
import string
import curses
def reader():
    win = curses.initscr()
    s = win.getch('noecho')

# tty-example-2.py

import sys

try:
    # windows or dos
    import msvcrt
    getkey = msvcrt.getch
except ImportError:
    # assume unix
    import tty, termios, TERMIOS
    def getkey():
        file = sys.stdin.fileno()
        mode = termios.tcgetattr(file)
        try:
            tty.setraw(file, TERMIOS.TCSANOW)
            ch = sys.stdin.read(1)
        finally:
            termios.tcsetattr(file, TERMIOS.TCSANOW,
mode)
        return ch
def main():
    horky=['y','e','s']
    borky=horky
    alpha=range(3)
    for count in alpha:
      jerk=getkey()
      print jerk,;sys.stdout.softspace=0;
      borky[count]=jerk
      
main()


thanks!
sanjay

__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com



From gmcm at hypernet.com  Sun Mar  5 08:27:48 2000
From: gmcm at hypernet.com (Gordon McMillan)
Date: 05 Mar 2000 13:27:48 GMT
Subject: Calling class objects
References: <38C188AD.1C61F217@flashmail.com>
Message-ID: <38c260d4$0$4306@wodc7nh0.news.uu.net>

Jp Calderone  wrote:

>class Master:
>        def __init__(self):
>                ## some init stuff, like get call the loadClass function
>                ## a few times - this works, printing the results gives
>                ## 
>                playerInitObj = loadClass('Player')
>
>        def connectionMade(self, sock, addr):
>                ## Call the constructor with sock and addr
>                ## This is where it seems to die - CPU usage jumps
>                ## to 100% and the network code stops accepting connections
>                ## - presumably because it is blocking on this call
>                player = playerInitObj(sock, addr)
>
>        def loadClass(name):
>                mod = __import__(name)
>                return eval(name + '.' + name)


>So why doesn't the connectionMade function do what I think it should?

It's difficult to figure out what you think it should do. My guess is this:

import Player
class Master:
  def __init__(self):
    self.playerInitObj = Player.Player()
  def connectionMade(self, sock, addr):
    self.player = self.playerInitObj(sock, addr)

Your Master.__init__ can't possibly work unless you have a global function 
"loadClass" (as written above you'd get a NameError). However, even if it 
did work, it would assign the results of loadClass to a method-local var which 
goes out of scope and gets deleted on the next line. Master.connectionMade 
has the exact same problem.

Because Python does not require variables to be declared, you must explicitly 
use "self" to make a variable belong to the instance.

Since you've hardcoded "Player", I don't see the reason for the dynamic 
import. If you don't want the Player module imported until it's needed, use:

  def __init__(self):
    import Player
    self.playerInitObj = Player.Player()

This has the additional advantage that the second instance of Master won't 
incur the overhead of searching your disk for a module named "Player".



From mhammond at skippinet.com.au  Fri Mar 31 01:41:24 2000
From: mhammond at skippinet.com.au (Mark Hammond)
Date: Fri, 31 Mar 2000 06:41:24 GMT
Subject: Python w/MS Outlook / MS Exchange
References: 
Message-ID: 

Your best bet is to look at testExchange.py in the win32com\test
directory.

For the ultimate in performance you may be better off using
win32com.mapi, but there arent too many samples for that (and the
C++ samples you can find should port quite obviously :-)

Mark.

"Benjamin Schollnick"  wrote in
message
news:rNHvjEdhm5Pp-pn2-LE0bjbfqNid6 at d185d18f2.rochester.rr.com...
> Folks,
>
> I was wondering if anyone has found a way to look up Email
address's,
> etc, in python from a MS Outlook "global" Address book?
>
> Basically, at work we are using MS Outlook, and I want to write
a
> CGI-BIN
> that will take a user name, and list their email information.
> Unfornately, it's a global
> address book out on the outlook server....
>
> Any suggestions on the next step, etc, would be helpful &
> Appreciated.
>
> - Benjamin
>
> ====================================================
>           (Remove "NoSpam" to Email me)
> ====================================================
> Please feel free to copy any and or all of this sig.
> A little something for spam bots:
>
> root at localhost postmaster at localhost admin at localhost
> abuse at localhost postmaster at 127.0.0.1
>
> Chairman William Kennard: bkennard at fcc.gov
> Commissioner Susan Ness: sness at fcc.gov
> Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov
> Commissioner Michael Powell: mpowell at fcc.gov
> Commissioner Gloria Tristani: gtristan at fcc.gov
> consumerline at ftc.gov
> fccinfo at fcc.gov
> ssegal at fcc.gov
>




From edcjones at erols.com  Wed Mar 15 01:02:42 2000
From: edcjones at erols.com (Edward C. Jones)
Date: Wed, 15 Mar 2000 01:02:42 -0500
Subject: Lisp to Python converter?
Message-ID: <38CF2782.F57144E3@erols.com>

Are there any programs that convert Lisp to Python? Lisp to C or
C++?

Thanks,
  Ed Jones




From wware at world.std.com  Mon Mar 13 13:49:52 2000
From: wware at world.std.com (Will Ware)
Date: Mon, 13 Mar 2000 18:49:52 GMT
Subject: Stackless/microthreads merge news
References:      
Message-ID: 

Konrad Hinsen (hinsen at cnrs-orleans.fr) wrote:
> Indeed. But what then are the applications for which one might
> profitably use microthreads? ...Or is it memory efficiency that you
> are aiming for?

Memory efficiency is a big part of it, and context switching should
presumably be faster (tho I haven't clocked it). What motivated my
interest in microthreading was a wish to run thousands or tens of
thousands of threads simultaneously, which started when I went to a
talk by Gerald Sussman on amorphous computing, described at
http://www.swiss.ai.mit.edu/projects/amorphous/
Sussman and his group are interested in studying computing architectures
where so many processors are networked together that you would never
bother to explicitly address a single processor, but just treat them
as a continuous computing substrate. In simulation, however, you still
need to model each of the processors.

Another application that interests me is trying to simulate
microeconomic behavior. There is some work going on in this area now,
mostly following the "artificial life" tradition, designing
economic agents who learn to transact with one another in an abstract
world (e.g. http://www.brook.edu/sugarscape/). I think it would be
more interesting to base models on empirically observed behavior of
real people and businesses.

Games are another possible class of applications. Microthreads would
allow you to code up the behaviors of game characters as independent,
simultaneous actors. These might be spaceships, or staggering zombie
brain-eaters, or Pacman monsters, or naval ships.

The reasons microthreads would be a win in these situations is that
(1) you can practically run several thousand of them simultaneously,
and (2) syntactically they are fairly painless, and therefore good for
the kind of experimental tinkering somebody might do with simulators or
games where raw performance isn't yet a critical need. The complexities
of OS threads probably mean that you wouldn't casually throw hundreds
of them at a back-of-the-envelope simulation.
-- 
 - - - - - - - - - - - - - - - - - - - - - - - -
Resistance is futile. Capacitance is efficacious.
Will Ware	email:    wware @ world.std.com


From owen.corpening at tivoli.com  Thu Mar 23 11:37:05 2000
From: owen.corpening at tivoli.com (Owen Corpening)
Date: Thu, 23 Mar 2000 10:37:05 -0600
Subject: Tangential anti-educationist rant (was: what is easier to learn first?...)
References:   <3E53238E59BADF34.01ECA7E96E32ECCE.EFB19829F3626C71@lp.airnews.net>
Message-ID: <8bdhke$ehl$1@news.tivoli.com>

funny, I thought C was a cinch, very easy to learn and teaches good habits.

owen

Cameron Laird wrote in message
<3E53238E59BADF34.01ECA7E96E32ECCE.EFB19829F3626C71 at lp.airnews.net>...
>In article ,
>Grant Edwards  wrote:
> .
> .
> .
>>more Python.  I'd definitely go with Python.  C is for OS
>>kernels, device drivers, and embedded work.  It really oughtn't
>>be taught to beginners or people who just want to write an
>>application.  C is low-level and unsafe: the programmer's got
>>to do way too much of the housekeeping, and there are countless
>>ways to hang yourself before you've even gotten enough rope out
>>to accomplish anything. -- but at least the semantics are
>>farily simple (assuming you know some assembly language and how
>>compilers work).
> .
> .
> .
>It pretty well captures my impression of
>institutional education that US high
>schools commonly teach C (and C++!) as a
>first programming language.  I find that
>typical of the mental abuse they thought-
>lessly perpetrate.
>--
>
>Cameron Laird 
>Business:  http://www.Phaseit.net
>Personal:  http://starbase.neosoft.com/~claird/home.html




From mhammond at skippinet.com.au  Wed Mar 22 18:44:48 2000
From: mhammond at skippinet.com.au (Mark Hammond)
Date: Wed, 22 Mar 2000 23:44:48 GMT
Subject: COM: Passing arrays, SAFEARRAYs, and BSTRs in connection points
References: <38d8e3f2$0$2941@senator-bedfellow.mit.edu>
Message-ID: <8bblte$3h8$1@nnrp1.deja.com>

In article <38d8e3f2$0$2941 at senator-bedfellow.mit.edu>,
"Robert"  wrote:
> The short form of the question:
> pythoncom seems to convert BSTR/unicode strings to normal python
strings
> automatically. Is there any way of recovering the original raw data?
> I am sending raw chars that are converted to BSTRs through COM to
> a python program. For example I am sending 'test' (4 bytes) in a
> SAFEARRAY/vector,
> convert it to a bstr using BstrFromVector, then send it off to
python, which
> somehow converts it to a string '??' (2 bytes). Is there anyway of
> retrieving the
> original 4 bytes?

You should be using a safe array of type VT_UI1 - this is the type that
most objects (eg, MS Database objects, etc) use for binary data.

When Python recieves a variant of this type, the Python program sees
the 4 bytes returned in a "buffer" object.

If you need to pass a 4 byte buffer to an external COM object from
Python, then you use the buffer built-in - eg:

CallSometing(buffer("test"))

Will cause Python to create a VT_UI1 safearray with the 4 bytes.

Looking at your "long story", it appears you are attempting to do this -
 we only added this feature since 125, so if you are not in 128 then
upgrade, and it should work.  If you _are_ on 128, mail me and we can
sort it out.

Mark.


Sent via Deja.com http://www.deja.com/
Before you buy.


From jayfreeman at earthlink.net  Tue Mar 28 14:47:42 2000
From: jayfreeman at earthlink.net (Jay Freeman)
Date: Tue, 28 Mar 2000 13:47:42 -0600
Subject: Checking for data on a serial port
Message-ID: <38E10C5D.895467C1@earthlink.net>

Howdy,

I'm probably missing something obvious in the docs, but I'd like to have
a way to see if there is any data waiting to be read on a serial port.
I'm doing a touch screen driven app on RedHat 6.1. I've tried two
methods of reading the serial port and they both behave the same way.
I've just opened /dev/ttyS0 for read, and used readline(), and I've
redirected stdin and used raw_input(). Both methods just sit on that
statement and wait until some data comes in. What I'd like to do is
check and see if there is any data, if there is then read it, if not
then check the time against a default timeout value so I can kill some
intermediate screen that the user has walked away from and start the
session over (it's a kiosk). Neither termios or tty modules seem to be
able to do what I want (although termios is handy for flushing extra
touches out of the buffer). Any ideas?

Thanks,

Jay



From jjv5 at nih.gov  Tue Mar 21 12:01:04 2000
From: jjv5 at nih.gov (James Vincent)
Date: Tue, 21 Mar 2000 12:01:04 -0500
Subject: PIL text on SGI
Message-ID: <38D7AAD0.5E6343A8@nih.gov>

Hello,


	Does anyone have success using PIL to create text in an image
on an SGI? I am able to do everything correctly under Linux, but under
IRIX 6.5.6
I get no exceptions, but also no text in any image of any type. Lines,
rectangles,
colors all work, just not text. Any help is appreciated.

			Jim


-- 


James Vincent
jjv5 at nih.gov


From reimunds_rei at yahoo.de  Mon Mar  6 10:37:28 2000
From: reimunds_rei at yahoo.de (Rei)
Date: Mon, 06 Mar 2000 15:37:28 +0000
Subject: MySQL module
Message-ID: <38C3D0B8.1B76A9E9@yahoo.de>

hi there!
anyone to help interpret the following errormessage (invoked by 'import
MySQL')?

ImportError: /usr/lib/python1.5/lib-dynload/MySQLmodule.so: undefined
                      symbol: __rawmemchr

best regards, rei



From greg at perceval.be  Wed Mar  1 11:15:55 2000
From: greg at perceval.be (Gregoire Welraeds)
Date: Wed, 1 Mar 2000 17:15:55 +0100 (CET)
Subject: no pyc file
In-Reply-To: <89jdnr$sg8$1@netnews.upenn.edu>
Message-ID: 

In reply to the message of Samuel Nicolary sent on Mar 1 (see below) :

According to the Python tutorial by GVR, in section 6.1.2 :

Normally, you don't need to do anything to create the spam.pyc file.
Whenever spam.py is successfully compiled, an attempt is made to write the
compiled version to spam.pyc. It is not an error if this attempt fails; if
for any reason the file is not written completely, the resulting spam.pyc
file will be recognized as invalid and thus ignored later. The contents of
the spam.pyc file is platform independent, so a Python module directory
can be shared by machines of different architectures. 
[...]
When a script is run by giving its name on the command line, the bytecode
for the script is never written to a .pyc or .pyo file. Thus, the startup
time of a script may be reduced by moving most of its code to a module and
having a small bootstrap script that imports that module. 

--
Life is not fair
But the root password helps
--

Gregoire Welraeds
greg at perceval.be
Perceval Development team
-------------------------------------------------------------------------------
Perceval Technologies sa/nv	Tel: +32-2-6409194		
Rue Tenbosch, 9			Fax: +32-2-6403154		
B-1000 Brussels			general information:   info at perceval.net
BELGIUM				technical information: helpdesk at perceval.net
URL: http://www.perceval.be/
-------------------------------------------------------------------------------

On Wed, 1 Mar 2000, Samuel Nicolary wrote:

> Date: Wed, 1 Mar 2000 10:42:04 -0500
> From: Samuel Nicolary 
> To: python-list at python.org
> Newsgroups: comp.lang.python
> Subject: no pyc file
> 
> Is there a reason why a pyc file would not be created upon execution of my
> script?
> 
> It is a simple text parcing application.
> 
> Thanks
> --
> Sam Nicolary
> Systems Admin - SOS - ISC
> University of Pennsylvania - Graduate School of Education
> 3700 Walnut Street
> Philadelphia, PA 19104
> (215) 573-5423 Fax - (215) 573-2119
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 
> 




From mfletch at tpresence.com  Mon Mar 13 14:17:00 2000
From: mfletch at tpresence.com (Mike Fletcher)
Date: Mon, 13 Mar 2000 14:17:00 -0500
Subject: Proposal: Weekly FAQ pointer (was Re: Newbie: Is there a faq 
	for this newsgroup?)
Message-ID: 

Writeup is pretty simple...


Subject: Weekly Frequently Asked Questions (FAQ) Pointer
The Python Frequently Asked Questions (FAQ) collection (with searching
capabilities) is available here:
	http://www.python.org/cgi-bin/faqw.py?req=home

The Python FAQ as a single static document is available here...
	http://www.python.org/doc/FAQ.html

Python Software Activity (PSA) members can add new entries to the FAQ (see
the welcome message from the PSA sent when you joined).


Still need someone with presence of mind (or a decent CRON scheduler) to
volunteer to post it every week :) . Enjoy,
Mike

-----Original Message-----
From: aahz at netcom.com [mailto:aahz at netcom.com]
Sent: Monday, March 13, 2000 2:11 PM
To: python-list at python.org
Subject: Proposal: Weekly FAQ pointer (was Re: Newbie: Is there a faq
for this newsgroup?)


In article <38cb9f9a$0$1338 at motown.iinet.net.au>,
Aesop  wrote:
>
>        Been programming in python for, well about 2 days now. Have a whack
>of dumb questions that are probably guaranteed to see me flamed to death.
Is
>there a FAQ anywhere? oe better still anyone got any good links to tutorial
>type sites for people who have not touched a computer language in about six
>or so years?

We've been getting a lot of questions like this lately, despite the
existence of python.org.  I think that a >>very short<< weekly FAQ with
pointers to the five or six most common URLs would be pretty handy.  I'm
willing to write it up if someone else takes the responsibility for
posting it; I'm just not sure whether I should talk to Fred, Barry, or
someone else.  Suggestions?

(Yes, I'm more than aware of the weekly Python-URL!, but that's not
labelled "FAQ" and it's a lot longer than someone who wants a quick
answer to "Where's the FAQ?" will read.)
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>
http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"Along the lines of getting a massage, taking a hot bubble bath, and
swimming in a pool of warm, melted chocolate, can you give me some
innovative ways that you pamper yourself?"
"Spend three hours flaming stupid people on the Net."  --Aahz
-- 
http://www.python.org/mailman/listinfo/python-list



From herzog at online.de  Sat Mar 18 15:14:13 2000
From: herzog at online.de (Bernhard Herzog)
Date: 18 Mar 2000 21:14:13 +0100
Subject: need fast parser for comma/space delimited numbers
References: <1258725464-20166134@hypernet.com> 
Message-ID: 

Les Schaffer  writes:

> >>>>> ">" == Gordon McMillan  writes:
> 
>     >> Second, benchmark against "int" and "float".
> 
> okay. i noticed in the Scientific Python modules K. Hinsen uses

I haven't seen those, but...

> something like this
> 
> numb = exec( str )

..I guess you mean eval()

> with str being things like ' 4.235 ', etc. i wonder which is faster?
> (thinking out loud)

int/float should be faster because eval creates an intermediate code
object which is then executed by the bytecode interpreter. eval has the
advantage that it automatically distinguishes between ints and floats,
though, and other literals and even expressions for that matter.

It is, of yourse a gaping security hole unless you use rexec.


-- 
Bernhard Herzog   | Sketch, a drawing program for Unix
herzog at online.de  | http://sketch.sourceforge.net/


From calishar at *NOSPAM*home.com  Wed Mar  1 19:26:37 2000
From: calishar at *NOSPAM*home.com (Calishar)
Date: Thu, 02 Mar 2000 00:26:37 GMT
Subject: Email/Newsgroup client?
References: 
Message-ID: 

On Wed, 1 Mar 2000 17:17:53 -0500, "Joel Lucsy"
 wrote:

>Are there any that work with win32? I found a couple at the Vault, but
>they're based on unix. I'm looking to replace Outlook Express, and no, I
>don't want anything like Eudora,Gravity,Newsxpress,etc. I'd like something
>mostly/completely python based.

I remember a program called Mahogany Mail, it was a Win32 (based or
compatible) mail client that had python scripting. A quick web search
shows the following URL

http://www.phy.hw.ac.uk/~karsten/M/status.html


Calishar


From python-list at teleo.net  Wed Mar  8 11:19:13 2000
From: python-list at teleo.net (Patrick Phalen)
Date: Wed, 8 Mar 2000 08:19:13 -0800
Subject: Is it Python or is it C ?
In-Reply-To: <004401bf8910$a42da4c0$01ffffc0@worldnet.att.net>
References: <0%hx4.3000$N3.36008@typhoon.southeast.rr.com>  <004401bf8910$a42da4c0$01ffffc0@worldnet.att.net>
Message-ID: <00030808323600.01321@quadra.teleo.net>

[Emile van Sebille, on Wed, 08 Mar 2000]

:: In which case, doesn't that transform the question to 'which
:: preferred pydioms yield the best performing bytecode?'? <*1>

:: *1 


If both the main clause of the sentence and the quotation are
interrogative, only one question mark is used:

"""
In which case, doesn't that transform the question to "which preferred
pydioms yield the best performing bytecode."? 
"""
Note that single quotation marks are incorrect. Reserve singles for
quotations nested in other quotations. (Further quotations within the
nested quotation would again use double quotes.)





From dirck at pacbell.net  Sun Mar 26 01:20:20 2000
From: dirck at pacbell.net (Dirck Blaskey)
Date: Sat, 25 Mar 2000 22:20:20 -0800
Subject: colostomy
References:  
Message-ID: 

Cliff Crawford  wrote in message
news:slrn8dqo5c.4sd.cjc26 at ith1-491.twcny.rr.com...
> * Dirck Blaskey menulis:
>>...
>> Please, PLEASE make colon's optional when not needed.
>> ...
> I actually like the colons.  They seem to make code a little easier
> to read.

I don't dispute their aesthetic value,
but for me, in practice, the requirement gets in the way.
I'm not exactly a new Python user either, I've written
a fair amount of Python code.  I just seem to have trouble
sometimes teaching my hindbrain to remember things
that my frontbrain forgets.
(I HATE learning a new text editor.)

I'm willing to bet I'm not the only coder who forgets to put
them in on a regular basis.  And since they're not really necessary,
they should at least be optional.

(The best approach for handling User Input errors
 isn't to provide a good error message,
 but to eliminate the possibility of error.)

>
>> I waste a lot of time going back and filling in the bloody things.
>
> After I learned Python, I had the same problem at first with C and
> semicolons.  I'm not sure why I hate semicolons as EOL markers, but
> like colons as block markers; I guess one is too much redundancy
> while the other is just the right amount. 

After many (10+) years of heavy (Heavy) C coding, I still would
occasionaly forget to type in semi-colons -
and now when typing Python I occasionaly add them in without thinking.
Fortunately, Python is cool enough not to complain.

>> The only other suggestion I have, and this isn't nearly as important:
>> it would be nice to have block comments like c's /* */ ...
>
> You can enclose the comment in """...""".  You can have strings
> anywhere where a statement is expected.

I hadn't known """ was allowed as a block comment -
I had thought doc strings were the only block option.

thanks for the tip,

d
===========================
Dirck Blaskey
Danbala Software
dirck at danbala.com
http://www.danbala.com





From aahz at netcom.com  Wed Mar  8 18:17:11 2000
From: aahz at netcom.com (Aahz Maruch)
Date: 8 Mar 2000 23:17:11 GMT
Subject: FTP hangs with urllib.urlretrieve
References: 
Message-ID: <8a6n1n$vpk$1@nntp6.atl.mindspring.net>

In article ,
Michal Wallace (sabren)  wrote:
>On Tue, 7 Mar 2000, Oleg Broytmann wrote:
>> 
>>    I am developing/running URL checker (sorry, yet another one :). And
>> found that I have consistent hangings on some FTP URLs.
>> 
>>    Here is test program I am using to retest my results - just URLopener
>> and urlretrieve, nothing magical; python is stock 1.5.2, hangs on all
>> platforms I am using - Pentium Linux, Sparc Solaris, Pentium FreeBSD:
>
>This is not limited to ftp urls... urllib just hangs sometimes.

I've submitted a patch that gives httplib.HTTP() a default timeout that
fixes these kinds of problems, but Guido hasn't accepted it yet.  If
someone wants to help me provide the info that Guido wants, I'd really
appreciate it.  Once that's done, it should be straightforward to patch
ftplib to have the same kind of timeout.
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"Along the lines of getting a massage, taking a hot bubble bath, and
swimming in a pool of warm, melted chocolate, can you give me some
innovative ways that you pamper yourself?"
"Spend three hours flaming stupid people on the Net."  --Aahz


From darogers at xnet.com  Fri Mar 24 17:56:58 2000
From: darogers at xnet.com (David A. Rogers)
Date: 24 Mar 2000 22:56:58 GMT
Subject: python / COM question
Message-ID: 

I'm learning COM and want to use python to test the objects I'm creating.  I
immediately ran into a problem.

I have an interface with a function like so:

	STDMETHOD(GetDate)(int* year, int* month, int* day);

How do I call this from python when all python functions are pass by value?

Thanks for any help,
dar



From corg at copernic.com  Mon Mar  6 08:54:35 2000
From: corg at copernic.com (Gaetan Corneau)
Date: Mon, 6 Mar 2000 08:54:35 -0500 
Subject: Self Nanny
Message-ID: 

> Yes, I went so far as to define a macro so I could use self.* in C++. 

Ah, c'mon guys: having to declare self may or may not be fun, but the fact
is that it is a gotcha for newbies, so I think self should be passed
implicitly to methods.

Remember: it's stuff like that that turns new users
off.______________________________________________________
   Gaetan Corneau
   Software Developer 
   Copernic Technologies inc. 
   http://www.copernic.com
   E-mail: corg at copernic.com                         
______________________________________________________
"Tu l'as trop ?cras?, C?sar, ce Port Salut"


-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/B/MU d- s+:++ a C++ 
UL+ P--- W+ N- K- W++ t-- 
!5 X- R+ tv-- b++ DI++ 
G e++ h---- r+++ y++++
------END GEEK CODE BLOCK------




 



From gregm at iname.com  Thu Mar  9 06:17:19 2000
From: gregm at iname.com (Greg McFarlane)
Date: Thu, 9 Mar 2000 22:17:19 +1100
Subject: TK Notebook with Tabs on the bottom
In-Reply-To: <38C4217C.B5CADA8F@exceptionalminds.com>; from Timothy Grant on 06 Mar 2000 at 01:22:04PM
References: <38C4217C.B5CADA8F@exceptionalminds.com>
Message-ID: <20000309221719.58051@nms.otc.telstra.com.au>

Currently Pmw.NoteBook only accepts 'n' and None as values for the
'tabpos' option.  The others ('s', 'e' and 'w') are on the Pmw todo
list.  If anyone would like to contribute ...

On 6 Mar, Timothy Grant wrote:
> Hi all,
> 
> Does anyone have a Tkinter notebook widget with tabs on the bottom? I've
> used the Pmw.Notebook widget successfully, but I haven't been able to
> figure out if those tabs can be moved to the bottom or not.
> 
> I have some rememberance of seeing a widget that would allow you to
> place the tabs wherever you want, but I can't find it, so I'm beginning
> to wonder if I dreamt it!
> 
> -- 
> Stand Fast,
>     tjg.
> 
> Chief Technology Officer              tjg at exceptionalminds.com
> Red Hat Certified Engineer            www.exceptionalminds.com
> Avalon Technology Group, Inc.                   (503) 246-3630
> >>>>>>>>>>>>Linux...Because rebooting isn't normal<<<<<<<<<<<<
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 

-- 
Greg McFarlane     INMS Telstra Australia     gregm at iname.com



From python-list at teleo.net  Mon Mar  6 20:00:56 2000
From: python-list at teleo.net (Patrick Phalen)
Date: Mon, 6 Mar 2000 17:00:56 -0800
Subject: 11-digit integer literal on a 32-bit CPU
In-Reply-To: <0003061647130K.03962@quadra.teleo.net>
References: <0003061647130K.03962@quadra.teleo.net>
Message-ID: <0003061702560L.03962@quadra.teleo.net>

Oh. I should add that the ID needs to be included in a delimited text
data file, so 10000000000L doesn't work.


[Patrick Phalen, on Mon, 06 Mar 2000]
:: I need to assign an 11-digit Transaction ID, according to specs I'm
:: given by a client.
:: 
:: Begin with 10000000000
:: 
:: Increment by 1 for each new transaction -- 10000000001, etc.
:: 
:: (Store as string in a file between transactions)
:: 
:: As an integer literal, this overflows on an Intel CPU.
:: 
:: What's a nice trick for dealing with this?
:: 
:: Total transactions aren't likely to exceed 999,999
:: 
:: -- 
:: http://www.python.org/mailman/listinfo/python-list



From jcw at equi4.com  Thu Mar  2 14:31:29 2000
From: jcw at equi4.com (Jean-Claude Wippler)
Date: Thu, 02 Mar 2000 20:31:29 +0100
Subject: MetaKit for python (Mk4py) on Macintosh ... no way :(
References: <1260348438-26442187@hypernet.com> <87vh36ob49.fsf@den.home.net> <87ln42dzbw.fsf@den.home.net>
Message-ID: <38BEC18E.D2A01466@equi4.com>

Frank,

> Of course, I meant to say 'I have NOT figured out how to do that
> yet with Mk4py'.

Perhaps the following helps:

import Mk4py
db=Mk4py.Storage()
vw=db.getas("people[name:S,age:I,weight:F]")
vw.append(name='Tarzan',age=34,weight=45.6)
vw.append(name='Jane',age=23,weight=34.5)

props = vw.structure()
for r in vw:
	for p in props:
		print getattr(r,p.name),
	print

Please consider posting MetaKit-specific questions on the MK-Scripting
mailing list, see http://sourceforge.net/mail/?group_id=736

-- Jean-Claude


From aahz at netcom.com  Thu Mar  9 10:28:34 2000
From: aahz at netcom.com (Aahz Maruch)
Date: 9 Mar 2000 15:28:34 GMT
Subject: Duplicates in lists
References: <38C748C7.35162A7B@teleatlas.com>
Message-ID: <8a8fv2$327$1@nntp6.atl.mindspring.net>

In article <38C748C7.35162A7B at teleatlas.com>,
Michael Husmann   wrote:
>
>is there someone who has an efficient function that finds all
>duplicates in a list?  I used a hash which works quite reasonable but
>maybe there is a better way.

If you're already using a dictionary, you'll only be able to do
micro-optimizations; your basic algorithm is the best available in
Python.  If you want us to show you how to optimize Python code, post
what you've got here.
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"Along the lines of getting a massage, taking a hot bubble bath, and
swimming in a pool of warm, melted chocolate, can you give me some
innovative ways that you pamper yourself?"
"Spend three hours flaming stupid people on the Net."  --Aahz


From embed at geocities.com  Wed Mar  8 10:47:32 2000
From: embed at geocities.com (Warren Postma)
Date: Wed, 8 Mar 2000 10:47:32 -0500
Subject: What If Python Replaced Elisp?
References: 
Message-ID: 

Why rewrite EMACS? Why not start from scratch with Python and see what
develops?

I never learned EMACS because I hated LISP. I took a LISP course in 2nd year
CompSci.  Blech!

I would love an Editor written in Python, scriptable in Python.  IDLE is
great except for when I need to use a command line machine. In fact, I find
a text screen less distracting when I'm writing reams of code.  I think a
Python+Curses based editor would be great. Does such a beastie exist?

Warren




From landauer at apple.com  Thu Mar  2 17:35:32 2000
From: landauer at apple.com (Doug Landauer)
Date: Thu, 02 Mar 2000 14:35:32 -0800
Subject: Python bindings for Apple's Foundation and AppKit ???
References: <87tkoi$hql$1@nntp1.atl.mindspring.net> <8ED6BCFDChdjsdhdfh75738@news.sshe1.sk.wave.home.com>  <38BDDFFD.F8B83BCE@mindspring.com>
Message-ID: 

echuck at mindspring asks questions unrelated to the posting he's
following up on...

Lemme shake up this 8-ball...

> So when is Apple going to provide Foundation and AppKit bindings for Python

Reply hazy, try again later.

> and support the language in Project Builder? :-)

Reply hazy, try again later.


Dang, it must be broken.
 
> (Or are you one of those Carbon people...)

Well, when I step on the old spectrometer, it says that there's Carbon
somewhere in there, as well as Nitrogen, Oxygen, Hydrogen, and Chocolate,
but no, I don't work on Carbon.  Or AppKit or Foundation.  Just gcc.  I
barely have time to just compile up a bare python (not even shared-libraries
or a readline library) for my own use, let alone write bindings for something
the size of AppKit.

I haven't even managed to convince them to ship Python on the
system yet :-( -- I just use it to make little tools to help me debug
stuff.
-- 
    Doug Landauer        landauer at apple.com (work)
                         landauer at scruznet.com (not-work)


From scarblac-spamtrap at pino.selwerd.nl  Wed Mar 15 08:37:58 2000
From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich)
Date: 15 Mar 2000 13:37:58 GMT
Subject: Should Python documentation for __class__ be improved?
References: 
Message-ID: 

Tom Funk wrote in comp.lang.python:
> While tracking down the UserList problems I've previously discussed I ran 
> across this line of code in UserList.__getslice__():
> 
>     userlist = self.__class__()
> 
> I'd never seen this idiom before and I wasn't sure exactly what was going 
> on.  So I started tearing up the Python docs looking for an explanation.  
> 
> I found a number of references to __class__, all of which made it look as 
> though __class__ was an attribute, rather than a method (though it's not 
> technically a method either).  Nowhere did I find anything that said  
> that __class__ was callable.  Also, there are *no* examples of calling 
> __class__() anywhere in the docs.

Well, it's not really 'callable'. __class__ *is* just an attribute. It's
just a reference to a class. And you can make an instance of a class.

class A:
   pass
   
a = A()

Now A == a.__class__.

So, obviously,
x = A()
now means the same thing as
x = a.__class__()

It's never explained that you can make an instance of __class__, since you
can make an instance of any class, and this one isn't any different. It's
slightly confusing that making a class instance looks like a function call.

-- 
Remco Gerlich,  scarblac at pino.selwerd.nl
  Murphy's Rules, "I sense... golden arches":
   In Original D&D, some swords had the ability to 'detect meal and what
   kind.'


From tismer at tismer.com  Thu Mar  2 15:51:56 2000
From: tismer at tismer.com (Christian Tismer)
Date: Thu, 02 Mar 2000 21:51:56 +0100
Subject: stackless/microthread merge
References:  <38BD197A.4F9E93C1@tismer.com> <9sxv4.28865$Jz3.173654@nnrp1.uunet.ca>
Message-ID: <38BED46C.905A5B9@tismer.com>


Warren Postma wrote:
[skipping nice words - thanks :-)]

> I can see stackless+microthread going on to challenge regular python by very
> careful optimizations at it's core. I'm seriously going to consider using
> this for my embedded control [SCADA, Radio Telemetry] uses, because I think
> thread latency is a pretty key part of any complex control system.

We're doing our best. For my part, I'm writing the fastest possible
but still flexible scheduler kernel that I can consider. Due to
Will's input, it has builtin thread locking already, to provide
atomic operations. But the stuff beyond the absolute basics
(which is about two or three extra support functions), everything
is done by Python, and people can implement their own thread
implementation on top of it.
Will will be the first one, of course. :-)

> I can't wait to see what this looks like when it's finished! :-) Very very
> cool!

I'm finishing the last function, so it will probably be less than
a week, unless I see a hairy bug.

cheers - chris

-- 
Christian Tismer             :^)   
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home



From helge.hess at mdlink.de  Thu Mar 30 10:30:15 2000
From: helge.hess at mdlink.de (Helge Hess)
Date: Thu, 30 Mar 2000 17:30:15 +0200
Subject: multiple interpreter sessions
Message-ID: <38E37307.18E5CFD0@mdlink.de>

Hi,

as far as I can see Python allows only one interpreter instance to be
embedded, right ? Is that already recognized as a problem or don't
people care ?

I would like to have separate Python runtimes in a single server, so
that they don't affect each other (eg for security and state reasons).
Is that going to be addressed in Python 1.6 or 2.0 ? Maybe someone
already has modified Python to support such stuff ?

Thanks
  Helge Hess


From spooky at dreamfish.org.uk  Fri Mar 31 05:05:09 2000
From: spooky at dreamfish.org.uk (Robert Longstaff)
Date: Fri, 31 Mar 2000 11:05:09 +0100
Subject: CGI support question
In-Reply-To: 
References: 
Message-ID: <00033111134600.00753@fishology>

> Can anyone tell me of an ISP who supports python in the UK? Or even better
> would be a site that would give me free space who supports Python.
>

You could try UK Shells (http://www.ukshells.co.uk). They provide UNIX shell
accounts with webspace and support CGI/SSI. Last time I looked they had Python
v1.5.1 installed so you could use that for your CGI.

An account is about 90 pounds per year (including VAT) for which you get 50MB.

Aside: I've got an account on UK Shells and am currently developing an app
that I'll test (and maybe even run) there, so I might ask them to upgrade to
v1.5.2 ;)

Robert.



From helpdesk at perceval.be  Thu Mar 16 05:29:30 2000
From: helpdesk at perceval.be (Gregoire Welraeds)
Date: Thu, 16 Mar 2000 11:29:30 +0100 (CET)
Subject: CVS acces via Python
Message-ID: 

Hi,

Is there any module that I can use to access a cvs with Python ?


--
Life is not fair
But the root password helps
--

Gregoire Welraeds
greg at perceval.be
Perceval Development team
-------------------------------------------------------------------------------
Perceval Technologies sa/nv	Tel: +32-2-6409194		
Rue Tenbosch, 9			Fax: +32-2-6403154		
B-1000 Brussels			general information:   info at perceval.net
BELGIUM				technical information: helpdesk at perceval.net
URL: http://www.perceval.be/
-------------------------------------------------------------------------------




From r.barendregt at village.uunet.be  Mon Mar 20 17:58:57 2000
From: r.barendregt at village.uunet.be (Robin Barendregt)
Date: Mon, 20 Mar 2000 22:58:57 GMT
Subject: Question about instance creation
References: <1258533308-31724431@hypernet.com>
Message-ID: <38d6aa4b.49104330@news.pandora.be>

"Gordon McMillan"  wrote:

>So, I haven't the foggiest idea *what* you're trying to do. 
>However, this might help clarify things.

My apologies. I'll try to be more precise (the example didn't
illustrate well what I wanted to do):

I have a derived class that I want to make instances of. I want to be
able to change the base class (hence the alias) and I can't just
create an instance of the base class and forget all about the derived
class, because the derived class inherits from another class as well.
So the derived class instance acts like a base class instance with the
extra functionality as defined in the other class. The def looks like
this:
class DerivedClass(BaseClassAlias, SomeOtherClass):

I do not even know if I'm searching in the right direction to get to
above mentioned result. I guess I could change the base class alias
and then directly instantiate the derived class. Any other ideas?

Robin.


From gmcm at hypernet.com  Sat Mar 11 16:58:37 2000
From: gmcm at hypernet.com (Gordon McMillan)
Date: Sat, 11 Mar 2000 16:58:37 -0500
Subject: not at Python Bugs -- __builtins__ madness
In-Reply-To: 
Message-ID: <1259310576-5365836@hypernet.com>

> Could some please explain how Python makes this mistake?
> 
>   jeffp at friday [4:15pm] bin #324> python
>   Python 1.5.2 (#1, Apr 20 1999, 08:57:03)  [GCC 2.7.2.3] on sunos5
>   Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>   >>> __builtins__
>   
> 
> It got the module name wrong.  Unless Python treats __builtins__ THAT
> specially, that's a major goof.  And the 1.5.2 docs say it's
> __builtin__.  This boggles my poor mind.  I'm checking Python Bugs...

No mistake. __builtin__ is a module. __builtins__ is a name 
which normally refers to __builtin__, but may not (eg, in 
restricted execution).

- Gordon



From breiter at usf.Uni-Osnabrueck.DE  Tue Mar  7 09:35:19 2000
From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter)
Date: 7 Mar 2000 14:35:19 GMT
Subject: Compile without execute for syntax check?
Message-ID: <8a3437$er1$1@newsserver.rrzn.uni-hannover.de>

The python interpreter in the non inspecting mode(default) finds
some python syntax errors directly before running the code.

Call me old fashioned, but the documentation is not clear about how
to use this build-in syntax check on scripts without executing them.
Nothing in the FAQ ether.

Yes, I should be able to do an
	import py_compile
	py_compile.compile("myscript.py")

which can degenerate into
	python -c "import py_compile; py_compile.compile('myscript.py')"
and might create python bytecode files.
And pythonwin of course has this as a nice button upfront.

So why nothing in the python manpage (where I looked first) in the
FAQ (second) look or in the library documentation?

The answer seems obvious: Just make everything a module then you can
compile it and run the test function in the same moment within
actually doing harm. This is certainly a healthy attitude, but
sometimes I do not want to run a testfunction, I just want the
syntax checked. :)

Just-proposing-another-documentation-improvement-to-learn-the-best-way-ly,
Yours
	Bernhard

ps.: Do I gain speed if I execute script, which I compiled with
py_compile, like "python myscript.pyc"  instead of "python myscript.py"?
-- 
Free Software Projects and Consulting 		         (intevation.net)  
Association for a Free Informational Infrastructure            (ffii.org)


From wware at world.std.com  Mon Mar 13 07:03:53 2000
From: wware at world.std.com (Will Ware)
Date: Mon, 13 Mar 2000 12:03:53 GMT
Subject: Stackless/microthreads merge news
References:  
Message-ID: 

Konrad Hinsen (hinsen at cnrs-orleans.fr) wrote:
> Looks great! One question: are there any provisions to use
> microthreads in C extension modules? If yes, is the Python interpreter
> (the modified one) thread-safe for microthreads, or is there still
> something like the global interpreter lock? Getting rid of that would
> be reason enought to switch to microthreads for me.

Chris wrote all the C code, and he can give better answers. I'm inclined
to say you should be able to do everything in C that the manual shows
being done in Python but of course the syntax would be much uglier. Also,
I'm not 100% certain of that, because running Python code causes a
counter (called uthread_ticker) to count down, and when it hits zero,
a context switch occurs, and to you that appears to be an invisible
background task. So you'd need to explicitly step down that counter and
allow the context switching code to run, and I'm not sure how you'd do
that unless you allowed yourself to return out to the Python world. So
the simplest thing would be to arrange your computation as a bunch of
limited-duration steps, each of which could be a call from Python. That's
probably not what you're looking for, maybe Chris will have a more
satisfactory idea.
-- 
 - - - - - - - - - - - - - - - - - - - - - - - -
Resistance is futile. Capacitance is efficacious.
Will Ware	email:    wware @ world.std.com


From nobody at nowhere.nohow  Sun Mar 26 22:51:58 2000
From: nobody at nowhere.nohow (Grant Edwards)
Date: Mon, 27 Mar 2000 03:51:58 GMT
Subject: Newbie - help in opening and reading a file from >>>
References:  
Message-ID: 

On Sun, 26 Mar 2000 21:17:37 GMT, Jerome Chan  wrote:
>
>> I've just installed 1.5 on my Windows 98Se system
>> I'm trying to execute the following-
>> >>>f=open('C:\Autoexec.bat')
>> and I get a no such directory or file error
>> Is there some parameter or path that I must set?
>>  Would apprecaite any clues...
>
>You must escape the \?

Back in the bad old days, I always used forwards slashes when
programming under DOS for just this reason (it also made them
more portable when moving code between DOS, VMS, and Unix).
Does win32 still accept forwards slashes in pathnames the way
DOS used to?

-- 
Grant Edwards                   grante             Yow!  My life is a patio
                                  at               of fun!
                               visi.com            


From quinn at triskaideka.ugcs.caltech.edu  Mon Mar 13 16:05:58 2000
From: quinn at triskaideka.ugcs.caltech.edu (Quinn Dunkan)
Date: 13 Mar 2000 21:05:58 GMT
Subject: Extention to the integer class.
References: 
Message-ID: 

On Mon, 13 Mar 2000 18:25:05 +0100 (CET), Gregoire Welraeds 
wrote:
>In reply to the message of Anthony J Wilkinson sent on Mar 14 (see below) :
>
>> Alternatively you could use a __call__ method:
>>         def __call__(self):
>>             return self.__val
>
>This works great. It also avoid to implement __cmp__() since i can do:
>while i() < 2:
>	...
>
>Thanks too :)

Also note that you can use __coerce__:
class Int:
    def __init__(self, val):
        self.__val = val
    def __int__(self):
        return self.__val
    def inc(self):
        return Int(self + 1)
    def dec(self):
        return Int(self - 1)
    def __repr__(self):
        return repr(self.__val)
    def __coerce__(self, other):
        return (int(self), other)

Your original one mutated itself, but hopefully you didn't really mean that :)
And this one should probably have __add__ etc.

Of course, lists and tuples still won't attempt to coerce their index to an
int, but then you could do:
class CoerceList(UserList.UserList):
    def __getitem__(self, i):
        return self.data[coerce(i, 0)[0]]
    ... etc for setitem, has_key ...

But this seems like a lot of work just to add two methods (and it's gonna be
slow if you use it a lot).  Everyone knows what i = i + 1 means, and it's not
that hard to type.  On the other hand, IMHO it's a problem with python that
you can't subclass built-in types.

But __coerce__ is tons of fun.  If you ever find yourself bored, go through
all your code and make it use __coerce__ extensively.  After that, you'll
never have a dull moment again.


From dan at cgsoftware.com  Wed Mar  1 15:40:06 2000
From: dan at cgsoftware.com (Daniel Berlin)
Date: Wed, 1 Mar 2000 12:40:06 -0800 (PST)
Subject: will python 3000 break my code?
In-Reply-To: <38BD6C19.CB058A2@roguewave.com>
Message-ID: 

> 
> No, it's a design change by a standards committe, that has evaluated all the
> options, giving individual vendors the chance to veto any changes that would be
> too radical for their customers (I know, I've been there).  It's an enormous leap
> from that to deciding that list.append(1,2,3) might be so confusing to some
> newcomers that people who know what they were doing have to change their code
> (ask Frederik if he doesn't have more interesting things to do than fixing
> multiargument appends ;-)
Actually, it's not a design change in about 95% of the incompatible
changes in g++. It's just the implementation happened to be allowing
illegal (by the language standard) things because nobody had gotten around
to saying "that's illegal". It's not a world away from deciding that
something that was never legal in the first place, and was accepted, is
now 
not accepted.

> > Should people stop fixing bugs in the python implementation cause some major
> > customer has programmers who wrote buggy code?
> > Nope.
> 
> Was this a bug?  Not really.  Was it a source incompatible design change? You
> bet.

Not a bug?
Can you point out where it says  in the documentation, that this is
allowed?
If you can point out where it says this was supposed to be allowed, i'll
happily agree that it's a source incompatible design change, and thus, is
a bad thing (TM).
 > 
> >
> > God damn it. It's not a feature. It's a bug. A bug. It should have been an
> > error nit he first place. It's only by the grace of Guido and a slip of the
> > eye that it wasn't.
> 
> And nobody would have complained if it _was_ an error in the first place.
I'll give you that.
But sometimes things slip through.

> 
> >    | the-days-of-legacy-code-are-upon-us'ly y'rs
> > No they aren't.
> 
> If you're going to have any luck getting a company (vs. individual dedicated
> programmers) to use your tools, is if the tools are stable enough that a company
> doesn't have to spend money every time you do a new release.  If you do think a
> change is neccessary, and they often are although I'm not sure this particular
> one rises to that level, you should at least warn customers by upping a major rev
> number (or waiting until it's time to do so).
> 
I have companies that use my tools.
They are stable.
When people report bugs,I fix them.
I don't retroactively decide that things that were features are now bugs.
Which is what you seem to be trying to say is happening here.
Look. I'll hapilly agree that if that were the case, it'd be wrong to just
change it without warning.
That would be legacy code.
If it's not the case, then the cod eis not legacy code, it's buggy code.
Regardless of how long it worked for, it's still buggy.

> The-price-of-purity-is-obscurity'ly y'rs
> -- bjorn

> 
> ps: since Guido hath spoken, there really is no reason to discuss this further,
> so this'll have to be my last words on the issue -- I know we're all heartbroken
> 
> 
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 




From tuttledon at hotmail.com  Wed Mar 22 18:03:07 2000
From: tuttledon at hotmail.com (Don Tuttle)
Date: Wed, 22 Mar 2000 23:03:07 GMT
Subject: Does Guido Have A Will? (The legal kind )
References:  <3110C5495705440B.A7540016610C3F64.6B294A66CE5E80A1@lp.airnews.net>  
Message-ID: 

Eh...... I own his 1st edition of The New Hackers Dictionary.  I
bought it back in '92 but had forgotten his name.

Don





From wware at world.std.com  Thu Mar 16 10:00:23 2000
From: wware at world.std.com (Will Ware)
Date: Thu, 16 Mar 2000 15:00:23 GMT
Subject: Chat system
References: 
Message-ID: 

Chris Armstrong (punck at SpamIsBadPenguinPowered.com) wrote:
> Another thing about the chat system: I need for it to be able to constantly
> stream in new content while still being able to type in your message and
> send it whenever you want. I know some programs like IRC clients do
> this without having two processes (one for the streaming content and
> one for the input). Oh, and one more thing, this'll all be using curses,
> if it matters.

You might be able to use microthreads, which should be available within
a week or two. The URL is
http://world.std.com/~wware/uthread.html
I'm not familiar enough with curses to know if there'd be any
incompatibility. I'd be interested in how things turn out; a few weeks
ago I emailed an economics professor, the author an educational
microeconomics simulator currently running in Vax Basic, who would like
to make his simulation web-based and run interactive sessions across the
country. The URL for his simulator is
http://ecedweb.unomaha.edu/ecosim.htm
I myself haven't done anything like an interactive web-based game and it
would be silly to try to reinvent the whole thing myself. Is there a URL
where I can read more about your project? Thanks.
-- 
 - - - - - - - - - - - - - - - - - - - - - - - -
Resistance is futile. Capacitance is efficacious.
Will Ware	email:    wware @ world.std.com


From phd at phd.russ.ru  Tue Mar 14 11:00:33 2000
From: phd at phd.russ.ru (Oleg Broytmann)
Date: Tue, 14 Mar 2000 16:00:33 +0000 (GMT)
Subject: Simple string formatting question
In-Reply-To: 
Message-ID: 

On Tue, 14 Mar 2000, Matthew Hirsch wrote:
> print '%5.3f %5.3f %5.3f 1i'% 
> (temp_list[0],temp_list[1],temp_list[2],temp_list.index(min(temp_list)) 
> + 1)
> 
> but it won't fit on one line.  It keeps thinking that I have two 
> separate incomplete statements.  What is the correct way to get around 
> this problem?  Thanks for your help.

print '%5.3f %5.3f %5.3f 1i'%  \
(temp_list[0],temp_list[1],temp_list[2],temp_list.index(min(temp_list)) + 1)

   (backslash is escape character; escaping end-of-line means continue)

Oleg.
---- 
    Oleg Broytmann      Foundation for Effective Policies      phd at phd.russ.ru
           Programmers don't die, they just GOSUB without RETURN.




From robinhat at rhk.dk  Sat Mar 11 10:08:44 2000
From: robinhat at rhk.dk (Lars Hoeyrup Jensen)
Date: Sat, 11 Mar 2000 16:08:44 +0100
Subject: How to handle timed out connections
Message-ID: <38CA617C.37948FB9@rhk.dk>

I have a program that tries to connect to a certain web page with
urlopen(). Sometimes the page doesn't respond: if I try to open it in
Netscape, after a couple of minutes I get a message like this:

"ERROR

The requested URL could not be retrieved

.....

(110) Connection timed out

...

Generated by .... (Squid/2.2.STABLE4)"


How do I handle this in Python? I would like to generate a message
like "The page is currently down" or something if the page doesn't
respond, but I don't know how to "detect" this timeout in Python.

Thanks in advance,
Lars



From boud at rempt.xs4all.nl  Thu Mar 30 10:01:05 2000
From: boud at rempt.xs4all.nl (Boudewijn Rempt)
Date: 30 Mar 2000 15:01:05 GMT
Subject: Rational-Rose and Python ...
References: 
Message-ID: <8bvq7h$gvn$1@news1.xs4all.nl>

Kiss, Arpad  wrote:

> http://boa-constructor.sourceforge.net/

Dash it! I was looking for boaconstructor, without the dashed dash...

-- 

Boudewijn Rempt  | http://www.valdyas.org


From hathawa2 at marshall.edu  Tue Mar  7 13:09:03 2000
From: hathawa2 at marshall.edu (Mark Hathaway)
Date: Tue, 7 Mar 2000 13:09:03 -0500
Subject: Self Nanny
References: 
 
Message-ID: <38C5709D.59E8@marshall.edu>

>> Gaetan Corneau  writes:
>>
>> OK, I didn't make myself clear :)

> Lloyd Zusman wrote:
>
> Yes you have, at least for me.

me too

>> GC:
>>
>> 1) *I* don't mind having to specify "self" in method definitions
>>
>> 2) *I* don't mind having to write "self.Something"
>>
>> 3) BUT I think that it would be *nice* not to have to specify "self" in
>> method definitions, and it would certainly help A LOT of newbies
>>
>> 4) if possible at all, not having to write "self.Something" would be cool,
>> but not as important as #3
>>
>> And don't tell me #3 can't (technically speaking) be done :)

Personally, I'd rather not ever have to write 'self' or 'self.anything'.
It contributes nothing to the code and doesn't describe what I'm trying
to write. It's extra verbosity without any payoff.

Was there a problem with doing it the other way around...

    class aClass:
        def __init__(self,number):
            self.num = number
            n = self.num

    class aClass:
        def __init__(number):
            local.n = number

where the roles are reversed. All object attributes are
referred to by their names and any class (global) attributes
are specified by "local.". This would decrease tremendously
the need to write 'self.' and would still easily allow the
differentiation of class-wide attributes from object attributes.

Which do you write more of? Object attribute names.
Why make that the more verbose version?

> LZ:
>
> Of course #3 can be done (technically speaking).  And in return for it
> getting done, would you volunteer to donate your personal time to
> change all the existing lines of Python code in the world that this
> change would break?

This is both true and annoying. In our search for better ways to do
things we keep running into this barrier that languages are written,
tried and much time & effort put into that trial. Then when someone
says, "Couldn't we do it better this way?", the answer is, "But, we've
put so much work into this..."

Somehow there has to be a willingness to put the effort in and then,
if it's not as perfect as we'd like, throw it away and start with
another
piece of whole cloth. Well, perhaps we could write a translator to
convert
the old to the new. That wouldn't take quite as much man-power, would
it?

> Or barring that, would you be willing to pay for the time of all the
> others who would have to do this work?

Pay? Who paid the first time? Didn't most of the Python code come about
because people liked the language and just wrote stuff to be distributed
via the internet for free? O.K. here's a penny. Ya satisfied?

I know you're saying people's time & effort is considerable. All I'm
saying
is there should be ways to move to new better ways of doing things
without
having to face such stiff resistance.


> This is not an issue about "caring" about C++ programmers.  I am a C++
> programmer, and literally hundreds of my colleagues over the past
> decade or so have been C++ programmers.  Many of these people have
> tried Python.  And *none* of them have ever even made a complaint
> about the explicit "self" of Python.  You are the first C++ programmer
> I have encountered who has ever raised this as an issue.  That's one
> out of hundreds of people.

Perhaps they are simply more accepting of what is, and don't challenge
it.
That doesn't mean they haven't thought about it. I'm not a C++
programmer,
so I don't know either.

> And as I have mentioned in another post, I challenge you to come up
> any signficant number of people who would be glad to use Python if
> only it didn't have an explicit "self".

It's not just about that issue. It's about an effort to move toward
something better. You're not against that altogether, are you?

> Your arguments have always been clear.  And they are still rather
> unconvincing.
>  Lloyd Zusman
>  ljz at asfast.com


A closed mind can't even be convinced by the truth or a stick up side
the head.


P.S. I like Python. I'm still learning it (a real newbie). I even accept
     the indentation rule.  :-)


Mark Hathaway
e-mail: hathawa2 at marshall.edu


From kojo at tamu.edu  Mon Mar 27 16:27:16 2000
From: kojo at tamu.edu (Kojo Idrissa)
Date: 27 Mar 2000 21:27:16 GMT
Subject: JPython vs. Javascript?
References: <38DF007A.64AFBE6E@tamu.edu> 
Message-ID: <8bojnk$3g8$1@news.tamu.edu>

Thanks for the response.  I'm aware that Java !=Javascript, but I guess my 
general question was more of a "Java Applet vs. Javascript" question, not a 
"JPython vs Javascript" question.  I thought that might be the case.  It's just 
that since I don't really know Java, the way I was going to make applets was 
through JPython.  From your response, it looks like the functionality of the 
two is very different.  You're right, I basically want to add some functions to 
static web pages...mostly the ability to have people be able to "respond" to a 
page or set of pages and have their repsonses sent to me for analysis.  Ah, the 
life of a researcher.

Thanks again, and if there's anything I've missed or am overlooking, please let 
me know.

In article , cpr at emsoftware.com says...
>
>I think you're conflating Javascript with Java. They're completely different
>beasts.
>
>Javascript is most often used embedded in web pages to do client-related
>(DHTML) work (what it sounds like you want to do), usually mucking with the
>HTML of a given page dynamically. Javascript (in this case) is built in to
>the browser, and (in modern browsers, e.g., IE 4/5, NS 4) can be used to do
>some fairly complex things.
>
>Java applets (and thus JPython applets) usually run in a little "visual
>sandbox" (to say nothing of their file system sandbox), i.e., a rectangular
>portion of a web page. They can't really do the kinds of things that
>Javascript scripts can do, in terms of augmenting the overall UI of a web
>page.
>
>--
>Cheers!
>/ Chris Ryland, President / Em Software, Inc. / www.emsoftware.com
>
>"Kojo Idrissa"  wrote in message
>news:38DF007A.64AFBE6E at tamu.edu...
>> Hello all.  I am new to Python and I've got a question (surprise).  I'm
>> teaching myself Python, but I'm also thinking about doing some stuff
>> with Javascript to add some functionality to some web-pages (surveys,
>> on-line tests, allowing people to interact through the web and "respond"
>> to a site).
>>
>> My question is this:  How do JPython/Java applets compare with
>> Javascript from a functionality standpoint?  I'm thinking it would be
>> nice to not worry about learning another language and get more mileage
>> out of my knowledge of Python by using JPython to turn Python code into
>> Java applets.  I'm just not sure of the pros and cons.  My guess is that
>> it's probably more an Applet vs. Javascript question, but I'm not sure.
>> Any insight would be appreciated.
>
>
>

-- 
****************************
Kojo Idrissa
KPMG Scholar
Accounting Doctoral Student
Texas A&M University
 
kojo at tamu.edu
401M Wehner Bldg.
409-862-2726
****************************



From thomas.heller at ion-tof.com  Mon Mar 27 15:02:52 2000
From: thomas.heller at ion-tof.com (Thomas Heller)
Date: Mon, 27 Mar 2000 22:02:52 +0200
Subject: tp_itemsize
Message-ID: <030a01bf9827$6f8002b0$4500a8c0@thomasnotebook>

Well,

after browsing through the source I have a vague impression
what tp_itemsize is for.
Is somewhere documentation for this?

Thomas Heller




From drugar at my-deja.com  Thu Mar 16 18:49:52 2000
From: drugar at my-deja.com (drugar at my-deja.com)
Date: Thu, 16 Mar 2000 23:49:52 GMT
Subject: How can I get a PyObject reference to an object already created?
Message-ID: <8arruu$dpm$1@nnrp1.deja.com>

In particular this is  Win32 project that embeds the python
interpretor.  Can I get a PyObject reference to an object that is
created by a script?
For example:

PyRun_SimpleString("import CustomScript\n");
PyRun_SimpleString("t=CustomClass()\n");

Is there anyway to get a reference to t? or any other object that is
created by importing CustomScript?  Assuming I know it's "name".

Thanks



Sent via Deja.com http://www.deja.com/
Before you buy.


From hartmut at oberon.noris.de  Tue Mar 28 15:27:35 2000
From: hartmut at oberon.noris.de (hartmut Goebel)
Date: Tue, 28 Mar 2000 21:27:35 +0100
Subject: Bug in module time: localization?
References: <16600602@oberon.noris.de>  <16600605@oberon.noris.de> 
Message-ID: <16600611@oberon.noris.de>

Berthold H?llmann (bhoel at starship.python.net) schrieb:

 >It's no workaround. Programs only honour the locale settings if you
 >tell them so. An when you write Python Programs, and want to use the
 >locale settings, you have to tell it. An you do this with the locale
 >module.

IC! Thanks for the help!

 >Berthold

+++hartmut


From gchiaramonte at ibl.bm  Sun Mar  5 10:22:30 2000
From: gchiaramonte at ibl.bm (Gene Chiaramonte)
Date: Sun, 5 Mar 2000 11:22:30 -0400
Subject: Help: sizeof() and reference in python?
In-Reply-To: <20000305073630.C7327@quark.emich.edu>
Message-ID: 

I guess I should have been more specific.

1 - I am trying to get the size of an object in bytes to monitor how much
memory a list or object occupies.
2 - I am trying to get the pointer to the memory address of an object. Much
like the array objects buffer_info(), where the second item in the returned
tuple is the pointer to the memory address of the first element of the
array.

Thanks for the help though.

Gene

> -----Original Message-----
> From: Jeff [mailto:jam at quark.emich.edu]
> Sent: Sunday, March 05, 2000 8:37 AM
> To: Gene Chiaramonte
> Subject: Re: Help: sizeof() and reference in python?
>
>
> On Sun, Mar 05, 2000 at 08:17:43AM -0400, Gene Chiaramonte wrote:
> > Is there a way to get the size of an object in python? I'd also
> like to get
> > a reference to an object.
> >
> > example in c:
> >
> > l = [1, 2, 3]	#python list
> >
> > t1 = sizeof(l)	// how i'd do it in c
> > t2 = &l
> >
> > Thanks,
> >
> > Gene
> >
>
> you can get the *length* of an object in python, which I suspect is the
> closest you can come to sizeof()..  what are you trying to do
> with sizeof()
> that len() can't already handle?
>
> the reference thing is easy ;).. everything is a reference in
> python. so if you
> want 't2' to be a reference to 'l', you assign it as normal 't2 = l'.
>
> hope that helps..
>
> regards,
> J
> --
> || visit gfd 
> || psa member -- 
> || New Image Systems & Services, Inc. 




From grant at nowhere.  Thu Mar 30 11:14:28 2000
From: grant at nowhere. (Grant Edwards)
Date: Thu, 30 Mar 2000 16:14:28 GMT
Subject: Philosophical long integer question...
References: <38E23160.B16860C2@bioreason.com>
Message-ID: 

In article <38E23160.B16860C2 at bioreason.com>, Brian Kelley wrote:

>In the same vein as should 1/2 equal 0.5:
>
>should (1 << 1000) produce a long int?  

My vote would be no, but I write embedded, real-time software
most of the time and am used to being constantly aware of the
machine representation of what I'm writing.

-- 
Grant Edwards                   grante             Yow!  My forehead feels
                                  at               like a PACKAGE of moist
                               visi.com            CRANBERRIES in a remote
                                                   FRENCH OUTPOST!!


From jstok at bluedog.apana.org.au  Sat Mar  4 20:22:47 2000
From: jstok at bluedog.apana.org.au (Jason Stokes)
Date: Sun, 5 Mar 2000 12:22:47 +1100
Subject: newbe question about lists
References: <0d6dde44.8e4c635f@usw-ex0102-015.remarq.com>
Message-ID: 

Fredrik S wrote in message <0d6dde44.8e4c635f at usw-ex0102-015.remarq.com>...
>Sorry for this simple question, but I can't go to sleep before I
>have solved it.
>
>I am running python on Beos for the first
>time.
>
>I'm going through a study course online, and ringt now I
>am trying lists.
>
>I type the following:
>>>>
>l1=["a1","a2","a3"]
>>>> l2=["a4","a5","a6"]
>>>> l3=l1
>>>>
>l3[1:1]=l2
>>>> l3
>['a1', 'a3', 'a4', 'a2']
>>>> l1
>['a1', 'a3',
>'a4', 'a2']
>
>QUESTION:
>Why is value of l1 changed... The only
>thing I can think of is B U G ...


This is just standard reference semantics.  Lists are mutable structures,
first of all.  Assigning the first list to l1 creates the list object and
binds it to the name "l1".  Assigning l1 to l3 binds "l3" to the *same*
object.  Therefore, any changes in the object referred to by the "l1" name
are now reflected in the object referred to by the "l3" name, because they
are one and the same.

To prevent this behaviour bind l3 to a *copy* of the object referred to by
l1, like this:

>>>l3 = l1[:]






From m.faassen at vet.uu.nl  Thu Mar 16 12:38:52 2000
From: m.faassen at vet.uu.nl (Martijn Faassen)
Date: 16 Mar 2000 17:38:52 GMT
Subject: SPAM
References: 
Message-ID: <8ar67d$f2e$1@newshost.accu.uu.nl>

Michal Bozon  wrote:
> __hi__

> What is it "spam" ?

Besides the other answers, the Python conferences are also sometimes referred
to as SPAM (i.e. SPAM7). I'm not sure why. :)

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?


From python-list at teleo.net  Tue Mar  7 21:41:41 2000
From: python-list at teleo.net (Patrick Phalen)
Date: Tue, 7 Mar 2000 18:41:41 -0800
Subject: A Question
In-Reply-To: <8a4dgt$naa$1@nntp.itservices.ubc.ca>
References: <8a4dgt$naa$1@nntp.itservices.ubc.ca>
Message-ID: <0003071846440C.00825@quadra.teleo.net>

[Purang Abolmaesumi, on Tue, 07 Mar 2000]

:: So, here is the problem: We would like to have a GUI which gets images from
:: a frame-grabber installed on the PC and show them on the screen (we have the
:: C functions right now which are running perfectly), send some data in
:: real-time to the VXWORKS machine (again, we have the C functions written)
:: and at the same time, interacts with user.
:: I have the following questions:
:: 1. Can we use Python for this?
:: 2. Can we call C functions in Python and vice versa easily?
:: 3. How fast is a Python program? Can we use it for a real-time application
:: like the one we have?
:: 4. If we use TKinter as the GUI, can we use our C functions for the
:: frame-grabber to show the image on the screen?

Since you're running under Linux, you might want to have a look at
SVGAlib (www.svgalib.org). Since it's a low-level library, it might meet
your real time needs better?



From donn at u.washington.edu  Mon Mar 13 12:29:51 2000
From: donn at u.washington.edu (Donn Cave)
Date: 13 Mar 2000 17:29:51 GMT
Subject: event loops and Python?
References:  <200003120619.QAA11915@piglet.dstc.edu.au>
Message-ID: <8aj8if$dk2$1@nntp6.u.washington.edu>

Quoth kragen at dnaco.net (Kragen Sitaker):
...
| There are a few things that were bothering me.
|
| One is that you can't have two event loops in the same thread.  Event
| loops are one of the few things you can only have one of.  Accordingly,
| if you have two pieces of code designed to run from two different event
| loops, and you want to build a program containing both, your choices
| are somewhat restricted --- modify one to work with the other's event
| loop, run them in different threads, or give up.
|
| So a standard event loop, or at least a standard event-loop API,
| for all event-loop-based Python applications would be very useful.

Sounds like asyncore is running unopposed for that, so far.

| Another is that handling signals safely in Perl is tough, and I
| assume the same thing is true of Python.

True, and I say good riddance.  Signals are easier to use in C, but
are really appropriate for only low level stuff, in my opinion -
for example from a software engineering point of view, try to get your
two pieces of code to cooperate over signals, or even protect themselves
from each other's use of signals.

| Another is that, while I'm comfy with writing select()-based
| event loops in C, I'm not particularly comfy with writing C code that
| interfaces with the Python interpreter, particularly at such an
| intimate level.  I was hoping I could put that off until later.
|
| Enough English.  Now it is time for me to write code before posting more.

Eek, use Python's select() function, if you don't use asyncore!  The
Python select() implementation is much more convenient

	Donn Cave, donn at u.washington.edu


From nnever50 at yahoo.com  Wed Mar 15 08:56:28 2000
From: nnever50 at yahoo.com (nathan)
Date: Wed, 15 Mar 2000 14:56:28 +0100
Subject: sorry..the program runs!
References: <8ale7h$bl$1@news1.sunrise.ch> 
Message-ID: <8ao4o6$5nh$1@news1.sunrise.ch>

..but anyway
I cannot do anything with the GUI until the process is ended.
As I already wrote, I have a process that runs during all the time and I
wont to have the possibility to interact with the GUI.
There's other ways?
Thank you!
N.




From embed at geocities.com  Mon Mar 27 12:03:42 2000
From: embed at geocities.com (Warren Postma)
Date: Mon, 27 Mar 2000 12:03:42 -0500
Subject: __getattr__ / __setattr__ - infinite recursion!?
Message-ID: <0yMD4.624$HG1.20784@nnrp1.uunet.ca>


Okay my first attempt at a "static type checking object" for Python blows
up, probably
a stack overflow, probably due to infinite recursion or some such thing....

Python blows up on the line that instantiates this object! I suspect I'm too
clueless to know how to do a proper __getattr__ / __setattr__
implementation. A better solution to this would be a built in dictionary
type with type-information as part of it's C code.  Has anyone built such a
beast directly in C?

Warren


#---------------------------------------------------------------------
# Why does this blow up Python?
#---------------------------------------------------------------------

import os, sys, string, pprint

# "type objects"
int_type       = type(0)
string_type    = type("X")
float_type     = type(0.1)

# required field flags?
required = 1
optional = 0


# Class with strict type checking and a single key:
class zdb_rec:
    def __init__(self, pattern_dict=None, keyname=None):
        "create an object with a strict pattern of required values to make
up a type"
        self.set_valid(pattern_dict)
        self.keyname = keyname
        self.reset_to_defaults(self)

    def set_valid(self,pattern_dict):
        self.attrs = pattern_dict

    def set_keyname(self,keyname):
        self.keyname = keyname

    def reset_to_defaults(self):
        # fill in default values for each attribute
        self.values = {}
        for x in self.attrs.keys():
            self.values[x] = self.attrs[x][2]

    def keyname(self):
        return self.keyname

    def key(self):
        return self.values[self.keyname]

      # setattr does typesafety check:
    def __setattr__(self,name,value):
        "custom __setattr_ with typesafety check"
        try:
            if (value == None) and (not self.attrs[name][1]):
                self.values[name] = None
            else:
                if (type(value) == self.attrs[name][1]):
                    self.values[name] = value
                else:
                    raise Error, "Invalid type in assignment"+`type(value)`
        except:
            raise Error, "Invalid attribute "+`name`
    def __getattr__(self,name):
        try:
            return self.values[name]
        except:
            raise Error, "Invalid attribute "+`name`

    def attr_count(self):
        return len(self.attrs)

    def validate(self):
        "raises an exception if validation fails, ie requird field not
provided"
        for x in self.attrs.keys():
            if self.attrs[x][1]:
                if self.values[x] == None:
                    raise Error, "validate() failed - required field not
set"

# "Person Database Schema":
person_attributes = {
 # attribute    type          required?   initialvalue
     "name":    (string_type,    required,  ""),
     "address": (string_type,    required,  ""),
     "age":     (int_type,       required,  0 ),
}


x = zdb_rec(person_attributes,"name")

print "done"






From aahz at netcom.com  Thu Mar 23 11:43:47 2000
From: aahz at netcom.com (Aahz Maruch)
Date: 23 Mar 2000 16:43:47 GMT
Subject: List limitations?
References: 
Message-ID: <8bdhk3$42d$1@nntp6.atl.mindspring.net>

In article ,
Daley, MarkX  wrote:
>
>What this does is connect to a server and pull data from it based on each
>family name in the familyname list, using an SQL query.  Conceivably, this
>code should connect to server1 and pull data for all familynames and write
>that data to a file, server_familyname_date.  Then it should connect to
>server2 and do the same.  However, when it connects to server 2, it isn't
>pulling the familynames from the familyname list correctly.  Instead, it is
>pulling single character strings, like a, b, e, g, h, r, S (these are the
>actual strings, which may or may not have some bearing on one of my
>familyname entries, I haven't been able to verify).  Has anyone else seen
>problem remotely related to this?  Any help is appreciated.

Questions/suggestions:

Have you tried connecting just to server2?
What happens if you switch server2 and server1?
Have you considered using mxODBC?
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Usenet is not a democracy.  It is a weird cross between an anarchy 
and a dictatorship.  --Aahz


From Lisowski.Tomasz at sssa.nospam.pl  Sat Mar 25 03:10:33 2000
From: Lisowski.Tomasz at sssa.nospam.pl (Tomek Lisowski)
Date: Sat, 25 Mar 2000 08:10:33 GMT
Subject: else clauses in while and for loops
Message-ID: 

Hi!

Which is the reason for else clauses in while and for loops? At the first
look it seems, that the statements in the else suit is executed always after
processing the loop. Wouldn't it be simpler, if I just put those statements
after the loop, and omit the else clause completely?

Please give some examples showing the real need for else clauses in this
context.

Thanks in advance

Tomasz Lisowski



From Marc_Battyani at csi.com  Tue Mar 14 16:07:47 2000
From: Marc_Battyani at csi.com (Marc Battyani)
Date: Tue, 14 Mar 2000 22:07:47 +0100
Subject: Can embedded static-linked python still import dll extensions?
References: 
Message-ID: 

Warren Postma  wrote in message
news:cItz4.33201$Jz3.306758 at nnrp1.uunet.ca...
> I recompiled the Python sources for Windows with config.h and put this
line
> in:
>
> #define MS_NO_COREDLL 1  // build a static library not a DLL!
>
>
> Now it statically links fine, but it doesn't allow me to import .pyd files
> (Python extension DLLs). Do you have to use the external Python DLL to
allow
> importing modules from DLLs, or can you statically link python but still
> allow external DLL add ons somehow?
>
> I want my embedded python deeply embedded but I still want to produce .PYD
> style add ons for the system once it's in the field. Am I stuck?

No. Nothing prevents you to exports functions from an exe.
Here is a small C program

#include 
__declspec( dllexport ) void foo(){printf("Foo\n");};
__declspec( dllexport ) void bar(){printf("Bar\n");};
main()
{
  foo();
  bar();
}

Let's compile it:

D:\temp>cl export.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

export.c
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/out:export.exe
export.obj
   Creating library export.lib and object export.exp

****** You can see it creates a .lib and a .exp **********

D:\temp>dumpbin /exports export.exe
Microsoft (R) COFF Binary File Dumper Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

Dump of file export.exe

File Type: EXECUTABLE IMAGE

  Section contains the following exports for export.exe

           0 characteristics
    38CEA936 time date stamp Tue Mar 14 22:03:50 2000
        0.00 version
           1 ordinal base
           2 number of functions
           2 number of names

    ordinal hint RVA      name

          1    0 00001012 bar
          2    1 00001000 foo

******* Here you can see the exported functions are... exported. **********

Good luck
Tell us informed.

Marc Battyani





From gmcm at hypernet.com  Wed Mar 15 09:51:38 2000
From: gmcm at hypernet.com (Gordon McMillan)
Date: Wed, 15 Mar 2000 09:51:38 -0500
Subject: For loop
In-Reply-To: <38cf6e09$0$6366@businessnews.de.uu.net>
Message-ID: <1258990590-4218974@hypernet.com>

Boris Ottlewski wrote:
> 
> I got this code snipet: (See the colons!)
> 
> for a in i.something():
>      for cf in a.somethingelse():
>           print cf.property
> 
> It works in python.exe (shell). How do I use this in embedded python? When a
> build a string with this code and do a Py_RunSimpleString() it raises a
> syntax error. Is there an alternative syntax? Is the colon someting just
> known to the python shell?

Make sure the lines are delimited properly, and the parser can 
detect a dendent and end-of-file:

"for i in a:\n for j in b: \n  something\n\n\0"

- Gordon



From prodos8 at yahoo.com  Sun Mar 26 19:26:04 2000
From: prodos8 at yahoo.com (carbon)
Date: Mon, 27 Mar 2000 00:26:04 GMT
Subject: Calculating Derivatives?
Message-ID: <260320001926276702%prodos8@yahoo.com>

Is there any python source that relates to calculating derivatives? 
I'd like to try writing software that does this (for polynomials), but
I don't know where to start.  any resources or help would be greatly
appreciated.  thanks.


From x at x.x  Mon Mar  6 16:50:11 2000
From: x at x.x (x at x.x)
Date: Mon, 06 Mar 2000 16:50:11 -0500
Subject: Problems with uploading binary files using cgi module
References: <01BF86EC.F2D432E0.shichang@icubed.com>
Message-ID: 

In article <01BF86EC.F2D432E0.shichang at icubed.com>,
Shichang Zhao  wrote:
> I am not sure there is a bug in Python cgi module or I did somethin wrong. 
> Here is what I am trying to achieve:
> 
> Goal:
>      Uploading a binary file, say a Microsoft Word file name test.doc, to 
> Web server's cgi-bin directory with a name
>      tmp.doc.
:
> 
> After the file is uploaded, I compared the original file's size (19,456 
> bytes) with the file saved onto the server's cgi-bin directory (tmp.doc, 
> size: 13,073 bytes). Some of the bytes are lost after the file is
uploaded.

Are you by any chance running this off a Windows server? I'm thinking
because you mentioned Microsoft Word; if so, I think I know what the
problem is: Standard input is opened by default in "text" mode, and
you're probably running into an end-of-file character (ascii 26) and
that's causing the file to truncate.

If that's the case, you're going to need to dig into the msvcrt module 
and reset sys.stdin at the beginning of your cgi script. If I recall,
you need the "OSF handle" functions. I had to do that once, I can
dig up the code if you need it.

I do remember that doing an os.fdopen(0, "rb") wouldn't do it in
Win32. It was necessary to get into the msvcrt.dll gunk.


From a.eyre at optichrome.com  Tue Mar 21 06:40:35 2000
From: a.eyre at optichrome.com (Adrian Eyre)
Date: Tue, 21 Mar 2000 11:40:35 -0000
Subject: How to retrieve an objects content
In-Reply-To: <38d6278b$0$29742@businessnews.de.uu.net>
Message-ID: <000101bf932a$45ab7fc0$3acbd9c2@optichrome.com>

> I would like to get an objects content into a string. (Like the 
> python print command) The print command uses PyFile_WriteObject
> which is quite unhandy. Any ideas?

PyObject_Str(), or PyObject_Repr() should do the trick. See:

http://www.python.org/doc/api/object.html

You'll also need to convert from a Python string to a C string.
For that you'll need PyString_AsString(). See:

http://www.python.org/doc/api/stringObjects.html

-----------------------------------------------------------------
Adrian Eyre  - http://www.optichrome.com 




From Vladimir.Marangozov at inrialpes.fr  Tue Mar 14 09:24:51 2000
From: Vladimir.Marangozov at inrialpes.fr (Vladimir Marangozov)
Date: Tue, 14 Mar 2000 15:24:51 +0100
Subject: Dictionary in Python
References:   <9t9pusynelo.fsf@mraz.iskon.hr>
Message-ID: <38CE4BB3.D81D2275@inrialpes.fr>

Hrvoje Niksic, replying:
>
> AFAIK Python dictionaries increase dynamically.

They also shrink dynamically. For those who are interested, there was
a good discussion on the dict implementation in the august 1999 archives
of python-dev. Look for a thread "shrinking dicts". Tim Peters explains
some subtleties of the implementation, especially in this msg:

http://www.python.org/pipermail/python-dev/1999-August/002162.html

-- 
       Vladimir MARANGOZOV          | Vladimir.Marangozov at inrialpes.fr
http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252


From calishar at *NOSPAM*home.com  Tue Mar 14 23:11:24 2000
From: calishar at *NOSPAM*home.com (Calishar)
Date: Wed, 15 Mar 2000 04:11:24 GMT
Subject: Stuck at CH9 of  PythonW32 book, VBA
References: <2KCz4.33305$bm.298215@news1.alsv1.occa.home.com>
Message-ID: 

On Wed, 15 Mar 2000 02:39:58 GMT, "Adolfo Aguirre" 
wrote:

>Hi.
>
>I just bought the new book "Python Programming on W32". CH9 starts with an
>excel exercise that requires the VBA editor. Instructions are given for
>Office 97.
>
>I have Office2000. And I don't see a VBA editor in it. When I tried to
>reinstall Office 2000 I did not see VBA as amodule option either.

The visual basic editor is under the Macros option under the Tools
menu. It's possible the tools menu won't display the Macros if you
havent used it before, in which case, just hold the mouse cursor (for
about a second) over the double down arrow at the bottom of the menu,
or select the double down arrow like any other menu option.

thanking-Microsoft-for-changing-how-menus-work-ly yrs,
Calishar

(neat, I finally get to use a -ly-yrs)



From wware at world.std.com  Thu Mar 23 14:48:58 2000
From: wware at world.std.com (Will Ware)
Date: Thu, 23 Mar 2000 19:48:58 GMT
Subject: Off Topic: looking for a paper
References: <38DA69F0.336A7729@sage.att.com>
Message-ID: 

Garry Hodgson (garry at sage.att.com) wrote:
> i'm looking for a paper i believe i've seen referenced here,
> but can't recall.  it describes a new jersey style of
> design, as exemplified by unix...

Go to www.google.com and search on "new jersey mit style unix". (I
conveniently remember that the competing style group was MIT.) In
the first ten hits, you'll see it appear five times.

-- 
 - - - - - - - - - - - - - - - - - - - - - - - -
Resistance is futile. Capacitance is efficacious.
Will Ware	email:    wware @ world.std.com


From tismer at tismer.com  Thu Mar  9 17:07:27 2000
From: tismer at tismer.com (Christian Tismer)
Date: Thu, 09 Mar 2000 23:07:27 +0100
Subject: Making sense of Stackless
References: <146101bf8164$fc19df90$6401a8c0@dorb> <38B98A01.9DC6C456@tismer.com> <148f01bf8185$fd355eb0$6401a8c0@dorb>
Message-ID: <38C8209F.E95D4A44@tismer.com>


Darrell wrote:
...
> It would be nice if I could do this.
> 
> def classIterator(seq):
>     offset= -1
>     return continuation.current(1)
>     offset=offset+1
>     return seq[offset]
> 
> The parm into current indicates I want the continuation to point just past
> this point.

This is included into continuations 0.8 which are about to be
published. It is even easier: Whatever I can express as a
function avoids to have to juggle with opcodes.
Here we go:

continuation.return_current()

Does exactly what we need: Return ourself and be in position
to be called again.

ciao - chris

-- 
Christian Tismer             :^)   
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaunstr. 26                  :    *Starship* http://starship.python.net
14163 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home



From ljz at asfast.com  Tue Mar  7 22:37:51 2000
From: ljz at asfast.com (Lloyd Zusman)
Date: 07 Mar 2000 22:37:51 -0500
Subject: Self Nanny
References:   <38C5709D.59E8@marshall.edu>
Message-ID: 

Mark Hathaway  writes:

> >> Gaetan Corneau  writes:
> >>
> >> [ ... ]
> 
> > Lloyd Zusman wrote:
> >
> > [ ... ]
> 
> Personally, I'd rather not ever have to write 'self' or 'self.anything'.
> It contributes nothing to the code and doesn't describe what I'm trying
> to write. It's extra verbosity without any payoff.
> 
> Was there a problem with doing it the other way around...
> 
>   [ ... examples snipped ... ]
> 
> where the roles are reversed. All object attributes are
> referred to by their names and any class (global) attributes
> are specified by "local.". This would decrease tremendously
> the need to write 'self.' and would still easily allow the
> differentiation of class-wide attributes from object attributes.
>
> Which do you write more of? Object attribute names.
> Why make that the more verbose version?

In Section 9.4 of the official Python tutorial (did you read it?),
Guido says this about his reasons for the explicit 'self':

  There is no shorthand for referencing data attributes (or other
  methods!) from within methods. I find that this actually increases
  the readability of methods: there is no chance of confusing local
  variables and instance variables when glancing through a method.

  Conventionally, the first argument of methods is often called
  self. This is nothing more than a convention: the name self has
  absolutely no special meaning to Python. (Note, however, that by not
  following the convention your code may be less readable by other
  Python programmers, and it is also conceivable that a class browser
  program be written which relies upon such a convention.)

You may disagree with this.  Nonetheless, this expresses Guido's
reasoning (or at least a part of it).  If you haven't done so already,
I suggest you read all the existing Python documentation.

And did you know that Python was first created some 10 years ago?  And
did you know that in the early stages of its development, many people
such as yourself raised the issues that you are now raising?  And did
you know that now, Python is a mature language and that there are
millions of lines of Python code in use in production applications all
over the world?

... and even if somehow this 'self' change ever were to happen in
Python, all the existing production applications would be very
expensive to change in terms of time and money.


> > LZ:
> >
> > Of course #3 can be done (technically speaking).  And in return for it
> > getting done, would you volunteer to donate your personal time to
> > change all the existing lines of Python code in the world that this
> > change would break?
> 
> This is both true and annoying. In our search for better ways to do
> things we keep running into this barrier that languages are written,
> tried and much time & effort put into that trial. Then when someone
> says, "Couldn't we do it better this way?", the answer is, "But, we've
> put so much work into this..."

So tell the truth: do you really think that this 'self' change is so
much of an improvement over the way that Python works today that it
would justify changing 100 percent of all existing Python programs
that contain method definitions?

Also, keep in mind that there indeed have been many many useful and
meaningful "Couldn't we do it better this way?"  discussions about the
implictness or explicitness of 'self' ... they took place maybe 5-10
years ago when Python was still in the design and debate stage of
development.

But since at least a few years ago, you can no longer think of Python
as a "trial" language.  As I mentioned, there are now millions of
lines of Python being used in real, production-grade applications
today.

If there was a new or young language being considered, discussion of a
behavior change like this would be quite useful and quite appropriate.
It's just that you're way too late to expect a such a major,
legacy-code-breaking change in a language which already has so much
existing production-grade code out there.


There is an undocumented and probably unintended behavior of the
Python 'append' method that people have been exploiting in certain
applications.  Recently, it was decided that in the next major release
of Python, this undocumented behavior will no longer work, and that
the 'append' method will then behave only as documented.  This change
will affect some existing Python applications, but many fewer than
would be affected by this suggested 'self' alteration.

And even in the case of this very small change which removes an
*undocumented* behavior of a method, Guido has recently given us a 3-4
month warning so that the small percentage of code which currently
uses this undocumented behavior could be altered.  And even with this,
there are costs involved in existing, production applications, and
some people are requesting that the change to 'append' not be made.

Given the impact of this tiny change to remove an undocumented
behavior of one method, can you imagine how much of a cost (money and
time) there would be in changing to an implicit 'self'?  As I
mentioned above, this change would require 100 percent of all method
definitions to be changed in all existing Python code.


> Somehow there has to be a willingness to put the effort in and then,
> if it's not as perfect as we'd like, throw it away and start with
> another piece of whole cloth.  [ ... ]

That's quite appropriate for a new or very young computer language.
But you're several years and a few millions of lines of production
code too late for Python.

It's very appropriate to "start over" when creating a new language.
For example, Stroustrup did that to C when inventing C++.  Larry Wall
did that when creating Perl.  Guido did that when creating Python.

And I invite you to do that with the new language that *you* could
create to supersede Python.  What's stopping you from doing that?


> [ ... ] Well, perhaps we could write a translator to convert the old
> to the new. That wouldn't take quite as much man-power, would it?

Even the best translator cannot be counted on to work in all cases.
Therefore, even after running an existing program through this
hypothetical translator, significant testing would have to be
performed to make sure that the converted program still works as it's
supposed to.  And for production applications where time and money is
on the line, this testing would be essential.  Hence, even with a code
translator, the greatest amount of expensive testing would have to be
done in those places where the downtime of an application would cost
the most.


> > Or barring that, would you be willing to pay for the time of all the
> > others who would have to do this work?
> 
> Pay? Who paid the first time? Didn't most of the Python code come
> about because people liked the language and just wrote stuff to be
> distributed via the internet for free? O.K. here's a penny. Ya
> satisfied?

The time and money I'm talking about wouldn't be for development
... it would be to compensate all the people who would have to expend
their own time and money to convert current, production Python
applications so that they would once again work once this hypothetical
change would go into effect.  And remember, this change would break
nearly 100 percent of all existing Python programs.

Would you be willing to explain what advantage this proposed change
would give to people already running these existing applications to
justify the large time and money cost of changing all of them?

The only potential advantages that anyone ever mentioned about having
an implicit 'self' are (1) that a certain small subset of new Python
users might find Python a little easier to learn if it handled 'self'
closer to the way that they are used to C++ handling 'this'; and (2)
that a small minority of existing Python coders find the explicit
'self' to be annoying.

Are there other advantages you see to this proposed change that would
justify the huge time and money cost of converting all the existing
Python programs?


> I know you're saying people's time & effort is considerable. All I'm
> saying is there should be ways to move to new better ways of doing
> things without having to face such stiff resistance.

I wholehearedly agree.  We should always move towards better ways of
doing things.  That's one of the main reasons that people invent new
computer languages.  Therefore, as I've suggested before: given that
it's years too late to make such a drastic change in Python, why not
propose a new language that has the better features that you are
suggesting?  I consider that to be a very worthwhile endeavor.


> > This is not an issue about "caring" about C++ programmers.  I am a C++
> > programmer, and literally hundreds of my colleagues over the past
> > decade or so have been C++ programmers.  Many of these people have
> > tried Python.  And *none* of them have ever even made a complaint
> > about the explicit "self" of Python.  You are the first C++ programmer
> > I have encountered who has ever raised this as an issue.  That's one
> > out of hundreds of people.
> 
> Perhaps they are simply more accepting of what is, and don't
> challenge it.  That doesn't mean they haven't thought about it. I'm
> not a C++ programmer, so I don't know either.

Well, perhaps there is a Great Silent Majority of Python users out
there who have been seething with resentment about 'self' having to be
explicit, and who will rise up and revolt to rally behind a leader who
finally raises his or her voice to fight the Python Establishment.

But I doubt it.

... especially given how much this has already been discussed over the
past 5-10 years with the end result being the Python language we see
today.

What is much more likely is that there are some people who would be
willing to participate in the design and development of a new O-O
scripting language which differs from Python and other existing
languages in ways that these people feel are important.  Would you be
willing to be part of that effort?


> > And as I have mentioned in another post, I challenge you to come up
> > any signficant number of people who would be glad to use Python if
> > only it didn't have an explicit "self".
> 
> It's not just about that issue. It's about an effort to move toward
> something better. You're not against that altogether, are you?

As you can tell from reading what I have already written above and
elsewhere, I am not against that at all, and in fact I'm for it.


> > Your arguments have always been clear.  And they are still rather
> > unconvincing.
> >  Lloyd Zusman
> >  ljz at asfast.com
> 
> 
> A closed mind can't even be convinced by the truth or a stick up side
> the head.

Please re-read this post and my others.

I have said this before and I'll say it again: this sort of feature
would be perfectly valid to discuss for a new language, or one that is
still in the design and debate stage of development ... and I
encourage you and others to do just that.  It's just too late to
effect the change in Python, given the amount of expensive work it
would take to re-tool the existing applications that are out there to
accomodate this change, and given the low amount of desire for such a
change among most Python users.

Also, if you somehow think that this is a new and undebated
suggestion, you might want to go back and try to find some of those
earlier debates about the way that Python handles 'self' that took
place 5-10 years ago when at that time it *was* a young language.

-- 
 Lloyd Zusman
 ljz at asfast.com


From alex at somewhere.round.here  Tue Mar 14 14:37:49 2000
From: alex at somewhere.round.here (Alex)
Date: 14 Mar 2000 14:37:49 -0500
Subject: Is UserList.py "strange" or is it cmp()?
References: 
Message-ID: 

Hi, Tom.

> >>> ul == aList
> in UserList.__cmp__(self=[0, 1, 2, 3], other=[0, 1, 2, 3]):
>    false leg: cmp(self.data, other)=0
> 1
> >>> cmp(ul,aList)
> in UsreList.__cmp__(self=[0, 1, 2, 3], other=[0, 1, 2, 3]):
>    false leg: cmp(self.data, other)=0
> 0

cmp should actually return 0 when it thinks its arguments are equal.  It
confused me for a while, too, but it makes sense in the context of an
ordering.  Usually, the way it's supposed to work is

cmp (a, b) => -1  if a < b
cmp (a, b) =>  0  if a == b
cmp (a, b) =>  1  if a > b

which is consistent with the results you got.  I guess that 'a == b' is
actually returning (not cmp (a, b))

Alex.


From grant at nowhere.  Mon Mar 13 14:34:39 2000
From: grant at nowhere. (Grant Edwards)
Date: Mon, 13 Mar 2000 19:34:39 GMT
Subject: How do I ...
References: <38CD2368.9D29554F@abo.fi>
Message-ID: 

In article <38CD2368.9D29554F at abo.fi>, Cesar Lopez wrote:

>How do I acces to the low-level of my system? I mean, for example, I
>want to access and configure the speed of my serial port using a Python
>program. I've tried building an extension C function and the call it
>from Python, but doesn?t works.

1) You really need to do a better job on your "Subject:" line.
   The bandwidth in this group is high enough that a lot of
   people aren't going to read all of the articles.  I read
   yours by accident -- I generally only read articles when I
   either know the answer to the question or am otherwise
   interested in the particular subject.
   
2) Read the FAQ

      http://www.python.org/doc/FAQ.html#4.68



-- 
Grant Edwards                   grante             Yow!  Now KEN is having
                                  at               a MENTAL CRISIS beacuse
                               visi.com            his "R.V." PAYMENTS are
                                                   OVER-DUE!!


From tuttledon at hotmail.com  Sun Mar 26 19:46:53 2000
From: tuttledon at hotmail.com (Don Tuttle)
Date: Mon, 27 Mar 2000 00:46:53 GMT
Subject: Language forks (was: Python tutorial/comparison for C++ programmer)
References:     <5FF7ED1C1C902C69.0E5D50066AC4B434.CE45BE37438DE91A@lp.airnews.net> 
Message-ID: <1cyD4.5258$8E5.54893@typhoon.southeast.rr.com>

[Grant Edwards]
> MS seems to actively attempt to diverge from standards in order to try to
> kill off those standards and establish their own dominance.


I think it's more accurate to say that Microsoft, like all commercial
companies, seeks a competitive advantage.  Just look at the Sun vs.
Microsoft battle.

Sun has visions of Java running everywhere on everything.  Java rules!
Microsoft is history! Microsoft is scared and decides if it's going to keep
its client base, they have to make Windows the most attractive OS to run
Java on.  So Microsoft 'optimizes' Java to run faster on Windows then any
other OS.  Then they create the most advanced Java development system
available (at the time) Visual J++.

Time move on.  Sun sues Microsoft and wins.  But Java fails to deliver on
the grand vision of write once, run anywhere.  Sun seeks support from a
"standards" committee.  But after 2 tries gives up because they can't find a
standards committee willing to  rubber stamp 'their' plan without having to
reveal all of their Java code, which would be the loss of a competitive
advantage to them.

Meanwhile Microsoft developed the open source protocol SOAP, which uses XML
to make remote procedure calls (and more)in a heterogeneous environment.
SOAP is OS and application neutral.  A PERL app on Linux can interact with a
Netware box running a COBRA app.  It just doesn't matter!

And now Sun is scared because SOAP could be the final straw to it's vision
of Java everywhere. Did Microsoft create a proposed open source standard
simply to make the world a better place? Of course not! Microsoft believes
it can leverage its development strengths to create the best applications at
each end of the SOAP pipeline.  And that, of course, translates to a
competitive edge. ;-)

Don






From jcrowe at io.com  Wed Mar  1 14:52:07 2000
From: jcrowe at io.com (Joseph Crowe)
Date: Wed, 1 Mar 2000 13:52:07 -0600
Subject: Python Rocks!
In-Reply-To: <38854F3A.4FBA74F9@exceptionalminds.com>
References: <860ftk$bas@news.or.intel.com>  <862jqd$l9s@news.or.intel.com>  <38854F3A.4FBA74F9@exceptionalminds.com>
Message-ID: 

On Tue, 18 Jan 2000, Timothy Grant wrote:
> You know Francois, this was my first reaction to this also. A good
> editor makes such a huge difference that I can barely work in one that
> doesn't have a "python" mode and syntax highlighting. However, it does
> take a little work to configure and editor to make it work.
> 
> Tye, have you taken a look at an editor with a Python mode? or used Idle
> or Pythonwin?
Hi All,

    Actually, vim...or more precisely, gvim seems to work very well in
Python mode as far as syntax highlighting goes.  Also, it's freely
available for most any platform and I think delivers with just about
any distro of Linux.
> Stand Fast,
>     tjg.

Joseph Crowe
http://www.io.com/~jcrowe
email jcrowe at io.com



From jwbnews at scandaroon.com  Mon Mar 20 14:57:01 2000
From: jwbnews at scandaroon.com (John W. Baxter)
Date: Mon, 20 Mar 2000 19:57:01 GMT
Subject: Pascal int()
References: <1258726940-20077342@hypernet.com> <38D66680.316F21D1@roguewave.com>
Message-ID: 

In article <38D66680.316F21D1 at roguewave.com>, Bjorn Pettersen 
 wrote:

> Gordon McMillan wrote:
> > [...]
> > I can assure you that no Python god, archangel, angel,
> > seraphim or cherubim would ever write anything but
> >  a = a + 1
> > 
> > - Gordon
> 
> ... of course, if P3K changed the meaning of 5 from "the object 5" to
> "a constructor for an Integer class, setting the value to 5" you could
> do all kinds of fun things, including:
> 
> 	a = 5
> 	a.inc()
> 
> And even though it would be backwards compatible, I don't really have
> high hopes for it being accepted (change? we don't need no stinking
> change ;-)
> 
> -- bjorn
> 

Nothing would prevent building an int wrapper similar to UserDict 
(except, perhaps, a slavish desire for performance of one's integers).  
The hypothetical UserInt's hypothetical subclass could certainly define 
the method inc().

Personally, I'd rather write a = a + 1.  I seldom used inc() whist 
writing Pascal, either, except for incrementing variables of types like 
(red, blue, green, khaki, oliveDrab).

(Various language implementations--some LISPs, some SmallTalks--show 
that by sacrificing some of the range of int, one can make int a class 
quite nicely.  I doubt that there would be many votes in favor of 
reducing int to 29 bits (or whatever).)

  --John

-- 
John W. Baxter   Port Ludlow, WA USA  jwbnews at scandaroon.com


From jfarrell at mincom.com  Sun Mar  5 21:02:12 2000
From: jfarrell at mincom.com (John Farrell)
Date: Mon, 06 Mar 2000 12:02:12 +1000
Subject: Splitting comp.lang.python
References:  <019601bf843c$b216b500$0201a8c0@spkydomain> <38BF1E16.7AD5FE93@mincom.com> <3572DB0C6C3EE456.0F7DD462C78FAF91.B661EE7244D9906C@lp.airnews.net>
Message-ID: <38C311A4.5F9E79C9@mincom.com>

Cameron Laird wrote:
> In article <38BF1E16.7AD5FE93 at mincom.com>,
> John Farrell   wrote:
> >I would also like to see a newsgroup for people who are working on the
> >Python implementation, but I can't think of a good name for it.
> "[T]he Python implementation"?!?  My rough extrapolations lead
> me to conclude that somewhere near the year 2037 there'll be
> more Python implmentations than there are Python programmers
> 

Except that some of the Unix ones will break due to the Unix Y2K+37 bug,
and it might take till 2039 to get the numbers back up :-).

John
-- 
Dr John Farrell - Research Architect - Mincom Limited

I don't suffer from stress.  I am a carrier.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d- s++:+ a C+++ U+ P-- L E--- W++ N+(-) o+ !K w---(+) !O !M !V PS+ PE Y?
PGP t--- !5 !X R(+) tv- b++ DI++ D G e++++ h---- r+++ y++++(*)
------END GEEK CODE BLOCK------
This transmission is for the intended addressee only and is confidential
information. If you have received this transmission in error, please delete
it and notify the sender. The contents of this E-mail are the opinion of the
writer only and are not endorsed by Mincom Limited unless expressly stated
otherwise.



From Johannes.Nix at mail.uni-oldenburg.de  Thu Mar 16 13:56:13 2000
From: Johannes.Nix at mail.uni-oldenburg.de (Johannes Nix)
Date: 16 Mar 2000 19:56:13 +0100
Subject: A python program as a Win "Service" or Unix "Daemon"?
References: <6D8A17398E28D3119F860090274DD7DB4985A7@pces.cadlab.it>
Message-ID: <8araoe$d2k@news.Informatik.Uni-Oldenburg.DE>

Alessandro Bottoni  writes:

> Is there any way to install a Python program as a Unix Daemon or a Windows
> Service? (Together with an instance of the interpreter, of course..)

Speaking for Unix, a daemon program is not very special.

It has normally the following features:

- It runs in the background, without attached terminal (standard
input). That is in C usually achieved by closing the standard input
and doing a fork() (or vice versa?). This is almost equivalent to
creating a new thread, so the threads interface should be enough.


- It sometimes reacts specially to interrupts, for example it may
read-read its configuration file if it receives a SIGHUP

- It uses frequently protected services and ports and thus runs with
root or other special privileges.


- An advanced daemon may send log messages to the syslog daemon, which
will write it to a file as /var/log/messages, or send it to another
computer.


- It starts normally automatically by a call from the system startup
scripts.

As can be seen, this should be achieved easily with standard commands,
except perhaps the interrupt protection.

Johannes


From michael.stroeder at inka.de  Fri Mar  3 09:52:47 2000
From: michael.stroeder at inka.de (Michael =?iso-8859-1?Q?Str=F6der?=)
Date: Fri, 03 Mar 2000 15:52:47 +0100
Subject: cgi, python and forms
References: <2WPv4.367$H95.27613@wagner.videotron.net>
Message-ID: <38BFD1BF.83C6D4C5@inka.de>

Akhar wrote:
> 
> I woud like to know how can I tell my python cgi script to differenciate
> these two:
> 

>

> I am using the cgi module but can't find any info on these. By using and reading the value of field SUBMITFIELD. Ciao, Michael. From pinard at IRO.UMontreal.CA Thu Mar 30 10:31:09 2000 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 30 Mar 2000 10:31:09 -0500 Subject: Incompatibility between socket and httplib in python CVS build. In-Reply-To: "Fredrik Lundh"'s message of "Wed, 29 Mar 2000 19:23:04 GMT" References: Message-ID: "Fredrik Lundh" ?crit: > [...] anyone insisting on using the bleeding edge development CVS version > (instead of a stable version) can save a lot of time by sub-scribing to > the python-cvs mailing list. in that way, you'll *know* what's changed > in the bleeding edge version. Just to put things straight, I'm not "insisting" to use it. Whatever in production for me still uses 1.5.2. But there is no chance that I contribute to the development effort (by reporting bugs, essentially) if I do not try using 1.5.2+ in some limited environments, where I know it is bearable that things can break. But your suggestion is a good idea. I'm not much of a CVS user, that's why I did not think of subscribing to anything having `-cvs' in it :-). But if modifications are described in there, it could be useful indeed. Thanks for your feedback. Oh, by the way, is there a specific mailing list to use (and to be) for discussing findings if any, or is `python-list' just acceptable? I took a slightly better look at Unicode implementation in 1.5.2+, and feel quite satisfied by it. Some of the things are left to users to handle (like dynamic combining, as per one of my previous messages), but Python is such that this can be worked out without too much pain. I now have the feeling it would be easy to bring my Unicode applications to Python. Looking at Lib/encodings/, I see that a few are missing from what the official `recode' has, and would feel like providing now, or soon, directly in Python, all those encodings which interface naturally with Unicode (that is most of them, by the way). In fact, if I go further and consider the `recode' in pretest, all Asian encodings are missing, which are many. But since `recode' relies on `libiconv' for those, I believe it would be much more natural to directly interface Python and `libiconv'. I'm also seriously pondering the idea of developing a Python implementation of `recode' that I could use for faster prototyping, and which I would even include within the `recode' distribution, next to all the C code. Prototyping, while using C uniquely, requires a lot of energy, and there are many new ideas to explore. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From reic0024 at bulldog5.d.umn.edu Wed Mar 15 13:51:53 2000 From: reic0024 at bulldog5.d.umn.edu (Aaron J Reichow) Date: Wed, 15 Mar 2000 12:51:53 -0600 Subject: wxPython for Mac In-Reply-To: References: Message-ID: On Wed, 15 Mar 2000, Brett Tribble wrote: > While I assume that this work is directed at Mac OS 8.x 9.x, what happens > with OS X and its BSD kernal? Will we see a port of the *nix variant? I > suppose this depends on the implementation of wxWindows itself, but has > there been any movement on this? I personally have no clue, but getting it going under Carbon shouldn't be a godlike feat. Aaron From loewis at informatik.hu-berlin.de Tue Mar 21 14:19:22 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Mar 2000 20:19:22 +0100 Subject: "builtin" methods References: <200003152307.AAA09960@dionysus.fw.cuci.nl> Message-ID: "Hans Nowak" writes: > Paragraphs 3.3.1 to 3.3.6 have all these methods. (Well, I think it's all > of them... :) I noticed the "special" names used by pickle are not mentioned (__getstate__, __setstate__, __getinitargs__) are not mentioned. But then, they aren't really that special, either :-) Regards, Martin From aahz at netcom.com Wed Mar 15 12:05:08 2000 From: aahz at netcom.com (Aahz Maruch) Date: 15 Mar 2000 17:05:08 GMT Subject: Type testing References: <6D8A17398E28D3119F860090274DD7DB498597@pces.cadlab.it> Message-ID: <8aofs4$io3$1@nntp6.atl.mindspring.net> In article <6D8A17398E28D3119F860090274DD7DB498597 at pces.cadlab.it>, Alessandro Bottoni wrote: > >Is it possible to test for the type of an object (I mean, a built-in object: >a digit, a string, etc...)? Use the built-in type() function and the types module. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Three sins: BJ, B&J, B&J --Aahz From nospam at noreply.com Fri Mar 31 01:13:21 2000 From: nospam at noreply.com (Brian) Date: Fri, 31 Mar 2000 06:13:21 GMT Subject: Advice requested: GUI project beginning References: <8c0dpv$djc$1@nntp6.u.washington.edu> <38e3fa10.298739985@news.mr.net> Message-ID: <5mXE4.9512$lX4.216839@paloalto-snr1.gtei.net> > >- Tkinter is flaky on the Mac. For instance it doesn't run in the IDL > >and it doesn't fully quit. > > Ain't cross-platform GUI a bitch? So when is Python going to have a GUI library as tightly bound with it as Tk is to Tcl and Swing/AWT is to Java? Is wxWindows heading in that direction? Seems like having to distribute Tcl/Tk with your Python program to have a GUI is not the favorite thing for most Python developers. Unfortunately Tk is one of the most portable toolkits ... anyone know if Guido has expressed any interest in wxWindows being the standard Python GUI and distribute wxWindows with Python? wrote in message news:38e3fa10.298739985 at news.mr.net... > On Thu, 30 Mar 2000 12:35:09 -0800, "Russell E. Owen" > wrote: > > >I am starting work on a telescope remote control user interface. It's a > >big program with lots of windows and controls and display graphics > >supporting the telescope and numerous instruments. > > Sounds like a fun project! > > >Python is a leading contender because I'd like a system that offers: > >- rapid development/change/test > >- robust > >- safe (automatic garbage collection and bounds checking) > >- runs under both unix and MacOS, if possible (windows wouldn't hurt, > >either) > >- will probably be around in 10 years > > Yup...Python is guilty on all counts. > > > > >My development platform is Mac. I'd like to stick to that, but fear it's > >not reasonable with Python because: > >- No threads on the Mac. (yet) > >- Tkinter is flaky on the Mac. For instance it doesn't run in the IDL > >and it doesn't fully quit. > > Ain't cross-platform GUI a bitch? > > > > >Any comments? If I do switch, is Python development or support notably > >superior under unix or windows -- aside from OS preferences? (Please no > >OS flame wars.) > > If switching is an option it would certainly give you better Python > support _now_. As for your platform question, various flavors of Unix > seem to be the best platform, but that distinction is getting to be > less and less relevant. The win32 & com extensions by Mark Hammond, et > al, work wonderfully. > > *nix support still has the edge, though. Hell, it's a standard part of > many Linux distros, and easilly added to FreeBSD via the ports > collectioin. > > In addition, Linux might possibly give you the option of staying on > your current machine(s) with the use of Yellow Dog Linux or other > LinuxPPC ports. I believe NetBSD has a PPC port as well, and both > have 68K ports if you have an older Mac. > > >What Python windowing environment do you recommend for a new project? > >wxPython? Tkinter? Java (via JPython)? (Is there anything else?). I'd > >prefer something that is easy to use and scalable. > > I've mostly used Tkinter, because there is a decent knowledge base out > there, given its de facto standard status. The main platforms I use > (SUN, Win32 & Linux) all either come with tcl/tk as an (optional) part > of the OS distribution or, in the case of Win32, as part of the Python > install. Makes for one less thing I have to get the user to install to > use my code. > > I've grabbed copies of wxPython/wxWindows and FLTK with its Python > interface. You might want to check them out as well. > > As you've noticed, cross platform GUI isn't very smooth today. I'd > submit that this is true using *any* language system today, thought. > Java/Swing is often touted as the 'silver bullet', but experience here > at work tells me that it ain't. It does have the advantage of using > the vast Java hype flow as lubricant for getting the infrastructure > for your program installed on your customer's computers, tho. > > > > >-- Russell > > > >P.S. I am also considering Smalltalk (superb language, but ugly GUI and > >hard to sell to folks used to C/tcl/perl) and Java (reasonable Mac > >support and long-term prospects, but not very malleable). Are there any > >other languages I should consider? > > No opinion on that here. Of late the only languages I tend to consider > for use are Perl if I need a quick one-off, C if I need to hit the > metal or for performance reasons, Java if I need to fix or modify a > project that was already written in Java and Python for everything > else. > > -- > "If your map and the terrain differ...trust the terrain." -- unknown > From python-list at teleo.net Sat Mar 4 17:54:01 2000 From: python-list at teleo.net (Patrick Phalen) Date: Sat, 4 Mar 2000 14:54:01 -0800 Subject: HELP: restore my faith in Python In-Reply-To: References: Message-ID: <00030414581106.02808@quadra.teleo.net> [Moshe Zadka, on Sat, 04 Mar 2000] :: until-the-timbot-implements-slash-arithmetic-for-intel-cpus-ly y'rs, Z. That'll never happen ... doesn't fit the bot's oft-expressed Criterion of Uselessness. From tim_one at email.msn.com Thu Mar 2 00:06:10 2000 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 2 Mar 2000 00:06:10 -0500 Subject: Splitting comp.lang.python In-Reply-To: <836DAFF48BB74487.F181DAFF1B4CD5BF.DCA44F8A445A3160@lp.airnews.net> Message-ID: <000f01bf8405$07e1ba80$732d153f@tim> [Manuel Gutierrez Algaba] > comp.lang.python.tim.peters where Tim Peters would fight > against ruby, viper, Haskell ... whatever, where most syntax . [Cameron Laird] > That clever rascal! Here I thought he was > fighting *for* all those things. It does rather dull the point of Manuel's post: since he has clearly already learned to filter out what I post, it wouldn't do him much actual good to banish me to e.g. comp.lang.python.bots (I see no reason to banish Tim Peters to his own little corner! Uncle Timmy is a generally amiable and helpful fellow. Not a bad programmer, either, to judge from the flawless reliablity of my self-satisfaction module.). if-it-weren't-for-me-instead-of-ints-python-would-still-be-using- guido's-original-dutch-roman-numerals-ly y'rs - tim From fredrik at pythonware.com Tue Mar 14 08:10:16 2000 From: fredrik at pythonware.com (fredrik at pythonware.com) Date: Tue, 14 Mar 2000 13:10:16 GMT Subject: Q. on Introduction to Tkinter References: <38CE331C.F5AD9029@pivot.net> Message-ID: <8aldnm$lcs$1@nnrp1.deja.com> Wayne wrote: > "Note that the 'name' option can only be set when > the widget is created." Does "name" refer to the > 'option = value" pair? "the 'name' option" refers to a special option called "name", which is described back in chapter three (see "more on widget names"). > Second, If one does not define an "option = value" > at creation of the widget, does that mean you can > not use config () to set the value later? nope. the "name" option is special; it can *only* be specified when you create the widget. all other options can be modified at any time. Sent via Deja.com http://www.deja.com/ Before you buy. From gerrit at nl.linux.org Wed Mar 1 11:48:08 2000 From: gerrit at nl.linux.org (Gerrit Holl) Date: Wed, 1 Mar 2000 17:48:08 +0100 Subject: Splitting comp.lang.python In-Reply-To: <09ED98078750F0D8.61776C14C63DBD6A.80A949C9746AAA0B@lp.airnews.net>; from claird@starbase.neosoft.com on Wed, Mar 01, 2000 at 09:51:17AM -0600 References: <09ED98078750F0D8.61776C14C63DBD6A.80A949C9746AAA0B@lp.airnews.net> Message-ID: <20000301174808.A10405@nl.linux.org> > I'm not so sanguine about c.l.p.platform. What are > examples of postings you anticipate there? COM, Windows programming using win32api, Unic programming such as processes and sockets, Mac programming with the Macintosh extension modules. regards, Gerrit. -- -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From phd at phd.russ.ru Tue Mar 7 05:15:43 2000 From: phd at phd.russ.ru (Oleg Broytmann) Date: Tue, 7 Mar 2000 10:15:43 +0000 (GMT) Subject: FTP hangs with urllib.urlretrieve Message-ID: Hello! I am developing/running URL checker (sorry, yet another one :). And found that I have consistent hangings on some FTP URLs. Here is test program I am using to retest my results - just URLopener and urlretrieve, nothing magical; python is stock 1.5.2, hangs on all platforms I am using - Pentium Linux, Sparc Solaris, Pentium FreeBSD: ---------- #! /usr/local/bin/python -O import sys, urllib urllib._urlopener = urllib.URLopener() # Some sites allow only Mozilla-compatible browsers; way to stop robots? server_version = "Mozilla/3.0 (compatible; Python-urllib/%s)" % urllib.__version__ urllib._urlopener.addheaders[0] = ('User-agent', server_version) url = sys.argv[1] print "Testing", url try: fname, headers = urllib.urlretrieve(url) print fname print headers except Exception, msg: print msg import traceback; traceback.print_exc() ---------- The program always hangs on some (but not all) FTP URLs. One is well-known for Python community: ftp://starship.python.net/pub/crew/jam/ :) Others are: ftp://ftp.sai.msu.su/ ftp://ftp.radio-msu.net/ ftp://ftp.relcom.ru/pub/ ftp://ftp.sunet.se/pub/ ftp://ftp.cs.wisc.edu/ ftp://ftp.cert.org/pub/ I've tested these sites with FTP clients (Midnight Commander, Netscape Navigator, ncftp) - all are accessible. It seems like a bug or bugs in ftplib. The first two are very near to me in terms of Internet distance (hop counts), so timeouts should not be a problem. These are sites near my ISP (Radio MSU, in Moscow State University). Can anyone with better knowledge of FTP protocol look and help? Does latest python (from CVS) perform better (if anyone willing to test)? Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From corg at copernic.com Mon Mar 6 17:03:38 2000 From: corg at copernic.com (Gaetan Corneau) Date: Mon, 6 Mar 2000 17:03:38 -0500 Subject: Self Nanny Message-ID: > still-no-chance-of-changing-ly y'rs Prrrrrrrllllzzztbll! :P ______________________________________________________ Gaetan Corneau Software Developer Copernic Technologies inc. http://www.copernic.com E-mail: corg at copernic.com ______________________________________________________ "Tu l'as trop ?cras?, C?sar, ce Port Salut" -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/B/MU d- s+:++ a C++ UL+ P--- W+ N- K- W++ t-- !5 X- R+ tv-- b++ DI++ G e++ h---- r+++ y++++ ------END GEEK CODE BLOCK------ From eq3pvl at eq.uc.pt Tue Mar 21 12:31:23 2000 From: eq3pvl at eq.uc.pt (Pedro Vale Lima) Date: Tue, 21 Mar 2000 17:31:23 +0000 Subject: Simulating a Web Browser in Python References: Message-ID: <38D7B1EB.627FD865@eq.uc.pt> Brian Fritz wrote: > After checking through the standard library and a couple of web sites I've > not found (or maybe I didn't notice) a decent library that would allow me > to write a simulated web browser. > > I need to be able to read and write into edit controls and accept and > return cookies. > Probably you know it, but just in case you didn't noticed, GvR wrote a web browser in Python. It's called Grail and you can get it from www.python.org From python at rose164.wuh.wustl.edu Fri Mar 31 23:52:07 2000 From: python at rose164.wuh.wustl.edu (David Fisher) Date: Fri, 31 Mar 2000 22:52:07 -0600 Subject: Python Threading and sys.exit() codes References: <8c2u4v$cft$1@nnrp1.deja.com> Message-ID: <00b501bf9b98$73298b60$cbe9093f@spkydomain> ----- Original Message ----- From: Newsgroups: comp.lang.python To: Sent: Friday, March 31, 2000 1:26 PM Subject: Python Threading and sys.exit() codes > My problem is this: I want to run this program as a scheduled task > under a job scheduler (currently testing cronDsys from #ifdef). The > single-threaded version of the program posts an appropriate code to the > environment via sys.exit(). The job scheduler traps this and takes > conditional action. So far, so good. > In the multi-threaded version of the program, the exit codes are not > getting posted and the main process is not terminating cleanly, at > least from the perspective of the job scheduler -- it appears to run > until manually terminated from the scheduler control console although > the NT command window disappears from the target desktop as expected. Well for one thing, sys.exit() doesn't do what you think it does. Sys.exit() raises an exception SystemExit which if not caught will cause the thread to exit silently. Read the docs for thread which threading is built on. I don't know of a way to catch an exception that another thread raises. Doesn't mean there isn't one, just that I don't know one. Another thing you look at is the Queue module. That's what got my attention because you are setting a global lock and poping stuff off of a fifo stack, and Queue does all that for you. Here's some code: import Queue import thread #yes, I know I'm supposed to use threading def worker(jobqueue): while 1: job = jobqueue.get() # this blocks until a job is available print job # or whatever def main(joblist): jq = Queue.Queue(0) for i in range(10): thread.start_new_thread(worker,(jq,)) for job in joblist: jq.put(job) There are lots of things that could be prettified in this code, but I hope it gives you some ideas. You might try a second Queue to gather return information. Good luck, David From greglandrum at earthlink.net Sun Mar 12 16:31:48 2000 From: greglandrum at earthlink.net (greg Landrum) Date: Sun, 12 Mar 2000 21:31:48 GMT Subject: PIL and Windows Installations Message-ID: <38CC0DA9.5EF572BD@earthlink.net> Well, I've just gotten bit (again) by the "installing PIL under Windows" problem. I did a bit of Deja-News searching and discovered a couple threads from late last year which provided all the answers I needed. In the hopes of saving others from the frustration of trying to get PIL (which is so great that it's a MUST HAVE) installed on Windows, I'm posting my solution. This is based upon the most recent binary PIL distribution: http://www.pythonware.com/downloads/pil-win32-991101.zip and *requires* that Tkinter is installed on your machine. It comes by default with the windows python distributions, so this shouldn't be too much of a problem. The binary distribution of PIL appears to require Tcl/Tk anyway. Step 1: Unzip the archive (it doesn't matter where), this will create a directory py152. Copy the files/folders from py152 to your Python installation directory (c:\program files\python by default). That handles the installation. Now try running one of the PIL sample programs (I recommend Scripts/viewer.py). If you get an error, then you'll need to move to Step 2: Edit the file c:\program files\python\pil\Image.py Move down to around line 47, where you'll find: import _imaging change this to: import sys if sys.platform == "win32": import FixTk # Attempt to configure Tcl/Tk without requiring PATH import _imaging Save the file and try running Scripts/viewer.py again. It ought to work. I hope this is helpful. -greg -- greg Landrum (greglandrum at earthlink.net) Software Carpenter/Computational Chemist From alex at somewhere.round.here Wed Mar 1 12:31:10 2000 From: alex at somewhere.round.here (Alex) Date: 01 Mar 2000 12:31:10 -0500 Subject: I wasn't complaining! (Was: will python 3000 break my code?) References: <87tkoi$hql$1@nntp1.atl.mindspring.net> <08Zu4.6976$3z.60274@newscontent-01.sprint.ca> Message-ID: Fredrik and Gerrit, thanks for the info. I didn't realize it would be a type error. I wasn't complaining, though, just giving an example of why I think some rewriting will be necessary. And I'm not suprised that it turns out to be bad form. I'm not a professional coder, and I'm learning those sorts of aesthetics as I go along. Alex. From markx.daley at intel.com Tue Mar 21 18:47:31 2000 From: markx.daley at intel.com (Daley, MarkX) Date: Tue, 21 Mar 2000 15:47:31 -0800 Subject: Re-inserting data Message-ID: The only problem with that is I don't have any control over whether or not tuples are used. I am using SQL to query data from a server and this is the format it uses to return the data. Worse yet, the tuples are not strictly strings, but dates and numbers, also. I am trying to pull a date from each tuple, convert it, and return it to the tuple before it gets written to a file. Any ideas? - Mark -----Original Message----- From: Alex [mailto:alex at somewhere.round.here] Sent: Tuesday, March 21, 2000 1:46 PM To: python-list at python.org Subject: Re: Re-inserting data > Some clarification is necessary as to my earlier message. Here is what the > nesting is like. > > result = [(a, b, c, d, e), (a1, b1, c1, d1, e1),...] Oh, I guess you are having trouble changing the elements because they are tuples. Try using lists instead. Then you can do things like for item in times: time2 = item[-1] time2 = munged_time (time2) item[-1] = time2 Alex. From jstok at bluedog.apana.org.au Sun Mar 26 08:41:46 2000 From: jstok at bluedog.apana.org.au (Jason Stokes) Date: Sun, 26 Mar 2000 23:41:46 +1000 Subject: Internals of interning strings References: Message-ID: Michael Hudson wrote in message ... >Bernhard Herzog writes: > >> That's something I've also wondered about. How likely is it that one and >> the same string object will be interned several times? That seems to be >> the only thing that's really optimized. > >If you have this in one module: > >import sys,os > >and in another > >import sys,string > >then the string "sys" will get interned twice during compilation. So >to answer your question, pretty likely. But those are *different* string objects. The optimization we're discussing affects only *the same* string object being interned several times. From claird at starbase.neosoft.com Tue Mar 7 12:25:34 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 7 Mar 2000 11:25:34 -0600 Subject: Python performance References: Message-ID: <67980F7CE7203C29.8576A630FEE7042D.1147C70DD44393FD@lp.airnews.net> In article , Chris Ryland wrote: >The recent Python-for-Lisp-ers note and other recent notes have brought up >Python performance. > >I'm just curious (being an old language hacker for 30+ years but new to >Python): why is Python performance ultimately any worse than Lisp? > >Is it because there's only been one major implementation effort so far, and >so people haven't had a chance to learn the techniques required to make it >run fast, while Lisp has had 30+ years to mature? > >What's so different about compiling Python vs. Lisp? Some Lisp compilers >have gotten quite good over the years. . . . There have, in fact, been several Python implementations already . They look "major" to me, although I can imagine you might be setting the boundaries in a different place from me. Performance is an explicit motivation for most of the alternative Pythons. Guido regularly professes a lack of interest in performance. At least part of the time, he's using that to attract attention to his profound belief in the importance of correctness; he works very, very hard to get Python "right", and, from what I can see, has faith that performance will follow and/or can be left to others. One difference between Python and LISP is that with Python, as with most its contemporaries, one has more of a feeling that the performance- pertinent action is happening in the libraries rather than the language. My conclusion: Python performance can be (roughly) as good as LISP's. It is, already, for the domains that matter most to the big players of the Python world. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From tom at parlant.com Tue Mar 14 17:25:03 2000 From: tom at parlant.com (Thomas Lane) Date: Tue, 14 Mar 2000 15:25:03 -0700 Subject: Return statement question References: Message-ID: <38CEBC3F.9CAC0A31@parlant.com> Are you sure func3 was never executed? I cut your code (modified to print stuff to the screen) and it definitely ran func3. Here's the code I ran: def func1(): print 'func1' def func2(): print 'func2' return 1 def func3(sv): print 'func3' func1() val= func2() func3(val) The output (as expected) was: func1 func2 func3 -Tom Gregoire Welraeds wrote: > > > In this cas func3 is never executed... > > why ? > From cgw at fnal.gov Mon Mar 27 12:34:20 2000 From: cgw at fnal.gov (Charles G Waldman) Date: Mon, 27 Mar 2000 11:34:20 -0600 (CST) Subject: copy directory from a to b, how? Message-ID: <14559.39836.789275.35413@buffalo.fnal.gov> Use the "copytree" function in the (oft-overlooked) "shutil" module. No reason to resort to os.system'ing some non-portable command. From tiddlerdeja at my-deja.com Tue Mar 28 06:28:08 2000 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Tue, 28 Mar 2000 11:28:08 GMT Subject: copy directory from a to b, how? References: <8bne0u$jlu$1@nnrp1.deja.com> <8bnfof$le9$1@nnrp1.deja.com> <38DFA2DD.4C2EE42C@bellatlantic.net> Message-ID: <8bq4vu$jk6$1@nnrp1.deja.com> Why use os.path.walk() to delete files? Am I missing something here? Would it not just be easier to use shutl.rmtree() ? Also, I hadn't thought that there may be a permission/sharing issue with c:\inetpub\wwwroot. I just didn't want to remove it as it may take some time if wwwroot stores a large number of files. I also felt it to be a bit unknerving that I would be remving the root directory of my web server. In article <38DFA2DD.4C2EE42C at bellatlantic.net>, sholden at BellAtlantic.net wrote: > davec999 at my-deja.com wrote: > > > > In article <8bne0u$jlu$1 at nnrp1.deja.com>, > > tiddlerdeja at my-deja.com wrote: > > > I'd like to copy a directory from c:/Inetpub/staging to > > > c:/Inetpub/wwwroot. > > > > > > How do I do this in Python? I know that I have shutil.copytree() at my > > > disposal, but this requires that the destination directory doesn't > > > exist. I don't want to remove c:/Inetpub/wwwroot so that I can perform > > > the copy. > > > > > > What is the best way to do this? Any help appreciated. > > Is is essential to do it in Python? I would use the line: > > os.system("xcopy c:\\inetpub\\staging c:\\inetpub\\wwwroot\\ /E") > > Remember the backslashes in the correct place (at the end of the second > > argument and not at the end of the first) and you should be fine. > > Of course, if you want it to work on multiple OSs this will obviously > > not work. :) > > Dave > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > Also be aware of the various nastinesses that NT (this *is* an NT problem, > right?) will put in your way: the C:\Inetpub\wwwroot directory may well > be impossible to rename or delete, which I suspect is the motivation > behind the original question. > > If you were to stop the WWW publishing service you should find that you > can delete all files and subdirectories (use os.path.walk to find them) > from the existing web, and replace the old web with a new one either by\ > using walk again or by the effective method suggested above. > > regards > Steve > -- > "If computing ever stops being fun, I'll stop doing it" > Sent via Deja.com http://www.deja.com/ Before you buy. From akuchlin at mems-exchange.org Tue Mar 7 13:57:02 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 07 Mar 2000 13:57:02 -0500 Subject: delete comments with re References: <8a33u1$mir$1@nnrp1.deja.com> Message-ID: <3dya7uwqv5.fsf@amarok.cnri.reston.va.us> laurent8 at sxb.bsf.alcatel.fr writes: > with this regular expression I've got > >>> r="/\*.*\*/" > >>> re.sub(r,'',t) > 'a=b; class foobar {}' Instead of .* in the middle, try a non-greedy match with .*? : pat = re.compile('/[*] .*? [*]/', re.VERBOSE) t='a=b; ...' print repr(pat.sub('', t)) This outputs 'a=b; o=1; j=1; class foobar {}'. Comments in C don't nest, luckily, so the comment will end at the first */ encountered after the comment starts. (The comment in '/*a/*b*/c*/' is '/*a/*b*/', that is.) .* will run to the end of the string and then backtrack until it finds a */; it matches as *much* as possible. .*? will repeatedly advance by one character and try to match */ at every point, so it matches as *little* as possible. -- A.M. Kuchling http://starship.python.net/crew/amk/ The criterion of simplicity is not necessarily based on the speed of the algorithm or in its complexity in serial computers. -- Armand De Callatay, _Natural and Artificial Intelligence_ From embed at geocities.com Tue Mar 7 10:35:18 2000 From: embed at geocities.com (Warren Postma) Date: Tue, 7 Mar 2000 10:35:18 -0500 Subject: Python/MySQL Where do "SELECT ..." results go? References: <38C4F789.71ECCB04@sprint.ca> Message-ID: > >>>curs.execute("Select * from test;") Try dir(curs) and see if there are next, prev, first, last, etc methods. Always a good idea with an object to ask it "what can you do for me"... dir(obj) is how you ask. Warren From culliton at clark.net Tue Mar 14 09:44:13 2000 From: culliton at clark.net (Tom Culliton) Date: Tue, 14 Mar 2000 14:44:13 GMT Subject: [] vs. () References: Message-ID: <1fsz4.793$u%1.20182@iad-read.news.verio.net> You're missing the critical mutable/immutable distinction. Tuples can be used as dictionary keys since they are immutable. They can also be used to get pass by value semantics (even though values are actually always passed by reference) when calling functions since you know that they can't be modified by the called function. Not to mention that they're somewhat more efficient. It seems like I'm forgetting another use for their immutablility, but thats already more than enough rationale for their existance. In article , Jason Stokes wrote: > >Michal Bozon wrote in message ... >>__Hi__ >>Could anyone tell me the difference between tuples and lists? (except from >>that a list has few methods (append, extend, remove...) and tuple >>doesn't.) > >Well, that's the difference. In an object oriented language, objects differ >by their interfaces. Tuples are fixed size ordered collections of objects, >and lists are variable sized ordered collections. From sbahling at pitnet.net Sat Mar 4 22:08:55 2000 From: sbahling at pitnet.net (Scott Bahling) Date: Sat, 04 Mar 2000 21:08:55 -0600 Subject: When to use classes? Message-ID: <38C1CFC7.DD9F0918@pitnet.net> I am just starting to use python and I love it so far. I have a couple of philosophical questions about OOP programming with python. First: When and when not to create a new class? An example would be if I have a class for a Polygon, I need to store a set of points defining the polygon object. One method would be to store a list of tuples containing the polygon's points. If I want to access the individual x and y coords of each point, I end up with code that looks like: firstxcoord = poly.points[0][0] firstycoord = poly.points[0][1] Or I could create a Point class and use a list of them in the Polygon class. Then I would have code that looks like: firstxcoord = poly.points[0].x firstycoord = poly.points[0].y The second piece of code is easier to read. But lets say that this Point class has no other purpose but to contain two numerical values; is the use of a Point class overkill? Is there a 'rule of thumb' for when to create a new class? Second: What is the general consensus about accessing instance variables directly like myobj.x=10 vs. through methods like myobj.setx(10). The first method is quicker/easier to code, but is it "bad" coding? Does anyone even care? I know these are general OOP questions. I am asking in case there are aspects of the python language that would help to determine when and when not to do these things. -thanks scott From tuttledon at hotmail.com Wed Mar 8 22:42:02 2000 From: tuttledon at hotmail.com (Don Tuttle) Date: Thu, 09 Mar 2000 03:42:02 GMT Subject: Is it Python or is it C ? (long) References: <0%hx4.3000$N3.36008@typhoon.southeast.rr.com> <38C5C0D5.6ED417DE@houston.rr.com> Message-ID: [Fredrik Lundh] > summing up, the more you do in C, the faster your > program runs. but C doesn't help if you use a lousy > algorithm... [2] > > or in other words, if your Python program doesn't > run fast enough, use the profiler. or ask for help > on comp.lang.python! Whew! I hope you get to use all this good info in your next version of (the eff-bot guide to) the standard python library. (Which I own, btw. Free and clear with no lean against it! ;-) I did not know about the profiler. Until tonight I just thought it was a bad TV show . Thanks to everyone, Don From punck at SpamIsBadPenguinPowered.com Sun Mar 12 17:28:32 2000 From: punck at SpamIsBadPenguinPowered.com (Chris Armstrong) Date: Sun, 12 Mar 2000 17:28:32 -0500 Subject: import & __import__ Message-ID: <2MUy4.5284$bt3.17551@newsfeed.slurp.net> Hi all. I'm pretty much a newbie to Python, and I have a question about import vs __import__. I'm implementing dynamically imported modules in a game I'm writing, and I need to use __import__ to do this. One thing I noticed is that __import__ doesn't seem to execute the modules that it imports, while import does.. The docs for __import__ don't mention anything about this, and I'm just curious about it. I tested this by making a simple module that just has `` print "Hi." '' in it. `` import modulename '' caused it to print out "Hi." while `` foobar = __import__("modulename") '' didn't. This isn't really important to me, I was just curious about it. -- Chris Armstrong http://drol.sourceforge.net Geek code version 3.12 GCS d? s:-- a--- C+++ UL++++>++++ P++ L+++ E--- W++ N+ o? K- w-- O-- !M V PS+(+++) PE? Y+(--) PGP(--) t+ 5 X+ R tv+ b+>++ DI+ D+++ G e- h!(--) r- y? Go to www.geekcode.com to find out what on earth this is. From Alessandro.Bottoni at think3.com Wed Mar 8 04:43:02 2000 From: Alessandro.Bottoni at think3.com (Alessandro Bottoni) Date: Wed, 8 Mar 2000 10:43:02 +0100 Subject: Python 1.6 and Python 3000's new features? Message-ID: <6D8A17398E28D3119F860090274DD7DB498538@pces.cadlab.it> I just read the "Frankly Speaking" column at O'Reilly's site ( http://www.oreilly.com/frank/ ), and I was quite chocked by two of the news: [Python 3000] The contents of this version are still under discussion, but will almost certainly be backward-incompatible. [Python 1.6] In addition, Guido will include some existing bug fixes and probably Fredrik Lundh's new regular expressions engine Why Python 3000 should be backward-incompatible? Is it possible to have a "big-picture" of this major version? Why new regular expressions? What was wrong with the "old" re module? (I'm NOT criticizing anybody. I'm just curious...) Thanks -------------------------------- Alessandro Bottoni (Alessandro.Bottoni at Think3.com) (alessandro.bottoni at libero.it) Web Programmer Think3 inc. (www.think3.com) From mindlace at imeme.net Thu Mar 2 18:06:10 2000 From: mindlace at imeme.net (ethan mindlace fremen) Date: Thu, 02 Mar 2000 23:06:10 +0000 Subject: compiling python w/large files Message-ID: <38BEF3E2.F3782546@imeme.net> I'm trying to compile python with large files on Linux, using kernel 2.3.47 and Libc6 2.1.13-5. http://www.python.org/doc/lib/posix-large-files.html tells me how to do it for , but not for Linux. If i just ./configure, large file support doesn't happen. Thanks in advance, Ethan Fremen http://imeme.net From thantos at chancel.org Wed Mar 1 18:11:28 2000 From: thantos at chancel.org (Alexander Williams) Date: Wed, 01 Mar 2000 23:11:28 GMT Subject: Python for non-programmers References: Message-ID: Gentlemen, there is a /reason/ that Introduction to Computing 101 and Basics of Programming 102 take half a year to introduce together, and its not just because of the quarter system in the local college. Many people need that much time to pick up the lexicon and assumptive web of associations that we, as programmers, make use of every single day. Like any other field with its own symbology and culture, it takes time to get the grounding in the true basics. Think of the field of computing as a culture unto itself with many different regional languages and you'll be far closer to understanding /why/ this difficulty is as it is. -- Alexander Williams (thantos at gw.total-web.net) | In the End, "Join the secret struggle for the soul of the world." | Oblivion Nobilis, a new Kind of RPG | Always http://www.chancel.org | Wins From hernanf at my-deja.com Fri Mar 3 11:41:48 2000 From: hernanf at my-deja.com (Hernan M. Foffani) Date: Fri, 03 Mar 2000 16:41:48 GMT Subject: has anyone seen comp.lang.python.announce? References: Message-ID: <89oq0c$m5l$1@nnrp1.deja.com> In article , "Fredrik Lundh" wrote: > on all newsservers I have access to, c.l.py.announce has > been empty for about as long as I remember, > .... > and what's worse, it doesn't show up on deja.com either. > In my My-Deja the last one is your Dr. Dobbs dated March 1st. Something happened before though: On Feb 25th there were 3 different Dr. Dobbs articles and one on Feb 6. > can this be fixed, or should the newsgroup be scrapped? > I find it hard to believe that the python universe doesn't > produce enough new stuff to keep the newsgroup alive... Warm winter up there? Too many news to read at c.l.p now? :-) Regards, -H. -- Hern?n Mart?nez Foffani hernanf at my-deja.com Sent via Deja.com http://www.deja.com/ Before you buy. From markx.daley at intel.com Thu Mar 23 12:22:09 2000 From: markx.daley at intel.com (Daley, MarkX) Date: Thu, 23 Mar 2000 09:22:09 -0800 Subject: List limitations? Message-ID: If I connect to server2 alone, it works properly. If I connect to server2 first, then server 1, server2 works and server1 returns strange characters for familynames. I am using mxODBC, at least, as far as understand it from the notes I downloaded. -Mark -----Original Message----- From: aahz at netcom.com [mailto:aahz at netcom.com] Sent: Thursday, March 23, 2000 8:44 AM To: python-list at python.org Subject: Re: List limitations? In article , Daley, MarkX wrote: > >What this does is connect to a server and pull data from it based on each >family name in the familyname list, using an SQL query. Conceivably, this >code should connect to server1 and pull data for all familynames and write >that data to a file, server_familyname_date. Then it should connect to >server2 and do the same. However, when it connects to server 2, it isn't >pulling the familynames from the familyname list correctly. Instead, it is >pulling single character strings, like a, b, e, g, h, r, S (these are the >actual strings, which may or may not have some bearing on one of my >familyname entries, I haven't been able to verify). Has anyone else seen >problem remotely related to this? Any help is appreciated. Questions/suggestions: Have you tried connecting just to server2? What happens if you switch server2 and server1? Have you considered using mxODBC? -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Usenet is not a democracy. It is a weird cross between an anarchy and a dictatorship. --Aahz From tismer at tismer.com Tue Mar 28 15:33:07 2000 From: tismer at tismer.com (Christian Tismer) Date: Tue, 28 Mar 2000 22:33:07 +0200 Subject: Stackless 1.1 Homepage: www.stackless.com Message-ID: <38E11703.C98FA418@tismer.com> *** ANNOUNCING *** ANNOUNCING *** ANNOUNCING *** The Stackless Python Homepage has its own website: http://www.stackless.com Stackless Python 1.1 is about to be published there, soon. Version 1.1 is a major overhaul of speed and versatility.

Stackless Python 1.1 + Continuations 0.8 - a version of Python 1.5.2 that does not need space on the C stack, and first-class callable continuation objects for Python. (28-Mar-2000) Christian Tismer Mission Impossible 5oftware Team

From nospam.newton at gmx.li Mon Mar 13 03:09:41 2000 From: nospam.newton at gmx.li (Philip 'Yes, that's my address' Newton) Date: Mon, 13 Mar 2000 08:09:41 GMT Subject: Is it Python or is it C ? References: <0%hx4.3000$N3.36008@typhoon.southeast.rr.com> <38C5C0D5.6ED417DE@houston.rr.com> <004401bf8910$a42da4c0$01ffffc0@worldnet.att.net> <38C69E6D.CD268578@bellatlantic.net> <38C706CE.66B7C6AA@cosc.canterbury.ac.nz> <38C8309B.9CE1D7F6@earthlink.net> <38cb370e.471286558@news.nikoma.de> <38CBCCA4.50D9C2@bellatlantic.net> Message-ID: <38cc9f3e.62191398@news.nikoma.de> On Sun, 12 Mar 2000 16:58:10 GMT, Steve Holden wrote: >All of which goes to show that there will bever be an adequate >substitute for the pain of intensive proofreading. And even >*then* bugs will slip in to documentation. Proofreading by someone who is competent technically, too -- just catching spelling errors won't help you if it turns >>"dd".<< into >>"dd."<< . Cheers, Philip -- Philip Newton From Jim.Tittsler at tokyopc.org Thu Mar 9 02:23:23 2000 From: Jim.Tittsler at tokyopc.org (Jim Tittsler) Date: 9 Mar 2000 07:23:23 GMT Subject: Python and MS Excel References: Message-ID: On Sat, 4 Mar 2000 19:24:01 GMT, Scott Barron wrote: >Does anyone have a link to a tutorial on creating/using Excel spreadsheets >with Python? An article by Andrea Provaglio in Software Development Online uses driving Excel as a way to introduce Python. http://www.sdmagazine.com/features/fr_4.htm From gmiller at classic-games.com Thu Mar 23 16:00:11 2000 From: gmiller at classic-games.com (Greg Miller) Date: Thu, 23 Mar 2000 15:00:11 -0600 Subject: Embedding Python in a MUD References: <38D7EAA8.6863DEE3@classic-games.com> Message-ID: <38DA85DB.33E02193@classic-games.com> Phillip Lenhardt wrote: > Might I suggest checking out Moebius? > > Features: > > * Written in Python: almost everything is runtime-modifiable. And it provides appropriate multiuser security? > * SQL database backend. Yuck. Historically, people who've tried this with muds have reported poor performance in exchange for almost no benefit. SQL is nice for its intended purposes, but not so well suited for muds. > * Very dynamic: both data and code come from the database. > * No save/load issues. I take it you mean its fully persistent across reboots and crashes? > * Threaded. > * Player scripting in Python. Does it expose synchronization primitives to users? -- http://www.classic-games.com/ History does not repeat itself, but it does rhyme. *** Please limit .sigs to four lines and avoid HTML mail or posts. *** From python at rose164.wuh.wustl.edu Tue Mar 21 16:10:12 2000 From: python at rose164.wuh.wustl.edu (David Fisher) Date: Tue, 21 Mar 2000 15:10:12 -0600 Subject: Simulating a Web Browser in Python References: Message-ID: <007701bf93af$0a4de460$7a3dfc80@spkydomain> ----- Original Message ----- From: "Brian Fritz" Newsgroups: comp.lang.python To: Sent: Tuesday, March 21, 2000 1:37 PM Subject: Re: Simulating a Web Browser in Python > > Well to make my intent a bit more clear... What I'm writing is going to > be a Web Robot. > > However, I'd heard of grail and it may be a good source of example and > howto code. > Well then, in the Tools directory of the Python source is webchecker. It will traverse a web tree looking for bad links. In the same directory is websucker, which will mirror a remote web site locally when pointed at the root url. I use it all the time when I want to pull content from the web and maintain it's structure. dnf From haskin at ptway.com Fri Mar 17 01:44:10 2000 From: haskin at ptway.com (Brian Haskin) Date: Fri, 17 Mar 2000 01:44:10 -0500 Subject: SHA Hash in python? Message-ID: <38D1D43A.6EF351BE@ptway.com> Does anyone know of a python module for the SHA cryptographic hash? Thanks, Brian Haskin haskin at ptway.com From claird at starbase.neosoft.com Thu Mar 9 08:53:08 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 9 Mar 2000 07:53:08 -0600 Subject: What If Python Replaced Elisp? References: Message-ID: <86BBD5F8F3E4194C.5E28784F01135B4A.5AB14C055AD33D4B@lp.airnews.net> In article , Matt Curtin wrote: . . . > Tad> Would it be easier to add a COM (automation) interface to > Tad> XEmacs if Python were used instead of Elisp? > >I do not see why. . . . Because Mark Hammond has already worked miracles in educating Python about COM. Your general principle that elisp is already quite refined, and more capable and mature than naive observers realize, is unarguable. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From S.I.Reynolds at cs.bham.ac.uk Tue Mar 14 06:31:55 2000 From: S.I.Reynolds at cs.bham.ac.uk (Stuart Reynolds) Date: Tue, 14 Mar 2000 11:31:55 +0000 Subject: itoa -- oops. References: <38CD3583.2694@cs.bham.ac.uk> Message-ID: <38CE232B.3B86@cs.bham.ac.uk> Alex wrote: > > > I'm not aware of one, but it's easy to roll your own... > > That wasn't really safe. You could get into infinite loops with > non-integer or negative inputs. This version should cope with that: Great. I've included a quick fix to also let it work up to base 36 (10 digits + 26 letters). > import string, types > > def itoa (n, base = 2): > if type (n) != types.IntType: > raise TypeError, 'First arg should be an integer' if (type (base) != types.IntType) or not (2<=base<=36): raise TypeError, 'Second arg should be an integer between 2 and 36' > output = [] > pos_n = abs (n) > while pos_n: > lowest_digit = pos_n % base if lowest_digit>=10: output.append( chr( ord('a')+lowest_digit-10 ) ) else: output.append( str(lowest_digit) ) > pos_n = (pos_n - lowest_digit) / base > output.reverse () > if n < 0: > output.insert (0, '-') > return string.join (output, '') > > if __name__ == '__main__': > assert itoa (16) == '10000' > assert itoa (17) == '10001' > assert itoa (-17) == '-' + itoa (17) assert itoa(10, 16) == 'a' assert itoa(15, 16) == 'f' assert itoa(16, 16) == '10' assert itoa(255, 16) == 'ff' assert itoa(256, 16) == '100' assert itoa(35, 36) == 'z' assert itoa(36, 36) == '10' assert itoa(-35, 36) == '-z' assert itoa(-36, 36) == '-10' Stuart From akira.kiyomiya at autodesk.com Tue Mar 14 22:06:30 2000 From: akira.kiyomiya at autodesk.com (Akira Kiyomiya) Date: Tue, 14 Mar 2000 19:06:30 -0800 Subject: Don't Laugh.... Message-ID: <8amunr$qe8@autodesk.autodesk.com> I am very new to Python stuff, so I am going to ask you a really dummy question. I am trying to run Python, but it seems like I cannot. I am using Windows 98 and installed Python on my machine. I am simply using Python command line that tells me "Python 1.5.2 Copyright 1991-1995 Stichting Mathematish Centrum, Amsterdam". I created one document called "module.py" by using my text editor The "module.py" only has a sentense " print 'Hello World!'" and that's it. I saved this file on my desktop and c drive, so I simply typed >>>module.py but I keep getting a message "Traceback : File "", line1 , in ? NameError: module" I even tried >>>import module but it is same thing. I don't think I can go to any specifc path that I saved my python file. In case you are wondering if I installed Python correctly, my Python interpretor works since I can type "print 'Hello World!" Okay, what am I doing wrong?? From kc5tja at garnet.armored.net Mon Mar 27 08:14:28 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 27 Mar 2000 13:14:28 GMT Subject: expanding persistant objects References: Message-ID: In article , Moshe Zadka wrote: >> i'm worried if i start saving the data one way, when i go >> to add extra fields i wont be able to load the files anymore. > >Pickle (and hence shelve) were designed to deal with this. Pickle works _perfectly_ for this. Shelve, in my experience, blows chunks. The reason is that shelve uses a dbm-type database to store pickled objects in. The file it produces is, consequently, a BINARY file, and is therefore proprietary to the database manager used. I have had to use the shelve module on several occasions, particularly for in-house development projects where I work. Moving databases between equivalently configured machines (e.g., both running Debian and configured using apt-get the same way) proved to be a very expensive operation. I found cases where different versions of same-family dbm libraries couldn't read older files, and at least two machines couldn't even *FIND* the dbm libraries, despite having them properly installed. These were problems of Windows proportions -- something I'd never seen before on Linux. I have since switched from using shelves to just plain Pickle files, and have never, ever had this problem since. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From shogan at iel.ie Fri Mar 24 04:58:49 2000 From: shogan at iel.ie (Shaun Hogan) Date: Fri, 24 Mar 2000 09:58:49 -0000 Subject: test exercises??? Message-ID: <002b01bf9577$8d557ca0$2801000a@iel.ie> hi ive been learning python and c/python integration for the last number of weeks. can anyone tell me if there are any websites that will give me problems to solve so i can put what i think i know to the test. thanks. ===================== Shaun Hogan Interactive Enterprise Ltd. alt. E-mail : shaun_hogan at yahoo.com +353 86 8342529 -------------- next part -------------- An HTML attachment was scrubbed... URL: From milesthompson at sprint.ca Tue Mar 7 07:35:22 2000 From: milesthompson at sprint.ca (Miles Thompson) Date: Tue, 07 Mar 2000 08:35:22 -0400 Subject: Python/MySQL Where do "SELECT ..." results go? Message-ID: <38C4F789.71ECCB04@sprint.ca> Dear All, Please be patient with me, if I've done something incredibly dumb. I've workekd with FoxPro, Access, SQl Server for years, but the Python/MySQL combination is new to me. My query results disappear and all I get is a count of the records retrieved. Here's what I've done. (Explore is the database, and table Test has 5 records.) >>> import Mysqldb >>>conn = Mysqldb.mysqldb('explore') >>>conn # # here's my first attempt at a select # >>>conn.execute("Select * from test;") 5 # # wasn't what I wanted, so then I did this # >>>curs = conn.cursor() >>>curs.execute("Select * from test;") 5 # # Nope. Try assigning to a variable? # >>>data = curs.execute("Select * from test;") >>>data 5 # # and at this point it was 11:30, and over the past two days I'd # hammered myself through the Python tutorial, various Python docs, # set up MySQL and played with it interactively, reinstalled a new version # of Python (1.5.2) and the Python module for MySQL. # I used python-MySQLmodule-1.4.0-7.i386.rpm # So I went to bed. I must be close, but the documentation is "scanty" and short on examples. Suggestions, or a pointer to a web site that answers the question, has examples, will be welcome. TIA - Miles Thompson milesthompson at sprint.ca From S.I.Reynolds at cs.bham.ac.uk Mon Mar 13 13:37:55 2000 From: S.I.Reynolds at cs.bham.ac.uk (Stuart Reynolds) Date: Mon, 13 Mar 2000 18:37:55 +0000 Subject: itoa Message-ID: <38CD3583.2694@cs.bham.ac.uk> Is there an integer to ascii (itoa) function in Python? I need to convert integers into various different bases (but to binary, in particular). Most languages come provided with an itoa-like function but I can't seem to find one in the Python API. Stuart From jwbnews at scandaroon.com Fri Mar 17 10:25:39 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Fri, 17 Mar 2000 15:25:39 GMT Subject: Pascal int() References: Message-ID: In article , japhy at pobox.com wrote: > First, you'd better not call it int(), because that'd cause some sillyness > -- there's a builtin int(). For sake of argument, I'll call it inc(). inc() is a likely name: it's what N. Wirth called the thing. --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From rurban at x-ray.at Fri Mar 3 13:18:36 2000 From: rurban at x-ray.at (Reini Urban) Date: Fri, 03 Mar 2000 18:18:36 GMT Subject: win32com.client.dynamic: VARIANT type not supported for SAFEARRAYS References: <5OBv4.2211$vW.5056@news-server.bigpond.net.au> Message-ID: <38c0020a.22381332@judy> Mark Hammond wrote: >"Olaf Trygve Berglihn" wrote in message >news:dn1n1oi7mw4.fsf at kikp0524.chembio.ntnu.no... >> TypeError: The VARIANT type is not supported for SAFEARRAYS >> >> Any explanations and/or suggestions? > >The Python COM framework doesnt have support for that variant type in >safe array :-( I have no idea what the variant type is, but it must >be one of the more obscure ones. What is the property defined as >returning? Presumably it is an array, but of what? Not a obscure one. A safearray of variants is a generic array which holds the union type (aka Variant, i.e. any type) instead of immediate (aka typed) data. The Variant is the basic IDispatch (late bound OLE) type, used to pass any types to/from ActiveX objects. The Safearray is an extension of a variant, holding a range-checked and type-checked array. A Safearray of variants is the most generic array type. -- Reini Urban http://xarch.tu-graz.ac.at/autocad/lisp/ffis.html From jajs at NOSPAMretemail.es Sun Mar 26 14:31:40 2000 From: jajs at NOSPAMretemail.es (*puntero_loko) Date: Sun, 26 Mar 2000 19:31:40 GMT Subject: Python tutorial/comparison for C++ programmer References: <8b956c$9tn$1@nnrp1.deja.com> <077C600D9F281A4D.487194D3E94C88DA.D53DE68986E89418@lp.airnews.net> <8bcr2a$b76$1@nnrp1.deja.com> Message-ID: Michael Hudson dijo sobre Re: Python tutorial/comparison for C++ programmer, en fecha: 23 Mar 2000 13:35:57 +0000 |I suppose it could be viewed as competition to VB, but then that's not |really relavent until Python gets a flashy point n' click GUI, and |even then, if micorsoft ship Visual Python (tm), how does this impact |me? Then we have to hide Glade... - From erno at iki.fi Tue Mar 14 02:26:02 2000 From: erno at iki.fi (Erno Kuusela) Date: 14 Mar 2000 09:26:02 +0200 Subject: How do I ... References: <38CD2368.9D29554F@abo.fi> Message-ID: >>>>> "Cesar" == Cesar Lopez writes: Cesar> How do I acces to the low-level of my system? I mean, for Cesar> example, I want to access and configure the speed of my Cesar> serial port using a Python program. It depends on your platform, as the std python distribution doesn't have platform specific serial io modules and accessing serial ports is not defined by C. If you happen to be using a unixish system, just opening the serial port os.open() and using the termios module or stty(1) should work. Cesar> I've tried building an extension C function and the call it Cesar> from Python, but doesn?t works. You are doing it wrong then :) If you tell us how it fails to work, people may be able to help. -- erno PS. This is in the FAQ. You should look in there before posting, so the newsgroup/mailing list doesn't get fooded with repeated questions on the same topic. From tgdeveloper at my-deja.com Fri Mar 10 16:10:42 2000 From: tgdeveloper at my-deja.com (tgdeveloper at my-deja.com) Date: Fri, 10 Mar 2000 21:10:42 GMT Subject: python-mode with GNU Emacs? Message-ID: <8aboce$23t$1@nnrp1.deja.com> Does python-mode.el (from www.python.org) work with GNU Emacs (20.5.1)? When I try to byte-compile the file, I get the following: --- Compiling file c:/Emacs/emacs-20.5/lisp/textmodes/python-mode.el at Fri Mar 10 10:50:51 2000 ** assignment to free variable zmacs-region-stays While compiling the end of the data: ** The following functions are not known to be defined: py-beginning-of-def-or-class, py-end-of-def-or-class, make-extent, set-extent-property, buffer-syntactic-context, py-mark-block, py-goto-block-up --- Then when I try to load-file "python-mode.elc" I get a message stating "too many arguments." Any help would be appreciated. Tom Sent via Deja.com http://www.deja.com/ Before you buy. From mhammond at skippinet.com.au Tue Mar 28 06:30:53 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 28 Mar 2000 11:30:53 GMT Subject: Determining Ethernet HW Address References: Message-ID: "Darrell" wrote in message news:dhSD4.7202$JE5.97355 at typhoon.nyroc.rr.com... > "Jerome Chan" wrote in message > > Is there a portable way of determining the Ethernet HW Address? > > > For windows without using Win32 try parsing the output of ipconfig /all I couldnt resist :-) In win32all-130 you will be able to use the Netbios function: from netbios import * # code ported from "HOWTO: Get the MAC Address for an Ethernet Adapter" # MS KB ID: Q118623 ncb = NCB() ncb.Command = NCBENUM la_enum = LANA_ENUM() ncb.Buffer = la_enum rc = Netbios(ncb) if rc != 0: raise RuntimeError, "Unexpected result %d" % (rc,) for i in range(la_enum.length): ncb.Reset() ncb.Command = NCBRESET ncb.Lana_num = ord(la_enum.lana[i]) rc = Netbios(ncb) if rc != 0: raise RuntimeError, "Unexpected result %d" % (rc,) ncb.Reset() ncb.Command = NCBASTAT ncb.Lana_num = ord(la_enum.lana[i]) ncb.Callname = "* " adapter = ADAPTER_STATUS() ncb.Buffer = adapter Netbios(ncb) print "Adapter address:", for ch in adapter.adapter_address: print "%02x" % (ord(ch),) , print Yields on my dual-NIC server: Adapter address: 00 a0 cc 54 22 2d Adapter address: 00 40 05 6b fc ca (both of which are correct :-) Mark. From dma at cyrus.andrew.cmu.edu Tue Mar 21 13:07:39 2000 From: dma at cyrus.andrew.cmu.edu (David Andersen) Date: Tue, 21 Mar 2000 13:07:39 -0500 Subject: Building Mac Python 1.5.2 Message-ID: <875417.3162632859@inuvik.hcii.cs.cmu.edu> I'm trying to build the Macintosh PythonCorePPC from the Python 1.5.2c1 source, using CWGUSI from Jack Jansen's site (built for PPC only) and CodeWarrior Pro 5.3. Compiling is no problem, but I then get the following link errors: Does anyone know what is going on? Link Error : export symbol 'fwalk' is undefined Link Error : export symbol '_prealloc_newpool__3stdFUl' is undefined Link Error : export symbol '_set_newnonptrmax__3stdFUl' is undefined Link Error : export symbol '_set_newpoolsize__3stdFUl' is undefined Link Error : export symbol '__malloc_pool' is undefined Link Error : export symbol '__num_to_file' is undefined Link Error : export symbol '__file_to_num' is undefined Link Error : export symbol '__pool_free' is undefined Link Error : export symbol '__pool_realloc' is undefined Link Error : export symbol '__pool_alloc_clear' is undefined Link Error : export symbol '__pool_alloc' is undefined Link Error : export symbol '__pool_preassign' is undefined Link Error : export symbol '__pool_preallocate' is undefined Link Error : export symbol '__init_pool_obj' is undefined Link Error : export symbol '__vfscanf' is undefined Link Error : export symbol '__end_critical_region' is undefined Link Error : export symbol '__begin_critical_region' is undefined Link Error : export symbol '__vfwscanf' is undefined Link Error : export symbol 'SIOUXclrscr' is undefined From effbot at telia.com Sun Mar 12 09:12:38 2000 From: effbot at telia.com (Fredrik Lundh) Date: Sun, 12 Mar 2000 14:12:38 GMT Subject: Compiling a Python script References: <_wwy4.14142$ql2.184042@typhoon.we.rr.com> Message-ID: LineNoise wrote: > I wrote a smal script for a friend to use, but he doesn't have the Python > interpreter, and he isn't going to have it anytime soon. I downloaded the > source distribution and tried to use the freeze tool, but it didn't work. I > think I have to compile/install the source distr to get it to work, but how > do I do that? My computer is running win98, and I have a copy of Visual C++ > that I can use, but I have no experience with it. start here: http://www.mcmillan-inc.com/install1.html From alex at somewhere.round.here Wed Mar 29 12:09:49 2000 From: alex at somewhere.round.here (Alex) Date: 29 Mar 2000 12:09:49 -0500 Subject: Incompatibility between socket and httplib in python CVS build. References: Message-ID: > iow, update your CVS copy and reinstall the standard library, and this > problem will go away. Oh, right. Sorry. Alex. From jpc at informatics.jax.org Wed Mar 8 15:25:18 2000 From: jpc at informatics.jax.org (John Corradi) Date: Wed, 08 Mar 2000 15:25:18 -0500 Subject: emacs can't find python-mode Message-ID: <080320001525180664%jpc@informatics.jax.org> Hi All, I've tried to install the python-mode.el for Emacs 20.3.1, but it tells me it can't find python-mode. I followed all of the instructions on the Python site. I've never customized Emacs before and the only lines in my new .emacs file are the ones for using the python-mode library. When I try "M-x locate-library RET python-mode RET" it tells me that it can't find python-mode in the search path despite the fact that I've added the appropriate line to my .emacs file. Am I missing something? How do I make sure python-mode is in the load-path? TIA. John -- John Corradi jpc at informatics.jax.org From mwh21 at cam.ac.uk Thu Mar 16 04:56:58 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 16 Mar 2000 09:56:58 +0000 Subject: Assigning output from a simple python statement References: <01bf8f1f$a611b640$3201a8c0@wraith.mclachlan.com.au> Message-ID: "Wilson Fletcher" writes: > I would like to execute an unknown python statement and store the output. > > It will typically be a print statement. eg. "print 'Hello World'" > > I won't know the statement until runtime becuase it will come from a > database. BUT I want to capture anything that goes to stdout and process > it. try this: import sys,StringIO def capture_output(code): so = sys.stdout sio = StringIO.StringIO() sys.stdout = sio try: exec code finally: sys.stdout = so sio.seek(0) return sio.read() not tested, but should work. I leave out my usual "do you really want to `exec' things you don't know everything about" comment, I think. Cheers, M. -- very few people approach me in real life and insist on proving they are drooling idiots. -- Erik Naggum, comp.lang.lisp From wlfraed at ix.netcom.com Sat Mar 25 00:00:06 2000 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Fri, 24 Mar 2000 21:00:06 -0800 Subject: HELP Newbie solve this Problem References: <8beo97$fm7$1@nnrp1.deja.com> <2atlds0ordevolp8ubbfghdi75ih0bdvst@4ax.com> <38DC2E16.6096@marshall.edu> Message-ID: On Fri, 24 Mar 2000 19:06:25 -0500, Mark Hathaway declaimed the following in comp.lang.python: > I can't really believe the Fartran code takes that much space. > I suspect it's given as a set-up, so the Python code to follow > will be all the more impressive. Well, here's a Python version. > > import string > lines = open('file.txt').readlines() > for each in lines: > eachlist = string.split(each) > str = eachlist[1] + " " + eachlist[0] > print str > > If you'd wanted the output printed back to a file then you could > add something other than the final 'print str' statement. > > Amazing isn't it? When a language doesn't get in your way the code > is brief and more readable. It's all the niggling little details > that a language like Fortran or C require that makes them very ugly. > I think either you missed a requirement, or I went too far... >From the original poster: history> The ?data?? file is the preamble to the constitution. history> The objective is to write a command that will give a list of how many history> times the letters appear in the preamble. Try not to use awk. The original program input is not that list of numbers and letters, but plain text to be counted (ignoring case and punctuation/numerics). I was just surprised the example output implied that the format was more difficult to produce than the ordering... -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From moshez at math.huji.ac.il Mon Mar 13 20:07:02 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 14 Mar 2000 03:07:02 +0200 (IST) Subject: itoa In-Reply-To: <38CD3583.2694@cs.bham.ac.uk> Message-ID: On Mon, 13 Mar 2000, Stuart Reynolds wrote: > Is there an integer to ascii (itoa) function in Python? I need to > convert integers into various different bases (but to binary, in > particular). Most languages come provided with an itoa-like function but > I can't seem to find one in the Python API. Have a look at the builtin "str" function -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From harold.taylor.remove-this at delete-this.uni-tuebingen.de Thu Mar 9 07:07:13 2000 From: harold.taylor.remove-this at delete-this.uni-tuebingen.de (H.V.Taylor) Date: Thu, 09 Mar 2000 13:07:13 +0100 Subject: how to catch signals References: Message-ID: <55HHOFE191QSaSQR5a2xg24K1Jpq@4ax.com> quinn at mono.ugcs.caltech.edu (Quinn Dunkan) wrote: >Hello! I have a process that starts children, and perhaps kills them at some >time. The children need to be unregistered when they die, so I set up a ... >.. snip ... >... after I kill (I can't just wait() afterwards, because it's >possible someone else killed it). Gosh, you sound blood-thirsty ;-)) I guess I'll have to read Kragen Sitaker's "Crime in Python" as well... Harold From nick at spam_me_notvideosystem.co.uk Mon Mar 6 05:26:27 2000 From: nick at spam_me_notvideosystem.co.uk (Nick Trout) Date: Mon, 6 Mar 2000 10:26:27 -0000 Subject: DirectX 7 and python References: <38c012da$0$2943@senator-bedfellow.mit.edu> Message-ID: <38c3854d@news.xtml.co.uk> "Robert" wrote in message news:38c012da$0$2943 at senator-bedfellow.mit.edu... > Hi, > With the release of DirectX 7, MS included a type library for Visual > Basic users > to access DX functionality. Apparently (from using the makepy and win) it > does not > provide automation/dispatch interfaces, so python can't access it. My > question is two-fold: > 1)Has anyone written pythoncom extensions to provide the necessary > interfaces? > 2)How does one go about writing a custom interface in pythoncom? Does anyone > have some sample code? I've been working on a wrapper for DX7 RM. ie. not COM/direct access. Pet project so slow progress! I did look for other projects doing this but found none, which surprised me. Have you come across anyone else working on DX Python stuff? From alex at somewhere.round.here Wed Mar 29 19:50:06 2000 From: alex at somewhere.round.here (Alex) Date: 29 Mar 2000 19:50:06 -0500 Subject: How to tell in site.py if python is being invoked interactively? References: <20000329194024.A1006339@vislab.epa.gov> Message-ID: Hi, Randall. No, I just have control over the python program they're going to use. Sorry about the bogus address. If I set the Mail-Followup-To header to the list address, won't replies to my messages that are CC'd to the newsgroup show up twice? On the other hand, a null address means mail people send me just disappears... Alex. From scherbi at bam.com Wed Mar 29 13:00:36 2000 From: scherbi at bam.com (Bill Scherer) Date: Wed, 29 Mar 2000 13:00:36 -0500 Subject: Rational-Rose and Python ... References: <8bt5fh$p2t$1@news.urz.uni-heidelberg.de> <38E22E94.CC6E66E@bam.com> Message-ID: <38E244C4.D69D3B4A@bam.com> Warren Postma wrote: > > It sounds like the modelling wasn't your primary problem on that project. > > Yes, probably. However, I find most new technologies, in attempting to > overcome a developer's resistance to trying something new, end up oversold. > A nice thing about Python, IMHO, is that because it's a language to which I > have the source code, it's not oversold. If it can't do something, I can > make it do something [like Christian Tismer's Stackless Python]. > > I think the same would be true for UML. The Tigris stuff looks exciting for > the same reason. If there's something my Case tool won't do, I can go in and > add it, send a patch, and it might even get put into the program. In other > words, the latest ROSE doesn't do much for me, even with it's much enhanced > two-way tools, but an open source UML tool might end up being just as handy > as Python itself. Even better if it worked from inside > Python/PythonWin/IDLE/etc, and was truly "compact" in much the same way as > Python is. > > Warren > agreed. From Richard.Jones at fulcrum.com.au Wed Mar 15 17:44:45 2000 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Thu, 16 Mar 2000 09:44:45 +1100 Subject: Pointers In-Reply-To: Message from Curtis Jensen of 2000-Mar-15 14:25:18, <38D00DCE.9740380F@be-research.ucsd.edu> Message-ID: <200003152244.JAA27546@envy.fulcrum.com.au> [Curtis Jensen] > I haven't found anything about pointers in python. Is there a pointer > type? If so, what is the syntax? In Python, the things you have come to know as variables are best thought of as "labels" for objects. In old-fashioned pointer-language-speak, they're about as equivalent to references or pointers as you're going to get. >>> a = 'hello world' >>> id(a) 135105304 In this case, 'a' is a label for the string object 'hello world'. We could assign another "pointer" to the same string by: >>> b = a >>> id(b) 135105304 So 'b' is now a label on the same object as 'a'. In pointer-language-speak, it's a pointer referencing the same data. Note that Python special-cases some very common objects (only immutable ones) so that you're using a reference to the same object: >>> c = 1 >>> id(c) 134955600 >>> d = 1 >>> id(d) 134955600 Neat huh? Common strings that you use in your programs may be intern()'ed ... but I'll leave that as an exercise for you to find out about (see the Library Reference for details about intern() and id()). Richard From gmcm at hypernet.com Thu Mar 9 23:29:45 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 9 Mar 2000 23:29:45 -0500 Subject: Python -> Win32 EXE In-Reply-To: Message-ID: <1259459908-1440638@hypernet.com> A[r]TA wrote: > > > not really -- but what you really want is the "installer" > > from the nice people at McMillan Enterprises, Inc: > > > > http://www.mcmillan-inc.com/install1.html > > > > The program gives a message: > Can't find DLL's, copy them to the right dir? > > Can somebody help me? I just trie to compile something with simple.py and it > doesn't work! The message most likely to match your vague description is produced when the installer can't figure out what your system directory is (because you don't have the Win32 extensions installed). In that case, before starting installer, do c:\>PATH=%PATH%;C:\Windows\System or whatever your system directory is. - Gordon From craigf at ilid.com.au Mon Mar 20 22:06:42 2000 From: craigf at ilid.com.au (Craig Findlay) Date: Tue, 21 Mar 2000 14:06:42 +1100 Subject: stdout and redirection (win NT) Message-ID: <3npddssd9fksp73pkor1tl3m0mqvg672tm@4ax.com> What am I doing wrong here? My sample python program test.py is: import sys sys,stdout.write('Hello World') >From a command prompt, I type: test.py and I get the expected Hello World output on the console. Next, I type: test.py > c:\myfile.txt I expect the file myfile.txt to contain the redirected output from the python script. Instead, myfile.txt exists but is empty. What is happening? Craig Findlay From mikael at isy.liu.se Tue Mar 28 09:48:07 2000 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 28 Mar 2000 16:48:07 +0200 (MET DST) Subject: No Vault my Fault? In-Reply-To: <8bqfrr$q14$1@weber.a2000.nl> Message-ID: On 28-Mar-00 Ilja Heitlager wrote: > Don't know where else to send this to, but is the Vault of Parnasses closed > or something? > Everytime I would like to enter www.vex.net/parnassus it asks me for a > password Could it be because I am on a Window$ machine with (UPC) cable > connection? (You Dutch readers know what I mean ;-) No problem for me... /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 28-Mar-00 Time: 16:47:54 This message was sent by XF-Mail. ----------------------------------------------------------------------- From tim_one at email.msn.com Thu Mar 9 21:23:18 2000 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 9 Mar 2000 21:23:18 -0500 Subject: What If Python Replaced Elisp? In-Reply-To: Message-ID: <000701bf8a37$992c12a0$58a2143f@tim> [Neel Krishnaswami] > There are actually a whole lot of optimizations that could be done, > but aren't, in the current Python interpreter. > > For example, in the following code: > > import operator > > lst = [] > for i in range(100): > lst.append(i**2 + i**2) > > result = reduce(operator.add, lst) > > You can statically infer the type of result, the final size of lst, > avoid actually allocating a range() object, eliminate the the > typechecks that make sure that i has a __pow__ method, the bounds > checks on the range object, do available expressions analysis on the > i**2 to avoid calculating it twice, and probably a few more > optimizations that I don't know about. Actually not, you can't do any of that now! You currently have no way to know that, e.g., some *other* module didn't import this one (let's call this one "neel"), and redirect neel.range and neel.reduce to some arbitrary functions of its own devious choosing. Heck, the call to neel.range may even reach back in and change neel.lst to anything at all before the loop body is entered. "i" may end up referring to an object whose __pow__ method sends email to Afghanistan; etc. This is why the Types-SIG is so keen to impose restrictions on what modules can do to each others' namespaces (in the presence of optional static typing). > ... > You don't have to win every game to make it to the championships. :) you-don't-even-need-to-win-one-but-it-sure-can't-hurt-ly y'rs - tim From wware at world.std.com Fri Mar 17 16:41:11 2000 From: wware at world.std.com (Will Ware) Date: Fri, 17 Mar 2000 21:41:11 GMT Subject: system calls to sh References: <38D295F8.C88CD9E4@stsci.edu> Message-ID: Alex (alex at somewhere.round.here) wrote: > >>> del os.environ['MY_VAR'] That doesn't work, but this will: >>> os.environ['MY_VAR'] = '' -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From jeffp at crusoe.net Fri Mar 10 07:38:14 2000 From: jeffp at crusoe.net (Jeff Pinyan) Date: Fri, 10 Mar 2000 12:38:14 GMT Subject: Duplicates in lists In-Reply-To: References: <38C748C7.35162A7B@teleatlas.com> <38C81A12.6B4E85EE@exceptionalminds.com> Message-ID: [posted & mailed] On Mar 10, Quinn Dunkan said: >>> is there someone who has an efficient function that finds >>> all duplicates in a list? >def uniq(a): > r = {} > for i in a: > r[i] = None > return r.keys() Your approach loses the order of the keys. If this is not acceptable, I offer: def ord_uniq(a): r = {} ret = [] for i in a: if not r.has_key(i): ret.append(i) r[i] = 1 return ret Or, using OrderedDict.py: def ord_uniq(a): r = OrderedDict.OrderedDict() for i in a: r[i] = 1 return r.keys() -- MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve japhy at pobox.com http://www.pobox.com/~japhy/ http://pinyaj.stu.rpi.edu/ PerlMonth - An Online Perl Magazine http://www.perlmonth.com/ The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/ From python at rose164.wuh.wustl.edu Fri Mar 3 05:55:00 2000 From: python at rose164.wuh.wustl.edu (David Fisher) Date: Fri, 3 Mar 2000 04:55:00 -0600 Subject: Access to _inp()/_outp() on Win95? References: <38bf3add@news.gvsu.edu> Message-ID: <002801bf84fe$ec5ada80$0201a8c0@spkydomain> After I wrote the first message I got to thinking, if you have SWIG, this is even easier. So, version 2. This implements the exact same module as the first one, but as you can see, you don't need to do anything with the Python/C api. Two steps (after SWIG is installed): swig coniomodule.i will make the c file coniomodule_wrap.c (and coniomodule_wrap.doc but that's not relevant). Now your Setup.in file should be one line: conio coniomodule_wrap.c Then run the compile.py script (by David Ascher, typo in the first message) to create the project files (this will also include the swig step in the project file, so you can rebuild in one step, cool huh?). If you knew all of this already, feel free to ignore me (and use the code ). I needed to brush up on my extension coding, and somebody else might find this interesting. David ----- Original Message ----- From: "Andrew Sterian" Newsgroups: comp.lang.python To: Sent: Thursday, March 02, 2000 10:07 PM Subject: Access to _inp()/_outp() on Win95? > Has anyone exposed the _inp() and _outp() functions under Win95/98 > in an extension module? I need to access some I/O ports directly and > was hoping to not reinvent the wheel. > > Thanks, > > -- > Andrew Sterian | > Assistant Professor | > Padnos School of Engineering | (616) 771-6756 > Grand Valley State University | > > > -- > http://www.python.org/mailman/listinfo/python-list -------------- next part -------------- A non-text attachment was scrubbed... Name: coniomodule.i Type: application/octet-stream Size: 131 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: coniomodule.c Type: application/octet-stream Size: 192 bytes Desc: not available URL: From effbot at telia.com Thu Mar 30 12:29:04 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 30 Mar 2000 17:29:04 GMT Subject: parsing CSV files with quotes References: Message-ID: Warren Postma wrote: > Another is that any code with eval() can do "way more than I intended" by > calling eval, since eval() is basically opening up the entire parser. > > Is there some code to do eval_literals_only() that knows about parsing > literal expressions but which can't be made to call any functions? value = eval(expression, {"__builtins__": {}}) for more info, see the eff-bot guide. From aa8vb at yahoo.com Tue Mar 28 07:47:38 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 28 Mar 2000 07:47:38 -0500 Subject: Can Python handel bignum or big floating point data type please? In-Reply-To: <0OqOOIs29gof883lmOsGthhxEC6Q@4ax.com> References: <0OqOOIs29gof883lmOsGthhxEC6Q@4ax.com> Message-ID: <20000328074738.B786492@vislab.epa.gov> cmfinlay at magnet.com.au: |Can Python handel bignum or big floating point data type please? |I have read that Python can handle long integer however I'm after a |long float | |In using Python on the win32 platform. |email me at cmfinlay at magnet.com.au |or please reply here. http://www.python.org/topics/scicomp/numbercrunching.html -- Randall Hopper aa8vb at yahoo.com From eric.hopper at ebenx.com Thu Mar 9 19:36:37 2000 From: eric.hopper at ebenx.com (Eric Hopper) Date: Thu, 09 Mar 2000 18:36:37 -0600 Subject: How do I... References: Message-ID: <38C84395.1F428E0F@ebenx.com> Brett Tribble wrote: > How do I find the name of the script that is currently running from within > the script? > > I.E. If I'm running C:\python\myscript.py how do I determine this? > > Brett import sys print sys.argv[0] From bboard at parc.xerox.com Tue Mar 28 15:21:52 2000 From: bboard at parc.xerox.com (Mail Archiving Daemon) Date: Tue, 28 Mar 2000 12:21:52 PST Subject: changing LD_LIBRARY_PATH for Python script Message-ID: <00Mar28.122133pst."3426"@watson.parc.xerox.com> Hi. I'm in a situation where I need to set the LD_LIBRARY_PATH before loading a Python module. But I can't find a way of doing this from Python. By the time I'm actually in the Python script, the interpreter is running, and changing the value of os.environ has no effect on that process (or on the dl mechanism). I could use a trick like Martin's #!/bin/sh true=0; then=1; fi=1; if true : then exec python "$0" "$@" fi del true, then, fi If I could only figure out the right strings to put in there :-). The code that is affected is a shared library loaded from *another* shared library that is in turn loaded from Python as a Python module. Bill From bjorn at roguewave.com Wed Mar 15 19:28:31 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 15 Mar 2000 17:28:31 -0700 Subject: Pointers References: <200003152259.JAA27601@envy.fulcrum.com.au> <38D01D46.28817769@be-research.ucsd.edu> Message-ID: <38D02AAF.78B3D200@roguewave.com> Curtis Jensen wrote: > > Richard Jones wrote: > > > > [Curtis Jensen] > > > Pointers are sometimes usefull. I have a module that creates a > > > dictionary. I want to include some elements from the distionary in one > > > class and other elements in another class. If I had pointers, I could > > > do that. Is there another way? > > > > As I explained in my response to your post (unlike the unhelpful Bjorn ;) > > you're already dealing with a reference there. The dictionary is an object and > > your only control over it is via your reference to it. You can make labels > > (variables) for that reference, or pass that reference around to functions or > > methods. I think you'll find that you can already do what you want: > > > > >>> class A: > > ... def foo(self, a): > > ... a['A'] = 1 > > ... > > >>> class B: > > ... def foo(self, b): > > ... b['B'] = 1 > > ... > > >>> a=A() > > >>> b=B() > > >>> d={} > > >>> a.foo(d) > > >>> b.foo(d) > > >>> d > > {'B': 1, 'A': 1} > > > > Richard > > Maybe I'm missunderstanding, but it appears that this is just a copy > routine. I want something like this: > > >>> d={'A':0,'B':0} > >>> class A: > ... def __init__(self): > ... self.a -> (Pointer to) d['A'] > ... > >>> class B: > ... def __init__(self): > ... self.b -> (Pointer to) d['B'] > >>> a=A() > >>> b=B() > >>> print a.a > 0 > >>> print b.b > 0 > >>> d['A'] = 1 > >>> d['B'] = 2 > >>> print a.a > 1 > >>> print b.b > 2 > > If the data in the dictionary changes, I want the data in the class to > automaticaly change also. Is this possible? Or at least something > close? yes. If you read through what Richard wrote above a couple of times, while remembering that ints are immutable and lists aren't, you should be able to understand the following: d = {'A':[0], 'B':[0]} # use a list as a box to put ints in class A: def __init__(self): self.a = d['A'] class B: def __init__(self): self.b = d['B'] a = A() b = B() print a.a[0] # should be 0 print b.b[0] # should be 0 d['A'][0] = 1 d['B'][0] = 2 print a.a[0] # should be 1 print b.b[0] # should be 2 Please don't do this There is almost always a more straightforward way of doing things like this. -- bjorn ps: in Richard's example the dictionary is _not_ passed by value, so there is no copying going on. The technical term is pass-by-object-reference, but you can think of it as pass-by-pointer in e.g. C++/C but with automatic dereferencing. From nielsenjf at my-deja.com Fri Mar 10 20:04:19 2000 From: nielsenjf at my-deja.com (John Nielsen) Date: Sat, 11 Mar 2000 01:04:19 GMT Subject: Python and Active Directory References: Message-ID: <8ac62h$c7m$1@nnrp1.deja.com> Using the constant 1 seemed to work (throwing in erroneous constants does make errors), but I didn't sniff packets to make sure. Btw, the pythonldap module (works fine w/exchange), looks to support kerberos(I haven't tested it), which may be useful for those playing with win2000. It is nicer than ADSI in some ways since it leverages python dictionaries. And, of course, pythonldap allows a unix box to talk to an MS box. john In article , "Mark Hammond" wrote: > > "Augustine David" wrote in message > news:t8Yx4.1012$Qf.532452 at news-west.usenetserver.com... > > -----BEGIN PGP SIGNED MESSAGE----- > > > I am attempting to reproduce the SDK examples below in Python. I > have ran > > "makepy" on the type library, > > but I am unsure how to call any of its classes using > > "win32com.client.Dispatch". Any input you can give me > > would be appreciated. > > This is a little painful unfortunately. Note the second line - this > is necessary to force the constant ADS_SECURE_AUTHENTICATION into the > COM constants namespace. This second line was generated by running > "makepy.py -i". Otherwise you could just use the literal constant 1 > :-) Normally the constants are "magically" loaded by the time you > need them, but not in this case. > > This requires build 128 of win32all. Also I cant make it work, but I > think I simply can't get the strings correct (Ive struggled with this > before :-( Sent via Deja.com http://www.deja.com/ Before you buy. From joacim at home.se Fri Mar 17 10:30:02 2000 From: joacim at home.se (JJ) Date: Fri, 17 Mar 2000 16:30:02 +0100 Subject: Java editor for Python References: <8atgsd$ava$1@vg170.it.volvo.se> Message-ID: <8atj21$k2m$1@vg170.it.volvo.se> So what! I want to use a Java editor even if you don't like Java or not. Java IS a great programming language but there is several more. I can't say that Python is one because I can to little about it (for now). I use JPython in my Java application and it seems to work just fine. // Joacim "Darrell" wrote in message news:pXrA4.24285$W5.355862 at typhoon.nyroc.rr.com... > "JJ" wrote in message > news:8atgsd$ava$1 at vg170.it.volvo.se... > > Hi! > > > > Anyone who knows where to find an editor written in Java with syntax color > > highlighting? > > > > It's a VERY big plus if there is a java bean and/or source code available. > > > > Java ? Java ! > We don't do no stinking JAVA! > > Be there is a colonizing editor that comes with Python for Python. > Checkout Idle in the tools directory or Pythonwin. > > > --Darrell > > > > > From ehagemann at home.com Mon Mar 20 21:38:14 2000 From: ehagemann at home.com (Eric Hagemann) Date: Mon, 20 Mar 2000 21:38:14 -0500 Subject: Building and Transvering multi-level dictionaries Message-ID: <01BF92B4.99B88AC0@cc264973-a.hwrd1.md.home.com> Nathan, Thanks for the correction. I guess my many years of C programming shows through ! Cheers Eric -----Original Message----- From: Nathan Clegg [SMTP:nathan at islanddata.com] Sent: Monday, March 20, 2000 9:05 PM To: Eric Hagemann Cc: python-list at python.org Subject: Re: Building and Transvering multi-level dictionaries On 21-Mar-2000 Eric Hagemann wrote: >#add a key and setup for a sub-dictionary > if(D.has_key('a') == 0) > D['a'] = {} In my opinion, this is a very dangerous habit to get into. Unlike C, perl and python have more than one false value. I don't know that you can be sure that a built-in such as this is guaranteed to be consistent between versions of python. Even more dangerous is that modules and functions written by others could use any of the false values. I personally always return None for false. Seems to me much safer to do: if not D.has_key('a'): D['a'] = {} ---------------------------------- Nathan Clegg nathan at islanddata.com From tim_one at email.msn.com Tue Mar 7 00:32:56 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 7 Mar 2000 00:32:56 -0500 Subject: Python performance In-Reply-To: Message-ID: <000d01bf87f6$97ffede0$2b2d153f@tim> [Chris Ryland] > ... > I'm just curious (being an old language hacker for 30+ years but new to > Python): why is Python performance ultimately any worse than Lisp? > > Is it because there's only been one major implementation effort > so far, and so people haven't had a chance to learn the techniques > required to make it run fast, while Lisp has had 30+ years to mature? > ... Python was implemented by essentially one guy in his "spare time", outside of academia, and raw speed was never one of his primary goals. Portabililty, robustness, maintainability, and ease of extending with C *were* primary goals, and Python meets or beats mosts Lisps on all of those counts despite having enjoyed less than a fraction of a percent of a percent of the total development effort that's been poured into Lisps (or Javas or Smalltalks, for that matter). nothing-a-few-million-dollars-and/or-legions-of-grad-student-slave- labor-couldn't-repair-but-the-mere-passage-of-time-won't-change- it-ly y'rs - tim From Lisowski.Tomasz at sssa.nospam.pl Sat Mar 25 02:41:19 2000 From: Lisowski.Tomasz at sssa.nospam.pl (Tomek Lisowski) Date: Sat, 25 Mar 2000 07:41:19 GMT Subject: Python on Alpha OpenVMS Message-ID: Hi! I have tried to compile Python sources on my VAX OpenVMS system, but soon I realized, that instead of my trusty DEC C++ compiler I need a native C compiler. Unfortunately my C++ compiler cannot be reverted to a native C language mode. Has anyone succeeded to create VAX OpenVMS Python binaries? Note: Apart from VAX OpenVMS I have also an Alpha OpenVMS server, but here I don't have any C/C++ compiler available. If anyone has created Alpha OpenVMS Python binaries, please contact me too. Thanks in advance Tomasz Lisowski From clopez at abo.fi Wed Mar 15 10:47:49 2000 From: clopez at abo.fi (Cesar Lopez) Date: Wed, 15 Mar 2000 17:47:49 +0200 Subject: wrapping drivers for Python Message-ID: <38CFB0A5.1636CAA8@abo.fi> I?m want to wrap some drivers that I have running in my system, but I want use this drivers with pythno programs. I?ve build and linked statically an external module for my Linux machine that emulates the behaviour of one of my devices, a green led. But I don?t know how to access to the low-leve system I only print on/off on my screen. If you know how to wrap or access to the low-leve or your machine with Python tell me. Here is my driver code: //led.h int Setup(int state); // state = 1 --> ON ; state = 0 --> OFF int static _state; // Defining communication with the device, Port, Adress, configuration registers and so on ... #define PBIOR (*(volatile short int *) (0x5ffffc6)) #define PBCR1 (*(volatile short int *) (0x5ffffcc)) #define PBCR2 (*(volatile short int *) (0x5ffffce)) #define PBDR (*(volatile short int *) (0x5ffffc2)) //led.c #include "led.h" int Setup(int state) { PBIOR |= 0x8000; // Set the bit for output PBCR1 &= ~0xc000; // Make it a normal I/0 switch (state){ case 1:{ PBDR |= 0x8000; // Set the LED on _state=1; // to read the state of the led return 0; } case 0:{ PBDR &= 0x0000; // Set the LED off _state=0; return 0; } default: return -1; // Error: Invalid code } //switch } From tuttledon at hotmail.com Thu Mar 2 17:39:07 2000 From: tuttledon at hotmail.com (Don Tuttle) Date: Thu, 02 Mar 2000 22:39:07 GMT Subject: Python and Windows Scripting Host References: <89jfkk$qcp$1@nnrp1.deja.com> <38BE7D61.E17FEBF2@gssec.bt.co.uk> Message-ID: [Alan G.] > Nope, WSH doesn't do any GUI stuff - its designed > to replace BAT files agfter all! > ??? Try running this script. import win32com.client shell = win32com.client.Dispatch("WScript.Shell") rslt=shell.Popup("Would you like to run Notepad?", 0, "Python WSH Test!", 35) if rslt == 6: shell.run("notepad") else: shell.Popup("Maybe next time.", 4, "Bye!") Using Python to access WSH objects, like Mark Hammond suggested, makes alot more sense than using WSH as the controlling environment. (providing you not forced into a mixed environment like Gaetan has mentioned). Although I still prefer WinBatch for Admin stuff. Don From tiddlerdeja at my-deja.com Wed Mar 15 09:44:15 2000 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Wed, 15 Mar 2000 14:44:15 GMT Subject: read NT registry with python References: <8alo1n$tdc$1@nnrp1.deja.com> <8ansn6$ece$1@nnrp1.deja.com> <8anvhr$1756@newton.cc.rl.ac.uk> Message-ID: <8ao7jt$m6t$1@nnrp1.deja.com> Thanks for that, very much appreciated. However, the second line: win32api.RegQueryValueEx('AdminPassword') I get an error with this: >>> win32api.RegQueryValueEx('AdminPassword') Traceback (innermost last): File "", line 1, in ? TypeError: RegQueryValueEx requires exactly 2 arguments; 1 given Any help with this is greatly appreciated. p.s. I realise this is lame me asking this, but I'm new to registry terms and I don't know what the second var should be. In article <8anvhr$1756 at newton.cc.rl.ac.uk>, "Richard Brodie" wrote: > > wrote in message news:8ansn6 $ece$1 at nnrp1.deja.com... > > > [HKEY_LOCAL_MACHINE\SOFTWARE\WOF] > > > > [HKEY_LOCAL_MACHINE\SOFTWARE\ABC\PlusSoftware] > > "AdminPassword"="Admin" > > import win32api > from win32con import * > > k=win32api.RegOpenKeyEx(HKEY_LOCAL_MACHINE, > 'SOFTWARE\\ABC\\PlusSoftware',0,KEY_QUERY_VALUE) > > win32api.RegQueryValueEx('AdminPassword') > > Sent via Deja.com http://www.deja.com/ Before you buy. From tim_one at email.msn.com Tue Mar 7 00:19:17 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 7 Mar 2000 00:19:17 -0500 Subject: HELP: restore my faith in Python In-Reply-To: Message-ID: <000b01bf87f4$b0444f60$2b2d153f@tim> [bunching together several replies here] [Tim] > int(0.999999999999999999993427) == 1 > int(0.99999999999999999993427) == 1 > int(0.9999999999999999993427) == 1 > int(0.999999999999999993427) == 1 > > and so on? So long as you draw the line *somewhere*, you haven't solved > anything, you've merely moved the surprises from where they're > predictable across *all* IEEE-754 platforms to something unique to Python. > > The problems with floating-point are deep and can't be patched > over. "Quick hacks" always backfire. If somebody wants to indulge in a > notion of "safe epsilon", there's nothing to stop them from writing > that explicitly. [Konrad Hinsen] > APL has a "comparison tolerance", implemented as a global (but > localizable) variable that can be changed by the user, and which > specifies the maximum relative error that is considered zero for the > purpose of comparisons. It's a handy feature for quick calculator-type > calculations, but it can get in the way when implementing more complex > algorithms. Note that the original poster was aiming at "fuzzing" float->int, though. Fudging fp comparisons can almost be made principled, but e.g. there's no reasonable way to do it without making it possible to find distinct x, y and z s.t. x==y and y==z but NOT x==z. Note too that APL is rife with implicit "under the covers" float->int conversions, while Python has none (i.e., the Python programmer must always say explicitly how they want float->int to get done). [John W. Baxter] > ... > 4. A decimal floating point class could certainly be written for > Python. Such have been; AFAIK almost nobody uses them, though. There's more call for it in the business world, where a penny rounded away is a billion-dollar lawsuit . [Neel Krishnaswami] > ... > Is this possible? I've forgotten most of my analysis, but I was under > the impression that you could divide the continuum as follows: > > o Rationals -- eg 2/3. Countably infinite. > o Algebraic irrationals -- eg sqrt(2). Countably infinite. > o Transcendental numbers -- everything else. Uncountably infinite. > > So presumably you could write numeric classes that properly (if you > don't care about speed or memory usage) handle rationals and algebraic > irrationals, but the full transcendentals are just plain impossible. > Maybe some interesting subset of the transcendentals are possible; > if you throw in e and pi most people will be happy most of the time? > Though on reflection this is getting pretty close to a full symbolic > computation package. What you're groping for is called the "constructive" or "computable" reals. There's a well-developed theory, and a few scattered implementation pkgs. The most recent influential text is by Pour-El and Richards -- curiously enough, I studied mathematical logic under the former and real analysis under the latter, so can vouch for their sterling characters . A sketchy intro to the main results can be found in Jean Vuillemin's "Exact Real Computer Arithmetic with Continued Fractions", IEEE Transactions on Computers, Vol 39 No 8, August 1990. H-J Boehm did a widely used implementation in the now-defunct Russell language, still available (last I checked) from Rice University. Just last year he released a more accessible (but plainer) implementation in Java, available from somewhere or other on the SGI web site. As I said at the start, though, *all* approaches to real arithmetic suck in deep ways. For example, while exp(log(pi + 1e-5000)) is exactly equal to pi + 1e-5000 under the computable reals, equality is in general undecidable, float->int also, and even figuring out the first digit of a constructive real's decimal expansion is in general undecidable too. > I guess Mathematica is that expensive for a reason -- arithmetic is > harder than I thought. :) Check out Macsyma (http://www.macsyma.com/). A sixth the price and more than adequate for most anything you'd like to explore. It does not implement the constructive reals, though. [Michael Hudson] > Food for thought: the computable numbers are countable. > > Proof left as an exercise for the reader (it's not hard!). > > (Is it even meaningful to ask whether they are [recursively] > enumerable?) Sure! That's meaningful for any countable set. It turns out that while they're countable, they're not recursively enumerable. If they were, you'd have an effective algorithm for computing one not in the enumeration, via the usual diagonalization trick. Since you *can* enumerate all possible programs, this may appear paradoxical. The "out" is that deciding whether a program produces a computable real is undecidable. And if your programming language is so weak that that question *is* decidable, then the same diagonalization argument proves that it's not strong enough to capture the notion of computable reals. almost-as-much-fun-as-continuations-ly y'rs - tim From effbot at telia.com Thu Mar 30 12:14:26 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 30 Mar 2000 17:14:26 GMT Subject: extending python: c++ problem References: <8bvmko$gki1@mailgate1b.telekom.de> Message-ID: Torsten H?rmann wrote: > Does anyone know about the following problem and have a solution? > I've written a python extension using c++. No Problems with msvc, but on > HPUX with aCC. When importing the , the python interpreter can > not find the "initmod" function in the created lib. Error message: > > >>> import mod > Traceback (innermost last): > File "", line 1, in ? > ImportError: dynamic module does not define init function (initmod) > >>> name mangling problems? using "nm" to figure out what happens to you "initmod" function might give you some clues... (maybe iostream.h the README and Misc/HPUX-Notes contain additional information on building shared libraries under HPUX: README: HP-UX: Please read the file Misc/HPUX-NOTES for shared libraries. When using threading, you may have to add -D_REENTRANT to the OPT variable in the top-level Makefile; reported by Pat Knight this seems to make a difference (at least for HP-UX 10.20) even though config.h defines it. Misc/HPUX-NOTES: There are two important points. First, the python executable must be linked with the -E option to explicitly export all symbols. This works with the vanilla interpreter, but I am not sure how friendly it will be when I try to embed the interpreter in a larger application. It may be necessary to hand tune the exports using the -e option. Anyway, the additional flag to $(CC) is "-Wl,-E", which passes the -E flag to the compiler. My link line (from an actual run) looks like this: cc config.o -Wl,-E libModules.a ../Python/libPython.a ../Objects/libObjects.a ../Parser/libParser.a -lm -ldld -o python [Guido's note: as of Python 1.5, replace the four libraries with ../libpython$(VERSION).a] Second, the dynamic module must be compiled with the +z option to make it position independent and then linked into a shared library: ld -b -o module.sl The -b tells the linker to produce a shared library. hope this helps! From bjorn at roguewave.com Wed Mar 1 14:14:34 2000 From: bjorn at roguewave.com (bjorn) Date: Wed, 01 Mar 2000 12:14:34 -0700 Subject: will python 3000 break my code? References: <87tkoi$hql$1@nntp1.atl.mindspring.net> <08Zu4.6976$3z.60274@newscontent-01.sprint.ca> <20000301083301.A25444@nl.linux.org> <615v4.1509$mYj.192181248@newsa.telia.net> <38BD6119.CC842307@roguewave.com> Daniel Berlin wrote: > >>>>> "bjorn" == writes: > > >> [snippage] > >> 3) it's considered Bad Style to use multi-argument append, IMHO. > >> ahem. does your HO really matter to all those who have to spend time > >> and money changing their existing code base. preliminary results > >> indicate that *all* our applications and libraries (including PIL) are > >> affected by this change. given that, it's quite likely that a few > >> other companies will also stumble upon this one... > > bjorn> I must say I was kind of concerned when Guido announced this > bjorn> change. Where I work, source code incompatible changes are an > bjorn> almost complete no-no, even for major releases. The impact to > bjorn> customers is just too great. The moral is probably, if you made an > bjorn> implementation boo-boo, you better learn to live with it quickly. > > Oh. I see. MS syndrome. > > This is the silliest thing i've ever heard. > If your C++ compiler has an implementation bug, and accepts some code it > shouldn't, then they shouldn't fix it because too many customers might depend > on buggy code? > Sorry, that's just not the way it works. > This is a *BUG*. NOT A FEATURE. > Why is this so hard to understand. > You don't deprecate bugs. > You fix them. > Anyone who made a bug in their code, has to fix it. > But they didn't know, you say? > Now they know. > When I worked at MS (MS Research, but I knew intimately what went on inside > MS, obviously), there was way too much of this mentality of "We can't fix > bugs because customers depend on them". > They were right of course, that it would break programs. > Mainly Idiot programmers (sorry, but i'm referring to the idiots specifically > coding assuming a *BUG* would always exist. It's different to make a mistake, > or check for a bug. But to simply assume no one will ever fix it is idiotic) > would program assuming bugs would always be there. > MS wouldn't fix the bug, because it would break too many programs. > So they were damned either way. > If they fixed it, it would break programs. > If they left it, they get yelled at for not fixing bugs. > So invariably, they left it. > This isn't the right answer. > The answer is to try to fix the bug as quickly as possible, so the least > number of people have the chance to write buggy code. > But if, later on, you find the bug, and it's existed for quite a while, that > doesn't mean you don't fix it. > If it was a feature, i might agree. It's not. > It's a bug. > Bugs don't get deprecated. > I don't see g++ saying "Warning: Doing this will no longer work in the next > version because you shouldn't have been doing this in the first place.". > It says "ANSI C++ forbids ...". > It's an error. No, it's a design change by a standards committe, that has evaluated all the options, giving individual vendors the chance to veto any changes that would be too radical for their customers (I know, I've been there). It's an enormous leap from that to deciding that list.append(1,2,3) might be so confusing to some newcomers that people who know what they were doing have to change their code (ask Frederik if he doesn't have more interesting things to do than fixing multiargument appends ;-) > Unless you turn on a flag turning compliance errors into warnings. > Most people will actually turn off the warning rather than fix the broken > code. > > Does this break a lot of code? > Sure. > Should that code break? > Yup. > > Should people stop fixing bugs in the python implementation cause some major > customer has programmers who wrote buggy code? > Nope. Was this a bug? Not really. Was it a source incompatible design change? You bet. > bjorn> I suppose I can agree with his analysis of the "evils" of > bjorn> multiargument append, but I'm not sure I think it's a big enough > bjorn> deal to break source compatibility. > > God damn it. It's not a feature. It's a bug. A bug. It should have been an > error nit he first place. It's only by the grace of Guido and a slip of the > eye that it wasn't. And nobody would have complained if it _was_ an error in the first place. > | the-days-of-legacy-code-are-upon-us'ly y'rs > No they aren't. If you're going to have any luck getting a company (vs. individual dedicated programmers) to use your tools, is if the tools are stable enough that a company doesn't have to spend money every time you do a new release. If you do think a change is neccessary, and they often are although I'm not sure this particular one rises to that level, you should at least warn customers by upping a major rev number (or waiting until it's time to do so). The-price-of-purity-is-obscurity'ly y'rs -- bjorn ps: since Guido hath spoken, there really is no reason to discuss this further, so this'll have to be my last words on the issue -- I know we're all heartbroken From skeltobc at mailandnews.com Tue Mar 14 11:17:06 2000 From: skeltobc at mailandnews.com (Ben Skelton) Date: Tue, 14 Mar 2000 17:17:06 +0100 Subject: Sorting a Dictionary Message-ID: <00031417174709.00246@avalon> On Tue, 14 Mar 2000, Remco Gerlich wrote: >> for i in range(len(l)): >> print l[i] > >But but but... why not simply > >for i in l: > print i > >That idiom range(len(l)) is only useful if you're actually doing something >with the index, other than using it as an index... I sometime have to use the first form if the elements of the list are being modified...it's annoying and maybe I've missed something: >>> a = ['one', 'two', 'three'] >>> for x in a: ... x = x + '***' ... >>> print a ['one', 'two', 'three'] >>> for i in range(len(a)): ... a[i] = a[i] + '***' ... >>> print a ['one***', 'two***', 'three***'] --Ben From barmeier at barmeier.com Fri Mar 17 04:20:44 2000 From: barmeier at barmeier.com (Matthias Barmeier) Date: Fri, 17 Mar 2000 10:20:44 +0100 Subject: Makeing a constant ?? Message-ID: <74u3ds8qrkpup3n7aqo5m6jiediiv5mvmk@4ax.com> Hi, In a funtion call I have to use a constant as one of the parameters. I want this constant to be created on the fly depending on some user input. Is it possible in Python to "make" a constant !? Ciao Matze From nobody at nowhere.nohow Tue Mar 21 00:10:55 2000 From: nobody at nowhere.nohow (Grant Edwards) Date: Tue, 21 Mar 2000 05:10:55 GMT Subject: Code basics References: <8ath59$c7i$1@vg170.it.volvo.se> Message-ID: On 17 Mar 2000 14:29:36 -0500, Alex wrote: > >> Why should the return value of a logic test be "obscure" knowledge? > >The return value itself is not terribly obscure, but your code's >reliance on it is relatively obscure, compared with something like > >if predicate: > result = true_value >else: > result = false_value > >I can understand the intent of this immediately, whereas with your code, >I had to think for a moment about what the results of your code could >be, and then determine the intent. > >> Why "hide" something so basic? > >It's not a question of information hiding, it's question of clarity. Right, it's not a question of information hiding, it's a question of intent hiding. -- Grant Edwards grante Yow! I'm definitely not at in Omaha! visi.com From deirdre at deirdre.net Tue Mar 14 11:44:00 2000 From: deirdre at deirdre.net (Deirdre Saoirse) Date: Tue, 14 Mar 2000 08:44:00 -0800 (PST) Subject: Guido van Rossum to speak in Mountain View 3/15 at 8 pm Message-ID: Guido will be speaking to to BayPIGgies tomorrow evening (Wednesday, March 15) on several topics including 1.6 development. Last time Guido spoke to BayPIGgies, he spoke to a packed house. We now have a larger facility for him to speak in. :) For more information, see: http://www.baypiggies.org For public transit directions, see: http://linuxmafia.com/bale -- _Deirdre * http://www.linuxcabal.org * http://www.deirdre.net "During my service in the United States Congress, I took the initiative in creating the Internet." -- Al Gore "If Al Gore invented the internet, I invented spell check." -- Dan Quayle From sp00fD at yahoo.com Tue Mar 21 09:43:53 2000 From: sp00fD at yahoo.com (sp00fD) Date: Tue, 21 Mar 2000 14:43:53 GMT Subject: python apps Message-ID: <8b81r5$b1q$1@nnrp1.deja.com> I've created an application that is written in python (http://www.erols.com/m.v.wilson), the install script is currently in shell (no real reason). I was wondering if there is something close to a standard installation method that is used to distribute python applications (not modules), or if it's just a custom thing. Also, anyone that wants to take a look at my code (see the above url), please feel free, I'd love some critiques and help!! I'm pretty new to python and OOP, so I'm not sure if this is any good or not (my programming technique (or lack thereof)). Thanks Sent via Deja.com http://www.deja.com/ Before you buy. From andres at hidalgo.cnchost.com Sat Mar 25 15:52:31 2000 From: andres at hidalgo.cnchost.com (Andres M. Hidalgo) Date: 25 Mar 2000 15:52:31 EST Subject: Python Journal Message-ID: <8bj8uf$3to@journal.concentric.net> Anyone know of any magazine publication dedicated to the python community like the ones dedicated to perl (Perl Journal) or Linux (Linux Journal) ???. andres at hidalgo.cnchost.com From bjorn at roguewave.com Wed Mar 29 20:43:23 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 29 Mar 2000 18:43:23 -0700 Subject: socket.connect() and socket.bind() change References: <20000329195448.O3140@coltronix.com> <8bttej$16q8$1@nntp6.u.washington.edu> Message-ID: <38E2B13B.22C530B3@roguewave.com> Donn Cave wrote: > > Quoth nascheme at enme.ucalgary.ca (Neil Schemenauer): > | I think this change is going to break a lot of code. The example > | in the documentation used to use: > | > | s.bind(host, port) > | > | and > | > | s.connect(host, port) > | > | Unlike the append() change I would consider this to be changing a > | documented interface. All of my socket code will be broken by > | this change. Anyone else? > > Not me, I seem to have missed that version of the document - the > 1.4 and 1.5 library references say bind(address) and connect(address), > and that's all I have at hand at the moment. > > But it looks like a couple of distribution library modules, ftplib and > gopherlib, use 2 arguments as above, so it's not just you. Library reference 7.2.2 Example uses two arguments. -- bjorn From gmiller at classic-games.com Tue Mar 21 16:33:28 2000 From: gmiller at classic-games.com (Greg Miller) Date: Tue, 21 Mar 2000 15:33:28 -0600 Subject: Embedding Python in a MUD Message-ID: <38D7EAA8.6863DEE3@classic-games.com> I'm considering Python as an in-mud scripting language. I have a few questions I haven't been able to find the answers to: (1) Are there any good tutorials on python embedding? (2) Can multiple python interpreters run in separate threads without interfering with each other (data corruption, locking, etc)? (3) Is there an easy way to serialize/deserialize objects to a custom database? -- http://www.classic-games.com/ History does not repeat itself, but it does rhyme. *** Please limit .sigs to four lines and avoid HTML mail or posts. *** From t_e_sanders at my-deja.com Wed Mar 29 15:39:29 2000 From: t_e_sanders at my-deja.com (t_e_sanders at my-deja.com) Date: Wed, 29 Mar 2000 20:39:29 GMT Subject: SimpleHTTPServer problems when tying up main thread Message-ID: <8btplu$nef$1@nnrp1.deja.com> Howdy. I'm experiencing problems when I try to use SimpleHTTPServer while tying up the main thread; specifically, I'm calling code roughly as follows: > # Start the server up: > server=SimpleHTTPServer.HTTPServer((address, > port), webserver) > thread.start_new_thread(server.serve_forever, ()) > > # Do something forever: > while 1: > time.sleep(1.0) > unrelated_stuff() It seems that if I let the main thread run out such that I get the ">>>" prompt, the server acts normally; however, when I prevent the main thread from completing the script, the page is never served. BasicHTTPServer.handle_request() seems to complete, but it the page never gets out; SimmpleHTTPServer's log_request never gets called. I must be missing something thread-related, but I can't seem to track it down; can anyone offer any advice? Thanks much, Thomas Sanders t.e.sanders at usa.net Sent via Deja.com http://www.deja.com/ Before you buy. From kcazabon at home.com Wed Mar 15 00:29:46 2000 From: kcazabon at home.com (Kevin Cazabon) Date: Wed, 15 Mar 2000 05:29:46 GMT Subject: Executing Applications References: <8amup2$eka$1@news.kersur.net> Message-ID: os.system() will execute commands in the native OS command line. Kevin. wrote in message news:8amup2$eka$1 at news.kersur.net... > How can I execute non-python scripts and applications from within a Python script? > > Something along the lines of exec in Bash, or exec() and system() in Perl. > > Thanks! > > -lf From x at collins.rockwell.com Wed Mar 8 08:45:00 2000 From: x at collins.rockwell.com (Jon) Date: Wed, 08 Mar 2000 07:45:00 -0600 Subject: Horizontal Scroll Bars for IDLE Message-ID: <38C6595C.210F256C@collins.rockwell.com> I finally got around to adding horizontal scroll bars to the IDLE editor window to help when you get those LONG lines of code. They changes are rather mionor (4 new lines of code) and were made in the EditorWindow.py module. To make the changes in IDLE, open EditorWindow.py and perform a search for 'vbar' which is in the EditorWindow class, __init__ method. Add those lines that have ### appended to them and VOILA you have it. Unfortunately, the scrollbar appears BELOW the row and column information in IDLE 0.5 (*sigh*). self.vbar = vbar = Scrollbar(top, name='vbar') self.hbar = hbar = Scrollbar(top, orient=HORIZONTAL, name='hbar')### ... vbar['command'] = text.yview vbar.pack(side=RIGHT, fill=Y) hbar['command'] = text.xview ### hbar.pack(side=BOTTOM, fill=X) ### text['yscrollcommand'] = vbar.set text['xscrollcommand'] = hbar.set ### Hope this is helpful. Jonathan Polley jwpolley at collins.rockwell.com From jeffp at crusoe.net Fri Mar 17 17:40:55 2000 From: jeffp at crusoe.net (Jeff Pinyan) Date: Fri, 17 Mar 2000 22:40:55 GMT Subject: Code basics In-Reply-To: <38D2A023.8E3F1809@webamused.com> References: <882568A5.006BC198.00@avnet.com> <38D2A023.8E3F1809@webamused.com> Message-ID: I didn't mean that I would code like that in every situation, folks. :) Yes, I come from a P___ background, and yes, you'll probably see people write Perl code like that, most often in games of Perl golf. I'd use an if-else in that situation, I'm sure. -- MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve japhy at pobox.com http://www.pobox.com/~japhy/ http://pinyaj.stu.rpi.edu/ PerlMonth - An Online Perl Magazine http://www.perlmonth.com/ The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/ From breiter at usf.Uni-Osnabrueck.DE Mon Mar 13 07:50:01 2000 From: breiter at usf.Uni-Osnabrueck.DE (Bernhard Reiter) Date: 13 Mar 2000 12:50:01 GMT Subject: What is the Python mainstream for the GUI Lib ..?? References: <8ad724$lpb$1@bw107zhb.bluewin.ch> Message-ID: <8aio5p$hq2$1@newsserver.rrzn.uni-hannover.de> In article <8ad724$lpb$1 at bw107zhb.bluewin.ch>, "Markus Meng" writes: > I 'played' a little with the FOX-Binding and with the wxpython. > I would like to 'feel' which GUI-LIB > will be used mostly from the python-users in the near future... I also add on wxPython. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) From gmcm at hypernet.com Tue Mar 28 16:13:50 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 28 Mar 2000 16:13:50 -0500 Subject: class scope workarounds In-Reply-To: Message-ID: <1257844462-27397521@hypernet.com> Warren Postma writes: > Here's a sample bit of code I wrote to try to figure out the Python scoping > rules with regards to class-level data members (what would be a static data > member in a C++ class). > > Let's suppose I have a base class with a class-scope variable 'x': > > class baseclass: > x = 5 # inherited classes can override this > def a_method(a): > classvar x # new keyword suggestion? > return a*x > > Now suppose I want to inherit and change x, but lots of methods in baseclass > reference x directly, and I want them to use the correct x for that > base-class: Not clear what you mean by "correct", but I suspect you've overlooked the obvious : >>> class A: ... x = 1 ... def showx(self): ... print self.x ... >>> class B(A): ... x = 2 ... >>> class C(B): ... x = 3 ... >>> c = C() >>> c.showx() 3 >>> b = B() >>> b.showx() 2 >>> - Gordon From timo at alum.mit.edu Fri Mar 17 00:39:48 2000 From: timo at alum.mit.edu (Timothy O'Malley) Date: Fri, 17 Mar 2000 00:39:48 -0500 Subject: Cookie module References: Message-ID: <170320000039482562%timo@alum.mit.edu> hola. Close. Lenny Self wrote: > Your code should read: > > ck = Cookie.SmartCookie() > ck.load(os.environ["HTTP_COOKIE"]) > L = ck("ogin").value Close. The third line should use brackets, not parentheses. Cookies work like dictionaries: L = ck["ogin"].value From dan at cgsoftware.com Wed Mar 1 15:48:45 2000 From: dan at cgsoftware.com (Daniel Berlin) Date: Wed, 1 Mar 2000 12:48:45 -0800 (PST) Subject: A comp.lang.python code snippet archive? In-Reply-To: Message-ID: On Wed, 1 Mar 2000, Mikael Olofsson wrote: > > On 01-Mar-00 Moshe Zadka wrote: > > Yes: why not have a pysnippets at something.something, which you can CC > > on any message, and have it automatically appear in a snippets page? I > > know I wouldn't mind adding the CC: for snippets I post. > > Just curious: Would you remember to do that all the time? I, for one, > would forget it within a month. Would you remember something like putting [snippet] in the subject? It's not hard to properly determine whether something contains python code snippets or not. It's hard to do it ina reasonable amount of time. > > /Mikael > > From effbot at pythonware.com Mon Mar 27 13:08:42 2000 From: effbot at pythonware.com (effbot at pythonware.com) Date: Mon, 27 Mar 2000 18:08:42 GMT Subject: Python 3000 References: <8bnm6r$nh1$1@anguish.transas.com> Message-ID: <8bo827$ft0$1@nnrp1.deja.com> Michael Sobolev wrote: > I do not know whether this is a proper place to ask this question. :) > > When I got Python 3000 sources (from CVS) and tried to build it, I saw > that it uses VERSION="1.5" all the time. Is it by design? I mean this > prevents me from direct installing this new version as it's going to > replace the files from existing python 1.5.2... Python 3000 is a code name for a future redesign of the python language. The stuff in CVS is "bleeding edge python", and is currently known as "1.5.2+". To use this in paralell, just install it by hand (copy the interpreter and the Lib directory to some suitable location). 1.6 alphas will be available soonish. Sent via Deja.com http://www.deja.com/ Before you buy. From sjoerd at oratrix.nl Wed Mar 1 06:49:27 2000 From: sjoerd at oratrix.nl (Sjoerd Mullender) Date: Wed, 01 Mar 2000 12:49:27 +0100 Subject: X gurus? In-Reply-To: Your message of Wed, 01 Mar 2000 10:23:39 +0100. <20000301102339.B28091@nl.linux.org> References: <38BCE605.2C78E347@sightreader.com> <20000301102339.B28091@nl.linux.org> Message-ID: <20000301114929.588F2301CF9@bireme.oratrix.nl> On Wed, Mar 1 2000 Gerrit Holl wrote: > Sjoerd Mullender has done that. > Parnassus links to his homepage > for an extensive X library in Python, but it's not on his > homepage. It can still be downloaded, however, on: It's back on my home page. > http://www.cwi.nl/ftp/sjoerd/X-extension.tar.gz Also see http://www.cwi.nl/ftp/sjoerd/ An update to this stuff is long overdue, but I have so little time to make that update... -- Sjoerd Mullender From grant at nowhere. Fri Mar 3 14:50:49 2000 From: grant at nowhere. (Grant Edwards) Date: Fri, 03 Mar 2000 19:50:49 GMT Subject: does opensource move faster with python? References: Message-ID: In article , Bernhard Herzog wrote: >"Michal Wallace (sabren)" writes: > >My drawing program Sketch might fit this description although I don't >intend to replace Python with C, only to rewrite some parts in C if the >Python equivalent turns out to be too slow. I switched from xfig to sketch a couple months ago. So far sketch has been plenty fast enough in interactive use (AMD K6-350 w/ 64M). The command-line eps-exporter program is noticably slower than the transfig equivalent, but not enough to worry about. >Python is much too valuable to throw away. Adding support for user >supplied scripts is a piece of cake, for instance, And I can testify that writing user scripts is a piece of cake due to their being in python. -- Grant Edwards grante Yow! What I need is a at MATURE RELATIONSHIP with a visi.com FLOPPY DISK... From mak at imakhno.freeserve.co.uk Tue Mar 7 10:44:19 2000 From: mak at imakhno.freeserve.co.uk (Makhno) Date: Tue, 7 Mar 2000 15:44:19 -0000 Subject: Creating a Python script 'interface' to c/c++ module Message-ID: <8a38a5$48j$1@newsg4.svr.pol.co.uk> My problem is difficult to explain... I've written a module for Perl in C/C++, but user's so not call the C functions directly, there is a level of Perl 'wrapping' it that does various checks (as well as providing an OO interface). Having written the bulk of the module as language-independant as possible, the time has come to port it to Python. Unfortuanately, I can't seem to provide the Python wrapper, the way the modules work does not seem to let me. For example, I want to call a C function called my_func(). With Perl I would use the hierarchy: Users code->Perl wrapper->C wrapper (XS file)->C function with Python, I can't seem to include the second step, only Users code->C wrapper->C function So calling my_module.my_func() in Python, calls C code directly, there is no chance of executing any Python inbetween. The question is how do I get some Python code in there? The only way I can think of is writing a Python module which acts as a wrapper for the C module, which doesn't seem like the best way. From neelk at brick.cswv.com Fri Mar 3 20:30:13 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 4 Mar 2000 01:30:13 GMT Subject: XML DTD for Python source? References: Message-ID: Greg Wilson wrote: > > "Neel Krishnaswami" wrote > > XML might be a useful interchange format, but IMO it doesn't > > really help solve the core difficulties in this enterprise. > > I wasn't expecting XML to solve my problem; however, given the > growing number of high-powered XML manipulation tools out there, I > figured that using it might make my problem easier to solve. At the > (trivial for power users, non-trivial for beginners) level, it'd > also allowed users to format their code in the same rich ways that > they format web pages. Wouldn't it be simpler to point them at Robin Friedrich's HTMLgen? It's hard to get much easier-to-use than "markup(filename)" to HTMLize a Python source file. > > [literate programming, Ensemble, etc.] > > Thanks for the Ensemble link --- I know my way around literate > programming fairly well, but hadn't run into the Berkeley project. Ensemble is really cool. If you read their papers and blindly reimplemented Ensemble, you'd have an IDE that would /blow away/ almost every existing effort, with the possible exception of some Smalltalk and Common Lisp IDEs. I have no idea why it's not well-known; I only stumbled across it while chasing down a pointer on incremental parsing algorithms. > > Neel: > > ...you *can't* store arbitrary Scheme code in semantically > > rich XML, because predicting whether you can finish reading a Scheme > > program is equivalent to the Halting Problem. > > Yes, I'm aware that you can't capture the whole of a program's semantics > by textual analysis. However, having written Scheme compilers in Scheme, > and having messed around (fifteen years ago) with Scheme-to-C compilers, > I seem to remember building AST's for the language that contained more than > just the syntax... I think I explained my point badly. Scheme (and Common Lisp) expand macros into a core language, which can indeed be represented with an AST. However, this AST does not map to the "conceptual level" of the programmer. For example, Common Lisp has the macro WITH-OPEN-FILE which means "open this file, do some operations on it, and remember to close it even if exceptions or other weirdness happens while doing those operations". This is the conceptual chunk the human programmer works at. But the macro call: (with-open-file (s p :direction :output :if-exists :supersede) (format s "Here are a couple~%of test data lines~%")) expands into this: (LET ((S (OPEN P :DIRECTION :OUTPUT :IF-EXISTS :SUPERSEDE))) (UNWIND-PROTECT (MULTIPLE-VALUE-PROG1 (PROGN (FORMAT S "Here are a couple~%of test data lines~%")) (WHEN S (CLOSE S))) (WHEN S (CLOSE S :ABORT T)))) which is substantially less perspicacious to a human reader. If the follow-on tools only see the second version, they won't be able to properly help with the essential function of code comprehension. Since macros are Turing-complete, the only general way you can make this comprehensible to separate follow-on tools is to teach each one what the macro means. So if there are N presentation tools you will need to define N additional extensions to the presentation schemas, one for each follow-on tool. If doing this as painlessly as possible interests you, you should look up the papers on the "Zodiac" and "McMicMac" tools at the PLT Scheme website at Rice. > Greg (who is still looking for a DTD for a programming language) XSL should count, and should also convince you it's a bad idea. ;) Seriously, you can easily get yourself a Python DTD by defining a DTD as follows: convert each nonterminal in the Python grammar into an element declaration, and then you're done. An example: you should change the production flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt to an element declaration like this: Start off the DTD with the file_input production, maybe renamed to something like "python_sourcefile", and proceed mechanically until you've converted the entire grammar. There's really nothing to it. (You may have to add some auxilliary productions to satisfy the limitations of XML -- it's been a long time since I last wrote a DTD, so I don't remember exactly what's legal.) Be careful about drawing too many inferences from the AST, though -- remember that when you do an import, it's perfectly legal for the import hook to email Michael Hudson for a custom version of bytecodehacks with which to randomly munge all the code objects in every loaded module. :) Incidentally, the grammar file is in the Python source distribution at Grammar/Grammar. Neel From jeffp at crusoe.net Wed Mar 15 14:02:37 2000 From: jeffp at crusoe.net (Jeff Pinyan) Date: Wed, 15 Mar 2000 14:02:37 -0500 (EST) Subject: in-place value modification (was Re: lambda without vars?) In-Reply-To: References: <8ao4lv$jss$1@nnrp1.deja.com> Message-ID: [posted & mailed] On Mar 15, Fran?ois Pinard said: >However, you cannot have the function to modify such variables (that is, >the value they have outside lambda). You can, but it is exceptionally difficult, requires a lot of munging and trickery, and the method is not the same for different cases: >>> a = [1,2,3] >>> def app(name,val): ... tmp = globals()[name] ... tmp.append(val) ... >>> app('a',4) >>> a [1, 2, 3, 4] Here's a much more complex example, which replicates chomp(), Perl-style. It is not suggested you USE this, but it shows the lengths one must go to. def chomp(name,rem="\n"): # chomp, Perl-style import string rlen = len(rem) pos = string.find(name, "["); if pos != -1: # dealing with a subscript name, subs = name[:pos], name[pos:] else: subs = "" # globalize name, and set tmp to name (or name[subs]) exec "tmp = globals()[name]" + subs if type(tmp) == type(""): if tmp[-rlen:] == rem: exec "globals()[name]" + subs + " = tmp[:-rlen]" return 1 else: return 0 # otherwise, operate on a list of some sort... retval = 0 if type(tmp) == type([]) or type(tmp) == type(()): cp = [] for obj in tmp: if type(obj) == type(""): if obj[-rlen:] == rem: obj = obj[:-rlen] retval = retval + 1 cp.append(obj) if type(tmp) == type(()): cp = tuple(cp) elif type(tmp) == type({}): # only chomp() the VALUE, not the key cp = {} for obj in tmp.items(): val = obj[1] if type(val) == type(""): if val[-rlen:] == rem: val = val[:-rlen] retval = retval + 1 cp[obj[0]] = val else: raise TypeError, "expected string, list, tuple, or dict" exec "globals()[name]" + subs + " = cp" return retval me = ["jeffrey\n"] print "'" + `me` + "'" chomp('me') print "'" + `me` + "'" It's nasty. :) I happen to really like Perl's ability to change the argument list it receives: @values = (10, 20, 30); for (@value) { $_ += 10 } print "@values"; # 20 30 40 add_one(@values); print "@values"; # 21 31 41 sub add_one { for (@_) { $_++ } } I find it a little icky that you have to bend over backwards to get such results in Python (even though I DID get it done...). -- MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve japhy at pobox.com http://www.pobox.com/~japhy/ http://pinyaj.stu.rpi.edu/ PerlMonth - An Online Perl Magazine http://www.perlmonth.com/ The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/ From genius at idirect.com Sat Mar 18 15:51:42 2000 From: genius at idirect.com (Snoopy :-))) Date: Sat, 18 Mar 2000 15:51:42 -0500 Subject: Need Help Re:PATH References: <38D279E8.EE95773D@idirect.com> <20000317141124.A1076108@vislab.epa.gov> Message-ID: <38D3EC5E.7CF99F3F@idirect.com> Thanks forr the help Randall. I noticed your resposnse in the Python NG as well. I followed your suggestion and am responding below with the results. Randall Hopper wrote: > Snoopy :-)): > |PATH & PYTHONPATH. I just don't know what am I doing wrong. > | > |For the purpuse of Practice In my home directory I created a directory > |called"Pydir" where I wan to keep the "Module & Script " Files. I want > |to use the "Bash-Shell". So In my (Home) "bash_profile " I did the > |following configuration: > |PATH=$PATH:/HOME/bin:/usr/bin/python:.:/home/charly/Pydir > |PYTHONPATH=$PYTHONPATH:.:/home/charly/Pydir:/usr/lib/python1.5:/usr/lib/python1.5/lib-tk > ... > > I believe you need to put an "export" before your declarations for bash. > Also, when you say "bash_profile", the user file for this is $HOME/.bashrc > > Try this: > > cd $HOME > echo $PYTHONPATH <-- Make sure /home/charly/Pydir > shows up here I did the above but it returns me to the "Prompt". Nothing else shows. > > export PYTHONPATH=/home/charly/Pydir <-- If not, just do this > python > >>> import mymodule I did the above and it seem to work. However it is only effective while I am logged in. If I loggout and log back again I have to use the above in order for things to work. This is confirmed by one of the Linux Books which states that this is a temporaary solution. The book say that in order to make it permanent the "PYTHONPATH=$PYTHONPATH:.:/home/charly/Pydir " should be placed in the "/home/charly/.bash_profile" file. I've done this as well but for some reason it's not taking efect. To make sure I also logged out and restarted. If I don't do the above "export PYTHONPATH..etc...." Then I have to run python from the file's current directory (Pydir) in order to be able to "import" the file. I am either doing something wrong in the configuration or there is a Bug somewhere. I've been browsing myt books as well as the Tutorials or the past 2-weeks and can't find the answer. Purhaps if I bug people in these groups long enough,some one will help me see the light. I sure would appreciate it. Best regards Charles > > > -- > Randall Hopper > aa8vb at yahoo.com From gmcm at hypernet.com Mon Mar 20 16:53:01 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 20 Mar 2000 16:53:01 -0500 Subject: Question about instance creation In-Reply-To: <38d791b7.42810784@news.pandora.be> Message-ID: <1258533308-31724431@hypernet.com> Robin Barendregt writes: > I hope that I'm not totally non-sensical here. Well I'm not making any sense of it. First you asked: > class Class3(Class1, Class2): > def __init__(self): > Class1.__init__(self) > Class2.__init__(self) > print 'Class3 init' > c = DynamicClass(Class1, "arg given") > print c > self.var3 = 'this is var3' ... > I want the var c in Class3.__init__ to contain and instance of the > class given as 1st argument to DynamicClass. I tried using return in > the DerivedClass.__init__ but I get an exception saying I should > return None in an __init__. How can I accomplish this? And the answer is obvious - forget DynamicClass and just c = Class1("arg given") (though I can't see any sense to this, especially since you're not saving a reference). But then you said > I'm sorry. What I meant was that I want c to contain an instance of > DerivedClass, of course. which means ignore the above advice, because it already does. and finally you say: > ...In class2.py, the definition for DynamicClass should > be: > > class DynamicClass: > def __init__(self, newAlias, *args): > global BaseAlias > BaseAlias = newAlias > apply(DerivedClass, args) > which is legal, but makes no sense. So, I haven't the foggiest idea *what* you're trying to do. However, this might help clarify things. Once Python hits a class statement: class Spam: ... it creates a class object (named "Spam"). When you create an instance of Spam by using "Spam(...)", Python creates an instance object whose attribute "__class__" points to the Spam class object. As the final step, Python invokes Spam's "__init__" method on the instance. At this point "self" already exists and is complete, just uninitialized. You can't mess with the value of "self" at all. If you're brave, you can mess with what the "__class__" attribute contains, and what "__class__.__bases__" contains. It's kind of fun once in awhile, but it introduces enough surprises that sane people stay away from it. As far as aliases go: class Spam: pass Eggs = Spam You can now create instances of "Eggs" and they will be identical to similarly created instances of "Spam", because "Eggs" is just another label for "Spam". >>> class Spam: ... pass ... >>> Eggs = Spam >>> e = Eggs() >>> e <__main__.Spam instance at 7fa4d0> >>> Does this help? - Gordon From python at rose164.wuh.wustl.edu Thu Mar 2 04:54:46 2000 From: python at rose164.wuh.wustl.edu (David Fisher) Date: Thu, 2 Mar 2000 03:54:46 -0600 Subject: runtime code loading References: <89joqr$21s$1@news01.cit.cornell.edu> Message-ID: <009801bf842d$57b5f300$0201a8c0@spkydomain> Hi Jp, Your post is a little hard to answer. It would help to know what the program is supposed to do, what the line of code is supposed to do, what platform and version you are running on. Including a small piece of working code that exibits the problem, instead of code fragments would help also. That said, it looks like you want to create an instance of the class Player and store it in self.connections[addr]. It would also help to know why you are doing it with open, read, compile, etc. Unless you have a good reason not to, I would sugest you use the standard import function to load code from a file. Post with some more info, and we'll try again. david ----- Original Message ----- From: "Jp Calderone" Newsgroups: comp.lang.python To: Sent: Wednesday, March 01, 2000 12:51 PM Subject: runtime code loading > (First, I'm a realtive newbie to Python, so if this is dumb, please excuse > me) I've got the following code and I can't figure out why it freezes at > the marked line: > > def connectionMade(self, sock, addr): > print 'Getting pObj...', > pObj = self.bootstrapObjects['Player'] > print 'Done\nGetting lObj...', > lObj = self.bootstrapObjects['LoginParser'] > print 'Done\nCreating player...' > self.connections[addr] = pObj(lObj, sock, addr) # Freezes here > print 'Done' > > > pObj and lObj are loaded with this code: > > def load(name): > infile = open('../lib/code/' + name, 'r') > source = infile.readlines() > result = compile(string.join(source, '\n'), '../lib/code/' + name, > 'single' > return result > > and the code files contain:" > > class Player: > > socket = None > address = None > > def __init__(self, socket, addr): > print 'Player init' > self.socket = socket > self.address = addr > > def hasData(self): > return self.socket.ready() > > def parse(self): > if not self.hasData(): > return > else: > pass > > class LoginParser: > > state = -1 > > def __init__(self): > self.state = 0 > > > Anything obvious that I'm doing wrong (or am I approhacing this from > completely the wrong angle?) > > Thanks in advance > -- > http://www.python.org/mailman/listinfo/python-list From btang at pacific.jpl.nasa.gov Mon Mar 13 21:00:29 2000 From: btang at pacific.jpl.nasa.gov (Benyang Tang) Date: Mon, 13 Mar 2000 18:00:29 -0800 Subject: How to do os.popen with write and read at the same time? Message-ID: <38CD9D3D.B0C57BBA@pacific.jpl.nasa.gov> I like to do thing like: stdin > grep 'something' >stdout How do I access stdin and stdout in python? os.popen accepts either 'w' or 'r' mode, but not both at the same time. From landauer at apple.com Fri Mar 24 21:29:01 2000 From: landauer at apple.com (Doug Landauer) Date: Fri, 24 Mar 2000 18:29:01 -0800 Subject: what is easier to learn first?... References: <8b861c$ecn$1@nnrp1.deja.com> Message-ID: > Kind of interesting to think that APL was designed for algorithm > publication, and only made a real language after the fact... No, sorry, that never happened. -- Doug Landauer landauer at apple.com (work) landauer at scruznet.com (not-work) From urena at lessing.oit.umass.edu Sun Mar 12 17:04:38 2000 From: urena at lessing.oit.umass.edu (Richard R Urena) Date: 12 Mar 2000 17:04:38 -0500 Subject: config'in apache for python References: <00030923081607.01104@quadra.teleo.net> Message-ID: <8ah49m$68e@lessing.oit.umass.edu> Matthew Barre writes: >Yes I'm trying to make it so that when I refer to a cgi script in my cgi bin >the script is executed instead of being just printed to the browser. FWIW: 1) I made sure these lines were uncommented in httpd.conf: ScriptAlias /cgi-bin/ "/var/apache/cgi-bin/" AllowOverride None Options None Order allow,deny Allow from all (this assumes Apache was built with mod_alias, which is the default) 2) chmod 755 on the scripts themselves (and of course they have the #!/usr/bin/python magic in the first line) This is running Apache 1.3.6 (and up) on Linux From helm at dnv.com Mon Mar 6 01:12:09 2000 From: helm at dnv.com (Jens Bloch Helmers) Date: 06 Mar 2000 07:12:09 +0100 Subject: Postprocessing tool (Electronic Light table?) Message-ID: I'm playing with the idea of building a Python tool for organizing postprocessing of data. This tool should: 1) Organize a directory structure for doing some parametric study. 2) Traverse this directory structure and create relevant input files for the postprocessing program(s). 3) Start the postprocessing program(s) When this Python script is finished, there is a (postscript) plot file in each subdirectory. These plots contains time series of some signal. I would then like to compare these plots. An old fashioned way of doing this is to make hardcopy of each an every plot. Put them on a light table and compare the curves. Is it possible to build a Python/Tkinter/? tool where you can pick any two plot files and and combine them in a 2 layer plot on screen? A kind of electronic light table? Are there any such tools out there? Any input on this would be appreciated! Jens Helmers From robin at jessikat.demon.co.uk Wed Mar 29 01:55:37 2000 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Wed, 29 Mar 2000 07:55:37 +0100 Subject: Microthreads is now available References: Message-ID: <94iVvEApja44EwdC@jessikat.demon.co.uk> In article , Will Ware writes I installed the binary package last night and was surprised that so little comes with the package. No documentation & no examples is bad for user acceptance. Should I download the source to get further information? as for the uthreads stuff thanks Will >With Chris Tismer's release of Stackless Python 1.1 and >Continuations 0.8, Python Microthreads are Now Available >to the General Python-Consuming Public. Microthreads are >useful when you want to program many behaviors happening >simultaneously. Simulations and games often want to model >the simultaneous and independent behavior of many people, >many businesses, many monsters, many physical objects, many >spaceships, and so forth. With microthreads, you can code >these behaviors as Python functions. You only need to think >a teeny bit about the fact that context switching occurs >between threads. There are also handy conveniences roughly >analogous to what you'd find in a real-time operating system >like PSOS or VxWorks. > >Once you a working Stackless Python 1.1 build, all you need >is to fetch this file and put it anywhere in your PYTHONPATH: >ftp://ftp.std.com/pub/wware/uthread.py > >If you want a collection of test cases, roughly corresponding >to the examples in the manual, pick up: >ftp://ftp.std.com/pub/wware/u1.py > >The Microthreads Manual resides at: >http://world.std.com/~wware/uthread.html > >Information about Stackless Python and Continuations is available >at: >http://www.stackless.com/ > -- Robin Becker From ljz at asfast.com Thu Mar 9 18:37:57 2000 From: ljz at asfast.com (Lloyd Zusman) Date: 09 Mar 2000 18:37:57 -0500 Subject: Python for non-programmers References: <38C7F00D.8761FBB@sage.att.com> Message-ID: thantos at chancel.org (Alexander Williams) writes: > On Thu, 9 Mar 2000 18:40:13 GMT, Bosco Hodgson wrote: > >i thought it was just to keep the riff-raff out. > > Sadly, with the advent of AoL and the Me-Too Generation on top of the > Eternal September, we can no longer be gatekeepers, merely clean-up > men. Uh-oh ... this is the first time I noticed a complaint like this in c.l.python about "Eternal September", etc. Does this mean this newsgroup has taken its first major step towards being like c.l.perl.misc? :) -- Lloyd Zusman ljz at asfast.com From gonzo at vex.net Tue Mar 14 14:00:17 2000 From: gonzo at vex.net (Anthony DeLorenzo) Date: 14 Mar 2000 19:00:17 GMT Subject: gracefully quit References: Message-ID: <8am281$2u7u$1@news.tht.net> >> raise SystemExit >> also works. > > It is a little ugly :) sys.exit() is nicer and more readable :))) At the same point, raise SystemExit saves importing a module, unless you already happen to have the sys module loaded for something else. Tony -- # Anthony DeLorenzo # http://www.vex.net/~gonzo/ # mojo wire: 209-391-8932 From mfletch at tpresence.com Wed Mar 15 10:13:48 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Wed, 15 Mar 2000 10:13:48 -0500 Subject: read NT registry with python Message-ID: WARNING: I don't have a clue, this is just something I do, don't muck with the registry evil and demons lurk beneath its surface, beware the corrupt registry my son, for that is the path to peanut-butter-death... Haven't you figured out that tree-in-forest question yet? You pay for these Zen lessons by the hour you know... Query example: import win32api, string # normally you would import these from win32con HKEY_CLASSES_ROOT = 0x80000000 HKEY_CURRENT_USER = 0x80000001 REG_SZ= 1 INCLUDE_PATH_KEY = "Software\\YourCompany\\YourProduct\\YourVersion\\YourVariable" def getIncludePath(): ''' Query registry for the include path ''' # download from registry here try: include = win32api.RegQueryValue( HKEY_CURRENT_USER, INCLUDE_PATH_KEY, ) except win32api.error: return None Well, heed the warning in the file, but here's an example of set... 8<______________ mcf/utils/fileassociation.py _______________ ### WARNING: # I don't have a clue what I'm doing here! import win32api ### Following is the "normal" approach, ### but it requires loading the entire win32con file (which is big) ### for two values... ##import win32con ##HKEY_CLASSES_ROOT = win32con.HKEY_CLASSES_ROOT ##REG_SZ = win32con.REG_SZ ### These are the hard-coded values, should work everywhere as far as I know... HKEY_CLASSES_ROOT = 0x80000000 REG_SZ= 1 def associate( extension, filetype, description="", commands=(), iconfile="" ): '''Warning: I don't have a clue what I'm doing here! extension -- extension including "." character, e.g. .proc filetype -- formal name, no spaces allowed, e.g. SkeletonBuilder.RulesFile description -- human-readable description of the file type commands -- sequence of (command, commandline), e.g. (("Open", "someexe.exe %1"),) iconfile -- optional default icon file for the filetype ''' win32api.RegSetValue( HKEY_CLASSES_ROOT, extension, REG_SZ, filetype ) if description: win32api.RegSetValue( HKEY_CLASSES_ROOT , filetype, REG_SZ, description ) if iconfile: win32api.RegSetValue( HKEY_CLASSES_ROOT , "%(filetype)s\\DefaultIcon" % locals(), REG_SZ, iconfile ) for (command, commandline) in commands: win32api.RegSetValue( HKEY_CLASSES_ROOT , "%(filetype)s\\Shell\\%(command)s" % locals(), REG_SZ, command, ) win32api.RegSetValue( HKEY_CLASSES_ROOT , "%(filetype)s\\Shell\\%(command)s\\Command" % locals(), REG_SZ, commandline ) -----Original Message----- From: tiddlerdeja at my-deja.com [mailto:tiddlerdeja at my-deja.com] Sent: Wednesday, March 15, 2000 9:44 AM To: python-list at python.org Subject: Re: read NT registry with python Thanks for that, very much appreciated. However, the second line: win32api.RegQueryValueEx('AdminPassword') I get an error with this: >>> win32api.RegQueryValueEx('AdminPassword') Traceback (innermost last): File "", line 1, in ? TypeError: RegQueryValueEx requires exactly 2 arguments; 1 given Any help with this is greatly appreciated. p.s. I realise this is lame me asking this, but I'm new to registry terms and I don't know what the second var should be. In article <8anvhr$1756 at newton.cc.rl.ac.uk>, "Richard Brodie" wrote: > > wrote in message news:8ansn6 $ece$1 at nnrp1.deja.com... > > > [HKEY_LOCAL_MACHINE\SOFTWARE\WOF] > > > > [HKEY_LOCAL_MACHINE\SOFTWARE\ABC\PlusSoftware] > > "AdminPassword"="Admin" > > import win32api > from win32con import * > > k=win32api.RegOpenKeyEx(HKEY_LOCAL_MACHINE, > 'SOFTWARE\\ABC\\PlusSoftware',0,KEY_QUERY_VALUE) > > win32api.RegQueryValueEx('AdminPassword') > > Sent via Deja.com http://www.deja.com/ Before you buy. -- http://www.python.org/mailman/listinfo/python-list From hathawa2 at marshall.edu Sat Mar 25 23:02:21 2000 From: hathawa2 at marshall.edu (Mark Hathaway) Date: Sat, 25 Mar 2000 23:02:21 -0500 Subject: HELP Newbie solve this Problem References: <8beo97$fm7$1@nnrp1.deja.com> <3.0.5.32.20000325011503.0081f100@mail.dicksonstreet.com> Message-ID: <38DDB6E3.4FE2@marshall.edu> >>> On Fri, 24 Mar 2000 03:43:38 GMT, race9047 at my-deja.com declaimed the >>> following in comp.lang.python: >>> >>> I must be from a different world then... The second part is what >>> I'd find easy... even in FORTRAN (maybe too easy in FORTRAN) >> At 21:10 3/23/00 -0800, Dennis Lee Bieber wrote: >> >> integer counts(26) / 26 * 0 / ! or is it 0 * 26? >> character line*132 ! set for the longest line the >> ! the data file can contain >> open(10, file="data", status="old") >> read(10, '(a132)', iostat=ios) line >> 10 continue >> if (ios .eq. 0) then >> do 20 i=1, 132 ! or the line length max >> if (line(i:i) .ge. 'a' .and. line(i:i) .le. 'z') then >> inx = ichar(line(i:i)) - ichar('a') + 1 >> counts(inx) = counts(inx) + 1 >> elseif (line(i:i) .ge. 'A' .and. line(i:i) .le. 'Z') >> x then >> inx = ichar(line(i:i)) - ichar('A') + 1 >> counts(inx) = counts(inx) + 1 >> else >> continue ! just my style >> endif >> 20 continue >> read(10, '(a132)', iostat=ios) line >> goto 10 >> endif >> close(10) >> do 30 i=1, 26 >> print *, char(i), ' ', counts(i) >> 30 continue >> stop >> >> >> It would look much cleaner in Python, and I'd use case > >conversion modules rather than the duplicates in the IF statements... I'm probably giving away somebody's homework, but I can't allow that stupid Fartran to stand without comparison to Python. Fortran 27 lines unreadable Python 53 lines commented 22 lines uncommented ---------------------------- snip here-------------------- class charFreq: # Written by: Mark Hathaway # Date: 2000.03.25 # # This class allows one to read text from a file, # tally the frequency of each character in the text, # report the frequency of either all or only specified characters # and specifically ignore case - count uppercase A..Z as a..z. '''Usage: from freqchar import charFreq obj = charFreq() obj.getText("filename.ext") obj.reportCounts() It defaults to reporting on string.letters & ignoreCase = None obj.reportCounts(stringOfCharsToLookFor,ignoreCase) use obj.reportCounts("any letters","true") to give some specific selection of letters and case specificity.''' def getText (self, filename): self.text = open(filename).read() self.charDict = {} # to store each letter and occurrences of it self.keys = [] # to store charDict.keys() - to sort later for char in self.text: if char not in self.keys: self.charDict[char] = 1 self.keys.append(char) else: self.charDict[char] = self.charDict[char] + 1 def reportCounts (self, lookfor="abcdefghijklmnopqrstuvwxyz"+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ", ignoreCase=None): '''One provides a character string and this method counts the occurrences of each character of the string in the text. If you're using the ignoreCase='true' option then provide the lowercase in the lookfor character string e.g. obj.reportCounts('abcxyz')''' from string import uppercase, lower self.keys.sort() for char in lookfor: if ignoreCase and (char in uppercase): char = lower(char) if char in self.keys: print char, self.charDict[char] #end charFreq From laptop51 at 51peg.com.nospam Sat Mar 4 22:05:24 2000 From: laptop51 at 51peg.com.nospam (Rick) Date: Sat, 4 Mar 2000 19:05:24 -0800 Subject: Elementry question on indeces Message-ID: >From the tutorial, on strings and zero relative indeces, where word = 'HelpA'. I have no problem with this, we are asking for 4th entry: >>> word[4] 'A' but it seems to me the following is asking for the 0th, 1th and 2th entries (ordinal 1st ,2nd and 3rd) but all we are getting is the zero-th and one-th. >>> word[0:2] 'He' What am I missing here? Makes me feel like I've been taking stupid pills. Thanks, Rick -- Yale beat Harvard From embed at geocities.com Thu Mar 2 12:21:28 2000 From: embed at geocities.com (Warren Postma) Date: Thu, 2 Mar 2000 12:21:28 -0500 Subject: stackless/microthread merge References: <38BD197A.4F9E93C1@tismer.com> Message-ID: <9sxv4.28865$Jz3.173654@nnrp1.uunet.ca> Thus Spake Christian Tismer: > This hook is especially for you, > and you can define its interface. Wow, what a nice guy! ;-) This looks like one interesting application of the open-source "all benefical forks should eventually be folded into the main fork, or failing that, a whole new product really does need to exist". I can see stackless+microthread going on to challenge regular python by very careful optimizations at it's core. I'm seriously going to consider using this for my embedded control [SCADA, Radio Telemetry] uses, because I think thread latency is a pretty key part of any complex control system. I can't wait to see what this looks like when it's finished! :-) Very very cool! Warren From josht at iname.com Fri Mar 10 17:59:12 2000 From: josht at iname.com (Josh Tompkins) Date: Fri, 10 Mar 2000 22:59:12 GMT Subject: req: flowchart generator? References: Message-ID: <8EF3B4465joshtinamecom@209.208.0.7> gvwilson at nevex.com (Greg Wilson) wrote in : >Does anyone have a tool that will generate flowcharts from Python source >automatically? (And please don't make jokes about flowcharts until you >have read David Scanlan's article in the Sept 1989 issue of "IEEE >Software".) > >Thanks, >Greg > Does anyone know where (on the 'Net, please) I can find a copy of this article? -- Josh "Josue" Tompkins ________________________________________________________________ "Destined For Great Things -- but pacing myself." - From a t-shirt. E-Mail: josht at iname.com ICQ: 21219667 AIM: JosueTheGreat Web: http://www.crosswinds.net/~josht _________________________________________________________________ From just at letterror.com Mon Mar 13 10:41:01 2000 From: just at letterror.com (Just van Rossum) Date: Mon, 13 Mar 2000 16:41:01 +0100 Subject: Stackless/microthreads merge news In-Reply-To: <38CCE6FA.50BE82AB@tismer.com> References: Message-ID: At 2:02 PM +0100 13-03-2000, Christian Tismer wrote: >Even more, it is possible to run micro-threads in every >real thread. For a real thread, microthreads are just >Python code. Every thread state has its own microthread >handler. Wow: that'll sure cause some brain explosions here and there... But: microthreads and select() seem a very cool combination! (It would be interesting to know how microthreads perform compared to OS threading as well as to no threading at all, just to see what the overhead is.) Go stackless! Just From pereira at research.att.com Tue Mar 21 23:14:40 2000 From: pereira at research.att.com (Fernando Pereira) Date: Wed, 22 Mar 2000 04:14:40 GMT Subject: stackless, uthreads, and GUIs References: Message-ID: <210320002314402870%pereira@research.att.com> In article , Neel Krishnaswami wrote: > Johann Hibschman wrote: > > > > I was wondering if anyone has experimented with using stackless to > > implement guis. I haven't played with the package much myself (yet), > > but it seems like you could write something nice using continuations > > to implement dialog boxes, and so on. > > > > I know most real GUIs use threads, but real OS threads are such a PITA > > to get to compile (in my experience), that I'd like other options. > > > > I'm mostly just playing with this idea for now. Is it a reasonable > > direction in which to be thinking? Any accessible references? > > There is a paper describing precisely this idea called "Escaping the > Tyranny of the Event Loop: an Alternative Control Structure for > Multi-threaded GUIs," by Matthew Fuchs. You can find it at > > http://www.cs.nyu.edu/phd_students/fuchs/ > > You may also be interested in reading about Fudgets, a purely > functional GUI toolkit for Haskell. This one is a bit mind-blowing, > though: > > http://www.cs.chalmers.se/ComputingScience/Research/Functional/Fudgets/ > A related, earlier, and simpler idea, based on ideas from CSP and Esterel is Cardelli & Pike's "Squeak: a language for communicating with mice", Proc. Twelfth ACM Annual Conference on Computer Graphics and Interactive Techniques (SIGGRAPH), 1985, . It might be a cool exercise to create a uthreads implementation of these ideas. -- F From dfan at harmonixmusic.com Thu Mar 9 11:22:38 2000 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 09 Mar 2000 11:22:38 -0500 Subject: Python performance References: <8a3if5$20l$1@nnrp1.deja.com> <38C571BC.F1760D18@bellatlantic.net> <8a49mu$jsm$1@nnrp1.deja.com> <38c7a9e7@news.xtml.co.uk> Message-ID: "Nick Trout" writes: | > All worship the all-beloved, universal and mighty C! | > | > Note that Doom and all the Quake games have also been written without a | > single opcode in assembler. | > | > There are still times when assembler gives you better performance. But | > the article to which you are replying explains why that's not as often | > any more. | | That's not true. Most of the software renderer was written in | assembler. I assume other bits were as well but in the main, most of | the game was written in C. Michael Abrash write a book called "The | Zen of Graphics Programming" which details getting the most out of | an x86 processor when you're rendering. Where else would he get the | experience to do this since he worked on Doom and Quake?! Actually, he didn't work on Doom, and he wrote THE ZEN OF GRAPHICS PROGRAMMING before he worked on Quake. -- Dan Schmidt | http://www.dfan.org From nospam at noreply.com Tue Mar 21 19:43:35 2000 From: nospam at noreply.com (Brian) Date: Wed, 22 Mar 2000 00:43:35 GMT Subject: what is easier to learn first?... References: Message-ID: "Collin Greene" wrote in message news:sddpupuilul18 at corp.supernews.com... > C+/+ or python or perl, I need an unbiased opionion here. I have NO > programming experiance. thanks for your time. > greene at hctc.com > > Another one to consider is Tcl/Tk. Mature, lots of extensions, very active user community, cross-platform, tightly coupled to the popular Tk GUI toolkit and it is progressing very rapidly. http://dev.scriptics.com/ From neelk at brick.cswv.com Wed Mar 22 21:40:40 2000 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 23 Mar 2000 02:40:40 GMT Subject: Consise doc on which C api calls do things with ref counts? References: Message-ID: Grant Munsey wrote: > I though I saw mention of a concise doc that tells exactly what > each of the Python C api calls does with object refcounts. > Is there such a thing? Thanks to Fred Drake, as of today there is. X# Go to http://www.python.org/doc, and grab the latest version of the Python documentation -- it should have info on refcounts for every function in the C API. Neel From rerwig at my-deja.com Thu Mar 16 04:46:05 2000 From: rerwig at my-deja.com (rerwig at my-deja.com) Date: Thu, 16 Mar 2000 09:46:05 GMT Subject: pthread error Python 1.5.2 on HP-UX 11.00 Message-ID: <8aqags$93a$1@nnrp1.deja.com> I tried to build Python on HP-UX 11.00 (it uses standard the cma library) but the generated exec core-dumps on a thread init. I changed the configure-file / Makefile with: lpthread, -Ae +Z -D_REENTRANT -D_POSIX_C_SOURCE, etc. but is doesn't help: configure can't find the pthread calls and fails on building. Any pointers? Ruud Sent via Deja.com http://www.deja.com/ Before you buy. From ezy at i.am Wed Mar 8 12:28:56 2000 From: ezy at i.am (Erik Christiansson) Date: Wed, 8 Mar 2000 18:28:56 +0100 Subject: SV: Environment variables References: Message-ID: <8a62ug$1eb$1@zingo.tninet.se> Thanks From kragen at dnaco.net Wed Mar 8 08:42:22 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Wed, 08 Mar 2000 13:42:22 GMT Subject: crimes in Python References: Message-ID: <1Nsx4.5923$yV1.1624509@tw11.nn.bcandid.com> Thanks very much for your response! In article , Remco Gerlich wrote: >Kragen Sitaker wrote in comp.lang.python: >> The Perl version is 79 lines; the Python one is 121 lines. >> >> This is probably not a fair way to evaluate Python, given that this is >> Perl's natural habitat. > >Even if it weren't you're only checking how useful it is to write Perl in >Python. You would get bad results as well if you wrote it in Python first >and then translated to Perl, I suppose. That's almost certainly true. Still, I'm impressed with Python's facility at supporting Perl-like programming. I'm sure I'll be even happier when I learn to think in Python. :) >> - What's the equivalent of the Perl idiom while () { }? I tried >> while line = sys.stdin.readline():, but Python complained that the >> syntax was invalid. > >If it's ok to read the whole file into memory at once: >for line in sys.stdin.readlines(): > >Otherwise, I suppose: >while 1: > line = sys.stdin.readline() > if not line: > break I thought about that. I decided it was just as icky, especially given that I couldn't outdent the if not line the way I would in other languages. (So my loop control would be hard to find.) >> - what kind of an idiot am I to list all the attributes of a victim >> line in an __init__ argument list, in an __init__ body, in the place >> that calls __init__ (implicitly), and in the output statement? It was >> dumb both times I did it, but it was more obvious it was dumb in Python. > >Dicts, you mean? :) I used a dict in the Perl version; I still ended up with the list in two places (which admittedly is better by far than four, and perhaps excusable, because in one case it was describing the input format, while in the other, it was describing the output format). I thought using a class instance would simplify things. I was wrong. >> infile = None >> while len(sys.argv) > 1: >> if not infile: >> infile = sys.argv.pop(1) >> else: >> sys.exit("Usage: " + sys.argv[0] + "infile") >> >> if infile: >> sys.stdin = open (infile, 'r') > >Using a while here is misleading, imo. You only ever use one argument. The theory was that I was going to add command-line switches at some point, which admittedly is a lousy reason to code such an obscure structure. >if len(sys.argv) > 2: > sys.exit("Usage: %s infile" % sys.argv[0]) >elif len(sys.argv) == 2: > infile = sys.argv[1] > sys.stdin = open(infile, 'r') >else > infile = None > >And you need some error checking on the open. I thought "IOError: [Errno 2] No such file or directory: 'foo'" was a sufficiently explanatory error message, given the context of the program's use. You'll note the Perl version does error-check the open and prints essentially the same error message if it fails. The string % operator seems to be a source of great sweetness and light. I should use it more. >> ''' >> sub splitcsv { >> my ($line) = @_; >> return $line =~ /\G((?:[^,"]|"[^"]*")*),?/g >> } >> ''' > >I don't know what this means. The =~ splits the line according to that >regexp, and returns a list or so? The =~ tells the regexp what string it should work on. The regexp, being a /g regexp in a list context, applies itself to the string repeatedly and returns a list of the parenthesized matches, a lot like re.findall. >> # Yow, how do I Python that? >> # The 're' module doesn't have \G. >> csv_re = re.compile("((?:[^,\"]|\"[^\"]*\")*),?") > >Use single quotes so you don't need to escape the double quotes. Good point. >> def splitcsv(line): >> return csv_re.findall(line) > >My intuition is that there should be a clean way without regexpen. But I >can't think of any right now. If this works, keep it :-) Well, you really do need a state machine with several states; regexps are a compact and (theoretically) understandable way to write those. They do lack something in the error-handling department; in this case, I'd like to make sure that I match the whole string, with no gaps or trailing garbage. >> victims = [] >> victim = None >> >> headerpat = re.compile("CRIME") >> carriage_control = re.compile("[\r\n]") >> blank_line = re.compile("\\s*$") >> comma = re.compile(",") > >Using regexps for this sort of thing is just plain silly. You have a big >Perl stuck in your brain! :-) Guilty! Perl in the first degree. :) In Perl, of course, searching for regexps is easier than searching for strings, which is why Perl folk usually search for strings by pretending they're regexps. >> line = sys.stdin.readline() >> while line: >> line = carriage_control.sub("", line) > >You know that there is always a \n on the end of the line. It's always \n, >not \r\n or \r, since you don't read the file in as binary. >So that line is just: > line = line[:-1] Actually, it is \r\n --- the file was written by Microsoft Excel, and Python is running on Linux. But the last line may have no CR or LF, and if someone wants to try the program on the Usenet post, they may not bother to put the CRs on. >If you want to delete trailing spaces as well, use string.strip. Makes >the check for empty line easier as well (line == ""). Yow, perfect! In Perl, we have to roll our own string.strip, so I did. (Turns out \r is "whitespace" to string.strip, even on Unix.) >> if headerpat.match(line): >> pass > >What happens when the word "CRIME" is part of any real data line? >I would check something like: > if line[:5] == "CRIME": Doesn't match() look only at the beginning of the string? Nevertheless, your solution is better. >> elif blank_line.match(line): > > elif string.strip(line) == '': > >I'm sure there are more similar improvements down below, but I have no more >time. Thanks for the time you did spend! It was extremely helpful. >> sys.stderr.write(join( >> split('crimeno crime type age sex race', ' '), "\t")) >> sys.stderr.write(join( >> map((lambda x: 'age' + `x` + "\tsex" >> + `x` + "\trace" + `x`), >> range(1, max_suspects+1))) >> ) > >This looks like it could be improved a lot. I thought so too. By the way, it's broken, now that I look at it. It puts unwanted spaces in the output. lambda x: '\tage%d\tsex%d\trace%d' % (x, x, x) would be one improvement. Perhaps for i in range(1, max_suspects+1): sys.stderr.write('\tage%d\tsex%d\trace%d' % (i, i, i)) -- Kragen Sitaker The Internet stock bubble didn't burst on 1999-11-08. Hurrah! The power didn't go out on 2000-01-01 either. :) From python at rose164.wuh.wustl.edu Tue Mar 14 19:44:50 2000 From: python at rose164.wuh.wustl.edu (David Fisher) Date: Tue, 14 Mar 2000 18:44:50 -0600 Subject: Thread.__init__() not called References: <38CECBD5.D0CE0B91@bogusaddress.com> Message-ID: <000c01bf8e17$ac6bc840$5f3dfc80@spkydomain> When you sub-class Thread you need to call its __init__ function inside yours. Like so: class SimpleThread(threading.Thread): def __init__(self,inOtherInfo): self.theOtherInfo = inOtherInfo print "setting other info to '" + self.theOtherInfo + "'" threading.Thread.__init__() ... Also for future reference, if you post in html, a lot of people won't/can't read you post, and one space is not enough indent to read you code without extra effort. Good luck, David ----- Original Message ----- From: Joe Smith Newsgroups: comp.lang.python To: python-list at python.org Sent: Tuesday, March 14, 2000 5:27 PM Subject: Thread.__init__() not called I am having the following output that I am a bit confused about. setting other info to 'other info' setting other info to 'other info' Traceback (innermost last): File "D:\usr\karl\inproc\threadTest2.py", line 38, in ? TestThreads(2) File "D:\usr\karl\inproc\threadTest2.py", line 31, in TestThreads thread.start() File "d:\bin\Python1.5.2\Lib\threading.py", line 351, in start assert self.__initialized, "Thread.__init__() not called" AssertionError: Thread.__init__() not called Here is a small test case the causes the problem: import time import threading def DoWork(numLoops, name, otherInfo): i = 0; while ( i < numLoops): print "hello from thread ", name, ", number ", i, ", other info is ", otherInfo time.sleep(1) i = i + 1 class SimpleThread(threading.Thread): def __init__(self,inOtherInfo): self.theOtherInfo = inOtherInfo print "setting other info to '" + self.theOtherInfo + "'" def run(self): try: DoWork(20, self.getName(), self.theOtherInfo) finally: pass def TestThreads(numThreads): try: o = "other info" threads = [] for i in range(numThreads): thread = SimpleThread(o) threads.append(thread) for thread in threads: thread.start() for thread in threads: thread.join() print "done testing loggin threads." finally: del o TestThreads(2) From mhammond at skippinet.com.au Mon Mar 13 16:46:14 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 13 Mar 2000 21:46:14 GMT Subject: win32ui.GetActiveWindow() problem References: Message-ID: "Michal Bozon" wrote in message news:Pine.OSF.4.10.10003131737550.6506-100000 at prfdec.natur.cuni.cz... > __Hi__ all. > If you are not Win9x/2000 user, this won't be probably something for you. ... > from win32ui import * > from time import sleep > > while 1: Change this line from: > s = GetActiveWindow().GetWindowName() To: s = GetForegroundWindow().GetWindowText() and you will be right! Mark. From mhammond at skippinet.com.au Sun Mar 26 18:47:42 2000 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 26 Mar 2000 23:47:42 GMT Subject: Language forks (was: Python tutorial/comparison for C++ programmer) References: <5FF7ED1C1C902C69.0E5D50066AC4B434.CE45BE37438DE91A@lp.airnews.net> Message-ID: "Grant Edwards" wrote in message news:slrn8dt5fb.bin.nobody at isis.visi.com... > Cameron Laird wrote: > > > > how does it happen that CPython and JPython > > happily co-exist? > > Because they've decided to? The goal of one is not to kill the other. That > can rarely be said of MS's attitude towards other entities in the SW world. > MS seems to actively attempt to diverge from standards in order to try to > kill off those standards and establish their own dominance. This also works in reverse - I think it would be accurate to say that the rest of the industry is very suspicious of MS, and very relucant to work with MS or embrace their standard deviations - even on the (possibly rare) occasions when it is a necessary and well designed extension. Don't forget that CPython also made concessions to JPython - wanting to work with each other cuts both ways... Mark. From a.eyre at optichrome.com Tue Mar 7 09:26:30 2000 From: a.eyre at optichrome.com (Adrian Eyre) Date: Tue, 7 Mar 2000 14:26:30 -0000 Subject: Win32 KeyboardInterrupt In-Reply-To: <38BD1C35.354B7922@nipltd.com> Message-ID: <001801bf8841$21347140$3acbd9c2@optichrome.com> > Turns out the worker class was blocking on a socket.accept(). As soon as I > telnetted to the listening port, the worker shut down... > > Any way I can make socket.accept() not do this? See the 'select' module for non-blocking IO. ----------------------------------------------------------------- Adrian Eyre - http://www.optichrome.com From sdhyok at email.unc.edu Thu Mar 9 17:25:16 2000 From: sdhyok at email.unc.edu (Daehyok Shin) Date: Thu, 9 Mar 2000 17:25:16 -0500 Subject: Sparse matrix? Message-ID: <8a98cc$8li$1@news2.isis.unc.edu> Is there any package supporting sparse matrices in Linear Algebra? Peter From mindlace at imeme.net Wed Mar 22 22:20:50 2000 From: mindlace at imeme.net (mindlace) Date: Thu, 23 Mar 2000 03:20:50 +0000 Subject: what do you expect? Message-ID: <38D98D92.C039DA6B@imeme.net> Flying Circus, I'm trying to do expect-like behavior in python. I tried to install PIPE 1.0, but I get an error along the way. I moved on to ExpectPy 1.8, which looks more maintained. When I run ./configure, I get this error: ./configure: unset: `ac_cv_lib_expect5.30.1_exp_expectv': not a valid identifier checking for exp_expectv in -lexpect5.30.1... (cached) no configure: error: Cannot compile with the Expect library I removed expect and compiled and installed the expect that the ExpectPy's site suggested, and I received the same error when I attempted to install. I then tried again to use expect from Debian potato, receiving the above error. I have tcl8.0. ... Now, I'm not committed to expect, but I have to run passwd from Zope, so it seemed to be the right decision. Is there a better way to do this? Thanks, ethan fremen -- http://mindlace.net __________________ mindlace at imeme.net I don't want The Truth but I wouldn't mind a Big Analogy. From jide2time at my-deja.com Tue Mar 21 11:18:17 2000 From: jide2time at my-deja.com (jide2time at my-deja.com) Date: Tue, 21 Mar 2000 16:18:17 GMT Subject: Tkinter 1.5.2 on windows Message-ID: <8b87bn$fd5$1@nnrp1.deja.com> I downloaded and installed the Python 1.5.2 distribution for PCs from www.python.org - I installed one PC and it worked fine. I installed it on another, and I can't get Tkinter to work - It fails in _tkinter.create(*,*,*), and claims that it could not find a usable init.tcl anywhere, despite the fact that there blatantly is one in the one of the directories that it claims to have searched... Help ! (P.S. I tried setting the TCL_LIBRARY and TK_LIBRARY environment symbols in autoexec.bat ... set TCL_LIBRARY=C:\blahblah set TK_LIBRARY=C:\blahblah This did not work, and besides, I didn't need to do this on the first PC, which I have had to give to someone else...) Cheers, Tim E Sent via Deja.com http://www.deja.com/ Before you buy. From jiml at longson.com Thu Mar 30 10:06:47 2000 From: jiml at longson.com (jiml at longson.com) Date: Thu, 30 Mar 2000 15:06:47 GMT Subject: Instantiate arbitrary classes at run time Message-ID: <8bvqhr$upu$1@nnrp1.deja.com> I am trying to create an instance of an arbitrary class at run time. I can load the class easily enough by target = 'arbitrary_class_name' command = "from " + str(target) + " import " + str(target) exec( command ) But can't figure out how to create an instance of the class without using the class name instance = arbitrary_class_name() works fine, but I need to be able to create that instance based on the string stored in target In Java, I would code something like instance = Class.forName( target ); and that would produce the same result as instace = new arbitrary_class_name( ) I suspect the same capability exists in Python, but I haven't figured out how to find it in the documentation. Sent via Deja.com http://www.deja.com/ Before you buy. From patknight at my-deja.com Wed Mar 29 07:43:24 2000 From: patknight at my-deja.com (patknight at my-deja.com) Date: Wed, 29 Mar 2000 12:43:24 GMT Subject: Choice Of Language (was: Python Advocacy) References: Message-ID: <8bstp9$mfq$1@nnrp1.deja.com> In article , "Don Tuttle" wrote: > [Ran] > So let me ask all you folks that do. What percentage of > your paid, professional time do you get to use Python? > Practically all the time I'm actually coding (if you include writing extensions in C/C++ for the bits we can't do in Python). I have two guys working with me who must code in Python >60% of their time as well. I'm the manager. Guess who gets to choose the language? :-) Sent via Deja.com http://www.deja.com/ Before you buy. From gerrit at nl.linux.org Wed Mar 1 04:23:39 2000 From: gerrit at nl.linux.org (Gerrit Holl) Date: Wed, 1 Mar 2000 10:23:39 +0100 Subject: X gurus? In-Reply-To: <38BCE605.2C78E347@sightreader.com>; from kens@sightreader.com on Wed, Mar 01, 2000 at 01:42:29AM -0800 References: <38BCE605.2C78E347@sightreader.com> Message-ID: <20000301102339.B28091@nl.linux.org> Mike Sabin wrote: > I am beginning a small project which I am afraid may > have to end up being written in C (I say afraid, > because I will have to LEARN C first, if this is the > case). I am programming for the X Windows environment > on Linux, and need to accomplish the following two > things: > > 1. At a certain time, I need to get the x-y coordinates > of my mouse pointer, no matter where my pointer is at > the time (it could be over the window for some other > application, but I want a function call to return > the coordinates to my application) > > 2. At a certain time, I need to artificially generate > a button 1 mouse click, whereever the mouse pointer is > currently located (e.g. over another application's > window). My program must do this, without me actually > having to click on the mouse or hit any key. > > Can it be done in python? I actually don't have much > hope that it can, but I am often surprised what some > of you people will come up with around here.... Sjoerd Mullender has done that. Parnassus links to his homepage for an extensive X library in Python, but it's not on his homepage. It can still be downloaded, however, on: http://www.cwi.nl/ftp/sjoerd/X-extension.tar.gz have fun, Gerrit. -- -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From boud at rempt.xs4all.nl Mon Mar 20 14:17:55 2000 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 20 Mar 2000 19:17:55 GMT Subject: Weird database question: SQL or what?? References: <38D5C2AD.BB0CA870@yahoo.com> Message-ID: <8b5th3$3ts$1@news1.xs4all.nl> Paul Winkler wrote: <...> With that small a set of data, I'd be tempted to start out with simple text files, perhaps structured as xml or something, and keep those files synchronized with timestamps for every record. Keep it simple, and convert your data to something more complicated when the need arises. Of course, everything you want _can_ be done with Python and an SQL database, but if you want all those features, it's going to be quite a job - I mean, there's a reason Lotus Notes is so big and expensive... -- Boudewijn Rempt | http://www.valdyas.org From ngps at post1.com Thu Mar 2 11:26:26 2000 From: ngps at post1.com (Ng Pheng Siong) Date: Thu, 02 Mar 2000 16:26:26 GMT Subject: Object Databases References: <1260348438-26442187@hypernet.com> <3dk8jnd5un.fsf_-_@amarok.cnri.reston.va.us> <38BCDDC4.6D96AE4D@onera.fr> <3daekicp86.fsf@amarok.cnri.reston.va.us> Message-ID: <89m4nb$nsb$1@nnrp1.deja.com> In article <3daekicp86.fsf at amarok.cnri.reston.va.us>, akuchlin at mems-exchange.org (Andrew M. Kuchling) wrote: > I was thinking of writing some simple schema declaration language, > re-using as much of Python's tokenise.py as possible. Something like: > > class Sequence using table sequences: > id int > name string > Operation[] ops > > class Operation: > op_id int > ... > > ... and then something could parse this description, spit out SQL to > create the tables, generate SQL to map between two slightly different > schemas, automatically load & save objects. I imagine a simpler approach is to use ZODB. One possibility is, instead of FileStorage or BerkeleyStorage as the underlying, use something like _MySQLStorage_ or _OracleStorage_! Writing the abovementioned new storages is left as exercises for the reader. ;-) Hmm, I wonder: MySQL doesn't have transactions, yet. Does wrapping it with ZODB provide sufficient transactional functionality, while retaining its high performance? Maybe we can bring this thread over to Zope-Dev. I've been putting off subscribing, I guess I have to now. ;-| Gedanke-experiments-are-fun-ly y'rs -- Ng Pheng Siong * http://www.post1.com/home/ngps Sent via Deja.com http://www.deja.com/ Before you buy. From emile at fenx.com Fri Mar 3 20:59:23 2000 From: emile at fenx.com (Emile van Sebille) Date: Fri, 3 Mar 2000 17:59:23 -0800 Subject: Remote Inbox inspector & mail-forwarder References: Message-ID: <0c9d01bf857d$45c35a60$01ffffc0@worldnet.att.net> I've seen memory problems come up about every second or third week on a dedicated server I'm running at one location. Win95, 64mb, with stock 1.5.2, mxODBC and win32v125(I think). The only other thing that system does is a batch file the uses xcopy and a beta command line interface version of winzip. not-sure-what-it-means-though-ly y'rs Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Grant Edwards Newsgroups: comp.lang.python To: Sent: Friday, March 03, 2000 11:53 AM Subject: Re: Remote Inbox inspector & mail-forwarder > > I've written a mail-forwarder also. After it runs for a couple > days, checking my inbox every minute or so, I get a COM error > about insufficient storage available. > > Seen anything like that? > > -- > Grant Edwards grante Yow! If Robert Di Niro > at assassinates Walter Slezak, > visi.com will Jodie Foster marry > Bonzo?? > -- > http://www.python.org/mailman/listinfo/python-list > From maxm at normik.dk Wed Mar 22 04:07:26 2000 From: maxm at normik.dk (maxm) Date: Wed, 22 Mar 2000 10:07:26 +0100 Subject: mod_perl and mod_python, is perl better for that task? In-Reply-To: <14550.26665.12140.694541@cmpu.net> Message-ID: > [mailto:python-list-admin at python.org]On Behalf Of Kendall Clark > Pedro> Really, could mod_python be as good as mod_perl? There are > Pedro> more than 400000 site running mod_perl, including sites > Pedro> with huge traffic like slashdot or imdb. PyApache and > Pedro> Httpdapy don't seem to be causing much of enthusiasm in > Pedro> Pythonland. Why? If mod_python could be as good as mod_perl > Pedro> I think there would be few reasons to use perl. Well there is probably a lot more people using Perl than Python. Probably a testament to the brand of Perl. Even in Open Source "marketing" is important. Besides ... mod_perl is practically all they got. Python has a lot more options (Zope etc.). A language like PHP is really nice and extremely qick to use for web devbelopment. But any language will at some point need the features of Python for making big Apps. Then php users will get into problems with their language. Besides that PHP is confined to Apache and cannot be used in the IIS, which a lot of our customers use. > I think the lack of enthusiasm is because Zope is a lodestone. It > deserves the attention and free, community development it gets, but it > would be a shame, and a detriment to Python long-term, if it > effectively squeezes everything else out of this space. It's good > stuff but it's not perfect for *every* Web application need. The main problem with Zope is the STEEP learning curve. To get more people to use it, it has to be easier to get into. IMHO dtml is absolutely the wrong aproach. I want Python in my pages as a scripting language. I don't want to learn a new (bastard) language to use my Python modules. The succes of php is probably a testament to the fact that others see it that way to. Well actually the whole idea of mixing html and code is a terrible idea, but most newbies find it natural and they have to find out for themself that it's a bad idea. What is needed is a tool that can start out that way, but can also be used as pure code, when that level of enlighment has been reached. Zope can do this, but it is way to difficult. You have to use a "product" to implement new functionality which is a real pain when you could just use a Python module. If you just want to use a single python function on a page, you have tweak all kinds of settings to get it in to you page. A bother for something that really should, and can be, simple. Perhaps I am wrong about Zope, but that shows another problem with it ... really poor documentation. What we need is probably something like PHP but with Python as the scripting language. Python in asp on IIS does this. Apache needs it. I have no idea how difficult it would be to implement though. I don't do c, only scripting languages like Python, PHP, Jscrip, VBScript etc. And then we need a bunch of implemented design patterns as modules to use on all platforms. This would benefit both zope and other projects too. and could make Python a killer webserver language. If anybody would implement the mod_python that worked on the apache, I would be all over it doing patterns in Python. Until then I do it on the IIS. Max M ------------------------------------------------------------------------ Max M Rasmussen, New Media Director http://www.normik.dk Denmark e-mail mailto:maxm at normik.dk private mailto:maxmcorp at worldonline.dk From shogan at iel.ie Thu Mar 2 05:20:30 2000 From: shogan at iel.ie (Shaun Hogan) Date: Thu, 2 Mar 2000 10:20:30 -0000 Subject: whats a good book on python/c/c++ integration? Message-ID: <02fd01bf8430$eff264c0$2801000a@iel.ie> can anyone recomend a good book that goes a bit in depth on python/c/c++ integration, embedding python and the like? -------------- next part -------------- An HTML attachment was scrubbed... URL: From falknor at worldspy.net Fri Mar 24 20:03:30 2000 From: falknor at worldspy.net (Falknor) Date: 24 Mar 2000 17:03:30 -0800 Subject: Hmm.. Whatever would be the Python equivalent to this? *ponders* Message-ID: <20000325010330.4707.cpmta@c000.sfo.cp.net> An embedded and charset-unspecified text was scrubbed... Name: not available URL: From claird at starbase.neosoft.com Tue Mar 21 08:46:02 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 21 Mar 2000 07:46:02 -0600 Subject: Tangential anti-educationist rant (was: what is easier to learn first?...) References: Message-ID: <3E53238E59BADF34.01ECA7E96E32ECCE.EFB19829F3626C71@lp.airnews.net> In article , Grant Edwards wrote: . . . >more Python. I'd definitely go with Python. C is for OS >kernels, device drivers, and embedded work. It really oughtn't >be taught to beginners or people who just want to write an >application. C is low-level and unsafe: the programmer's got >to do way too much of the housekeeping, and there are countless >ways to hang yourself before you've even gotten enough rope out >to accomplish anything. -- but at least the semantics are >farily simple (assuming you know some assembly language and how >compilers work). . . . It pretty well captures my impression of institutional education that US high schools commonly teach C (and C++!) as a first programming language. I find that typical of the mental abuse they thought- lessly perpetrate. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From aahz at netcom.com Fri Mar 10 11:49:15 2000 From: aahz at netcom.com (Aahz Maruch) Date: 10 Mar 2000 16:49:15 GMT Subject: Python performance References: Message-ID: <8ab92b$4fo$1@nntp6.atl.mindspring.net> In article , Chris Ryland wrote: > >Then again, if GvR really *isn't* interested in serious performance >speed-ups ("not that there's anything wrong with that" ;-), nothing's >probably gonna happen. I think it's more accurate to state that performance improvements take lower priority than other issues. -- --- Aahz (Copyright 2000 by aahz at netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 "Along the lines of getting a massage, taking a hot bubble bath, and swimming in a pool of warm, melted chocolate, can you give me some innovative ways that you pamper yourself?" "Spend three hours flaming stupid people on the Net." --Aahz From donn at oz.net Wed Mar 1 00:53:02 2000 From: donn at oz.net (Donn Cave) Date: 1 Mar 2000 05:53:02 GMT Subject: any non programmers out there? References: <38bc8506@omega> Message-ID: <89ib7u$ljs$0@216.39.151.169> Quoth "Cristian Echeverria" : | I think a very good and basic introduction is the Python tutorial: | | http://www.python.org/doc/current/tut/tut.html I started with that document and liked it a lot, too, but it's probably a little hairy for someone who really has no background in this area. I mean this not as criticism of the document, which is perfect for its normal audience, but in case someone out there is thinking ``Man, I must be retarded, that was Greek to me!'' Donn Cave, donn at oz.net From avv at quasar.ipa.nw.ru Thu Mar 9 12:40:39 2000 From: avv at quasar.ipa.nw.ru (Alexander V. Voinov) Date: Thu, 09 Mar 2000 09:40:39 -0800 Subject: Anyone using Curses with Python on NT? References: <38c6ea4b_4@news1.prserv.net> Message-ID: <38C7E217.64D7DE@quasar.ipa.nw.ru> Hi, Michael Appelmans wrote: > > I have a project that requires text mode screens for telnet application. I > thought of doing it in Python to make it interesting but the console mode > would require some form curses library. There is a pyslang wrapping at: ftp://starship.python.net/pub/crew/avv/pyslang/pyslang-0.2.0.tgz. There is also a bit higher level (but other way more restrictive) set of widgets newt, which might be possible to recompile with the win32 port of SLang. Regards Alexander From clopez at abo.fi Tue Mar 14 06:38:31 2000 From: clopez at abo.fi (Cesar Lopez) Date: Tue, 14 Mar 2000 13:38:31 +0200 Subject: Hi, about extending python with C and SWIG Message-ID: <38CE24B7.5160A8A4@abo.fi> I need to run call a C function from a Python program, so now I?m using SWIG to get the wrap file and build this interface. Here is my header, code and interface files: //led.h int Setup(int state); // state = 1 --> ON ; state = 0 --> OFF int _state; // Defining communication with the device, Port, Adress, configuration registers and so on ... #define PBIOR (*(volatile short int *) (0x5ffffc6)) #define PBCR1 (*(volatile short int *) (0x5ffffcc)) #define PBCR2 (*(volatile short int *) (0x5ffffce)) #define PBDR (*(volatile short int *) (0x5ffffc2)) //led.c #include "led.h" int Setup(int state) { PBIOR |= 0x8000; // Set the bit for output PBCR1 &= ~0xc000; // Make it a normal I/0 switch (state){ case 1:{ PBDR |= 0x8000; // Set the LED on _state=1; // to read the state of the led return 0; } case 0:{ PBDR &= 0x0000; // Set the LED off _state=0; return 0; } default: return -1; // Error: Invalid code } //switch } //led.i %module led %{ #include "led.h" %} extern int Setup(int state); extern int _state; IT IS CORRECT THIS INTERFACE FILE? Or How can I do to wrap my "#define ...." includes in led.h Thanks. Cesar Lopez From ulf.engstrom at b2b-link.com Thu Mar 9 08:35:31 2000 From: ulf.engstrom at b2b-link.com (=?iso-8859-1?Q?Ulf_Engstr=F6m?=) Date: Thu, 9 Mar 2000 14:35:31 +0100 Subject: popup from cgi Message-ID: <006801bf89cc$5708ee40$d300a8c0@Alexis> A little while ago we talked about doing com-things from a cgi-script and I managed to get it working. Now I wondering about extending it a little and adding a popup from windows scripting host. In Mark Hammonds reply last time was: > COM GUI apps wont work Is this true for all sorts of com-objects? Is it true for scripting host? There isn't any sort of security setting that can change this? What I want is a special area on a webpage, as soon as anyone enters I want to have a popup on the computer running the webserver. Is there any other way but com to get a nice little popup from Python? The reason I thought about WSH is that I've been working with it's shell functions and I'm using some other com-objects at the same place Regards Ulf -------------- next part -------------- An HTML attachment was scrubbed... URL: From moshez at math.huji.ac.il Thu Mar 23 00:49:49 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 23 Mar 2000 07:49:49 +0200 (IST) Subject: determining type In-Reply-To: <8bb0p2$b6r$1@nnrp1.deja.com> Message-ID: On Wed, 22 Mar 2000, sp00fD wrote: > Maybe I'm missing something, but how does this help if it's an integer > rather than a string? "%s" format specifier implicitly invokes the str() function. -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html http://www.linux.org.il -- we put the penguin in .com From effbot at telia.com Tue Mar 7 14:16:33 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 07 Mar 2000 19:16:33 GMT Subject: Self Nanny References: <38C5709D.59E8@marshall.edu> Message-ID: Mark Hathaway wrote: > Was there a problem with doing it the other way around... > class aClass: > def __init__(self,number): > self.num = number > n = self.num > > class aClass: > def __init__(number): > local.n = number > where the roles are reversed. All object attributes are > referred to by their names and any class (global) attributes > are specified by "local.". This would decrease tremendously > the need to write 'self.' and would still easily allow the > differentiation of class-wide attributes from object attributes. you sure lost me there. do you want to make it illegal to use local variables in methods? what happened to num, btw? and how come you don't need to qualify the argument name? and do you really think it's a good idea to have different scoping rules for methods and stand-alone functions? > Which do you write more of? Object attribute names. really? I'm pretty sure I don't. to prove that I'm a minority, why not analyze your favourite Python application? From claird at starbase.neosoft.com Wed Mar 1 14:38:19 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 1 Mar 2000 13:38:19 -0600 Subject: Splitting comp.lang.python References: <20000301140753.16735.qmail@qa.polytopic.com> Message-ID: <836DAFF48BB74487.F181DAFF1B4CD5BF.DCA44F8A445A3160@lp.airnews.net> In article , Manuel Gutierrez Algaba wrote: . . . >comp.lang.python.tim.peters where Tim Peters would fight >against ruby, viper, Haskell ... whatever, where most syntax . . . That clever rascal! Here I thought he was fighting *for* all those things. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From me at my.own.computer Sun Mar 12 11:34:09 2000 From: me at my.own.computer (Aesop) Date: Mon, 13 Mar 2000 00:34:09 +0800 Subject: Newbie: req for a bit of tutorial type help. References: Message-ID: <38cbc6d0$0$1327@motown.iinet.net.au> Howdy, Thanks for the quick response ;-) . I have the Win32 distribution, which does not contain the file you mentioned. Still very interested. know where i can find it? TIA yours in zeros and ones..... "Moshe Zadka" wrote in message news:Pine.GSO.4.10.10003121707240.2178-100000 at sundial... > For a program in Python that prints primes, look in the source > distribution, at the Demo/scripts/primes.py > > On Sun, 12 Mar 2000, Aesop wrote: > > > Howdy, > > At risk of repeating myself, i have been using python for about 2 days > > now. its been at least six years since i last looked at "C" and the old > > brain has been flushed and reloaded with a lot of non programming type > > things ;-) > > > > Am trying to write a program to calculate prime numbers. Trying to do this > > crossword type thing that is entirely mathematical in nature and i need a > > list of prime numbers of 2 digits. Thinking this is a damned good excuse for > > figuring out how to programme, again, I went off and downloaded Python. > > > > Writing up a brute force type algorithm (no points for creative thinking on > > my behalf). What i need is something that will perform divisions of the > > prospective prime number, and report whether there is any "remainder". I.E > > the modulus operator of C. > > > > anyone point me to , or supply some good info for a raw recruit? > > > > > > Yours in zeros and ones, > > Ambrose. S > > > > > > -- > > http://www.python.org/mailman/listinfo/python-list > > > > -- > Moshe Zadka . > http://www.oreilly.com/news/prescod_0300.html > > From cpr at emsoftware.com Fri Mar 10 11:07:13 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Fri, 10 Mar 2000 16:07:13 GMT Subject: Python performance References: Message-ID: Maybe Python 3K would be a good time to revisit the structure of the interpreter (allowing massive breakage to the C interface for embedding/extending) in order to make it more optimizable? E.g., one could start using old Lisp implementation tricks such as encoding primitive objects in the actual object pointer, etc. There's probably a reasonably short catalog of such techniques that are well-known in the Lisp world. Then again, if GvR really *isn't* interested in serious performance speed-ups ("not that there's anything wrong with that" ;-), nothing's probably gonna happen. -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com "Chris Ryland" wrote in message news:jQ%w4.238$m4.7517 at news... > The recent Python-for-Lisp-ers note and other recent notes have brought up > Python performance. > From embed at geocities.com Mon Mar 27 11:19:34 2000 From: embed at geocities.com (Warren Postma) Date: Mon, 27 Mar 2000 11:19:34 -0500 Subject: Strict Type Checking Objects in Python Message-ID: Has a well documented method already been made to create a static class definition? For example, to give the type of each attribute, and an exhaustive list of the values for each attribute, and perhaps then to instantiate efficiently any number of these objects, all of which references a single shared "definition" of the valid attributes for a type. I am thinking this would be handy for databases. Warren --- code snippet -- type_string = type("a") # what is the official "name" of the string type anyways!? #type,length,null?, .... ?? whatever else ?? ..... attributes_list = { "name": (type_string, 80, non_null, ..... ), "address": (type_string, 100, non_null, ..... ) }; class my_obj(typesafe_obj): def __init__(self,dict): self.dict = dict # store a reference to a value attribute list .... From kelley at bioreason.com Fri Mar 31 06:41:52 2000 From: kelley at bioreason.com (Brian Kelley) Date: Fri, 31 Mar 2000 12:41:52 +0100 Subject: Philosophical long integer question... References: <38E23160.B16860C2@bioreason.com> <38E3C327.96C077C5@t-online.de> Message-ID: <38E48F00.2D9BD07E@bioreason.com> Ralf Muschall wrote: > Brian Kelley wrote: > > > should (1 << 1000) produce a long int? (It currently produces 0 on a > > IMHO it should if and only if everything else promotes as > well. In that case, it would be nice to have standard types > (e.g. classes that come with the libs) like int8, int16, > int32, int64, uint8, ... which behave like their names > indicate (e.g. for hacking crypto stuff). > > Ralf I hadn't thought about this approach. Currently python will not promote unless forced. What if the procedure was reversed? Promote unless explicitly told not to promote. So (1 << 1000) will promote but (int32(1) << 1000) won't (or whatever you want to specify 'normal' integers with) Is this what you mean? Half of my brain likes this, the other half doesn't. The questions are what forms are used the most often and how this would affect users (it certainly would affect a lot of code...) -- Brian Kelley (505) 982-7884 ext 207 Bioreason, Inc kelley at bioreason.com 105 Washington #303, Santa Fe NM, 87501 From alex at somewhere.round.here Sat Mar 25 19:55:33 2000 From: alex at somewhere.round.here (Alex) Date: 25 Mar 2000 19:55:33 -0500 Subject: Multi-argument append() is illegal References: <000f01bf8296$dbe53480$732d153f@tim> <38BCE283.CA2EAB85@sightreader.com> <20000326014025.B25139@xs4all.nl> Message-ID: I don't know whether this has been mentioned, but along the same lines, I noticed recently that the 'index', 'count' and 'remove' methods of lists also treat multiple arguments as a tuple: >>> l = map (None, range (10), range (10, 20)) >>> l.index (1, 11) >>> l.count (1, 11) 1 >>> l.remove (1, 11) >>> for t in l: print t ... (0, 10) (2, 12) (3, 13) (4, 14) (5, 15) (6, 16) (7, 17) (8, 18) (9, 19) >>> This probably also wants changing. Alex. From moshez at math.huji.ac.il Tue Mar 7 00:58:29 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Tue, 7 Mar 2000 07:58:29 +0200 (IST) Subject: HELP: restore my faith in Python In-Reply-To: Message-ID: On 7 Mar 2000, Michael Hudson wrote: > Food for thought: the computable numbers are countable. > > Proof left as an excercise for the reader (it's not hard!). > > (Is it even meaningful to ask whether they are [recursively] > enumerable?) They are, with the classical diagonal argument. -- Moshe Zadka . http://www.oreilly.com/news/prescod_0300.html From gchiaramonte at ibl.bm Wed Mar 8 07:04:06 2000 From: gchiaramonte at ibl.bm (Gene Chiaramonte) Date: Wed, 8 Mar 2000 08:04:06 -0400 Subject: List Init Behavior Message-ID: When initializing a list of lists, I came across this behavior. >>> l = [[0]*2]*3 >>> l [[0, 0], [0, 0], [0, 0]] >>> l[1][1] = 5 >>> l [[0, 5], [0, 5], [0, 5]] What I really want to do is quickly init a large list of lists where each row is its own list. Not all rows pointing to the same list as above. Any ideas? This works - but I like the one line syntax better. x = 5 y = 10 l = [0]*y for i in range(y): l[i] = [0]*x Thanks, Gene From cpr at emsoftware.com Mon Mar 6 23:46:07 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Tue, 07 Mar 2000 04:46:07 GMT Subject: Python performance Message-ID: The recent Python-for-Lisp-ers note and other recent notes have brought up Python performance. I'm just curious (being an old language hacker for 30+ years but new to Python): why is Python performance ultimately any worse than Lisp? Is it because there's only been one major implementation effort so far, and so people haven't had a chance to learn the techniques required to make it run fast, while Lisp has had 30+ years to mature? What's so different about compiling Python vs. Lisp? Some Lisp compilers have gotten quite good over the years. I realize this is a big subject, and that many of you Python wizards out there have thought a good deal about it, and I don't want to open a can of worms, but if someone can summarize the issues, that'd sure be helpful to someone who wants to understand them. Thanks. -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com From darrell at dorb.com Mon Mar 13 20:51:21 2000 From: darrell at dorb.com (Darrell) Date: Tue, 14 Mar 2000 01:51:21 GMT Subject: Stackless/microthreads merge news References: Message-ID: "Will Ware wrote: > Memory efficiency is a big part of it, and context switching should > presumably be faster (tho I haven't clocked it). What motivated my > interest in microthreading was a wish to run thousands or tens of > thousands of threads simultaneously, which started when I went to a > talk by Gerald Sussman on amorphous computing, described at > http://www.swiss.ai.mit.edu/projects/amorphous/ So your contributing to the end of human life.. http://washingtonpost.com/wp-srv/WPlate/2000-03/12/215l-031200-idx.html --Darrell From kragen at dnaco.net Tue Mar 14 10:01:07 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Tue, 14 Mar 2000 15:01:07 GMT Subject: Forth like interpreter References: <158801bf8bdc$08516040$6401a8c0@dorb> <8al719$h5c$1@nnrp1.deja.com> Message-ID: In article <8al719$h5c$1 at nnrp1.deja.com>, wrote: >> Not all compilers implement switch statements as jump-tables. > >really? can you name one that doesn't? gcc 2.95.2 doesn't always implement switch statements as jump-tables when compiling for i386. Sometimes it implements them with a rat's nest of jumps. Here are two examples, one where it uses a jump-table and one where it doesn't. nclude int main(int argc, char **argv) { switch(argc) { case 1: printf("got a unity\n"); return 0; case 2: case 3: printf("got two or three\n"); return 1; case 4: printf("got four, a square!\n"); return 2; case 5: printf("got five\n"); return 1; case 6: printf("got the first perfect number\n"); return 2; case 7: printf("got seven\n"); return 1; default: printf("got something weird\n"); return -1; } } This switch compiles to a jump table. Here's the output of gcc -Wall -S; the jump table is at .L12. -O2 leaves it as a jump table. .file "switch2.c" .version "01.01" gcc2_compiled.: .section .rodata .LC0: .string "got a unity\n" .LC1: .string "got two or three\n" .LC2: .string "got four, a square!\n" .LC3: .string "got five\n" .LC4: .string "got the first perfect number\n" .LC5: .string "got seven\n" .LC6: .string "got something weird\n" .text .align 4 .globl main .type main, at function main: pushl %ebp movl %esp,%ebp subl $8,%esp movl 8(%ebp),%eax decl %eax cmpl $6,%eax ja .L11 movl .L12(,%eax,4),%eax jmp *%eax .p2align 4,,7 .section .rodata .align 4 .align 4 .L12: .long .L4 .long .L6 .long .L6 .long .L7 .long .L8 .long .L9 .long .L10 .text .p2align 4,,7 .L4: addl $-12,%esp pushl $.LC0 call printf addl $16,%esp xorl %eax,%eax jmp .L2 .p2align 4,,7 .L5: .L6: addl $-12,%esp pushl $.LC1 call printf addl $16,%esp movl $1,%eax jmp .L2 .p2align 4,,7 .L7: addl $-12,%esp pushl $.LC2 call printf addl $16,%esp movl $2,%eax jmp .L2 .p2align 4,,7 .L8: addl $-12,%esp pushl $.LC3 call printf addl $16,%esp movl $1,%eax jmp .L2 .p2align 4,,7 .L9: addl $-12,%esp pushl $.LC4 call printf addl $16,%esp movl $2,%eax jmp .L2 .p2align 4,,7 .L10: addl $-12,%esp pushl $.LC5 call printf addl $16,%esp movl $1,%eax jmp .L2 .p2align 4,,7 .L11: addl $-12,%esp pushl $.LC6 call printf addl $16,%esp movl $-1,%eax jmp .L2 .p2align 4,,7 .L3: .L2: leave ret .Lfe1: .size main,.Lfe1-main .ident "GCC: (GNU) 2.95.2 20000220 (Debian GNU/Linux)" This switch, on the other hand, compiles to an altogether different sort of structure: #include int main(int argc, char **argv) { switch (argv[0][0]) { case 'a': return 73; case 'Q': return 81; case '!': return 33; case '-': printf("%s [aQ!]\n", argv[0]); return 0; default: return 1; } } Here's what it compiles to, with some comments I added: .file "switch.c" .version "01.01" gcc2_compiled.: .section .rodata .LC0: .string "%s [aQ!]\n" .text .align 4 .globl main .type main, at function main: pushl %ebp movl %esp,%ebp subl $8,%esp movl 12(%ebp),%eax movl (%eax),%edx movb (%edx),%al ; load argv[0][0] cmpb $81,%al je .L5 ; if 'Q', go to .L5 cmpb $81,%al jg .L10 ; if not above 'Q': cmpb $33,%al je .L6 ; if '!', go to .L6 cmpb $45,%al je .L7 ; if '-', go to .L7 jmp .L8 ; otherwise, go to .L8 ("default:") .p2align 4,,7 .L10: ; else (below 'Q'): cmpb $97,%al je .L4 ; if 'a', go to .L4 jmp .L8 ; otherwise, go to .L8 ("default:") .p2align 4,,7 .L4: movl $73,%eax jmp .L2 .p2align 4,,7 .L5: movl $81,%eax ; when I wrote this code, I honestly didn't ; realize 81 was the ASCII code for 'Q'. I guess ; I have ASCII on the brain. jmp .L2 .p2align 4,,7 .L6: movl $33,%eax ; I *did* know '!' was 33, though. jmp .L2 .p2align 4,,7 .L7: addl $-8,%esp movl 12(%ebp),%eax movl (%eax),%edx pushl %edx pushl $.LC0 call printf addl $16,%esp xorl %eax,%eax jmp .L2 .p2align 4,,7 .L8: movl $1,%eax jmp .L2 .p2align 4,,7 .L3: .L2: leave ret .Lfe1: .size main,.Lfe1-main .ident "GCC: (GNU) 2.95.2 20000220 (Debian GNU/Linux)" -O2 swizzles some blocks around and eliminates some useless instructions, but leaves the rat's-nest. The polymorphic inline cache people seem to think that a couple of tests might be quicker than a jump table in many cases these days. -- Kragen Sitaker The Internet stock bubble didn't burst on 1999-11-08. Hurrah! The power didn't go out on 2000-01-01 either. :) From ed at sis.yorku.ca Wed Mar 29 09:36:39 2000 From: ed at sis.yorku.ca (Ed F. McCurdy) Date: Wed, 29 Mar 2000 09:36:39 -0500 Subject: (Continuous) strip chart recorders with Tkinter/PIL In-Reply-To: Chris WRIGHT's message of "26 Mar 2000 21:11:15 -0500" References: Message-ID: <200003291436.JAA13022@sprawl.sis.yorku.ca> You may want to look at the BLT graph widget (http://www.tcltk.com/blt/index.html). There is a fairly rich python wrapper for that in the PMW (Python Mega Widgets) library (http://www.dscpl.com.au/pmw/). Hope this helps, Ed -- Edward F. McCurdy, | ed at sis.yorku.ca York University, Toronto, Canada | (416) 736-2100x22685 From ulf.engstrom at b2b-link.com Tue Mar 21 05:15:51 2000 From: ulf.engstrom at b2b-link.com (=?iso-8859-1?Q?Ulf_Engstr=F8m?=) Date: Tue, 21 Mar 2000 11:15:51 +0100 Subject: ICQ with Python? Message-ID: <000501bf931e$6f91eec0$d200a8c0@no> Has anyone tried accessing ICQ with a Python interface? I thought it was an interesting thing to try, but if someone has done it already I can start buildning from there instead :) (I want to get and send icq-msgs from within some other programs) Regards Ulf From kens at sightreader.com Sun Mar 5 16:13:09 2000 From: kens at sightreader.com (Ken Seehof) Date: Sun, 05 Mar 2000 13:13:09 -0800 Subject: Elementry question on indeces References: Message-ID: <38C2CDE5.B623CDE3@sightreader.com> Think about these questions and all will be very clear. "You have a 5 inch piece of string. You want to cut it into one inch pieces. How many times to you cut the string?" "Has the new millenium started yet or not?" "Why is this the 21st century when it starts with 20?" "How many integers are there between 50 and 100?" Rick wrote: > From the tutorial, on strings and zero relative indeces, > where word = > 'HelpA'. > > I have no problem with this, we are asking for 4th entry: > >>> word[4] > 'A' > > but it seems to me the following is asking for the 0th, 1th and 2th entries > (ordinal 1st ,2nd and 3rd) but all we are getting is the zero-th and one-th. > > >>> word[0:2] > 'He' > > What am I missing here? Makes me feel like I've been taking stupid pills. > > Thanks, > Rick > > -- > Yale beat Harvard From dowe at 209-165-0.170.lightspeed.net Thu Mar 23 23:44:44 2000 From: dowe at 209-165-0.170.lightspeed.net (Dowe Keller) Date: Thu, 23 Mar 2000 20:44:44 -0800 Subject: Python tutorial/comparison for C++ programmer In-Reply-To: <077C600D9F281A4D.487194D3E94C88DA.D53DE68986E89418@lp.airnews.net>; from Cameron Laird on Wed, Mar 22, 2000 at 12:30:31PM -0600 References: <8b956c$9tn$1@nnrp1.deja.com> <077C600D9F281A4D.487194D3E94C88DA.D53DE68986E89418@lp.airnews.net> Message-ID: <20000323204444.A23932@209-165-0.170.lightspeed.net> On Wed, Mar 22, 2000 at 12:30:31PM -0600, Cameron Laird wrote: > This can hardly be overemphasized. There are > even hints that Microsoftians are catching on > to the reality that Python is the best language > for Win32 development. Think how remarkable > this is. I personally think it remarkable that Microserftians can catch mutch of anything at all (they certainly have a big problem catching bugs ;-). I truly wonder how mutch of MS DOS/Windows is C++ and how mutch is assembly spagetti code. -- Dowe Keller dowe at onemain.com http://dowe.50meg.com --- -----BEGIN GEEK CODE BLOCK---- GSC d? s: a C++++ L * U++>++++ P++ L+++>++++ E- W++ N++ K++ w--- M- PS+++ PE++ Y+ PGP t+ 5+ X+ R tv b++++ DI+ D+ G e+>++ h++ r@ y+ -----END GEEK CODE BLOCK----- From michael at camelot-it.com Wed Mar 8 09:41:54 2000 From: michael at camelot-it.com (Michael Tiomkin) Date: Wed, 08 Mar 2000 16:41:54 +0200 Subject: List Init Behavior References: Message-ID: <38C666B2.21114A6A@camelot-it.com> Gene Chiaramonte wrote: > When initializing a list of lists, I came across this behavior. > > >>> l = [[0]*2]*3 > >>> l > [[0, 0], [0, 0], [0, 0]] > >>> l[1][1] = 5 > >>> l > [[0, 5], [0, 5], [0, 5]] > > What I really want to do is quickly init a large list of lists where each > row is its own list. Not all rows pointing to the same list as above. Any > ideas? > > This works - but I like the one line syntax better. > x = 5 > y = 10 > l = [0]*y > for i in range(y): > l[i] = [0]*x As usual in Python, you can do something like this with a one liner: l = map(lambda u,z=[None]*x: z+[], range(y)) Michael From kc5tja at garnet.armored.net Thu Mar 9 08:29:27 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 9 Mar 2000 13:29:27 GMT Subject: What If Python Replaced Elisp? References: Message-ID: In article , taashlo at sandia.gov wrote: >I saw a comparison of Lisp and Python at > which stated that Lisp can be >about 100 times faster than Python. I'm going to assume that this I think this has a lot to do with the "explicit syntax tree" that you build with LISP programs. Think about it -- the structure of LISP programs directly mirrors an equivalent semantic tree built with a traditional compiler, like C. As a result, the same types of optimizations that are possible with languages like C are possible with the likes of LISP too. Many LISP environments compile to raw assembly language too, though I somehow doubt elisp does this. There is little, if anything, preventing this type of optimizability in Python as well -- I recall a discussion from a friend of mine (Billy Tanksley) from before I regularly read this newsgroup, indicating a desire to switch from plain bytecodes to three-operand RISC-like, platform independent, fixed-width codes. If memory serves me correctly, it had something to do with run-time code optimization and efficiency. >doesn't hold true for Elisp. But is Python fast enough to be a >scripting engine for an editor? (Beginner WAG: Python 'feels' just as Plenty fast enough in my opinion. >Would it be easier to add a COM (automation) interface to XEmacs if >Python were used instead of Elisp? If you're going to go this route, then please also consider adding CORBA interfaces. Having an editor that is simultaneously scriptable via COM and CORBA will be very, very useful. If not COM, then definately CORBA -- ORBs such as OmniORBpy and Fnorb (<-- VERY easy to use, BTW -- highly recommended) are available, and are reasonably cross-platform, as CORBA is designed to be as independent from its supporting environment as possible. >Would the GUI be improved by using Tkinter or wxWindows? I would like to see GTK myself. Tkinter just "feels" wrong to me for some reason. >What other advangages/disadvantages would arise due to this change? Quite likely we'd have a kick-butt editor that didn't take up 20MB+ of drive space. :) -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From be at et.dtu.dk Tue Mar 28 04:03:09 2000 From: be at et.dtu.dk (Brian Elmegaard) Date: Tue, 28 Mar 2000 11:03:09 +0200 Subject: statvfs? References: <6RDC4.1541$ep.48748@news.siol.net> Message-ID: <38E0754D.C6B3E848@et.dtu.dk> Tomaz Ficko wrote: > > I'm using Python 1.5.2 on Suse Linux 6.3 I've been trying to use the > os.statvfs function, but it looks like I don't have it. I compiled Python > from source. > What I'm missing here. > > Tom I had a similar problem ompiling the twin libraries on hpux. The solution was to use gnu make instead of make. -- Brian Elmegaard (be at et.dtu.dk) http://130.225.70.76/staff/be/be.html Phone +45 4525 4169 Fax +45 4593 0663 Dept. of Energy Engineering, Technical University of Denmark, DK-2800 Lyngby From rod at inf.bme.hu Fri Mar 17 04:57:50 2000 From: rod at inf.bme.hu (Gabor Papp) Date: Fri, 17 Mar 2000 10:57:50 +0100 Subject: Tkinter long menu problem References: <38C90EEF.518EA33F@inf.bme.hu> <20000316114307.A982714@vislab.epa.gov> <38D1129E.9DDCBE37@webamused.com> Message-ID: <38D2019D.11961398@inf.bme.hu> > This is certainly not what either of you is looking for, but I feel > compelled to point out that menus with huge cascades are a terrible user > interface design. You would be doing your users a huge service to spend You are right, but there are some circumstances when you need to use it, for example Netscape bookmarks, the user can have a lot of bookmarks, and the menu must break at the bottom of the screen. Anyway, we figured out the solution. It's option columnbreak, when this option is set to 1 at a menu item, tk breaks the menu. Gabor Papp From effbot at telia.com Fri Mar 10 05:10:23 2000 From: effbot at telia.com (Fredrik Lundh) Date: Fri, 10 Mar 2000 10:10:23 GMT Subject: HELP: restore my faith in Python References: <38C00D46.8CC5BA67@americasm10.nt.com> <38C373C4.3EBB62D8@sightreader.com> <38C7DAFB.D5FE279D@stud.upb.de> <38C8D101.CDA3E07B@sightreader.com> Message-ID: Ken Seehof wrote: > Okay. You are right. Better yet let's make sure floats Never work > correctly. The more they work right, the more people will think they > work right. We should have a special case for 1/2. Obviously, 1/2 > should be 7.392. > Also, there should be a limit on the size of lists of 100 items (beyond > which the program should dump core). If people can have over 100 > items in a list, they might think they can have several trillion, which > would overflow memory. now that's the lamest "I posted a lousy idea and everyone told me it sucked, so now I gotta say something nasty to save my face" post I've seen in a long time... From edcjones at erols.com Mon Mar 27 00:36:23 2000 From: edcjones at erols.com (Edward C. Jones) Date: Mon, 27 Mar 2000 00:36:23 -0500 Subject: locals(): snippets and a question Message-ID: <38DEF357.CA5BC5B7@erols.com> #! /usr/bin/python """ The Python reference Manual, Section 4.1, Footnote 4.2 says: The current implementations [of globals() and locals()] return the dictionary actually used to implement the namespace, except for functions, where the optimizer may cause the local namespace to be implemented differently, and locals() returns a read-only dictionary. """ # When a is set to 7, the dictionary loc is not updated. I don't think the # documentation made any promises about this. def fun1(): loc = locals() a = 7 print loc fun1() # If some operation is done that requires the dictionary returned by # locals(), loc is updated. def fun2(): loc = locals() a = 7 locals() # eval('a') # exec('x = 0') print loc fun2() # Is there anything I can do to keep locals_dict updated from within watch? class watch: def __init__(self, locals_dict): self.locals_dict = locals_dict def fun3(): w = watch(locals()) a = 7 print w.locals_dict fun3() From kragen at dnaco.net Sat Mar 11 12:11:42 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Sat, 11 Mar 2000 17:11:42 GMT Subject: Incorrect error message References: <20000308212531.A5590@nl.linux.org> Message-ID: In article , Fredrik Lundh wrote: >gerrit at nl.linux.org wrote: >> >>> open('/tmp/abcde', 'e') >> Traceback (innermost last): >> File "", line 1, in ? >> IOError: [Errno 22] Invalid argument: '/tmp/abcde' > >in this case, the combination is a bit misleading, but >there's no reasonable way to avoid this. Is it less reasonable to produce a misleading error message or to duplicate fopen's functionality using fdopen? I suppose he who has time to complain has time to submit patches . . . -- Kragen Sitaker The Internet stock bubble didn't burst on 1999-11-08. Hurrah! The power didn't go out on 2000-01-01 either. :) From alan.gauld at gssec.bt.co.uk Thu Mar 2 09:37:56 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Thu, 02 Mar 2000 14:37:56 +0000 Subject: Python and Windows Scripting Host References: Message-ID: <38BE7CC4.5CE67723@gssec.bt.co.uk> Don Tuttle wrote: > I've never used WSH and was wondering if any of you have > ever used Python(PyScript?) with it? Where do I get pyscript - I looked in the winall dist but couldn't see it. My forthcoming book uses Python and WSH(VBScript and JScript) but it would be nice to tie all three languages together in an Appendix or something! > Any advantage over Python & win32all? An easier to use object model for running apps in windows and accessing files, the registry etc. The distributed access to remote printers, network drives in WSH is much easier than using the Win32 API from pythonwin! > Disadvantages? It's slower. Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From kens at sightreader.com Wed Mar 1 04:21:34 2000 From: kens at sightreader.com (Ken Seehof) Date: Wed, 01 Mar 2000 01:21:34 -0800 Subject: win32 IDE References: <38B99B4C.4F26226F@sightreader.com> Message-ID: <38BCE11E.CDB96D4A@sightreader.com> Fredrik Lundh wrote: > Ken Seehof wrote: > > You should join the IDE-SIG, which unfortunately does not yet exist. > > http://www.python.org/sigs/progenv-sig/ > > Yup. That's true. Probably a SIG is a bit premature still (I'll bet it will happen by the end of the year though). Anyway, that -was- two years ago. The amount of IDE work being done has increased substantially, and I'm ready to give it a mailing list a try. I have 18 people so far expressing interest. - Ken Seehof From arnaud at crao.net Tue Mar 7 05:04:44 2000 From: arnaud at crao.net (Arnaud Fontaine) Date: Tue, 07 Mar 2000 11:04:44 +0100 Subject: MPI and/or PVM Message-ID: Hail ! Anyone use PVM or MPI in Python ? I just found a reference to a pypvm module and a few links on the Python Parallelization Project page on Starship but ... nothing more. Regards, Arnaud From hnowak at cuci.nl Sun Mar 5 14:01:33 2000 From: hnowak at cuci.nl (Hans Nowak) Date: Sun, 5 Mar 2000 20:01:33 +0100 Subject: printing problem In-Reply-To: <20000305185551.22418.qmail@web1703.mail.yahoo.com> Message-ID: <200003051902.UAA31530@dionysus.fw.cuci.nl> On 5 Mar 00, at 10:55, sanjay pradeep wrote: > hi this is regarding my previous message, "printing > problem". > the program should print out each character at the > time that the character is entered. right now it > buffers all three characters and prints them out at > once, at the end of the program. > thanks, matt Try sys.stdout.flush() after the print statement. HTH, --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://www.hvision.nl/~ivnowa/newsite/ Python questions? See http://tor.dhs.org/~zephyrfalcon/snippets You call me a masterless man. You are wrong. I am my own master. From kragen at dnaco.net Wed Mar 8 22:58:40 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Thu, 09 Mar 2000 03:58:40 GMT Subject: Self Nanny References: <89r5ru$a5o$1@nnrp1.deja.com> Message-ID: In article <89r5ru$a5o$1 at nnrp1.deja.com>, wrote: >What's this? Assembler or Perl? Not very readable! Why don't you post a cleaned-up version? You could do it in C++ if you like :) -- Kragen Sitaker The Internet stock bubble didn't burst on 1999-11-08. Hurrah! The power didn't go out on 2000-01-01 either. :) From Alessandro.Bottoni at think3.com Wed Mar 15 12:01:23 2000 From: Alessandro.Bottoni at think3.com (Alessandro Bottoni) Date: Wed, 15 Mar 2000 18:01:23 +0100 Subject: Type testing Message-ID: <6D8A17398E28D3119F860090274DD7DB498597@pces.cadlab.it> Is it possible to test for the type of an object (I mean, a built-in object: a digit, a string, etc...)? I'm looking for something like: Result = isDigit(MyVariable) Result = isString(MyVariable) (Result = true | false, 1 | 0) Thanks. -------------------------------- Alessandro Bottoni (Alessandro.Bottoni at Think3.com) (alessandro.bottoni at libero.it) Web Programmer Think3 inc. (www.think3.com) From Lisowski.Tomasz at sssa.nospam.pl Mon Mar 27 00:57:14 2000 From: Lisowski.Tomasz at sssa.nospam.pl (Tomek Lisowski) Date: Mon, 27 Mar 2000 05:57:14 GMT Subject: Odp: Python on Alpha OpenVMS References: Message-ID: <_KCD4.2797$a01.54385@news.tpnet.pl> U?ytkownik Ian Parker w wiadomo?ci do grup dyskusyjnych napisa?:hDlBpKAS7T34Ew1e at gol.com... > In article , Tomek Lisowski > writes > >Hi! > > > >I have tried to compile Python sources on my VAX OpenVMS system, but soon I > >realized, that instead of my trusty DEC C++ compiler I need a native C > >compiler. Unfortunately my C++ compiler cannot be reverted to a native C > >language mode. Has anyone succeeded to create VAX OpenVMS Python binaries? > > > >Note: Apart from VAX OpenVMS I have also an Alpha OpenVMS server, but here I > >don't have any C/C++ compiler available. If anyone has created Alpha OpenVMS > >Python binaries, please contact me too. > > > >Thanks in advance > > > >Tomasz Lisowski > > > > Tomasz > > If you aren't planning changes to the source, why not just download and > link the object modules from: > http://decus.decus.de/~zessin/python/obj.html > > I'm so inspired by this solution, I'm at last downloading them myself. I am just not sure, for which platform were these modules compiled, and for which version of OpenVMS system. I suppose, there could be some differences between the OpenVMS versions. At least you can see them in the source code, where there are some #ifdef and #if directives concerning the OpenVMS version string. Please report, if you succeeded in making your Python running properly, including the platform and OS info. Regards Tomasz Lisowski From tismer at tismer.com Tue Mar 14 08:40:33 2000 From: tismer at tismer.com (Christian Tismer) Date: Tue, 14 Mar 2000 14:40:33 +0100 Subject: Forth like interpreter References: <158801bf8bdc$08516040$6401a8c0@dorb> <38CBFA30.E247C266@tismer.com> Message-ID: <38CE4151.70EF1470@tismer.com> "Samuel A. Falvo II" wrote: > > In article <38CBFA30.E247C266 at tismer.com>, Christian Tismer wrote: > >Well, that's one reason why I said "no Forth, but TIL". > >There is no need for a Forth dictionary to have a threaded > >language. I have Python's dictionaries, why use something else? > > Well, if you were trying to implement Forth, and not a Forth-like language, > Python's dictionaries would need to be ordered by the time the words are > created. This allows such words as "FORGET" (non-standard word, I know, but > is typical of most Forth environments) to be implemented with proper > semantics. Furthermore, Forth allows you to "derive" words. For example: Why do you need to discuss this? I already said that I *am* not building Forth, since I know what the implications are. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From alex at somewhere.round.here Thu Mar 9 12:09:23 2000 From: alex at somewhere.round.here (Alex) Date: 09 Mar 2000 12:09:23 -0500 Subject: Simple question - Numeric Python References: Message-ID: > 1 2 3 > 4 5 6 > 7 8 9 > > How would you enter this? > > Would it be: > 1) array(((1,2,3),(4,5,6),(7,8,9))) or > 2) array(((1,4,7),(2,5,8),(3,6,9))) Perhaps you could try them both in the python shell, and see which one gives you what you want. Alex. From steriana at gvsu.edu Thu Mar 2 23:07:04 2000 From: steriana at gvsu.edu (Andrew Sterian) Date: Thu, 2 Mar 2000 23:07:04 -0500 Subject: Access to _inp()/_outp() on Win95? Message-ID: <38bf3add@news.gvsu.edu> Has anyone exposed the _inp() and _outp() functions under Win95/98 in an extension module? I need to access some I/O ports directly and was hoping to not reinvent the wheel. Thanks, -- Andrew Sterian | Assistant Professor | Padnos School of Engineering | (616) 771-6756 Grand Valley State University | From melgin at my-deja.com Wed Mar 1 04:10:07 2000 From: melgin at my-deja.com (melgin at my-deja.com) Date: Wed, 01 Mar 2000 09:10:07 GMT Subject: CGI and odbc Message-ID: <89impe$9ld$1@nnrp1.deja.com> Hi, I am trying to use odbc in a script to pull data from a database and then publish it to a web page. Although I am able to connect to the database and gather the information, when I try to call the script from a web page an error occurs stating that it cannot import the dbi, odbc module, as if it isn't there. I've also tried using my own scripts within a cgi script and the same error occurs. Does anyone have any ideas as to what this is and what I can do about it???? Many Thanks Matt Elgin Sent via Deja.com http://www.deja.com/ Before you buy. From niels at endea.demon.nl Fri Mar 10 12:21:10 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Fri, 10 Mar 2000 18:21:10 +0100 Subject: Loading a whole HTML document in a SQL 7.0 TEXT field References: <6D8A17398E28D3119F860090274DD7DB498551@pces.cadlab.it> Message-ID: <38C92F05.3E44CDBA@endea.demon.nl> Alessandro Bottoni schreef: > I'm using mxODBC. I put all the HTML document in a string variable with this > instruction: > Blob = SourceFile.read(-1) > And I try to put all this stuff in the "Content" TEXT field of SQL70 DB in > this way: > SQLCommand = 'update ' + OutPutTable + ' set Content=\'' + Blob + '\' where > SolutionNumber=' + SolutionNumber > Cursor.execute(SQLCommand) You would have to be very lucky for Blob not to contain something that is illegal in an SQL string literal. Using an SQL parameter might work better. -- Niels Diepeveen Endea automatisering From nick at spam_me_notvideosystem.co.uk Thu Mar 23 11:56:41 2000 From: nick at spam_me_notvideosystem.co.uk (Nick Trout) Date: Thu, 23 Mar 2000 16:56:41 -0000 Subject: Intranet database Message-ID: <38da4e47@news.xtml.co.uk> Hi, I'm trying to set up an intranet database that can be browsed and edited using forms through HTML etc. I haven't done this before and I'd like to use Python. Please could you advise me how to do this! ie. what would you use to generate forms and manage/query the data? I'm have looking PyApache/Httpdapy, and Zope (although it might be a bit overkill)? Cheers, Nick. From jh at cddk.dk Fri Mar 3 05:34:05 2000 From: jh at cddk.dk (Jesper Hertel) Date: Fri, 3 Mar 2000 11:34:05 +0100 Subject: redirecting output References: <89nbc0$2ng@journal.concentric.net> Message-ID: <89o4ev$bpb$1@news1.tele.dk> Hi Andres, os.popen(command_line) returns a pipe from wich you can read the standard output from the command given by command_line. That is, for example, a = os.popen("dir").read() runs the command "dir" and puts the entire output from the command in the variable a. Another function os.popen2() also returns standard error output from the command, but this does not work in Windows, unfortunately. Jesper Hertel Andres M. Hidalgo wrote in message news:89nbc0$2ng at journal.concentric.net... > How can I run another application(non .py) from within a .py script and > capture its output ala perl way, without saving the other apps. output to a > file. I'am using python in Windows NT/2K > Andres > > From wtopa at dmcom.net Thu Mar 23 12:04:32 2000 From: wtopa at dmcom.net (Wayne Topa) Date: Thu, 23 Mar 2000 12:04:32 -0500 Subject: Jack-pot In-Reply-To: <20000323031047.A31335@novara.avenue>; from jcm@bigskytel.com on Thu, Mar 23, 2000 at 03:10:47AM -0700 References: <20000323031047.A31335@novara.avenue> Message-ID: <20000323120432.C8771@dmcom.net> Subject: Re: Jack-pot Date: Thu, Mar 23, 2000 at 03:10:47AM -0700 In reply to:David Porter Quoting David Porter(jcm at bigskytel.com): >| * Mikael Olofsson : >| > Gosh, what's up? Suddenly I get several copies of each posting to >| > c.l.py. I follow the group through its mailing list. Am I the only >| > one having this problem? >| > >| >| The same thing is happening in my mailbox. >| >| -- >| http://www.python.org/mailman/listinfo/python-list Same here. -- I wish life has a scroll back buffer. _______________________________________________________ From cpr at emsoftware.com Fri Mar 31 16:04:02 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Fri, 31 Mar 2000 21:04:02 GMT Subject: Are newlines sometimes required at end of Python code? References: <38E505D9.61F2AB05@erols.com> Message-ID: <6p8F4.23$CA.1325@news> I'm no language expert, but I think the parser requires an EOL at the end of any compound statement. -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com - - - "Edward C. Jones" wrote in message news:38E505D9.61F2AB05 at erols.com... > Why does this piece of code work: > > s~=~"""for~i~in~range(3):\n~~~~x~=~i\n""" > exec~s > > while this one doesn't: > > s~=~"""for~i~in~range(3):\n~~~~x~=~i""" > exec~s > > I have replaced all the spaces in the code by "~". > > From leenders at quicknet.nl Sat Mar 25 18:32:38 2000 From: leenders at quicknet.nl (Renier Leenders) Date: Sat, 25 Mar 2000 23:32:38 +0000 Subject: zope Message-ID: <38DD4C96.3235AE82@quicknet.nl> hello, my question is not really on topic here, but I don't know where to put it elswhere. i am a newbie on python and zope and i tried to install zope. i used the rpms from Jeff Rush. default, i got the following back: Traceback (innermost last): File "z2.py", line 497, in ? logger_object=lg) does someone how to fix this? From lewst at yahoo.com Tue Mar 14 19:34:57 2000 From: lewst at yahoo.com (lewst) Date: Tue, 14 Mar 2000 16:34:57 -0800 (PST) Subject: using python variables inside quotes Message-ID: <20000315003457.23914.qmail@web2105.mail.yahoo.com> Greetings, This is a simple question, so please excuse, but I am slowly learning Python by trying to rewrite all my Perl scripts. Thus far I like it much better than Perl, but a small matter has me stumped. My question deals with using variables inside quotes. Take this sample program for example: #!/usr/bin/env python import os, random imgdir = "/home/lewst/images/" piclist = os.listdir(imgdir) chosenpic = imgdir + random.choice(piclist) os.system("xv %s &" % chosenpic) This script displays a random image from a directory full of images using the "xv" image manipulation program. Is there a simpler way to access the `chosenpic' variable within the os.system() call? At first I tried the following: os.system("xv chosenpic &") This didn't work, because it is looking for the literal "chosenpic" instead of the name of one of my images. In Perl, I could use the following: system("xv $chosenpic &"); Perl recognizes the `$' as a variable. Since in Python variables are not declared with punctuation marks like this, it is not as easy to distinguish them from regular words. Have I missed something trivial? (Please CC: me on followups) __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com From jeffp at crusoe.net Mon Mar 27 13:04:23 2000 From: jeffp at crusoe.net (Jeff Pinyan) Date: Mon, 27 Mar 2000 18:04:23 GMT Subject: binary to decimal conversion In-Reply-To: <38DF50FA.60ABAA04@pagic.net> References: <8b0r07$r5u$0@216.39.162.232> <38DF50FA.60ABAA04@pagic.net> Message-ID: [posted & mailed] On Mar 27, ezra said: >def Int2Bin(di): > chars = ['0','1'] > do = '' > q = 0 > while di >= 2: > q = di % 2 > do = chars[q] + do > di = di / 2 > do = chars[di] + do > if len(do)%4 >= 1 and len(do)%4 <= 3 : do = '0'*(4 - len(do)%4) + do > return do ># End of def Int2Bin(di) Hmm. >def Int2Oct(di): [snip] >def Int2Hex(di): [snip] Why make these two functions? Python offers a (s)printf like formatting for strings: >>> a = "%o" % 100 >>> a '144' >>> a = "%x" % 100 >>> a '64' They're strings. Do with them what you will. Personally, I think it is monumentally easier to convert an octal number to binary, than a decimal number. Here's my stab at it: def dec2bin (val): val = "%o" % val # we like octal ret = "" for i in range(len(val)): # yes, I'm using index instead of value byte = int(val[i]) bit = 0 # bitwise operations are fun if byte & 1: bit = 1 if byte & 2: bit = 10*bit + 1 if byte & 4: bit = 100*bit + 1 if i != len(val) - 1: bit = "%03d" % bit # this is why I use index else: bit = `bit` ret = bit + ret return ret -- MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve japhy at pobox.com http://www.pobox.com/~japhy/ http://pinyaj.stu.rpi.edu/ PerlMonth - An Online Perl Magazine http://www.perlmonth.com/ The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/ From m.faassen at vet.uu.nl Sat Mar 4 17:47:59 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Mar 2000 22:47:59 GMT Subject: Python advocacy References: <38BEE429.179D4865@prescod.net> <1e6xz1s.uuanez7qwj3oN%bparsia@email.unc.edu> Message-ID: <89s3qv$jdk$1@newshost.accu.uu.nl> Bijan Parsia wrote: [snip] > "Python merges many of Smalltalk's ideas with a syntax that is > more likely to appeal to C, C++ and Java programmers". > I rather suspect it appeals more to Pascal and Modula-2 programmers :) > And poor Dylan, which sold it's soul to mixfix only to be doomed to > obscurity, in the general world, and scorn from its progeniters. I don't know -- I always preferred C and C++ to Pascal (and Object Pascal in Delphi). I don't know Modula-2 or Dylan and only have passing familiarity with Java (the syntax's like C++ anyway). And I like Python's syntax a lot. That's just a single case in point, I may be just weird. :) No-I-*am*-just-weird-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From paul.robinson at quantisci.co.uk Tue Mar 14 08:36:51 2000 From: paul.robinson at quantisci.co.uk (Paul Robinson) Date: Tue, 14 Mar 2000 13:36:51 +0000 Subject: BaseHTTPServer, ThreadingMixIn and COM. Message-ID: <38CE4073.402C47E5@quantisci.co.uk> Is there some inherant problem with using code such as... ExcelApp=win32com.client.Dispatch("Excel.Application") ExcelApp.visible = 0 workbook = ExcelApp.Workbooks.Add() worksheet=workbook.Worksheets.Add() cell = worksheet.Cells(1, 1) val = unquote('=(2+3)*7') cell.Value = val val = cell.Value ExcelApp.DisplayAlerts=0 workbook.Close() ExcelApp.DisplayAlerts=1 ExcelApp.Quit() ...inside the request handler of a server that looks like: from BaseHTTPServer import HTTPServer from SocketServer import ThreadingMixIn class AServer(ThreadingMixIn, HTTPServer): pass The request handler is subclassed from BaseHTTPRequestHandler and I'm simply overriding the do_GET method. When the server does not include the ThreadingMixIn then all is well, but it seems that I'm running into problems opening these Excel objects in threads. I presume that it's my code being thread-un-safe rather than the win32com stuff in general. What precautions should I be taking and/or how can I avoid this problem? The actual error I get is as follows: [Note that it's after one succesful request to the server] D:\Temp\pySERV>python server.py localhost - - [14/Mar/2000 13:33:28] "GET /%3d%282%2b7%29%2a12 HTTP/1.1" 200 - Unhandled exception in thread: Traceback (innermost last): File "C:\PROGRA~1\PYTHON\LIB\SocketServer.py", line 243, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\PROGRA~1\PYTHON\LIB\SocketServer.py", line 366, in __init__ self.handle() File "C:\PROGRA~1\PYTHON\LIB\BaseHTTPServer.py", line 258, in handle method() File "simpleExcel.py", line 10, in behaviourGET ExcelApp=win32com.client.Dispatch("Excel.Application") File "C:\Program Files\Python\win32com\client\__init__.py", line 13, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Program Files\Python\win32com\client\dynamic.py", line 67, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Program Files\Python\win32com\client\dynamic.py", line 58, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221008, 'CoInitialize has not been called.', None, None) [WinNT 4, SP4, Python 1.5.2, PythonWin Build 127] Any help would be appreciated. Paul. ----------------------------------- Business Collaborator Team Enviros Software Solutions http://www.businesscollaborator.com ----------------------------------- From tim_one at email.msn.com Fri Mar 17 01:24:04 2000 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 17 Mar 2000 01:24:04 -0500 Subject: bitsize? In-Reply-To: <38D1380C.3930B66A@math.okstate.edu> Message-ID: <000201bf8fd9$649f4d20$682d153f@tim> [posted & mailed] [David C. Ullrich] > ... > It would be nice if there was a builtin "bitsize" function > returning the number of bits in a long value. (Ie ceil(log_2(n)), > more or less). Yes, it would. I obtained provisional permission from Guido to trying adding this as a method on longs (the function is too specialized to justify polluting the builtins). Never did the work, though. On two previous occasions this came up, two other people volunteered to add this (along with some other methods on longs), but soon after vanished from the face of Python's version of Earth. So the only rational conclusion is that this idea is cursed! I may try it again someday -- but need to locate a reputable exorcist first. > A few bugs (features?) in real.py have got me to doing > a few numeric things using longs. A person really does > need bitsize() to get an appropriate "initial guess" > for lots of algorithms. The bitsize function in real.py is > a magnificent hack, Yes, actually due to Christian Tismer. > but it really shouldn't be needed - Definitely not -- it takes O(log2(N)) time now but should be O(1). This screws up the timing behavior for many long-int algorithms. > something inside Python knows how many bits the long > is taking, and I don't see what harm it could do to expose > this information. It's not like I want the address or anything... Heh heh -- getting the address is easy now. > (Speaking of addresses: Does anyone know a valid one > for Jurjen N.E. Bos, the author of real.py? I have a few that > don't work if you want to trade.) Nope. I had snail-mailed some papers on the constructive reals to him when he was writing real.py, and we corresponded about it over some number of months. Then he vanished! It's a conspiracy all right, but its nefarious goals remain clouded. BTW, Hans Boehm recently (within the last year) ported his version of infinite-precision reals to Java, and that's available somewhere on the SGI web site. "One of these days" I hope to port that to Python. everyone-please-hold-their-breath-ly y'rs - tim From gvwilson at nevex.com Fri Mar 3 17:14:26 2000 From: gvwilson at nevex.com (gvwilson at nevex.com) Date: Fri, 3 Mar 2000 17:14:26 -0500 (EST) Subject: XML DTD for Python source? In-Reply-To: <38C021A2.1CD93631@prescod.net> Message-ID: > Paul Prescod wrote: > > Python is no more "flat" than XML. XML's tree happens to be very > well-hyped. > > I will go this far: Python could use better ways of attaching > structured content to methods, classes and other declared objects. It > seems that structured docstrings will be the mechanism. As long as > there is a single structured docstring syntax (or at least > meta-syntax) I think that that solution is reasonable but you are > right that in a perfect world Python would have anticipated structured > annotations in the beginning (does any language??). Greg Wilson writes: I'm not actually asking for any changes in Python's syntax (or Scheme's, or C's, or...). I'm asking for a change in the way program source is stored on a disk. I earnestly hope that the XML tags in the program source aren't visible, any more than they would be with any other decent WYSIWYG environment. So, once again: I'm interested in exploring what would happen if we (programmers) used the same structured, extensible representation that other people are moving toward, rather than building lots of pre- and post-processing engines to handle less uniform (and certainly less extensible) structured representations of our own. If anyone has already done this, I'd be grateful for pointers. Thanks, Greg From grant at nowhere. Fri Mar 24 11:25:33 2000 From: grant at nowhere. (Grant Edwards) Date: Fri, 24 Mar 2000 16:25:33 GMT Subject: what is easier to learn first?... References: Message-ID: Cameron Laird wrote: > >>I don't know how many painfully boring hours I spent many years >>ago in a numerical analysis class learning ways of finding >>Eigen values and Eigen vectors. Something I never had to do >>before or since. I can only presume that somebody who does > >Just as there are different languages for different >minds ... My own reaction is that computational linear >algebra is so beautiful that rendering it boring should >be a felony. Personally, I see eigenvalues everywhere-- >planting onions, coding HTML, changing flat tires. And possibly so would I had I even known what they were. But I didn't know what they were, just how to find them. There were people in the class who thought it a useful thing to be able to do, so I assumed it was just one of the many holes in my education. >I understand that not everyone shares that perspective. > >Given a bit more leisure, I'm sure I can tie this back >in to the Python-for-education threads. Not this morn- >ing, though. How about: When deciding what language to learn first, it's also important to also decide for what purpose you want to use it, lest you spend all your time learning how to use a hammer only to find yourself confronted with a fast array of sheet metal screws. -- Grant Edwards grante Yow! How's the wife? Is at she at home enjoying visi.com capitalism? From johann at physics.berkeley.edu Wed Mar 22 15:15:42 2000 From: johann at physics.berkeley.edu (Johann Hibschman) Date: 22 Mar 2000 12:15:42 -0800 Subject: stackless, uthreads, and GUIs References: <210320002314402870%pereira@research.att.com> Message-ID: Fernando Pereira writes: > In article , Neel Krishnaswami > wrote: >> >> There is a paper describing precisely this idea called "Escaping the >> Tyranny of the Event Loop: an Alternative Control Structure for >> Multi-threaded GUIs," by Matthew Fuchs. You can find it at >> >> http://www.cs.nyu.edu/phd_students/fuchs/ On a quick overview, that paper looks like fun. Thanks for the reference. I'm reading it now. >> You may also be interested in reading about Fudgets, a purely >> functional GUI toolkit for Haskell. This one is a bit mind-blowing, >> though: >> >> http://www.cs.chalmers.se/ComputingScience/Research/Functional/Fudgets/ I looked at it briefly, but I've never really worked with Haskell, so I've put it on the back burner. > A related, earlier, and simpler idea, based on ideas from CSP and > Esterel is Cardelli & Pike's "Squeak: a language for communicating with > mice", Proc. Twelfth ACM Annual Conference on Computer Graphics and > Interactive Techniques (SIGGRAPH), 1985, > . It might > be a cool exercise to create a uthreads implementation of these ideas. That also seems fun; I've heard many things of Squeak, but I haven't read the paper before. Alas, if I keep playing with everyone else's thesis research, I'll never get my own done. A pox upon over-specialization! -- Johann Hibschman johann at physics.berkeley.edu From kelley at bioreason.com Wed Mar 29 12:01:11 2000 From: kelley at bioreason.com (Brian Kelley) Date: Wed, 29 Mar 2000 18:01:11 +0100 Subject: Python and Wavelets References: <38E22D8D.DE42621A@wag.caltech.edu> <38E261DF.16D989F5@t-online.de> Message-ID: <38E236D7.DA93B3E5@bioreason.com> Ralf Muschall wrote: > Richard P. Muller wrote: > > > I am thinking of putting together a python module to handle wavelets. I > > This would be nice, expecially if it would be a module that somehow > works with NumPy objects (people who want wavelets will probably > have installed NumPy anyway). > > Ralf There are some good starting points so you might not have to reinvent the wheel. One of the best (and free) packages that I have used is called WaveLib from INRIA which is a C library for doing wavelet transforms. Unfortunately, you have to e-mail them to get permission and the location of the source code! (bourges at int-evry.fr) A comprehensize but slightly outdated list of wavelet packages is available here: http://www.eee.metu.edu.tr/~ngencer/amara.htm Good luck! -- Brian Kelley (505) 982-7884 ext 207 Bioreason, Inc kelley at bioreason.com 105 Washington #303, Santa Fe NM, 87501 From wware at world.std.com Mon Mar 13 08:51:56 2000 From: wware at world.std.com (Will Ware) Date: Mon, 13 Mar 2000 13:51:56 GMT Subject: Stackless/microthreads merge news References: Message-ID: Konrad Hinsen (hinsen at cnrs-orleans.fr) wrote: > Do I understand correctly that microthreads are handled completely in > the Python interpreter, with no OS support at all? In that case, > there is no way to profit from multiple processors, or even to let > other threads continue when one is waiting for I/O etc. The kind of thing you're looking for would involve interrupting the physical processor rather than the Python VM. Unfortunately, all your conjectures about the unsuitability of microthreads for your application are, to the best of my knowledge, accurate. If you had a big thoroughly optimized Fortran routine, you're right, you'd need to insert task switch calls, which wouldn't be any fun. Sorry the manual didn't make this clearer. I had intended microthreads to be useful for behavioral simulators where performance wasn't terribly critical. It's my understanding that Python's support for OS threads is quite good, but you probably already know a lot more about that than I do. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From kern at caltech.edu Sat Mar 25 04:44:01 2000 From: kern at caltech.edu (Robert Kern) Date: 25 Mar 2000 09:44:01 GMT Subject: CallDLL/WinDLL vs Python Wrapper Extension (Win32) References: Message-ID: <8bi1p1$j5u@gap.cco.caltech.edu> In article , Tom Funk <_spam_sux_tdfunk at _spam_sux_nettally.com> writes: [snip] > I've just started reading the Embedding/Extending Python docs. I've > downloaded four chapters of SWIG. I think SWIG is probably overkill > since I get the first impression that it's designed to wrap C/C++ source, > not header files alone. Actually, you usually run SWIG over a header file or a marked up version of it. > I've also looked at some of the docs and > examples that come with Sam Rushing's DynWin module that use calldll, > gencb and windll. > > I'm trying to decide the best approach to take. > > The API consists of 53 #defines (mostly numeric constants), 2 enums, 7 > typedef'd structs, and 24 function calls. Of the 6 required callback, > all take a struct as an argument. FWIW, see Chapter 9 of the SWIG User's Manual about the callbacks. > I don't want to expose the end user to the (ugly) API directly, rather I > want to python-ize it. i.e., create a Library class that exposes the > source code as a dictionary or list. Provide an Application class that > wraps a group of libraries and exposes the libraries as a collection > (dictionary or list). Move, copy and compile functions would become > methods of a library rather than distinct function calls. Things like > this. With SWIG, you would expose the pure API and write a Python wrapper around it. The wrapper is generally pretty easy with SWIG's shadow classes to work with. > So, any takers? Does anyone have any feedback on what might be a > preferred approach? SWIG will probably get you up and running really fast. You can work out the API you want to expose pretty quickly. However, I haven't used windll, so I can't offer a comparison. -- Robert Kern kern at caltech.edu "In the fields of hell where the grass grows high Are the graves of dreams allowed to die." -- Richard Harter From gerrit at nl.linux.org Wed Mar 1 09:10:34 2000 From: gerrit at nl.linux.org (Gerrit Holl) Date: Wed, 1 Mar 2000 15:10:34 +0100 Subject: Splitting comp.lang.python In-Reply-To: ; from mikael@isy.liu.se on Wed, Mar 01, 2000 at 02:44:46PM +0100 References: <20000301135248.B1411@nl.linux.org> Message-ID: <20000301151034.A4873@nl.linux.org> > > On 01-Mar-00 Gerrit Holl wrote: > > Python language + builtin functions <-> Python modules + extensions > c.l.py.pure c.l.py.modules > > That could be a fairly clear division. I'm not trying to dissapoint you, > but I think that some people would say that many of the modules should > be considered as a fundamental part of the language, e.g. sys, string, > and others. I can imagine a newbie asking in c.l.py.pure: > > How do I do string conversion in Python? > > The dissapointing answer would be: > > Good question, ask at c.l.py.modules! Hmm, maybe you are right. > Perhaps the best thing would be to keep c.l.py as it is as the general > place for discussion, and then adding subgroups for specific interests. Perl uses: comp.lang.perl.announce comp.lang.perl.misc comp.lang.perl.tk comp.lang.perl.modules comp.lang.perl comp.lang.perl.moderated Maybe it's a good idea too do something like that on c.l.py. regards, Gerrit. -- -----BEGIN GEEK CODE BLOCK----- http://www.geekcode.com Version: 3.12 GCS dpu s-:-- a14 C++++>$ UL++ P--- L+++ E--- W++ N o? K? w--- !O !M !V PS+ PE? Y? PGP-- t- 5? X? R- tv- b+(++) DI D+ G++ !e !r !y -----END GEEK CODE BLOCK----- From aa8vb at yahoo.com Tue Mar 28 08:41:45 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 28 Mar 2000 08:41:45 -0500 Subject: tracebacks - How to add frames?? Message-ID: <20000328084145.A776274@vislab.epa.gov> Is it possible to add frames to the current traceback object from inside a C extension? I have Python calling C making callbacks to Python, and I'm missing the middle layer in tracebacks. Tim Peters summarizes it nicely: | If A calls B tails calls C tail calls D blows up, I damn sure don't | want a traceback claiming that A called D directly. I want to get a | traceback object with the full chain intact Thanks, -- Randall Hopper aa8vb at yahoo.com From effbot at telia.com Thu Mar 9 12:27:42 2000 From: effbot at telia.com (Fredrik Lundh) Date: Thu, 09 Mar 2000 17:27:42 GMT Subject: function jumptable idiom References: <200003091627.LAA22884@smtp1.andrew.cmu.edu> Message-ID: Brian E Gallew wrote: Content-Type: multipart/signed; protocol="application/pgp-signature"; boundary="pgp-sign-Multipart_Thu_Mar__9_11:27:24_2000-1"; micalg=pgp-md5 (now that's a great way to make sure your messages don't show up in some agents. maybe you didn't want the bots to see your post? ;-) > I'm building a program with an interactive loop in it, along with a > trivial parser. What I'm doing is this: > cmd = command_list[words[0]] > cmd(words[1:]) > However, that means that all of the functions in the jumptable have to > assume that they will always get one argument (a list). Is there a > more natural way to express this? maybe you could use apply? cmd = command_list[words[0]] apply(cmd, tuple(words[1:])) (don't forget to add try-except to make sure your program doesn't stop if user forgets an argument or two...) alternatively, you can use the cmd module: http://www.python.org/doc/current/lib/module-cmd.html here's an example (from the eff-bot guide; see below for more info): # # cmd-example-1.py import cmd import string, sys class CLI(cmd.Cmd): def __init__(self): cmd.Cmd.__init__(self) self.prompt = '> ' def do_hello(self, arg): print "hello again", arg, "!" def help_hello(self): print "syntax: hello [message]", print "-- prints a hello message" def do_quit(self, arg): sys.exit(1) def help_quit(self): print "syntax: quit", print "-- terminates the application" # shortcuts do_q = do_quit # # try it out cli = CLI() cli.cmdloop() # end and here's some output: > help Documented commands (type help ): ======================================== hello quit Undocumented commands: ====================== help q > hello world hello again world ! > q hope this helps! From tismer at tismer.com Sun Mar 12 15:52:57 2000 From: tismer at tismer.com (Christian Tismer) Date: Sun, 12 Mar 2000 21:52:57 +0100 Subject: Forth like interpreter References: <158801bf8bdc$08516040$6401a8c0@dorb> Message-ID: <38CC03A9.6461C7D6@tismer.com> Darrell wrote: > > "Samuel A. Falvo II wrote: > > For a detailed reason as to why this is/was, feel free to ask the > > question in comp.lang.forth. > > > Went looking and found my self linked back to Python. > http://starship.skyport.net/crew/vlad/archive/threaded_code/ Well, I looked into this technique a while before. It may help for some compilers. On Windows with MSVC, the main switch translates to ; 1115 : f->f_next_instr = next_instr; ; 1116 : f->f_stackpointer = stack_pointer; ; 1117 : ; 1118 : /* Main switch on opcode */ ; 1119 : ; 1120 : switch (opcode) { lea eax, DWORD PTR [ebx+7] mov DWORD PTR [ebp+320], edi cmp eax, 140 ; 0000008cH mov DWORD PTR [ebp+324], esi ja $L4460 xor edx, edx mov dl, BYTE PTR $L6154[eax] jmp DWORD PTR $L6155[edx*4] The first two mov's are necessary for stackless and just pipelined in. The real "overhead" is the check on default (cmp eax, 140) and in the double lookup. The "mov dl" maps to an index into the address table. It may count for Forth, but for Python this is very fast. Note the "ebx+7" in the beginning. That's because I added a few extra opcodes for error handling, which are negative. The savings were great: Error variables have so short lifetime that they never occupy registers. ciao - chris (well this is nothing for C.L.P. I guess) -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From tim_one at email.msn.com Mon Mar 6 23:13:14 2000 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 6 Mar 2000 23:13:14 -0500 Subject: 11-digit integer literal on a 32-bit CPU In-Reply-To: <0003061647130K.03962@quadra.teleo.net> Message-ID: <000901bf87eb$75748ca0$2b2d153f@tim> [posted & mailed] [Patrick Phalen] > I need to assign an 11-digit Transaction ID, according to specs I'm > given by a client. > > Begin with 10000000000 > > Increment by 1 for each new transaction -- 10000000001, etc. > > (Store as string in a file between transactions) > > As an integer literal, this overflows on an Intel CPU. > > What's a nice trick for dealing with this? > > Total transactions aren't likely to exceed 999,999 [and later] > Oh. I should add that the ID needs to be included in a delimited > text data file, so 10000000000L doesn't work. >>> id = long("10000000000") >>> id = id + 1 >>> str(id) '10000000001L' >>> str(id)[:-1] '10000000001' >>> That is, converting strings to and from longs is easy. You just have to strip the trailing "L" on output. Note that this is changing in 1.6, though (i.e., the trailing "L" is going away via str(), but staying via repr()). don't-let-one-character-drive-you-from-the-obvious-approach-ly y'rs - tim From roger.burnham at gte.net Wed Mar 8 18:30:35 2000 From: roger.burnham at gte.net (Roger Burnham) Date: Wed, 08 Mar 2000 23:30:35 GMT Subject: Odd COM problems with VC References: <8a6cq6$421$1@nnrp1.deja.com> <38c6c7b4.12989015@news.gte.net> Message-ID: <38c6e05c.19301409@news.gte.net> On Wed, 08 Mar 2000 21:43:00 GMT, roger.burnham at gte.net (Roger Burnham) wrote: >Jim, > >I have a script to automate building all my projects: Sorry 'bout that, I cut and pasted too quickly from different program versions. The projects dictionary for the version I posted should look like: projects = { '01 C:\DevSrc\Python\Python-1.5.2\PCbuild\pcbuild.dsw': ('python15', 'python', 'pythonw'), '02 C:\DevSrc\Python\Python-1.5.2\Exts\Python and Extensions.dsw': ('win32ui', 'win32api', 'timer', 'pythonwin',), } to allow specifying the order things are built. Cheers, Roger Burnham Cambridge Research & Instrumentation rburnham at cri-inc.com http://www.cri-inc.com/ http://starship.python.net/crew/roger/ PGP Key: http://www.nai.com/default_pgp.asp PGP Fingerprint: 5372 729A 9557 5F36 177F 084A 6C64 BE27 0BC4 CF2D From Boris.Ottlewski at NOSPAMsystemsoft.de Mon Mar 20 09:54:05 2000 From: Boris.Ottlewski at NOSPAMsystemsoft.de (Boris Ottlewski) Date: Mon, 20 Mar 2000 15:54:05 +0100 Subject: Python drives me mad... Message-ID: <38d63af7$0$29755@businessnews.de.uu.net> Last attempt to get the result from python in embedded mode. (I am about to quit...) I do this: FILE *stream; char temp[8192]; new_stdout = PyFile_FromString("c:\\freopen.out", "w"); PySys_SetObject("stdout", new_stdout); file://PySys_SetObject("stderr", new_stdout); int res = PyRun_SimpleString("print 2\n"); Py_XDECREF(new_stdout); This should print the "2" to the redirected stdout which is c:\freopen.out. But the file is empty!!!!!!!!!! and...I cant delete it, it is still locked (shouldnt Py_XDECREF close it?) bye, Boris Ottlewski From tiddlerdeja at my-deja.com Tue Mar 14 11:06:19 2000 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Tue, 14 Mar 2000 16:06:19 GMT Subject: read NT registry with python Message-ID: <8alo1n$tdc$1@nnrp1.deja.com> Does anyone know of any windows extensions to read values from the NT registry with Python? Writing to the registry would also be a bonus! Any help really appreciated. Sent via Deja.com http://www.deja.com/ Before you buy. From mlauer at trollinger-fe.rz.uni-frankfurt.de Fri Mar 31 05:27:27 2000 From: mlauer at trollinger-fe.rz.uni-frankfurt.de (mlauer at trollinger-fe.rz.uni-frankfurt.de) Date: 31 Mar 2000 12:27:27 +0200 Subject: Advice requested: GUI project beginning References: <8c0dpv$djc$1@nntp6.u.washington.edu> <38e3fa10.298739985@news.mr.net> <5mXE4.9512$lX4.216839@paloalto-snr1.gtei.net> Message-ID: <38e47d8f@nntp.server.uni-frankfurt.de> Brian (nospam at noreply.com) wrote: > > >- Tkinter is flaky on the Mac. For instance it doesn't run in the IDL > > >and it doesn't fully quit. > > > > Ain't cross-platform GUI a bitch? > So when is Python going to have a GUI library as tightly bound with it as Tk > is to Tcl and Swing/AWT is to Java? Is wxWindows heading in that direction? If you have patience and don't need it _now_, there seems to be two alternatives in the future. Qt right now runs on Win (although it's commercial and __expensive__) and Linux, Gtk right now runs on *nix, BeOS and Windows- ports are in production. The Gnome/GTK bindings for python are excellent, don't know about the KDE/Qt bindings though. I think either one of them or both will become the next generations standard GUI for (and not only ) Python RAD apps... now if I have said before, they need to grow a bit. -- -- Regards & Gruesse from Mickey @ http://www.Vanille.de --------------------------------------------------------- How could anyone know me - when I don't even know myself ? From effbot at telia.com Tue Mar 7 00:44:28 2000 From: effbot at telia.com (Fredrik Lundh) Date: Tue, 07 Mar 2000 05:44:28 GMT Subject: uploading a binary file with ftplib References: <8a2022$ttd$1@nnrp1.deja.com> Message-ID: <0H0x4.465$74.8773@newsc.telia.net> thehaas at my-deja.com wrote: > I've submitted this to python.faqts.com, but no one has answered. So > I'm asking it here. . . > > I'm trying to upload a binary file to a site using ftplib. I can log in > successfully and do "cd dir_name", but cannot figure out how to upload > the file. The standard Python module documentation seems a bit cryptic > to me in this case (though it is usually quite good). well, the docs clearly tell you to pass a file object as the second argument, not a string. so does the doc string... > ftp.storbinary('stor ravine.pyc',open('ravine.pyc','r').read(),2) ftp.storbinary('stor ravine.pyc', open('ravine.pyc','r'), 1024) From cpr at emsoftware.com Fri Mar 31 21:37:42 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Sat, 01 Apr 2000 02:37:42 GMT Subject: parsing CSV files with quotes References: <009f01bf9a6f$f6f8a180$74eb0b18@stcla1.sfba.home.com> <38E4C603.7459B4B5@easystreet.com> <38E51E8B.4AD79567@easystreet.com> Message-ID: There is no standard other than what works with the largest variety of programs. It's sad that such a trivial issue is often thorny w.r.t. interoperability. (Of course, Microsoft's applications are the worst offenders in terms of randomness.) -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com "Al Christians" wrote in message news:38E51E8B.4AD79567 at easystreet.com... > Chris Ryland wrote: > > > > > > Doubled quotes are *supposed* to work. Why not try putting some double > > quotes in a cell and exporting with Excel to see how they're quoted? > > Yes, they do work in Excel, now that I go back and refresh my > recollection by testing again. But doubled quotes within a string > don't work in Star Office, however. (FWIW, Quattro doesn't do CSV's.) > > So what to you mean by "*supposed*"?? Is there any kind of ISO, BSI, or > ANSI standard for CSV files? I vaguely recall that the unix sort > program falls under the posix standard, and that it is suppoed to sort > records of delimited fields. Can anyone quote the law on this stuff? > > TIA > > > Al From mlh at idi.ntnu.no Sun Mar 5 08:56:43 2000 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 5 Mar 2000 14:56:43 +0100 Subject: import idea References: Message-ID: <89tp37$pk0$1@kopp.stud.ntnu.no> This is something we talked about a while back during a discussion about "Python vs Perl", where powerful one-liners were seen as a strength of Perl... Having the import implicit would make them easier in Python too... I seen to remember advocating a switch for this... I.e. if you run Python with the implicit import switch, it would somehow ("magically") find modules itself... I'm not sure how useful it would be, though... -- Magnus Lie Hetland magnus @ hetland . org Joel Lucsy wrote in message news:zVAv4.4321$ik6.612742 at news4.usenetserver.com... > Is it possible to not have to explicitly do imports? Such as: > fl=glob.glob('*') > without the: > import glob > Is there a __getattr__ for globals that could trap the glob not being > present, see if it could import it, etc....? > Just wondering, I have no current need. Nor do I think it should be a > standard. Just something that an individual could cook up for his system to > really bash out scripts in record time. > > -- > - Joel Lucsy (jjlucsy at concentric.net) > > > > > From matheusrodrigues at hotmail.com Thu Mar 30 14:45:08 2000 From: matheusrodrigues at hotmail.com (Matheus Rodrigues) Date: Thu, 30 Mar 2000 19:45:08 GMT Subject: Python x ibook (Mac) Message-ID: <20000330194508.2655.qmail@hotmail.com> >At 6:48 PM +0000 30-03-2000, Matheus Rodrigues wrote: > >Is there anyone here that could tell me what are the Python features that >I > >will not have in a ibook (notebook from apple) ? > >What are my limits once I try to run Python on this machine ? Just van Rossum wrote: >The same as on any other Mac I presume... Mainly: no threading (yet), no >forking. Does it mean that IDLE and the Tkinter extensions work fine too ? You said "no threading (yet)". Is there anyone working on that ? Matheus ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From bjorn at roguewave.com Fri Mar 31 20:25:41 2000 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Fri, 31 Mar 2000 18:25:41 -0700 Subject: Python 1.6 alpha 1 released References: <00033115131700.03666@quadra.teleo.net> Message-ID: <38E55015.3907B68A@roguewave.com> Patrick Phalen wrote: [bobbage] > > Well, these two posts have scratching my head. What sort of > environment are you two (Vladimir & Bjorn) working in that makes it > seem so onerous to fix your sock.connect() syntax (considering that > you literally have months to prepare for it)? [more bobbage] Some of us have jobs that doesn't involve administering servers, and fixing things when they break, but rather working on getting the next release of the software we can charge for out the door. The more time I spend on fixing compatibility issues in Python scripts, the less time I spend on "real" work. As for my environment, I'm working in a heterogenous, and occationally discrete network, and on a daily basis I'm probably running Python on more than five major platforms. I'm also not a system administrator (nor do I want to be), so even the process of finding all disk based versions of scripts is non-trivial (not to mention automatically generated python code, python code for dormant products in source code control systems etc. etc.) Switching over without some guarantee that we wouldn't have major downtime would be irresponsible, and currently the benefits of 1.6 is not great enough to warrant planning and implementing such a move. -b From scarblac-spamtrap at pino.selwerd.nl Wed Mar 15 09:10:47 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 15 Mar 2000 14:10:47 GMT Subject: lambda without vars? References: <8ao4lv$jss$1@nnrp1.deja.com> Message-ID: moonseeker at my-deja.com wrote in comp.lang.python: > Can't I use variables in a lambda definition? > > i.e.: > > xList = [5, 10, 20, 35, 55] > y = 50 > a = filter (lambda x: x I've now visited and read the information on both Stackless Python and Microthreads, and I must say they both seem like excellent features. Has any thought been given to making the generic Python use the Stackless implementation? It seems that if the stackless implementation is binary-compatible with "regular" Python, there shouldn't be too much of a problem. But are there other issues I haven't seen addressed in this forum? At any rate, both of these projects seem to have produced some excellent tools. I look forward to playing with the microthread implementation in particular. :-) Thanks, -Brent From tismer at tismer.com Fri Mar 10 11:38:32 2000 From: tismer at tismer.com (Christian Tismer) Date: Fri, 10 Mar 2000 17:38:32 +0100 Subject: Stackless/microthreads merge news References: Message-ID: <38C92508.DC1013B@tismer.com> Will Ware wrote: > > Chris Tismer and I expect to release microthreads running on > Stackless Python very soon. At this point things appear stable > enough that we can release a user's manual, available at > http://world.std.com/~wware/utdoc.html I would like to point out that the whole text and most of the microthread library is Will's creation. Most of the credits must go to him! My part is the dirt work of hacking the C code to enable microthreads via continuations. Thanks to Will for making the microthreads into a Stackless Python application. cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net 14163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From embed at geocities.com Mon Mar 27 16:40:42 2000 From: embed at geocities.com (Warren Postma) Date: Mon, 27 Mar 2000 16:40:42 -0500 Subject: Request for Python 1.6 or higher: catch infinite recursion before Windows does! Message-ID: > > I betcha Stackless doesn't have this problem.... Hmm. Where are Stackless > binaries for Windows!? I'm gonna go find them, finally... > Hmm. DLL is 4k smaller, IDLE still runs, and my infinite recursion routine leads to a much friendlier end: RuntimeError: Maximum recursion depth exceeded Way to go Christian Tismer! I'm a believer! :-) Interesting detail: Takes IDLE a few MINUTES to dump the traceback for about 10000 lines of traceback information. Maybe tracebacks should be limitd to a maximum of 10 levels, or should print "..." wherever a loop in recursion is detected. Sample of IDLE output: Python 1.5.42 (#0, Jan 31 2000, 14:05:14) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam IDLE 0.5 -- press F1 for help >>> def foobar(X): return X*foobar(5) >>> foobar(5) Traceback (innermost last): File "", line 1, in ? foobar(5) File "", line 2, in foobar return X*foobar(5) File "", line 2, in foobar return X*foobar(5) [9980 lines deleted here!] RuntimeError: Maximum recursion depth exceeded >>> Warren From sjoerd at oratrix.nl Tue Mar 7 09:49:38 2000 From: sjoerd at oratrix.nl (Sjoerd Mullender) Date: Tue, 07 Mar 2000 15:49:38 +0100 Subject: uploading a binary file with ftplib In-Reply-To: Your message of Tue, 07 Mar 2000 05:44:28 +0000. <0H0x4.465$74.8773@newsc.telia.net> References: <8a2022$ttd$1@nnrp1.deja.com> <0H0x4.465$74.8773@newsc.telia.net> Message-ID: <20000307144939.4735F301CF9@bireme.oratrix.nl> On Tue, Mar 7 2000 "Fredrik Lundh" wrote: > thehaas at my-deja.com wrote: > > I've submitted this to python.faqts.com, but no one has answered. So > > I'm asking it here. . . > > > > I'm trying to upload a binary file to a site using ftplib. I can log in > > successfully and do "cd dir_name", but cannot figure out how to upload > > the file. The standard Python module documentation seems a bit cryptic > > to me in this case (though it is usually quite good). > > well, the docs clearly tell you to pass a file object as the > second argument, not a string. so does the doc string... > > > ftp.storbinary('stor ravine.pyc',open('ravine.pyc','r').read(),2) > > ftp.storbinary('stor ravine.pyc', open('ravine.pyc','r'), 1024) Shouldn't that be ...open('ravine.pyc','rb')... (note the b). We are talking uploading a *binary* file here... -- Sjoerd Mullender From tbryan at python.net Sun Mar 12 05:11:06 2000 From: tbryan at python.net (Thomas A. Bryan) Date: Sun, 12 Mar 2000 05:11:06 -0500 Subject: Newbie: req for a bit of tutorial type help. References: <38cba29f$0$1326@motown.iinet.net.au> Message-ID: <38CB6D3A.F719AB54@python.net> Aesop wrote: > What i need is something that will perform divisions of the > prospective prime number, and report whether there is any "remainder". I.E > the modulus operator of C. Python's not like C. Just fire up the interpreter and *try* it. :) >>> 15 % 2 1 >>> 15 % 4 3 >>> 15 % 3 0 So for x and y where type(x) and type(y) are and where y is nonzero, ( y * ( x / y ) + x % y ) == x always returns true. ---Tom From aa8vb at yahoo.com Wed Mar 8 17:58:30 2000 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 8 Mar 2000 17:58:30 -0500 Subject: Tkinter: OptionMenu question Message-ID: <20000308175830.A28302@vislab.epa.gov> How do you set the font? This: menu = apply( OptionMenu, ( parent, var ) + tuple( option_names ), { 'font':PANEL_FONT } ) generates: TypeError: unexpected keyword argument: font -- Randall Hopper aa8vb at yahoo.com From effbot at telia.com Tue Mar 28 19:42:21 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 29 Mar 2000 00:42:21 GMT Subject: regular expressions questions References: <11A17AA2B9EAD111BCEA00A0C9B4179305321B0A@molach.origin.ea.com> <38D6DDAA.F69F3BEC@ooc.com.au> <3d3dpiejnj.fsf@amarok.cnri.reston.va.us> <38DEA7A9.CB1C324F@ooc.com.au> <3d66u8y0rw.fsf@amarok.cnri.reston.va.us> Message-ID: Neel Krishnaswami wrote: > I think that Greg Ewing has the right idea with Plex; strings should > be for strings, not for encoding a regular expression in. regular expression engines are cool things. regular expression syntaxes suck. > We have a perfectly good language -- Python -- for expressing data > structures in. Trying to encode regexps in a seperate sublanguage will > just grow escape sequences without bound, because the set of characters > that can be part of a string overlaps with the characters that denote regexp > info. > > x = Str("[foo]", "(bar)") > > is simpler than the crazy nest of quoting that is > > x = re.compile(r"(\[foo\])|(\(bar\))") > > and it gets relatively simpler as the complexity of the regexp goes > up. Ping came up with something called rxb which implements a pythonish syntax on top of 'regex' (and soon 're'): digit + some(whitespace) + exactly(':)') you can find the code over at: http://www.lfw.org/python/ implementing this (or something very similar) on top of the 'sre' engine is on my todo list. but I suppose getting a 'sre' version ready for the first 1.6 alpha has a slightly higher priority :-) From bparsia at email.unc.edu Sun Mar 5 11:51:01 2000 From: bparsia at email.unc.edu (Bijan Parsia) Date: Sun, 5 Mar 2000 11:51:01 -0500 Subject: Python advocacy References: <38BEE429.179D4865@prescod.net> <1e6xz1s.uuanez7qwj3oN%bparsia@email.unc.edu> <00030415261707.02808@quadra.teleo.net> Message-ID: <1e6zgzc.1xl2pys8ogaalN%bparsia@email.unc.edu> Patrick Phalen wrote: > [Neel Krishnaswami, on Sat, 04 Mar 2000] > :: Quinn Dunkan wrote: > :: > On Sat, 4 Mar 2000 00:37:06 -0500, Bijan Parsia > :: > wrote: > :: > >And poor Dylan, which sold it's soul to mixfix only to be doomed to > :: > >obscurity, in the general world, and scorn from its progeniters. > :: > :: > Guess it would help if I knew what mixfix was... > :: > :: Not really; he just means Algolish (Algolic? Algolaceous?) syntax, > > I think he's referring to Dylan Thomas, who was a hopeless Algolholic > and cooC addict, who was known to mix his fixes. This is about the funniest, cleverest thing I've read in at least a week. I was dying! (To add some content: My Dylan "slam" was a joke. Dylan started out with a Lispy syntax (and if you want a Lispy Dylanish thing, try RScheme) but then converted to a Pascalish one as a marketing move akin to how Paul described Python in relation to Smalltalk (and if you can parse *that*, you'll have no trouble with mere Dylan syntax ;)). Thereupon, a slew of Lispy Dylan folks cried "Herasy herasy" and went back to mucking with Common Lisp :) Dylan seems to have survived Harliquin's sale, although it's still a bit too soon to tell. Apple's dumping of it, however, did kill it's best shot at a building a substantial constituacy it's had, and, as far as I can see, will have for quite a while. However, it's a pretty darn nifty langauge, and I rather suspect that most Pythoners might find it a bit more congenial than Common Lisp.) Cheers, Bijan Parsia. From effbot at telia.com Wed Mar 1 02:01:35 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 01 Mar 2000 07:01:35 GMT Subject: will python 3000 break my code? References: <87tkoi$hql$1@nntp1.atl.mindspring.net> <08Zu4.6976$3z.60274@newscontent-01.sprint.ca> Message-ID: Alex wrote: > > > I wouldn't worry about that. You won't have to throw or rewrite old > > code, unless you want to take advantage of features in Python 3000. > > It wouldn't suprise me if some rewriting were needed. For instance, > Guido said that he will be changing the list.append method so that > l.append(1,2) gives a syntax error. note it will give a TypeError at run time, not a SyntaxError. make sure you run checkappend.py over and over again... From pnpayne at swissonline.ch Tue Mar 21 16:09:29 2000 From: pnpayne at swissonline.ch (pnpayne at swissonline.ch) Date: Tue, 21 Mar 2000 22:09:29 +0100 Subject: Load a module twice ... or not ??? References: <1258456323-36354740@hypernet.com> Message-ID: <38D7E509.71124F30@swissonline.ch> Gordon McMillan wrote: > Philip Payne writes: > > > Can anyone by any chance give me a definitive explanation to the > > following (Python 1.5.2). > > > > In the book 'Internet Programming with Python', by Watters, van Rossum > > and Ahlstrom, in the section 'How to Load a Module Twice, and Why You > > Shouldn't', on page 199/200 (my edition, anyway), it states that you > > shouldn't have module interrelationships that result in a module > > running as a main program and also being imported by another module in > > the same interpreter. > > Here's the simple example: > --module A > import B > a = 1 > if __name__ == '__main__': > global a > a = 2 > B.doit() > --module B > import A > def doit(): > print A.a > --------- > If you run A, it will print "1". Gordon, the example may be simple but with global variables you are really having to try quite hard. I don't write code that does anything like this. All I do is have a module A.py that might be: def f1(): ... def f2(): ... class C1: ... def main(): c = C1() c.GO() if __name__ == '__main__' : main() that runs as a main program in the PyApache-embedded interpreter. Then I have another module B.py that imports A just in order to use the function f1() defined there. B.py might be: import A def f3(): ... class C2: ... includes references to A.f1() ... def main(): c = C2() c.GO() B also runs as a main program in the same interpreter 'session' as A did, since I don't kill the interpreter between Apache requests, but I really don't see why I should have any problems. All the examples I've seen so far involve global variables in one form or another. I don't use global variables except for performance reasons to cache database data between Apache requests and these globals are only set once. What mystified me in WvRA's book was the references to classes being defined twice. I mean, so what if they are??? > > > > Since I don't, in practice, encounter any problems doing what WvRA say I > > shouldn't do, is this in fact an issue? Is the above quote relevant to > > current Python versions?? And if so, can someone tell me in detail under > > what circumstances there might be a problem? > > Yes (you're lucky); yes; see above. > > - Gordon From loewis at informatik.hu-berlin.de Tue Mar 28 13:37:52 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 28 Mar 2000 20:37:52 +0200 Subject: Where to read about 1.5.2+ References: Message-ID: Alex writes: > Hi. I have just set things up so that I can use the python CVS > snapshots on a regular basis. Is there a list of user-visible > changes to it that I could read somewhere? Not a short form, AFAIK, at least not yet. You can do 'cvs log' on individual files, though... Regards, Martin From ralph at inputplus.demon.co.uk Mon Mar 27 14:50:44 2000 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 27 Mar 2000 20:50:44 +0100 Subject: else clauses in while and for loops References: <38DD2EE3.C7F3CB54@webamused.com> Message-ID: <8boe2k$gmh$1@inputplus.demon.co.uk> > > Please give some examples showing the real need for else clauses in > > this context. > > def lookup(stringList, word): > """Finds the first instance of word in stringList. Returns -1 if not > found""" > i = 0 > while i < len(stringList): > if stringList[i] == word: > break > i = i + 1 > else: > # is only executed if we never hit that break > return -1 > return i I don't think that is a real need. Wouldn't it normally be written to return ASAP rather than jump through hoops. def lookup(stringList, word): i = 0 while i < len(stringList): if stringList[i] == word: return i i = i + 1 return -1 Ralph. From jeffp at crusoe.net Fri Mar 17 12:06:51 2000 From: jeffp at crusoe.net (Jeff Pinyan) Date: Fri, 17 Mar 2000 17:06:51 GMT Subject: Code basics In-Reply-To: <8ath59$c7i$1@vg170.it.volvo.se> References: <8ath59$c7i$1@vg170.it.volvo.se> Message-ID: [posted & mailed] >while( notDone ) >{ > int chip = this.getNumberOfSomething(); > if (chip == 10 ) > { > System.out.println("Tjohoo"); > } > else > { > System.out.println("Oh no!"); > } >} I'll be a jerk, and do this brevity-style: while notDone: print ("Oh no!","Tjohoo")[this.getNumberOfSomething() == 10] Now, I ask you folk, is that "bad" Python? Is that "bad" programming in general, to be brief and succinct like that? I'm curious -- I have a tendency to do things like that. :) -- MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve japhy at pobox.com http://www.pobox.com/~japhy/ http://pinyaj.stu.rpi.edu/ PerlMonth - An Online Perl Magazine http://www.perlmonth.com/ The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/ From banderson at boi.hp.com Mon Mar 6 13:46:31 2000 From: banderson at boi.hp.com (Bill Anderson) Date: Mon, 06 Mar 2000 11:46:31 -0700 Subject: Programmatically Getting Process ID References: <89pi3n$8lc$1@nnrp1.deja.com> Message-ID: <38C3FD07.AE7EA787@boi.hp.com> "Samuel A. Falvo II" wrote: > > In article <89pi3n$8lc$1 at nnrp1.deja.com>, Hernan M. Foffani wrote: > >The portable way to do it (in UN*X, I mean) is to run a script and get > >the output (via pipes), something like: > > > >#!/bin/sh > >ps -ef | grep "$1" | grep -v grep | awk '{ print $1 }' > > I just got done doing this and, unfortunately, this is not portable. This > script will not return the PID of the process(es), but rather the user under > which the said process(es) run. > > On _my_ Linux distribution, the awk statement should read '{ print $2 }' > instead of $1. I'm not sure about how well this would work on a non-Linux > system. After changing it to $2, it works on my Linux and HPUX boxen. I believe this _should_ be portable for Unixen. After all, the key in this equation is ps's output format. If not, you can call ps with a formatting option, whoch should _theoritcally_ make it *nix portable. YMMV > Just giving you a heads up. Ditto. -- Bill Anderson Linux/Unix Administrator, Security Analyst ESBU (ARC) bill_anderson at boi.hp.com My opinions are just that; _my_ opinions. From gmcm at hypernet.com Sat Mar 25 14:33:48 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 25 Mar 2000 14:33:48 -0500 Subject: Heh, sorry for all these questions so close together. In-Reply-To: <20000325174426.21164.cpmta@c000.sfo.cp.net> Message-ID: <1258109662-11445237@hypernet.com> Falknor wrote: > The equiv to the gettimeofday is time.time().. that's no prob. Prob is, it only > returns seconds.. not micro seconds. and the differences in > the C select and the Python one throw me for a little loop.. > Not sure how i could do the same thing with the > select.select() as is done there :) time.time returns a float number of seconds. time.sleep takes a float, and for most platforms is implemented in terms of select. - Gordon From dfan at harmonixmusic.com Wed Mar 8 11:27:25 2000 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 08 Mar 2000 11:27:25 -0500 Subject: crimes in Python References: <1Nsx4.5923$yV1.1624509@tw11.nn.bcandid.com> Message-ID: Michael Hudson writes: | kragen at dnaco.net (Kragen Sitaker) writes: | | > >> sys.stderr.write(join( | > >> map((lambda x: 'age' + `x` + "\tsex" | > >> + `x` + "\trace" + `x`), | > >> range(1, max_suspects+1))) | > >> ) | | Random advice: while you're learning Python, forget map exists. | | This is a particularly heinous use of it, as you're using it for | side-effects and ignoring the results. Isn't he passing the resulting list to join()? | I think map is occasionally useful for actually mapping a function | over a list of inputs, but in this context it makes no sense. | | > for i in range(1, max_suspects+1): | > sys.stderr.write('\tage%d\tsex%d\trace%d' % (i, i, i)) | | This is so much better, isn't it? I can tell at a glance what you're | up to, whereas I couldn't really tell from your `map'. Both the map and the explicit for are equally intelligible to me, but I've always been a fan of a functional style. I do agree that using map on a range (rather than a list you already have) is kind of awkward. -- Dan Schmidt | http://www.dfan.org From dieter at handshake.de Thu Mar 30 14:09:08 2000 From: dieter at handshake.de (Dieter Maurer) Date: 30 Mar 2000 21:09:08 +0200 Subject: segmentation fault with Tkinter in Solaris (sft) References: Message-ID: "Fredrik Lundh" writes on Wed, 29 Mar 2000 19:26:49 GMT: > Ryan Thompson wrote: > > After a little more research I see that python 1.5.2 only works with > > tcl/tk 8.0 in solaris, but will not work with 8.1 or higher without > > patches. Is this true for 8.3? > it definitely won't work without the patches, so you might as > well try them out... I have just generated (and tested) "_tkinter" with tcl/tk 8.3.0 under Linux/glibc2. As for 8.2.2 and unlike 8.1, there were no patches needed. Of cause, I had to edit "Modules/Setup" to get "_tkinter" compiled and linked with the correct tcl/tk headers/libraries. I would expect the same behaviour for Solaris (but not for Windows). I do not expect the core to be related with an incompatibility between Python 1.5.2 and tcl/tk 8.3.0. Dieter From akuchlin at mems-exchange.org Wed Mar 22 17:15:28 2000 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 22 Mar 2000 17:15:28 -0500 Subject: regular expressions questions References: <11A17AA2B9EAD111BCEA00A0C9B4179305321B0A@molach.origin.ea.com> <38D6DDAA.F69F3BEC@ooc.com.au> Message-ID: <3d3dpiejnj.fsf@amarok.cnri.reston.va.us> "Darrell" writes: > [Derek Thomson] > > [ And now, at last, Perl 5.6 allows regexes to refer to other regexes. So > >now we > > can uses regexes to parse balanced expressions like matching parenthesis. Actually, this was an experimental feature in Perl5.005. Search the perlre documentation for the (?{ code }) construct. > >No doubt this will appear in Python's re module before long. ] This is highly unlikely, because last time around we couldn't come up with a way to do this that wasn't impressively ugly. See the thread starting with this July 1998 article: The general tenor of opinion seemed to be that, if you want to parse expressions, use a real parser generator, and we certainly have enough of those for Python. Adding a feature to regexes for this produces difficult-to-read code -- you need a pretty intimate knowledge of exactly how the computer tries matches and then backtracks -- and makes the matching engine more complicated. So this feature is almost certainly not going to be added. (Elegant patches to add a new feature, of course, can often reverse theoretical objections.) -- A.M. Kuchling http://starship.python.net/crew/amk/ About those crude, hate-filled cartoons in your Lesbian, Gay and Bi issue: they're meant to subvert and debunk the stereotypical notion that all gay people are imbued with Wildean wit, right? -- C. Doerksen, in a letter to the McGill Daily From mak at imakhno.freeserve.co.uk Thu Mar 9 08:32:36 2000 From: mak at imakhno.freeserve.co.uk (Makhno) Date: Thu, 9 Mar 2000 13:32:36 -0000 Subject: Python performance References: <8a3if5$20l$1@nnrp1.deja.com><38C571BC.F1760D18@bellatlantic.net> <8a49mu$jsm$1@nnrp1.deja.com> <86og8pul8u.fsf@g.local> Message-ID: <8a8m45$kr0$1@news8.svr.pol.co.uk> >Pick an application. Any application (almost). I bet you that >at least 80% of it is "non-critical, low-performance". So >write the performance-critical bits in C or, if you really >need to, assembler, and the rest in a higher-level language. I aggree entirely. The idea of writing the core system in a low-level language, and having a higher-level language as it's interface "controlling" the system, is the way I approach problems (And is I think the future as most systems seems to be 10% core code, 90% interface code). Another advantage is that a developer can opensource the controller code, allowing the user to have a greater degree of flexibility. From moshez at math.huji.ac.il Fri Mar 31 02:19:16 2000 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 31 Mar 2000 09:19:16 +0200 (IST) Subject: Cleanup? In-Reply-To: <8c0cb7$13c4$1@news2atm.raleigh.ibm.com> Message-ID: On Thu, 30 Mar 2000, Arint? wrote: > I want to be able to run sets of python scripts, but how can I cleanup all > the variables (globals) from the last one run? Run them with "exec