From mail at to.me Wed Apr 28 01:53:36 1999 From: mail at to.me (Usenet User) Date: 28 Apr 1999 05:53:36 GMT Subject: GUI other than Tkinter (TVision?) References: <3721567f.1748033@news> <7g1a8h$fae$1@Starbase.NeoSoft.COM> Message-ID: <8DB68CFE2HolyMama@bbinews.netvigator.com> Anyone interested in wrap this TVision with python? http://www.geocities.com/SiliconValley/Vista/6552/tvision.html Turbo Vision is the good old TUI (Text User Interface) we used in Turbo C++ and it is GPLed. It is written in C++ and maybe someone want to wrap it with python. ========== What's Turbo Vision? Turbo Vision (TVision for short) is a TUI (Text User Interface) that implements the well known CUA widgets. With TVision you can create an intuitive text mode application, intuitive means it will have CUA like interface (check boxes, radio buttons, push buttons, input lines, pull -down menues, status bars, etc.). All the people acustomed to the Windows, MacOS, OS/2, Motif, GTK, etc. interfaces will understand the interface at first sight. =========== From mcannon at 21stcentury.net Tue Apr 13 00:40:19 1999 From: mcannon at 21stcentury.net (Michael J. Cannon) Date: Mon, 12 Apr 1999 23:40:19 -0500 Subject: Python and Nutcracker References: <370B62F2.93D76301@oi42.kwu.siemens.de> Message-ID: <3712CAB2.77A5AF2B@21stcentury.net> Dr Tschammer: Speaking from experience, both in supporting (independently of DataFocus) and porting, all I can say is be careful of the I/O and exception handling in the Nutcracker, especially when addressing issues involved in Winsock and calls to any messaging .dll's or libraries. Also, your users will have to disable the Nutcracker service manually when doing backups from NT databases on the server (especially SQL server and Oracle) and then manually restart, as cron and at -type calls are problematic with the Nutcracker services running. Finally, license WinBatch for your customers/users as they will need it. Personally, I have given up on Nutcracker as support is both expensive and a nightmare of frustrated users. My preferred platform is now Java (via javat) or a mix of c (GNU C or C+/++) and python. For a taste of what you're in for as far as support, check out the EDI-L mailing list and watch for messages on Harbinger's TLE product (formerly UNIX PREMENOS), or see if you can't get in contact with someone who will honestly critique NUWC's efforts (prominently featured on the DataFocus site). My feeling is that Nutcracker was a good idea with a rushed implementation. With all the faults of NT, to depend on a set of libraries existing as a service, poorly implemented, is asking for trouble. "Dr. Armin Tschammer" wrote: > Hi, > Has anyone experience with Python and Nutcracker ? > We are using embedded Python in our application which > is developed under HPUX. > We are now porting our application to Windows NT > with the help of the Nutcracker library. > Has anyone already done such stuff ? > > Armin From faassen at pop.vet.uu.nl Thu Apr 22 13:49:24 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Thu, 22 Apr 1999 19:49:24 +0200 Subject: Pointers to variables References: <19990422121403.A279051@vislab.epa.gov> Message-ID: <371F6124.48EA9794@pop.vet.uu.nl> Randall Hopper wrote: > > This doesn't work: > > for ( var, str ) in [( self.min, 'min_units' ), > ( self.max, 'max_units' )]: > if cnf.has_key( str ): > var = cnf[ str ] > del cnf[ str ] > > It doesn't assign values to self.min, self.max (both integers). The values > of these variables are inserted into the tuples and not references to the > variables themselves, which is the problem. > > How can I cause a reference to the variables to be stored in the tuples > instead of their values? Hi there, I've been trying to understand the purpose of the code in your fragment and your question for a minute or so, but I'm not entirely sure I get it yet. I'm assuming what you want is to get 'cnf[str]' assigned to self.min or self.max. What you could do is something like this: for str in ('min_units', 'max_units'): if cnf.has_key(str): setattr(self, str, cnf[str]) del cnf[str] Tuples, by the way are immutable, so you can't change what values their elements point to after they've been created (though if these values point to other things themselves you can change that). That is, you can't do this: foo = (value1, value2) foo[0] = "hey" But, if you'd use a mutable list, you still run into trouble. If you say this: mylist = [None] # list with a single element None variable_i_want_to_change = "Foo" # a variable I want to change mylist[0] = variable_i_want_to_change # okay, mylist[0] points to same data mylist[0] = "Bar" # now mylist[0] points to different data then 'variable_i_want_to_change' won't change. You've simply changed what value mylist[0] points at. This is because a string (and integers etc) are immutable values in Python. If you use a mutable value such as a dictionary, you get this: mylist = [None] variable_i_want_to_change = {} mylist[0] = variable_i_want_to_change mylist[0]["some key"] = "bar" # indeed changes variable_i_want_to_change! # mylist[0] = "Bar" -- doesn't work, makes mylist[0] point elsewhere I suspect I'm making things sound horribly complicated when they aren't really. I can keep all this in my head easily, it's just hard communicating it. I can understand the confusion with pointers from C, but note that this is the actual semi-equivalent C code (of the first fragment, not the dict one, and using ints instead of strings): /* Initialize the variables, assume easy allocate functions which do all the malloc() calls I don't want to figure out right now */ int** mylist = allocate_list(); *mylist[0] = 0; /* now we have a list with a pointer to an int value, which is 0 */ int* variable_i_want_to_change = allocate_int(); *variable_i_want_to_change = 1; /* now we have a variable which points to an int value, which is 1 */ *mylist[0] = *variable_i_want_to_change; /* now the data mylist[0] points at becomes 1 too */ *mylist[0] = 2; /* now the data mylist[0] points at becomes 2 */ /* has the data *variable_i_want_to_change changed? no. I hope! :)*/ I don't expect this explained a lot. I feel like Tim Peters somehow... :) Regards, Martijn From tville at earthlink.net Wed Apr 14 13:01:30 1999 From: tville at earthlink.net (susan e paolini) Date: Wed, 14 Apr 1999 13:01:30 -0400 Subject: what do you do with Python Message-ID: <3714C9EA.86C0A4E@earthlink.net> I never see jobs with Python advertised so what is it that Python does? Thanks for the advice From roy at popmail.med.nyu.edu Thu Apr 29 14:02:40 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Thu, 29 Apr 1999 14:02:40 -0400 Subject: padding strings Message-ID: Given a string, I want to generate another string which is exactly N characters long. If the first string is less than N, I want to blank-pad it. If the first string is greater than N, I want to truncate it. What's the most straight-forward way to do that? -- Roy Smith New York University School of Medicine From larsga at ifi.uio.no Tue Apr 6 01:33:09 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 06 Apr 1999 07:33:09 +0200 Subject: SNMPy update References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> Message-ID: * Jeremy Hylton | | expect that I'd want to release it given the export control hassles. | However, it seemed clear to me that an ASN.1 compiler could be | written to generate the encode/decode routines. If someone is | interested in that, I've got some design notes and rough code on how | to do the encode/decode and on how to build a backend for SNACC. I'd be interested in that. I've been thinking of doing a pure-Python LDAP client. --Lars M. From sweeting at neuronet.com.my Sun Apr 25 16:11:31 1999 From: sweeting at neuronet.com.my (sweeting at neuronet.com.my) Date: Sun, 25 Apr 1999 20:11:31 GMT Subject: converting perl to python - simple questions. References: <000001be8f3e$eea9c3c0$d39e2299@tim> Message-ID: <7fvstg$nqo$1@nnrp1.dejanews.com> > > Anyway, since I know that there are a few ex-perlmongers on the list, > > would somebody be so kind as to confirm whether I've translated > > the following code snippets correctly : > > > > a) Perl's "defined". > > [perl] > > if (defined($x{$token}) > > > > [python] > > if (x.has_key(token) and x[token]!=None) : > > If should be enough to do > > if x.has_key(token): > > under the probably-correct theory that the Perl is just asking "does hash > 'x' have key 'token'?" "None" is a specific valid value, not at all > "undefined", so checking x[token] against None doesn't make sense unless > you've established your own consistent program-wide convention of using None > to *mean* something like undefined. Which is dicey. After e.g. "del > x[token]", a reference to x[token] doesn't yield None, it raises the > KeyError exception. For years, I've been thinking of "None" in Python as "null" in javascript, meaning "no value set" and so it was actually quite interesting to see that Perl has "exists" and "defined" functions for dictionaries.... I had translated "exists($dictionary{$token})" into "dictionary.has_key(token)" and hence went overboard when I translated "defined(...)" Anyway, from testing it does appear that both defined() and exists() can be simply replaced with dico.has_key(token) in my scripts. > > b) RE's. > > [perl] > > if ($mytext !~ /^\s$/) > > > > [python] > > if not (re.match('^\s$'), mytext) > > Hmm. The Perl says "if mytext isn't a single whitespace character", which > is an odd thing to check! If that's the intent, fine. Yes, loads of double-byte character processing ... > Python's "match" > already constrains the search to begin at the start of the string, so the > leading "^" isn't needed (use Python's "search" if don't want that > constraint). aaaah - subtle. Thanks. >So: > > if not re.match(r"\s$", mytext): > > Get in the habit of using r-strings for writing regexps; they'll make your > backslash life much easier. Thank you for pointing that out - the perl stuff's been screwing with my head and making me confused, \s being ok in that language. > Another thing to note is that high-use regexps can be compiled, and if > they're always used in the same way (match vs search) you can capture that > choice too. So this may be more appropriate: > > is_single_whitespace = re.compile(r"\s$").match > > while whatever: > ... > if not is_single_whitespace(mytext): > ... > ... Thank you very much - I'd read the excellent howto on python.org and that described this too. I chose not to compile just for clarity since I'm still trying to work out if I've translated the code from perl to python correctly. But I will optimise later... > Hoisting the regexp compilation out of the loop can be a substantial win. > > > Since I know neither perl nor chinese, it would be nice if somebody > > could help me remove one of the variables in my debugging. > > native-speakers-of-both-say-chinese-is-easier-to-read-ly y'rs - tim after today, i'd be inclined to agree :) chas -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From parkw at better.net Wed Apr 28 15:20:42 1999 From: parkw at better.net (William Park) Date: Wed, 28 Apr 1999 15:20:42 -0400 Subject: HTML "sanitizer" in Python In-Reply-To: ; from Scott Stirling on Wed, Apr 28, 1999 at 12:49:55PM -0400 References: Message-ID: <19990428152042.A708@better.net> On Wed, Apr 28, 1999 at 12:49:55PM -0400, Scott Stirling wrote: > Hi, > > I am new to Python. I have an idea of a work-related project I want > to do, and I was hoping some folks on this list might be able to > help me realize it. I have Mark Lutz' _Programming Python_ book, > and that has been a helpful orientation. I like his basic packer > and unpacker scripts, but what I want to do is something in between > that basic program and its later, more complex manifestations. > > I am on a Y2K project with 14 manufacturing plants, each of which > has an inventory of plant process components that need to be tested > and/or replaced. I want to put each plant's current inventory on > the corporate intranet on a weekly or biweekly basis. All the plant > data is in an Access database. We are querying the data we need and > importing into 14 MS Excel 97 spreadsheets. Then we are saving the > Excel sheets as HTML. The HTML files bloat out with a near 100% > increase in file size over the original Excel files. This is > because the HTML converter in Excel adds all kinds of unnecessary > HTML code, such as for every single > cell in the table. Many of these tables have over 1000 cells, and > this code, along with its accompanying closing FONT tag, add up > quick. The other main, unnecessary code is the ALIGN="left" > attribute in tags (the default alignment _is_ left). The > unnecessary tags are consistent and easy to identify, and a routine > sh! > ould be writable that will automate the removal of them. > > I created a Macro in Visual SlickEdit that automatically opens all > these HTML files, finds and deletes all the tags that can be > deleted, saves the changes and closes them. I originally wanted to > do this in Python, and I would still like to know how, but time > constraints prevented it at the time. Now I want to work on how to > create a Python program that will do this. Can anyone help? Has > anyone written anything like this in Python already that they can > point me too? I would really appreciate it. > > Again, the main flow of the program is: > > >> Open 14 HTML files, all in the same folder and all with the .html > >> extension. Find certain character strings and delete them from > >> the files. In one case (the tags) it is easier to find the > >> whole tag with attributes and then _replace_ the original tag > >> with a plain . Save the files. Close the files. Exit the > >> program. Hi Scott, I shall assume that a tag occurs in one line. Try 'sed', for i in *.html do sed -e 's///g" $i > /tmp/$i && mv /tmp/$i $i done or, in Python, for s in open('...', 'r').readlines(): s = string.replace('', '', s) print string.strip(s) If tag spans over more than one line, then read the file in whole, like for s in open('...', 'r').read(): If the tag is not consistent, then you may have to use regular expression with 're' module. Hopes this helps. William > > More advanced options would be the ability for the user to set > parameters for the program upon running it, to keep from hard-coding > the find and replace parms. To use command line parameters, like $ cleantd 'ALIGN="left"' change to s = string.replace('' % sys.argv[1], '', s) > > OK, thanks to any help you can provide. I partly was turned on to > Python by Eric Raymond's article, "How to Become a Hacker" (featured > on /.). I use Linux at home, but this program would be for use on a > Windows 95 platform at work, if that makes any difference. I do > have the latest Python interpreter and editor for Windows here at > work. > > Yours truly, > Scott > > Scott M. Stirling > Visit the HOLNAM Year 2000 Web Site: http://web/y2k > Keane - Holnam Year 2000 Project > Office: 734/529-2411 ext. 2327 fax: 734/529-5066 email: sstirlin at holnam.com > > > -- > http://www.python.org/mailman/listinfo/python-list From aa8vb at vislab.epa.gov Sat Apr 17 11:23:44 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Sat, 17 Apr 1999 15:23:44 GMT Subject: Bug with makesetup on FreeBSD In-Reply-To: <19990416215633.C2020@ipass.net>; from Randall Hopper on Fri, Apr 16, 1999 at 09:56:33PM -0400 References: <19990416143607.B1546743@vislab.epa.gov> <19990416215633.C2020@ipass.net> Message-ID: <19990417112344.A1624668@vislab.epa.gov> Andrew Csillag: |Randall Hopper wrote: |> Andrew Csillag: |> |makesetup in Python 1.5.1 and 1.5.2 bombs on lines in the Setup file |> |that use backslash continuation to break a module spec across lines on |> |FreeBSD. |> |> BTW FWIW, I just built 1.5.2 last night on 3.0-RELEASE using the 1.5.2c1 |> port. Worked fine. But it may not invoke makesetup under the hood. | |It does invoke makesetup (that's how the Makefile in Modules gets |written). I'm also running FreeBSD 2.2.8, so it may be a bug in /bin/sh |that has been subsequently fixed... The quick test is to try this on |your 3.0 machine | |$ read line |some text here\ | |On my 2.2.8 machine after I hit return after the \, I get a command line |prompt, not a "blank prompt" that would mean that the read wasn't done. It must be something else then, because here with stock Bourne shell: |$ read line |some text here\ |$ echo $line |some text here\ I get the same behavior you describe, but no build breakage. Randall From wdrake at my-dejanews.com Fri Apr 30 14:54:25 1999 From: wdrake at my-dejanews.com (wdrake at my-dejanews.com) Date: Fri, 30 Apr 1999 18:54:25 GMT Subject: Oracle Call Interface References: <7gb3hn$lse$1@nnrp1.dejanews.com> <3729ADDA.8E51C1D0@palladion.com> Message-ID: <7gcu8v$8gp$1@nnrp1.dejanews.com> I was interested in using Oracle's Advanced Queuing (AQ), specifically the asynchronous event notification features. Thanks In article <3729ADDA.8E51C1D0 at palladion.com>, Tres Seaver wrote: > Jeffrey Chang wrote: > > > > > If anyone has experience writing applications directly to the Oracle Call > > > Interface (OCI), in Python or JPython please send me examples or references on > > > how to do it. > > > > Yuck! What are you planning to do? Do you really really need to write > > directly to the OCI or can you use one of the available Oracle extension > > modules? > > > > About a year ago, I used the oracledb module from Digital Creations with > > Oracle7. It's very nice, but not optimized, and thus slow for large > > queries. Since then, Digital Creations has made DCOracle > > (http://www.digicool.com/DCOracle/; their commercial extension module) > > open source, so I guess that will replace oracledb. I haven't looked at > > it, but according to the FAQ, it's "much faster." > > > > I strongly advise you to use an extension module or JDBC if at all > > possible. Writing to the OCI is extremely ugly -- all the stuff we try to > > avoid by using python! > > ODBC/JDBC solutions suffer from "least-common-denominator" symptom; one can't > easily exploit Oracleisms. I haven't played with DCOracle yet, but wrapping OCI > into a nice Pythonic package would be a big win in some situations (passing > array parameters to stored procedures is the one I most often want). > > -- > ========================================================= > Tres Seaver tseaver at palladion.com 713-523-6582 > Palladion Software http://www.palladion.com > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From tim_one at email.msn.com Sat Apr 10 22:15:54 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 11 Apr 1999 02:15:54 GMT Subject: Python 2.0 compatibility In-Reply-To: References: Message-ID: <000401be83c1$3a66e060$7fa22299@tim> [Paranoid User] > We have selected Python as the scripting language for the next > generation of one of our embedded systems. Good choice! Take the opportunity to expand it to all of your systems. > This is a very fast-track project scheduled to ship near the end of > the first quarter of 2000. In Internet time, that's about a century from now; but in Python time, it's just the early part of next year . > I ran across a quote that said something to the effect that Python 2 will > be incompatible with Python 1. Before I make a decision as to whether we > freeze with Python 1.5.2, or migrate to Python 2 when it is released, I > need to find out the extent of truthfulness in the "quote". > > So, if anyone in-the-know about Python 2 could let me know the proposed > extent of its compatibility with 1.5.2 I would really appreciate it. If anything concrete is known about Python2, it's inside Guido's inscrutable head. Don't worry about it. Since it doesn't yet exist (nor even a wisp of a sketch of an outline of a design document), it's all speculation. My guess is it will end up being more compatible than most dare to hope -- or to fear <0.7 wink>. By and large, the only suggestions Guido has seemed especially keen about are considered by many to be legitimate design errors in Python1 (the rift between types and classes is a clear example of that; that e.g. 3/2 returns 1 instead of 1.5 is a controversial example). It doesn't much matter for you, though, since Python 1.6 will still be part of the 1.x line, and won't come out before the end of this year. If the much-later-still Python2 does turn out to be wildly incompatible, there are enough people using the Python1 line that someone other than Guido is likely to take over its maintenance (even if not active future development) -- and *certain* to take it over if enough companies care enough to pay for that service. speaking-for-the-professional-prostitutes-of-the-world-ly y'rs - tim From paul at prescod.net Thu Apr 29 15:00:33 1999 From: paul at prescod.net (Paul Prescod) Date: Thu, 29 Apr 1999 19:00:33 GMT Subject: padding strings References: Message-ID: <3728AC50.9085F2C0@prescod.net> Roy Smith wrote: > > Given a string, I want to generate another string which is exactly N > characters long. If the first string is less than N, I want to blank-pad > it. If the first string is greater than N, I want to truncate it. > > What's the most straight-forward way to do that? How about this: def mypad( s, num ): return string.ljust( s, num )[:num] -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Microsoft spokesman Ian Hatton admits that the Linux system would have performed better had it been tuned." "Future press releases on the issue will clearly state that the research was sponsored by Microsoft." http://www.itweb.co.za/sections/enterprise/1999/9904221410.asp From janssen at parc.xerox.com Wed Apr 21 17:33:08 1999 From: janssen at parc.xerox.com (Bill Janssen) Date: Wed, 21 Apr 1999 21:33:08 GMT Subject: HTTP-NG Support? In-Reply-To: <002201be8c08$1969e570$8b7125a6@cpda6686.mcit.com> References: <002201be8c08$1969e570$8b7125a6@cpda6686.mcit.com> Message-ID: I've been using Python with HTTP-NG a lot, via ILU. ILU Python implements the w3ng wire protocol and the w3mux protocol and most of the type system -- the only thing missing is local objects, and I'm working on them now. Bill From donn at u.washington.edu Mon Apr 26 12:40:25 1999 From: donn at u.washington.edu (Donn Cave) Date: 26 Apr 1999 16:40:25 GMT Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> <371F9D0C.4F1205BB@pop.vet.uu.nl> <7foe7r$15mi$1@nntp6.u.washington.edu> <37245184.3AADF34D@pop.vet.uu.nl> Message-ID: <7g24tp$raa$1@nntp6.u.washington.edu> Martijn Faassen writes: | Donn Cave wrote: ... |> It's not much like C++ here, but it's uncanny how it reeks of Python! |> Namespaces, references! | | Indeed. Not having used that class attribute trick often myself, I | wasn't aware of this surprising behavior. I suppose in order to get the | C++ behavior it's best to use a module global variable. Not at all, either way is fine - the class scope is just as good a place as the module scope, for me it's the perfect place for things that are specific to the class. It's the usage that you have to watch out for, and while there are some perils for the unwary, in the long run it's also an opportunity to gain a deeper understanding of how simple Python is. Same for module attributes - common problem, someone imports a module attribute like from foo import shared shared = 5 and then wonders, how come no change to the attribute as seen from other modules. The right way to set to a module attribute - if you must do this at all - is foo.shared = 5 and just the same for a class attribute (of class Foo): from foo import Foo Foo.shared = 5 In general, you have the problem only when your usage doesn't reflect the design. If it's really a class attribute, but you set it in the instance scope, if it's really an external module attribute but you bind it into the present module's scope during import. Python bites if you trick it. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From xx_nospam at delorges.in-berlin.de Fri Apr 16 11:07:59 1999 From: xx_nospam at delorges.in-berlin.de (Jo Meder) Date: 16 Apr 1999 17:07:59 +0200 Subject: HTML Authentication with Python References: <7f5iru$rlm@news.acns.nwu.edu> <14102.27498.772779.5941@bitdiddle.cnri.reston.va.us> <7f6577$8kp@news.acns.nwu.edu> <37171EDE.9DFD027A@quantisci.co.uk> Message-ID: Stephen Crompton writes: [Excellent explanation of HTTP-Authentication snipped] If you still need to do the authentication yourself, e.g. because the username/password combinations are held in a database that is not supported by your Webserver: It can be done and how you do it depends on the type of server you use. I have a working solution for Apache (which works by (ab)using the rewrite-module) and a solution for Roxen Challenger that I'll test in Real Life(tm) soon. Jo. -- xx_nospam at delorges.in-berlin.de is a valid address - ist eine gueltige Adresse. From fredrik at pythonware.com Tue Apr 13 10:49:08 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 13 Apr 1999 14:49:08 GMT Subject: CVS module References: <7evbjf$85f$1@anguish.transas.com> Message-ID: <001d01be85bc$cd9e92e0$f29b12c2@pythonware.com> Michael Sobolev wrote: > My quick attempt to find something that would help me to cope with CVS files > failed. Could anybody advise me whether such a module exist? Under "such a > module" I mean something that permits to get the complete information about the > given file: > > cvsfile = CVSFile () > > from pprint import pprint > > pprint (cvsfile.revisions) > > or something alike. maybe Demo/pdist/cvslib.py (in the Python source distribution) could be a start? From tim_one at email.msn.com Sat Apr 3 01:26:17 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 3 Apr 1999 06:26:17 GMT Subject: disenchanted java user mumbles newbie questions In-Reply-To: <3705980A.1C7E9512@swcp.com> References: <3705980A.1C7E9512@swcp.com> Message-ID: <000101be7d9a$e1ae88a0$879e2299@tim> [Alex Rice] > 1) In the Python 1.5 Tutorial, sec. 9.2 "Python Scopes and Name Spaces" > there is the following passage: > ... > -- however, the language definition is evolving towards static name > resolution, at ``compile'' time, so don't rely on dynamic name > resolution! > ... > Where can I read more about this move towards for compile time, static > name resolution and the reasons for it. Best I can suggest is scouring years' worth of DejaNews. Most of it is summarized in early postings to the Python Types-SIG, though (http://www.python.org/, and follow the SIGS link at the top ...). "The reasons" are the same as everyone else's: a mix of efficiency and compile-time-checked type safety. I'd say the Python thrust these days may be more toward adding *optional* type decls, though. OTOH, nothing has changed in this area of Python for > 5 years, so don't panic prematurely . > For some reason I was envisioning Python as being less like Java and > more like Objective-C or Smalltalk in terms of dynamic binding. Yes, it is. It's extreme, though. For example, in def sumlen(a, b, c): return len(a) + len(b) + len(c) Python can't assume that "len" refers to the builtin function "len", or even that all three instances of "len" refer to the same thing within a single call (let alone across calls). As to what "+" may mean here, it's even hairier. In effect, the current semantics require that Python look up every non-local name and access path from scratch every time it (dynamically) hits one. This leads to some pretty disgusting convolutions for speeding "inner loops", in support of a generality that's wonderful to have but actually *needed* by very little code. Because of a professional background in compiler optimization, I'm supposed to be appalled by this . > 2) Which reminds me: does anyone have a URL for that Ousterhut (sp?) > article at Sunlabs about Scripting languages and why scripting rulz and > where he has a taxonomy of programming languages along 2 dimensions? > Lost that bookmark and cannot find it again. It's one of the White Papers at: http://www.scriptics.com/scripting/white.html > 3) What's the Python equivalent of depends.exe? --something to find what > modules your script is depending upon? Suggest searching python.org and DejaNews and Starship for "freeze" and "squeeze". > It seems like one would be able to create a very slim distribution if one > needed an .exe, couple of .dll only a handful of .py files. Why do I suspect you're a Windows programmer ? The most advanced Python distribution system for Win32 is likely Gordon McMillan's, available for free at http://www.mcmillan-inc.com/install.html May also want to visit the Python DistUtils SIG. > A Java+Swing application can be 1-2 MB not including the VM! bloat--ed. Doubt you're going to get off much cheaper with Python + Tcl/Tk, although it includes two complete language implementations. > What's a typical size of a bare-bones Python distribution? Download one, unpack it, and do "dir" . soon-even-light-bulbs-will-have-20Gb-hard-drives-ly y'rs - tim From boud at rempt.xs4all.nl Sun Apr 25 15:03:05 1999 From: boud at rempt.xs4all.nl (boud at rempt.xs4all.nl) Date: Sun, 25 Apr 1999 19:03:05 GMT Subject: GUI other than Tkinter References: <3721567f.1748033@news> Message-ID: Russell Nelson wrote: : mrfusion at bigfoot.com writes: : :> Well, I've just about given up on EVER getting Tkinter to work on my :> Win98 machine. Is there any other GUI module that I can get that :> doesn't require TCL/TK to be installed on my machine? Isn't there :> something called GD? : : There's pygtk, which uses the gtk toolkit. : On Windows 98? -- Boudewijn Rempt | www.xs4all.nl/~bsarempt From justin at linus.mitre.org Fri Apr 23 22:09:54 1999 From: justin at linus.mitre.org (Justin Sheehy) Date: 23 Apr 1999 22:09:54 -0400 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> Message-ID: mlh at idt.ntnu.no (Magnus L. Hetland) writes: > (And... How about builtin regexes in P2?) Um, why? I don't see any need at all for them to move from module-status to core-language-status. The only way that I could understand the desire for it would be if one wanted to write little scripts that were basically just some control flow around regexes and string substitution. That is, something that looked like most of the programs written in that other P language. ;-) In all seriousness, what reason do you have for making that suggestion? I am willing to believe that there might be a good reason to do so, but it certainly isn't immediately obvious. -Justin From tim_one at email.msn.com Thu Apr 8 02:26:21 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 8 Apr 1999 06:26:21 GMT Subject: Crappy Software was Re: [OffTopic: Netscape] Re: How should In-Reply-To: <1288614834-78399188@hypernet.com> References: <1288614834-78399188@hypernet.com> Message-ID: <000a01be8188$b7f56280$749e2299@tim> [Gordon McMillan, among others with Netscape vs IE experience] > ... > Having recently ported a sophisticated applet using JNI (Sun's new > native interface) to JRI (older Netscape) and RNI (older IE), I too > can kick and scream. > [guess the outcome ] I'm no browser wizard -- just took a few stabs over the past year & a half at writing some relatively simple Java applets, JavaScript and HTML for the amusement of my family. No CSS, no frames, nothing at all even remotely cutting-edge. One Netscape-using sister had dozens of problems with *all* of these, most eventually determined to be cases of NS not meeting the appropriate std, and-- far too often --crashing her machine. Fact is NS dropped the browser ball a couple years ago, then poked holes in it, then attached industrial-strength vacuum cleaners on the off chance any air remained. > ... > When's the last time you closed a GUI from the file menu?? Hey, I'll close a stinking GUI any way I can . right-next-to-my-reboot-foot-pedal-ly y'rs - tim From mwh21 at cam.ac.uk Sat Apr 17 20:09:48 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 18 Apr 1999 01:09:48 +0100 Subject: Plugins, or selecting modules to import at runtime References: <924379180.825429211@news.intergate.bc.ca> <924385178.948235039@news.intergate.bc.ca> Message-ID: Gerald Gutierrez writes: > Never mind. I just found the module "imp". That's waay overkill for what you need; the builtin function __import__ will do nicely: Python 1.5.2 (#2, Apr 14 1999, 13:02:03) \ [GCC egcs-2.91.66 19990314 (egcs-1.1.2 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> __import__("sys") >>> s=__import__("sys") >>> s >>> HTH Michael > Thanks. > > On Sat, 17 Apr 1999, Gerald Gutierrez wrote: > >Hi all. > > > >I'd like to write a program in Python in which the user can select one of > >several modules to execute through a function that has the same name in all the > >modules. I don't believe "import" lets me pass it a string. There is also > >reload(), but the module to reload must be previously imported. > > > >This is very similar to plugins like that used in Netscape, Photoshop and the > >GIMP. > > > >Can someone please give me a hint? > > > >Thanks. > > > >Please forward replies to gutier at intergate.bc.ca. From tavares at connix.com Sat Apr 10 12:14:26 1999 From: tavares at connix.com (Chris Tavares) Date: Sat, 10 Apr 1999 12:14:26 -0400 Subject: pythonwin COM Update link out of date References: <7em639$fto$1@m2.c2.telstra-mm.net.au> Message-ID: <370F78E2.8EA7433E@connix.com> Mark Hammond wrote: > Bernhard Reiter wrote in message ... > >http://www.python.org/ftp/python/pythonwin/pwindex.html#oadist > > > >Gives a bad link to the MS Microsoft Knowledge Base article Q164529. > >The link is bad and I cannot relocate the article with the search > >engine on that site and other methods... :( > > > >The closest I could get was: > > http://support.microsoft.com/support/kb/articles/Q139/4/32.asp > >from > > http://support.microsoft.com/support/downloads/LNP195.asp > > > >Hmmmm.... is there a potential danger in installing oadist.exe? > > There _shouldnt_ be any danger! > > These days it is getting quite unnecessary. If you have (I believe) IE4 or > Office 97, you are pretty up-to-date, and that includes many PCs these days. > > You could try installing the Python stuff, and see if it works. Also, see > my other post this morning as to why the install may fail - try this out > first. > > Mark. Another option is to download DCOM for Win95 - that'll get the user up to date and then some! -Chris From bernhard at alpha1.csd.uwm.edu Sun Apr 18 00:31:27 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 18 Apr 1999 04:31:27 GMT Subject: NT: win32api and win32ui import error References: <7fbcpq$2jb$1@nnrp1.dejanews.com> Message-ID: On Sun, 18 Apr 1999 01:33:46 GMT, hj_ka at my-dejanews.com wrote: >I don't know whether this is also related: when I installed >win32all-124.exe, I got a few warnings: > >"Registration of the (AXScript/Python Interpreter/Python Dictionary) >failed. Installation will continue, but this server will require >manual registration before it will function." I had the same warnung and also cannot run the win32 extentions. (import win32com.client e.g. fails for me.) Mark Hammond suggested to update some DLLs and it might very well be a problem related to old DLL version. (I didn't manage for some reasons to update my DLLs here on my Windows95 system, so I finally gave up. Any Windows Hacker with experience in this speak up and offer help! ;-) ) Mark said, that the following dll and their versions might be relevant: ole32.dll oleaut32.dll msvcrt.dll The following are used, but should be fine: pywintypes15.dll python15.dll kernel32.dll user32.dll You can check the version number in the explorer im C:windows/system with properties. Maybe an upgrade package including these .DLLs from support.microsoft.com can help. Please report back, If you found a solution... Bernhard From bill_seitz at my-dejanews.com Thu Apr 15 11:02:28 1999 From: bill_seitz at my-dejanews.com (bill_seitz at my-dejanews.com) Date: Thu, 15 Apr 1999 15:02:28 GMT Subject: stupid Win-CGI getting started question References: <7f0f0h$pfb$1@nnrp1.dejanews.com> <8DA86302Bduncanrcpcouk@news.rmplc.co.uk> <7f2no0$n80$1@nnrp1.dejanews.com> <8DA9637FEduncanrcpcouk@news.rmplc.co.uk> Message-ID: <7f4v1u$jpd$1@nnrp1.dejanews.com> In article <8DA9637FEduncanrcpcouk at news.rmplc.co.uk>, Duncan Booth wrote: > I didn't say it was impossible to run .py files as CGI, simply that I had > problems getting it to work. Since my number one priority was not to take > the web server off-line at all, there were limits to how far I could play > around with it. I'm sure there must be some way to get it to work, but I > got enough for my purposes. Gotcha. I did some more playing around. No success, but here's what I did/found: When I try to call a .py file I get the "This server has encountered an internal error which prevents it from fulfilling your request" message. The NES error log shows: [15/Apr/1999:10:35:53] failure: for host 192.246.193.43 trying to GET /pcgi/dntest.py, send-cgi reports: could not send new process (File Not Found Error) [15/Apr/1999:10:35:53] failure: cgi_send:cgi_start_exec d:\program files\python\lib\dntest.py failed If I rename the .py file to .cmd and call it with that name, it works fine. I'm defining a /pcgi/ path to point to the location of the python files, so I'm not counting on the suffix to mean anything. All the various CGI folders get mapped to object name="cgi", but again, since suffix is irrelevant, that shouldn't be the problem. I went into mime.types and added the py extension to the cgi reference (note that cmd is not in that extension list). Still get an error, but the log changes to [15/Apr/1999:10:52:57] failure: for host 192.246.193.43 trying to GET /pcgi/dntest.py, send-cgi reports: could not send new process (Error Number is unknown) [15/Apr/1999:10:52:57] failure: cgi_send:cgi_start_exec d:\program files\python\lib\dntest.py failed Does this suggest any clues? I've asked a friend who doesn't know Python but knows Netscape pretty well. Will report back if he has any suggestions. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From garryh at att.com Fri Apr 9 13:37:27 1999 From: garryh at att.com (Garry Hodgson) Date: Fri, 9 Apr 1999 17:37:27 GMT Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <7e30fp$8vf$1@news1.rmi.net> <14085.18282.936883.727575@bitdiddle.cnri.reston.va.us> <7ectjd$516$1@srv38s4u.cas.org> <19990408075544.B983383@vislab.epa.gov> Message-ID: <370E3AD7.16C48C5F@att.com> Randall Hopper wrote: > I believe that was Fredrik Lundh . > > In shopping for Python books late last month, I happened upon his announced > plan to write a Tkinter book. So I slipped him an e-mail query asking how > the book was going and if he had an estimated timeframe (in case it was > close to market), but I haven't received a response. I assume he's just > busy like the rest of us. for what it's worth, fredrik has never replied to any of the mail i've sent him. your mileage may vary. -- Garry Hodgson seven times down garry at sage.att.com eight times up Software Innovation Services AT&T Labs - zen proverb From fdrake at cnri.reston.va.us Tue Apr 20 09:18:38 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Tue, 20 Apr 1999 13:18:38 GMT Subject: Can't work this XDR out In-Reply-To: <371C0CF7.2D1260D7@hons.cs.usyd.edu.au> References: <371C0CF7.2D1260D7@hons.cs.usyd.edu.au> Message-ID: <14108.32430.842541.785124@weyr.cnri.reston.va.us> Matthew Robert Gallagher writes: > Whilst trying to pack a list xdr packer asks for > > (list, pack_item) > > what is the pack_item can't work this out as there are no examples Matthew, pack_item will typically be another method from the same packer object. For example, to pack a list of ints, use this: import xdrlib p = xdrlib.Packer() p.pack_list([1, 2, 3], p.pack_int) I hope this helps. I'll add an example to the documentation. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From holger at phoenix-edv.netzservice.de Thu Apr 22 09:48:58 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Thu, 22 Apr 1999 13:48:58 GMT Subject: sort of multiple dictonaries Message-ID: <371F28CA.2240BB7B@phoenix-edv.netzservice.de> Hi there, perhaps a typical newbie-question: I've got a list of dictonaries like that: mydics=[{'sortit': 'no412', 'mode': 'nothing'}, {'sortit': 'no112', 'mode': 'something'}, {'sortit': 'no02', 'mode': 'something else'}] Is there an easy way to get that list sorted like that: def sortDictonary(aDictonary, theSortKey="sortit"): .... Result have to be: mydics=[{'sortit': 'no02', 'mode': 'something else'}, {'sortit': 'no112', 'mode': 'something'}, {'sortit': 'no412', 'mode': 'nothing'}] Any hints? Ciao, Holger From justin at linus.mitre.org Thu Apr 29 11:45:50 1999 From: justin at linus.mitre.org (Justin Sheehy) Date: 29 Apr 1999 11:45:50 -0400 Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> Message-ID: David Steuber writes: > I would like better python support in XEmacs. There is a python > mode, but I haven't seen anything about evaluating Python code > ineteractivly the way you can with Lisp and elisp. The support for Python in XEmacs will obviously never be as good as the support for emacs lisp. However, it is already about as good as it is for other lispy things like clisp, scheme, etc. One can run a python interpreter in an emacs window. This can be interacted with directly, or you can send code to it from a python-mode buffer. It has served my needs fairly well. > -> ehh, Python? > > It looks interesting. It is more C like than Lisp like. Well, in the obvious syntactical sense, sure. I am comfortable in several dialects of Lisp, but find C to be No Fun. I am rapidly becoming at home with Python. In many of the less-immediately-obvious but very important ways, I find that Python doesn't feel much like C at all. -Justin From ruebe at aachen.heimat.de Mon Apr 26 16:12:12 1999 From: ruebe at aachen.heimat.de (Christian Scholz) Date: Mon, 26 Apr 1999 20:12:12 +0000 Subject: tzname problem Message-ID: <3724C89C.256703D0@aachen.heimat.de> Hi! I compiled and installed Python 1.5.2 on my Linux box. But I have a problem when using tzname (well, actually Zope has): >>> from time import tzname Traceback (innermost last): File "", line 1, in ? ImportError: cannot import name tzname >>> Does anybody know why this happens? timemodule is included of course.. best, Christian From gjohnson at showmaster.com Fri Apr 23 12:03:57 1999 From: gjohnson at showmaster.com (Tony Johnson) Date: Fri, 23 Apr 1999 16:03:57 GMT Subject: Python too slow for real world In-Reply-To: <372068E6.16A4A90@icrf.icnet.uk> References: <372068E6.16A4A90@icrf.icnet.uk> Message-ID: <000401be8da2$e5172430$7153cccf@showmaster.com> I find python syntax less taxing then perl's (IE less lines) You may need to check your python code and see how you can optimize it further... Tony Johnson System Administrator Demand Publishing Inc. -----Original Message----- From: python-list-request at cwi.nl [mailto:python-list-request at cwi.nl]On Behalf Of Arne Mueller Sent: Friday, April 23, 1999 7:35 AM To: python-list at cwi.nl Subject: Python too slow for real world Hi All, first off all: Sorry for that slightly provoking subject ;-) ... I just switched from perl to python because I think python makes live easyer in bigger software projects. However I found out that perl is more then 10 times faster then python in solving the following probelm: I've got a file (130 MB) with ~ 300000 datasets of the form: >px0034 hypothetical protein or whatever description LSADQISTVQASFDKVKGDPVGILYAVFKADPSIMAKFTQFAGKDLESIKGTAPFETHAN RIVGFFSKIIGELPNIEADVNTFVASHKPRGVTHDQLNNFRAGFVSYMKAHTDFAGAEAA WGATLDTFFGMIFSKM The word floowing the '>' is an identifier, the uppercase letters in the lines following the identifier are the data. Now I want to read and write the contens of that file excluding some entries (given by a dictionary with identifiers, e.g. 'px0034'). The following python code does the job: from re import * from sys import * def read_write(i, o, exclude): name = compile('^>(\S+)') # regex to fetch the identifier l = i.readline() while l: if l[0] == '>': # are we in new dataset? m = name.search(l) if m and exclude.has_key(m.group(1)): # excluding current dataset? l = i.readline() while l and l[0] != '>': # skip this dataset l = i.readline() pass o.write(l) l = i.readline() f = open('my_very_big_data_file','r') # datafile with ~300000 records read_write(f, stdout, {}) # for a simple test I don't exclude anything! It took 503.90 sec on a SGI Power Challange (R10000 CPU). An appropiate perl script does the same job in 32 sec (Same method, same loop structure)! Since I've to call this routine about 1500 times it's a very big difference in time and not realy accaptable. I'd realy like to know why python is so slow (or perl is so fast?) and what I can do to improove speed of that routine. I don't want to switch back to perl - but honestly, is python the right language to process souch huge amount of data? If you want to generate a test set you could use the following lines to print 10000 datasets to stdout: for i in xrange(1, 10001): print '>px%05d\nLSADQISTVQASFDKVKGDPVGILYAVFKADPSIMAKFTQFAGKDLESIKGTAPFETHAN\n\ RIVGFFSKIIGELPNIEADVNTFVASHKPRGVTHDQLNNFRAGFVSYMKAHTDFAGAEAA\n\ WGATLDTFFGMIFSKM\n' % i And if you don't believe me that perl does the job quicker you can try the perl code below: #!/usr/local/bin/perl -w open(IN,"test.dat"); my %ex = (); read_write(%ex); sub read_write{ $l = ; OUTER: while( defined $l ){ if( (($x) = $l =~ /^>(\S+)/) ){ if( exists $ex{$x} ){ $l = ; while( defined $l && !($l =~ /^>(\S+)/) ){ $l = ; } next OUTER; } } print $l; $l = ; } } Please do convince me being a python programmer does not mean being slow ;-) Thanks very much for any help, Arne From akuchlin at cnri.reston.va.us Fri Apr 23 14:04:16 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Fri, 23 Apr 1999 14:04:16 -0400 (EDT) Subject: millisecond time accuracy In-Reply-To: <3720A4A6.125DA1C7@OMIT_THIS.us.ibm.com> References: <3720A4A6.125DA1C7@OMIT_THIS.us.ibm.com> Message-ID: <14112.46141.974182.785300@amarok.cnri.reston.va.us> Kevin F. Smith writes: >Is there a way to measure time accurate to milliseconds? > >For example, by calling the time.time() function I get seconds. Is >there a comparable function that I could use to measure interval times >down to at least millisecond accuracy? Nothing portable. However, time.time() actually returns a floating point number, and the Python implementation tries to use the most precise function available in the C library. If your system supports gettimeofday(), which has microsecond resolution, then time.time() will return a floating point number with microsecond precision. Note that precision is not the same as accuracy! Python just uses the C library, so the accuracy or lack thereof is up to the library implementation. -- A.M. Kuchling http://starship.python.net/crew/amk/ They dreamed the world so it always was the way it is now, little one. There never was a world of high cat-ladies and cat-lords. -- Dream, in SANDMAN #18: "A Dream of a Thousand Cats" From ajung at sz-sb.de Sun Apr 4 10:35:47 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Sun, 4 Apr 1999 14:35:47 GMT Subject: Python on Apache and traceback In-Reply-To: <7e4bta$ild$1@paperboy.owt.com>; from kj7ny@email.com on Sat, Apr 03, 1999 at 12:05:16AM -0800 References: <7e4bta$ild$1@paperboy.owt.com> Message-ID: <19990404163546.A3249@sz-sb.de> On Sat, Apr 03, 1999 at 12:05:16AM -0800, kj7ny at email.com wrote: > Before you flame my socks off, I know this is NOT the right place to > probably ask this question, but I guarantee you there is no where better to > get the right answer. > > I am using Python on Apache on Win98. > > Has anyone figured out how to get at the traceback errors when using Python > on Apache? They are not automatically returned to the browser as they are on > IIS and PWS. Around your code with a try/except clause and catch the traceback in the except clause. You can get the traceback by using the traceback module. Logging can be achieved by writing the traceback to a file. I not sure if this is really neccessary because the traceback of Python CGI scripts should be logged to the script or error logfile of Apache. Happy Easter, Andreas -- _\\|//_ (' O-O ') ------------------------------ooO-(_)-Ooo-------------------------------------- Andreas Jung, Saarbr?cker Zeitung Verlag und Druckerei GmbH Saarbr?cker Daten-Innovations-Center Gutenbergstr. 11-23, D-66103 Saarbr?cken, Germany Phone: +49-(0)681-502-1528, Fax: +49-(0)681-502-1509 Email: ajung at sz-sb.de (PGP key available) ------------------------------------------------------------------------------- From spamfranke at bigfoot.de Tue Apr 20 13:29:43 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 20 Apr 1999 17:29:43 GMT Subject: unpickling an NT object in Solaris? References: Message-ID: <371cb8f0.64496430@news.omnilink.de> On Tue, 20 Apr 1999 10:57:49 -0400, dozier at bellatlantic.net (Bill Dozier) wrote: >Hi, > >I created an object running python on NT and pickled it. I have no problem >unpickling on NT, but when I ftp'd the file over to Solaris, I get an >ImportError exception ("No module named __main__^M") when I try to >unpickle it. > Pickling uses a text format which should be platform independent. My guess: Did you transfer via FTP in text mode? In that case, line endings get converted. "__main__^M" seems to point at this. Stefan From mwh21 at cam.ac.uk Wed Apr 14 11:58:00 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 14 Apr 1999 16:58:00 +0100 Subject: forking + stdout = confusion References: <87n20caldg.fsf@spock.localnet.de> Message-ID: clarence at silcom.com (Clarence Gardner) writes: > Clarence Gardner (clarence at silcom.com) wrote: > : However, your first thought also works, with the same caveat about stderr. > : stdin, stdout, and stderr all have the __xxx__ copy in the sys module > : (which I was not aware of). > > Mea culpa. The os.close() *is* still necessary. Is there yet another > copy of these file objects? I tried to find that function that returns > the reference count, but don't see it in the manual. It's sys.refcount: Python 1.5.2 (#2, Apr 14 1999, 13:02:03) [GCC egcs-2.91.66 19990314 (egcs-1.1.2 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> sys.getrefcount (sys.stdout ) 5 Five! I don't know where all of those are... > -- > -=-=-=-=-=-=-=-= > Clarence Gardner > AvTel Communications > Software Products and Services Division > clarence at avtel.com From zigron at jps.net Fri Apr 23 15:54:57 1999 From: zigron at jps.net (Zigron) Date: Fri, 23 Apr 1999 12:54:57 -0700 Subject: PythonWin/ActiveX-Script Question Message-ID: <37214562@news1.jps.net> I recently installed PythonWin/et al, and went into the win32comext/axscript/demos/client/ie directory, and found that basically none of the demos worked at alllllll. After fiddling with 'foo2.html', I found that all the references to 'MyForm.whatever' or 'Form2.whatever' were resulting in NameErrors..and that if I put 'window.' onto the front of all the references they then worked. I'm just wondering if that's how it's susposed to be? --Stephen From phd at sun.med.ru Fri Apr 9 06:15:26 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Fri, 9 Apr 1999 10:15:26 GMT Subject: two questions In-Reply-To: <370dbbe7.71248459@scout> References: <370dbbe7.71248459@scout> Message-ID: On Fri, 9 Apr 1999, Chris... wrote: > Since I am new to python (ver 1.5 under NT), these may be silly, > anyhow: > > 1) How can I copy files with python? At first I planned to run the > DOS-command "copy" from python, but couldn't find the right function. > Second, I thought, there might be a python command to do it. Until > now, I didn't succeed. Look into shutil.py module. You need copy2() function. > 2) Is there an way to mimic Perls > perl -p -e s/pattern1/pattern2/ > command line? Although you can run python -c "script", python usually intended for scripts, not for perl-like one-liners. > Thanks a lot in advance > > bye > Chris... > Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From morse at harborcom.net Thu Apr 15 10:07:53 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Thu, 15 Apr 1999 14:07:53 GMT Subject: overloading ( was Different methods with same name but different signature? ) - overloadinginpython.tar.gz (1/1) References: <3716909C.D8D1B372@fedex.com> Message-ID: <3715f2b9.74013415@mail.oh.verio.com> begin 644 overloadinginpython.tar.gz M'XL(`##R%3<``^P\_7/;-K+]5?PK4+=I1)F2)?DCK15[)G&#2M_\1GTMW88V]D9;@_ZSW:V!MBRN;GS'>M_3:+T M,\^%ES'VW54:W`OW4/__T>?LX]&;O?PFG`YZ0PM?CH]>[G6/-^9YMA$EOA=M M1.%X0P-87A3MLB1B at N?"LN(DF^U:K1_;.-!FW>!2S"+6]=?763>_](+DAG73 MA;A,8M9-V`<8>[>9%[:\].T;.J%5FL*PWYL'[P^?O'FS"8$&0_8/ZU6 MJWO48_"O1R]R-B#35GU$:QC[T3S@&W*Z06];=JJ%P!**C at T_B2?A5/7W>M at K M7PP2_5[^`,'X1J,B9$ZZL*P$6(,;L`XT M^O`):U,H.W)IG3J)K,>S+,G0,EA6R_I/2^FWYVL]%8'^2G,\8/_9L\%`V__M MS9TAV/_!<&?SF_W_*YX?E.%DSW,1A$GO-W=+;ZVKY,P ML-DN"]I]V_K$TBR,Q:2]MAKVG_&:/6)W*]#!:!9*?.&#^)X0-@<&$$)$SPS` M:R^:)[( M3,.P`-:33ZM"@"?H:;[08C2I>JOU)/9FO)US\3NVVXWVHPJ3+P&9]N2;\?B3 MCYE1?JTY'JK_;.ZH^L]FOS^0\?]@^YO__TN>29;,*LD_"V=ID at G6L:@K%Q"1 M3LM&]27CEB46*5?=>]#0\Y-9&D:\G:VYY__M7JR[;?ICN[W.F at TQ<,`G;,K% M>^Y%+[)IWO;@P]ZU4`0(%6`YOZ#7#$"PMVRACTF2,0]TGF'?KM42V0(^:3Q` M>CUQ&>;J'?'UO#3E<=`NZ>S-/.%?MCV[-\V2>=H>V+:$UQ,60Z"=W_H\%;LK M$`*2%6,]VU*+H`1`S%/@"8VW'?6FAP#D.'?+,A,9MR#T<3F?"(F<:]MV,"4R MJE/E&&T?'0D/<(U at UP:,QJG^L@=QYXX%EA_W;YE<,-#1Q&&=^FXZYBXN;;O< MSQBZFAEP3C at N3$8">Z-%&P8YC.:D[7;L=8.9!:)3D?4(5^,$?SI9^G_X+-];%8A[T^.CXT+4HA6=")_1]` M;QE6EMF-ES-O+A(PRZ'O1=$"#$7,,PCC`C9>L%V$/@./$X63$)H^9FABP0?$ M`3N*!<\FGL_9&SD$?(,\AL!!O_,L#Y.8#7I#UGXY#Z,`8 at J'O@HD3X"$'8SGS0E@!A,">+V@: M_/2\21CS_^RKV`9[MLP[_.LR01&T at 0G8^YY2F3^M/+;Z;.-0 at A_4>2MC'H M;PQ!^C9W!\]V!SO`:.^/B"_8X6W*?L0)5F#R)],E[?$3X!3NM9^`(+"8\T"* MCQ=@GI2%WAB at HC"^PA"-=IN3V,E#HA`U"`(^^.R!&3XHAH!.0A@(2``;*BA@ MOF&`(T`1EH,13>#!/H&7[BG"7D1Y4M*4SU,,%'%F)(]BMS$J(K:H8ZIY#*QD M'P%S:RT`%8&)238*VZWX\.MD,;:`EX'Z4I]QO!U$DY[!!$,:$BTW_\XN35`T#:7)WE_# MG7X\?BZQDPZF%#]/\3M+YH)!S*8CG6F5(H:BFS\::TW.PN16`VV-/'5D--J9 MI+)8.(D\S!0_64I(0^!V'[E-'?!"?ZE!'<7!R+4ZM]DGMD:*=W.)CKA]W=U' M*3\/+VR5MYNCG^1K#BM!NOO(&AH.-*ROJR^3*AH3@:-FNZN1Q>[HI+&4E?YC MRL"2"(#A0?-B43%&AB%:L:`K)RF023>(A%=*`GIU22"$I8)""I(BI2`8?!S% M($X9\[V<.^R&/]4A:$*ABR<(MPXX$"$B@%@#8FMR?L"2!`.5^6P,$05HN8P( M'TO\/D>O%7=6B2$9]$XL=;PB>=0C^"P]'PQ_OAA9]XD52 at DLS9^E[;I`.;'- M]@"E!BV$HMTQ04OOH23PSI1#?,F5A"%)SMK!DF(_H5P#;"F$;SV0S=B6'NHP MR]PS+I2)@O=;WST!P@[Q(I&#V$Q1/?GM^/@1I75)6'.U'=)B5:4UOT=:>X\D M,_<:K/RS9,4Q9"V5 at E.7E9HH?46Y*8.+]#\K.`.2&LG92PZ)RNGB`Q@%Q2C% M3#(36$,%Z:K&,>[1R=&']D]RD(L?-F,G"63:NU)*@H3G\5/!;I+LBJ&P)#,. M88P/:0D8?MC51H3`OLH#4'VLMJXI at F"Y*Q^@$>D at CXGO-$<>_L&328.$V(XY M\*67 at X`AL![8OVMD-08.C1\JP M03TT95L9S8:AJL?!@?"=X8LQ,%\Y,#<&GBT-_,Q%BM3%TPS, at _6,&+8 at XQYHA+=< M15!6"@/I>0[-`$:D6D9V8WA(RKEB?J.XI>]/6:PIY^AD/)]'0ANSXNUT\9;/ MW)/#CPW:X`S(-AAJWTO&KE)_4\M':L6G>`)4,1,J=I"PDNURZNZ^@R174.RIFJ M:^[NJ[0)FG>VS';5V%Y*Q6PP4:B6[9VMCFDZ#!C;KF,Z[U_4)X859WSBQ\4N MP!K_?G1R\/[P==M,*YE>:VF8RWZS^ZXB&KC_4BB\(-!"87BYPO>A8Z+CM7LR M7^>>O#>U5XL995?7FHNU3INE(ZME%0&YW)[]/0S@]:YT!]I97IM;->R4KR/= M?<^.9=*2:H_LE*/OW\)*LH"^&V.ITGWK#"$7`<\R9PW9#<[M-43/$:-;W5A* MII*2%X5_H%:KBJ"\"M+3204^_#84[8'A\?&?C at LT>RZ:%EA(9.-:Y$J6$,F0 M!-%).2B1B"SB<9LRIW5)#\8SZ:*]`H=3)%D-`%J0Y,DD?5T!F9>0>162(&3P MT\0/F8I9CU9\EL_GE*#IYP at B>[#XO+54?-;U9S5Z=<&YJ;B+\32)6C:/NR*$ M7233"3&:?T6I6(?-.!XRA/FLQ^BL9)+`WMX@%AV:J]+SM1=&Y'9V%0UD,M[S M:9B#OWDK_9P2D20+ISA383KXC7REZT)@-2"I%-)B*`4BC/1HC+K(C0.[RHVR MFU!QJ!C9I[*%#D([,6,_WL>0M+!P6Z1KV*8 M\@KL3%)Q1MN at BA$2&9BU2= MKX'3#NI(8'?QI@?(5'@-O72_2QX/C2$?+][!:!RLK]L%WF)?WGI7_!2R&LYH at J:9D4%B6,H"T8L3BZ at E)@]&@JSS>X)8]X M`-+GM)-*Q-Y!$C/W,?@HL)#+4.M#C/](YB`2,9T>IH@$]KW4R3&>.LI*C#($ M($N`?\TP%FO`;,2TP#H.4I&C(0]"(`8RA056?;`U+(YM"1%`D\;C"3$J7:^P M.54*$`9_6D4RC&<3]-,PF00ZL,?"."?%=8Q)+>4W*?-X>LIFL*MA5]UXY/%U MF"4QGC?B"C-.=7KB(Y*_F(V32,NX#%]ZCWP<2N=&R^>5__L/+#!'(%MOJ.O< M!\FB^+E^O'`&4@)*0^%U>;91>>1!QW)^\DJ;4IT;UX9MF&<-Q@,6MHX-T1WS M>`I&O4T2@.TTO9E+7P`-P4;>B8;'' M$(8"75%HV/?J8N],/#)5*VGP46KOVX=/*YB%F]M`SADTS\&9@*W"7_B,P^I( M6IVY+-TNTB76F\Q"(X7@):DEN@;)H)T_'V[O7(PJZ-Z`A8M+5UN7CY7HT+OS MH(H0T!V6CKE)U`K>'R";2^Z?87&H/!:H%?TT>]YZMTRF2#I*-P"X`&012J4(_B].&%@)NH" M4>"406F:Y.K`'`^G*":JXC0U1U"D64Y4457]0C!R&E7AL)Q0XBKB.U]+ M`[(/92;0H5K],HM[\.+ at U\.SH_\Z9.SGAIZW+\[^QEC_]IE)7R&&Y=MY%1ER MI\XZ at CL"H0JLX=#%0B&`R+$S=Y MW/`2HG2(2,ZXET%,>,^2$(U)_A5?+*_'+GU:Y\K,7`%Z5#.1G6`%^489!(K)]`+Z.Z#1!7DZZ1%Y2R%"6S,5^JU.?E#Q,=+IUAYDKJT6-)[IR,&=*:U M at 3>$J'#,B?0[8N"15"9,([G[$: M.B+&JY#R3(B%['FQOA$>UMCU\R!SAO/PHD%*4?/7?1#L*/Y1=9`1*5XW-XHTQ6[9Q$`]%5V:"GT<=4 MNH<32$S#]$TUX2N,DGU4'PJ&86PI"D&B?A',TLJ MNWF0AA!J0KV1DM83$,,TPI1)DM at .8W*3X%*2#))V6Q$MFJQHM0:W)"YB4+!= MK42W5ID^,+B.+[454;]FN^EJ+7-'P!!4N^HA at C)P6`M8RI55BKO:G%6K$*Y? MM=1N/3FGG5+VGIK=2WY[/MBY8'O0\>EI_ZG#G@[P8X@?F_BQA1_;^+&#'\_P MXV?\^.4I_;+BJ8R4C+;J8ZOE7-UX6Y#+6$>$XC/#*MAFKN51 at Q0O4N%ZT+(;4 M,<)8N6:.6X;]=X<`R,3;2"_W>L*MJ_8S] MF^)S';=5XXK"23JLP5$X17AOCYA$5H\P0-1D<*%G8T:J%N)Q2!&#R/Z[&A[= MW1T at PGV)&-2^"1_^^-=FC7'+^>#"OJ#_ at T?S-,/M;85_4,>O(SM%]QC[#8OW$3ILV2L5Q\NE7A;9*VI/BRD8%:RIQ-+,#>4R/VL= MBKN4."KX91= M'CP$1_LBTAJ8KL;5&AK, at EXI5B:X6`XJ'[)W38;NRRQ<2RVA)EJ%[3-4A\C\ M=3:;]=BK,,#KE"1VH3(,=#U`B]F=:;-,:/RU(]6#DTE=F5!6>X6C1'Z8)27E MX8IKY\NGHFKR1GY5Q;E(.I2SQUY:+8*N^]T M[%?,3HF at .CE)N4\_B(7IWB0)Y`!ST&A_^GO6/M:>,(]BO^%=>+TKT+)^,S+\D82T!H at PJ!4M*JW8607E!MI59>UV at 8@E`;K\G&0132K[3C"_R8^!E(:)5:OCRY,/7+F:E$GC!-Y(N,I8B$/# M!"YDP'1^INS'@N\/[C:N_TH.CJ_3WA$YI4#>D=_(9-6'A84M,+;:QXA$FV<& M5FY"IX;D'IR]/\.YBXS"2$J1;[EIN%(6:*;D9`B:T%UN\DD1^*D?,3$)JY3* MJBPTP5+"<_U6D#X!%$RX]70G,M>(<4APBE)%,S:H8NCA;:958\O(8:2$IK?ZZFHVRB8< MT1LLV3W4LP_J:5G)/D`_E=L5K981?2&^.78L56_^N3U'1\S0]=56=/^K/0N/31U3YU-;YB.MLRIJO M]7*/KI*_[EEE/.6XM-VAJVAS>&LX5[I>H3)'4&U?HR+4,9CYB#<%6#332-_#"I;X\9<\*F-A M-*5"7AK=99H/-09&LLBRS(,H3+>4QD_(6ZS0SW;9P+;G2D<\&= MQP[0W"-;X\!>94:C/01A=?FJ&S_\`'WTZ_[I,+B0'9-M]\,&;87F/E1GIM=7 MICD<[(W[3$OK=ZK40O7>O=WWYMH+Y:)'N53KH]'4[D<[;=_M-UJ8TEX#G1YW=`W;^S51:>"1`'=8%4L%G(OJHC\7H^, M@`QI6I%,H*F7 at _W[T^4K$?G)'<\"JB\>&3SV24W(]^&5&F81;70]B&/JL&02X_ at FY)Q$ MBL-B)D']YI8U//5A\#H>G/9:OBOCP)9V6"#MT,N7M%4DY["H2/ZQ]!#[PO&P M]..[MUM'._MOO=\/-PX.M@]_S?';E(?WV\;ASL;F[O9XO*=NF#,*TN?#XSW^ M\-T]YO^K^OVG^DJ=WO]$QZ M_VNE5E/]_V*=WO^*%\OW?V83RO=_GG8(>&KYZR>HN\/CQ^(Q\?W/Y56S_H]7 M^?VO4E:_]OB=I_;:7<_YM)F.X at 7X$)Q%D?+S2(DU2HMT+W/PVO/@V+]HE at A*6E MP+6:`4B3\HJ&'QZ?R!7*`*'15T1#C;TTQ at KX>^4%@U=+.&Z?ISTG61A:GZ_[ M0[7>26W>:OB&05E[$H$D!_-\,`[72[UY3_PY$%X1$;H^=-X?J"P,"BG1Z@@* M/L"[HFDAP6^AQ7DLHC at X'Y&+HC0.+4E`32R92J`/E_W!6;]WWI6[E=>XJA1` M12N'[(!ZUT7;QK0YO2[LF8K0N<.;:.M2PX)P1)6ZY$UKW>O!*!-<0B$")`8Y MN!8A@!UWT=1[#B>6Y"*.P*7R$*7C;I=M-()N:$5G:A<=N2M]I3L:]%50U2`.)-[2A6INO@*B%2-?@?KF M"J&=+%ZFPO=>>K<5G3=!*"_34'"\RM7%1\P43VLY9P at XO#J/:)7/,XB(3U,! M'C,'B7QUC5Q+,#244\NS:MHH_43-I9DZ%E?BKGNU1K:F)98G$&F#O/(,0 M%R*(>8Y4-2SSU*YUH+T(VGV1!'7/DD/$T^L!I7QJS3)$U9)$N9I-;Y/A&X:5 M?/*D&:P4$5T>%Y[*E5MOT$/)6D>PJH#_JO(Q(L&(LP%^C1!=+ZXPW6@[B[*+ MXF(M5DR`W]G at +=](E)V]HMIMRUEAQXZB:26VQ/[I4.))`@"$D=`Y(X\J]60U M8*H`L93KWA+8)SBY,.:`2F0;5Q[4 MO;)>("TC:2!QE@/!G+BD$ FXF@=\Z]O<64H0QG*4(8RE*$,92A#&0"@```` ` end From tjreedy at udel.edu Wed Apr 7 21:49:00 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 8 Apr 1999 01:49:00 GMT Subject: Xbase++ preprocessor implementation in Python References: <37097A3A.F772205@magna.com.au> <7eehg9$3at$1@news.udel.edu> Message-ID: <7eh1uc$b9e$1@news.udel.edu> Sorry for the repetition. Glitch with newssite. TJR From jkraai at polytopic.com Thu Apr 29 01:01:38 1999 From: jkraai at polytopic.com (jkraai) Date: Thu, 29 Apr 1999 05:01:38 GMT Subject: Maximize Benefit when Purchasing Learning Python References: <199904290028.SAA20624@shell.rmi.net> Message-ID: <3727E7B2.616A87F0@polytopic.com> Mark, I'll make the check out to your wife if you promise not to tell mine. All fun aside, can somebody give me a substantive answer? I'd really like to make sure that somebody I 'know' is the middele man--or middle wife. I really was actually looking for an answer to my question. I'll gladly send you a check, but I'd rather not do it explicitly, rather as a part of a purchase of three copies of this book to evangelize my coworkers. Help me do somebody a favor & let others know how we collectively can do _you_ a bigger favor than merely buying the book. I tell you what, if you've got the stones to send me your address off-list, you'll get a check. If you think Mr. Ascher is worth it--and I don't doubt it for a moment--if he'll provide me with the same, I'll send him one, too. If Chris or Tim'd ever write a book ... Guido? c'mon. Does anybody know what Guido desires most in life? I probably can't buy it today, but it'd be nice to know so I could taunt him with little plastic replicas. somebody-stop-me'ly y'rs, --jim P.S. I _like_ the cover. Mark Lutz wrote: > > David Ascher wrote: > > On Wed, 28 Apr 1999 jkraai at murl.com wrote: > > > > How can I help whom when purchasing Python books? > > > > I'll dare to speak for Mark, and say that you should feel free to send > > either Mark or I (or both) checks for any amount whatsoever. Skip the > > middleman. Save trees -- don't buy the book, just send us cash. Don't > > hesitate for a minute. > > What he said. (Though you could save another > middleman by making the check out to my wife.) > > --Mark Lutz (http://rmi.net/~lutz) From donn at u.washington.edu Thu Apr 22 20:18:03 1999 From: donn at u.washington.edu (Donn Cave) Date: 23 Apr 1999 00:18:03 GMT Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> <371F9D0C.4F1205BB@pop.vet.uu.nl> Message-ID: <7foe7r$15mi$1@nntp6.u.washington.edu> Martijn Faassen writes: ... |> 4. access to class's members using "::" |> e.g. some_class::static_value |> e.g. some_class::static_func(x) | | Python does not support static methods (or 'class methods'). Usually a | module level global function suffices for this purpose. | | A static value can be created like this (besides using a global variable | in a module): | | class Foo: | self.shared = 1 | | def __init__(self): | print self.shared Just a nit-pick on this particular item - I tried that already, a couple of days ago, so I know it won't work! You meant to say, class Foo: shared = 1 Now a couple of further observations. Per the question, yes, that variable ("attribute") is accessible in the class scope: print Foo.shared As well as in the instance scope, as shown in Martijn's example. However, it may come as a surprise that if you assign to that attribute in the instance scope, for example through "self" in a method, what you get is a new reference bound in the instance scope, and other instances still see the original class value. ... def privatize(self): self.shared = 0 f1 = Foo() f2 = Foo() f1.privatize() print Foo.shared, f1.shared, f2.shared 1 0 1 It's not much like C++ here, but it's uncanny how it reeks of Python! Namespaces, references! Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From dwelton at cnet.com Thu Apr 15 14:12:22 1999 From: dwelton at cnet.com (David N. Welton) Date: 15 Apr 1999 11:12:22 -0700 Subject: REPOST:pretty please - Help re libpython1.5.so References: <3714B9F9.30285D74@earth.ox.ac.uk> Message-ID: <87btgpah2x.fsf@padova.cnet.com> I think it would be really cool if the default distribution had a nice libpython*.so included, as Tcl does. I'm not quite sure Python will ever be quite so simple to use as an embedded language as Tcl, given that it is a bit more complex (and more powerful!), but being able to do: gcc -o foo foo.c -lpython1.5 would be a nice step... Ciao, -- David Welton dwelton at cnet.com 415-395-7805 x4150 From phd at sun.med.ru Tue Apr 6 08:15:32 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Tue, 6 Apr 1999 12:15:32 GMT Subject: mxDateTime in Python distribution In-Reply-To: <19990406070255.A867135@vislab.epa.gov> References: <19990406070255.A867135@vislab.epa.gov> Message-ID: Hi! On Tue, 6 Apr 1999, Randall Hopper wrote: > I'd like to add my vote toward integrating Marc Lemburg's mxDateTime > functionality into the next Python release. I vote against it. Not that I am against mxTools - it is perfect library, really. > I needed to do some date/time arithmetic recently and found that core > Python didn't have this functionality. I was a little skeptical about > using a seperate extension for portability reasons. There is always some need for something more. Do you really want to include every bit of code into the Library? It would take infinite time to download and compile Python distribution if all possible modules and extensions come in. I want to keep the Library as little as possible. Download, compile and install only those extensions you need. > Randall Oleg. ---- Oleg Broytmann National Research Surgery Centre phd2 at email.com Programmers don't die, they just GOSUB without RETURN. From jefftc at leland.Stanford.EDU Tue Apr 27 17:54:03 1999 From: jefftc at leland.Stanford.EDU (Jeffrey Chang) Date: Tue, 27 Apr 1999 14:54:03 -0700 Subject: JPython 64K limit on source-code size? In-Reply-To: <7g4mgd$uo7$1@nnrp1.dejanews.com> References: <7g4mgd$uo7$1@nnrp1.dejanews.com> Message-ID: [Monty] > I have a JPython program I'm using as a test suite. It's generated code and > around 74K long. When I try to run it with JPython I get this message: > > Traceback (innermost last): > (no code object) at line 0 > java.lang.ClassFormatError: org/python/pycode/_pyx0 (Code of a method longer > than 65535 bytes) [...] > If this 64K ceiling is indeed a basic limitation of JPython because of Java, > I'm wondering if there is an easy way to split the file into pieces in a > chain-like fashion. Any ideas? Yep, this is a java thingy. From the stack trace, it looks like you have a method that is >64K long. According to Sun's JVM specification, the maximum code allowed for any individual method is 65536 bytes: http://www.javasoft.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#88659 That limit includes any code that it may have generated to initialize variables that you declared. For example, initializing a large array of strings as a class or instance variable could get you up to that limit, if you're not careful. It doesn't look like you will need to split up your file, but you will need to either split up your method or load your variables at run time. Jeff From jeffp at crusoe.net Fri Apr 16 21:12:22 1999 From: jeffp at crusoe.net (evil Japh) Date: Fri, 16 Apr 1999 21:12:22 -0400 Subject: OrderedDict.py v1.00 Message-ID: I have attached version 1.00 of OrderedDict.py. I have not yet finished the more extensive documentation of it, but I have the module with pretty good __doc__ strings, and a test.py program to make sure it works. Let me know how you like it, what you think should be changed, etc. This module has potential to be useful. :) -- Jeff Pinyan (jeffp at crusoe.net) www.crusoe.net/~jeffp Crusoe Communications, Inc. 732-728-9800 www.crusoe.net -------------- next part -------------- A non-text attachment was scrubbed... Name: OrderedDict-1.00.tar.gz Type: application/octet-stream Size: 2020 bytes Desc: URL: From ajung at sz-sb.de Fri Apr 23 12:24:34 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Fri, 23 Apr 1999 16:24:34 GMT Subject: Python too slow for real world In-Reply-To: <37207E20.21D3CCDD@appliedbiometrics.com>; from Christian Tismer on Fri, Apr 23, 1999 at 04:05:20PM +0200 References: <372068E6.16A4A90@icrf.icnet.uk> <37207E20.21D3CCDD@appliedbiometrics.com> Message-ID: <19990423182434.A9539@sz-sb.de> On Fri, Apr 23, 1999 at 04:05:20PM +0200, Christian Tismer wrote: > > Summarizing: Stay with the Perl code, if you need it so fast. > Perl is made for this real world low-level stuff. > Python is for the real world high level stuff. There's nothing more to add - just some remarks. We are running several production processes that are mainly based on Python in several ways - we use use Python as middleware component for combining databases like Oracle, workflow systems like staffeware, Corba components .... Are systems consiss of several thousands lines of code and the code is still manageable. Have you ever seen a Perl script with a thousand lines that has been readable and understandable ? And speed has never been a real problem for Python. Ok - Perl's regex engine seems to be faster but not the whole world consists of regular expressions. Python is in every case more open and flexible for building large systems - take Perl to hack your scrips and build real systems with Python :-) Cheers, Andreas From trashcan at david-steuber.com Sat Apr 10 20:53:18 1999 From: trashcan at david-steuber.com (David Steuber) Date: 10 Apr 1999 19:53:18 -0500 Subject: Internet Robot References: <7ehe9m$hbs$1@nnrp1.dejanews.com> <7emldl$rh9$1@nnrp1.dejanews.com> Message-ID: gscot at my-dejanews.com writes: -> David Steuber: Thank you for the reply (and Thanks to every one that -> replied). It was a big help to read over the rfc 1945 and rfc 2068. It is the -> first time that I have every looked at one and they are pretty informative. -> I can now POST my request but the server is asking for authentication. Hmm. You are posting to a URL that requires authentication? The way the server requests authentication is by sending down the following headers (for basic authentication): 401 Unauthorized HTTP/1.0 WWW-Authenticate: Basic realm="WallyWorld" To deal with that, you have to send up proper credentials. The header looks something like this: Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ== Where the last string is a Base64 encoded userid:password. See section 11 in RFC-1945 for details. -> You mentioned that it might be helpful to capture and look at the client's -> out put. How do I do that. This can be tricky. Idealy, when talking to the server, you want an HTTP client that will show you all the headers. When talking to the client, you want the server to display all the headers (or send them back to the client). I've always done this the hardway. You can actually talk to an HTTP server with telnet if you are desperate enough. I don't recomend it because one typo and you have to do the request over again. Other people responding mentioned a url package for python. I would take a look at that to see just what it can do. It may make the job a lot easier. -- David Steuber http://www.david-steuber.com s/trashcan/david/ to reply by mail If you don't, I won't see it. "The way to make a small fortune in the commodities market is to start with a large fortune." From faassen at pop.vet.uu.nl Thu Apr 15 13:35:24 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Thu, 15 Apr 1999 19:35:24 +0200 Subject: Is there a 'make' replacement written in python ? References: Message-ID: <3716235C.221B9F11@pop.vet.uu.nl> Markus Kohler wrote: > > I'm looking for a replacement for the 'make' command While the Python distutils don't fully intend to replace 'make', the distutils do have code for platform independent building of C extensions, so some basic make facilities are included. I'm sure that code can use more work, so you're very welcome to join the distutils SIG if you're interested. :) Inspiration from other make replacements like 'Cons' is of course very welcome. Regards, Martijn From fredrik at pythonware.com Thu Apr 29 11:36:04 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 29 Apr 1999 15:36:04 GMT Subject: python and SOCKS firewall References: Message-ID: <013301be9256$07e03710$f29b12c2@pythonware.com> David Steuber wrote: > I sympathize with the fact that you are stuck using Novell GroupWise > for USENET. However, could you please find a way to limit you line > lengths? and we all sympathize with the fact that you're using a newsreader that is smart enough to understand quoted- printable encoding, but not smart enough to break long lines... From tismer at appliedbiometrics.com Wed Apr 21 06:51:24 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 21 Apr 1999 10:51:24 GMT Subject: WINNT/9X patch for errors.c References: <371CF528.532DB5C@appliedbiometrics.com> <199904202239.SAA11014@eric.cnri.reston.va.us> Message-ID: <371DADAC.AF549EC0@appliedbiometrics.com> This is a patch to errors.c which gives the correct POSIX error messages for WinNT/9X. Reason: os.listdir("nonexistent") gave OSError: [Errno 3] No such process Problem caused by: The standard function strerror is supposed to give an error message for a system error. Under Windows, these are DOS messages, not POSIX. They don't match completely. Solution: Instead of strerror, FormatMessage is used. This function has an option to return standard system messages. This will now give the correct message. The messages are those which appear to be natural under Windows: kernel32.dll defines them all in the default language of your operating system Guido van Rossum wrote: > > Christian, > > I just tried your code on Windows, and I noticed a missing feature. > Python now adds the filename (when it is known) to the error message; > your code doesn't do this. Solved this, too. My code was ok, but the filename moved into the next line. The returned message contains a CR/LF sequence and also a dot. I'm removing this now, and it looks good. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 -------------- next part -------------- *** /w/orion/install/cvsroot/python/dist/src/python/errors.c Mon Dec 21 19:33:30 1998 --- /w/orion/install/python1.5/errors.c Wed Apr 21 12:13:40 1999 *************** *** 49,54 **** --- 49,59 ---- #endif #endif + #ifdef _WIN32 + #include "windows.h" + #include "winbase.h" + #endif + void PyErr_Restore(type, value, traceback) PyObject *type; *************** *** 291,297 **** --- 296,319 ---- if (i == 0) s = "Error"; /* Sometimes errno didn't get set */ else + #ifndef _WIN32 s = strerror(i); + #else + { + int len = FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, // no message source + i, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &s, + 0, // size not used + NULL ); // no args + // remove trailing cr/lf and dots + while(len && s[len-1] <= '.') s[--len] = '\0' ; + } + #endif if (filename != NULL && Py_UseClassExceptionsFlag) v = Py_BuildValue("(iss)", i, s, filename); else *************** *** 300,305 **** --- 322,330 ---- PyErr_SetObject(exc, v); Py_DECREF(v); } + #ifdef _WIN32 + LocalFree(s); + #endif return NULL; } From aahz at netcom.com Sat Apr 24 12:01:17 1999 From: aahz at netcom.com (Aahz Maruch) Date: Sat, 24 Apr 1999 16:01:17 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <37215EFB.433AFCA6@prescod.net> Message-ID: In article <37215EFB.433AFCA6 at prescod.net>, Paul Prescod wrote: >Justin Sheehy wrote: >> >>> (And... How about builtin regexes in P2?) >> >> In all seriousness, what reason do you have for making that >> suggestion? I am willing to believe that there might be a good reason >> to do so, but it certainly isn't immediately obvious. > >One benefit would be that the compiler could compile regexps at the same >time everything else is being compiled. If you really care and if you're going to run the same program multiple times, just use pickle. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Hi! I'm a beta for SigVirus 2000! Copy me into your .sigfile! From tismer at appliedbiometrics.com Fri Apr 30 03:57:03 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 30 Apr 1999 07:57:03 GMT Subject: Read MS Access 97 *.mdb files with python?? References: <37287369.D6E67313@t-online.de> <3728867D.94B5BBF9@appliedbiometrics.com> <3728A903.CF75B41A@pop.vet.uu.nl> <3728B7DF.80E23481@t-online.de> <3728D832.AA4B72A@lemburg.com> Message-ID: <3729624F.CFF4E6AF@appliedbiometrics.com> "M.-A. Lemburg" wrote: ... > For the file format try: > > http://www.wotsit.org/ > > Don't know whether they list it, but if they don't it's likely > that it's not published anywhere. Just a note: They give info about the .ldb format which is ridiculous, just the format of the locking files, half an hour of work to find out. The .mdb format is to my knowledge documented nowhere. I know of exactly two companies in the world which have tracked down this format to an extreme extent, and who are able to recover a broken database file. I once tried this for myself, but this needs hundreds of hours, creating thousands of databases, modifying data and comparing files. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 jeremy at cnri.reston.va.us Thu Apr 15 18:44:31 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 15 Apr 1999 18:44:31 -0400 (EDT) Subject: HTML Authentication with Python In-Reply-To: <7f5iru$rlm@news.acns.nwu.edu> References: <7f5iru$rlm@news.acns.nwu.edu> Message-ID: <14102.27498.772779.5941@bitdiddle.cnri.reston.va.us> I don't think you want to do the authentication in Python at all. Instead, you need to configure the Web server to do authentication. If you configure the server properly, users won't be able to run your CGI scripts until the server has checked their username and password. Jeremy From guido at CNRI.Reston.VA.US Sat Apr 10 00:07:16 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Sat, 10 Apr 1999 00:07:16 -0400 Subject: Possible problem with timemodule.c [1.5.2c1] In-Reply-To: Your message of "Fri, 09 Apr 1999 21:40:18 EDT." <199904100140.VAA11860@python.org> References: <199904100140.VAA11860@python.org> Message-ID: <199904100407.AAA02004@eric.cnri.reston.va.us> [Andy Dustman wrote] > [I decided not to bug Guido directly with this...] Hehe, I scan the newsgroup digests for the string "1.5.2" so I found your post anyway :-) > My compile is completely clean except for Modules/timemodule.c: > > ./timemodule.c: In function `time_strptime': > ./timemodule.c:429: warning: assignment makes pointer from integer without > a cast > > This is in time_strptime(), naturally. The code immediately before this > is: > > #ifdef HAVE_STRPTIME > /* extern char *strptime(); /* Enable this if it's not declared in */ > > On Linux, strptime() IS declared in . However, I find nothing in > timemodule.c that would cause to be included for Linux. configure > does find strptime and does cause HAVE_STRPTIME to be defined in config.h. Rest assured, is included, indirectly, by mytime.h or myselect.h. > This is unlikely to be a "showstopper", but I thought I would point it > out. This may simply be a Linux (RedHat 5.2) problem. The more I look at > , the more I lean towards thie conclusion. The prototype for > strptime() is not defined unless __USE_XOPEN is defined. The solution, > however, is not obvious. This analysis sounds right to me. (Can't test it -- the only Linux box we have here on the network was powered down because it was overheating. Too much press attention for Open Source I guess :-) Perhaps __USE_XOPEN could be defined somewhere by the configure script? Anybody suggest a good spot to do this? --Guido van Rossum (home page: http://www.python.org/~guido/) From news at dorb.com Thu Apr 29 10:45:41 1999 From: news at dorb.com (Darrell) Date: Thu, 29 Apr 1999 10:45:41 -0400 Subject: Fatal Python error: PyThreadState_Get: no current thread References: Message-ID: I was just trouble shooting a problem like this. I was using python.exe and a xxx.pyd. The xxx.pyd had debug turned on and should have been named xxx_d.pyd. When I ran with python_d.exe the "no current thread" error cleared up. If your lucky the Windows and Unix ports have this in common. --Darrell Timothy Docker wrote in message news:m4izp3rc21l.fsf at macquarie.com.au... > > > I've seen questions related to this error in dejanews, but no > definitive answer. It seems that this error can indicate a variety of > misconfigurations. Here's my situation: > > I have a program written a while ago under python 1.4 that I am trying > to run under python 1.5.1. This program uses Tkinter, and makes no > reference to Threads. On my Solaris 2.6 machine here I have > > python1.4 - compiled without threads > python1.5.1 - compiled with threads > python1.5.2 - compiled with threads > > After a lot of reduction, I ended up with the 10 or so lines shown > below. If I run it each of the installed versions and press the > displayed quit button, I see the following > > | qad16:tools $ /opt/python/python1.4/sunos5/bin/python test.py > | qad16:tools $ /opt/python/python1.5.1/bin/python test.py > | Fatal Python error: PyThreadState_Get: no current thread > | Abort > | qad16:tools $ /opt/python/python1.5.2/bin/python test.py > | qad16:tools $ > > So... what's wrong with my 1.5.1 installation? Have I misconfigured > the thread stuff, or is a bug that has been fixed in 1.5.2? There is a > note in the Misc/NEWS of 1.5.2 that says that PyThreadState_Get has > been replaced by a macro that doesn't do error checking. Does this > mean that the problem is still lurking in my 1.5.2 installation? > > Thanks for any pointers! > > Tim > > -------------------- test.py -------------------- > import sys > from Tkinter import * > > def cancel(): > sys.exit(0) > > def quitFromWM(event): > pass > > mf = Frame() > mf.bind("", quitFromWM ) > f = Frame(mf).pack(side=BOTTOM,fill=BOTH) > Button( f, text = 'Quit', command = cancel ).pack() > mf.mainloop() > > > > > -------------------------------------------------------------- > Tim Docker timd at macquarie.com.au > Quantative Applications Division > Macquarie Bank From downstairs at home.com Sun Apr 25 23:04:16 1999 From: downstairs at home.com (TM) Date: Mon, 26 Apr 1999 03:04:16 GMT Subject: [SOLVED] Re: Can't get wish80 working on tcl\tk 8.0.5 References: <3722974b.17318321@news> Message-ID: I've figured out the problem and I'm passing it on to the groups in case it might help someone else. I had a program called Window Blinds running that was causing the hanging. When I shut this accessory off, the wish80 and Tkinter stuff started working again. Tom wrote in message news:3722974b.17318321 at news... > I can't seem to get the graphical wish80 shell working on my win98 > machine. Can anyone PLEASE help me to get this working??? > > Here's the story: > Installed the latest version (8.0.5) as it came with the > latest version of Python. I could not get any python programs that > accessed Tkinter to work. I tracked the problem back to the tcl > installation by trying first the command line tcl shell which worked, > then the wish80 shell which does not work. I can see a process in > my task window, but the program's window never opens up. I've made > sure I've got the proper path set up and I still get nothing. > > I tried installing a previous release (tcl 7.4(?) and tk 4.2) and that > wish shell came up just fine. I uninstalled that and reinstalled > version 8.0.5 and I get nothing. > > Please can someone help me fix this?? What could I be missing or > doing wrong?? > > > Thank you for ANY help. > > Tom > From moshez at math.huji.ac.il Sun Apr 25 18:17:48 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 26 Apr 1999 01:17:48 +0300 Subject: Time complexity of dictionary insertions In-Reply-To: <000901be8e11$b4842560$f09e2299@tim> References: <000901be8e11$b4842560$f09e2299@tim> Message-ID: On Sat, 24 Apr 1999, Tim Peters wrote: > [someone asks about the time complexity of Python dict insertions] > > [Tim replies] > > Min O(1), Max O(N), Ave O(1). If the hash function is doing > > a terrible job (e.g. maps every key to the same hash value), make > > those all O(N). > This one-ups-man-ship would be a lot cuter if Python's dict insertion were > in fact amortized constant time <0.9 wink>. It's not, and the answer I gave > doesn't imply that it is. Insertion in STL hashed associative containers > isn't ACT either. This is interesting. What is the WCS behaviour of Python dicts? but-it-doesn't-really-matter-'cause-it-takes-finite-time-anyway-ly y'rs, Z. -- Moshe Zadka . QOTD: What fun to me! I'm not signing permanent. From alex at somewhere.round.here Thu Apr 29 10:53:33 1999 From: alex at somewhere.round.here (Alex) Date: 29 Apr 1999 10:53:33 -0400 Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> Message-ID: > I would like better python support in XEmacs. There is a python mode, > but I haven't seen anything about evaluating Python code ineteractivly > the way you can with Lisp and elisp. Is this the sort of thing you want? Try C-c ! to create a python shell, C-c C-c to evaluate a buffer in that shell, or C-c | to evaluate a marked region. Then you can execute commands interactively in that shell. This works for python-mode in emacs. I would guess it would be the same in xemacs. Unless these are customizations I did and forgot about... :) Alex. From skip at mojam.com Sat Apr 17 09:08:39 1999 From: skip at mojam.com (Skip Montanaro) Date: Sat, 17 Apr 1999 13:08:39 GMT Subject: Need someone to try some rarely used bsddb methods Message-ID: <7fa14m$vfm$1@nnrp1.dejanews.com> I noticed today that there is apparently still no documentation for the bsddb module, so I started working on some. While trying out the bsddb hash object methods, I noticed a few didn't seem to work. I tested this under Red Hat Linux 5.0 (PC hardware) and Python 1.5.1. I used Berkeley DB v 2.3.16 with the backwards compatibility interface, so that might be causing my problems. I see no functional changes in the 1.5.2 version of the bsddb module, so I doubt it's causing problems. If you have the time, please try executing the following Python statements and let me know what methods, if any, generate tracebacks. I will need to know what version of Python you used, what version of Berkeley DB you used, and for completeness, what OS platform and version you used. (If you use version 2 of the DB library you will have to modify the bsddbmodule.c source to include db_185.h instead of db.h.) import bsddb db = bsddb.hashopen("/tmp/spam.db", "c") for i in range(10): db["%d"%i] = "%d"% (i*i) db.keys() db.first() db.next() db.last() db.set_location('2') db.previous() db.sync() The btree object (the one I use regularly) didn't have any problems. The keys returned with the record object seem to be screwed up: >>> db = bsddb.rnopen("/tmp/spamr.db", "c") >>> for i in range(10): db["%d"%i] = "%d"% (i*i) ... >>> db.keys() ['0\000\000\000', '1\000\000\000', '2\000\000\000', '3\000\000\000', '4\000\000\000', '5\000\000\000', '6\000\000\000', '7\000\000\000', '8\000\000\000', '9\000\000\000'] Can anyone confirm this rather odd behavior as well? Private replies appreciated. Thanks, -- Skip Montanaro (skip at mojam.com, 518-372-5583) Mojam: "Uniting the World of Music" http://www.mojam.com/ Musi-Cal: http://www.musi-cal.com/ -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From tismer at appliedbiometrics.com Mon Apr 19 17:06:06 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Mon, 19 Apr 1999 21:06:06 GMT Subject: Memory and swapping question References: <371B5ED8.A9C82170@appliedbiometrics.com> <7fg1ep$t5s$1@nnrp1.dejanews.com> Message-ID: <371B9ABE.3D2D8543@appliedbiometrics.com> aaron_watters at my-dejanews.com wrote: > > In article <371B5ED8.A9C82170 at appliedbiometrics.com>, > Christian Tismer wrote: > > due to a question which came up in the tutor list, I'd like > > to ask if somebody can explain the following:.... > > timings on making huge lists of integers... > > > On my system, creation takes about 10 times as for big/2, > > this is ok. But the del takes at least three times as long. > > Besides the fact that integers are never really disposed but > > build up a freelist, why is deletion so much slower now? > > Could be wrong, but this may be a case of a famous database > problem. The OS (typically) swaps out pages by picking the "least recently > used" page, but when you are decreffing (scanning) a HUGE list of sequentially > allocated objects this guarantees that the page you need next will > be swapped out by the time you get to it. Yikes! Allocation is faster > because you are really only "paging things out" (the first time) > and the write to the disk can be buffered until the disk is > ready, allowing the program to proceed (?I think?). Exactly. In this case, things are even worse: Iin the de-allocation phase, the internal integer cache is scanned in order, to return the integers to the freelist. This treats a stack-like structure as a heap, making integer deallocation like a list.reverse() on the cache file. It also applies to other objects which are created in-order and referenced by the list. The same disk trashing. Which means that the malloc routines use a similar, stack-like freelist, at least on Win98. > This is one reason why Oracle and Sybase, etc, like to do their own > memory and disk management ("gimme them sectors -- don't need no > g.d. filesystem, thanks!"). Just a guess, but a not completely > uneducated one. Well, I changed the deallocation strategy of lists to free objects beginning from the end. (1 line in listobject.c) Now, all my examples run as expected, with del no longer being more expensive than create. cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 andrew at starmedia.net Fri Apr 16 14:35:55 1999 From: andrew at starmedia.net (Andrew Csillag) Date: Fri, 16 Apr 1999 18:35:55 GMT Subject: Bug with makesetup on FreeBSD References: <37175E05.4CF3C68@starmedia.net> <19990416141948.B1545732@vislab.epa.gov> Message-ID: <3717830B.D2ABFBFD@starmedia.net> Randall Hopper wrote: > > Andrew Csillag: > |makesetup in Python 1.5.1 and 1.5.2 bombs on lines in the Setup file > |that use backslash continuation to break a module spec across lines on > |FreeBSD. > > BTW FWIW, I just built 1.5.2 last night on 3.0-RELEASE using the 1.5.2c1 > port. Worked fine. But it may not invoke makesetup under the hood. > > Randall It does invoke makesetup (that's how the Makefile in Modules gets written). I'm also running FreeBSD 2.2.8, so it may be a bug in /bin/sh that has been subsequently fixed... The quick test is to try this on your 3.0 machine $ read line some text here\ On my 2.2.8 machine after I hit return after the \, I get a command line prompt, not a "blank prompt" that would mean that the read wasn't done. In either case, I was able to get the thing built without the patch, I just had to type make -e SHELL=/usr/local/bin/bash, but that sucks. Drew Csillag -- "There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence." - Jeremy S. Anderson From chwang at olemiss.edu Mon Apr 12 16:47:05 1999 From: chwang at olemiss.edu (haibo wang) Date: Mon, 12 Apr 1999 15:47:05 -0500 Subject: where can I find the binary code for mSQL or mySQL module in Pyton Message-ID: <37125BC9.316AE200@olemiss.edu> I had installed Python on the Sun workstation running solaris 2.6. I need to download the module for mSQL and mySQL. Where can I find the binary code? Who is maintaining the Python mSQL module. Thanks, Haibo Wang UNIX/NT Consultant Office of IT University of Mississippi From dalke at bioreason.com Thu Apr 29 21:18:15 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Thu, 29 Apr 1999 19:18:15 -0600 Subject: string.atoi('-') References: <372894B5.78F68430@embl-heidelberg.de> Message-ID: <372904D7.1A9FC1AB@bioreason.com> (cc'ed to Jens Linge , the author of) > With python 1.51 running on a SGI: > >>> string.atoi('-') > Traceback (innermost last): > File "", line 1, in ? > ValueError: invalid literal for atoi(): - > >>> > > But with python 1.52 running on a SGI: > >>> string.atoi('-') > 0 > >>> > > Does it depend on the compilation? > Does anyone have the same problem? > > WHAT IS THE RULE? My 1.5.1 installation on IRIX 6.2 and 6.5 (compiled under 6.2 with the 7.1 compiler using -o32) says: val> python Python 1.5.1 (#21, Nov 23 1998, 15:04:47) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import string >>> string.atoi('-') 0 so it isn't a 1.5.1 to 1.5.2 difference or a difference in the -o32 libraries for the OS version. I suspect either the compiler or the -n32 libs. I compiled 1.5.2c1 with the newer compiler using -n32. The result is the error you got: max> ./python Python 1.5.2c1 (#5, Apr 29 1999, 19:04:33) [C] on irix646 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import string >>> string.atoi('-') Traceback (innermost last): File "", line 1, in ? ValueError: invalid literal for atoi(): - I recompiled 152c1 for SGI_ABI = -o32 on the same machine and compiler. max> ./python Python 1.5.2c1 (#6, Apr 29 1999, 19:12:12) [C] on irix646-o32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import string >>> string.atoi('-') Traceback (innermost last): File "", line 1, in ? ValueError: invalid literal for atoi(): - This suggests that the compiler changed a bit (fixed a bug it seems) and that you are compiling 1.5.2 on the 7.1 compiler while you compiled 1.5.1 on the 7.2 compiler. Can you try other combinations of machines and compilers? Or perhaps change the ABI to -n32 (or -o32) to get a different set of library routines? Andrew dalke at bioreason.com From dave at zeus.hud.ac.uk Thu Apr 8 05:00:48 1999 From: dave at zeus.hud.ac.uk (Dave Dench) Date: Thu, 8 Apr 1999 09:00:48 GMT Subject: Extreme Programming ( XP ) in python ? Message-ID: <199904080900.KAA17021@brahms.scom> Dear All, I recently attended the OT99 conference at Oxford University. One of the highlights was the inspiring keynote speech by Kent Beck on his experiences with Extreme Programming ( XP ) . ( ref: http://c2.com/cgi/wiki?ExtremeProgrammingRoadmap ) Unfortunately, he was using Java as his particular language vehicle, but that is not mandatory. It would seem to me that XP and python is a marriage made in heaven. Has anyone on this list had any experiences with XP on their projects? David PS as a side-note, despite this being primarily a practitioners conference, there didn't seem to be much awareness of python at the conference, despite my dropping it into any conversation I could. It would seem that Java IS making in-roads, despite reservations. PPS It would also seem that XML is starting to get linked with CORBA very productively by passing content-rich strings. ( perhaps this is old news ? ) ________________________________________________________________________________ ************************************************ * David Dench * * The University of Huddersfield , UK * * Tel: 01484 472083 * * email: d.j.dench at hud.ac.uk * ************************************************ ________________________________________________________________________________ From news at helen.demon.nl Thu Apr 29 05:54:58 1999 From: news at helen.demon.nl (Ilja Heitlager) Date: Thu, 29 Apr 1999 11:54:58 +0200 Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> Message-ID: <7g99pj$b1$1@news.worldonline.nl> David Steuber wrote: >I would like better python support in >XEmacs. There is a python mode, but I haven't seen anything about >evaluating Python code ineteractivly the way you can with Lisp and >elisp. I use windows python, it has debuggers and such. >-> Need GUI's? MFC or tcl/tk? > >MFC???? I hope to seperate the functionality from the GUI to >make both orthoganal to each other. If I can pull that off, I suppose >a Windows version would be possible for what I want to do. I am >expecting to go straight to XLib and OpenGL. If I need an abstraction >layer over X, it would probably be xt. OK, A UNIX guy (that will change ;-) Take a look at the modules section in www.python.org All gui's you mention are supported, there is also a WPY package. It is an abstract representation and uses MFC on MS or tcl/tk otherwise. > >-> Networking, Parsers, XML, HTML, regex? >I am not sure if I need to use networking. I am hoping to get >concurrent development via outside tools like CVS. If there's ASCII CVS is never a problem ofcourse, but I just named a few packages. > >-> ehh, Python? > >It looks interesting. It is more C like than Lisp like. I was >considering using Lisp, but for various reasons I have abandoned that >idea. JavaScript is too weak. Perl is a strong scripting language, >but it is a real bitch to create C++ style classes. The syntax is a >nightmare. I'll keep it for text munching. Python has very strong regex support, so you will probably start using python for that as well ;-) There is a thread at this moment however discussing performance on LARGE text-processing in Perl and Python. I never was much of a parenthesis fetisjist, so LISP is out of my league. If you need functional constructs, python has that as well (lambda's etc) If you need symbolical stuff, I am working on that. I have experience with Prolog and Reduce/RLISP (Lisp without () and a month ago I took Python to do symbolical stuff. It gave me just what I wanted: OO and strong operator overloading. much better then simple Lisp-tuples. Tell me if you need this kind of stuff. The last year I did a lot of large system stuff in Java (both pure and MS), which was a great relief from C. Last month I got to learn Python, which I love even better. Until now there isn't anything I can think of what I could not do in Python and JPyhton is probably the HOLY GRAIL. Guido is king, Python is his round table and we are the knights that follow. From dkuhlman at netcom.com Thu Apr 8 19:02:11 1999 From: dkuhlman at netcom.com (G. David Kuhlman) Date: Thu, 8 Apr 1999 23:02:11 GMT Subject: infoseek? References: <7ehcn3$elg$1@newssvr01-int.news.prodigy.com> Message-ID: Daye wrote: > does anyone know if Infoseek.com still use python for their > search engine? Thanks. There was an article in Python Journal dated about 7/98 in which Andy Feit of Infoseek says that they still use Python heavily and that they make Python available to customers who want to customize there Intranet seek engines. A relevant quote from that article: "The other thing that Python gives our product is that, when customers come to us and ask 'Can you customize it to do such and such?', we almost alwasy say yes. ... We have patching points in a language that is flexible enough to do almost anything." Feit also makes comments that indicate confidence that his customers will be able to make the Infoseek engine do anything. And that just makes me drool with envy. I wish my company's product could do that. I'm trying to make it so. Python Journal is at: http://www.pythonjournal.com but when I tried a few minutes ago, I was denied access to this article. - Dave From jkraai at polytopic.com Thu Apr 29 01:07:01 1999 From: jkraai at polytopic.com (jkraai) Date: Thu, 29 Apr 1999 05:07:01 GMT Subject: HTML "sanitizer" in Python References: <19990428152042.A708@better.net> <00e501be91c4$db944f20$0301a8c0@cbd.net.au> Message-ID: <3727E8F5.7AC7EAB0@polytopic.com> Um, a vote of confidence here for tidy. I've rewritten tidy to do several different specialized things. I am no C hacker, and have been told it's 'awful' code, but I sure had no problems with it. , just-another-2c-in-the-bucket-ly-yours --jim Mark Nottingham wrote: > > There's a better (albeit non-Python) way. > > Check out http://www.w3.org/People/Raggett/tidy/ > > Tidy will do wonderful things in terms of making HTML compliant with the > spec (closing tags, cleaning up the crud that Word makes, etc.) As a big > bonus, it will remove all tags, etc, and replace them with CSS1 style > sheets. Wow. > > It's C, and is also available with a windows GUI (HTML-Kit) that makes a > pretty good HTML editor as well. On Unix, it's a command line utility, so > you can use it (clumsily) from a Python program. > > I suppose an extension could also be written; will look into this (or if > anyone does it, please tell me!) From jeremy at cnri.reston.va.us Sat Apr 10 14:40:19 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Sat, 10 Apr 1999 14:40:19 -0400 (EDT) Subject: Internet Robot In-Reply-To: <7emldl$rh9$1@nnrp1.dejanews.com> References: <7ehe9m$hbs$1@nnrp1.dejanews.com> <7emldl$rh9$1@nnrp1.dejanews.com> Message-ID: <14095.39355.48967.900033@bitdiddle.cnri.reston.va.us> How are you generating your HTTP requests? httplib or urllib? IN either case, you ought to be able to get Python to print out some debugging information, which will be much more useful than doing something with a packet capture tool. There's nothing fancy going on at the packet level that you need to look at -- just the data that's coming back over the socket. One of the easiest ways to do that is with the set_debuglevel method on an HTTP object. But your question probably has an even easier answer: What kind of authentication is the server doing? Python supports HTTP Basic authentication with urllib, and I've gotting a working implementation of Digest authentication that should be ready for release any day now. The authentication support is not well documented (if it's documented at all), so you'll have to look at the code. Jeremy From stadt at cs.utwente.nl Wed Apr 21 06:38:58 1999 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Wed, 21 Apr 1999 12:38:58 +0200 Subject: Kosovo database; Python speed Message-ID: <371DAAC2.D9046550@cs.utwente.nl> Suppose we were going to make a database to help Kosovars locate their family members. This would probably result in hundreds of thousands of records (say 1 record (file) per person). Would Python be fast enough to manage this data, make queries on the data, or should compiled programs be used? Richard. From fw at cygnus.stuttgart.netsurf.de Sun Apr 25 13:07:14 1999 From: fw at cygnus.stuttgart.netsurf.de (Florian Weimer) Date: 25 Apr 1999 19:07:14 +0200 Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: sweeting at neuronet.com.my writes: > a) Perl's "defined". > [perl] > if (defined($x{$token}) > > [python] > if (x.has_key(token) and x[token]!=None) : Depending on the code, you can omit the comparision to `None'. Perl programmers traditionally uses `defined' to test if a key is in a hash, so your code is the correct translation if you mimic Perl's undefined value with Python's `None', but most of the time, this is not required. > b) RE's. > [perl] > if ($mytext !~ /^\s$/) > > [python] > if not (re.match('^\s$'), mytext) Your Python code unconditionally executes the `false' branch of the `if' statement. I hope this is the correct translation: # Execute this once at the beginning of the program. single_space = re.compile(r'^\s$') # use a r'aw' string # Later on, you can try to match this regexp to a string: if not single_space.match(mytext): > Since I know neither perl nor chinese, it would be nice if somebody > could help me remove one of the variables in my debugging. I see. I've tried to install a Chinese text processing environment for a friend. ;) From MHammond at skippinet.com.au Tue Apr 13 03:41:35 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 13 Apr 1999 17:41:35 +1000 Subject: Python without registry entries References: <370fb711.28093946@news.demon.co.uk> <7eol16$1l2$1@m2.c2.telstra-mm.net.au> <37121820.3758204@news.netmeg.net> Message-ID: <7eusdh$s3o$1@m2.c2.telstra-mm.net.au> Les Schaffer wrote in message <37121820.3758204 at news.netmeg.net>... >On Sun, 11 Apr 1999 08:57:49 +1000, "Mark Hammond" wrote: > >>You can. Python does not _need_ the registry for anything. > >a followup question: > >I just switched over our windows machine to NT from win98, and did a >clean install so the registry is fresh spanking new... > >is there some way to restore the registry settings for python and the >win32 extensions without downloading the whole darn thing again? >pythonwin doesnt run right now because win32ui.pyd is not found. in There is a script "regsetup.py" installed in the win32 directory somewhere. This attempts to resurrect the registry. It hasnt been tested for a while, but it should work. Something like: python.exe regsetup.py will setup the core stuff, and python.exe regsetup.py --pythonwin should get Pythonwin running. [In fact, you hit a bug anyway - pythonwin _should_ be capable of running without any special registry too - and now can - as of 124.] Mark. From garryh at att.com Tue Apr 13 15:56:40 1999 From: garryh at att.com (Garry Hodgson) Date: Tue, 13 Apr 1999 19:56:40 GMT Subject: Python for embedded controllers? References: <370de606.77891472@news.oh.verio.com> Message-ID: <3713A178.B03F1F1D@att.com> Ken McCracken wrote: > Neal Bridges in Toronto, Ont. has been developing an onboard Forth > compliler for the Pilot for a while. People seem pretty well enthused > about it and it is making converts to the Forth language and reattracting > programmers who had given up on Forth. i have very fond memories of forth, with which i wrote tons of software on my old atari 800. i can't imagine ever going back to it, though. -- Garry Hodgson seven times down garry at sage.att.com eight times up Software Innovation Services AT&T Labs - zen proverb From claird at Starbase.NeoSoft.COM Tue Apr 27 16:39:22 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 27 Apr 1999 15:39:22 -0500 Subject: WARNING: AIX and dynamic loading. References: <7g4i77$qif$1@nnrp1.dejanews.com> Message-ID: <7g579q$cao$1@Starbase.NeoSoft.COM> In article <7g4i77$qif$1 at nnrp1.dejanews.com>, Jakob Schiotz wrote: > > >Hi everybody, > >I would like to warn developers using AIX against this trap waiting >for us to fall into. (I am cross-posting this to the SWIG mailing list >although it is not strictly a SWIG problems, as SWIG users will be >doing just the kind of stuff that gets you into trouble). . . . There are several issues specific to dynamic loading under AIX that are quite independent of Python. Your caching example is one I've never heard of before, but the comp.lang.tcl crowd knowledgeable about the Stubs project might be able to help you if you run into more problems. I agree that SWIG is an apt locus for such discussion. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From guido at CNRI.Reston.VA.US Tue Apr 13 20:23:37 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Tue, 13 Apr 1999 20:23:37 -0400 Subject: Python 1.5.2 -- final version released Message-ID: <199904140023.UAA24831@eric.cnri.reston.va.us> On April 13, the final version of Python 1.5.2 was released. Thanks to all who reported problems with the release candidate! This will conclude the 1.5 development cycle; while I may release some essential patches later, my main development focus will be on Python 1.6 (with 2.0 on the horizon; 1.6 will probably be the last of the 1.x versions). Go to http://www.python.org/1.5/ for more info, or download directly: ftp://ftp.python.org/pub/python/src/py152.tgz (source, 2.5M) ftp://ftp.python.org/pub/python/win32/py152.exe (Windows installer, 5.0 M) Per tradition, I will disappear from the face of the earth for a few days -- see you all on Monday! --Guido van Rossum (home page: http://www.python.org/~guido/) From guido at CNRI.Reston.VA.US Sat Apr 10 14:51:06 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Sat, 10 Apr 1999 14:51:06 -0400 Subject: 1.5.2c1 will not compile on Windows NT SP4 with VC++ 6.0 SP1 In-Reply-To: Your message of "Sat, 10 Apr 1999 18:42:10 BST." <000001be8379$76536190$060110ac@barrynt.private> References: <000001be8379$76536190$060110ac@barrynt.private> Message-ID: <199904101851.OAA04654@eric.cnri.reston.va.us> > I extracted the 1.5.2c1 kit into P:\ Where did you get it? > python15 error > -------------------- > VC++ 6.0 gives this error. > > Fatal error C1083: Cannot open source file: > 'P:\Python-1.5.2c1\Modules\reopmodule.c': No such file or directory > > The file reopmodule.c is not in the kit. Hm... I just tried this with VC++ 6.0 (not sure which service pack) and there's no mention of reopmodule.c -- indeed that module was deleted ages ago. Where exactly did you get the project file you used? Perhaps you had an older project file (e.g. from an earlier alpha or beta release) lying around? > Having removed reopmodule.c from the project I get a link error > > LINK : fatal error LNK1104: cannot open file ".\PC\python_nt.def" > > This file is also missing. This file is no longer distributed. If you use the project files for VC++ 5.0 that are distributed in the PCbuild directory (VC++ 6.0 will convert them for you) you will note that it is no longer referenced. > Removing python_nt.def from the project reveals files that need to be added > to the project: > > object\bufferobject.c > pc\initwinsound.c > modules\_localemodule.c > > LINK needs winmm.lib added to it. These things have all been corrected in the distributed project files. > Now I get a python15 built. > > pyhon error > ---------------- > The project cannot find python.c > > fatal error C1083: Cannot open source file: > 'P:\Python-1.5.2c1\python\Modules\python.c': No such file or directory > > There is a extra "python" directory that is not in the kits layout. > Fixed by replacing with 'P:\Python-1.5.2c1\Modules\python.c' > > Same path problem with python15.lib. > Fixed by replacing with P:\Python-1.5.2c1\vc40\python15.lib > > Now I get a python.exe Again, I wonder where you got the kit... > _tkinter > ---------- > The tk and tcl libs are named tk80.lib and tcl80.lib not tk80vc.lib and > tcl80vc.lib. Ditto -- your kit is not the set of workspace/project files I'm distributing. (Unless I've accidentally distributed two sets. Which set are you using?) > I used the Tcl/Tk that the 1.5.2c1 installation put on my system. > > Now I have _tkinter.dll > > How was the kit for Windows built given all the missing or misnamed files? > Or is this a side effect of using VC++ 6.0? > > I also notice that the python.exe was built 8 apr 1999 but report sa dated > of 12 Mar 1999 > on the interactive command line. Sounds like you have an old Python build lying around. --Guido van Rossum (home page: http://www.python.org/~guido/) From gmcm at hypernet.com Tue Apr 6 23:12:31 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 7 Apr 1999 03:12:31 GMT Subject: Embedding python question: PyRun_String only returns None no In-Reply-To: References: Message-ID: <1288667549-75228395@hypernet.com> Dave Kuhlman replies to a query about PyRun_SimpleString... > When you embed Python in an application, the application often > exposes functions that are callable from Python scripts. You could > provide a function named setReturnValue(value), which when called, > passed a Python object (the value). The script calls this function, > and then, when it exits, the embedding application (the caller of > PyRun_String or PyRun_SimpleString) uses the Python value saved by > this function. With all the error checking and some app specific logic removed, here's some code that loads a module and calls a specific function in that module: module = PyImport_ImportModule("mymodule"); moduledict = PyModule_GetDict(module); func = PyDict_GetItemString(moduledict, "CheckMenu"); args = Py_BuildValue("(ss)", "spam", "eggs"); retval = PyEval_CallObjectWithKeywords(func, args, (PyObject *)NULL) Py_XINCREF(retval); rc = PyArg_Parse(retval, "s", &str); Py_XDECREF(retval); Py_XDECREF(module); - Gordon From jefftc at leland.Stanford.EDU Fri Apr 30 03:50:00 1999 From: jefftc at leland.Stanford.EDU (Jeffrey Chang) Date: Fri, 30 Apr 1999 00:50:00 -0700 Subject: Oracle Call Interface In-Reply-To: <7gb3hn$lse$1@nnrp1.dejanews.com> References: <7gb3hn$lse$1@nnrp1.dejanews.com> Message-ID: > If anyone has experience writing applications directly to the Oracle Call > Interface (OCI), in Python or JPython please send me examples or references on > how to do it. Yuck! What are you planning to do? Do you really really need to write directly to the OCI or can you use one of the available Oracle extension modules? About a year ago, I used the oracledb module from Digital Creations with Oracle7. It's very nice, but not optimized, and thus slow for large queries. Since then, Digital Creations has made DCOracle (http://www.digicool.com/DCOracle/; their commercial extension module) open source, so I guess that will replace oracledb. I haven't looked at it, but according to the FAQ, it's "much faster." I strongly advise you to use an extension module or JDBC if at all possible. Writing to the OCI is extremely ugly -- all the stuff we try to avoid by using python! Jeff From MHammond at skippinet.com.au Fri Apr 23 19:53:12 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 24 Apr 1999 09:53:12 +1000 Subject: Windows install has problems. Guido asked that I use this newsgroup to discus further References: <924039873.18221.0.nnrp-12.9e982a40@news.demon.co.uk> <924040766.18823.0.nnrp-12.9e982a40@news.demon.co.uk> <371FAE0F.43B33158@siosistemi.it> <924903282.24080.0.nnrp-10.9e982a40@news.demon.co.uk> Message-ID: <7fr133$56e$1@m2.c2.telstra-mm.net.au> Barry Scott wrote in message <924903282.24080.0.nnrp-10.9e982a40 at news.demon.co.uk>... > I think its important that python without add on's can access the >registry under > Windows. It is a fundamental requirement on Windows. FYI, Guido has basically agreed that the Win32 registry functions (and likely support for native Windows handles) will move into the core in the 1.6 timeframe. Mark. From bhowes at cssun3.corp.mot.com Thu Apr 29 13:26:16 1999 From: bhowes at cssun3.corp.mot.com (Brad Howes) Date: 29 Apr 1999 10:26:16 -0700 Subject: Python Powered Car Audio Message-ID: Check out http://www.empeg.com. It describes a cool in-dash MP3 player running Linux. On the Tech page, I found this: The unit's UI is written in Python, allowing Python-esque users to add features and giving great flexibility in the way the unit works. -- Brad Howes bhowes at motorola.com Principal Compass Hacker Work: +1 602 446 5219 Motorola Cell: +1 602 768 0735 From akuchlin at cnri.reston.va.us Mon Apr 19 09:03:35 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Mon, 19 Apr 1999 13:03:35 GMT Subject: How to merge data in a existant file In-Reply-To: <7feqbf$pr6$1@nnrp1.dejanews.com> References: <7feqbf$pr6$1@nnrp1.dejanews.com> Message-ID: <14107.10521.542022.542456@amarok.cnri.reston.va.us> fquiquet at lemel.fr writes: >I know how to write data in a new file : >I don't know what is the function that permit to add data whithout erase >existing data. Open the file in append mode, with a mode string of 'a' (or 'ab' for a binary file) instead of 'w'. >>> f = open('test-file', 'w') ; f.write('abc\n') ; f.close() >>> f = open('test-file', 'a') ; f.write('abc\n') ; f.close() >>> open('test-file', 'r').read() 'abc\012abc\012' -- A.M. Kuchling http://starship.python.net/crew/amk/ The NSA regularly lies to people who ask it for advice on export control. They have no reason not to; accomplishing their goal by any legal means is fine by them. Lying by government employees is legal. -- John Gilmore From call at 83331002.wong Thu Apr 29 04:59:32 1999 From: call at 83331002.wong (Mr Wong) Date: 29 Apr 1999 08:59:32 GMT Subject: make your first $1 million Message-ID: <7g971k$cje$11125@hfc.pacific.net.hk> HANG CHEONG INTERNATIONAL A new successful marketing tactic to increase your sales : Do you always have problems to find channels to increase your sales? The advertise in newspapers, magazines and doing some Direct Mailing, but still can not achieve you goal, so why still dumping your money to a media that could not help your sales and not using the most efficient and modern way of selling stragies E-MAIL.Now many big companies are using this, because it is economical, fast and efficient, and the other way is selling by fax through the internets, and the result are remarkable. According to report pointed out that the ratio of internet selling is 1,000:1.5 that is 20,000,000 names x 0.0015 = 30,000. These 30,000 clients will buy from you and if your net profit is $50 that is to say your total profit is: HK$50 x 30,000 = HK$1,500,000. 1.5 Million Dollars !!! How to make your first 1 million in your life, now it is quite possible that you can make your first 1 million within one month. But the thing is ??Are you selling the right products, through the right media.?? *************************************************************************** A full set of sales tool with 20 million of client??s names will make you a SUPER SALES. A professional mail software (no need to go through any ISP Mail Server,making your computer as the professional Mail Server, its super speed. Easy to use. * 500,000 E-mail addresses in Hong Kong * 1,000,000 E-mail address in Taiwan * 20,000,000 E-mail address in the World (latest revised on 10th March 1999.) * A free revision one year (around 100,000 every month) * Free of charge of 200,000 names of fax addresses in Hong Kong for 1999. * Door to door installation * Technical support * software replacement. * Using CD-R dish and CD-AutoRun Menu. (Only HK$680 for one full set) for unlimited use. HK$680 is very small amount, you may not need it now but you will sure to use it when you have every thing ready. *************************************************************************** If you need any E-mail address, call us any time!! *************************************************************************** Don??t miss this chance, you may make lots of money with this new marketing technique. Booking Hotline : (852) 8333 1002 Mr Wong 2ND FL.FRONT BLOCK HING YIP HOUSE.24,SAI YEE ST,HK _________________________________________________________________________________________ From tim_one at email.msn.com Thu Apr 22 16:19:48 1999 From: tim_one at email.msn.com (tim_one at email.msn.com) Date: Thu, 22 Apr 1999 20:19:48 GMT Subject: Time complexity of dictionary insertions References: <371F2125.BEC5F892@fzi.de> Message-ID: <7fo08u$4j2$1@nnrp1.dejanews.com> In article <371F2125.BEC5F892 at fzi.de>, Oliver Ciupke wrote: > As I understood from the Python documentation, dictionaries are > implemented as extensible hash tables. Yes. > What I didn't find either in the references or in the FAQ is: what is > the actual time complexity for an insertion into a dictionary? Min O(1), Max O(N), Ave O(1). If the hash function is doing a terrible job (e.g. maps every key to the same hash value), make those all O(N). > Do the old contents (probably references) Yes. > have to be copied when extending (doubling?) Approximately doubling, yes. > the dictionary? Right. > I guess updates and deletions have constand complexity, right? No; see above for insertion. Deletion is O(1) always, because Python doesn't try to shrink the table by magic (if you stick in a million keys and then delete them, the table will still contain a million "this entry isn't being used" markers). > If the complexity of insertion is something like n*log(n), does anyone > know measurements "how linear" the real measured times are? In practice, with a non-pathological hash function + key distribution combo, insertion & deletion act like O(1) on average. for-more-details-see-the-source-codely y'rs - tim -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From jmrober1 at ingr.com Fri Apr 16 11:37:24 1999 From: jmrober1 at ingr.com (Joseph Robertson) Date: Fri, 16 Apr 1999 10:37:24 -0500 Subject: Windows install has problems. References: <924039873.18221.0.nnrp-12.9e982a40@news.demon.co.uk> Message-ID: <37175933.5477D57F@ingr.com> Guido, didn't I write you a hack for this? I'll look on my home machine later, but I think I did. Also, why doesn't the Tcl install do this correctly? We should complain to them about it. Anyway, I am sure I can fix this using wise. Joe Robertson jmrobert at ro.com Barry Scott wrote: > THis is Guido's reply to my comments that tcl80.dll is not found > by IDLE on a default installation. > > > > > Running "IDLE (Python GUI)" reports that tcl80.dll is > > > > not in my path then the shell comes up and I can > > > > use Tkinter from the shell. > > > > > > > > Just in case this might be involved my Windows NT system > > > > is on G: not C:. > > > > > > To solve this one, I think you'll have to edit your autoexec.bat to > > > add the Tcl directory (containing that DLL) to the PATH variable. For > > > various reasons I do not believe it is a good idea to copy the Tcl/Tk > > > DLL files into the Python directory, nor do I think it is possible to > > > reliably edit autoexec.bat in the installer. Instead, Tkinter.py > > > imports a hack module, FixTk.py, which searches for tcl80.dll in a few > > > places and then patches the PATH environment variable of the running > > > process, but this is not failsafe either. :-( > > > > It would be nice if I did not have to edit the path manually. > > Suggest that the install edits the path or you use the registry > > to find the tcl80.dll image. > > I wish I could. The installer is very stupid. Windows sucks :-( > > > 1) The PATH is a registry key on NT. I don't have an autoexec.bat, > > isn't for MS-DOS compatibility only these days? > > No, it's still needed on Windows 98 and 98. > > > The machines PATH is in > > > > HKEY_LOCAL_MACHINE\CurrentControlSet\Control\Session Manager\Environment > > > > 2a) I notice that HKEY_CLASSES_ROOT\TclShell\shell\open\command > > contains a default value which is how to run wish. e.g. > > > > G:\PROGRA~1\Tcl\bin\wish80.exe "%1" > > > > tcl80.dll is in the same dir as wish80.exe. > > > > 2b) > HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls > > lists all the shared files on the system. There is an value > > "G:\Program Files\Tcl\bin\tcl80.dll" with the date 0x0000001 against it. > > > > 2c) HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.0 > > contains the default value field with the data G:\PROGRA~1\Tcl > > > > The DLL being in data + "\tcl80.dll". > > > > BArry > Please take it up on the newsgroup -- there are many people with > similar interests and more understanding of Windows than I have! > > --Guido van Rossum (home page: http://www.python.org/~guido/) From mli389 at merle.acns.nwu.edu Thu Apr 15 16:40:30 1999 From: mli389 at merle.acns.nwu.edu (Matthew T Lineen) Date: 15 Apr 1999 20:40:30 GMT Subject: HTML Authentication with Python Message-ID: <7f5iru$rlm@news.acns.nwu.edu> I am currently running python on an Windows NT Server. We only want certain pages to be accessed by people with accounts on the server in order to update a database through python. Using this code: def main(): if not os.environ.has_key("REMOTE_USER"): print "HTTP/1.0 401 Access Denied" print "Status: 401 Authenication Required" print "WWW-authenticate: Basic;" print "Content-type: text/html\n\n\n" else: print "Worked" I was able to get an authentication box to pop up in both netscape and ie, but when a user who is not an administrator tries to authenticate it doesn't accept the username / password. Is this a good way to go about authentication in python or is there another library to interface with the browsers and the NT user database? Furthermore, I'm relatively sure that the problem lies in user permissions, but I have no idea where to begin troubleshooting. Where is the os.environ 'kept'? Any help would be appriciated. Matthew Lineen From richard at folwell.com Thu Apr 15 03:56:58 1999 From: richard at folwell.com (Richard Folwell) Date: Thu, 15 Apr 1999 07:56:58 GMT Subject: Please unsubscribe me Message-ID: <01BE871E.C5505F20.richard@folwell.com> Thanks, Richard Folwell Riverside Information Systems Ltd Tel: +44 958 900 549 Email: richard at folwell.com Fax: +44 171 681 3385 From gmcm at hypernet.com Thu Apr 22 21:55:55 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 23 Apr 1999 01:55:55 GMT Subject: try vs. has_key() In-Reply-To: References: Message-ID: <1287289735-37704702@hypernet.com> Aahz asks: > I've seen roughly half the people here doing > > try: > dict[key].append(foo) > except: > dict[key]=[foo] > > with the other half doing > > if dict.has_key(key): > dict[key].append(foo) > else: > dict[key]=[foo] > > Can people explain their preferences? I have done both. Option 1 requires slightly less typing, but is only better when you (in practice) have a dict with a small number of keys and rather longish lists. (In Python, "try" is damned near free, and "except" is a lot cheaper than, say, C++'s "catch", but still costs a good deal more than has_key.) Conscientious practice of option 2, of course, allows you to look St. Peter in the eye and demand entrance without fear of contradiction... - Gordon From akuchlin at cnri.reston.va.us Wed Apr 28 11:11:07 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Wed, 28 Apr 1999 11:11:07 -0400 (EDT) Subject: try vs. has_key() In-Reply-To: <37247ea3.494305@news.jpl.nasa.gov> References: <37247ea3.494305@news.jpl.nasa.gov> Message-ID: <14119.9202.870049.51888@amarok.cnri.reston.va.us> William H. Duquette writes: >>>> d = {} >>>> a = 'Foo' >>>> d[a] = d.get(a, []).append('Bar') >>>> d >{'Foo': None} >I'd have expected to see {'Foo': 'Bar'}, but that's not what I get. The .append() method only returns None, not the list you've just appended to. >>> L = [] >>> print L.append(2) None >>> L [2] You'd want something like: dummy = d[a] = d.get(a, []) dummy.append('Bar') -- A.M. Kuchling http://starship.python.net/crew/amk/ When I originally designed Perl 5's OO, I thought about a lot of this stuff, and chose the explicit object model of Python as being the least confusing. So far I haven't seen a good reason to change my mind on that. -- Larry Wall, 27 Feb 1997 on perl5-porters From davidcuny at yahoo.fr Mon Apr 19 05:06:07 1999 From: davidcuny at yahoo.fr (davidcuny at yahoo.fr) Date: Mon, 19 Apr 1999 09:06:07 GMT Subject: Database search engine Message-ID: <7ferls$qrj$1@nnrp1.dejanews.com> Hello, I'm doing an Intranet Web site with a database (Apache, DB2 and NT). I'd like to realize a quite complex search engine on the database : - the user enters mutli keywords - there exists a table of non significant words - there exists a table of words that have meaning: "kind" and "sort" Where can I find an algorithm or, the best, Perl code for that kind of work? Is Perl the good tool to do that (Perl??,java)?? thanks David -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From moshez at math.huji.ac.il Fri Apr 23 07:13:59 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 23 Apr 1999 14:13:59 +0300 Subject: try vs. has_key() In-Reply-To: References: Message-ID: Note: This article is a non-commercial advertisement for the ``get'' method of dictionary objects. Brought to you by the object None and the method .append. On Thu, 22 Apr 1999, Darrell wrote: > My experience shows that throwing an exception is slower. > > Aahz Maruch wrote in message > news:aahzFAM4oJ.M7M at netcom.com... > > I've seen roughly half the people here doing > > It depends on the expected hit/miss ratio. If you have many hits, few misses -- use the first Few hits, many misses -- use the second. Best way is to use (for example, counting) d={} for word in words: d[word]=d.get(word, 0)+1 Or, for logging: d={} for word in words: first_two=word[:2] d[first_two]=d.get(first_two, []).append(word) Unfortunately, few people seem to know about the ``get'' method, which is really good. >From the docs: a.get(k[, f]) the item of a with key k (4) (4) Never raises an exception if k is not in the map, instead it returns f. f is optional, when not provided and k is not in the map, None is returned. This makes dictionary types behave in a Perl-hash-like manner, which is sometimes a good thing. Note that this idiom is (I think) more efficient, and shorter. -- Moshe Zadka . QOTD: What fun to me! I'm not signing permanent. From bkc at murkworks.com Wed Apr 21 18:55:03 1999 From: bkc at murkworks.com (Brad Clements) Date: Wed, 21 Apr 1999 18:55:03 -0400 Subject: interfacing to Dragon from a Python app References: <000801be89dd$d407a0c0$ed9e2299@tim> Message-ID: <7fll1r$6kn$1@news.clarkson.edu> I have used microsoft's iit product. What attracted me was the price.. (Also, I have T3 access) It DOES work, though you need a good headset for dictation to work well. I guess that's generally true of everything else anyway.. I'm planning on using it with Python to "read" imap messages to me via telephone... Frank Sergeant wrote in message ... >In article <000801be89dd$d407a0c0$ed9e2299 at tim>, >"Tim Peters" wrote: > >> FYI, people curious about speech recognition under Windows might want to >> give Microsoft's implementation a try; see the little-known >> >> http://www.microsoft.com/iit/ > >Thanks for the pointer. I browsed around the site for awhile. > >> This is not for the Windows-ignorant, weak-hearted, or slow-modem'ed , > >I couldn't quite bring myself to start the 21MB download. I'm still >pondering my approach to the whole Speech Recognition (SR) thing. I'm >gradually getting some hardware set up that might support it and >considering the Dragon Preferred product (around $135 somewhere on >the net) versus saving up for the Dragon developer's kit. Third in >line, I guess, is Microsoft's 21MB download. Although ... > >I'm also thinking of overall priorities -- in that that SR might >not be able to make a silk purse out of a sow's ear (then again, >a sow's ear may be better at SR than a silk purse). > > > -- Frank > frank.sergeant at pobox.com > From llwo at dbtech.net.nospam Mon Apr 19 21:39:46 1999 From: llwo at dbtech.net.nospam (Karl & Mel) Date: Mon, 19 Apr 1999 20:39:46 -0500 Subject: calldll windll instantiation Message-ID: <371bdcbf.0@news.dbtech.net> Need some help. I think?(scarry moment)? that I need to create more that one instance of a dll. 1. Can this be done? 2. Is my sample even close? """gm_class quick wrapper of dll functions""" import windll import time class test: def __init__(self): self.gm=windll.module('GM4S32') def load_bde(self, SysDir='c:\\program files\\goldmine', GoldDir='c:\\program files\\goldmine\\gmbase', CommonDir='c:\\program files\\goldmine\\demo', User='PERACLES', Password=''): start=time.time() (SysDir, GoldDir, CommonDir, User, Password)=map(windll.cstring,(SysDir, GoldDir, CommonDir, User, Password)) return (self.gm.GMW_LoadBDE(SysDir, GoldDir, CommonDir, User, Password), "Startup Time: " + str(time.time()-start)) def unload_bde(self): return self.gm.GMW_UnloadBDE() ...other defs... >>> import gm_class >>> a=gm_class.test() >>> b=gm_class.test() >>> a >>> b >>> a.gm >>> b.gm >>> a.load_bde() # This works (1, 'Startup Time: 0.490000009537') >>> a.gm >>> b.gm >>> b.load_bde() # This fails but should work ;-( (0, 'Startup Time: 0.0') >>> a.gm >>> b.gm >>> a.gm==b.gm # Don't know if this is correct 1 >>> a==b 0 >>> >>> gm_class.windll.dump_module_info() -------------------- WINDLL Function Call Stats: --- --- 2 GMW_LoadBDE >>> From catlee at globalserve.net Thu Apr 22 08:12:06 1999 From: catlee at globalserve.net (Chris AtLee) Date: Thu, 22 Apr 1999 08:12:06 -0400 Subject: stdout in a restricted environment Message-ID: <7fn3rs$1v9$1@whisper.globalserve.net> I'm trying to make a program that will enable users to connect to a server running a python interpreter and be able to program in a restricted environment in that interpreter. The rexec object has methods called s_exec and s_eval which are supposed to use secure forms of the standard I/O streams, but I can't redefine them to be something else (specifically, an object that sends the response back to the client) Any pointers on how to go about redirecting the standard I/O streams from a restricted environment? Cheers, Chris From tim_one at email.msn.com Sat Apr 3 02:54:54 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 3 Apr 1999 07:54:54 GMT Subject: W9x "import" case sensitivity In-Reply-To: <37038658.FEAFF01F@palladion.com> References: <37038658.FEAFF01F@palladion.com> Message-ID: <000301be7da7$4277a3e0$879e2299@tim> [Tim sez he's never had a problem with case-sensitive imports under Win95, but that people at work do; speculates it may be due to non-Windows things, like network servers and old source-control systems, that change filename case seemingly at random ] [Tres Seaver] > On NT 4.0 SP3, with Python installed on NTFS E: drive: > > Python 1.5.2b1 (#0, Dec 10 1998, 11:29:56) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import SYS > Traceback (innermost last): > File "", line 1, in ? > import SYS > ImportError: No module named SYS > >>> import sys > >>> import HTMLLIB > Traceback (innermost last): > File "", line 1, in ? > import HTMLLIB > NameError: Case mismatch for module name HTMLLIB > (filename E:\tools\Python\Lib\htmllib.py) > >>> import htmllib > >>> > > (Note the different error messages.) This is not what I mean by having "a problem" -- this is working for you the same way as it works under e.g. Unix, which is the way it's documented to work. "A problem" would be if Python griped on the import htmllib line too, where the import-name case *does* match the distributed filename case. That's what I've seen happen at work, where the distributed filename case somehow or other "gets changed" by "something", so that the *correct* import statement doesn't work. That's never happened to me. The different error msgs you're getting are due to sys being a builtin module and not having a *file* named sys.py, Sys.py, SYs.py, sYs.py, sYS.py, syS.py, or sYs.py on your PYTHONPATH. Create a file with one of those names, and you'll get NameError instead of an ImportError when doing "import SYS". Python doesn't check the builtin modules name for case mismatches, and that's all that's going on here -- it may be seen as inconsistent, but this too works the same way across all platforms. caseclarifyingly y'rs - tim From trussarv at cirano.umontreal.ca Tue Apr 6 20:01:54 1999 From: trussarv at cirano.umontreal.ca (Vincent Trussart) Date: Tue, 06 Apr 1999 20:01:54 -0400 Subject: is imaplib 8bit clean? Message-ID: <370AA072.5D116DD2@cirano.umontreal.ca> I am trying to fetch headers from messages on a imap4 server that contains french characters (???). Instead of getting the correct message I get things like =?ISO-8859-1?Q?Soir=E9e?= How should I handle this? thanks a lot (i would prefer an answer by email) -------------- next part -------------- A non-text attachment was scrubbed... Name: trussarv.vcf Type: text/x-vcard Size: 228 bytes Desc: Card for Vincent Trussart URL: From john at oreilly.com Mon Apr 12 17:56:30 1999 From: john at oreilly.com (John Dockery) Date: Mon, 12 Apr 1999 21:56:30 GMT Subject: Message from O'Reilly - It's Released!!! Message-ID: <37126b27.79691844@news.shore.net> Learning Python was released on 4/9/99. Bookstores should be seeing it shortly. For the two people who read this newsgroup and don't already have it bookmarked: http://www.oreilly.com/catalog/lpython From joe at strout.net Sat Apr 10 13:59:09 1999 From: joe at strout.net (Joe Strout) Date: Sat, 10 Apr 1999 10:59:09 -0700 Subject: Idiom for Getting Slices of a List References: Message-ID: [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] In article , Moshe Zadka wrote: > I want a clean, and relatively efficient method to do the following: > I have an array of length, n*m and I want to make it an array of > length m, where each member is an array of length n. > > Example: n=2, m=3 > [0, 1, 2, 3, 4, 5] ==> [[0, 1], [2, 3], [4, 5]] Well, if you want efficient and clean you should use Numeric... >>> import Numeric >>> a = Numeric.array( [0, 1, 2, 3, 4, 5] ) >>> a array([0, 1, 2, 3, 4, 5]) >>> a.shape = (3,2) >>> a array([[0, 1], [2, 3], [4, 5]]) That last item is equivalent to the nested list-of-lists you asked for. (Note: to be picky, it's not an array unless you make it an array using either the array module or the Numeric module. What you illustrated looked like a list of lists.) Cheers, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From r.hooft at euromail.net Mon Apr 19 10:07:01 1999 From: r.hooft at euromail.net (Rob Hooft) Date: Mon, 19 Apr 1999 14:07:01 GMT Subject: Tkinter - the app that wouldn't quit In-Reply-To: <19990419095013.A62714@vislab.epa.gov> References: <19990416144831.A1548022@vislab.epa.gov> <19990419095013.A62714@vislab.epa.gov> Message-ID: <14107.14469.908426.160852@octopus.chem.uu.nl> >>>>> "RH" == Randall Hopper writes: RH> Do I need to add special testing-harness hooks into the dialog RH> class, or is there a general way to determine when a dialog RH> destroys/unmaps itself from outside of the dialog code? Using Tkinter, you can "wait" for a few specific events. "w.wait_window()" will wait for w to be destroyed. But even then, a destroyed window can not be reused! Alternatively wait_visibility() and wait_variable() methods can be used. I come back to my advertisement: in the *Dialog() classes in the Pmw framework this has all been programmed (using a wait_variable in that case); there is no real reason except "the fun of it" to reinvent this wheel... Regards, Rob Hooft. -- ===== R.Hooft at EuroMail.net http://www.xs4all.nl/~hooft/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From tismer at appliedbiometrics.com Sat Apr 3 06:40:24 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sat, 3 Apr 1999 11:40:24 GMT Subject: WinDLL CallDLL References: <370327E3.66047D53@easystreet.com> <3703CB0C.83AB035E@ingr.com> <370402DE.E6AD7C37@easystreet.com> Message-ID: <3705FE28.372A3D7A@appliedbiometrics.com> Al Christians wrote: > > I'm still getting some success running the DLLDemo.Py, but none > with any of the others. I get addressing exceptions from them. Well, I have never tested with NT SP4, so we can't be sure which piece of software is going nuts here. I will send you exactly the .pyd files which I use, and we will try some basic steps together. If that doesn't work, I would believe you have a problem with you system. [other path fiddling stuff which does not address the problem] > I've done that, too, and made the change to DynWin\__init__.py given > by Christian Tismer. Whatever you did, there is no reason for the kind of crashes you get. Dynwin should not work at all since it cannot import a module, or it should work just fine. > I've deleted my \Python directory and done several reinstalls of > Py152b2.exe. No success. Do I need to install from the source. > I've also tried re-building CallDLL.Pyd using MSVC++ v5. That > seemed to succeed. But I get the same run-time results. No, you need to use another approach to track this down. There is a different problem which you will not solve unless you do smaller steps. I never had the problems you have, just different ones. We need to step by steps check out if you can use calldll and npstruct as necessary, then check the modules which are built upon it. I will attach some examples which you should try. > I don't complain about something given gratis, like all this fine > python software, but there does seem to be some potential for improving > the packaging or beefing up the documentation a little here and there. Sorry, you are right in the general case but not in this one. Sam has done some great work. He has a very special minimalistic approach, and his number of users is relatively small compared to, say PythonWin. He never claimed that his stuff is ready, but it is all alpha stuff where he is providing a preview for the curious. Using DynWin is not using a ready-made package which has a couple of maintainers, but you are on your own, or better: You are jumping into the boat to help Sam with improving it. > I can offer some time to try to help do that for some of these packages > that run on NT. If any developers of python code that is licensed as > some variety of free or open source want to take advantage of the point > of view of a typically brain-dead potential user for a few hours and > collaborate on recording what we have to learn to do to get this stuff > installed, they could contact me. I suppose, however, that in most > cases it is pure lack of time that prevents production of more > documentation, and that it would be easier for the developer to write > it directly than to try to collaborate. This case is even worse since at the time Sam was working on DynWin and LumberJack, having reached his "critical mass", he was hired away """Ack! I have taken a full-time job, so work on lumberjack will halt for a couple of months. Stay Tuned...""" This was from October 17, see http://www.nightmare.com/~rushing/lumberjack/index.html That means he might be in the "gosh I simply got no time" state which I know very well. Until that becomes better, people like Gordon McMillan and me might be able to help. cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 gustav at morpheus.demon.co.uk Sat Apr 10 17:02:16 1999 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Sat, 10 Apr 1999 21:02:16 GMT Subject: Python without registry entries Message-ID: <370fb711.28093946@news.demon.co.uk> Hi, I'm trying to set up a Python distribution on CD, for transport to a number of PCs (possibly at client sites). My first thought is to install Python on my PC, with whatever optional modules I need, and copy that installation onto CD. That leaves me with a CD installation, which I can use on other PCs - the only problem is that I won't have any registry entries. In the first instance, I can set up registry entries as I need. All I need then is to know what registry entries Python requires (there's documentation on python.org for basic Python stuff, but what does pythonwin and the rest of win32all need?). However, it would be nice to be able to run Python, at some level, without *any* configuration changes (registry entries, environment variables) at all. (Perl runs fine from a CD binary distribution, with no registry settings). Can I do this? If so, what (if any) changes are needed to the basic installed distribution? Thanks for any help anyone can give me... Paul Moore. PS Will TCL/Tk (Tkinter) work in this way, too? If so, do I need to do anything further to set it up? From JamesL at Lugoj.Com Wed Apr 21 23:21:39 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 21 Apr 1999 20:21:39 -0700 Subject: How many of us are there? References: <371E2648.DED123AE@callware.com> <000301be8c67$08dd6600$959e2299@tim> Message-ID: <371E95C3.8D3EDE4D@Lugoj.Com> Tim Peters wrote: > > [Ivan Van Laningham] > > Hello, Pythonistas-- > > Does anyone out there have some idea how many people subscribe to the > > mailing list, or read the newsgroup? > > Yes, I keep exact daily tallies of both, along with the precise number of > Python programmers broken down by industry, application, age, gender, > income, countries of origin and residence, employer and life goals. Thank god he doesn't break down the numbers by aberrant food preferences. And no, I'm not saying. Otherwise I'd be the only Python programmer in the "Likes butter microwaved over Cheerios as a snack" category. > > While I can't pass this information out for free, it's available for a > price. How do you think all those spammers got your email address ? > > python's-demographics-make-perl's-look-like-cobol's-ly y'rs - tim Industry: Telecommunications Application: Network mismanagement Age: Over 40. Not saying how much. Gender: Mail or E-mail? Mail! Income: Never enough. Country of origin: U S of A Country of residence: Califunia; no wait, that doesn't seem right. Employer: Some unlikely startup. Life goals: To be able to identify a Larch. From ivnowa at hvision.nl Fri Apr 16 18:03:13 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Fri, 16 Apr 1999 22:03:13 GMT Subject: Simple module installation In-Reply-To: <37170674.F77233A6@prescod.net> References: <37170674.F77233A6@prescod.net> Message-ID: <199904162101.XAA02559@axil.hvision.nl> On 16 Apr 99, Ce'Nedra took her magical amulet and heard Paul Prescod say: >I was just installing Fnorb and it was as painless an installation as a >sane person could ask for but I got to thinking...couldn't this be less >painless? The reason I ask is because I'm thinking of distributing code >that depends on code that depends on code that depends on Fnorb and I need >each installation part to be as simple as possible. So this isn't meant to >pick on Fnorb in particular but to use it as a random sample package with >binary and Python parts. > >The only thing that makes it extremely mildly painful is that it requires >setting a few environment variables: > >FNORB_HOME >PYTHONPATH >PATH > >The PYTHONPATH and PATH would be unneccessary if Fnorb used the Windows >registry. Even so, I think that a Python-managed, portable, text >file-based registry (like JPython's) would be better than depending upon >the over-centralized Windows registry. Yes, please don't use the Windows registry! Using it doesn't actually *reduce* the "pain". (I never quite understood what good it was, anyway, aside of a feeble attempt at making copy protection more fool proof.) The Python-based registry as you describe it sounds neat. It sounds like it would be fairly easy to register and unregister programs and things, without messing up your whole system, unlike a certain other registry. >If Python could find scripts in its PYTHONPATH then this wouldn't be >necessary. So this is a feature request for that feature. I can implement >it if people agree it would be a good idea: > >python -r script: run the script named "script.py" in the PYTHONPATH This looks good too. >If we put my idea for a Python-managed registry together with the "-r" >idea then Fnorb could register itself on Windows or Unix like this: > >python -r register Fnorb /path/to/fnorb Hmm... but how do you *un*register? Nice ideas, + Hans Nowak (Zephyr Falcon) + Homepage (under construction): http://www.cuci.nl/~hnowak/ + You call me a masterless man. You are wrong. I am my own master. + May 60 trolls cut your chicken feathers out with your bad self! From fredrik at pythonware.com Tue Apr 20 05:53:46 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Apr 1999 09:53:46 GMT Subject: Tkinter Canvas & Fast Scrolling/Dragging References: <19990416174016.A1559856@vislab.epa.gov> Message-ID: <00b301be8b13$b0e35300$f29b12c2@pythonware.com> Randall Hopper wrote: > Basically, what I want to do is turn off filling of canvas objects > temporarily while the user is scrolling the canvas or they're dragging one > of the shapes. When the operation is finished (user releases the mouse), > I'll turn fill back on. > > The idea here being that the canvas seems to be pretty responsive for me > until it has to draw stipple shapes. Then it's painfully slow. > > I know how to do this for dragging, but I don't know where to "hook in" for > scrolling. I think the best way is to add bindings to the scrollbar(s). something like: scrollbar.bind("", my_canvas.no_detail) scrollbar.bind("", my_canvas.full_detail) might do the trick. another solution would be to hook into the scrollbar interface; see http://www.dejanews.com/getdoc.xp?AN=464786051 for some details. but that only allows you to figure out when to switch to less detail... you could perhaps switch back after a short timeout, or when the user moves the mouse back into the canvas. From jfarr at real.com Fri Apr 23 15:01:50 1999 From: jfarr at real.com (Jonothan Farr) Date: Fri, 23 Apr 1999 12:01:50 -0700 Subject: problem with windows sockets Message-ID: I'm rather stuck trying to solve a networking problem. I've implemented a TCP socket server derived from SocketServer.SocketServer and I want it to be able to restart itself. The problem I'm having is binding a socket to the same port twice. If I don't call setsockopt() with SO_REUSEADDR, then I get a winsock error 10048, defined in winsock.h as WSAEADDRINUSE (or 48, 'Address already in use' on Linux). It seems like setting SO_REUSEADDR should work, which it does on Linux but not on NT. Here's some example code to illustrate my point. --------------------- # Server: import socket port = 12000 queue = 5 print 'bind 1' s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', port)) s.listen(queue) client, addr = s.accept() client.send('foo') s.close() print 'bind 2' s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('', port)) s.listen(queue) client, addr = s.accept() client.send('foo') s.close() --------------------- # Client: import socket host = 'localhost' port = 12000 bufsize = 1024 print 'connect 1' s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) print s.recv(bufsize) s.close() print 'connect 2' s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) print s.recv(bufsize) s.close() --------------------- This works fine on Linux, but on NT I get a winsock error 10061 (defined as WSAECONNREFUSED) when I try to connect a client after binding the port a second time. Is this a problem with Winsock, a problem with Python, or a problem with my code? How can I work around this? Any help would be appreciated. Thanks, --jfarr From aa8vb at vislab.epa.gov Tue Apr 13 07:11:31 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 13 Apr 1999 11:11:31 GMT Subject: RPC and XDR with python In-Reply-To: <37119B99.B3E2633C@hons.cs.usyd.edu.au>; from Matthew Robert Gallagher on Mon, Apr 12, 1999 at 05:07:06PM +1000 References: <37119B99.B3E2633C@hons.cs.usyd.edu.au> Message-ID: <19990413071131.A1293592@vislab.epa.gov> |Does anybody know where these resource are located. |python.org has a couple of ref but nothing concrete | |It would be better find an example thou Well, haven't looked for RPC, but XDR is there. Here's a code snip from something I wrote recently, brutally cut and simplified to highlight how xdrlib can be used: -------------- next part -------------- import os # popen import struct # unpack import xdrlib # Unpacker import string # join # # Basic example # fp = os.popen( "SomeXDRGeneratingTool" ) buffer = fp.read() fp.close() unpacker = xdrlib.Unpacker( buffer ) a_double = unpacker.unpack_double() an_int = unpacker.unpack_int() a_float = unpacker.unpack_float() # # Utility rtn to read an undelimited array # def UnpackString( unpacker, str_len ): """ Unpack an undelimited XDR string with the characters stored as ints """ str = string.join( unpacker.unpack_farray( str_len, lambda unp=unpacker: chr( unp.unpack_uint() ) ), '' ) end = string.find( str, "\0" ) if end < 0: end = len( str ) return string.rstrip( str[ 0:end ] ) From olipt at mayo.edu Thu Apr 29 20:34:49 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Thu, 29 Apr 1999 19:34:49 -0500 Subject: Extension Doc bug In-Reply-To: <14120.52559.376120.364972@weyr.cnri.reston.va.us> References: <14120.52559.376120.364972@weyr.cnri.reston.va.us> Message-ID: > > Michael P. Reilly writes: > > I just spent the morning trying to find a very obscure bug related to > > the passing keyword arguments to a builtin method/function. > > Michael, > You didn't post your original code that exhibited the bug, so I > can't be sure of my conclusions. If you can send source for enough of > your extension module that someone can compile it, that would be > helpful. > My first inclination, however, is that you passed in illegal > arguments to PyArg_ParseTupleAndKeywords(). Passing NULL for the > keywords dictionary is allowed; I've been looking at the > implementation and don't see a way for that to be a problem (but I > might have missed something). > FYI, I've used PyArg_ParseTupleAndKeywords() in a C-extension and passed it a NULL pointer with no problems. Python 1.5.2b (Redhat 5.2 Linux 2.0.36) From paul at prescod.net Thu Apr 22 17:46:30 1999 From: paul at prescod.net (Paul Prescod) Date: Thu, 22 Apr 1999 21:46:30 GMT Subject: >>> Down-Translation? <<< References: <7fo16e$810$1@usenet49.supernews.com> Message-ID: <371F98B6.66A0515D@prescod.net> Nagwa Abdel-Mottaleb wrote: > > Greetings: > > I am looking for a suitable language that will enable me to > down-translate XML files into something like LaTeX files. > Is it easy to use Python for this process? For example, > how easy it is to write code segments that enable to > translate You want to find out about the Python XML sig. http://www.python.org/sigs/xml-sig You can use the code from the xml-sig to build a DOM which is an in-memory tree model of the data. Then you can walk the DOM and output the relevant LaTeX tags using "sys.stdout.write" or something like it. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "The Excursion [Sport Utility Vehicle] is so large that it will come equipped with adjustable pedals to fit smaller drivers and sensor devices that warn the driver when he or she is about to back into a Toyota or some other object." -- Dallas Morning News From gherman at my-dejanews.com Thu Apr 22 07:52:33 1999 From: gherman at my-dejanews.com (Dinu C. Gherman) Date: Thu, 22 Apr 1999 11:52:33 GMT Subject: Project for newbie References: <70alf7.qc6.ln@loopback> Message-ID: <7fn2i0$7ql$1@nnrp1.dejanews.com> In article <70alf7.qc6.ln at loopback>, morph at softhome.net wrote: > > I've read my way through the tutorial, and am now stuck - where do I go > from here? I want to learn how to use Python, but don't have any > pressing projects at the moment - can anyone suggest a program I should > have a go at writing, to help me learn the language further? What about this little problem, assuming you're interested in internet programming and keen to get familiar with the Python XML module...? ;-) Have fun, Dinu Context: The Altavista babelfish returns the following result page (see appendix below) after issuing this request: "translate 'water' from English to French" on that WWW page: http://babelfish.altavista.com Some quick testing reveales that you can do the same with just typing the following (wrapped) URL in your browser: http://babelfish.altavista.com/cgi-bin/translate? doit=done&urltext=water&lp=en_fr Exercise 1: Write a program babelfish.py calling the Altavista Babelfish over the WWW (using httplib, say) and parse its HTML output using your favorite HTML/XML parser (suggestion: use the XML module written by the Python XML-SIG) in order to extract the result and print it nicely in a terminal window like this: darwin> python babelfish.py water en_fr l'eau darwin> Exercise 2: Improve your program by allowing multiple words to be translated in a row, like this (you'll have to send multiple requests as Babelfish will try to treat your words as a sentence): darwin> python babelfish.py spam eggs en_fr spam oeufs darwin> Appendix: Sample Babelfish output (see context description) AltaVista: Translations AltaVista
Maps AltaVista Home
AltaVista Translation Help - AltaVista Home

En Fran?ais:

l'eau

Use the above text to search the Web

To translate, type plain text or the address (URL) of a Web page here:
Translate from:

Put the power of Babel Fish into IE 5. Get AV Power Tools (119k)

Download SYSTRAN Personal and translate your private documents in seconds.

AltaVista Home | Help | Feedback
©1995-98 | Disclaimer | Privacy | Advertising Info
-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From arnold at dstc.edu.au Sun Apr 18 23:17:15 1999 From: arnold at dstc.edu.au (David Arnold) Date: Mon, 19 Apr 1999 03:17:15 GMT Subject: Simple module installation In-Reply-To: Your message of "Fri, 16 Apr 1999 14:53:32 +0200." <371732CC.201012AF@lemburg.com> References: <371732CC.201012AF@lemburg.com> Message-ID: <199904190317.NAA12600@piglet.dstc.edu.au> -->"Marc-Andre" == M -A Lemburg writes: Marc-Andre> Paul Prescod wrote: >> The PYTHONPATH and PATH would be unneccessary if Fnorb used >> the Windows registry. in previous versions, Fnorb used the windows registry. however, this has now been removed because it caused endless problems: users would reinstall python, and all their fnorb code would break (since it used the previous installation's paths). so then they had to reinstall fnorb, even though nothing had changed, and then they had two fnorb installations, and ... so now you have a couple of environment variables, and a batch file which sets them to the "guessed" values. when you python installation changes, you can edit the batch file (easier and safer than editing the registry). >> Even so, I think that a Python-managed, portable, text file-based >> registry (like JPython's) would be better than depending upon the >> over-centralized Windows registry. we're hoping that the distutil-sig will come up with a nice solution ;-) d From barmar at bbnplanet.com Thu Apr 22 14:01:27 1999 From: barmar at bbnplanet.com (Barry Margolin) Date: Thu, 22 Apr 1999 18:01:27 GMT Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <371F11C2.3162025@ciril.fr> <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk> Message-ID: In article <4fv$ECA+JyH3EwbN at jessikat.demon.co.uk>, Robin Becker wrote: >I take this completely differently; least astonishment for me is if >program X looks and behaves the same way no matter what keyboard, mouse >and screen I'm using. As a 'user' of the program X it shouldn't matter >what OS/WM is executing the code. I certainly don't want vi or emacs to >be different on the mac why should I treat word or excel differently? I would be very surprised if Netscape on the Macintosh presented a Windows-like user interface, rather than adopting the standard Macintosh user interface. Most end users don't switch between platforms much, so it's more important that all the programs on their system conform to their expectations, than that a particular program work the same across different platforms. -- Barry Margolin, barmar at bbnplanet.com GTE Internetworking, Powered by BBN, Burlington, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group. From duncan at rcp.co.uk Thu Apr 15 04:58:10 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 15 Apr 1999 08:58:10 GMT Subject: 1.5.2 install problems on NT References: <3714D8FF.634655C5@ina.fr> Message-ID: <8DA968455duncanrcpcouk@news.rmplc.co.uk> Richard GRUET wrote in <3714D8FF.634655C5 at ina.fr>: >cl problems: >--------------- >shared by many ! see Hoon Yoon for instance... wish80;exe works (hence I >conclude that tcl is installed properly) but IDLE or Tkdb don't, with >insults like: >C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl: bad event type >bad event type or keysym "MouseWheel" > while executing >"bind Listbox { > %W yview scroll [expr - (%D / 120) * 4] units >}" > (file "C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/listbox.tcl > invoked from within >"source [file join $tk_library listbox.tcl]" > (file "C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl" lin > invoked from within >"source C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl" > ("uplevel" body line 1) > invoked from within >"uplevel #0 [list source $tkfile]" > >This probably means that Tk wasn't installed properly. > I had exactly that problem. I think it means that you upgraded an old Tcl system but there are still copies of the old Tcl80.dll files lying around somewhere and python is finding those in preference to the new ones. Delete tcl80.dll from the \winnt\system32 directory or wherever they are, and add the tcl bin directory (e.g. D:\Progra~1\Tcl\Bin) to the end of your path in the control manager/system/environment settings. -- Duncan Booth duncan at dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan From iam at not.you Wed Apr 28 14:59:34 1999 From: iam at not.you (Ken Power) Date: Wed, 28 Apr 1999 18:59:34 GMT Subject: Thankyou Mr. van Rossum and Python community Message-ID: <372757ce.23222371@news.mysolution.com> Thank you for creating Python. It's simply amazing. After a brief overview, I was able to create a small script. Big deal? Maybe, unless you realize it took me 2-3 days to write a similar script in VBA, using MSWord 97. The Python script is faster to boot and easier to change and extend. It makes me wonder how I have been able to program, let alone work, with out this valuable language. Again, thank you. -------------------------------- Ken Power uncle_wiggly at bigfoot dot com get that? -------------------------------- From cgw at fnal.gov Thu Apr 15 16:53:50 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Thu, 15 Apr 1999 20:53:50 GMT Subject: for in benchmark interested In-Reply-To: <14102.15523.573321.443195@bitdiddle.cnri.reston.va.us> References: <37157CE7.EFB470CA@inka.de> <14102.15523.573321.443195@bitdiddle.cnri.reston.va.us> Message-ID: <14102.20958.460408.832042@buffalo.fnal.gov> But won't this break apart words that happen to span across a 500000-byte blocks boundary? Jeremy Hylton writes: > The Python version would be faster if you used sys.stdin.read instead > of sys.stdin.readlines. I'm not sure why you need to split the input > into lines before you split it into words; it seems like an > unnecessary step. > while 1: > buf = read(500000) > if buf: > for key in string_split(buf): > dict[key] = dict_get(key, 0) + 1 > else: > return dict From jepler at inetnebr.com Thu Apr 29 21:13:10 1999 From: jepler at inetnebr.com (Jeff Epler) Date: Fri, 30 Apr 1999 01:13:10 GMT Subject: try vs. has_key() References: <7g51q6$1pt$1@vvs.superst.iae.nl> <14119.8145.293039.667256@bitdiddle.cnri.reston.va.us> Message-ID: On Wed, 28 Apr 1999 11:13:28 -0400 (EDT), Jeremy Hylton wrote: > d={} > for word in words: > first_two=word[:2] > d[first_two]=d.get(first_two, []).append(word) > >This second bit doesn't work because the append method on list objects >returns None. As a result, the first time a new value for first_two >appears None will be assigned to that key in the dictionary. The >second time that value of first_two shows up, None will be returned by >d.get. Then the code will raise an AttributeError, because None >doesn't have an append method. > >The following code would be correct: > > d={} > for word in words: > first_two=word[:2] > d[first_two]= temp = d.get(first_two, []) > temp.append(word) what about d[first_two] = d.get(first_two, [])+[word] ? Or is list construction and addition going to be enough more expensive than the function call to make this a lose as well? Jeff From landrum at foreman.ac.rwth-aachen.de Mon Apr 19 11:01:18 1999 From: landrum at foreman.ac.rwth-aachen.de (Greg Landrum) Date: Mon, 19 Apr 1999 17:01:18 +0200 Subject: Beginner - Tkinter info References: <371c59e9.2723125@news.tin.it> Message-ID: <371B453E.C3F83831@foreman.ac.rwth-aachen.de> Kranio wrote: > > I am just starting using python and I would like to learn more. I have > about all the docs written by guido but I haven't found yet > documentation about tkinter usage. Can you help me? > Where I can find some example of both python and tkinter? A couple of people have already provided pointers to what little there is in the way of Tkinter docs, so I'm not actually going to contribute anything towards answering this question. What I am going to do is take this wonderful opportunity to bitch and moan a little bit about the state of the Tkinter documentation. The rest of the "base" parts of python seem to be fairly completely documented. At least I can always find the information I need to solve whatever problem I happen to be having. This is a great thing (thanks Guido!) which makes it easy for experienced programmers who are new to Python to hit the ground running. Unfortunately, the same isn't even close to true of Tkinter. The most useful thing I have so far been able to find is Fredrik Lundh's "Introduction to Tkinter": http://www.pythonware.com/library/tkinter/introduction/index.htm While this contains some useful information, it has a couple of problems: 1) It's a work in progress (which means: "woefully incomplete"). 2) It isn't available as one download (if it is, I couldn't find it and I looked pretty hard). I do most of my programming at home where constant net access is not an option, so I like to have my docs locally accessible. Not to mention how frustrating problems with net lag are when trying to read docs. 3) It is woefully incomplete. I did my first "reasonable size" program in python the weekend before last. I really enjoyed the whole process (including learning more of the language), with the exception of figuring out how to make Tkinter work. If it hadn't been for Pmw (which includes copious examples and is almost completely documented), I would have thrown my hands up in disgust and either abandoned the project or gone back to straight C and XLib... which would have been a real shame, because the thrill of having my little networked game run essentially without modification on NT, linux and AIX was hard to beat. I know full well that writing docs is both boring and a pain in the ass, but they really are needed by the community and would (I think) help the growth of python. Just my two cents, -greg -- --------------------- Dr. Greg Landrum (landrum.NOSPAM at foreman.ac.rwth-aachen.de) Institute of Inorganic Chemistry Aachen University of Technology From skip at mojam.com Tue Apr 20 13:53:10 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 20 Apr 1999 17:53:10 GMT Subject: opening more than 1 file References: <371CB255.5FCAFBAF@solair1.inter.NL.net> Message-ID: <371CBF75.10FA1EE6@mojam.com> martin van nijnatten wrote: > > I have a variable, which can have a value in the range from 1 to 20. > > If the value is 7, I have to open 7 files. > > What could be an elegant way of doing this? Well, how about: files = [] for i in range(nfiles): files.append(open("/tmp/file%03d"%i, "wb")) then access the i-th file as files[i]? -- Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/ skip at mojam.com | Musi-Cal: http://www.musi-cal.com/ 518-372-5583 From jam at newimage.com Mon Apr 26 06:19:59 1999 From: jam at newimage.com (jam) Date: Mon, 26 Apr 1999 06:19:59 -0400 Subject: timeout on urllib.urlopen? In-Reply-To: <7g0r7c$gn9$1@nnrp1.dejanews.com>; from Kevin L on Mon, Apr 26, 1999 at 04:48:44AM +0000 References: <7g0r7c$gn9$1@nnrp1.dejanews.com> Message-ID: <19990426061959.A18551@toast.internal> On Mon, Apr 26, 1999 at 04:48:44AM +0000, Kevin L wrote: > > I'm trying to use urllib.urlopen() on a big list of urls, some of which are > dead (they don't return a 404, just no response). And the function just waits. > Is there any way to specify a timeout period for this function? thanks, > > Kevin > greetings, attached, please find a short lightly tested module that might do what you are looking for.. please let me know if this is what you need. it's a piece of code I wrote for a larger application, and it seems to get the job done nicely. suggestions for optimizations, etc, accepted. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. -------------- next part -------------- import socket import string import select from urlparse import urlparse, urlunparse from httplib import HTTP, HTTP_PORT from errno import EINPROGRESS, ETIMEDOUT class localHTTP(HTTP): def __init__(self, host = '', port = 0, timeout = 10.0): self.connect_timeout = timeout HTTP.__init__(self, host, port) def connect(self, host, port = 0): if not port: i = string.find(host, ":") if i >= 0: host, port = host[:i], host[i+1:] try: port = string.atoi(port) except string.atoi_error: raise socket.error, "nonnumeric port" if not port: port = HTTP_PORT self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if self.debuglevel > 0: print "connect:", (host, port) self.sock.setblocking(0) try: self.sock.connect(host, port) except socket.error, why: if why[0] == EINPROGRESS: pass else: raise socket.error, why (r, w, e) = select.select([], [self.sock], [], self.connect_timeout) if w == [self.sock]: self.sock.setblocking(1) return else: raise socket.error, (ETIMEDOUT, "timeout during connect phase") def checkurl(url): if url == "" or url == None: return None u = urlparse(url) netloc = u[1] path = u[2] h = localHTTP(netloc) h.set_debuglevel(0) h.putrequest("HEAD", path) h.putheader("accept", "text/html") h.putheader("accept", "text/plain") h.endheaders() return h.getreply() if __name__ == "__main__": print checkurl("http://quark.newimage.com:8080/") From trashcan at david-steuber.com Fri Apr 30 18:27:48 1999 From: trashcan at david-steuber.com (David Steuber) Date: 30 Apr 1999 18:27:48 -0400 Subject: running application config files written in Python References: Message-ID: Bjoern Giesler writes: -> PS David: a) Faking headers is Not A Good Thing. b) 12 lines of signature -> (even more in your previous mails) are Not A Good Thing Either. a) Which headers are you referring too? The return address I am using is valid. However, I get so much spam that I rarely check it any more. I basicly expect replys to go the the news groups so that everyone may benifit if by some miracle I ask a good question. b) I still have some wrinkles to work out with my signature. I have a fixed portion of text followed by the output of the fortune program. I can shorten the fixed portion easily enough. However, I don't know how to make fortune grab only short quotes. It is pot luck whether it is one line or ten. In the interim, I'll knock out four lines. -- David Steuber | s/trashcan/david/ if you wish to reply by mail Overheard in a bar: Man: "Hey, Baby, I'd sure like to get in your pants!" Woman: "No, thanks, I've already got one ass-hole in there now." From KUNCEJ at mail.conservation.state.mo.us Mon Apr 12 10:52:00 1999 From: KUNCEJ at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Mon, 12 Apr 1999 14:52:00 GMT Subject: Does the standard ftplib module support proxies? Message-ID: The standard urllib.py also supports proxies. I don't think the library manual explains it, and I found the internal docs insufficient. Search dejanews for urllib and proxy to find some help. Basically, you set an environment variable that defines the proxy: (NT example) SET http_proxy=http://204.71.200.68:8080 and urllib takes it from there. For me it works on a standard proxy, but not with a socks server This is just from my [recent] experience with a new firewall that was imposed on me. I'm not an expert on the subject. I hope the urllib documentation can be improved in this area. Maybe a python/firewall HOWTO is in order? --Jeff >>> Paul Moore 04/11/99 04:26pm >>> The header says it all... I've looked in the manual, but I can't see anything about proxy (firewall) support, one way or another. Actually, the same question applies to httplib and urllib. Thanks, Paul Moore. From stephan at pcrm.win.tue.nl Mon Apr 26 04:07:35 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 26 Apr 1999 10:07:35 +0200 Subject: Bug or Feature? References: <37208E69.4B022E0C@mediaone.net> <7fr3eg$bqr@world1.bellatlantic.net> Message-ID: "David Cuthbert" writes: > Fuming Wang wrote: > > Most definitely a feature. You're getting the same reference for all four > list elements. To break it apart: Nevertheless, it makes it difficult to construct multi-dimensional "arrays". For this, I would like to propose the following function which I use: (why isn't something like this in the standard library, or didn't I just look well enough?) # Make a tensor (i.e. list of list of lists...) def make_tensor(*args): if args: head = args[0] tail = args[1:] result = [] for i in range(head): result.append(apply(make_tensor, tail)) return result else: return None if __name__ == '__main__': print make_tensor() print make_tensor(3) print make_tensor(1,2) Greetings, Stephan From dubois1 at llnl.gov Fri Apr 2 20:07:50 1999 From: dubois1 at llnl.gov (Paul F. Dubois) Date: Sat, 03 Apr 1999 01:07:50 GMT Subject: Numerical Python download site temporarily changed Message-ID: The normal site LLNL site for Numerical Python downloads, xfiles.llnl.gov, is and will be unavailable for some days. Lacking sufficient notice to do anything better, I have copied the last two releases and the Numerical Python documentation to my own personal web site. The URL is: http://dubois.simplenet.com/python I will post to this group when xfiles is again available. We regret any inconvenience to the public. Paul F. Dubois Lawrence Livermore National Lab From stephan at pcrm.win.tue.nl Fri Apr 23 09:10:50 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 23 Apr 1999 15:10:50 +0200 Subject: opening more than 1 file References: <371CB255.5FCAFBAF@solair1.inter.NL.net> <371CCAE0.7DE87F8A@aw.sgi.com> <7fpteh$cik$1@news1.xs4all.nl> Message-ID: "Gornauth" writes: > Gary Herron wrote in message <371CCAE0.7DE87F8A at aw.sgi.com>... > >files = map(lambda i: open("file%02d"%i, 'w'), range(N)) > > I'm not completely sure how that one-liner works. To be honest, I have no > clue whatsoever. The above fragment is equivalent to: def open_file(i): filename = "file%02d" % i file = open(filename, 'w') return file files = map(open_file, range(N)) And the last line could be replaced by: files = [] for i in range(N): file = open(file(i)) files.append(file) Basically, 'lambda' is handy when you need to "def"ine a function but don't want to define a function, and map is handy when you need to do a for-loop but you don't want to do a for-loop. This allows one to write "simple" (as in "short") programs. > Could someone more python-literate please be so kind as to give a couple of > examples on how to use 'map' and 'lamba'? To start with map(): map() applies a given function to every element of a given list. In most cases, the same result could have been had with a for-loop. It is best for simple functions, especially built-ins, because in that case it's faster than the resulting for-loop, and for a simple function I find map often clearer. e.g. you have a list with integers and want to convert them all to strings: strlist = map(str, intlist) as opposed to: strlist = [] for i in intlist: strlist.append(str(i)) I find the first possibility not only shorter, but also more readable. Lambda lets you create a simple one-shot function. It is most useful when you need to pass a function as an argument, and the function you want to pass is very simple. You *can* combine map and lambda to simulate very complex for-loops. However, I think that in that case it's usually better to write out the for-loop. > > Met vriendelijke groeten, > Hans Groeten, Stephan From aaron_watters at my-dejanews.com Mon Apr 12 15:05:20 1999 From: aaron_watters at my-dejanews.com (aaron_watters at my-dejanews.com) Date: Mon, 12 Apr 1999 19:05:20 GMT Subject: hey advocates Message-ID: <7etg59$6mt$1@nnrp1.dejanews.com> I don't know whether it really matters or not, but aren't there any CGI or web applications written in Python? http://cgi-resources.com/Programs_and_Scripts/ [Actually, my experience has been that sites like this one don't actually accept submissions they have no exterior interest in, but it might be worth a try. Let's harass the poor bugger, shall we?] -- Aaron Watters ==== It's humbling to think that when Mozart was my age he'd been dead for 3 years. -- Tom Lehrer -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From cgw at fnal.gov Mon Apr 12 18:14:15 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Mon, 12 Apr 1999 22:14:15 GMT Subject: Converting a string to a tuple In-Reply-To: <01be8530$65bb7120$52037e81@saints> References: <01be8530$65bb7120$52037e81@saints> Message-ID: <14098.28727.245158.616727@buffalo.fnal.gov> Bruce Huzyk writes: > Here is a basic problem that is causing me much stress: > > I have a string a = '(1, "abc\\def", 2)' that I would like to convert to a > tuple. > > I have tried eval(), but it interprets the backslashes. The cheapest thing to do is this: import string def str_to_tup(s): return eval(string.replace(s, '\\', '\\\\')) If you're concerned about safety (the "eval" could be evaluating any Python code, possibly a hazard if the string is coming from user input) then you don't want to use eval at all, you need to actually process the string, looking for commas, quotes, backslashes, etc. If you need to do this, you may find some parser generator/lexical analyzer tools already in existence, if you look around python.org From sca at isogmbh.de Tue Apr 27 08:05:51 1999 From: sca at isogmbh.de (Chris...) Date: Tue, 27 Apr 1999 12:05:51 GMT Subject: threading/events questions Message-ID: <3725a47f.96308574@scout> Hello... After experimenting with the modules thread and threading I have some open questions. I've written the famous ping-pong program ----------------------------------------------------------------------------------------------------- from Threading import * from time import sleep Quit = Event() def f(t, msg): print msg Quit.wait(t) if Quit.isSet(): return f(t, msg) def run(): t1 = Thread(target=f, args=(10, 'ping')) t2 = Thread(target=f, args=(5, '\tpong')) t1.start() t2.start() sleep(60) Quit.set() ----------------------------------------------------------------------------------------------------- With that program, the threads are running for 60 seconds. But, how can I stop one thread and not both? I don't want to write an additional function doing exactly the same except dealing with a different Event. My second problem is sending an event with a message. ChangeOutput = Event() and send the event ChangeOutput('something different than ping-pong') to one thread. After receiving this message, the thread should change the recursive call to f(t, 'something different, than ping-pong'). How can I wait for events (more than one)? In the code above, I am just waiting for one event with a proper timeout. How can I react on the additional event ChangeOutput? Thanks a lot in advance! bye Chris... From fredrik at pythonware.com Tue Apr 13 03:21:15 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 13 Apr 1999 07:21:15 GMT Subject: role of semilcolon References: Message-ID: <00f401be857f$ff063410$f29b12c2@pythonware.com> Andy Dustman wrote: > a=1;b=2;b=3 > > is the same as: > > a=1 > b=2 > b=3 > > But a Pythonism you may want to adapt is: > > a,b,c = 1,2,3 that's a somewhat dubious pydiom: the semicolon variant is about twice as fast. (and unless you use the -O option, the semicolon form is also faster the one-assignement-per-line form...) From cjw at connection.com Wed Apr 14 22:04:33 1999 From: cjw at connection.com (Colin J. Williams) Date: Wed, 14 Apr 1999 22:04:33 -0400 Subject: Pythonw Tab setting Message-ID: <37154931.19739780@connection.com> The program AutoIndent.py has: prefertabs = 0 spaceindent = 4*" " Should spaceindent be changed to 2 if one wishes the tabs to have that value? Currently I use PythonWin which permits the user to change the Tab value (incidentally, it also provides for breakpoints). Any advice would be appreciated. Colin W. From achrist at easystreet.com Sat Apr 3 02:00:07 1999 From: achrist at easystreet.com (Al Christians) Date: Fri, 02 Apr 1999 23:00:07 -0800 Subject: string.join() vs % and + operators References: <37054490.E79ADCC9@easystreet.com> <000001be7d92$ea8da080$879e2299@tim> Message-ID: <3705BC77.E2C4EA8B@easystreet.com> Tim Peters wrote : (All kinds of [snipped] insights and outsights) Great stuff, Tim. You are right. Your method boosts speed by a factor of 5 over the fastest of my 3 methods, which already looked to be fast enough not to worry about. In the applications I'm looking at, building records from a few dozen fields each and then writing them out to indexed files, the record building should take much less time than the I/O and record manager. So, no matter how fast or slow Python is compared to brand X, the internal processing will be pretty insignificant as a part of the total run time. Does-the-next-Python-book-tell-how-to-finish-a-message-so-that-the-reader's-IQ-equals-their-percentage-of-comprehension? Al From hyoon at bigfoot.com Fri Apr 16 14:12:30 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Fri, 16 Apr 1999 14:12:30 -0400 Subject: restore sources from PYC [Q] References: <000101be879c$8aed0670$6eba0ac8@kuarajy.infosys.com.ar> Message-ID: <37177D8E.FF43BF65@bigfoot.com> Hi, What happens if you do NOT want your pyc codes to be reverse engineered? Can you prevent someone from doing this type of rev eng? Some members in my IT committee always have a problem with this ability and often used as excuse to kill any new tech adoption. Michael Hudson wrote: > > "Bruno Mattarollo" writes: > > Hi! > > > > By mistake I am unable to find the PY files (source) from a project I was > > working on. I only have the PYC files... Is there a way to recover the > > sources from the PYC? I only need my sources, I don't give a d... for the > > comments... > > Well.... The pyc files are marshalled code objects (after an eight > byte header), and there's the standard module dis which can > disassemble code objects, from which you could have a stab at > rewriting your code. You certainly wouldn't *want* to do it this way. > > It would probably be within the bounds of possibility to write a > decompiler, though unless you've lost a vast heap of code this is > going to be a much bigger project than rewriting your code. > > Anyway, if it helps, here's a function that'll pull the code out of a > .pyc file and disassemble that code: > > def dis_pyc(pyc_name): > import marshal,dis > file=open(pyc_name,'rb') > file.read(8) > code=marshal.load(file) > did.dis(code) > > (NB: This isn't much use because defined functions and classes are in > their own code objects stored as constants - they're still accessible, > in code.co_consts, but this code doesn't go looking for them) > > > TIA > > > > /B > > > > Bruno Mattarollo > > ... proud to be a PSA member > > Good luck! > > Michael -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From Bjoern.Giesler at stud.uni-karlsruhe.de Wed Apr 21 07:23:47 1999 From: Bjoern.Giesler at stud.uni-karlsruhe.de (Bjoern Giesler) Date: 21 Apr 1999 11:23:47 GMT Subject: Tkinter Q Message-ID: <7fkcg3$61o$1@news.rz.uni-karlsruhe.de> Hi, whenever I try to construct a slightly more complicated Tkinter test at the Python console, I get a FloatingPointError. The same program written to a file works flawlessly. Is that a known bug? --Bjoern From samschul at ix.netcom.com Tue Apr 13 12:59:57 1999 From: samschul at ix.netcom.com (Sam Schulenburg) Date: Tue, 13 Apr 1999 09:59:57 -0700 Subject: New Python Book err on Page 265 Message-ID: <7evt60$2e7@dfw-ixnews9.ix.netcom.com> I received the new Programming Python book and found an error on Page 265 in the get_temperature(country,state,city) function. line 13: stop = string.index(data,'°v;F',start-1) s/b stop = string.index(data,'°F',start-1) With this correction the function works as advertised. Mark this is a great book. Sam Schulenburg From gutier at intergate.bc.ca Sat Apr 17 15:54:30 1999 From: gutier at intergate.bc.ca (Gerald Gutierrez) Date: Sat, 17 Apr 1999 12:54:30 -0700 Subject: Plugins, or selecting modules to import at runtime Message-ID: <924379180.825429211@news.intergate.bc.ca> Hi all. I'd like to write a program in Python in which the user can select one of several modules to execute through a function that has the same name in all the modules. I don't believe "import" lets me pass it a string. There is also reload(), but the module to reload must be previously imported. This is very similar to plugins like that used in Netscape, Photoshop and the GIMP. Can someone please give me a hint? Thanks. Please forward replies to gutier at intergate.bc.ca. From sjoerd at oratrix.nl Wed Apr 21 09:44:04 1999 From: sjoerd at oratrix.nl (Sjoerd Mullender) Date: Wed, 21 Apr 1999 13:44:04 GMT Subject: Job opening at Oratrix, Amsterdam Message-ID: <19990421134405.030A1301D04@bireme.oratrix.nl> Oratrix Development is a newly formed company that originated in the multimedia group at CWI. The very same group that released both Python and Guido to the Python community. Oratrix Development is located in Amsterdam, The Netherlands. We are an IT startup company that develops and markets authoring and presentation software for multimedia presentations that are going to be distributed to end-users via the Internet. Oratrix markets its products under the name GRiNS. The GRiNS suite will consist of a GRiNS authoring tool for creating presentations and a GRiNS player for end-user viewing of presentations. GRiNS was designed to support the World-Wide Web Consortium (W3C) standard language SMIL, the Synchronized Multimedia Interchange Language (pronounced "smile"). Unlike HTML, SMIL is an XML-based language that allows users to define temporal relationships among objects in a presentation. The GRiNS suite of programs is almost completely written in Python and is in fact the oldest extant Python project. Guido himself once worked on this project (before it was called GRiNS). We are working hard on the first GRiNS suite products and are looking for enthusiastic Multimedia Programmers/Developers with knowledge and experience in some or all of the following areas: Python (obviously), Pythonwin, C++, Direct X, Netshow, Windows 95/98/NT APIs. If you are interested or want to recommend a friend, please send a message to Manja Strick van Linschoten or call her on +31-20-6795306. -- Sjoerd Mullender Jack Jansen From guido at eric.cnri.reston.va.us Thu Apr 29 09:08:51 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 29 Apr 1999 09:08:51 -0400 Subject: IDLE ! References: <371ADC8C.54C4CDBE@zipzap.ch> <3728126B.E35F4464@bph.ruhr-uni-bochum.de> <37281303.73BB69A4@bph.ruhr-uni-bochum.de> Message-ID: <5l3e1jbml8.fsf@eric.cnri.reston.va.us> Marc Saric writes: > Some things I would like to see in an updated version: > > Cursor-up-and-down-history in the command shell, like in PTUI. It's there, try ESC-p and ESC-n. You can also do something like >>> pr and then ESC-p will retrieve the previous command starting with 'pr'. Also, you can move the cursor to a previous command and simply hit Return; this will move it to the bottom for further editing or you can hit Return again to execute it. > Some key-bindings seem to be problematic (at least with a german > keyboard; you cant press "CTRL+ [" for indentation for example). I admit that the key bindings are not ideal; there seems to be no universally accepted set of bindings. In a future version, you will be able to customize your key bindings more easily; right now, editing the keydefs file is your only resort. (If someone is willing to put some effort in coding up this feature, it would be greatly appreciated!) > On Unix (SuSE 6.0 to be exact) I can't manage to get proper > Windows-style copy and paste (CTRL+C, CTRL+V) (I don' like the > Unix-key-bindungs, and therefore changed that to the > windows-settings). How exactly did you change to the windows-settings? Is it ^C or ^V that doesn't work? (You can verify this using the Edit menu.) ^V is a Tk default binding for scroll-down; ^C is an IDLE binding in the Shell window for interrupt; either might cause you problems (I haven't tried this myself). > Maybe it's just me who is too stupid, and someone may help me... No, and yes... --Guido van Rossum (home page: http://www.python.org/~guido/) From bbaetz at ug.cs.usyd.edu.au Wed Apr 28 04:13:54 1999 From: bbaetz at ug.cs.usyd.edu.au (Bradley Baetz) Date: Wed, 28 Apr 1999 18:13:54 +1000 Subject: Q on Tkinter Scrollbar References: <370CFAC8.32EB0B29@ingr.com> <7g2g0f$km7$1@mlv.mit.edu> Message-ID: <3726C342.1DF7C6D6@ug.cs.usyd.edu.au> > I think you need to, in _vscroll, set the position of the scrollbar. > I did this exact thing in a tcl app once, so I know it's possible. > It's a bit of work to figure out where things are supposed to be, but > you're going to have to tell it what being halfway down means anyway. > > Michael Is it possible to find out the location of the top and bottom character of a tkinter text object currently showing? I want to be able to seardch for a tag on the currently viewable portion, but I can find out the start and end positions of the text. Thanks, Bradley From ucvocnmb at somethingfunny.net Tue Apr 13 14:41:32 1999 From: ucvocnmb at somethingfunny.net (ucvocnmb at somethingfunny.net) Date: Tue, 13 Apr 1999 18:41:32 GMT Subject: --- No Obligation - Be paid to Surf!! ---- Message-ID: An unregistered copy of Newsgroup AutoPoster 95 was used to post this article! --- http://www.alladvantage.com/go.asp?refid=ATE-943 This link will take you to a site of a Company that has launched this promotion only a week ago. This will not cost you any money and only a little time. It is not guaranteed to work, but, if this takes off, you'll kick yourself for not trying it. Go to the site indicated and read up on it and maybe sign-up. If you don't get involved, at least you learned about something! Good luck! http://www.alladvantage.com/go.asp?refid=ATE-943 From kelvin_chu at my-dejanews.com Sun Apr 25 15:19:47 1999 From: kelvin_chu at my-dejanews.com (kelvin_chu at my-dejanews.com) Date: Sun, 25 Apr 1999 19:19:47 GMT Subject: HELP! NumPy (Graphics) and Linux Message-ID: <7fvpsh$l8e$1@nnrp1.dejanews.com> Hi all; I've had great success with EZplot and now want to move my code to Linux- based platforms in my lab. I am having significant difficulties building the Graphics portion of NumPy. 0. I am running RedHat linux 5.2 1. I have installed Yorick in the cannonical place. 2. Instead of libX11.a, I have a shared-object library, locatedin /usr/X11R6/lib When I do the build (python makethis.py), I receive the following error: gcc -fpic -I/usr/local/lib/yorick/1.4/h -g -O2 -I/usr/local/include/python1.5 -I/usr/local/include/python1.5 -DHAVE_CONFIG_H -c ./Gist/Src/gistCmodule.c ./Gist/Src/gistCmodule.c:75: arrayobject.h: No such file or directory ./Gist/Src/gistCmodule.c:88: warning: `PyFPE_END_PROTECT' redefined /usr/local/include/python1.5/pyfpe.h:169: warning: this is the location of the previous definition make: *** [gistCmodule.o] Error 1 I suspect that I am going to run into multiple problems. There is a cryptic statement in the README that indicates that I should do import_arrays() before doing the build...where do I implement this? How much of this problem is related to the shared object X libs? Thanks, I appreciate any light you can shed on this matter! Cheers, Kelvin -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From eugened at istar.ca Wed Apr 21 23:23:59 1999 From: eugened at istar.ca (Eugene Dragoev) Date: Wed, 21 Apr 1999 23:23:59 -0400 Subject: The Future of Tk? Message-ID: <371E964F.C531C2A@istar.ca> For programmers using languages other than Tcl. I recently "discovered" the latest stable version of Tcl/Tk (8.05) and must say that was quite impressed by the simplicity and ease of use of Tk. But I also found that while older versions of Tk were using lightweight components (Some Java terminology :) the latest version is using native components for things like scrollbars and buttons. I don't want to say that this is bad for Tcl users but what about all the other languages that use Tk? Isn't writting multiplatform GUI harder using native components. I think Java made big step forward in abandoning the native components and using lightweight ones in Swing. Is there going to be any Tk implementation that will continue using lightweight components? What do you think? Eugene From aaron_watters at my-dejanews.com Thu Apr 8 11:15:30 1999 From: aaron_watters at my-dejanews.com (aaron_watters at my-dejanews.com) Date: Thu, 08 Apr 1999 15:15:30 GMT Subject: GadFly - MemoryError References: <370B5E83.C796BFF3@palladion.com> Message-ID: <7eih6b$ck2$1@nnrp1.dejanews.com> It would be interesting to try this, but my guess is that this would be slower than the first query since equalities are optimized and "in" is not. I hope oleg is using gadfly 1.0 too (not beta 0.2 or whatever). -- Aaron Watters In article <370B5E83.C796BFF3 at palladion.com>, Tres Seaver wrote: > Oleg Broytmann wrote: > > > > Hello! > > > > I tried to add yeat another database backend to my project "Bookmarks > > database". My database contains now about 3000 URLs, not too much, I think. > > I subclass by BookmarksParser to parse bookmarks.html into gadfly database > > and got a database of 500 Kbytes - very small database, I hope. > > Then I tried to find duplicates (there are duplicates). I ran the query: > > > > SELECT b1.rec_no, b2.rec_no, b1.URL > > FROM bookmarks b1, bookmarks b2 > > WHERE b1.URL = b2.URL > > AND b1.rec_no < b2.rec_no > > How many duplicates are there? Something like > > SELECT URL FROM bookmarks GROUP BY URL HAVING COUNT(*) > 1 > > will produce the URL's with duplicates; you could then do > > SELECT rec_no, URL FROM bookmarks > WHERE URL IN > (SELECT URL FROM bookmarks GROUP BY URL HAVING COUNT(*) > 1) > > or create a temp table first with the results of the subquery, then join it in a > separate query. > -- > ========================================================= > Tres Seaver tseaver at palladion.com 713-523-6582 > Palladion Software http://www.palladion.com > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From merlyn at stonehenge.com Thu Apr 29 10:24:00 1999 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: 29 Apr 1999 07:24:00 -0700 Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: >>>>> "Dan" == Dan Schmidt writes: Dan> Four and a half, actually; Perl 5.000 was released in October 1994, Dan> exactly a week after Python 1.1. In fact, Perl 5 has been the current Dan> version longer than Perl 4 was (Perl 4 was released in March 1991, so Dan> it was the newest version for only three and a half years). Not to mention that *all* versions of Perl prior to 5.004 have known, documented buffer-overflow potential problems, so if you use those scripts in any public-execution environment (like CGI or setuid programs or daemons), you are setting yourself up for a "non use of best practices" lawsuit when the bad guys break in. I'm told by people in-the-know of a rootkit that targets *any* CGI script and sends it the right thing to break in, presuming you know the arch of the box and have a reasonable guess as to the Perl version. Perl 4 is dead. Anything before 5.004 is dangerous. Perl5 *is* Perl. Just another Perl (and Python) hacker, -- Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095 Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying Email: Snail: (Call) PGP-Key: (finger merlyn at teleport.com) Web: My Home Page! Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me From tim_one at email.msn.com Sat Apr 3 02:54:58 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 3 Apr 1999 07:54:58 GMT Subject: Python Chip In-Reply-To: <3703D175.85747FEE@pop.vet.uu.nl> References: <3703D175.85747FEE@pop.vet.uu.nl> Message-ID: <000501be7da7$450ddf20$879e2299@tim> [Martijn Faassen] > This isn't official, but have you all heard about the Python chip? > ... [recklessly premature disclosure deleted] ... [Chad Netzer] > April fools, right? [Martin] > No, no, this is as serious as a ten ton weight! Just ask Tim about the > stress tests if you still don't believe it. :) > > Is-it-april-already-ly yours, As Martijn reported, the stress tests are going *amazingly* well, modulo a subtle space/tab screwup in the hardware. I've completed VLSINANNY.py, which will verify future hardware conformance to generally accepted international leading whitespace principles, but the Russian part of the team is refusing to cooperate in protest of Kosovo (although if you ask me, they're just pissed at the Swedes for sneaking herring into the borscht ... again). Delicate international diplomacy aside, the tests are *so* promising that the Steering Committee has delayed announcement of the 1999 Pythonic Award, pending completion of a successful run of GuidoStone.py, a full real-time 3D simulation of a gawky Dutchman throwing rocks at a Sicilian mobster, from the back of a galloping camel. This was supposed to complete yesterday, but was interrupted when Larry Wall ran up from the back of the room and smashed the chip with his bare hands. Guido-- the very definition of grace under pressure --quipped "But, Larry, *we've* known for a decade that you've wasted your life!", and pulled a backup chip out of his sneer. The most important thing, though, is that until they say otherwise, I'm *still* the Only Living Pythonic Award winner! no-joking-matter-ly y'rs - tim From nascheme at m67.enme.ucalgary.ca Fri Apr 16 18:17:32 1999 From: nascheme at m67.enme.ucalgary.ca (Neil Schemenauer) Date: 16 Apr 1999 22:17:32 GMT Subject: reval builtin References: <7f36m6$koq@ds2.acs.ucalgary.ca> <001701be86e0$68574a60$589e2299@tim> Message-ID: <7f8cts$cei@ds2.acs.ucalgary.ca> On Thu, 15 Apr 1999 01:36:38 GMT, Tim Peters wrote: >def reval(string): > return eval(string, {"__builtins__": {}}) Yes, I know that trick. It is much too easy and straight forward though. ;) >If you're determined to allow only literals (I don't see any harm in >allowing e.g. 1+3), probably easiest to feed the string to the std parser >module, then crawl over the AST looking for things to complain about. I thought of doing that but suspected that it would be pretty slow. I decided to waste some of my time and hand code a parser. I will announce it in another post. Since your the compiler guy, you should able to point out all the errors in my code, right? picking-tim-bots-umm-brain?-ly y'rs - Neil From dalke at bioreason.com Sun Apr 25 21:14:51 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Sun, 25 Apr 1999 19:14:51 -0600 Subject: Handling backspace chars in a string... References: <37239c48.594910176@news2.bga.com> Message-ID: <3723BE0B.EFEC289A@bioreason.com> bwizard at bga.com (Purple) said: > I'm in the posistion of having to process strings with arbitrary > numbers of backspace and newline characters in them. The backspaces > actually get put in the string, so I have to handle removing the > characters that are backspaced over. > > [one implementation given] > > This just looked rather messy to me -- I was curious if anyone know > a better way? Here's one possibility. It uses a regular expression substitution to replace + with the empty string. (Note: don't use a raw string for the re; r".\b" will find a character which is before a word break.) When done, it removes all the leading backspaces. import re char_backspace = re.compile(".\b") # Don't use a raw string here any_backspaces = re.compile("\b+") # or here def apply_backspaces(s): while 1: t = char_backspace.sub("", s) if len(s) == len(t): # remove any backspaces which may start a line return any_backspaces.sub("", t) s = t >>> apply_backspaces("\bQ\b\bAndqt\b\brew Dalkt\br\be") 'Andrew Dalke' You mentioned something about containing newlines. By default, the "." re pattern doesn't match a \n, so the above code acts like a normal tty, and doesn't remove the \n if followed by a newline. This is likely the right thing. That's also why I delete any backspace because "this\n\bthat" should be the same string as "this that" Andrew Dalke dalke at acm.org From adustman at comstar.net Mon Apr 12 19:06:08 1999 From: adustman at comstar.net (Andy Dustman) Date: Mon, 12 Apr 1999 23:06:08 GMT Subject: role of semilcolon In-Reply-To: References: Message-ID: On 12 Apr 1999, Reuben Sumner wrote: > In the python interpreter doing 'a=1;b=2;b=3' does what I would > expect, three seperate assignments. However ; doesn't seem to appear > in the language reference except in the list of delimeters. Is the > above example formally valid python? Semicolon is a statement separator. So is the end of line unless you have open parentheses, brackets, braces, or triple-quotes. So: a=1;b=2;b=3 is the same as: a=1 b=2 b=3 But a Pythonism you may want to adapt is: a,b,c = 1,2,3 In practice, semicolon is rarely used in Python, since the end of line separates statements just as well with one less byte (none vs. one :), and multiple assignments can be done as above. -- andy dustman | programmer/analyst | comstar communications corporation telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d From tjreedy at udel.edu Tue Apr 6 22:36:02 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 7 Apr 1999 02:36:02 GMT Subject: Xbase++ preprocessor implementation in Python References: <37097A3A.F772205@magna.com.au> Message-ID: <7eegai$3ak$1@news.udel.edu> In article <37097A3A.F772205 at magna.com.au>, garys at magna.com.au says... >Attached please find a Python implementation of the Xbase++ preprocessor. ... >Oh, and it is *dead slow*! - hundreds of times slower I think! ... I do not know re's well enough to comment on whether they can be rewritten to run faster. I believe there is a python profiler which might give indications on where to start to speed things up. Terry J. Reedy From matt at mondoinfo.com Sun Apr 11 14:59:56 1999 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sun, 11 Apr 1999 13:59:56 -0500 Subject: best way to copy a file [Q] References: <000201be8441$7965d4d0$6eba0ac8@kuarajy.infosys.com.ar> Message-ID: In article <000201be8441$7965d4d0$6eba0ac8 at kuarajy.infosys.com.ar>, "Bruno Mattarollo" wrote: > Hi! > > I need to copy a file (can be binary or ascii) from one path to > another. I > have tryied to do: > line = fd.readline() > while line: > fd2.write(line) > line = fd.readline() > fd.close() > fd2.close() > > It only works for ascii files ... How can I do a 'copy' ...? I need to > run > this on NT ...:( And I don't want to open a shell to do a copy from > there... I also tryied fd.read() ... No success neither. I have looked > unsuccesfully throughout the documentation and didn't find a 'filecopy' > method. The files can range from 1KB to 600MB+ ... Bruno, You need to open the files in "binary" mode since Windows makes a distinction between text and binary files. I understand that something like in=open("file","rb") out=open("file2","wb") should work. Also, you might want to reconsider using readline() for binary files. If a large binary file happened not to contain \r\n, readline() might try to grab an unreasonably large piece of the file: >>> foo=open("/dev/zero") >>> foo.readline() Bus error The function copyfile() in the standard module shutil would probably work well for you. But now you know why . Regards, Matt From dacut at kanga.org Fri Apr 23 20:32:41 1999 From: dacut at kanga.org (David Cuthbert) Date: Fri, 23 Apr 1999 20:32:41 -0400 Subject: Bug or Feature? References: <37208E69.4B022E0C@mediaone.net> Message-ID: <7fr3eg$bqr@world1.bellatlantic.net> Fuming Wang wrote: > I found this little surprise with Python 1.5.1: > >list = [[0]*2]*4 > >list > [[0, 0], [0, 0], [0, 0], [0, 0]] > >list[0][1] = 9 > >list > [[0, 9], [0, 9], [0, 9], [0, 9]] > Is this a bug or a feature that I don't know about? Most definitely a feature. You're getting the same reference for all four list elements. To break it apart: list = [[0] * 2] * 4 # let a = 0, an integer. [[a] * 2] * 4 # integers are immutable, so a copy is made # for [a] * 2; let the copy be b. [[a, b]] * 4 # ah, but [a, b] is a list, q. [ q ] * 4 # lists are mutable, so we're just expanding # references that all refer to the same # q object. [ q, q, q, q ] # Ta da! All four elements have the same # object. If this were not the case, lists would be completely unnecessary since they would be the same as tuples! From faassen at pop.vet.uu.nl Tue Apr 27 12:29:32 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Tue, 27 Apr 1999 18:29:32 +0200 Subject: Pointers to variables References: <19990422121403.A279051@vislab.epa.gov> <371F6124.48EA9794@pop.vet.uu.nl> <7g2f5m$kl6$1@mlv.mit.edu> Message-ID: <3725E5EC.63AC65B1@pop.vet.uu.nl> Michael Vezie wrote: > > In article <371F6124.48EA9794 at pop.vet.uu.nl>, > Martijn Faassen wrote: [snip my code example] > > I don't think it has anything to do with mutable or not. mylist[0] > simply points (at first) to the same object (string) that > variable_i_want_to_change (hereafter called 'var2chg'). Then, > at the second assignment, mylist[0] points to something different. > If var2chg were an array or dictionary, it would make no difference; > mylist[0] would still, after the second assignment, be "Bar". I know this; I probably made it sound too horribly complicated. > > mylist = [None] > > variable_i_want_to_change = {} > > mylist[0] = variable_i_want_to_change > > mylist[0]["some key"] = "bar" # indeed changes > >variable_i_want_to_change! > > This is different from the other examples. Here, you dereference > mylist[0] (which is still pointing to the same object that var2chg > points to). So the common object that they both point to changes. > Strictly speaking, you aren't changing var2chg, just that which it > (and mylist[0]) points to. Yes, that's because everything in Python is a reference. But in case of immutable objects this is identical to value semantics, unless you use a tuple which contains a mutable object in itself. > > # mylist[0] = "Bar" -- doesn't work, makes mylist[0] point elsewhere > > Well, it works as expected. It changes mylist[0], not what mylist[0] > references. If you know you're dealing with references and that assignment only changes what variable references what data, yes. I was attempting to explain the implications of this, but I admit it was horribly convoluted. :) [snip my atrocious C code] > I wonder if this is how it goes. I've not dived into the python > engine code, so I don't know. Are immutable objects stored as > objects or just as the data? I haven't dived in the Python code either, but I've seen people talk about Python allocating an object for either integer, so I imagine yes. > In the grand scheme of things, it > really makes no difference. If there were an "add" method for > ints (so you could say: > > var2chg = 5 > var2chg.add(3) > > and have var2chg have a value of 8), then it would obviously be > a concern. But you can't, so it really doesn't matter at the > python level whether: > > a = 5 > b = a > > means that b and a point to the same object, or to separate > values of 5. If you could do b.add(3) and suddenly have a > with a value of 8, then it would. Yes, unless you deal with tuples, which are immutable, but can contain mutable things: a = { "mutable" : "Yes" } b = (a, "foo") c = b c["mutable"] = "really" # b is changed at this point too, even though the tuple was immutable This was pointed out to me on the Python tutor list after I pointed out that reference vs value semantics is the same in case of immutable objects. It's only the same in case they're deeply immutable (or if you exclude tuples). Anyway, I was trying to attempt to explain the same principles as you did; I just wasn't very succesful at it. :) Regards, Martijn From debot at xs4all.nl Sun Apr 11 08:31:50 1999 From: debot at xs4all.nl (Frank de Bot) Date: Sun, 11 Apr 1999 14:31:50 +0200 Subject: Processing time Message-ID: <37109636.1FF246CB@xs4all.nl> How can I get the Processing time of a script? -- \\\|/// \\ - - // ( @ @ ) /----------------------oOOo-(_)-oOOo--------------------\ | | | | | My Email: debot at xs4all.nl | | Homepages: http://www.searchy.net/ | | http://www.debot.nl/ppi/ | | | | | \-------------------------------Oooo--------------------/ oooO ( ) ( ) ) / \ ( (_/ \_) From oakley at channelpoint.com Thu Apr 22 18:31:19 1999 From: oakley at channelpoint.com (Bryan Oakley) Date: 22 Apr 1999 22:31:19 GMT Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <371F11C2.3162025@ciril.fr> <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk> Message-ID: <7fo7vn$irf$12@newsread.f.de.uu.net> Barry Margolin wrote: > > In article <4fv$ECA+JyH3EwbN at jessikat.demon.co.uk>, > Robin Becker wrote: > >I take this completely differently; least astonishment for me is if > >program X looks and behaves the same way no matter what keyboard, mouse > >and screen I'm using. As a 'user' of the program X it shouldn't matter > >what OS/WM is executing the code. I certainly don't want vi or emacs to > >be different on the mac why should I treat word or excel differently? > > I would be very surprised if Netscape on the Macintosh presented a > Windows-like user interface, rather than adopting the standard Macintosh > user interface. Most end users don't switch between platforms much, so > it's more important that all the programs on their system conform to their > expectations, than that a particular program work the same across different > platforms. I would have to agree with that statement. While there are those who think retaining the same look and feel across platforms is necessary, I would wager they are in the distinct minority. That's not to invalidate their position, but merely to put it in context. _Most_ users of software want a package to look and feel like the other packages on a given system. I hate, for example, the artsy (-fartsy) graphic programs that have some weird UI instead of a more traditional UI. On the other hand, to some degree this is application-dependent rather than user-dependent. For example, if I were to have a requirement to write a air traffic control program that had to run on BeOS, MacOS, NT and *nix, I would think there would be significant advantages to keeping it 100% identical across all platforms. So, to some degree it depends on the application, or the targeted user base. My point being, there's a need in the world for both models. Only, the model where applications should adhere to native conventions is (I'm guessing) far and away the most commonly expected model by most users. Which is why I think using native windows on Tk is a win -- it meets the needs of the majority (though definitely not all) of the users in the world. -- Bryan Oakley mailto:oakley at channelpoint.com ChannelPoint, Inc. http://purl.oclc.org/net/oakley From rhww at erols.com Wed Apr 21 03:23:20 1999 From: rhww at erols.com (R Wentworth) Date: Wed, 21 Apr 1999 03:23:20 -0400 Subject: HTMLgen in Java? References: <7f2are$kqq$1@panix.com> Message-ID: <371D7CE8.7CF9067@erols.com> "David C. Lambert" wrote: > > I'm looking for a Java class library (freeware) that is more > or less parallel to HTMLgen in its capabilities and structure. > (That is, classes encapsulating the programmatic generation > of the major HTML structures). Well, one option might be to use JPython, in which case you would have easy access to any Java class library you like, from Python. Granted, this may not be the right solution for everyone. (See http://www.python.org/jpython) > If anyone knows of such a beast, I'd appreciate a pointer. > > TIA. > > - David C. Lambert > dcl at panix.com From aa8vb at vislab.epa.gov Tue Apr 6 08:27:04 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 6 Apr 1999 12:27:04 GMT Subject: mxDateTime in Python distribution In-Reply-To: ; from Oleg Broytmann on Tue, Apr 06, 1999 at 04:15:32PM +0400 References: <19990406070255.A867135@vislab.epa.gov> Message-ID: <19990406082704.A868024@vislab.epa.gov> Oleg Broytmann: |> I needed to do some date/time arithmetic recently and found that core |> Python didn't have this functionality. I was a little skeptical about |> using a seperate extension for portability reasons. | | There is always some need for something more. Do you really want to |include every bit of code into the Library? It would take infinite time to |download and compile Python distribution if all possible modules and |extensions come in. | | I want to keep the Library as little as possible. Download, compile and |install only those extensions you need. On that thread, we should strive for a balance. Short download times is nice, but we shouldn't go the way of Tcl where everything useful is a separately downloaded and installed extension. That limits the accessibility of the language. (Joe, I tried that new tool you gave me; it doesn't work. Oh, Bill you have to extensions A,B,C,D,E,F, and G. If you have root access, run this. Otherwise run this, put these files over here, munge this config file,a and set this env variable... [Bill to self: Nahh, it's not worth it. Next project].) Randall From tedken at manning.com Fri Apr 9 10:41:19 1999 From: tedken at manning.com (Ted Kennedy) Date: Fri, 09 Apr 1999 10:41:19 -0400 Subject: New book on Perl TK Message-ID: <370E118F.E387C3F8@manning.com> We are looking for a few qualified people to review and comment on the manuscript of a new book entitled, "Application Building with Perl TK". If interested, please send a brief description of your credentials to and I will send you more information. From tim_one at email.msn.com Sun Apr 11 18:04:25 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 11 Apr 1999 22:04:25 GMT Subject: bug or feature? traceback with python -x off by one line In-Reply-To: <3710DF00.DF5@creo.com> References: <3710DF00.DF5@creo.com> Message-ID: <001101be8467$43307660$2a9e2299@tim> [Dale Nagata] > I'm using Python 1.5.1 on Windows NT 4.0 Service Pack 3. This should work the same way everywhere, 1.5.2 included. > If I run a script the "normal" way, the exception > traceback prints the correct source file line numbers: > > E:\home\dale\test\>python testx.py > ... > File "E:\home\dale\test\testx.py", line 18, in ? > main() > ... > > However, if I run the exact same script with the Python -x > command line option to skip the first line of the script, the > reported line numbers are consistently off by one: > > E:\home\dale\test>python -x testx.py > ... > File "testx.py", line 17, in ? > try: > ... > > Is this the way it's *supposed* to work? Feeling a bit under-telepathic today, I can only confirm that the code is functioning as written . -x is implemented via advancing the input file stream beyond the first line (well ...) before the parser ever sees it. As far as the parser is concerned, the first line it sees is line number 1. > ... > Any ideas on the best way to resolve this? I agree it would be nice to change. In the meantime, I don't see a Python-only workaround. Under NT you don't *need* the -x trick, though (look for NT help on "assoc" and friends; provided you have the cmd.exe extensions enabled (the NT default), you can teach NT that .py files are to be run by Python, much as .bat files are to be run by the command-line interpreter; you cannot teach Win95 this, though). > How, from within a script, can I detect that the -x option is > in effect? Can't; the info is long gone. > Or do I have to go hack the interpreter source? Start with function Py_Main in Modules\main.c. If you get it to work, send a patch to Guido! I'd try replacing the "skipfirstline" fgets with a loop that does getc until it hits a newline or EOF, and if hits a newline pushes it back with ungetc. This is a local change to one block of code. Then the first line the parser sees will be "\n", which is harmless, but will advance the line counter. As is, the skipfirstline block advances the stream *beyond* the newline, and that's where you're getting in trouble; the current code is also flawed if the first line (including trailing newline) has more than 255 characters. aha!-12-more-than-a-power-of-3-ly y'rs - tim From tseaver at palladion.com Mon Apr 12 09:33:53 1999 From: tseaver at palladion.com (Tres Seaver) Date: Mon, 12 Apr 1999 08:33:53 -0500 Subject: WinZip vs 0-length files (was RE: trivial import question) References: <000401be7808$6105e3c0$549e2299@tim> <000201be8308$8b824520$ac9e2299@tim> Message-ID: <3711F641.AA796DA8@palladion.com> Tim Peters wrote: > > With tne candidate release of Python 1.5.2 just out, this is quite timely! > > At various times in March, at least Brad Clements, Lars Marius Garshol and > Tres Seaver spread the rumor that WinZip wouldn't extract 0-length files, > thus causing Python packages depending on an empty __init__.py to fail in > mysterious ways. > > I tried reproducing that but had no problems with the latest WinZip, so had > a good time insulting them all . > > But they were right! Steve Spicklemire provided the missing clue offline: > while WinZip does not have a problem with 0-length files in .zip archives, > it does indeed fail to extract them from .tgz archives. Heh, vindication! I hadn't reproduced the problem myself since Tim's chastisement (not the comfy chair!), and appreciate his graciousness in beating us to the counterpunch. -- ========================================================= Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From mwh21 at cam.ac.uk Wed Apr 14 11:45:09 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 14 Apr 1999 16:45:09 +0100 Subject: REPOST:pretty please - Help re libpython1.5.so References: <3714B9F9.30285D74@earth.ox.ac.uk> Message-ID: Nick Belshaw writes: > I'm gonna start taking this personally soon !!! 1) You've not been very specific wrt platform, hardware. 2) I was getting there! Give us 24 hours! > You bright guys out there..................................... > > If anyone can spare a second - > > Whilst trying to get Python plugins to work on Gnumeric-0.23 I bumped up > > against the need for libpython1.5.so.0.0.0 > > I have 'The Full Python' ( - thats the sequel to 'The Full Monty' !!! ) > > and can build xxxx.a no problem but what do I have to do to get xxxx.so > Can't seem to find anything specific on it in the docs or readme or > Setup and my knowledge is too superficial to allow me to be clever. Are you sure it's exactly libpython1.5.so.0.0.0 it's asking for? I've just compiled this bit of gnumeric (succesfully) and it's created libpython.la, which references libpython.so.0.0.0 and libpython.a, both of which are linked to libpython1.5.a. This is all on a redhat 5.2/i386 with slap bang up to date python and gnumeric from their respective CVS repositories. > Help anyone? I'd try updating your gnumeric, and if that fails, email me more details & what make says as it fails and I'll have a think. > cheers > Nick/Oxford Geochemistry Michael/"the other place" From bkc at murkworks.com Thu Apr 8 12:29:52 1999 From: bkc at murkworks.com (Brad Clements) Date: Thu, 8 Apr 1999 12:29:52 -0400 Subject: When will 1.5.2 final be released? Message-ID: <7eilic$r7f$1@news.clarkson.edu> I was porting 1.5.2b2 to NetWare, but have decided to wait for the final release. Any ideas when that will be available? Thanks.. From paul.moore at uk.origin-it.com Fri Apr 9 08:18:27 1999 From: paul.moore at uk.origin-it.com (Paul Moore) Date: Fri, 9 Apr 1999 14:18:27 +0200 Subject: add type predicates to types module? References: <14085.18842.492142.484721@bitdiddle.cnri.reston.va.us> <3705D878.4454DBEB@lemburg.com> Message-ID: On Sat, 3 Apr 1999 10:59:36 +0200, M.-A. Lemburg wrote: >Jeremy Hylton wrote: >> >> The folkloric "file-like object" type is a good example. When people >> say "file-like object" they mean an object that responds in a >> reasonable way to the particular subset of methods on a builtin file >> object that they are interested in. Er, doesn't this point out one of the inherent flaws with this scheme? You don't really want to know the type of the item, you want to be able to do certain things with it. So why not do try: whatever... except TypeError: whatever you do if you're given the wrong type In other words, try and trap exceptions rather than test beforehand. That tends to be how C++ "generic programming" works. Write templates using the operations you need - the templates won't compile when used with incorrect types. We're just replacing a compile time check with a runtime one, because Python uses dynamic typing in place of C++'s static model. Paul Moore. From johanw at easics.be Tue Apr 13 03:09:45 1999 From: johanw at easics.be (Johan Wouters) Date: Tue, 13 Apr 1999 09:09:45 +0200 Subject: Error loading 'binascii' References: <19990413032855.10759.qmail@nw179.netaddress.usa.net> Message-ID: <3712EDB9.E2240D74@easics.be> Seems to work here: > python Python 1.5.1 (#2, Apr 20 1998, 16:24:46) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import binascii >>> Kind regards, -- =================================================================== Johan Wouters === Easics === ASIC Designer === VHDL-based ASIC design services === Tel: +32-16-395 616 =================================== Fax: +32-16-395 619 Interleuvenlaan 86, B-3001 Leuven, BELGIUM mailto:johanw at easics.be http://www.easics.com From sdm7g at Virginia.EDU Fri Apr 23 14:26:41 1999 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 23 Apr 1999 14:26:41 -0400 (EDT) Subject: Python too slow for real world In-Reply-To: <3720A21B.9C62DDB9@icrf.icnet.uk> References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> Message-ID: On Fri, 23 Apr 1999, Arne Mueller wrote: > Hi All, > > thanks very much for all the suggestions how to speed up things and how > to THINK about programming in python. I got alot of inspiration from > your replys. However the problem of reading/writing larges files line by > line is the source of slowing down the whole process. > > def rw(input, output): > while 1: > line = input.readline() > if not line: break > output.write(line) > > f = open('very_large_file','r') > rw(f, stdout) > > The file I read in contains 2053927 lines and it takes 382 sec to > read/write it where perl does it in 15 sec. These simple read/write > functions use the functions from the C standard library, don't they? So, > readline/write don't seem to be implemented very efficently ... (?) > > I can't read in the whole file as a single block, it's too big, if > readline/write is slow the program will never get realy fast :-( > My guess would be that a difference this big is due to the file buffering mode. See 'open' in the library reference docs: | open (filename[, mode[, bufsize]]) [...] | ... The optional bufsize argument | specifies the file's desired buffer size: 0 means unbuffered, 1 means | line buffered, any other positive value means use a buffer of | (approximately) that size. A negative bufsize means to use the system | default, which is usually line buffered for for tty devices and fully | buffered for other files. If omitted, the system default is used.[2.10] Note that last sentence. If your really testing this by writing to the standard output, it may be using line buffered io. ( On a related note, I think it was AIX that had a horribly misfeatured /dev/null implementation that caused io tests dumped to /dev/null to be slower than if you used an actual device!) Adding the following wrapper function to your 'rw' function, you can test the effect of different buffer sizes or options. from time import clock def test1( filename, buf=None ): if buf == None: inp = open( filename, 'r' ) else: inp = open( filename, 'r', buf ) out = open( 'junk', 'w' ) c0 = clock() rw( inp, out ) c1 = clock() return c1 - c0 On the Mac, this makes about a *37 difference. ( I got tired of waiting for it to finish on 'big.file' , so I cut down the size. ) >>> iotest.makebigfile( 'not.so.big.file', 4001 ) >>> iotest.test1( 'not.so.big.file' ) 1.18333333333 >>> iotest.test1( 'not.so.big.file', buf=1 ) 1.88333333333 >>> iotest.test1( 'not.so.big.file', buf=0 ) 68.3833333333 I surely HOPE this is your problem! ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- Caldera Open Linux: "Powerful and easy to use!" -- Microsoft(*) (*) From gellyfish at gellyfish.com Fri Apr 30 04:54:32 1999 From: gellyfish at gellyfish.com (Jonathan Stowe) Date: 30 Apr 1999 09:54:32 +0100 Subject: Python and Perl References: Message-ID: <37296fc8@newsread3.dircon.co.uk> In comp.lang.perl.misc Ben Caradoc-Davies wrote: > [This is not intended to start another pointless language war. Well, at least > not between Perlers and Pythonistas. :-) ] > Then why did you cross-post it then ? *plonk* /J\ -- Jonathan Stowe From paul at prescod.net Mon Apr 26 18:09:09 1999 From: paul at prescod.net (Paul Prescod) Date: Mon, 26 Apr 1999 22:09:09 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <37215EFB.433AFCA6@prescod.net> <3724B2D6.B468687A@prescod.net> Message-ID: <3724E405.5E8ACFD6@prescod.net> Roy Smith wrote: > > Paul Prescod wrote: > > It is a performance issue if you don't know that regexps are supposed to > > be compiled. > > I hope this doesn't sound as bad as I fear it might, but part of being a > good programmer (or at least a good computer scientist) is to understand > performance issues like this. No doubt. But Python is not designed to be a programming language exclusively for good programmers or computer scientists. As I understand the design, it also caters to those that are new programmers and to those that don't want to worry about any more details than they absolutely have to. > If you > don't understand that factoring the expensive constant compilation process > out of a loop is important to make your program run fast, you aren't a > good programmer. No programming language can help that. That is absolutely not true. It is, however, a common myth. A programming language can have default behaviours that support beginning programmers. Python does that in most cases. In the last Perl/Python flame war someone used the analogy of clumsiness. Sure, a clumsy person could kill themself with a dull knife but that doesn't mean that a loaded gun and a dull knife are equally dangerous. I'm not promoting any particular language change here. I'm arguing against the throw-your-hands-in-the-air-and-expect-programmers-to-be-experts argument that is used to shout down any change that makes the language easier for non-experts. That's the design philosophy that gives rise to other languages that start with P: "You mean you aren't familiar with the string interpolation conventions of the C-shell and the input argument defaulting of Awk?" -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco Company spokeswoman Lana Simon stressed that Interactive Yoda is not a Furby. Well, not exactly. "This is an interactive toy that utilizes Furby technology," Simon said. "It will react to its surroundings and will talk." - http://www.wired.com/news/news/culture/story/19222.html From aahz at netcom.com Sat Apr 17 10:35:48 1999 From: aahz at netcom.com (Aahz Maruch) Date: Sat, 17 Apr 1999 14:35:48 GMT Subject: re.sub() loops References: Message-ID: In article , Andreas Jung wrote: > >I am trying to do some lame HTML processing with some >HTML. The following lines tries to remove some >unneccessary code from a HTML file. However python hangs >in this call: > >data = re.sub('','',data) Does the ...
contain *all* the strings "es", "da", "en", "fi", and "sv"? Or are the strings supposed to be "?es" and so on? In any event, with six ".*" patterns in there, you've got exponential processing time, even if it's not hanging. I think that if you want assistance in constructing the correct regex, you'll need to give us more info about the data and the goal you're trying to accomplish. You might find it productive to pick up a copy of the O'Reilly regex book -- I'd used regexes for years, but I didn't really learn them until I started using that book. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Sometimes, you're not just out of left field, you're coming in all the way from outer space. From dfan at harmonixmusic.com Fri Apr 23 13:16:14 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 23 Apr 1999 13:16:14 -0400 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> Message-ID: Arne Mueller writes: | I can't read in the whole file as a single block, it's too big, if | readline/write is slow the program will never get realy fast :-( You can use the 'sizehint' parameter to readlines() to get some of the efficiency of readlines() without reading in the whole file. The following code isn't optimized, but it shows the idea: class BufferedFileReader: def __init__ (self, file): self.file = file self.lines = [] self.numlines = 0 self.index = 0 def readline (self): if (self.index >= self.numlines): self.lines = self.file.readlines(65536) self.numlines = len(self.lines) self.index = 0 if (self.numlines == 0): return "" str = self.lines[self.index] self.index = self.index + 1 return str -- Dan Schmidt -> dfan at harmonixmusic.com, dfan at alum.mit.edu Honest Bob & the http://www2.thecia.net/users/dfan/ Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/ Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/ From guido at eric.cnri.reston.va.us Fri Apr 30 23:46:16 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 30 Apr 1999 23:46:16 -0400 Subject: Python documentation updated! References: <14122.3325.631762.383828@weyr.cnri.reston.va.us> Message-ID: <5liuada1vb.fsf@eric.cnri.reston.va.us> Congratulations with the release of the documentation, Fred! The new version really looks very slick. --Guido van Rossum (home page: http://www.python.org/~guido/) From kajiyama at grad.sccs.chukyo-u.ac.jp Thu Apr 29 17:40:56 1999 From: kajiyama at grad.sccs.chukyo-u.ac.jp (Tamito Kajiyama) Date: 29 Apr 1999 21:40:56 GMT Subject: Python implementation of tar In-Reply-To: frankmcgeough@my-dejanews.com's message of Sat, 24 Apr 1999 23:20:22 GMT References: <7ftjjl$tim$1@nnrp1.dejanews.com> Message-ID: frankmcgeough at my-dejanews.com writes: | | Does someone has a tar implementation written in Python? The attached is one that I wrote last year. It can extract files from archives, but cannot create an archive. Feel free to use, modify, and redistribute the module. Comments and improvement are appreciated. Regards, KAJIYAMA, Tamito ----------snip----------snip----------snip---------- #!/usr/bin/env python # # Tar.py - handles tape archive (tar) files # written by Tamito KAJIYAMA <18 November 1998> # import string BLOCKSIZE = 512 def trim_null(v): return v[:string.find(v, '\000')] def oct2int(v): return eval('0' + string.strip(v)) def int2int(v): return int(string.strip(v)) class SubfileHeader: def __init__(self, hblock, tar_name, base): self.tar_name = tar_name self.base = base self.name = trim_null(hblock[0:100]) self.mode = hblock[100:108-2] self.uid = oct2int(hblock[108:116-2]) self.gid = oct2int(hblock[116:124-2]) self.size = oct2int(hblock[124:136]) self.mtime = oct2int(hblock[136:148]) self.checksum = int2int(hblock[148:156-2]) self.linkflag = hblock[156] self.linkname = trim_null(hblock[157:256]) if self.size % BLOCKSIZE == 0: self.size_in_block = self.size / BLOCKSIZE else: self.size_in_block = self.size / BLOCKSIZE + 1 class Subfile: def __init__(self, header): self.base = header.base self.size = header.size self.file = open(header.tar_name, 'r') self.file.seek(header.base, 0) self.header = header def fileno(self): return self.file.fileno() def seek(self, offset, whence=0): if whence == 0: pass elif whence == 1: offset = self.tell() + offset elif whence == 2: offset = self.size - offset else: raise IOError, (22, 'Invalid argument') if offset < 0: offset = 0 elif offset > self.size: offset = self.size self.file.seek(self.base + offset, 0) def tell(self): return self.file.tell() - self.base def read(self, length=None): remain = self.size - self.tell() if remain <= 0: return '' elif length and length < remain: return self.file.read(length) else: return self.file.read(remain) def readline(self, length=None): remain = self.size - self.tell() if remain <= 0: return '' elif length and length < remain: return self.file.readline(length) else: return self.file.readline(remain) def readlines(self): lines = [] while 1: line = self.readline() if not line: break lines.append(line) return lines class Tar: def __init__(self, filename): file = open(filename, 'r') self.headers = [] while 1: # read subfile header hblock = file.read(BLOCKSIZE) if hblock[0] == '\000': break header = SubfileHeader(hblock, filename, file.tell()) self.headers.append(header) # skip subfile body file.read(BLOCKSIZE * header.size_in_block) file.close() def list(self): return self.headers def retrieve(self, name): for header in self.headers: if header.name == name: return Subfile(header) else: return None def test(): import os, sys, time if len(sys.argv) == 2: tar = Tar(sys.argv[1]) for header in tar.list(): print ' name:', header.name print ' size:', header.size, 'bytes' print 'mtime:', time.ctime(header.mtime) print elif len(sys.argv) > 2: tar = Tar(sys.argv[1]) for filename in sys.argv[2:]: file = tar.retrieve(filename) if file: outfile = open(file.header.name, 'w') outfile.write(file.read()) outfile.close() print 'wrote', file.header.name else: print filename, 'not found' else: print 'Usage: %s filename.tar [filename ...]' % \ os.path.basename(sys.argv[0]) if __name__ == '__main__': test() ----------snip----------snip----------snip---------- -- KAJIYAMA, Tamito From hyoon at bigfoot.com Tue Apr 13 18:22:29 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Tue, 13 Apr 1999 18:22:29 -0400 Subject: Event in COM Message-ID: <3713C3A5.59CB36E5@bigfoot.com> Hi, Can anyone show me some code or recommend me a book for this problem? I look through the newsgroup and tried to read the source, but I cannot figuire it out. (Thanks in Adv) I am trying to write an event handler for a ocx control that receives real time data. Obviously, I cannot retrieve anything without event handelers. after following: >> import win32com.client >> rR = win32com.client.Dispatch('RTLIST.RTList') ---- Obvious place for me to do this is at gen_py/xxxxxxx-0900000--33242432.py (something like it) by uncommenting those lines and writing it in, but I would like to write a class by inheriting it and overwriting it and keep these things general as possible. class _DRTListEvents: "Xyris RTList Control events" CLSID = pythoncom.MakeIID('{122B0CF2-C843-11CF-8925-00AA00575EBE}') _public_methods_ = [] # For COM Server support _dispid_to_func_ = { 3 : "OnChangeEx", 4 : "OnErrorEx", 1 : "OnSnapComplete", 2 : "OnChange", 5 : "OnChangeVnt", } def __init__(self, oobj = None): pass def _query_interface_(self, iid): import win32com.server.util if iid==self.CLSID: return win32com.server.util.wrap(self) # Handlers for the control # If you create handlers, they should have the following prototypes: # def OnChangeEx(self, ItemIndex=defaultNamedNotOptArg, ItemName=defaultNamedNotOptArg, ItemValue=defaultNamedNotOptArg, ItemStatus=defaultNamedNotOptArg, ChangeType=defaultNamedNotOptArg): # "Occurs whenever real-time update is made to an item in the list" # def OnErrorEx(self, ErrorCode=defaultNamedNotOptArg): # "Occurs when RTList experiences an error communicating with the real-time data source" Help! -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From pboddie at my-dejanews.com Mon Apr 19 11:13:01 1999 From: pboddie at my-dejanews.com (Paul Boddie) Date: Mon, 19 Apr 1999 15:13:01 GMT Subject: Problem with FNORB References: <19990419073413.22923.00002720@ng-fz1.aol.com> Message-ID: <7ffh5k$d7k$1@nnrp1.dejanews.com> In article <19990419073413.22923.00002720 at ng-fz1.aol.com>, alhopiteau at aol.com (Alhopiteau) wrote: > i have a problem with fnorb, running the example i get a error while the script > try to import the Fnorb.cdr module, this module is developped using C, how to > manage this? If you mean that when you try to execute a program which imports various Fnorb modules, you get errors complaining about the whereabouts of the cdr module, then you should ensure that your PYTHONPATH points to the directory where cdrmodule.so is located. So, if you have cdrmodule.so in /home/badger/Fnorb then you must make sure that /home/badger/Fnorb is in your PYTHONPATH. Note that in the Fnorb source, cdr is not used as if it belongs to the Fnorb package. (import cdr is used.) I believe that the instructions with Fnorb advise you to place the .so files (made in Fnorb/src) either somewhere in your existing PYTHONPATH, or in the Fnorb directory. If you choose the second of these two options then you must modify your PYTHONPATH accordingly. I was caught out by this, but the above solution worked for me. -- Paul Boddie Oslo, Norway -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From ddb at crystal.uwa.edu.au Wed Apr 28 21:57:23 1999 From: ddb at crystal.uwa.edu.au (Douglas du Boulay) Date: Thu, 29 Apr 1999 09:57:23 +0800 Subject: sharing variables in fortran References: <3725643A.734B9F06@crystal.uwa.edu.au> Message-ID: <3727BC83.831910A@crystal.uwa.edu.au> Travis Oliphant wrote: > > I am wondering if it is possible to coerce python to use > > memory addresses corresponding to a fortran common block (by way of a c > > extension) > > for storage of certain variables. > There is an exported function you can call from C called > PyArray_FromDimsAndData that creates a NumPy array from some dimension > information and a pointer to already allocated memory. There is some > improving documentation on the C-API to Numeric in the documentation > recently released for NumPy. See the scientific computing topic section > of www.python.org > > I'm not sure how to access a Fortran common block from C at the moment. > Thanks Travis, that at least gets me started If I can borrow from Greg Landrums reply: if testblock is my fortran common block, the equivalent in C is typedef struct { float var1; int var2; } common1; common1 testblock; /* a global block that exists for the entire period of module use */ so if I have a testmodule.c file with: typedef struct { PyObject_HEAD /* something is missing here */ } TestObject; What do I have to put in the TestObject struct to be able to read and write the var1 and var2 variables directly in a python script with something along the lines of self.testblock.var1=2.0 ? Thanks again. Doug From savageb at pacbell.net Mon Apr 5 02:37:20 1999 From: savageb at pacbell.net (savageb) Date: Sun, 04 Apr 1999 23:37:20 -0700 Subject: newbie questions (Python vs. Perl) References: <37082E26.A9445E43@earthlink.net> Message-ID: Phil Voris wrote: > > 1) I hear it's the best for learning OO. I have heard high praise of > Eifel as well, but information on it seems to be scarce at best. (I > have C and Perl experience) Will Python take me to the next level in > terms of understanding OO? > I think this is likely. If for no other reason than that it makes understanding easier to get to play with objects interactively (in the interpreter). Have fun. Bob From mal at lemburg.com Fri Apr 30 10:04:05 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 30 Apr 1999 16:04:05 +0200 Subject: mktime() like function to produce GMT? References: <00be01be9308$c649cf60$0301a8c0@cbd.net.au> Message-ID: <3729B855.3A7C6B5A@lemburg.com> Mark Nottingham wrote: > > I need a function to produce a Unix epoch time from a time tuple, a la > time.mktime(). Problem is, mktime() gives you the tuple in localtime, which > is dangerous if you're dealing with GMT times in the past (like in the > HTTP). > > Is there a function that will make a GMT epoch time straight from a time > tuple? On some platforms there is gmtime() which does exactly this. It's available through mxDateTime, BTW, which also offers a work-around solution for those platforms where it is not available. See the Python Pages below. -- Marc-Andre Lemburg Y2000: 245 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.python.net/~lemburg/ : --------------------------------------------------------- From jfarr at real.com Fri Apr 23 15:02:59 1999 From: jfarr at real.com (Jonothan Farr) Date: Fri, 23 Apr 1999 12:02:59 -0700 Subject: problem with windows sockets Message-ID: <3v3U2.5267$Bm3.336482@news20.ispnews.com> I'm rather stuck trying to solve a networking problem. I've implemented a TCP socket server derived from SocketServer.SocketServer and I want it to be able to restart itself. The problem I'm having is binding a socket to the same port twice. If I don't call setsockopt() with SO_REUSEADDR, then I get a winsock error 10048, defined in winsock.h as WSAEADDRINUSE (or 48, 'Address already in use' on Linux). It seems like setting SO_REUSEADDR should work, which it does on Linux but not on NT. Here's some example code to illustrate my point. --------------------- # Server: import socket port = 12000 queue = 5 print 'bind 1' s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('', port)) s.listen(queue) client, addr = s.accept() client.send('foo') s.close() print 'bind 2' s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) s.bind(('', port)) s.listen(queue) client, addr = s.accept() client.send('foo') s.close() --------------------- # Client: import socket host = 'localhost' port = 12000 bufsize = 1024 print 'connect 1' s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) print s.recv(bufsize) s.close() print 'connect 2' s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((host, port)) print s.recv(bufsize) s.close() --------------------- This works fine on Linux, but on NT I get a winsock error 10061 (defined as WSAECONNREFUSED) when I try to connect a client after binding the port a second time. Is this a problem with Winsock, a problem with Python, or a problem with my code? How can I work around this? Am I going about it in entirely the wrong way? Any help would be appreciated. Thanks, --jfarr From sportsnutz at email.msn.com Fri Apr 23 16:49:04 1999 From: sportsnutz at email.msn.com (sportsnutz) Date: Fri, 23 Apr 1999 16:49:04 -0400 Subject: I NEED MAJOR HELP Message-ID: Ive never programmed before and i need some tips on some command to work this thing From guido at eric.cnri.reston.va.us Fri Apr 23 09:45:47 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 23 Apr 1999 09:45:47 -0400 Subject: Running idle as a package References: <372050E3.9D05CE8F@easics.be> Message-ID: <5lr9pbsb5g.fsf@eric.cnri.reston.va.us> Jan Decaluwe writes: > I was trying to run idle as a package, so I turned the idle > directory into a python package. But then I got: > > Python 1.5.2 (#2, Apr 21 1999, 17:14:19) [GCC 2.8.1] on sunos5 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> from idle import idle > Failed to load extension 'SearchBinding' > Traceback (innermost last): > File "/usr/local/lib/python1.5/site-packages/idle/EditorWindow.py", line 470, in > load_standard_extensions > self.load_extension(name) > File "/usr/local/lib/python1.5/site-packages/idle/EditorWindow.py", line 481, in load_extension > mod = __import__(name) > ImportError: No module named SearchBinding > ... > > Apparently the problem is caused by the call to __import__, > that is not aware of the intra-package shortcut. Thanks. A better fix (that works whether or not idle is being used as a package) is to change the __import__ call as follows (line numbers may be off): *** EditorWindow.py 1999/04/20 15:45:28 1.18 --- EditorWindow.py 1999/04/23 13:42:38 *************** *** 484,490 **** return extend.standard def load_extension(self, name): ! mod = __import__(name) cls = getattr(mod, name) ins = cls(self) self.extensions[name] = ins --- 484,490 ---- return extend.standard def load_extension(self, name): ! mod = __import__(name, globals(), locals(), []) cls = getattr(mod, name) ins = cls(self) self.extensions[name] = ins --Guido van Rossum (home page: http://www.python.org/~guido/) From arcege at shore.net Thu Apr 8 14:24:37 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 08 Apr 1999 18:24:37 GMT Subject: DNS module ? References: Message-ID: Thomas Wouters wrote: : I'm looking for a DNS module. Actually, I'm looking for Anthony Baxters' DNS : module, from what I've read on dejanews :) However, the URL he gives in : the link in those posts, and all others I could find, point to a machine : that no longer exists (alumni.dgs.monash.edu.au) and I cannot find a similar : module anywhere else (except for the Demo DNS module, which, frankly, wont : do :) : Am I looking in the wrong places ? Mind you, I started looking into python : less than 24 hours ago, but I did check www.python.org, starship python, : dejanews and altavista (though the starship python searchengine was showing : a lack of voom when I tried it -- I think it was stunned) There is a dnslib module in the source distribution of Python 1.5.1 (and in Python 1.5.2bx), in the Demo/dns subdirectory. : I would be _very_ grateful for any pointers to the damned module, before I : write it myself, out of frustration, burning desire and the sublimal : messages... Must... ...write... ...Python... Quick, get this man some toast&spam&vikings&spam! -Arcege From aybtqtjw at somethingfunny.net Mon Apr 12 04:44:36 1999 From: aybtqtjw at somethingfunny.net (aybtqtjw at somethingfunny.net) Date: Mon, 12 Apr 1999 08:44:36 GMT Subject: A BUSINESS OPPORTUNITY Message-ID: An unregistered copy of Newsgroup AutoPoster 95 was used to post this article! --- Join Me For Free! Hi Friend, YOU PAY NOTHING TO ME UNTIL YOU ARE SATISFIED WITH THE INCOME AFTER THE FIRST MONTH AND WOULD LIKE TO CONTINUE WITH THE PROGRAM. This is your safeguard and allows you time to start building your new business before parting with any money! Project 21 is a step-by-step, monthly course of information on how to operate a successful internet business entirely from the comfort of your own PC at home. The first installment is a comprehensive, 50+ page manual which guides you into the lucrative world of home mail order. Each month you will receive a new installment which helps you progress in an easy to follow fashion. The monthly payment of $90 covers the cost of the manual installment and gives you full reproduction rights. Once you have your first customer the $90 per month is covered. After that every new customer is pure profit worth $1080 per year to you! I'm sure that you will have received hundreds of offers in your e-mailbox full of hype and promising you $1000s for doing next to nothing but all asking you to pay cash before disclosing what they are selling -- usually rubbish to be filed in the trash. Already since going on-line with Project 21 my income stream looks destined to multiply. Here are some genuine facts we would like to share with you: >One Client writes... I first ran a small test emailing on Monday evening and by Wednesday morning I'd had 9 inquiries and ONE Letter of Intent. Then I started posting in Newsgroups and sent out 2 bulk emails (of 500 and 750 addresses). By Sunday there had been over 60 inquiries and 5 Letters of Intent. Not having done much on-line promoting I was flabbergasted at the speed. By contrast, conventional mail would have taken 6-8 weeks to get the first 5 customers and just think of all the associated costs! >Another Client writes... When I first went on-line with this, I promoted directly to other entrepreneurs like myself. Within 5 days of promotion I had received 27 Letters of Intent!! I have taken part in other business ventures that promise riches such as network marketing and other programs, but not one has given me the independence this has! What sets Project 21 apart from the rest is that you can join me without paying a penny until you tried it for one month. You only need give me a LETTER OF INTENT valid for 30 days during which time you can promote the program until your first months information package has expired. At that time, if you wish to continue promoting, you would start paying me for each additional information package received after the first month. The LETTER OF INTENT is not binding after 30 days and you have my personal guarantee that, should you join, I will buy your business back from you at any time, no quibbles. By duplicating my 30 day offer and buy-back guarantee you too can be on your way to a six figure annual income and what's more IT COSTS NOTHING TO GET STARTED. Give it a try. Fill out the following LETTER OF INTENT. (Cut it and Paste it to a new email.) Then Email it to me. Let's get started!! With my best wishes for your financial future; _____________________________________________________ I hereby apply to join in Project 21. I understand that I may promote this program on-line via Email and Usenet postings and that full advice and assistance will be available to me. This LETTER OF INTENT is valid for a period of 30 days from the date Email transmission. During the 30 days I need make no payment for Project 21. If I am satisfied with Project 21 after the first month and wish to continue I will agree to pay $90 US for each additional information package received after the first month. NAME: ADDRESS: City: State: COUNTRY: POST/ZIPCODE: Phone: E-mail: Alt. E-mail: Birth Date: DATE TRANSMITTED: Steven balaw at sprint.ca From poinot at onera.fr Wed Apr 21 12:48:53 1999 From: poinot at onera.fr (Marc Poinot) Date: Wed, 21 Apr 1999 16:48:53 GMT Subject: [ANNOUNCE] Programme final JPF001 Message-ID: <371E0175.6F0AE680@onera.fr> Vous trouverez le programme final de la Journee Python France du 28 Mai 1999 a... http://www.onera.fr/congres/jpf001/index.html All European are welcomed at JPF001, please have a look at the final programme (URL above). Marcvs [alias Bien entendu, sont bienvenus les US citizens, and people coming from Africa, Asia, Australia (Hi Australian Pythoners!), Canada, India, ...] ----------------------------------------------------------------------- Marc POINOT Alias: marcvs Email: poinot at onera.fr ONERA -MFE/DSNA/ELSA Tel: 01.46.73.42.84 Info: elsa-info at onera.fr 29, Div. Leclerc Fax: 01.46.73.41.66 Site: 92322 Chatillon FRANCE Project: elsA Web: http://www.onera.fr ----------------------------------------------------------------------- From befletch at my-dejanews.com Wed Apr 21 20:39:48 1999 From: befletch at my-dejanews.com (befletch at my-dejanews.com) Date: Thu, 22 Apr 1999 00:39:48 GMT Subject: How do I use proxies with httplib? References: <7fl97e$lnc$1@nnrp1.dejanews.com> <099101be8c3f$cb6206e0$f29b12c2@pythonware.com> Message-ID: <7flr4l$6bc$1@nnrp1.dejanews.com> In article <099101be8c3f$cb6206e0$f29b12c2 at pythonware.com>, "Fredrik Lundh" wrote: > wrote: > > I want to use httplib through a proxy server and I can't seem to get > > it to work. [...] > you might be able to use urllib instead: [...] When I first looked at this I thought it wouldn't do the trick either, since I wanted to use the HTTP POST protocol. On further inspection I see that urllib has that covered. So I tried it out, only to run up against a problem that I want to blame on urllib; it claims to not recognize the http url type: Python 1.5.1 (#0, Nov 18 1998, 12:17:58) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import urllib >>> connection=urllib.urlopen('http://www.yahoo.com') Traceback (innermost last): File "", line 1, in ? File "C:\PROGRAM FILES\HOMERUN\lib\python1.5\urllib.py", line 59, in urlopen return _urlopener.open(url) File "C:\PROGRAM FILES\HOMERUN\lib\python1.5\urllib.py", line 155, in open return self.open_unknown(fullurl) File "C:\PROGRAM FILES\HOMERUN\lib\python1.5\urllib.py", line 169, in open_unk nown raise IOError, ('url error', 'unknown url type', type) IOError: ('url error', 'unknown url type', 'http') >>> As a test, I hacked urllib by forcing it to think all url's are http url's, like so: # name = 'open_' + type name = 'open_http' This gets past the url type only to fail on the urllib line: if not host: raise IOError, ('http error', 'no host given') Hacking in a host doesn't help much either. Is there something wrong with my proxy 'set' command? (This is under W95) SET http_proxy="100.287.14.130:80" Thanks again, - Bruce (emailed & posted) -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From ivanlan at callware.com Thu Apr 22 11:09:27 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 22 Apr 1999 15:09:27 GMT Subject: How many of us are there? References: <000301be8c67$08dd6600$959e2299@tim> Message-ID: <371F3BA7.7E53151C@callware.com> I should have known. Tim Peters wrote: > > [Ivan Van Laningham] > > Hello, Pythonistas-- > > Does anyone out there have some idea how many people subscribe to the > > mailing list, or read the newsgroup? > > Yes, I keep exact daily tallies of both, along with the precise number of > Python programmers broken down by industry, application, age, gender, > income, countries of origin and residence, employer and life goals. > > While I can't pass this information out for free, it's available for a > price. How do you think all those spammers got your email address ? > > python's-demographics-make-perl's-look-like-cobol's-ly y'rs - tim -ly y'rs, Ivan PS: Just define your currency. One or two jelly donuts?-) ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From movits at lockstar.com Fri Apr 9 13:43:50 1999 From: movits at lockstar.com (Mordy Ovits) Date: Fri, 9 Apr 1999 17:43:50 GMT Subject: OpenSSL/X.509 References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <3709C8BE.4257C9F1@lemburg.com> <14090.16807.950025.496495@bitdiddle.cnri.reston.va.us> <370A78B6.2C18D10F@lockstar.com> <370BE48E.2BA9750C@lemburg.com> Message-ID: <370E3C56.D035A3FB@lockstar.com> M.-A. Lemburg wrote: > > Mordy Ovits wrote: > > > > Jeremy Hylton wrote: > > > > > > >>>>> "MAL" == M -A Lemburg writes: > > > > [SNIP] > > > > > MAL> Note that I have a project running with the intention to wrap > > > MAL> OpenSSL in an OO manner called mxCrypto (see the link below). > > > > > > Looking forward to seeing it. When do you think you might have an > > > alpha release ready? > > > > > > Jeremy > > >>I have a fairly complete SWIGing of OpenSSL/SSleay working. I made it on >>company time, so I have to get company permission to release it. If there is >>real interest, I'll push for us to release it. It does all the X.509 stuff, is > > very OO, and builds on win32 and unices. > > Interested? > > Sure, but if your company is US based, then chances are high > you won't be able to share the code outside the US... that's > why I started mxCrypto, BTW.\ That's debatable. The SWIG bindings contain no crypto code in their own right. It is merely glue to crypto code. I wouldn't be able to release statically prebuilt libraries, but why would I want to anyway? Our lawyers keep waffling on this, which is why I haven't released it already. I'm really pleased with it, and would love give something back to the Python community. How long before we Americans are reduced to doing Crypto with a deck of cards? (See Bruce Schneier's Solitaire). Mordy -- o Mordy Ovits o Cryptographic Engineer o LockStar Inc. --------------------------------------------------------------------------- #!/usr/local/bin/python from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!= '-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce( lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1))) From nathan.froyd at rose-hulman.edu Sat Apr 24 23:48:49 1999 From: nathan.froyd at rose-hulman.edu (Nathan Froyd) Date: 24 Apr 1999 22:48:49 -0500 Subject: pickling and unpickling on the same file? Message-ID: Is there any way to implement the above beast? Something like: p = Pickler(file) u = Unpickler(file) file.seek(random_pos) x = u.load() z = [7, 8, 9] p.dump(z) would be perfect -- Nathan | nathan.froyd at rose-hulman.edu | http://www.rose-hulman.edu/~froydnj/ God went through hell so we don't have to. ICQ:18861764 | AOL:myrlyn007 Avoid the gates of hell. Use Linux. Python:"x='x=%s;x%%`x`';x%`x`" Evolution is a million line computer program falling into place by accident. From Jack.Jansen at oratrix.com Tue Apr 13 06:05:39 1999 From: Jack.Jansen at oratrix.com (Jack Jansen) Date: Tue, 13 Apr 1999 12:05:39 +0200 Subject: simple indexed file module? References: Message-ID: <371316F3.29E6DC89@oratrix.com> Joe Strout wrote: > > For a CGI script I'm working on, I need to keep a couple of indexed > files. These will contain variable-length data (descriptions), which > may be changed fairly frequently. So I imagine that in addition to the > data file, there will be an index file that keeps track of the position > and length of each record. New or expanded records will be stuffed in > wherever there is free space, or at the end if no sufficient free chunk > is available. anydbm is probably the simplest here. Works on the Mac too, where gdbm is available. -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen at oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From JamesL at Lugoj.Com Mon Apr 5 23:57:52 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 05 Apr 1999 20:57:52 -0700 Subject: SNMPy update References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> Message-ID: <37098640.6B0147DF@Lugoj.Com> Jeremy Hylton wrote: > > I'll second your sentiment! I did some work on an X.509 library > written entirely in Python. Like you friend's SNMP code, it will > probably never be released; I don't have time to finish it nor did I > expect that I'd want to release it given the export control hassles. > However, it seemed clear to me that an ASN.1 compiler could be written > to generate the encode/decode routines. If someone is interested in > that, I've got some design notes and rough code on how to do the > encode/decode and on how to build a backend for SNACC. (A free-ish > ASN.1 compiler; the only one?) > > Jeremy I had planned to write an SNMP MIB compiler in Python (actually also an ASN.1(88) and ASN.1(9?) compiler). Worked out how to do macros, but I just joined a startup, so I haven't found time to make any progress. The MIB compiler would have output Python modules. I have an outstanding contract to supply said compiler, but they haven't complained about it being delivered (of course, I only get paid for deliverables ). From ruebe at aachen.heimat.de Fri Apr 23 17:01:13 1999 From: ruebe at aachen.heimat.de (Christian Scholz) Date: Fri, 23 Apr 1999 21:01:13 +0000 Subject: Problem while Installing.. Message-ID: <3720DF98.8CEC8D8F@aachen.heimat.de> Hi everybody! I have a strange problem right now: 'import exceptions' failed; use -v for traceback Warning! Falling back to string-based exceptions Fatal Python error: Cannot create string-based exceptions IOT trap/Abort This I get when I try to install a new compiled Python 1.5.2 on my Linux Box. It was working before and did this after I told configure to use threads.. This message appears when the installation process wants to start compiling the modules (compileall.py). I tried importing it then by hand with my installed python which worked (The actual python interpreter is installed before the compile process, right?) and I then changed the Makefile to use the installed python which worked. But now when I want to use Python it says the same. Any idea what happens? I will now try to disable threads again and I will see if it works then again.. -- Christian From mlh at idt.ntnu.no Sun Apr 25 15:48:25 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 25 Apr 1999 21:48:25 +0200 Subject: learning python References: <7fqqtc$msf$1@nnrp1.dejanews.com> Message-ID: wwells5546 at my-dejanews.com writes: > Hi everybody, > > I know nothing about computer language. I guess I need to start with Python, > I've downloaded the progam and installed. I have the Python window and the > Ineractive window before me what do I do next????? > > Any help on tutorials for somebody who doesn't know anything would be helpful. Please check out my tutorial "Instant Hacking" which is meant for people in your situation. As my blurb says: "A quick introduction to programming in general, using Python for examples etc. Meant for people who haven't done any programming before, but have managed to get their hands on a Python interpreter." I guess that's you :) It's at http://www.idi.ntnu.no/~mlh/python/programming.html You might also want to look at http://www.idi.ntnu.no/~mlh/python/different.html when you gain a bit confidence -- it's a Python tutorial for newbies :) > > Regards > -- > Hi! I'm the signature virus 99! Magnus > Copy me into your signature and join the fun! Lie Hetland http://arcadia.laiv.org From amaranda at nospam.com Thu Apr 15 05:29:18 1999 From: amaranda at nospam.com (Alex Maranda) Date: Thu, 15 Apr 1999 10:29:18 +0100 Subject: threads References: <1288080841-20523503@hypernet.com> <1288067824-21306356@hypernet.com> Message-ID: <3715B16E.542B@nospam.com> Gordon McMillan wrote: > > Eric Lee Green writes: > > > Ah. Okay. So Python is doing user-land threads and not Posix > > (OS-level) threads? > > Nope. Those are OS threads. It's just that there's an interpreter > lock, which only gets released every N byte-code instructions. This is kind of misleading. Posix threads can be both user level or kernel level, depending on the contention scope passed to pthread_create() (PTHREAD_SCOPE_PROCESS/PTHREAD_SCOPE_SYSTEM). excerpt from Python-1.5.2/Python/thread_pthread.h: /* set default attribute object for different versions */ #if defined(PY_PTHREAD_D4) || defined(PY_PTHREAD_D7) # define pthread_attr_default pthread_attr_default # define pthread_mutexattr_default pthread_mutexattr_default # define pthread_condattr_default pthread_condattr_default #elif defined(PY_PTHREAD_STD) || defined(PY_PTHREAD_D6) # define pthread_attr_default ((pthread_attr_t *)NULL) # define pthread_mutexattr_default ((pthread_mutexattr_t *)NULL) # define pthread_condattr_default ((pthread_condattr_t *)NULL) #endif On my machine, Solaris2.5.1, I'm pretty sure it goes on #elif, so I get a null ptr (defaults to user level threads). It doesn't matter on SMP machines anyway because of the interpreter lock. BTW, any estimate (Guido?) on when will the interpreter be fully reentrant? (1.6? 2.0?) Cheers, -- Alex Maranda mailto: amaranda at spider dot com Spider Software Ltd. Tel: +44 (0)131 4757036 Edinburgh, UK http://members.xoom.com/Alex_Maranda STREAMS based communications protocols for embedded systems From miller at uinpluxa.npl.uiuc.edu Mon Apr 26 12:57:12 1999 From: miller at uinpluxa.npl.uiuc.edu (M.A.Miller) Date: 26 Apr 1999 11:57:12 -0500 Subject: examples of parsing html? Message-ID: <764sm3pbfb.fsf@zero.npl.uiuc.edu> Can anyone point me to examples of how to parse html files? I want to extract urls from an index so I can use those urls to get data files. Mike -- Michael A. Miller miller5 at uiuc.edu Department of Physics, University of Illinois, Urbana-Champaign From chadm at sgi.com Mon Apr 26 14:27:11 1999 From: chadm at sgi.com (Chad McDaniel) Date: 26 Apr 1999 11:27:11 -0700 Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: aahz at netcom.com (Aahz Maruch) writes: > In article <7fvagp$8lm$1 at nnrp1.dejanews.com>, > wrote: > > > >a) Perl's "defined". > > [perl] > > if (defined($x{$token}) > > > > [python] > > if (x.has_key(token) and x[token]!=None) : > > That looks correct. Thankfully Python does have short-circuit > evaluation. Note that if you normally expect x[token] to have a value, > you might restructure the code a bit to use try/except. > wouldn't x.get() work more elegantly: --- if (x.get(token)) : [do stuff] --- -- -chad From bhuzyk at kodak.com Wed Apr 14 09:45:34 1999 From: bhuzyk at kodak.com (Bruce Huzyk) Date: 14 Apr 1999 13:45:34 GMT Subject: Converting a string to a tuple References: <01be8530$65bb7120$52037e81@saints> <14098.28727.245158.616727@buffalo.fnal.gov> <00f501be857f$ff636f40$f29b12c2@pythonware.com> <01be85b5$f7197c90$52037e81@saints> <008f01be85b8$a5be9580$f29b12c2@pythonware.com> <040801be8646$823310d0$f29b12c2@pythonware.com> Message-ID: <01be8685$52f6c930$52037e81@saints> First let me thank everyone for their help. Let me take a step back and try to describe my problem with a little more detail with the disclaimer that I am a little new to Python (but not programming, BTW I couldn't find the PEWBIE module) and that I am more of a newsgroup reader then writer so please excuse the fact that this is my third post. I will list my solution and ask the question: Is this the way that you would implement this? Any side effects? E:\PYTHON>type c:\batch\script1.py import string fp = open("c:\\test.txt", "r") s = fp.readline() s = s[2:] a = {} a['1'] = eval(string.replace(s, '\\', '\\\\')) print type (a['1']) filename, offset = a['1'] print filename, offset fp.close E:\PYTHON>python c:\batch\script1.py c:\a\test.txt 1932 E:\PYTHON>type c:\test.txt :R("c:\a\test.txt",1932) E:\PYTHON> From tseaver at palladion.com Mon Apr 12 09:20:20 1999 From: tseaver at palladion.com (Tres Seaver) Date: Mon, 12 Apr 1999 08:20:20 -0500 Subject: OrderedDict.py References: Message-ID: <3711F314.FC15B844@palladion.com> evil Japh wrote: > > Is there a need for a module which allows for ordered processing of an > dictionary? > > I have one written, and it works fine I think. Basically, it allows for a > dictionary to be treated like a list, but have the data structure of > dictionary. Key-value pairs retain the order you entered them in. Unless > you specifically change them. I'm currently working on more methods, to > allow it to be sliced like an array. Your approach sounds like a sequence of (key, value) tuples. It can't really be used as a general-purpose dictionary, because searching for an arbitrary element using the key is going to be linear in the number of elements, whereas the native Python dictionary is (normal-case) constant-time for the same lookup. Perhaps you are maintaining the ordered keys in a separate sequence on the side? This construct is more useful, but again has scalability problems: removing items from the list is harder, and more expensive, and you store the keys twice (if keys are objects, this is only storing refernces twice). -- ========================================================= Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From paul at prescod.net Sat Apr 24 02:04:43 1999 From: paul at prescod.net (Paul Prescod) Date: Sat, 24 Apr 1999 06:04:43 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> Message-ID: <37215EFB.433AFCA6@prescod.net> Justin Sheehy wrote: > > > (And... How about builtin regexes in P2?) > > In all seriousness, what reason do you have for making that > suggestion? I am willing to believe that there might be a good reason > to do so, but it certainly isn't immediately obvious. One benefit would be that the compiler could compile regexps at the same time everything else is being compiled. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco Company spokeswoman Lana Simon stressed that Interactive Yoda is not a Furby. Well, not exactly. "This is an interactive toy that utilizes Furby technology," Simon said. "It will react to its surroundings and will talk." - http://www.wired.com/news/news/culture/story/19222.html From hyoon at bigfoot.com Wed Apr 14 11:58:50 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Wed, 14 Apr 1999 11:58:50 -0400 Subject: TCL_LIBRARARY and making it work References: <3714B880.22F87048@bigfoot.com> Message-ID: <3714BB3A.54BF2531@bigfoot.com> Hi, I think I found the problem by setting TKPATH, but now I got a different prob. All this used to work fine prior to install. I don't know what's going on. Traceback (innermost last): File "", line 1, in ? File "c:\TEMP\python-BEAf6p", line 2, in ? Tkinter._test() File "C:\Python\Lib\lib-tk\Tkinter.py", line 1947, in _test root = Tk() File "C:\Python\Lib\lib-tk\Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable tk.tcl in the following directories: {C:\Python\TCL\lib\tk8.0} . C:/Python/TCL/lib/tk8.0 ./tk8.0 ./lib/tk8.0 ./library ./tk8.0/library ./library C:/Python/TCL/tk8.0/library C:/Python/TCL/lib/tk8.0/tk.tcl: bad event type or keysym "MouseWheel" bad event type or keysym "MouseWheel" while executing "bind Listbox { %W yview scroll [expr - (%D / 120) * 4] units }" (file "C:/Python/TCL/lib/tk8.0/listbox.tcl" line 179) invoked from within "source [file join $tk_library listbox.tcl]" (file "C:/Python/TCL/lib/tk8.0/tk.tcl" line 151) invoked from within "source C:/Python/TCL/lib/tk8.0/tk.tcl" ("uplevel" body line 1) invoked from within "uplevel #0 [list source $tkfile]" C:/Python/TCL/lib/tk8.0/tk.tcl: bad event type or keysym "MouseWheel" bad event type or keysym "MouseWheel" while executing "bind Listbox { %W yview scroll [expr - (%D / 120) * 4] units }" (file "C:/Python/TCL/lib/tk8.0/listbox.tcl" line 179) invoked from within "source [file join $tk_library listbox.tcl]" (file "C:/Python/TCL/lib/tk8.0/tk.tcl" line 151) invoked from within "source C:/Python/TCL/lib/tk8.0/tk.tcl" ("uplevel" body line 1) invoked from within "uplevel #0 [list source $tkfile]" This probably means that Tk wasn't installed properly. > -- > ***************************************************************************** > S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, > yelled at yahoo.com hoon at bigfoot.com(w) > "Miracle is always only few standard deviations away, but so is > catastrophe." > * Expressed opinions are often my own, but NOT my employer's. > "I feel like a fugitive from the law of averages." Mauldin > ***************************************************************************** > > ------------------------------------------------------------------------ > > Hoon Yoon > > Hoon Yoon > > Netscape Conference Address > Netscape Conference DLS Server > Additional Information: > Last Name > First Name Hoon Yoon > Version 2.1 -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From aa8vb at vislab.epa.gov Wed Apr 14 08:30:18 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Wed, 14 Apr 1999 12:30:18 GMT Subject: IDLE with Tk app Message-ID: <19990414083018.A1361046@vislab.epa.gov> 1) A first test >>> from Tkinter import * >>> button = Button( None, text="Testing" ) >>> button.pack() >>> button.mainloop() Works fine, so I close the button's window (click X - WM_DELETE event), but IDLE is still stuck in button.mainloop(). The same test in the raw python interpreter causes it to return to the prompt. 2) I try to exit (File->Exit) "The program is still running; do you want to kill it?" I click OK. (and we're still in the interpreter with the program running.) Try again, same result. So I kill the IDLE window. Anything I'm doing wrong here? I'd guess this is related to IDLE also being a Tk app. Is there a work-around so Tk apps can be run as-is in IDLE? Randall From brunomadv at ciudad.com.ar Wed Apr 21 10:29:07 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Wed, 21 Apr 1999 14:29:07 GMT Subject: Kosovo database; Python speed In-Reply-To: <371DAAC2.D9046550@cs.utwente.nl> References: <371DAAC2.D9046550@cs.utwente.nl> Message-ID: <002501be8c03$5085f760$6eba0ac8@kuarajy.infosys.com.ar> I presume that a SQL engine would be the fastest solution and all the programming, in my opinion, should be done in Python using a database connector. It depends on the uses you will give to this DB, but MySQL should be the better choice. If you need data consistency (via FK) and a transactional database, you should be looking perhaps to a commercial SQL engine like Oracle or MS-SQL ... But if it's for querys mainly, MySQL if damn fast ... :-) Hope this helps... and specially I hope this helps a little bit for the people of Kosovo... /B Bruno Mattarollo ... proud to be a PSA member > -----Original Message----- > From: python-list-request at cwi.nl [mailto:python-list-request at cwi.nl]On > Behalf Of Richard van de Stadt > Sent: Wednesday, April 21, 1999 7:39 AM > To: python-list at cwi.nl > Subject: Kosovo database; Python speed > > > Suppose we were going to make a database to help Kosovars locate > their family members. This would probably result in hundreds of > thousands of records (say 1 record (file) per person). > > Would Python be fast enough to manage this data, make queries on > the data, or should compiled programs be used? > > Richard. > From tratt at dcs.kcl.ac.uk Tue Apr 20 04:54:49 1999 From: tratt at dcs.kcl.ac.uk (Laurence Tratt) Date: Tue, 20 Apr 1999 09:54:49 +0100 Subject: bzip2 module for Python Message-ID: In message <87zp43gaac.fsf at illusion.tui-net> Paul Kunysch wrote: [me 'announcing' pyBZlib] >> As I said, I am interested to know if there is a demand for this, so >> comments are appreciated. > IMHO it would be nice to have a module like the current "gzip", which > handles .bz2 .gz .Z and uncompressed files transparently. pyBZlib handles .bz2 files 'transparently' as such, in that the inputs and outputs to the bzip2 library are simply standard .bz2 files. The two simple test files included with pyBZlib demonstrate this by slurping .bz2 files straight into the libraries methods :) Do you mean you would like to see a module where you give it a file (which could be .bz2, .gz, .zip etc), and then get an uncompressed version back without worrying what compression type was used? Would you also want it to automatically untar files? Laurie From garys at magna.com.au Mon Apr 5 23:06:35 1999 From: garys at magna.com.au (Gary Stephenson) Date: Tue, 06 Apr 1999 13:06:35 +1000 Subject: Xbase++ preprocessor implementation in Python Message-ID: <37097A3A.F772205@magna.com.au> Attached please find a Python implementation of the Xbase++ preprocessor. It is not yet a totally perfect rendition, but it is pretty close. By implication, it should also be a reasonable rendition of the Clipper preprocessor (though I have not yet tested this). Oh, and it is *dead slow*! - hundreds of times slower I think! This is undoubtedly partly due to me being a Python newbie, and I would greatly appreciate any tips on how I might speed it up a bit. Any tips on how the code could be improved would be equally welcome, particularly any Python idioms that I have obviously not yet groked. (Error handling for example!!) I could not figure out how to make either KJparsing or TRAP do what I wanted, and I haven't yet looked at John Aylcock's stuff (but I intend to!), so the code is built from scratch around the re module. Any comments as to the relative (de)merits of this approach are welcomed. I would like eventually to make this available to the Clipper/Xbase++ community. But I want to present Python in the best possible light - so I thought it best to first release it here in the hope that it might be further refined first. "Why write such a program?" I hear you ask! Several reasons : - I needed a concrete project to help me get up to speed with Python. - I want to translate some or all of my Clipper/Xbase++ source to Python, and I'm hoping this will help (but I'm not quite sure how!). - the Clipper/Xbase++ preprocessor had always been a bit of a mystery to me, so I thought this might deepen my understanding of it a bit (it has!). - Ditto for regular expressions! - I have taken the opportunity to make some "improvements". Some patterns that do not successfully translate under Xbase++, but IMHO should, do under PRGPP. - There are some concerns in the Xbase++ community as to incompatibilities between the Clipper and Xbase++ preprocessors. Hopefully, this tool might serve to clarify and/or resolve such issues. - Clipper and Xbase++ are only available on Window$ :-( - I love programming, the open-source idea, Python and the Clipper/Xbase++/VO languages. I would like eventually to see an open-source implementation of a such a language. Nuff said. many tias, gary -------------- next part -------------- """ PRGPP.py - a Python re-implementation of the Xbase++ (Clipper) preprocessor Released to the public domain 2-Apr-1999, Provided as-is; use at your own risk; no warranty; no promises; enjoy! by Gary Stephenson (garys at magna.com.au) (who is currently underemployed ) """ import re import sys import glob import string Identifier = re.compile(r"\s*([A-Za-z_]+[A-Za-z0-9_]*)") NumLiteral = re.compile(r"\s*([0-9]+(\.[0-9]+)?)") StringLiteral = re.compile(r"\s*('.*?'|\".*?\")") LogLiteral = re.compile(r"\s*(\.f\.|\.t\.)",re.I ) Operator = re.compile(r"\s*(\+\+|\+=|\+|--|-=|->|-|\*\*|\*=|\*|/=|/|,|!|\||%|\.not\.|\.or\.|\.and\.|@|:=|:|==|=|>=|>|<=|<)",re.IGNORECASE) BlockHeader = re.compile(r"\s*\{\s*\|.*\|" ) OpenBrackets = re.compile(r"\s*(\[|\(|{)") CloseBrackets = re.compile(r"\s*(\]|\)|})") eol = re.compile(r"\s*$") comma = re.compile(r"\s*,") defStmt = re.compile( r"#\s*define\s+(?P\w+)(?P.*)?", re.IGNORECASE ) ifdef = re.compile( r"#\s*ifdef\s+(?P\w+)", re.IGNORECASE ) ifndef = re.compile( r"#\s*ifndef\s+(?P\w+)", re.IGNORECASE ) elsedef = re.compile( r"#\s*else\s*", re.IGNORECASE ) endif = re.compile( r"#\s*endif\s*", re.IGNORECASE ) include = re.compile( r"#\s*include\s+(?P.+)",re.IGNORECASE ) undef = re.compile( r"#\s*undef\s+(?P\w+)", re.IGNORECASE ) cmd = re.compile( r"#\s*command\s*(?P.+)=>(?P.*)", re.IGNORECASE ) xcmd = re.compile( r"#\s*xcommand\s+(?P.+)=>(?P.*)", re.IGNORECASE ) trans = re.compile( r"#\s*trans(late)?\s+(?P.+)=>(?P.*)", re.IGNORECASE ) xtrans = re.compile( r"#\s*xtrans(late)?\s+(?P.+)=>(?P.*)", re.IGNORECASE ) pragma = re.compile( r"#\s*pragma\s*.+", re.IGNORECASE ) matchLit = re.compile( r"\s*([^\s^\[^\]^<]+)" ) matchGrp = re.compile( r"\s*\[" ) endGrp = re.compile( r"\s*\]" ) matchMrk = re.compile( r"\s*<(.+?)>" ) DumbMrk = re.compile( r"\s*#<(.+)>" ) firstNonWhite = re.compile( r"(\s*)\S" ) defs = { "__XPP__":None } lineno = 0 curfile = "" curIndent = "" def StripComment( ln="" ) : global curIndent n = string.find( ln, '//' ) if n <> -1 : ln = ln[:n] m = firstNonWhite.match(ln) if m : curIndent = m.group(1) return string.strip( ln ) def splitMatch( str, lft, rght ) : "Parses the string on balancing delimiters" j = string.find( str, lft ) if j == -1 : return ( str,"","" ) bef = str[:j] i = j + 1 l = len( str ) n = 0 while i < l : if str[i] == rght : if n == 0 : return ( bef, str[j+1:i], str[i+1:] ) n = n - 1 elif str[i] == lft : n = n + 1 i = i + 1 assert 0, "Unbalanced delimiters detected" def pseudofunc( key, str, line ) : i = string.find( str, ")" ) srch = string.split( str[1:i], "," ) str = str[i+1:] i = string.find( line, key ) bef = line[:i] line = line[i+2:] l = len( line ) n = 0 i = 0 while n < l : c = line[n] if c == "(" : i = i + 1 elif c == ")" : if i == 0 : break i = i - 1 n = n + 1 aft = line[n+1:] subs = string.split( line[:n],"," ) l = len( subs ) assert l==len(srch), "Length mismatch" for i in xrange( 0,l ) : str = replace( str, string.strip( string.rstrip( srch[i] ) ) , string.strip( string.rstrip( subs[i] ) ) ) return bef + str + aft def writeln( hFile ) : hFile.write( curIndent+tline+"\n" ) def writeBlank() : if rootfile == curfile : hOut.write( "\n" ) def readln( hFile ) : global lineno while 1 : s = hFile.readline() lineno = lineno+1 if not s : hFile.close() break s = StripComment( s ) if not s : writeBlank() continue if s[0] == "*" : writeBlank() continue if s[:2] != "/*" : break writeBlank() while string.rstrip(s)[-2:] != "*/" : writeBlank() s = hFile.readline() lineno = lineno+1 if not s : hFile.close() print "Error : Unclosed Multiline Comments" sys.exit(1) return s def readNextLine( hFile ) : s = readln( hFile ) while s[-1:] == ";" : s = s[:-1] + " " + readln( hFile ) writeBlank() return s def defOmit( hFile ) : while 1 : line = readNextLine( hFile ) m = endif.match( line ) if m : return m = elsedef.match( line ) if m : return m = ifdef.match( line ) if m and not defs.has_key( m.group("name") ) : defOmit( hFile ) m = ifndef.match( line ) if m and defs.has_key( m.group("name") ) : defOmit( hFile ) class MatchGroup: """ see docstring for MatchTree""" def __init__( self ) : global curpos self.trees = [] while 1: self.trees.append( MatchTree() ) m = matchGrp.match( tline, curpos ) if not m : break curpos = m.end() def __repr__( self ) : return self.pprint( 0 ) def pprint( self, ind ) : s = "" for t in self.trees : s = s + t.pprint( ind+1 ) return s def match( self ) : while 1 : mtch = 0 for t in self.trees : if t.match() : mtch = 1 break if not mtch : break return 1 class MatchTree: """ MatchTree -> ( Literal | Marker | MatchGroup )+ MatchGroup -> ( MatchTree )+ MatchTree stores the "syntax tree" for each clause MatchGroup is a grouping of clauses at the same "level" (i.e. contiguous in the declaration) tline is the (global) string we are matching to curpos is the (global) current index into tline, which the match methods increment on success! """ def __init__( self ) : self.tokens = [] self.parse() def __repr__( self ) : return self.pprint() def pprint( self, ind=0 ) : s = "" for t in self.tokens : s = s + t.pprint( ind ) s = s + (" "*ind)+"--------------\n" return s def match( self ) : global curpos i = curpos for m in self.tokens : if not m.match() : curpos = i return 0 return 1 def search( self ) : global curpos i = curpos strt = self.tokens[0].search() if strt != -1 : for t in self.tokens[1:] : if not t.match() : curpos = i return -1 return strt def parse( self ) : global curpos l = len( tline ) while curpos < l : m = matchGrp.match( tline, curpos ) if m : curpos = m.end() self.tokens.append( MatchGroup() ) state = "G" continue m = endGrp.match( tline, curpos ) if m : curpos = m.end() return m = matchMrk.match( tline,curpos ) if m: body = m.group( 1 ) curpos = m.end() c = body[0] if c == "(" : self.tokens.append( ExtendedMarker( body[1:-1] ) ) elif c == "#" : # single self.tokens.append( SingleMarker( body[1:] ) ) elif c == "*" : # wild self.tokens.append( WildMarker( body[1:-1] ) ) elif string.strip( body )[-3:] == "..." : # list n = string.find( body, "," ) self.tokens.append( ListMarker( string.strip( body[:n] ) ) ) elif string.find( body, ":" ) > 0 : # restricted self.tokens.append( RestrictedMarker( body ) ) else : # regular self.tokens.append( RegularMarker( body ) ) state = "M" continue m = Identifier.match( tline,curpos ) if m : self.tokens.append( KeyWord( m.group(1) ) ) curpos = m.end() continue m = matchLit.match( tline,curpos ) if m : self.tokens.append( Literal( m.group(1) ) ) curpos = m.end() continue assert 0, "Error - Unable to parse : "+tline[curpos:] def readExpression( xpos=0, expect="",commaOK = 0 ) : prevTok = "O" while xpos < len( tline ) : m = BlockHeader.match( tline,xpos ) if m : xpos = readExpression( m.end(), "}" ) prevTok = "B" continue m = OpenBrackets.match( tline, xpos ) if m : c = m.group(1) if( prevTok != "O" and prevTok != "I" ) : return xpos if c == "[" : bal = "]" elif c == "{" : bal = "}" else : # c == "(" bal = ")" xpos = readExpression( m.end(), bal, 1 ) prevTok = "X" continue m = CloseBrackets.match( tline, xpos ) if m : if expect : if m.group(1) != expect : assert 0, "Unbalanced delimiters" return m.end() return xpos if not commaOK : m = comma.match( tline,xpos ) if m : return xpos m = Operator.match(tline, xpos) if m : prevTok = "O" xpos = m.end() continue m = NumLiteral.match(tline, xpos) if not m : m = StringLiteral.match(tline, xpos) if not m : m = LogLiteral.match(tline, xpos) if m : if prevTok != "O" : return xpos prevTok = "L" xpos = m.end() continue m = Identifier.match(tline, xpos) if m : if prevTok != "O" : return xpos prevTok = "I" xpos = m.end() continue print "Error : Unable to parse string : "+tline[xpos:] sys.exit(1) return xpos def ParseExpression() : global curpos i = curpos curpos = readExpression( i ) return tline[i:curpos] class Literal : def __init__( self, s ) : #self.re = re.compile( r"\s*"+re.escape( s )+r"(\b|$)", re.I ) self.re = re.compile( r"\s*"+re.escape( s ), re.I ) assert s def __repr__( self ) : return self.pprint() def pprint( self, ind=0 ) : return (" ")*ind + "Literal : "+self.re.pattern+"\n" def match( self ) : global curpos m = self.re.match( tline, curpos ) if m : curpos = m.end() return 1 return 0 def search( self ) : global curpos m = self.re.search( tline, curpos ) if m : curpos = m.end() return m.start() return -1 class KeyWord : def __init__( self, s ) : self.re = re.compile( r"\s*\b"+ s +r"(\b|$)", re.I ) assert s def __repr__( self ) : return self.pprint() def pprint( self, ind=0 ) : return (" ")*ind + "Keyword : "+self.re.pattern+"\n" def match( self ) : global curpos m = self.re.match( tline, curpos ) if m : curpos = m.end() return 1 return 0 def search( self ) : global curpos m = self.re.search( tline, curpos ) if m : curpos = m.end() return m.start() return -1 class MatchMarker : def __init__( self, name ) : self.name = name self.vals = [] if currentCmd.markers.has_key( name ) : print "Error - marker name already present : "+name sys.exit(1) currentCmd.markers[name] = self def __repr__( self ) : return self.pprint() def pprint( self,ind=0 ) : assert 0, "Abstract method called" return "" def match( self ) : assert 0, "Abstract method called" return 0 def getVal( self, i=0, f=None ) : l = len( self.vals ) if i >= l : if l : val = self.vals[l-1] else : val ="" else : val = self.vals[i] if f : return apply( f, (val,) ) return val class RegularMarker( MatchMarker ) : def __init__( self, name ) : MatchMarker.__init__( self,name ) def pprint( self, ind=0 ) : return (" ")*ind + "Regular : "+self.name+"\n" def match( self ) : self.vals.append( ParseExpression() ) return 1 class RestrictedMarker( MatchMarker ) : def __init__( self, body ) : n = string.find( body, ":" ) name = string.strip( body[:n] ) MatchMarker.__init__( self, name ) self.vals = [] mstr = string.replace( body[n+1:],",","|" ) self.re = re.compile( "\s*("+string.replace( mstr, " ", "" )+")", re.I ) def pprint( self, ind=0 ) : return (" ")*ind + "Regular : "+self.name+", "+self.re.pattern+"\n" def match( self ) : global curpos m = self.re.match( tline, curpos ) if m : self.vals.append( m.group( 1 ) ) curpos = m.end() return 1 return 0 def search( self ) : global curpos m = self.re.search( tline, curpos ) if m : self.vals.append( m.group( 1 ) ) curpos = m.end() return m.start() return -1 class WildMarker( MatchMarker ) : def __init__( self, name ) : MatchMarker.__init__( self,name ) def pprint( self, ind=0 ) : return (" ")*ind + "Wild : "+self.name+"\n" def match( self ) : global curpos self.vals.append( tline[curpos:] ) curpos = len( tline ) return 1 class SingleMarker( MatchMarker ) : def __init__( self, name ) : MatchMarker.__init__( self,name ) self.re = re.compile( r"\s*([^\s]*)" ) def pprint( self, ind=0 ) : return (" ")*ind + "Single : "+self.name+"\n" def match( self ) : global curpos m = self.re.match( tline, curpos ) if m : self.vals.append( m.group(1) ) curpos = m.end() return 1 return 0 class ExtendedMarker( MatchMarker ) : def __init__( self, name ) : MatchMarker.__init__( self,name ) self.reXpr = re.compile("\s*\(") def pprint( self, ind=0 ) : return (" ")*ind + "Extended : "+self.name+"\n" def match( self ) : global curpos m = self.reXpr.match( tline, curpos ) if m : self.vals.append( ParseExpression() ) return 1 m = StringLiteral.match( tline, curpos ) if not m : m = Identifier.match( tline, curpos ) if m : self.vals.append( m.group(1) ) curpos = m.end() return 1 return 0 class ListMarker( MatchMarker ) : def __init__( self, name ) : MatchMarker.__init__( self,name ) def pprint( self, ind=0 ) : return (" ")*ind + "List : "+self.name+"\n" def match( self ) : global curpos val = [] self.vals.append( val ) while 1: xpos = curpos curpos = readExpression(curpos) val.append( tline[xpos:curpos] ) m = comma.match( tline,curpos ) if not m: break curpos = m.end() return 1 def getVal( self, i=0, f=None ) : l = len( self.vals ) if i >= l : if l : val = self.vals[l-1] else : val = [""] else : val = self.vals[i] if not val : val.append("") if f : val = map( f, val ) return reduce( lambda x,y : x+","+y, val ) class ResultGroup : def __init__( self ) : global curpos self.markers = [] self.prs = "" l = len( tline ) while curpos < l : m = matchGrp.match( tline,curpos ) if m : self.prs = self.prs + tline[m.start():m.end()-1] + "%s" curpos = m.end() self.markers.append( (ResultGroup(),) ) continue if endGrp.match( tline,curpos ) : return Dumb = 0 m = matchMrk.match( tline,curpos ) if not m : Dumb = 1 m = DumbMrk.match( tline,curpos ) if m : self.prs = self.prs + tline[curpos:m.start()] body = m.group(1) curpos = m.end() c = body[0] if Dumb : mname = body func = stringify elif c == '"' : assert body[-1] == '"', "Invalid match marker : "+body mname = body[1:-1] func = normstringify elif c == "(" : assert body[-1] == ')', "Invalid match marker : "+body mname = body[1:-1] func = smartstringify elif c == "{" : assert body[-1] == '}', "Invalid match marker : "+body mname = body[1:-1] func = blockify elif c == "." : assert body[-1] == '.', "Invalid match marker : "+body mname = body[1:-1] func = logify else : # regular mname = body func = lambda s : s if not currentCmd.markers.has_key( mname ) : print "Error : match marker not found for "+mname+" at line :",lineno print tline print currentCmd.mtree sys.exit(1) self.markers.append( (currentCmd.markers[mname],func) ) self.prs = self.prs + "%s" continue m = matchLit.match( tline, curpos ) if m : self.prs = self.prs + tline[m.start():m.end()] curpos = m.end() def expand( self, i = 0 ) : l = [] for m in self.markers : if len(m) == 2 : l.append( m[0].getVal( i, m[1] ) ) else : l.append( m[0].repexpand() ) return self.prs % tuple( l ) def repexpand( self ) : # Note : this should not have any repeating group markers! maxlen = 0 Result = "" for m in self.markers : if len( m[0].vals ) > maxlen : maxlen = len( m[0].vals ) for i in range( 0, maxlen ) : Result = Result + self.expand( i ) return Result class Command : cmds = [] def __init__( self, srch, repl ) : global currentCmd,tline,curpos self.markers = {} currentCmd = self curpos = 0 tline = string.strip( srch ) self.mtree = MatchTree() tline = string.strip( repl ) curpos = 0 self.repl = ResultGroup() Command.cmds.insert(0,self) def transform( self ) : global tline if self.mtree.match() : tline = self.repl.expand() t = self.markers.items() for (n,m) in t : m.vals = [] return 1 return 0 class Translate( Command ) : trns = [] def __init__( self, srch, repl ) : global currentCmd,tline,curpos self.markers = {} currentCmd = self tline = string.strip( srch ) curpos = 0 self.mtree = MatchTree() tline = repl curpos = 0 self.repl = ResultGroup() Translate.trns.insert(0,self) def transform( self ) : global tline i = self.mtree.search() if i != -1 : tline = tline[:i]+ self.repl.expand()+ tline[curpos:] t = self.markers.items() for (n,m) in t : m.vals = [] return 1 return 1 return 0 def stringify( s ) : if string.lstrip( s )[0] == '"' : return "'"+s+"'" return '"'+s+'"' def normstringify( s ) : if s : return '"'+s+'"' return s def smartstringify( s ) : if not s : return "" s = string.strip( s ) if s[0] == "(" and s[-1:] == ")" : return s return '"'+s+'"' def blockify( s ) : if s : return "{|| "+s+" }" return "" def logify( s ) : if s : return ".T." return ".F." def applydefs() : global defs,tline for (frm,to) in defs.items() : i = string.find( tline, frm ) if i <> -1 : tline = string.replace( tline, frm, to ) return 1 return 0 def applytrans() : for c in Translate.trns : if c.transform() : return 1 return 0 def applycmds() : for c in Command.cmds : if c.transform() : return 1 return 0 def transform( line ) : global tline,curpos tline = line assert tline, "Empty string before transform" curpos = 0 while 1 : if applydefs() : continue if applytrans() : continue if applycmds() : continue break assert tline, "Empty string after transform" writeln( hOut ) def PreProcess( cFile ) : global defs,hOut,lineno,curfile hFile = open( cFile, "r" ) if not hFile : print "Error : unable to open "+cFile sys.exit(1) savno = lineno savfile = curfile curfile = cFile lineno = 0 while not hFile.closed : line = readNextLine(hFile) if not line : continue m = defStmt.match( line ) if m : nam = m.group("name") if defs.has_key( nam ) : print "Error : : "+nam+" already defined" sys.exit(1) if not m.group("aft") : defs[nam] = "" # preprocessor const elif m.group("aft")[0] == "(" : #pseudofunction defs[nam+"("] = m.group("aft") else : # symbolic constant defs[nam] = string.strip( string.rstrip( m.group("aft") ) ) continue m = ifdef.match( line ) if m : if not defs.has_key( m.group("name") ) : defOmit( hFile ) continue m = ifndef.match( line ) if m : if defs.has_key( m.group("name") ) : defOmit( hFile ) continue m = elsedef.match( line ) if m : defOmit( hFile ) continue m = endif.match( line ) if m : continue m = include.match( line ) if m : fname = string.split( m.group("filename"),'"' )[1] IncludeFile( fname ) continue m = undef.match( line ) if m : if defs.has_key( m.group("name") ) : del defs[ m.group("name") ] continue m = xcmd.match( line ) if m : Command( m.group("srch"),m.group("repl") ) continue m = cmd.match( line ) if m : Command( m.group("srch"),m.group("repl") ) continue m = xtrans.match( line ) if m : Translate( m.group("srch"),m.group("repl") ) continue m = trans.match( line ) if m : Translate( m.group("srch"),m.group("repl") ) continue m = pragma.match( line ) if m : continue transform( line ) hFile.close() lineno = savno curfile = savfile def IncludeFile( fname ) : import os if not os.path.exists( fname ) : if os.environ.has_key("INCLUDE") : incpaths = string.split( os.environ["INCLUDE"], ";" ) for p in incpaths : if os.path.exists( p + "\\" + fname ) : hOut.write( '#line 1 "'+p+"\\"+fname+'"@"'+fname+'"\n' ) fname = p+"\\"+fname break else : print "Error : unable to find : "+fname sys.exit( 1 ) else : print "Error : unable to find : "+fname sys.exit( 1 ) else : hOut.write( '#line 1 "'+fname+'"@"'+fname+'"\n' ) PreProcess( fname ) if curfile : hOut.write( "#line "+str(lineno)+' "'+curfile+'"\n' ) def PreProcessPrg( prg, pp=None,std=None ) : import os global hOut,curfile,rootfile if "." not in prg : prg = prg+".prg" if not pp : pp = os.path.splitext(prg)[0]+".ppp" hOut = open( pp, "w" ) rootfile = prg print "Preprocessing",prg,"to",pp,"using",std if std : IncludeFile( std ) hOut.write( '#line 1 "'+prg+'"\n' ) curfile = prg PreProcess( prg ) hOut.close() if __name__ == "__main__" : import getopt optlist, args = getopt.getopt( sys.argv[1:], "Uu:" ) if not args or len(args) > 2 : print "Syntax : PRGPP [-U | -u ] [ ] " else : if len(args) < 2 : args.append( None ) if optlist : if optlist[0][0] == "-U" : PreProcessPrg( args[0], args[1] ) elif optlist[0][0] == "-u" : PreProcessPrg( args[0], args[1], optlist[0][1] ) else : PreProcessPrg( args[0],args[1],"std.ch" ) From margaret at bewell.net Wed Apr 21 18:08:53 1999 From: margaret at bewell.net (margaret at bewell.net) Date: Thu,22 Apr 1999 18:08:53+2000 Subject: Thing about Linux you do not know... Message-ID: <104221999181500sforge@mcs.net> New total graphics and CAD solution for LIN????X !!! http://www.linuxcad.com LinuxCAD may replace AutoCAD and Visio in 90% of cases where ACAD is used, and in 100% cases the Visio is used it means thousands of dollars in savings !!! Plus true multitasking of Linux and freedom from the MS-Windows. http://www.linuxcad.com LinuxCAD is an AutoCAD for Linux for all practical purposes it implements all major features of ACAD in such a way that new users (who had ACAD experience before) do not need any additional training to start working with LinuxCAD. http://www.linuxcad.com LinuxCAD is a professional quality Computer Aided design and Drafting system for Linux , LinuxCAD is all graphics , all visual modelling and all diagramming you may need for Linux !!! http://www.linuxcad.com LinuxCAD can be used in: Software Development Flowcharting , Entity Relationship Diagramming, System Administration Diagramming and you actually can start your sysadmin tasks from inside LinuxCAD, Mechanical Engineering drafting, PCB and schematic design ( easily integrated with routing programs ), Geographicsl Information Systems, Any kind of drafting where integration with database is important, Floor plans for buildings and facilities, Architectural Drafting, Front end for programmable rendering systems like OpenGL, Can be used to replace ACAD in every application later is used !!! LinuxCAD - a must have for every Linux user. LinuxCAD for Sun SPARC - $350 ( when purchasing multiple copies major discount provided ). LinuxCAD is available for Intel x86 and PowerMac Linuxes. LinuxCAD is a very affordable commercial program Intel version - only $99 LinuxPPC version - only $120 Also available for all major ????nix versions ( look at our web site for details. ) YO???? CAN START ????SING WORKING, BREATHING LIN????XCAD IN 24 HO????RS AFTER PAYING BY CREDIT CARD !!! This prices will meet our competitors anywhere in the world to the benefits of all Linux users. They show our commitment to mass Linux market, our long term goals and superior quality of our product in comparison to competition. LinuxCAD v 1.85 includes important additions: 1. Printing to HPGL compatible plotters , 2. Printing DeskJet and LaserJet , 3. Printing Postscript 4. Printing LinuxCAD MS Windows based Print server. 5. Blocks and Attributes - just like in AutoCAD. 6. Bezier Splines. 7. 3D objects and algorythms. 8. ????ser Coordinate Systems. 9. Bug fix from LinuxCAD rel 1.8 10. Hidden lines removal. 11. Dview command. 12. Forming of 3D shapes by extrusion and revolution. 13. Support for SHX fonts in ????nifont format. That means national symbols, including german accent letters, cyrillic, katakana, kanji. all included in $99 basic package, there is no need to purchase any additions or extensions. Now our competitors can no longer claim "The best performance/price ratio" The best performance/price ratio provides nothing else but LinuxCAD alone !!! check and see for yourself: http://www.linuxcad.com The outline of the main features of the previous versions: 1) LinuxCAD provides great variety of entity types ( lines , circles , ellipses , traces , text , polylines , solids , doughnuts , arcs , spline curves , user defined entities and 3D entities ) , 2) LinuxCAD implements all necessary editing features ( scale , rotate , mirror , offset , array , copy , move , hatch , trim , extend , purge , ... ). 3) Allows up to 1000 layers, with ability to control layer color and visibility independently. 4) All entities are transferable to and from AutoCAD through DXF exchange format. 5) Supports user defined line types and load able fonts in SHX format ( including ????nicode fonts ). 6) Supports a hardcopy to printers. 7) Parts of the drawing can be copied between different instances of the LinuxCAD using X-Clipboard. 8) LinuxCAD has industry standard Motif G????I. 9) Allows users to write custom applications for automating typical editing and drafting tasks using industry most popular C-compiler GCC. 10) Easy integration to relational databases !!! http://www.linuxcad.com We are looking for resellers of the shrink wrapped copies of LinuxCAD, reseller discounts provided. Software Forge Inc. public relations department PS. LinuxCAD has been developed using our proprietary Post Object Oriented Technology of Software Development. We have a strategic advantage against our competitors ( including big ones ) in the speed of development and manageability of huge volumes of source code (!) In the long run You better off with LinuxCAD !!! LinuxCAD is the future , AutoCAD is the past, Give LinuxCAD a try !!! http://www.linuxcad.com Software Forge Inc. , just as such companies as Cygnus,Caldera,SSC, Netscape,Oracle,IBM,Redhat doing its best in bringing Linux OS in the mainstream of business computing !!! Our product LinuxCAD firmly establishes Linux as solid platform for Computer Aided Drafting and diagramming !!! This entire post is Copyright of the Software Forge Inc. and can be reproduced or copied only in its entirety in its original unmodified form. From bhuzyk at kodak.com Mon Apr 12 17:05:11 1999 From: bhuzyk at kodak.com (Bruce Huzyk) Date: 12 Apr 1999 21:05:11 GMT Subject: Converting a string to a tuple Message-ID: <01be8530$65bb7120$52037e81@saints> Here is a basic problem that is causing me much stress: I have a string a = '(1, "abc\\def", 2)' that I would like to convert to a tuple. I have tried eval(), but it interprets the backslashes. From jfarr at real.com Fri Apr 23 18:29:38 1999 From: jfarr at real.com (Jonothan Farr) Date: Fri, 23 Apr 1999 15:29:38 -0700 Subject: Efficient List Subtraction References: <3720EF73.CA7DDEFF@Colorado.edu> Message-ID: I have also longed for built in support for the union and intersection of two sequences. Perhaps: list.union(list2) and list.intersection(list2) ?? insert-clever-witty-long-hyphenated-phrase-ly y'rs --jfarr From roy at popmail.med.nyu.edu Mon Apr 26 16:01:41 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Mon, 26 Apr 1999 16:01:41 -0400 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <37215EFB.433AFCA6@prescod.net> <3724B2D6.B468687A@prescod.net> Message-ID: Paul Prescod wrote: > It is a performance issue if you don't know that regexps are supposed to > be compiled. I hope this doesn't sound as bad as I fear it might, but part of being a good programmer (or at least a good computer scientist) is to understand performance issues like this. Regular expression theory hasn't changed a whole bunch in the last 20 years; it's the same stuff in C, Perl, and any other language that has RE functionality (either built-in or through some library). The idea of factoring constant operations out of loops is the same today is it was 10, 20, 30 years ago. If you don't know that RE's get compilied (and that the compilation stage can be expensive), you don't understand the tool you're using. If you don't understand that factoring the expensive constant compilation process out of a loop is important to make your program run fast, you aren't a good programmer. No programming language can help that. -- Roy Smith New York University School of Medicine From aaron_watters at my-dejanews.com Tue Apr 13 09:15:16 1999 From: aaron_watters at my-dejanews.com (aaron_watters at my-dejanews.com) Date: Tue, 13 Apr 1999 13:15:16 GMT Subject: simple indexed file module? References: Message-ID: <7evg0s$spu$1@nnrp1.dejanews.com> In article , Joe Strout wrote: > For a CGI script I'm working on, I need to keep a couple of indexed > files. These will contain variable-length data (descriptions), which > may be changed fairly frequently. So I imagine that in addition to the > data file, there will be an index file that keeps track of the position > and length of each record. New or expanded records will be stuffed in > wherever there is free space, or at the end if no sufficient free chunk > is available. If the data is small I'd say use an in memory approach with load and store using marshal. If the data is large enough that the time to load/unmarshal/marshal/store becomes an issue (probably on the order of megs, I think) then use some sort of dbm implementation. bplustree.py will work, but it doesn't do the kind of garbage management you ask for (you'd have to do that periodically offline). I haven't tested it on a mac, but it should require few if any changes. http://starship.skyport.net/crew/aaron_watters/bplustree/ also have a look at http://www.chordate.com/gadfly.html -- Aaron Watters === You can express emotion in many ways and with varying degrees of loudness. -- from my recently purchased French vocab tape. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From news at helen.demon.nl Thu Apr 29 04:27:34 1999 From: news at helen.demon.nl (Ilja Heitlager) Date: Thu, 29 Apr 1999 10:27:34 +0200 Subject: Using Python for Modular Artificial Intelligence code References: Message-ID: <7g94lp$mdu$1@news.worldonline.nl> >I've started looking into Python as the AI scripting language for this >purpose, but I'm having trouble seeing exactly how I could do this. I want >a message passing architecture - so one object in the game world sends a >message to another for interpretation (along with a Python tuple for the >parameters of the message perhaps). This requires a two way interface >between my C++ code and the Python script loaded for the particular game >object. Wouldn't you be better of using a network or distributed architecture. Use Corba or TCP/IP protocol to let your objects interact. Saves you the trouble of language-interoperatablility and provides possibilities for multi-user (You're doing a LARGE game project, not?) Where do you use C++ for anyway? GUI's? Build them in Python, forget C++ until you are done and than use C++ to speed up critical sections Ilja From 4mschulz at informatik.uni-hamburg.de Fri Apr 30 08:40:00 1999 From: 4mschulz at informatik.uni-hamburg.de (Marko Schulz) Date: 30 Apr 1999 12:40:00 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: <7gc8b0$27t$2@rzsun02.rrz.uni-hamburg.de> Markus Kohler wrote: > > Python-1.5.2c1 .... > 0.52 seconds > > Squeak .... > 0.13 seconds. I wouldn't put too much meaning in this number. You can't say how big the startup costs are for a python vs. squeak. You mentioned Garbage Collection. There are other factors, that might make other (longer running?) examples very different. Still it would be nice, if python were faster. -- marko schulz "Die Welt ist gut, die Welt ist schlecht. Ich seh' mehr als ich begreifen kann. Ich sehe in 3-D." '3-D', Extrabreit From jeremy at cnri.reston.va.us Thu Apr 15 15:25:37 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 15 Apr 1999 15:25:37 -0400 (EDT) Subject: for in benchmark interested In-Reply-To: <37157CE7.EFB470CA@inka.de> References: <37157CE7.EFB470CA@inka.de> Message-ID: <14102.15523.573321.443195@bitdiddle.cnri.reston.va.us> The Python version would be faster if you used sys.stdin.read instead of sys.stdin.readlines. I'm not sure why you need to split the input into lines before you split it into words; it seems like an unnecessary step. The version below is 25% faster on my machine than your fastest Python version. (And I'm not even an expert Python optimizer :-). import sys import string def run(): dict={} dict_get = dict.get read = sys.stdin.read string_split = string.split while 1: buf = read(500000) if buf: for key in string_split(buf): dict[key] = dict_get(key, 0) + 1 else: return dict dict = run() write = sys.stdout.write for word in dict.keys(): write("%4d\t%s\n" % (dict[word], word)) Jeremy From richard at folwell.com Fri Apr 16 16:01:32 1999 From: richard at folwell.com (Richard Folwell) Date: Fri, 16 Apr 1999 20:01:32 GMT Subject: stupid Win-CGI getting started question Message-ID: <01BE8851.3B6BED90.richard@folwell.com> On 14 April 1999 19:45, bill_seitz at my-dejanews.com [SMTP:bill_seitz at my-dejanews.com] wrote: > So nobody can run .py files as CGI? > > Is this a known problem? What's its scope? Only Netscape/NT? What about IIS? It was certainly possible to run .py files as CGI under IIS 2. I did not need to upgrade that system, so cannot be sure about later versions of IIS, but would find it extremely hard to believe that anyone would remove the ability to use an abitrary external program to provide a CGI resource to a web server from a mainstream web server. I do remember seeing a (at least one, maybe more) posting about differences in configuring IIS2/3/4 w.r.t. external programs (e.g. stuff which worked fine under IIS2/3 stopped working when the server was upgraded to version 4). The problem has to be along these lines. The CGI spec (I understand) simply requires programs/languages that can handle standard input (stdin) and produce standard output (stdout). > I'm trying to keep my code generic enough that it can be moved to other > platforms/servers down the road (which is why I haven't been looking at nsapy > or Medusa or ZopeHTTP...), so I don't want to work around a problem now and > just have it hit me again later. I'd like to understand the nature of the > problem enough to evaluate alternative solutions. I have done some work with ISAPI (the Microsoft equivalent to NSAPY). There are performance gains with these approaches, but you definitely lock yourself into a single web server supplier (unless someone has come up with a neat way of producing cross-platform support for these plug-ins). CGI has the big advantage that it is supported by all non-toy web servers, and the actual code should not need changing between different web servers. Richard From calishar at *remove*this*.home.com Thu Apr 15 17:59:58 1999 From: calishar at *remove*this*.home.com (Calishar) Date: Thu, 15 Apr 1999 21:59:58 GMT Subject: Freezing an App References: <7f15dj$bq4$1@m2.c2.telstra-mm.net.au> <7f3v96$g88$1@m2.c2.telstra-mm.net.au> Message-ID: Mark Hammond wrote in message news:7f3v96$g88$1 at m2.c2.telstra-mm.net.au... > Are you sure the code is being executed at all? I cant imagine how these > could silently do nothing. Actually, I must plead guilty to a week long case of brain death. I took a close look at teh code and the registry today, and the code was doing exactly what I told it to do, which of course was not quite what I wanted it to. I was placing the Computer Name value one level too deep. So the program worked, the freeze worked, the programmer should be fired. Hanging his head in shame, Calishar From jeffp at crusoe.net Sat Apr 3 20:38:37 1999 From: jeffp at crusoe.net (evil Japh) Date: Sat, 3 Apr 1999 20:38:37 -0500 Subject: Why are they? Re: Module Documentation Strings In-Reply-To: References: Message-ID: Why are there documentation strings? I mean, granted it would be very bad if the next version of python did not support them, but why not just use comment lines? Just curious why this convention is used. -- Jeff Pinyan (jeffp at crusoe.net) www.crusoe.net/~jeffp Crusoe Communications, Inc. 732-728-9800 www.crusoe.net From jeremy at cnri.reston.va.us Wed Apr 28 11:13:28 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Wed, 28 Apr 1999 11:13:28 -0400 (EDT) Subject: try vs. has_key() In-Reply-To: References: <7g51q6$1pt$1@vvs.superst.iae.nl> Message-ID: <14119.8145.293039.667256@bitdiddle.cnri.reston.va.us> >>>>> "AM" == Aahz Maruch writes: AM> It appears that the second parameter for get() (to specify a AM> value different from None when the key is not found) is new to AM> 1.5.2. In 1.5.1 you still have to do the following: That's not correct. The optional second argument for get has been around since get was introduced, which was before the release of 1.5 final. (You check the CVS log for dictobject.c for confirmation :-). If you use get, you can always specify a default value. This thread seems to have included a lot of code that misuses dictionaries and other built-in types, which is probably why you concluded that get changed between 1.5.1 and 1.5.2. I think the confusion started when the following bits of code were posted: d={} for word in words: d[word]=d.get(word, 0)+1 The above part is just fine -- an efficient way to count words. d={} for word in words: first_two=word[:2] d[first_two]=d.get(first_two, []).append(word) This second bit doesn't work because the append method on list objects returns None. As a result, the first time a new value for first_two appears None will be assigned to that key in the dictionary. The second time that value of first_two shows up, None will be returned by d.get. Then the code will raise an AttributeError, because None doesn't have an append method. The following code would be correct: d={} for word in words: first_two=word[:2] d[first_two]= temp = d.get(first_two, []) temp.append(word) It would be less efficient, however, than the following: d={} for word in words: first_two=word[:2] if d.has_key(first_two): d[first_two].append(word) else: d[first_two] = [word] (And as Barry pointed out earlier in the thread, depending on how frequently you expect has_key to return true, you may want to use try/except instead. See http://www.python.org/~bwarsaw/ecshort.pdf.) Jeremy From wtanksle at dolphin.openprojects.net Tue Apr 6 00:40:22 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Tue, 06 Apr 1999 04:40:22 GMT Subject: Crappy Software was Re: [OffTopic: Netscape] Re: How should Python be evangelized? References: <7dos4m$usi$1@nnrp1.dejanews.com> <7dqs0h$lcq$1@nnrp1.dejanews.com> <2_6M2.30$Kj1.679@198.235.216.4> <37019F42.EA55CA8@kanga.org> <009d01be7b47$8a9a6020$f29b12c2@pythonware.com> <7dtmso$7u6$1@news.clarkson.edu> <3703ca33.9749737@news.bctel.ca> <37089dcb@fermi.armored.net> Message-ID: On Mon, 5 Apr 1999 12:15:17 -0700, Samuel A. Falvo II wrote: >>Er, that'd be the same Netscape that has such broken CSS that it is >>absolutely unuseable? >While I understand that Netscape's CSS implementation is not the best, I >have to take an opposing view as to it not being usable. Netscape's CSS is >more than adequate for the vast majority of the web sites out there. They >provide my web sites with a good, professional appearance under both >Netscape and MSIE. I understand what you mean -- we have to design for what's out there, not what we wish was out there. Nevertheless, Netscape is so broken that it will *crash* on certain CSS inputs. Not render them wrong, crash. Thud. "Doctor, it hurts when I do this!" >>Myself, I prefer Opera; at least it meets standards. MSIE runs a close >>second these days. Netscape is horrendously buggy. >And Mozilla will decimate MSIE. The trick, of course, is them actually >releasing it as a finished product. :-) I have EVERY hope that this will happen. (Please please please...) And it'll be using Python, too. (Right?) >However, when I actually see Opera for Linux, I'll be sure to give it a >shot. I've used Opera for Windows, and was only mildly impressed. It was a >blazingly fast web browser, but it didn't have the feature set that MSIE had >at the time. A lot has changed since then, I know -- which is why I'm >willing to give it another shot. The one reason I like Opera (I'm not using it now because I'm a cheapskate): it fully and nearly correctly supports the keyboard. Oh, it's CSS is better than anything else, but like you said I don't code for the best, I code for _everything_. >(I'll be REALLY happy when they port Opera to AmigaOS 5.) Hmm, would that be because of Opera or because of AmigaOS 5? (The current version is OS 4.) Are there many Amiga Python users out there? -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From arcege at shore.net Wed Apr 28 15:47:55 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 28 Apr 1999 19:47:55 GMT Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: Aahz Maruch wrote: : In article , : Florian Weimer wrote: :> :>(Quotation from the Perl 4 manpage. This version doesn't have an :>`exists' function.) : Then you've just made a completely irrelevant comment, on the order of : referring to Python 1.2. Perl 5 has been out for more than two years, : and there are so many improvements that I don't know of *anyone* who's : doing new work in Perl 4. Perl 5 was released somewhere around 3-4 years ago. And I haven't written much Perl code in that time - but any Perl code I have written is for perl4. I avoid perl5 religiously. But there could easily be others out there who still use perl4 as well. Just like there are ppl out there who still use Tcl 7.5 (my previous and current employers) and Python 1.4. It is not always easy to upgrade when you have to support customers in the field using real-world products. -Arcege From moshez at math.huji.ac.il Thu Apr 29 13:32:05 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 29 Apr 1999 20:32:05 +0300 Subject: Python IS slow ! [was] Re: Python too slow for real world In-Reply-To: <7g9qmo$luf$1@news.udel.edu> References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <7g9qmo$luf$1@news.udel.edu> Message-ID: On 29 Apr 1999, Terry Reedy wrote: > >The reason it's slow is its runtime model. _Every_ function call requires > >a lookup in a hash table, just on the off-chance that the programmer > >changed the meaning of the function. > > A batch-mode optimizer analyzing an entire file (module) should be able to > detect whether or not function names are rebound. Or a human optimizer, might do something like (old code) for i in a: f(a) (new code) lf=f for i in a: lf(a) Python (I believe) optimizes local variable lookups. -- Moshe Zadka . QOTD: My own exit is more likely to be horizontal then perpendicular. From heaney at cambridge.scr.slb.com Thu Apr 22 05:50:40 1999 From: heaney at cambridge.scr.slb.com (Steven Heaney) Date: 22 Apr 99 10:50:40 +0100 Subject: HTMLgen in Java? References: <371D7CE8.7CF9067@erols.com> Message-ID: Try looking at http://java.apache.org/ecs/index.html ........................................................................ Steven Heaney Schlumberger http://www.slb.com/cgi-bin/people.pl?type=person&name=steven%20heaney From fredrik at pythonware.com Sat Apr 10 10:00:51 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 10 Apr 1999 14:00:51 GMT Subject: Q on Tkinter Scrollbar References: <370CFAC8.32EB0B29@ingr.com> Message-ID: <004f01be835a$c0e15240$f29b12c2@pythonware.com> Joseph Robertson wrote: > I want to manually control the scrollbar in a tkinter app, i.e. I don't > want to tie it to another widget as a child. Below is what I have so > far. I can't figure how to make the 'thumb' stay at the returned > position, or the point where the user drags it. Right now it always > pops back to the top. > > I want it to behave like a Scale, but look like a scrollbar. Think of a > virtual window on a dataset, where I don't want to load the contents of > the data set into a listbox (not enough memory). > > Anyone do this before, know of any similar examples, or give me a clue > where to look next. I don't want to use extensions or another GUI, it > needs to be Tkinter. you're halfways there. as you've seen, the callback given to the scrollbar's "command" option (your _vscroll callback) is called with "moveto" or "scroll" events, as described on: http://www.pythonware.com/library/tkinter/introduction/scrollbar.htm however, the scrollbar target (your dataset) should respond to this by calling the scrollbar's "set" method with two floating point values (first and last), which gives the thumb's position as 0.0 (upper/left) and 1.0 (lower/right). the target should of course also update the scrollbar if the view changes by any other reason (e.g. if you load a new dataset). scrollable widgets like Listbox and Text provide "xscrollcommand" and "yscrollcommand" options for this purpose. Cheers /F fredrik at pythonware.com http://www.pythonware.com From tseaver at palladion.com Fri Apr 30 08:59:53 1999 From: tseaver at palladion.com (Tres Seaver) Date: Fri, 30 Apr 1999 07:59:53 -0500 Subject: HTML "sanitizer" in Python References: Message-ID: <3729A949.C16289FB@palladion.com> Scott Stirling wrote: > > 4) If someone helps me out, I think I should be able to use this info. and the tutorial and the Lutz book to loop the process and make the program run until all *.htm files in a folder have been handled once. > > Well, if I understand correctly, the *only* thing you're trying to do > is to remove some specific strings from a bunch of files. Now if I > were you, I wouldn't even bother to use Python on something that > simple; I would just use sed. With sed, you could do: > > sed 'g/string_to_be_eliminated//g' my_file.html > output.html > > Presto, that's it. I think that there is a version for GNU sed for > Windows somewhere out there; do yourself a favour and get it. Look for the "user tools" under http://sourceware.cygnus.com/cygwin/ -- ========================================================= Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From jeremy at cnri.reston.va.us Fri Apr 30 11:08:30 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Fri, 30 Apr 1999 11:08:30 -0400 (EDT) Subject: try vs. has_key() In-Reply-To: References: <7g51q6$1pt$1@vvs.superst.iae.nl> <14119.8145.293039.667256@bitdiddle.cnri.reston.va.us> Message-ID: <14121.50708.131339.251436@bitdiddle.cnri.reston.va.us> >>>>> "JE" == Jeff Epler writes: >>The following code would be correct: >> >> d={} >> for word in words: >> first_two = word[:2] >> d[first_two]= temp = d.get(first_two, []) >> temp.append(word) JE> what about d[first_two] = d.get(first_two, [])+[word] ? Or is JE> list construction and addition going to be enough more expensive JE> than the function call to make this a lose as well? Yeah. Concatenating two lists results in a new list being created every time (and you're already creating a new list containing the value of word). Two list allocs is definitely more expensive that an append. Jeremy From arcege at shore.net Thu Apr 29 14:58:07 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 29 Apr 1999 18:58:07 GMT Subject: padding strings References: Message-ID: <3Z1W2.97$9L5.17946@news.shore.net> Roy Smith wrote: : Given a string, I want to generate another string which is exactly N : characters long. If the first string is less than N, I want to blank-pad : it. If the first string is greater than N, I want to truncate it. : What's the most straight-forward way to do that? You can use format strings: Python 1.5.1 (#3, Jul 16 1998, 10:35:48) [GCC 2.7.2.2] on aix4 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> '%*s' % (10, "Michael") ' Michael' >>> '%-*s' % (10, "Michael") 'Michael ' >>> '%-*.*s' % (10, 10, "Michael P. Reilly") 'Michael P.' >>> (Taken from section 2.1.5.1 "More String Operations" in the Python Library Reference). You can also use '%%' to delay some of the formatting: fmt = '%%-%d.%ds' % (10, 10) # yields '%-10.10s' print repr(fmt % name) This is probably more efficient if you are going to use the same format widths repeatedly. -Arcege From rgruet at ina.fr Thu Apr 15 11:07:43 1999 From: rgruet at ina.fr (Richard GRUET) Date: Thu, 15 Apr 1999 16:07:43 +0100 Subject: 1.5.2 install problems on NT References: <3714D8FF.634655C5@ina.fr> <8DA968455duncanrcpcouk@news.rmplc.co.uk> Message-ID: <371600BF.28EE6F31@ina.fr> Forget what I've just written: I've just removed tk80.dll (in addition to tcl80;dll) from the system32 directory, and this time all worked fine. So the final solution is : - remove any extra copy of tcl80.dll and tk80.dll except the ones in tcl\bin directory - add tcl\bin directory to the Path environment variable. Thanks for your help Richard Duncan Booth a ?crit : > Richard GRUET wrote in <3714D8FF.634655C5 at ina.fr>: > > >cl problems: > >--------------- > >shared by many ! see Hoon Yoon for instance... wish80;exe works (hence I > >conclude that tcl is installed properly) but IDLE or Tkdb don't, with > >insults like: > >C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl: bad event type > >bad event type or keysym "MouseWheel" > > while executing > >"bind Listbox { > > %W yview scroll [expr - (%D / 120) * 4] units > >}" > > (file "C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/listbox.tcl > > invoked from within > >"source [file join $tk_library listbox.tcl]" > > (file "C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl" lin > > invoked from within > >"source C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl" > > ("uplevel" body line 1) > > invoked from within > >"uplevel #0 [list source $tkfile]" > > > >This probably means that Tk wasn't installed properly. > > > > I had exactly that problem. I think it means that you upgraded an old Tcl > system but there are still copies of the old Tcl80.dll files lying around > somewhere and python is finding those in preference to the new ones. > Delete tcl80.dll from the \winnt\system32 directory or wherever they > are, and add the tcl bin directory (e.g. D:\Progra~1\Tcl\Bin) to the end of > your path in the control manager/system/environment settings. > > -- > Duncan Booth duncan at dales.rmplc.co.uk > int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" > "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? > http://dales.rmplc.co.uk/Duncan From smithkf at OMIT_THIS.us.ibm.com Fri Apr 23 12:49:42 1999 From: smithkf at OMIT_THIS.us.ibm.com (Kevin F. Smith) Date: Fri, 23 Apr 1999 09:49:42 -0700 Subject: millisecond time accuracy Message-ID: <3720A4A6.125DA1C7@OMIT_THIS.us.ibm.com> Is there a way to measure time accurate to milliseconds? For example, by calling the time.time() function I get seconds. Is there a comparable function that I could use to measure interval times down to at least millisecond accuracy? Thanks. From dfan at harmonixmusic.com Thu Apr 22 13:30:53 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 22 Apr 1999 13:30:53 -0400 Subject: Pointers to variables References: <19990422121403.A279051@vislab.epa.gov> Message-ID: Randall Hopper writes: | This doesn't work: | | for ( var, str ) in [( self.min, 'min_units' ), | ( self.max, 'max_units' )]: | if cnf.has_key( str ): | var = cnf[ str ] | del cnf[ str ] | | It doesn't assign values to self.min, self.max (both integers). The | values of these variables are inserted into the tuples and not | references to the variables themselves, which is the problem. | | How can I cause a reference to the variables to be stored in the | tuples instead of their values? Here's how I would do it: for ( varname, str ) in [( 'min', 'min_units' ), ( 'max', 'max_units' )]: if cnf.has_key( str ): setattr (self, varname, cnf[ str ]) del cnf[ str ] I don't think this is really any slower than what you wanted to do, since Python was doing namespace lookups on 'min' and 'max' before anyway. If min and max were mutable objects, a variation of your approach would probably work, if there were a method to change them in-place (e.g., "var.set_me (cnf[str])"). "var = cnf[str]" is never going to do what you want, since it just makes the name 'var' point to a different object (that's what assignment means in Python). I've just been using Python for a week, so take my answer with a grain of salt... -- Dan Schmidt -> dfan at harmonixmusic.com, dfan at alum.mit.edu Honest Bob & the http://www2.thecia.net/users/dfan/ Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/ Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/ From python-mode at python.org Thu Apr 29 14:01:52 1999 From: python-mode at python.org (python-mode at python.org) Date: Thu, 29 Apr 1999 14:01:52 -0400 (EDT) Subject: Emacs' python-mode buggy? References: <14120.30592.807745.732604@anthem.cnri.reston.va.us> <3728955e.19679327@news.omnilink.de> Message-ID: <14120.40592.744600.160039@anthem.cnri.reston.va.us> >>>>> "SF" == Stefan Franke writes: SF> What bothers me most with the Emacs mode's TQSs is SF> that editing gets terribly slow if there lots of them (and SF> they are long). SF> On each CR, Tab or : the current indent is computed, SF> which takes *much* longer than outside the String. SF> Can this be fixed? It's probably better with XEmacs, which has primitives that python-mode can use to figure out if it's sitting inside a string or not. Emacs doesn't have these. That being said, I've had a few people report such problems but no one who's been able to send me a code sample so I can profile it. If you can do this, use C-c C-b to send a python-mode bug report and include your sample. -Barry P.S. Everything you ever wanted to know about python-mode and font-locking: http://www.python.org/emacs/python-mode/faq.html From mnot at pobox.com Fri Apr 30 08:55:50 1999 From: mnot at pobox.com (Mark Nottingham) Date: Fri, 30 Apr 1999 12:55:50 GMT Subject: mktime() like function to produce GMT? Message-ID: <00be01be9308$c649cf60$0301a8c0@cbd.net.au> I need a function to produce a Unix epoch time from a time tuple, a la time.mktime(). Problem is, mktime() gives you the tuple in localtime, which is dangerous if you're dealing with GMT times in the past (like in the HTTP). Is there a function that will make a GMT epoch time straight from a time tuple? Thanks, Mark Nottingham, Melbourne Australia mnot at pobox.com http://www.pobox.com/~mnot/ From mrfusion at bigfoot.com Tue Apr 20 22:49:43 1999 From: mrfusion at bigfoot.com (mrfusion at bigfoot.com) Date: Wed, 21 Apr 1999 02:49:43 GMT Subject: Tkinter hangs on mainloop References: <371c19bb.60709557@news> <008a01be8b11$e17fb320$f29b12c2@pythonware.com> Message-ID: <371d3ae9.134747887@news> >> I've done a complete install of python ver 1.5.2 on my >> windows98 system and I've run into a problem with Tkinter (no big >> surprise!) I can import it with the line : from Tkinter import * > >I assume you're running this from the command >line, right? I've tried both from the command line and double clicking the file name (I have the proper associations set up). I've tried running k:\python\python tktest.py, I've tried starting python and typing the file in one line at a time, I've even tried waving a dead chicken over my computer. No luck. >> It hangs. > >not really. it doesn't hang, it just doesn't return >immediately. in fact, it won't return until you've >closed the root window. Actaully it doesn't return at all.....ever. If I close the root window, I get a messsage from windows that says : "Windows can't shut this program down automatically. It is recommended that you close the program....bla bla bla". >before you to this, look in the task bar. click on >the Tk icon, and the (quite small) window will pop >up. I've looked, there's no icon on the task bar. I've check through the task manager and there's nothing there either. > >http://www.pythonware.com/library/tkinter/introduction/intro01.htm >has some more information on the mainloop function. I went to this site and typed in the example file (it was basically the same one that I was trying to run). I still get nothing. Any other suggestions? Thank you for trying to help , Tom From morse at harborcom.net Thu Apr 22 07:28:34 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Thu, 22 Apr 1999 11:28:34 GMT Subject: Controlling Linux serial port w/ Python ... - posixport.py (1/1) References: <924762349.809295488@news.intergate.bc.ca> Message-ID: <371f07e2.156646776@mail.oh.verio.com> begin 644 posixport.py M:6UP;W)T(&]S"FEM<&]R="!F8VYT;"P at 1D-.5$P*:6UP;W)T('1E7=O2`M+2!P87)I='DN("!-=7-T(&)E(&]N92!O9CH* M("`@("`@("`@("`@("`@("`@("`@(").;R(L(")/9&0B+"`B179E;B(L(")- M87)K(BP@;W(@(E-P86-E(@H@("`@("`@("`@("!D871A3&5N("TM(&1A=&$@ M;&5N9W1H("@U+3 at I"B`@("`@("`@("`@('-T;W!":71S("TM(",@;V8@2!F;W(@ M=&AE(&]P=',N"@H@("`@("`@("`@("!+97EW;W)D(&%R9W5M96YT2!C;VYT86EN:6YG('1H92!F M;VQL;W=I;F<@4U1224Y'4SH*("`@("`@("`@("`@("`@(%!O0H@("`@("`@("`@("`@("`@1&%T84QE;F=T:`H@("`@("`@("`@("`@ M("`@4W1O<$)I=',*("`@("`@("`B(B(*("`@("`@("!I9B`H71H M;VX@<&]S="`Q,B\R,R\Y-R`@("`*("`@("`@("`CPH@("`@("`@("`Q,3`Z5$52 M34E/4RY",3$P+"`*("`@("`@("`@,3$U,C`P.E1%4DU)3U,N0C$Q-3(P,"P@ M"B`@("`@("`@(#$R,#`Z5$5234E/4RY",3(P,"P@"B`@("`@("`@(#$S-#I4 M15)-24]3+D(Q,S0L(`H@("`@("`@("`Q-3`Z5$5234E/4RY",34P+"`*("`@ M("`@("`@,3 at P,#I415)-24]3+D(Q.#`P+"`*("`@("`@("`@,3DR,#`Z5$52 M34E/4RY",3DR,#`L(`H@("`@("`@("`R,#`Z5$5234E/4RY",C`P+"`*("`@ M("`@("`@,C,P-#`P.E1%4DU)3U,N0C(S,#0P,"P@"B`@("`@("`@(#(T,#`Z M5$5234E/4RY",C0P,"P@"B`@("`@("`@(#,P,#I415)-24]3+D(S,#`L(`H@ M("`@("`@("`S.#0P,#I415)-24]3+D(S.#0P,"P@"B`@("`@("`@(#0V,#@P M,#I415)-24]3+D(T-C`X,#`L(`H@("`@("`@("`T.#`P.E1%4DU)3U,N0C0X M,#`L(`H@("`@("`@("`U,#I415)-24]3+D(U,"P@"B`@("`@("`@(#4W-C`P M.E1%4DU)3U,N0C4W-C`P+"`*("`@("`@("`@-C`P.E1%4DU)3U,N0C8P,"P@ M"B`@("`@("`@(#7=O Message-ID: <370594A2.E2571128@swcp.com> Martijn Faassen wrote: ... > Python/Perl diplomatic relations Rob Malda of Slashdot let me run his > site (www.slashdot.org) on this machine today too (in Zope), and it only I thought Slashdot was running PHP! Or is that part of the joke? Zope is cool. Alex From jwbaxter at olympus.net Mon Apr 26 17:32:57 1999 From: jwbaxter at olympus.net (John W. Baxter) Date: Mon, 26 Apr 1999 14:32:57 -0700 Subject: A bonus came with Learning Python Message-ID: Actually, it looked like a billing error until I recovered from the "sticker shock." Folded into the book was a packing slip with invoice attached, for a large amount* for 57 copies of Learning Python. Once I realized this was O'Reilly shipping to and invoicing Amazon.com, I was amused rather than comatose. *I'm not saying *what* large amount, except to say that at that sort of pricing in the industry, it seems odd that Amazon isn't making money. I haven't recovered enough even to skim...but a quick paging (with a stop at "Files in action") leads me to say "Looks good, Mark...thanks!" --John -- If nothing is pressing, putter about with this or that. (Fortune cookie) John W. Baxter Port Ludlow, WA USA jwb at olympus.net From schorsch at schorsch.com Tue Apr 6 12:35:14 1999 From: schorsch at schorsch.com (Georg Mischler) Date: Tue, 06 Apr 1999 16:35:14 GMT Subject: Select weirdness on Solaris 2.4 References: <199904011625.LAA28154@python.org> <199904011702.MAA06784@eric.cnri.reston.va.us> Message-ID: <7edd41$5gi$1@nnrp1.dejanews.com> In article <199904011702.MAA06784 at eric.cnri.reston.va.us>, Guido van Rossum wrote: > Georg Mischler wrote: > > > So the question now turns away from asyncore and towards python > > internals. Can anyone spot the crucial difference between the > > following C (compiled with -lsocket -lnsl) and what python does > > with the 6 lines from above? > > Here's another suggestion. Aren't there two socket implementations in > Solaris? One SysV compatible and one BSD compatible? Does Python > link with the same set of libraries as your little C program? Thanks for all the suggestions from everybody. I finally gave up when I found the following in asyncore.py: if os.name == 'mac': # The macintosh will select a listening socket for # write if you let it. What might this mean? def writable (self): return not self.accepting else: def writable (self): return 1 This showed me that the problem is not unique to my system, and also pointed me to the solution. My derived class now overwrites: def writable(self): return not self.accepting Since I know that the dispatcher will never write anything to any socket (why should it?), this is save and will end my headaches. I still don't understand the behaviour of select in this case, but I leave that to the socket experts to ponder... as-long-as-it-works-don't-ask-why-ly yrs -schorsch -- Georg Mischler -- simulation developper -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From tseaver at palladion.com Wed Apr 7 09:32:51 1999 From: tseaver at palladion.com (Tres Seaver) Date: Wed, 07 Apr 1999 08:32:51 -0500 Subject: GadFly - MemoryError References: Message-ID: <370B5E83.C796BFF3@palladion.com> Oleg Broytmann wrote: > > Hello! > > I tried to add yeat another database backend to my project "Bookmarks > database". My database contains now about 3000 URLs, not too much, I think. > I subclass by BookmarksParser to parse bookmarks.html into gadfly database > and got a database of 500 Kbytes - very small database, I hope. > Then I tried to find duplicates (there are duplicates). I ran the query: > > SELECT b1.rec_no, b2.rec_no, b1.URL > FROM bookmarks b1, bookmarks b2 > WHERE b1.URL = b2.URL > AND b1.rec_no < b2.rec_no How many duplicates are there? Something like SELECT URL FROM bookmarks GROUP BY URL HAVING COUNT(*) > 1 will produce the URL's with duplicates; you could then do SELECT rec_no, URL FROM bookmarks WHERE URL IN (SELECT URL FROM bookmarks GROUP BY URL HAVING COUNT(*) > 1) or create a temp table first with the results of the subquery, then join it in a separate query. -- ========================================================= Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From m.mariani at imola.nettuno.it Thu Apr 29 20:01:41 1999 From: m.mariani at imola.nettuno.it (Marco Mariani) Date: Fri, 30 Apr 1999 00:01:41 GMT Subject: while (a=b()) ... Message-ID: <19990430000141.A5867@shalott> Hi all language lawyers! Which one is more ugly? ===== c = curs.fetchone() while c: print c c = curs.fetchone() ===== while 1: c = curs.fetchone() if c: print c else: break ===== Is there an elegant way? while curs.fetchone() print $_ :-))) -- "If you're going to kill someone there isn't much reason to get all worked up about it and angry. Any discussions beforehand are a waste of time. We need to smile at Novell while we pull the trigger." - Jim Allchin, Microsoft corp. - From ag_news at datamorgana.com Thu Apr 15 19:26:21 1999 From: ag_news at datamorgana.com (Anbjorn Grindheim) Date: 16 Apr 1999 01:26:21 +0200 Subject: what do you do with Python References: <3714C9EA.86C0A4E@earthlink.net> Message-ID: * susan e paolini | I never see jobs with Python advertised so what is it that Python does? It makes life happier! Besides turning repetive tasks to fully automatic procedures when I administer web content at my need- the-money-very-badly-since-i-am-a-student-job, it also has given several special purpose applications to other employees wanting to lay out content as well - applications written in no-time compared to other programming languages. When I sooner or later leave the job, I bet the job advertisment will say "Python" all over it :-) -- Anbjorn Grindheim From morse at harborcom.net Thu Apr 29 07:58:57 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Thu, 29 Apr 1999 11:58:57 GMT Subject: Tags for Python Message-ID: <37284922.3377336@news.oh.verio.com> Someone emailed me a question about tags for Python. Unfortunately, the message was accidently deleted before I could reply. So, for whoever you are, here's a copy of a previous post: > does it exist something like etags or ctags for python that allows to > "tag-complete" python code in Emacs? look in your python distribution at Tools/scripts/ptags.py -- Garry Hodgson comes a time garry at sage.att.com when the blind man Software Innovation Services takes your hand, says, AT&T Labs "don't you see?" From liw at iki.fi Tue Apr 13 15:59:35 1999 From: liw at iki.fi (Lars Wirzenius) Date: 13 Apr 1999 19:59:35 GMT Subject: rfc822 date header References: <37136310.62A6BE1A@rubic.com> Message-ID: <7f07n7$7pqv$1@midnight.cs.hut.fi> jeffbauer at bigfoot.com: > def strdate(self, timeval=None): > from time import gmtime, strftime, time > if timeval is None: > timeval = time() > return "Date: %s" % strftime('%a, %d %b %Y %H:%M:%S GMT', > gmtime(timeval)) Here's what I wrote for Slime (thhe mailer I'm writing): def _date_header(self): """Return Date header reflecting current time.""" # XXX this should probably communicate the local time zone # somehow t = time.gmtime(time.time()) return "Date: %s, %02d %s %04d %02d:%02d:%02d GMT\n" % \ (rfc822._daynames[t[6]], t[2], rfc822._monthnames[t[1]], t[0], t[3], t[4], t[5]) Note that it isn't locale dependent. (I apologize for the bad indentation of a whole tab, I haven't got around to implementing proper indentation support in my editor.) From chadm at sgi.com Thu Apr 22 13:24:48 1999 From: chadm at sgi.com (Chad McDaniel) Date: 22 Apr 1999 10:24:48 -0700 Subject: New python user seeks comments References: <371DA955.9F13B144@pop.vet.uu.nl> <371E2DEE.C2BD5A58@pop.vet.uu.nl> Message-ID: Martijn Faassen writes: > Chad McDaniel wrote: > > ['in' is a reserved word so can't be used as a variable name] > > > It seems that Python could have mentioned that to the user. > > True, though it does say this: > > File "", line 2 > in = open("test.txt", "r") > ^ > SyntaxError: invalid syntax > > Could be better, but easily could've been far worse.. I used Perl (and still do) before Python and I think that the Perl interpreter gives exceptionally informative error messages. Of course, with Perl's syntax, that may be a necessity ;-> -- -chad From aa8vb at vislab.epa.gov Wed Apr 14 11:01:16 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Wed, 14 Apr 1999 15:01:16 GMT Subject: 1.5.2 broke IRIX module loading Message-ID: <19990414110116.A1374923@vislab.epa.gov> I built and tried 1.5.2 this morning, and it failed to load a module that worked fine on 1.5.1. See below for the errors. This is a C library I don't have source for which has references to a number of zeroed-out internal symbols which aren't used. In this case (see errors), "currstepc" is the exported C interface wrapper, and "currstep" is the internal FORTRAN routine which has been zeroed-out. To convince Python to load this again, I found I had to reverse one of the 1.5.1 changes to importdl.c (patch attached). I believe this news post describes the problem I'm running into: http://www.dejanews.com/[ST_rn=ps]/getdoc.xp?AN=289722207 Could we consider reversing this change to importdl.c in the Python dist? Randall ------------------------------------------------------------------------------- > python Python 1.5.2 (#1, Apr 14 1999, 08:42:47) [C] on irix646-o32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Util Traceback (innermost last): File "", line 1, in ? File "Util.py", line 2, in ? import Utilc ImportError: 1380391:python-o32: rld: Fatal Error: unresolvable symbol in /home/rhh/work/libUtil.so: currstep ------------------------------------------------------------------------------- > nm -Bo libUtil.so | grep currstep libModels3.so: 5ffccda0 B currstep libModels3.so: 5fe1e6c0 T currstep_ libModels3.so: 5fe1e880 T currstepc ------------------------------------------------------------------------------- -------------- next part -------------- --- Python/ORIG/importdl.c Wed Jan 27 12:53:10 1999 +++ Python/importdl.c Wed Apr 14 10:41:40 1999 @@ -441,7 +441,7 @@ #ifdef RTLD_NOW /* RTLD_NOW: resolve externals now (i.e. core dump now if some are missing) */ - void *handle = dlopen(pathname, RTLD_NOW); + void *handle = dlopen(pathname, RTLD_NOW | RTLD_GLOBAL); #else void *handle; if (Py_VerboseFlag) From faassen at pop.vet.uu.nl Thu Apr 29 06:18:26 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Thu, 29 Apr 1999 12:18:26 +0200 Subject: Maximize Benefit when Purchasing Learning Python References: <9FJV2.153$pX2.88806@news.shore.net> <37277454.19DE2FDB@callware.com> Message-ID: <372831F2.E9200A15@pop.vet.uu.nl> Ivan Van Laningham wrote: > > Hi All-- > > "Michael P. Reilly" wrote: > > > > David Ascher wrote: > > : On Wed, 28 Apr 1999 jkraai at murl.com wrote: > > > > :> How can I help whom when purchasing Python books? > > > > : I'll dare to speak for Mark, and say that you should feel free to send > > : either Mark or I (or both) checks for any amount whatsoever. Skip the > > : middleman. Save trees -- don't buy the book, just send us cash. Don't > > : hesitate for a minute. > > > > Better yet. Secure web credit-card transfers? Saves the paper from the > > envelopes and checks/bills. ;) > > > > -Arcege > > People wonder what attracts me to Python. I claim it's the genteel > comportment, sophisticated manner, and air of refined ennui projected by > the participants in the online discussion. > > -ly y'rs, > Ivan I hereby wish to say you people are welcome to send me checks and money and stuff too. I don't care so much about trees as you all do apparently, so free books are welcome as well. :) But, you might say, Martijn, you haven't done a thing that makes me want to send you money and gifts! Well, this is no problem -- you can send them to me anyway. I-love-this-newsgroup-ly yours, Martijn From scott at chronis.pobox.com Wed Apr 14 20:59:12 1999 From: scott at chronis.pobox.com (scott cotton) Date: 15 Apr 1999 00:59:12 GMT Subject: reval builtin References: <19990331160323.21601.00000471@ng-fi1.aol.com> <7du3ab$3ag@chronicle.concentric.net> <371219E9.9EA91839@home.com> <7f36m6$koq@ds2.acs.ucalgary.ca> Message-ID: here's another config file utility. i know that some pythoners won't like this, but it uses shell-like '$variable' expansion. i personally like this interpolation syntax in config files (but not in programming languages). enjoy, scott """ Utilities for reading config files. functions: readcf(path) - return a dict containing the vars and vals readtxt(txt) - same as above but for text instead of file dict2cf(dict, templ=None) - see function doc string """ import string class SyntaxErrorCF(StandardError): def __init__(self, *args): self.args = args # # "eval" for config files # given the rhs of an assignment as plain text, # figure out what it's python native value is. # def figger(rhs): rhs = string.strip(rhs) if rhs == "None": return None elif rhs == 'yes' or rhs == 'on': # boolean return 1 elif rhs == 'no' or rhs == 'off': # more booleans return 0 elif len(rhs) >= 6 and rhs[:3] in ('"""', "'''") \ and rhs[:3] == rhs[-3:]:# TQS return rhs[3:-3] elif rhs[0] in ("'", '"') and rhs[0] == rhs[-1]: # plain string return rhs[1:-1] elif rhs[0] == '[' and rhs[-1] == ']': # list (of strings only) list = [] inner = rhs[1:-1] for s in string.split(inner, ","): # items in the list s = string.strip(s) if not s: continue if s == '""' or s == "''": # empty string list.append("") elif len(s) >= 6 \ and s[:3] in ('"""', "'''") \ and s[-3:] == s[:3]: # triple quoted string list.append(s[3:-3]) elif s[0] in ("'", '"') and s[0] == s[-1]: # regular string list.append(s[1:-1]) # since lists can only be lists of strings, we allow bare words else: list.append(s) return list else: # the only remaining value is an int. try: return string.atoi(rhs) except ValueError: # oh well, the var get's None. return rhs # # return a dict containing non variable substituted key-values # from the text of a config file. # def getassignments(text): linect = 0 assgns = {} var = None check_tqs = 0 # is it a triple quoted string? text = string.replace(text, "\\\n", "") for line in string.split(text, "\n"): stripped = string.strip(line) linect = linect + 1 if check_tqs: # check for the end of a triple quoted string rhs = rhs + "\n" + line if len(stripped) >= 3 and stripped[-3:] == check_tqs: # the variable check_tqs contains either ''' or """ as # a string literal. assgns[var] = figger(rhs) var, rhs = None, None check_tqs = 0 elif not stripped or stripped[0] == '#': # we try to wrap everything we know up from a previous assignment if var is not None and rhs is not None: if not string.strip(rhs): raise SyntaxErrorCF(linect -1, "%s = " % (var)) assgns[var] = figger(rhs) # reinitialize the variables. rhs = None var = None continue elif line[0] not in " \t": if var is not None and rhs is not None: if not string.strip(rhs): raise SyntaxErrorCF(linect -1, "%s = " % (var)) assgns[var] = figger(rhs) var, rhs = None, None if string.find(line, "=") == -1: # not an assignment raise SyntaxErrorCF(linect, line) lhs, rhs = string.split(line, "=", 1) var = string.strip(lhs) if len(string.strip(rhs)) >= 3 \ and string.strip(rhs)[:3] in ('"""', "'''"): check_tqs = string.strip(rhs)[:3] var = string.strip(lhs) else: if var is None: raise SyntaxErrorCF(linect, line) rhs = rhs + " " + line # here we just wrap up what we found out iterating over the # lines in the text one last time. if var is not None and rhs is not None: if not string.strip(rhs): raise SyntaxErrorCF(linect -1, "%s = " % (var)) assgns[var] = figger(rhs) return assgns # # globally replace variables with values (eg $prefix) # def global_replace(text, dict): for k, v in dict.items(): text = string.replace(text, '$' + k, v) return text # # replace variables defined earlier in a config file # def internal_replace(dict, replacements): for var, rvars in replacements.items(): for rvar in rvars: cval = dict[var] if type(cval) is type([]): l = [] for s in cval: l.append(string.replace(s, '$' + rvar, dict[rvar])) dict[var] = l elif type(cval) is type(""): dict[var] = string.replace(cval, '$' + rvar, dict[rvar]) return dict # # top level function # def readcf(file, global_repl=None, int_repl=None): """ given a path to a file, and any replacements that need to be made, return a dictionary containing the variables in the config file as keys and the values as values. """ text = open(file).read() text = string.replace(text, "\\\n", "") # get rid of \ cont'd lines if global_repl is not None: text = global_replace(text, global_repl) d = getassignments(text) if int_repl is not None: d = internal_replace(d, int_repl) return d def readtxt(txt, global_repl=None, int_repl=None): """ reads the text of a cf file into a dict and return the dict. """ txt = string.replace(txt, "\\\n", "") if global_repl is not None: txt = global_replace(txt, global_repl) d = getassignments(text) if int_repl is not None: d = internal_replace(d, int_repl) return d def dict2cf(dict, templ=None): """ given a dictionary keyed by the configuration variables and whose values are a 3-tuple of (var-value, descr, vtype) where vtype is one of 'str', 'int', 'bool' or 'list', return text suitable for writing a config file. If optional second arg 'templ' is passed, then transpose the values to the template, which should be a string with 1 %()s entry per variable """ txtdict = {} for k, (val, vtype, descr) in dict.items(): valstr = "" descr = string.rstrip(descr) entry = descr + "\n#\n" + k + " = " if vtype == "str": if string.find(val, "\n") != -1: valstr = '"""\\\n' + val + '"""' elif string.find(val, '"') != -1: valstr = "'" + val + "'" else: valstr = '"' + val + '"' elif vtype == "bool": if val: valstr = "yes" else: valstr = "no" elif vtype == "int": valstr = "%d" % (val) elif vtype == "list": if not val: valstr = "[]" else: spaces = " " * (len(k) + 4) valstr = "[" for item in val: if string.find(item, "\n") != -1: valstr = "%s%s%s%s,\n%s" % (valstr, '"""\\\n', item, '"""', spaces) elif string.find(item, '"') != -1: valstr = "%s%s%s%s,\n%s" % (valstr, "'", item, "'", spaces) else: valstr = "%s%s%s%s,\n%s" % (valstr, '"', item, '"', spaces) valstr = valstr[:-2 - len(spaces)] + "]" else: print "weird:", k, val, descr, vtype valstr = valstr + "\n\n" txtdict[k] = entry + valstr if templ: return templ % txtdict else: vars = txtdict.keys() vars.sort() res = "" for v in vars: res = res + txtdict[v] return res On 14 Apr 1999 23:00:22 GMT, wrote: >On Mon, 12 Apr 1999 15:59:05 GMT, Jim Meier wrote: >>This introduces some major security problems, and is a little difficult >>to edit, but there is very little parsing needed to make it usable. Does >>anyone know of a way to limit the damage a user can do to such a file? > >It would be nice to have an "reval" builtin that would only evaluate >literals. That would make building things like config files safe and >easy. I have two ideas on how to accomplish this: > > 1. Create a new start symbol "reval_input" in the Grammar/Grammar > and add a "builtin_reval" function in Python/bltinmodule.c. Sound > easy? Well, the connection between these two changes is long and > twisted. > > 2. Use something like lex and yacc to create an extension module > that does the Right Thing(TM). I think the problem with this > approach is making it conform to the real Python grammar. If I > get time I will try it. > >Perhaps some guru can explain an easy way to accomplish this and same me >some time. > > > Neil From paranoid at mnet.com.null Sat Apr 10 16:46:47 1999 From: paranoid at mnet.com.null (Paranoid User) Date: Sat, 10 Apr 1999 13:46:47 -0700 Subject: Python 2.0 compatibility Message-ID: Hello, We have selected Python as the scripting language for the next generation of one of our embedded systems. This is a very fast-track project scheduled to ship near the end of the first quarter of 2000. I ran across a quote that said something to the effect that Python 2 will be incompatible with Python 1. Before I make a decision as to whether we freeze with Python 1.5.2, or migrate to Python 2 when it is released, I need to find out the extent of truthfulness in the "quote". So, if anyone in-the-know about Python 2 could let me know the proposed extent of its compatibility with 1.5.2 I would really appreciate it. Sorry for the obscured reply address. I get spam from addresses I haven't used for 10 years. 8-( -------- Daryl V. McDaniel darylm @ viper.mnet.com Micronetics (503) 621-0234 Aloha Research Group Portland, Oregon USA "Aloha Research Group", "Mnet", and "mnet" are trademarks of Micronetics From calishar at *remove*this*.home.com Tue Apr 13 19:59:49 1999 From: calishar at *remove*this*.home.com (Calishar) Date: Tue, 13 Apr 1999 23:59:49 GMT Subject: Freezing an App Message-ID: Hi Folks, Sorry to ask what must be a fairly frequently asked question by now, but I am having problems freezing an app. It uses Tkinter and win32all (the win32api and win32con modules spcifically). I did a freeze on it this morning, and took it into my client site, and after about 3 hours of bashing away at the situation, I managed to get part of the app to work properly. The part I am having problems with is using win32api. It runs, doesnt set the registry values it is suppoed to, and exits without giving any errors. Could some kind soul please email me (or reply to group is fine) step-by-step instructions for freezing a win32api program. Ideally also telling me how I can freeze the tkinter part wqithout needing the init.tcl, tk.tcl, and component .tcl files (like button.tcl). I am not a c/c++ programmer, so working in VC++ 5.0 is VERY strange to me, although I can probably follow instructions. I'm not a total dummy, but when it comes to having to build python + tkinter + win32all for windows I feel like it. I had less problems building things for linux after using it for 3 hours. THanks in advance for whatever help you can give me, Calishar P.s. My E-mail address is munged to mess up spam machines, the fix should be obvious. From Michael.Scharf at gmx.de Thu Apr 15 15:08:14 1999 From: Michael.Scharf at gmx.de (Michael Scharf) Date: Thu, 15 Apr 1999 21:08:14 +0200 Subject: Is there a 'make' replacement written in python ? References: Message-ID: <3716391E.954DDCDD@gmx.de> Markus Kohler wrote: > > I'm looking for a replacement for the 'make' command > similiar to Cons : > Therefore something like Cons written in python would be really cool. Some years ago, Samuel L. Bayer posted a pymake. Unfortunately, dejanews does not keep the uuencoded file, but maybe someone has it... http://www.dejanews.com/getdoc.xp?AN=296444432 Michael -- ''''\ Michael Scharf ` c-@@ TakeFive Software ` > http://www.TakeFive.com \_ V mailto:Michael_Scharf at TakeFive.co.at From robin at jessikat.demon.co.uk Tue Apr 13 21:00:26 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Wed, 14 Apr 1999 02:00:26 +0100 Subject: site.py & COM startup References: <7f0kin$ben$1@m2.c2.telstra-mm.net.au> Message-ID: In article <7f0kin$ben$1 at m2.c2.telstra-mm.net.au>, Mark Hammond writes >Robin Becker wrote in message ... >>using Mark Hammond's win32com for a server I find that the installation >path is not >>automatically in sys.path so my base .pth files are missed and I get >troubles. >> >>I hacked site.py to fix this using the fact that sys.prefix == '' when >running a com >>server (I guess inproc). > >It is indeed when run as an inproc. The problem is that Python uses the >current executable to try and deduce the Python home. When Python is being >used as a COM server, the host executable could be _anything_, and therefore >cant be used to locate the Python home. > >So, I would like to fix this once and for all in the COM stuff, but I cant >work out a reasonable strategy for locating the Python home. > >Also, FYI: As of build 124 and later of my extensions, when you register a >COM object its path is now also automatically saved away, and automatically >used as the object is created - thus, no more errors due to your COM object >not being on the PythonPath... > >Mark. > > so the com module itself will be known, but things it might be using aren't guaranteed if they're in the standard locations. Site.py is supposed to be in $PYTHONHOME/Lib. -- Robin Becker From arcege at shore.net Wed Apr 21 08:17:24 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 21 Apr 1999 12:17:24 GMT Subject: New python user seeks comments References: <371db9cb.5622314@news.omnilink.de> Message-ID: Stefan Franke wrote: : On 21 Apr 1999 00:33:10 -0400, David Steuber wrote: :>Er, uh, hmm. :> :>I wrote my first Python program today. It took longer than I :>expected. Who would have guessed that you couldn't give a file object :>the name 'in'? Or at least that was one of the weirder obstacles. : Maybe a reserved keyword-aware editor could have saved you : from this? You could try IDLE, which comes with the lastest Python : distribution or PythonWin, if you are using Windows. : There's a very clever Python Emacs mode as well... And syntax highlighting for Python in vim (Vi IMproved). -Arcege From wtanksle at dolphin.openprojects.net Wed Apr 28 13:54:02 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 28 Apr 1999 17:54:02 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: On 28 Apr 1999 09:57:18 +0200, Markus Kohler wrote: >>>>>> "Brian" == Brian Lloyd writes: >[deltia] > Brian> Arne, >Python would be appropriate for much more problems if it would only be as fast >as other scripting languages. The bytecode interpreter IS significantly slower >than other byte code interpreted languages. Since we all know that python >is more productive than most other languages, this becomes sooner or later an >issue because one would not be able some tasks in python because it is just >to slow. Your data is correct (Python is slow for many things, slower than it needs to be), but your conclusion is wrong. Python isn't slow because its bytecode engine is slow; actually, although there's a lot of room for improvement, its bytecode engine is faster than many of the others out there. The reason it's slow is its runtime model. _Every_ function call requires a lookup in a hash table, just on the off-chance that the programmer changed the meaning of the function. >It seems to me that without a redesign of at least the bytecode for >function calls python's speed will not take off. Bytecode won't help enough -- the whole calling model needs to be examined. Fortunately, that's one of the things the 2.0 design process will be looking at. Like you, I hope that they consider Smalltalk as an example. And Oberon (SlimBinaries), and Eiffel (typing and general compile-time error catching), and ... >Markus -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From akuchlin at cnri.reston.va.us Thu Apr 29 12:12:05 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Thu, 29 Apr 1999 12:12:05 -0400 (EDT) Subject: Python and CGI In-Reply-To: <37286538.5EAE0173@lemburg.com> References: <37286538.5EAE0173@lemburg.com> Message-ID: <14120.33118.681723.27557@amarok.cnri.reston.va.us> M.-A. Lemburg writes: >Although there were a number of hits on the web-page, I'm not >sure whether the announcement got the message through... this >is intended to be a campaign with the goal of promoting Python >as CGI engine. I think a critical thing that's missing for CGI newbies is a collection of example Python scripts, and a CGI HOWTO. Look at www.cgi-resources.com for some ideas; it would be quite helpful to newbies if there were example Python scripts that acted as hit counters, guestbooks, mailers, etc. -- A.M. Kuchling http://starship.python.net/crew/amk/ Information is not knowledge. Knowledge is not wisdom. Wisdom is not truth. Truth is not beauty. Beauty is not love. Love is not music. Music is the *best!* -- Frank Zappa, _Joe's Garage_ From tim_one at email.msn.com Mon Apr 5 21:06:45 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 6 Apr 1999 01:06:45 GMT Subject: Possible regex match bug (re module) In-Reply-To: <19990405084819.B802985@vislab.epa.gov> References: <19990405084819.B802985@vislab.epa.gov> Message-ID: <000001be7fc9$bdb0fec0$65a22299@tim> [Randall Hopper] > Re doesn't handle named groups in alternative patterns like it > seems it should. Given an alternative pattern with a particular group > name in each, it only assigns the match if the group name matches the > last alterative. re should raise an exception here -- it never intended to allow your pattern. The deal is that symbolic group names are no more than that: names for numbered groups. Like so: >>> import re >>> p = re.compile('(---(?P[^-]*)---)|(===(?P[^=]*)===)') >>> p.groupindex {'id': 4} >>> The groupindex member maps a symbolic name to the numeric group for which it's an alias, and so in this pattern referring to group "id" is identical to referring to group number 4. That explains everything you've seen. re should instead notice that it already had a definition for name "id", and complain about the redefinition. Same as in Perl, you're going to have to write a hairier regexp with only one interesting group, or give the interesting groups different names and sort them out after the match (in an alternation involving named groups, at most one will be non-None after a match). Here's a discouraging example of the former approach: >>> p = re.compile(r"([-=])\1\1(?P((?!\1).)*)\1\1\1").match >>> p("---abc---").group("id") 'abc' >>> p("===def===").group("id") 'def' >>> print p("===ghi---") None >>> p("------").group("id") '' >>> p("---=---").group("id") '=' >>> print p("===a=b===") None >>> if-regexps-are-your-friends-you'd-hate-to-meet-your-enemies-ly y'rs - tim From aa8vb at vislab.epa.gov Tue Apr 6 10:34:12 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 6 Apr 1999 14:34:12 GMT Subject: SWIG, Modulator, BGEN, etc. - which? (Re: swig or not to swig ?) In-Reply-To: <3709f149.2262513@news.oh.verio.com>; from Kevin Dahlhausen on Tue, Apr 06, 1999 at 11:39:03AM +0000 References: <4p6O2.1348$8m5.2126@newsr1.twcny.rr.com> <3709f149.2262513@news.oh.verio.com> Message-ID: <19990406103412.A869943@vislab.epa.gov> "Darrell" : |Didn't have much luck with bgen. |modulator seems handy, Is there a reason to prefer swig ? I'm also interested in what wrapping options folks like best. Roll-your-own, SWIG, Modulator, BGEN? (Do others not listed exist for UNIX?) I'm primarily thinking in terms of both ease of definition and maintenance. With maintenance, I have in mine: 1) automatically updating the wrapper "guts" most of the time, and 2) ideally providing some facility to "flag" wrapper functions whose signatures have changed. The latter point is intended to be a work queue for a human operator to act on. That is, for them to update the all the scripting code which uses functions/symbols whose signatures have changed (a substitute for compiling and linking, since our script isn't compiled and linked with the wrapped code). Any pointers or insights appreciated, Randall From jam at newimage.com Mon Apr 26 16:30:14 1999 From: jam at newimage.com (jam) Date: Mon, 26 Apr 1999 16:30:14 -0400 Subject: help In-Reply-To: ; from Stone Cold on Mon, Apr 26, 1999 at 07:18:13PM +0000 References: Message-ID: <19990426163014.B20207@toast.internal> On Mon, Apr 26, 1999 at 07:18:13PM +0000, Stone Cold wrote: > > I just got python and I need some help getting started. I have no > programing knowlodge yet but I want to know all the languges. can someone > help? > greetings and welcome to python! I would suggest having a look at for pointers on where to start.. also check out the online versions of the documentation (so you can read it before printing it out on paper) located at . python will run on linux, other unix-like platforms, and win32. it has a reasonable liscense, source code is available, it is easily extensible in C or C++, and is a top notch 'glue' language. the semantics of the language are *very* clean and elegant, making it a snap to learn. it has been described as 'executable pseudo code', and it lives up to that reputation. I don't want to sound like a bad commercial, but python is really and truly very very cool and a lot of fun to work with. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From jody at ldgo.columbia.edu Thu Apr 8 10:19:36 1999 From: jody at ldgo.columbia.edu (Jody Winston) Date: 08 Apr 1999 10:19:36 -0400 Subject: Chaning instance methods References: <370C2904.A6F4BD54@inrialpes.fr> <000801be8188$b59aa9a0$749e2299@tim> <370CC27E.ED2D0D59@inrialpes.fr> Message-ID: What I was trying to do was to dynamically change the runtime behavior of an object instance by loading the new methods from a permanent store. Since this wasn't easy to do, I now just save off all of the attributes, kill the old object, create a new object, and restore the attributes. This works, but it doesn't seem to be as elegant as having the ability to replace methods. -- Jody Winston Manager SeisRes Lamont-Doherty Earth Observatory RT 9W, Palisades, NY 10964 jody at ldeo.columbia.edu, 914 365 8526, Fax 914 359 1631 Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. From pduffin at mailserver.hursley.ibm.com Wed Apr 28 06:07:21 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Wed, 28 Apr 1999 11:07:21 +0100 Subject: WARNING: AIX and dynamic loading. References: <7g4i77$qif$1@nnrp1.dejanews.com> Message-ID: <3726DDD9.19A1@mailserver.hursley.ibm.com> Jakob Schiotz wrote: > > Hi everybody, > > I would like to warn developers using AIX against this trap waiting > for us to fall into. (I am cross-posting this to the SWIG mailing list > although it is not strictly a SWIG problems, as SWIG users will be > doing just the kind of stuff that gets you into trouble). > > SCENARIO: > You are developing a dynamically loaded C module for Python (or > possibly for other languages). You place the module in a directory on > the PYTHONPATH. That directory is NFS mounted. Or you are loading > the module directly from the directory where you compiled it, and that > directory is NFS mounted. > > SYMPTOMS: > You are improving the code, but it does not seem to have any effect at > all. Eventually you realise that Python is loading the buggy version > of your module that you tried out this morning, although _all_ copies > on disk are the new improved version you just wrote ! > > PROBLEM: > If you copy the module to the PYTHONPATH directory using cp, the old > file gets overwritten, but keeps the same inode number. Apparently, > the AIX dynamical loader is caching the module somewhere, and does not > discover that the file has been modified. (If the directory is not NFS > mounted cp will fail with an error message saying that you cannot > overwrite a running program - although the program has stopped.) > > It is _possible_ that this only occurs if the module you wrote causes > python to dump core. It certainly makes it frustrating to fix the > bug as you continue to get the version that dumps core loaded into > python, even after you fixed the bug. > I found this problem when developing extensions for Tcl, my solution was to run slibclean (as root) which removes all unused modules from the system. > SOLUTION: > You makefile should remove the old module (the .so file) before copying the > new version into the installation directory. Then the file gets a new > inode number and the loader discovers that it has been changed. If > you ever load the module directly from the development directory you > should also remove the .so file before compiling/linking, as you will > otherwise get hit by the same bug. > That is very useful, as I had a solution I did not bother to find out what was happening. > I just wanted to warn you all about this bug in AIX. I wasted too much time > on this last Friday :-( > AIX should definitely look at the modification date as well as the inode. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From radbit at my-dejanews.com Tue Apr 27 21:10:16 1999 From: radbit at my-dejanews.com (radbit at my-dejanews.com) Date: Wed, 28 Apr 1999 01:10:16 GMT Subject: RE's in Python syntax References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <37215EFB.433AFCA6@prescod.net> <3724B2D6.B468687A@prescod.net> <37252816.42634501@Lugoj.Com> <3725F91D.4F9D6373@prescod.net> Message-ID: <7g5n5m$tg7$1@nnrp1.dejanews.com> In article <3725F91D.4F9D6373 at prescod.net>, Paul Prescod wrote: > Roy Smith wrote: > > > > The thread was moving in the direction of "my program using regex is too > > slow, and I think the solution would be to move regex into the python core > > to make it faster". I was just pointing out why that is flawed reasoning. > > But it isn't flawed reasoning. There are many arguments for moving > something into the core and many arguments for keeping something OUT of > the core, and "performance in the hands of a newbie" strikes me as a valid > argument for inclusion. Simplicity of expression is another. > hear, hear - my thinking exactly - Python is a great language to code in and like in all languages algorithms matter when you're looking for speed and efficiency. On the other hand if Python can offer better support (in terms of speed and efficiency) both newbies and experienced programmers will benefit Cheers -- Florent Heyworth -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From herzog at online.de Sun Apr 11 08:40:26 1999 From: herzog at online.de (Bernhard Herzog) Date: 11 Apr 1999 14:40:26 +0200 Subject: _tkinter.c, threads and C-modules in 1.5.2 Message-ID: A few weeks ago, there was a bug report on c.l.py regarding an incompatibility between Sketch and Python 1.5.2b2 on Linux/glibc2. It seems to me that the cause for the problems is the new Tcl-lock in 1.5.2. The tcl-lock was introduced for better thread support in Tkinter. Whenever _tkinter calls the tcl interpreter, it releases the python-lock and acquires the tcl-lock. Sketch defines some tcl-callbacks in C, which in turn may call the python interpreter, but without releasing the tcl-lock and acquiring the python-lock. I think that this is the cause, because compiling just the _tkinter module without thread support cures the problem, or so I'm told, I can't test this myself at the moment as I'm still on libc5. The question now is, how do I make Sketch work correctly with a threadable _tkinter? AFAICT, Sketch would have to have access to some static variables in _tkinter.c. The best solution IMO would be to give third-party C-modules access to the functionality of the macros ENTER_TCL, LEAVE_TCL, etc, via some C-functions to access those variables and a _tkinter headerfile installed with the other Python headerfiles. As it's probably too late to get something like this into Python 1.5.2 final :(, the easiest solution for Sketch is to provide its own non-threaded _tkinter module that is used instead of Python's if Sketch runs with Python 1.5.2. It's kind of funny that 1.5.2 make it both easier, with the new interpaddr() method, and harder, with the tcl-lock, to extend tkinter with C-modules. Bernhard -- Bernhard Herzog | Sketch, a python based drawing program herzog at online.de | http://www.online.de/home/sketch/ From gornauth at dds.nl Tue Apr 13 07:38:36 1999 From: gornauth at dds.nl (Gornauth) Date: Tue, 13 Apr 1999 13:38:36 +0200 Subject: ZopeHTTP speed problem. References: <7etton$j4q$1@nnrp1.dejanews.com> Message-ID: <7evagc$dkj$1@news2.xs4all.nl> befletch at my-dejanews.com wrote in message <7etton$j4q$1 at nnrp1.dejanews.com>... >I downloaded Zope to kick the tires a bit. It looks very interesting, >but I am having a small problem with the ZopeHTTP server being really >slow. It is taking about 5 seconds per HTTP request. Does anyone have >an idea of what might be wrong here? Did you try running the server with threads enabled? If not, try this: "start.bat -t" I did wonders for me :) g/. From wware-nospam at world.std.com Sat Apr 24 00:11:47 1999 From: wware-nospam at world.std.com (Will Ware) Date: Sat, 24 Apr 1999 04:11:47 GMT Subject: I NEED MAJOR HELP References: Message-ID: sportsnutz (sportsnutz at email.msn.com) wrote: : Ive never programmed before and i need some tips on some command to work : this thing Gently ease up on the clutch while you slowly press down on the gas. If you hear a grindy noise, the clutch is unhappy, push it back down and try again. -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Will Ware email: wware[at]world[dot]std[dot]com PGP fp (new key 07/15/97) 67683AE2 173FE781 A0D99636 0EAE6117 From akuchlin at cnri.reston.va.us Thu Apr 29 12:39:12 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Thu, 29 Apr 1999 12:39:12 -0400 (EDT) Subject: GUI and creating GIF In-Reply-To: <7g7u2k$fr0$1@wanadoo.fr> References: <7g7u2k$fr0$1@wanadoo.fr> Message-ID: <14120.35313.19477.657175@amarok.cnri.reston.va.us> Frank.Derville writes: >I would like to >1) create a GIF file under Python by drawing lines, text, ... I have looked >at Tk which can create bitmaps and photoimage but their seem to be no >possibility to transform a canvas into a photoimage. >2) rotate some text on a canvas. The Python Imaging Library seems to be what you need; look at http://www.pythonware.com/products/pil/ . PIL lets you create Image objects which are bitmaps that you can draw on and manipulate in various ways, and save Images in one of a large number of different formats, GIF and JPEG being the most common ones. There's also some connectivity with Tkinter, so you can display Images on a canvas. I'm not sure if PIL's font code can handle rotation, though. -- A.M. Kuchling http://starship.python.net/crew/amk/ Fast, fat computers breed slow, lazy programmers. -- Robert Hummel From loredo at spacenet.tn.cornell.edu Mon Apr 5 15:40:15 1999 From: loredo at spacenet.tn.cornell.edu (Tom Loredo) Date: Mon, 05 Apr 1999 15:40:15 -0400 Subject: Python books References: <7dtsa4$b6p$1@nnrp1.dejanews.com> <7e0t19$1de$1@nnrp1.dejanews.com> <7e2vol$8c6$1@news1.rmi.net> <37090160.C52377BA@boi.hp.com> Message-ID: <3709119F.59ACCC73@spacenet.tn.cornell.edu> Bill Anderson wrote: > So what other publisher has a Python book out, and what is the name of > it? You could of course find this out at python.org, but FWIW the answer is: *Internet Programming With Python* which includes Mr. Python himself in the author list. Despite its title, it has very good *general* coverage of Python, including extending and embedding it; the chapters on creating HTML documents and writing CGI scripts should be viewed merely as nice examples showing off some of the capability described more generally in the earlier chapters. I think the title is a bit unfortunate. -Tom Loredo From atai-no-spam at glink.net.hk Thu Apr 29 07:42:16 1999 From: atai-no-spam at glink.net.hk (>0 Remove -no-spam to reply) Date: 29 Apr 1999 11:42:16 GMT Subject: Shelve vs. Deepcopy Message-ID: Hi: I have a class who contains reference to other classes. Now I would like to test an instance of this class. The test would alter the instance but I would like to retain this instance, so at first I make a deepcopy of this instance and perform the test on the copy. However, it take quite a long time to finish the test. Then I try to use shelve to do the same thing. I.e. first store the instance on a dbm. Then the copy is obtain from loading the dbm. And to my surprise, the latter method is much faster than the first method. With some profiling, I saw that the number of functions calls of the first method is at least twice that of the second one. The following are two test programs to illustrate this. When the first one is run, using shelve is faster. While in the second one, deepcopy is faster. I hope I have make some sense in the above sentences. Regards, >0 test.py Cut here ----------------------------------------------- import copy, shelve, time class test: def __init__(self, num): self.a = num self.b = (2,3,`num`) self.c = (3,7, `num`) class test1: def __init__(self, obj): self.dict = {(1,3):obj} for i in range(100): self.__dict__[(`i`,1)] = i a = test(7) b = test1(a) dbase = shelve.open('tmp') dbase['store'] = b start = time.time() for i in range(1000): c = dbase['store'] stop = time.time() print stop - start start = time.time() for i in range(1000): c = copy.deepcopy(b) stop = time.time() print stop - start dbase.close() test2.py Cut here------------------------------------------------- import copy, shelve, time class test: def __init__(self): for i in range(100): self.__dict__[`i`] = i a = test() dbase = shelve.open('tmp') dbase['store'] = a start = time.time() for i in range(1000): c = dbase['store'] stop = time.time() print stop - start start = time.time() for i in range(1000): c = copy.deepcopy(a) stop = time.time() print stop - start dbase.close() From wtanksle at dolphin.openprojects.net Thu Apr 29 19:06:15 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 29 Apr 1999 23:06:15 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> Message-ID: On 29 Apr 1999 10:35:50 +0200, Markus Kohler wrote: >>>>>> "William" == William Tanksley writes: > William> On Wed, 28 Apr 1999 20:04:00 GMT, Paul Prescod wrote: > >> William Tanksley wrote: > >>> And Oberon (SlimBinaries), and Eiffel (typing and general > >>> compile-time error catching), and ... > >> Actually, isn't Eiffel's type system famous for being full of > >> holes? > William> I'm familiar with the covariance/contravariance argument, > William> but I've never before heard anyone say anything about > William> Eiffel being full of holes. What problems have you heard > William> of? >As far as I remember Eiffel requires a global system analysis to be type >safe at compile time. According to Meyer, that would be the most permissive thing to do. He also suggested an option, the rule about "no polymorphic CATcalls", which would not require such intensive processing and would allow most of the same things. All in all, though, after having read over Meyer's materials very carefully, I have to say that I don't like his justifications. I just looked at the Sather site (Sather is an Eiffel-inspired language which uses contravariance), and they explain how to solve the problem he was demonstrating (in a MUCH more logical and reuable way!). Since Sather is itself an subclass of Eiffel, I don't think I'm violating any typing rules by claiming that imitating Sather is similar to taking things from Eiffel ;-). Sather itself offers some interesting options for inheritance. For example (let me translate to Python): class Gizmo(Object): inherits the interface of Object, but _none_ of its implementation. If you want the same member functions as Object had, you have to do this: class Gizmo(Object): import Object from Object import new, del, etc This means that classes can behave like modules (because they bring functions into their namespace the same way)... And logically, vice versa. Of course, "inheriting an interface" is only meaningful with static typing. Notice that this also addresses the issue of interfaces -- every class is an interface. The disturbing thing, of course, is that this is totally incompatible with the current way of doing things. That's easy to overcome, though: class Gizmo(Object, ): from Doodad import * > >> Regardless, wouldn't a better source of inspiration on typing > >> be a language with *optional* compile-time error checking? > William> Good question. I don't know the answer, but I can point > William> out the dangers of not planning our path. [the dangers of C++ and other loose languages -- mixed measures considered harmful] > William> The other dangerous side, of course, is being one of the > William> languages which are so safe you can't use them without a > William> huge manual and pages of UML. Python can NOT wind up > William> like this, regardless of the dangers obvious in the other > William> side. >Agreed. The main problem with todays statically typed languages is that >they are too restrictive and to complicated. I'm not sure that they're _too_ restrictive; they work in their domains. The problem is that we don't want to loose Python's greatest strength: it's friendly. > William> Let me expand a little on the dangers of C++. > William> - virtual functions. It shouldn't be my job to tell the > William> compiler when virtual lookups are the only thing to do; > William> the compiler ought to be able to tell. For performance > William> gurus, a way to hint to the compiler that virtual lookups > William> were _not_ needed might be useful -- but what if the > William> programmer was wrong? >True, SmallEiffel inlines most of the virtual function calls automatically. >This is the way to go. Inlines virtual functions? I think you got your wires crossed ;-). Virtual functions, by definition, can't be inlined. Inlining is where you place the routine's source code directly into the code of the calling routine. > William> - GC -- hard to add after the fact. No worry with > William> Python, but what if there are other issues like it? >I'm not sure if I understand this sentence. Do you mean GC is hard to add >to python without breaking existing code ? >I would agree with that. And why do you say "no worry" >Do you mean GC is not worth the effort ? Guido seems to think so. Anyone who disagrees is free to contribute and work on porting GC code (I would like to see it). I think that worrying about the other issues is FAR more rewarding -- RC is not only hard to replace with GC, but the rewards for doing so are relatively small (in comparison to the other things we can think about). I don't want to stop anyone from trying, though. The nice thing about free software is that even if everyone disagrees with you or thinks it's not worth it you can still get it done. So what other issues are worth thinking about? I don't know. > You may have a look at Strongtalk a Smalltalk with static (optional) > type checking. Found it using Google.com (a GOOD search engine for technical matters). http://java.sun.com/people/gbracha/nwst.html I'll be spending some time reading it. My initial impression: _very_ good. This would fit well, I think. > Markus -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From rhays at interaccess.com Thu Apr 8 07:30:31 1999 From: rhays at interaccess.com (Bob Hays, Computer Geek) Date: Thu, 08 Apr 1999 11:30:31 GMT Subject: Q: How to use long names in python for windows Message-ID: <370e9080.37656309@news.interaccess.com> I'm on Win95, I've downloaded python 1.5.1 and pythonwin (123 I think). I've been using pythonwin for development and that works great. Now, I want to create a set of batch files to run processes for me - I'm getting the following error from python: ValueError: Module name too long My import statement to the python interpreter is: import SumHours.MonthOfFiles This worked fine in pythonwin. In addition, I made sure to: set PYTHONPATH=H:\PySources;H:\Python\lib before starting. Is there a problem with long file name support in python 1.5.1 on Windows95? Is there some startup script I need to execute first to enable long file names? I want my code to run properly on UNIX also (which it does right now), and I hate 8.3 naming conventions. Thanks and have fun! - Bob -- I did not ask for the anal probe. -- Passion Fish Discipline is never an end in itself, only a means to an end. - King Crimson Whoever flees history will be pursued by history. - Janusz Korczak -----BEGIN GEEK CODE BLOCK----- Version: 3.1 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------ rhays at interaccess.com (home) http://homepage.interaccess.com/~rhays Bob.Hays at abnamro.com (work) From chadm at sgi.com Wed Apr 21 15:04:30 1999 From: chadm at sgi.com (Chad McDaniel) Date: 21 Apr 1999 12:04:30 -0700 Subject: New python user seeks comments References: <371DA955.9F13B144@pop.vet.uu.nl> Message-ID: Martijn Faassen writes: > David Steuber wrote: > > > > Er, uh, hmm. > > > > I wrote my first Python program today. It took longer than I > > expected. Who would have guessed that you couldn't give a file object > > the name 'in'? Or at least that was one of the weirder obstacles. > > It's not that weird as 'in' is a reserved keyword in Python. :) > > for i in whatever: > print "See?" > It seems that Python could have mentioned that to the user. -- -chad From neilh at fast.fujitsu.com.au Wed Apr 14 22:58:05 1999 From: neilh at fast.fujitsu.com.au (Neil Hodgson) Date: Thu, 15 Apr 1999 12:58:05 +1000 Subject: Can't run Win32 Debugger outside PythonWin References: <371475d6.77664796@news.omnilink.de> Message-ID: <371555BD.70107860@fast.fujitsu.com.au> Stefan Franke wrote: > I just upgraded my NT4 SP3 Workstation to Python 1.5.2 and > win32all build 124. Unluckily I can't start the debugger any > longer from outside PythonWin. > That is, typing > > It seems the Scintilla.DLL can't be found (even the latest update from the > author's hompage). However, sys.path is OK: > > D:\Programme\Python\Pythonwin\pywin\debugger>python > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import debugger > ... > dllid = win32api.LoadLibrary("Scintilla.DLL") > pywintypes.api_error: (126, 'LoadLibrary', 'Das angegebene Modul wurde nicht gef > unden.') > > [The German error msg says "module not found"] Sorry, I don't see this error myself. As a temporary workaround you could try copying Scintilla.DLL into the windows or windows system directory (often called \winnt\system32). I hope Mark has some more insight into this as I don't understand how Python manipulates the path. Neil Hodgson From morse at harborcom.net Tue Apr 27 08:22:45 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Tue, 27 Apr 1999 12:22:45 GMT Subject: GUI other than Tkinter References: <3721567f.1748033@news> <7g1a8h$fae$1@Starbase.NeoSoft.COM> <7g2gul$faf$1@Starbase.NeoSoft.COM> Message-ID: <3725aa15.4550122@news.oh.verio.com> claird at Starbase.NeoSoft.COM (Cameron Laird) wrote: . >>> >> >>I appreciate this useful list. >>Also ... I noticed a refernce to `fltk' on this list, and I downloaded >>and built it. However, I don't notice any Python support as part of >>this distribution, and I'm wondering why `fltk' is on this "Python GUI" >>list. Is there somewhere else where a Python interface to `fltk' >>might exist? >I've sent a copy of your question to a couple >of people likely to know more. We are working on it - and perl support too. While FLTK doesn't play games with the preprocessor, it does use a lot of function overloading. Bjorn Petterson contributed a python idiom to allow overloaded functions. It's about 2/3 of the way completed - at least for an open alpha release. I've got a handfull of the fltk test programs implemented in Python. In a few weeks, we'll be asking for people to help test the wrappers. Mailing list: www.egroups.com/group/pyfltk/ Future home: http://www.netpedia.net/hosting/fltk/ From fredrik at pythonware.com Fri Apr 23 08:37:27 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 23 Apr 1999 12:37:27 GMT Subject: Pointers to variables References: <19990422121403.A279051@vislab.epa.gov> <19990423080721.A344578@vislab.epa.gov> Message-ID: <021801be8d86$0d3ba7a0$f29b12c2@pythonware.com> Randall Hopper wrote: > I think I understand the source of my confusion. This construct: > > for ( var, val ) in [( min, 1 ), ( max, 100 )]: > > isn't pairwise assignment to all the values of the list. If it were, val > would be an alias for the variable min, then an alias for max, etc. but that's exactly what it is. read on! > This actually builds a completely new list: > > [( valueof(min), 1 ), ( valueof(max), 100 )] > > in memory first, which is then iterated over. This is why my original > example didn't work. nope. that's not the reason. read on! > Also, the "valueof()" relation for some types in python (apparently) > is a reference rather than a value (lists, objects, etc.) which explains > why these examples work: *EVERYTHING* is a reference. a pointer. a memory address. or whatever term you prefer. > (1) min = [ 0 ] > max = [ 0 ] > > for ( var, val ) in [( min, 1 ), ( max, 100 )]: > var[0] = val here, you modify the object in place (through the reference), by assigning to a list slot. corresponding C-ish code: varPtr->setitem(0, valPtr); > (2) class Val: > def __init__( self, num ): > self.num = num > > min = Val(0) > max = Val(0) > > for ( var, val ) in [( min, 1 ), ( max, 100 )]: > var.num = val here, you modify the "var" object in place by setting an attribute. corresponding C-ish code: varPtr->setmember("num", valPtr); > but this one doesn't: > > (3) min = 0 > max = 0 > for ( var, val ) in [( min, 1 ), ( max, 100 )]: > var = val here, you tell python to change the binding for the name "var" in the local name space so it points to the same thing as the name "val". corresponding C-ish code: varPtr = valPtr; or rather: setlocalname("var", valPtr); > So basically this is just a little asymmetry in the language. Putting a > variable in a list/tuple (valueof(var)) performs a shallow copy rather than > a deep copy. nope. content is never copied. only references. all the time. perfect symmetry. From da at ski.org Thu Apr 29 01:22:27 1999 From: da at ski.org (David Ascher) Date: Thu, 29 Apr 1999 05:22:27 GMT Subject: Maximize Benefit when Purchasing Learning Python In-Reply-To: <3727E7B2.616A87F0@polytopic.com> References: <3727E7B2.616A87F0@polytopic.com> Message-ID: > I tell you what, if you've got the stones to send me your > address off-list, you'll get a check. If you think Mr. > Ascher is worth it--and I don't doubt it for a moment--if > he'll provide me with the same, I'll send him one, too. You're not serious, are you? Anyway, ask Mark about the first part about being worth it, but the second part is: 522A Green St San Francisco CA 94133 Shameless, I know -- but what if you're one of the eBay founders and the check will cover my kid's tuition in the year 2015? I'd hate myself for not answering =). If you'd rather buy me a drink at the next conference, that'd be fine too. I already owe Jeff Bauer and Fredrik Lundh drinks, so we may have to start maintaining a database... [Off-topic: send in abstracts for the next Python conference! It'll be fun! Mark and I will meet for the third time! We'll dedicate books for free! We'll meet more folks who don't look like what we thought they looked like! Information is on www.python.org] More seriously, on the topic of where to buy -- I tell people to buy it through the PSA because 1) it's cheap and efficient, and 2) the PSA might get some $'s from it. I don't know how much, but it's statistically guaranteed to be more than through any other distribution channel. Note that if you really want to have more cents come to Mark and I, you should buy it direct from ORA. But most of the difference in the price goes to ORA, not to us =). What I most want from readers is that you write good programs, evangelize the use of Python where needed and as appropriate, and help Python grow. While you're at it, join the PSA and/or the Python Consortium. If, as a side effect, more companies hire us as trainers or consultants, that's fine too. --David Ascher From fredrik at pythonware.com Thu Apr 15 09:24:11 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Apr 1999 13:24:11 GMT Subject: 1.5.2 install problems on NT References: <3714D8FF.634655C5@ina.fr> Message-ID: <002201be8743$4414b940$f29b12c2@pythonware.com> Richard GRUET wrote: > Tcl problems: > --------------- > shared by many ! see Hoon Yoon for instance... wish80;exe works (hence I > conclude that tcl is installed properly) but IDLE or Tkdb don't, with > insults like: > C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl: bad event type > bad event type or keysym "MouseWheel" > while executing > "bind Listbox { > %W yview scroll [expr - (%D / 120) * 4] units > }" > (file "C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/listbox.tcl > invoked from within > "source [file join $tk_library listbox.tcl]" > (file "C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl" lin > invoked from within > "source C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl" > ("uplevel" body line 1) > invoked from within > "uplevel #0 [list source $tkfile]" > > This probably means that Tk wasn't installed properly. It means that you have several conflicting versions of Tk installed on your machine (or rather, that Python is picking up a version of tk80.dll that is older than the library files). Most likely, you'll find the offender in the system directory. See the thread "Tkinter, bad event type" for more info. From olipt at mayo.edu Fri Apr 16 23:59:25 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Fri, 16 Apr 1999 22:59:25 -0500 Subject: #!/usr/bin/env python -u In-Reply-To: References: <37175574.25EBDDBE@stuco.uni-klu.ac.at> Message-ID: > > So I tend to depend on GNU configure when I'm installing a script. I > actually look for Python in the user's environment, then use sed to > hard-code that path into the scripts before installing them. Can this > be done with RPM? Sure, since RPM is just a series of sh scripts that run while installing a package. You could put something in the %post section that did this. Then the scripts would be set up for whoever ran the rpm command, but not anyone who didn't have this same enviroment. This would imply multiple rpm databases on a single system for different users. I'm not familiar with using RPM in this way but I bet it could be done... Travis From da at ski.org Fri Apr 30 00:39:17 1999 From: da at ski.org (David Ascher) Date: Thu, 29 Apr 1999 21:39:17 -0700 (Pacific Daylight Time) Subject: Trouble with proxies In-Reply-To: <7gasj8$g79$1@nnrp1.dejanews.com> Message-ID: On Fri, 30 Apr 1999 befletch at my-dejanews.com wrote: > Hello again everyone, > > I have tried all the suggestions people have sent me, and I have tried all > the local debugging I could think of, but I still can't see the world from > behind my proxy server. Can anyone find a possible solution to this? I've > had to modify my URL lines with (colin-slash-slash) to get past DejaNews' > Draconian posting filters: > > > C:\>SET http_proxy=http(colin-slash-slash)10.187.200.230 I found I had to set the port of the proxy server (in our case 8080), so: C:\>SET http_proxy=http://10.187.200.230:8080 or whatever [FYI, that it's "colon", not "colin"] --david ascher From moritz at news.uni-mannheim.de Sun Apr 25 14:38:18 1999 From: moritz at news.uni-mannheim.de (Moritz Moeller-Herrmann) Date: Sun, 25 Apr 1999 20:38:18 +0200 Subject: GUI other than Tkinter References: <3721567f.1748033@news> Message-ID: On 25 Apr 1999 17:09:22 GMT, Michael W. Ryan wrote: >On 25 Apr 1999 09:23:35 -0400, Russell Nelson wrote: >>mrfusion at bigfoot.com writes: >>> Well, I've just about given up on EVER getting Tkinter to work on my >>> Win98 machine. Is there any other GUI module that I can get that > ^^^^^ >>> doesn't require TCL/TK to be installed on my machine? Isn't there >>> something called GD? >>There's pygtk, which uses the gtk toolkit. >As far as I know, GTk has not been ported to the Win32 platform, yet. And i wanted to propose pyQT/pyKDE :-) Seriously QT works for Windows, too but I think the bindings are for real operating systems only, aren't they? -- Moritz Moeller-Herrmann mmh at gmx.net ICQ# 3585990 # Not only Get my public pgp / gpg key from # Open Source(TM) http://webrum.uni-mannheim.de/jura/moritz/pubkeymoritz # but also # Open Minded! From Jan.Kybic at epfl.ch Wed Apr 28 08:46:09 1999 From: Jan.Kybic at epfl.ch (Jan Kybic) Date: 28 Apr 1999 14:46:09 +0200 Subject: Q: Threading and reload Message-ID: Hello everybody, I am developping a small web server. The problem is that since I added multithreading, the reload() command does not seem to have any effect. I have a separate thread for every request. The interaction logic itself is in a special module. I would like to be able to reload() this module for debugging purposes by issuing a proper HTTP request. The code looks like this: import Module class ThreadingHTTPServer(BaseHTTPServer.HTTPServer): def process_request(self, request, client_address): """Start a new thread to process the request.""" t=threading.Thread(target=self.finish_request, args=(request, client_address)) t.setDaemon(1) t.start() class Handler(CGIHTTPServer.CGIHTTPRequestHandler): def run_cgi(self): if script=='reload': reload(Module); ... ; return ... if not clients.has_key[client_number]: # new client clients[client_number]=Module.clientLogic() clients[client_number].emit_page() ... Before introducing threads, all worked fine but since then the reload() does not seem to do anything. What am I doing wrong? Are there any special considerations for using reload and threads? Thanks a lot. Jan -- ------------------------------------------------------------------------- Jan Kybic BIG IOA DMT EPFL Lausanne, Switzerland http://bigwww.epfl.ch/kybic tel. work +41 (21) 693 5741 For PGP key see my WWW page. From R.Hooft at EuroMail.com Mon Apr 19 02:42:51 1999 From: R.Hooft at EuroMail.com (Rob Hooft) Date: 19 Apr 1999 08:42:51 +0200 Subject: Tkinter - the app that wouldn't quit References: <19990416144831.A1548022@vislab.epa.gov> Message-ID: I would suggest to use Pmw (http://www.dscpl.com.au/pmw/) which contains ready-to-use dialog windows. The problem in your current program appears to be that when your application window is destroyed, "root" is still an active window, although it is invisible. The WM_DELETE protocol is never called, because you're not "destroying" the window using the window manager. The smallest change would be to make the "Quit" button run "sys.exit" immediately instead of "self.destroy". Regards, -- ===== R.Hooft at EuroMail.net http://www.xs4all.nl/~hooft/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From aa8vb at vislab.epa.gov Mon Apr 26 10:42:45 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Mon, 26 Apr 1999 10:42:45 -0400 Subject: "Compiling" scripts before execution ? Message-ID: <19990426104245.A504861@vislab.epa.gov> One concern I've been mulling over lately is the potential problem maintaining Python scripts over time. For example: 1) It's easy to never create (or to sever) a link to a imported symbol defined in another module, and you may never know it until python tries to execute the referencing line of script code. 2) If the signature of an imported method changes, and all references to it in all scripts aren't updated, you may never know it until Python tries to execute one of these "broken" line of script code. I realize with batch scripts, if you're diligent you can write and maintain exhaustive test code and include it in the modules (Re: Tim's doctest thread) -- a good idea IMO. However, I primarily have Python GUI code in mind, where it's not so simple to automate testing. What are folks doing to keep this class of errors from being a problem? Is there a way to "lint" or compile Python code such that it forces symbols to resolve when seen (possibly disallowing some dynamic symbol definition available in the language (e.g. adding methods to classes after class definition). To take a few examples: $ python >>> class C: $ python >>> def F(): ... def M(): >>> class C: ... return G() ... print self ... def M(self): ... ... ... self.RemovedMethod() >>> >>> ... >>> Is there a "Python lint" tool or hidden option (e.g. "-Dstrict_python") that can turn these into build-time errors of some sort? Any tips appreciated. Thanks, Randall From dalke at bioreason.com Mon Apr 26 16:39:47 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Mon, 26 Apr 1999 14:39:47 -0600 Subject: Trouble with httplib and IRIX References: <7g219p$hvb$1@nnrp1.dejanews.com> Message-ID: <3724CF13.C4680904@bioreason.com> basv at sara.nl said: > I'm running python 1.5.2 and running it on IRIX 6.5.3 systems. > ... > I have the following problem when i'm trying to connect to an > non-existing machine the program hangs forever. I don't get that behaviour using 1.5.2c1 or 1.5.1 on either of our 6.5.2m machines. max> pwd /home/u05/dalke/ftps/Python-1.5.2c1 max> env PYTHONPATH=Lib ./python Python 1.5.2c1 (#4, Apr 14 1999, 16:29:33) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import socket >>> import httplib >>> httplib.__file__ 'Lib/httplib.pyc' >>> def main(): ... h = httplib.HTTP() ... h.set_debuglevel(100) ... try: ... h.connect("www.nsrc.nus.sg") ... except socket.error, detail: ... print 'Connect failed: %s' %detail ... >>> main() connect: ('www.nsrc.nus.sg', 80) Connect failed: host not found >>> ^D max> uname -aR IRIX64 max 6.5 6.5.2m 11051732 IP30 Can you attach a debugger or force a core dump and see where it's hanging? Andrew dalke at acm.org From moshez at math.huji.ac.il Sat Apr 3 13:26:11 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 3 Apr 1999 20:26:11 +0200 Subject: Module Documentation Strings Message-ID: Is anyone working on adding doc-strings to the "re" module? I'm thinking of starting, and I wonder if I'm re-inventing the wheel here. -- Moshe Zadka . QOTD: What fun to me! I'm not signing permanent. From Gaetan_Corneau at baan.com Wed Apr 14 06:43:28 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Wed, 14 Apr 1999 10:43:28 GMT Subject: Pig Latin? Message-ID: <816010E2456BD111A48700805FBBE2EEA63EEF@ex-quebec-u1.baan.com> OK, I'll bite: Could someone tell me what "pig latin" is? A form of latin spoken by pigs? ______________________________________________________ Gaetan Corneau Software Developer (System integration Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 654-1454 ext. 252 ______________________________________________________ "Profanity is the one language all programmers know best" From frankmcgeough at my-dejanews.com Sat Apr 24 19:20:22 1999 From: frankmcgeough at my-dejanews.com (frankmcgeough at my-dejanews.com) Date: Sat, 24 Apr 1999 23:20:22 GMT Subject: Python implementation of tar Message-ID: <7ftjjl$tim$1@nnrp1.dejanews.com> Does someone has a tar implementation written in Python? -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From manus at bullfrog-tech.com Fri Apr 9 19:41:24 1999 From: manus at bullfrog-tech.com (Manus Hand) Date: Fri, 09 Apr 1999 17:41:24 -0600 Subject: Help (PLEASE) CGI on 98/NT Message-ID: <370E9024.6D256DE8@bullfrog-tech.com> I had my Win95 Personal Web Server (PWS) up and running just fine, having merely followed the simple instructions on Aaron's pws.html page at the starship. So they go and give me a 98 machine. Well, it has PWS, so you'd THINK it'd work if I did the same thing. Nope. I get "500 Server Error" and NO other help from Mr. Gates. My sysadmin has been unable to get NT's IIS 4 to run Python CGI as well. I (desperately!!!) need someone to come to the rescue, at LEAST on Win98's PWS, and hopefully also on NT's IIS 4. HELP!!!! PLEASE REPLY DIRECT TO ME AT manus at python.net IN ADDITION TO POSTING. Much obliged! Manus From dave at zeus.hud.ac.uk Thu Apr 29 07:38:25 1999 From: dave at zeus.hud.ac.uk (Dave Dench) Date: Thu, 29 Apr 1999 11:38:25 GMT Subject: Designing Large Systems with Python Message-ID: <199904291138.MAA06634@brahms.scom> > From python-list-request at cwi.nl Thu Apr 29 11:40:56 1999 > From: davecook at home.com (David M. Cook) > Newsgroups: comp.lang.python > Subject: Re: Designing Large Systems with Python > X-Organization: http://members.home.com/davecook > Reply-To: davecook at home.com > Date: Thu, 29 Apr 1999 10:13:48 GMT > X-Complaints-To: abuse at home.net > X-Trace: news.rdc1.sdca.home.com 925380828 24.0.189.179 (Thu, 29 Apr 1999 > 03:13:48 PDT) > To: python-list at cwi.nl > > Now to add something to the discussion, you might want to check out Extreme > programming: > > http://c2.com/cgi/wiki?ExtremeProgrammingRoadmap > > It seems to be popular with SmallTalk people. > At the recent OT99 at Oxford University, Kent Beck gave a keynote speech about XP as a paradigm. They happen to be using Java on their projects, language is not an issue. David ________________________________________________________________________________ ************************************************ * David Dench * * The University of Huddersfield , UK * * Tel: 01484 472083 * * email: d.j.dench at hud.ac.uk * ************************************************ ________________________________________________________________________________ From aahz at netcom.com Tue Apr 20 20:52:54 1999 From: aahz at netcom.com (Aahz Maruch) Date: Wed, 21 Apr 1999 00:52:54 GMT Subject: VB Nothing equivalent in win32com References: <7fiffg$4sb$1@nnrp1.dejanews.com> <7fj65j$6cp$1@m2.c2.telstra-mm.net.au> Message-ID: In article <7fj65j$6cp$1 at m2.c2.telstra-mm.net.au>, Mark Hammond wrote: > >Python uses None. Pythoncom also uses None in almost all relevant cases. I'm tempted to make a comment about None of your business, but I'm sure you've all heard the joke before. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "You often don't really understand the problem until after the first time you implement a solution." - Eric S. Raymond From tismer at appliedbiometrics.com Wed Apr 7 04:51:35 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 7 Apr 1999 08:51:35 GMT Subject: Chaning instance methods References: <000401be80bc$999f1820$699e2299@tim> Message-ID: <370B1C97.AC3CFD8A@appliedbiometrics.com> Tim Peters wrote: > Right, a direct attribute of an instance is never a method. Except that > this "works": > > import new > f.m = new.instancemethod(m2, f, Foo) > f.m() > > This sets f.m to a *bound* instance method that refers to f, which Python > treats as an ordinary function when later referenced via f.m. Without using > the "new" module, you can get the same effect via e.g. > > old_Foo_m = Foo.m > Foo.m = m2 > f.m = f.m # heh heh > Foo.m = old_Foo_m As a related topic, there is also DOnBeaudry's functor module from March '97 which makes use of the newmodule internally and is able to create quite efficient wrappers around callables with bound parameters. The calling overhead is about twice as large as for the original function. This version needed some tweaking to make it run under Python 1.5 . I just uploaded a slightly modified version to incoming and hope it will make it into contrib/system. cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 mlh at idt.ntnu.no Fri Apr 23 10:13:12 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 23 Apr 1999 16:13:12 +0200 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <37207685.F29BE1AB@ingr.com> Message-ID: Joseph Robertson writes: > Hi, > > For what you state here, you don't even really need to read the 'data' at > all. > Just read your descriptors, and store the offsets and len of the data in a > dictionary (i.e. index it). > > readline > if first char == > > get id > get current position using seek method > store id, pos in dict > #for each id, we now have its byte posisition in the file Well... You have to read all the lines to find all the descriptors, don't you? Is there really any great speadup here? Of course, you would get some speedup later, when using the same structure again... > > Then have a filter method which keeps or discards the records by criteria. > [...] If the number of excluded element isn't very high, this method will only add to the burden of processing, won't it? (By seek -- do you mean os.lseek? Or is ther another one... Just curious.) > > This way you can create views on your data without actually trying to load it > all. The tradeoff of course is memory for fileaccess time, but I found > fileaccess to be faster than doing all the work 'up front'. Hm. Yes. If the size (in lines) of the records is constant, then you could, of course, use seek to skip all the data while processing as well... > Besides my > project reached the point where we ran out of memory often, some datasets are > on 8+ cdroms! > > Hope that was relevant, but maybe I misunderstood the question. > Joe Robertson, > jmrobert at ro.com > > > > [...] -- > Hi! I'm the signature virus 99! Magnus > Copy me into your signature and join the fun! Lie Hetland http://arcadia.laiv.org From msrisney at my-dejanews.com Sat Apr 24 00:30:56 1999 From: msrisney at my-dejanews.com (msrisney at my-dejanews.com) Date: Sat, 24 Apr 1999 04:30:56 GMT Subject: wrapped around the axle on regexpressions and file searching Message-ID: <7frhe0$8g1$1@nnrp1.dejanews.com> Hey Pythoniers! I'm attemtping to locate log files on my drive(s), and do some comparison. here's a simplified snippet where I'm getting bottlenecked. >>>import os,re >>>regexp = re.compile('.log') >>>def find_log_files(arg, directory, names): ...for name in os.listdir(directory): if regexp.search(name): print directory + "\\" + name >>>os.path.walk('D:\\',find_log_files,None) here are my questions: 1. this prints out not only files with the file extensions ".log" but also any file name that has "log" in it's name. how would I rewrite to avoid?? 2. is there a better, faster way of doing this??, my end goal is to open the files and compare time sequences to one another. 3. Is ther any way to determine the number of drives on a system, obviuosly I am hardcoding the top level drive letter "D:\", is there any way to search the entire system much like win32's find file search?? TIA -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From a.mueller at icrf.icnet.uk Fri Apr 23 12:38:51 1999 From: a.mueller at icrf.icnet.uk (Arne Mueller) Date: Fri, 23 Apr 1999 17:38:51 +0100 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> Message-ID: <3720A21B.9C62DDB9@icrf.icnet.uk> Hi All, thanks very much for all the suggestions how to speed up things and how to THINK about programming in python. I got alot of inspiration from your replys. However the problem of reading/writing larges files line by line is the source of slowing down the whole process. def rw(input, output): while 1: line = input.readline() if not line: break output.write(line) f = open('very_large_file','r') rw(f, stdout) The file I read in contains 2053927 lines and it takes 382 sec to read/write it where perl does it in 15 sec. These simple read/write functions use the functions from the C standard library, don't they? So, readline/write don't seem to be implemented very efficently ... (?) I can't read in the whole file as a single block, it's too big, if readline/write is slow the program will never get realy fast :-( thanks a lot for discussion, Arne From frederic.bonnet at ciril.fr Thu Apr 22 08:10:42 1999 From: frederic.bonnet at ciril.fr (Frederic BONNET) Date: Thu, 22 Apr 1999 14:10:42 +0200 Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> Message-ID: <371F11C2.3162025@ciril.fr> Hi, Eugene Dragoev wrote: [...] > But I also found that while older versions of Tk were using lightweight > components (Some Java terminology :) the latest version is using native > components for things like scrollbars and buttons. > > I don't want to say that this is bad for Tcl users but what about all > the other languages that use Tk? Isn't writting multiplatform GUI harder > using native components. I think Java made big step forward in > abandoning the native components and using lightweight ones in Swing. > > Is there going to be any Tk implementation that will continue using > lightweight components? By lightweight I guess you mean emulated in some way. I don't think that cross-platform look&feel consistency is a good thing. As a GUI designer I'd rather follow the principle of least astonishment: an app running on Windows should look and feel like a Windows app. The same app running on MacOS and X should do the same on the respective platforms. Such a cross-platform application is not supposed to look and feel the same on all platforms. If users want to use the same app on several platforms, it's their problem, and I think this isn't an issue: if the same person uses an application on both Mac and Windows, he or she is supposed to know both platforms, so he won't be surprised if the same application behave differently on different platforms. On the contrary he or she would be surprised to use an application that behaves like a Mac app on his Windows system. The current Tk implementation addresses these problems in a transparent manner, which is good for both programmers and users. A short summary of menubar differences between systems: - they are placed on top of a window on Windows and X, and on top of the screen on Mac. - on Mac, the mouse button must be kept pressed to open and navigate the menu (until recently). On X, one needs to click on each menu to open it. On Windows, one needs to click on a menu but doesn't need to keep the button pressed. And I don't speak about look differences. See you, Fred -- Fr?d?ric BONNET frederic.bonnet at ciril.fr --------------------------------------------------------------- "Theory may inform, but Practice convinces" George Bain From dfan at thecia.net Sun Apr 18 20:28:33 1999 From: dfan at thecia.net (Dan Schmidt) Date: 19 Apr 1999 00:28:33 GMT Subject: Sorting tuples References: <7fdkhf$12d$1@sparky.wolfe.net> Message-ID: On Sun, 18 Apr 1999 14:57:52 -0700, Jon Cosby wrote: | I have a list of tuples | [('a','p','q'),('b','r','s'),('c','t','u'),('a','v','w'),('b','x','y')], | and I want to print out | | a : p, q, v, w | b : r, s, x, y | c : t, u This works: # Create a dictionary indexed by the first element of each tuple tups = [('a','p','q'),('b','r','s'),('c','t','u'),('a','v','w'),('b','x','y')] dict = {} for tup in tups: key, val = tup[0], tup[1:] try: dict[key] = dict[key] + list(val) except KeyError: dict[key] = list(val) import string keys = dict.keys() keys.sort() # keys is now a sorted list of the keys in dict for key in keys: print "%s : %s" % (key, string.join (dict[key], ", ")) -- Dan Schmidt -> dfan at thecia.net, dfan at alum.mit.edu Honest Bob & the http://www2.thecia.net/users/dfan/ Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/ Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/ From MHammond at skippinet.com.au Thu Apr 15 01:52:27 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 15 Apr 1999 15:52:27 +1000 Subject: Can't run Win32 Debugger outside PythonWin References: <371475d6.77664796@news.omnilink.de> <371555BD.70107860@fast.fujitsu.com.au> Message-ID: <7f3uos$fjg$1@m2.c2.telstra-mm.net.au> Neil Hodgson wrote in message <371555BD.70107860 at fast.fujitsu.com.au>... >Stefan Franke wrote: > >> I just upgraded my NT4 SP3 Workstation to Python 1.5.2 and >> win32all build 124. Unluckily I can't start the debugger any >> longer from outside PythonWin. >> That is, typing >> >> It seems the Scintilla.DLL can't be found (even the latest update from the >> author's hompage). However, sys.path is OK: sob. Ive seen this, and thought my update solved it. Ill check into it more... > Sorry, I don't see this error myself. As a temporary workaround you >could try copying Scintilla.DLL into the windows or windows system >directory (often called \winnt\system32). That is the best idea for now. However, you will need to remember to delete it when a new pythonwin build comes out (fairly soon) Mark. From mmc at vip.cybercity.dk Thu Apr 15 15:24:02 1999 From: mmc at vip.cybercity.dk (Morten Christensen) Date: Thu, 15 Apr 1999 19:24:02 GMT Subject: Fnorb for JPython ? (WAS: Fnorb 1.0 - A Python CORBA ORB) References: Message-ID: <371619a4.1287080@news.cybercity.dk> On Wed, 14 Apr 99 16:59:36 GMT, Martin Chilvers wrote: >Announcing the release of version 1.0 of 'Fnorb' a Python CORBA ORB. Great news! >Things on the TODO RSN list:- > >1) Implement the POA >2) Implement the rest of the CORBA 2.1 datatypes >3) Move documentation to PDF format. I would like to suggest support for JPython (for pure java) !!! :-) Keep up the good work! Thanks, Morten Christensen From banderson at boi.hp.com Fri Apr 30 18:38:06 1999 From: banderson at boi.hp.com (Bill Anderson) Date: Fri, 30 Apr 1999 22:38:06 +0000 Subject: Rat sited on Amazon References: <199904302115.PAA03581@shell.rmi.net> Message-ID: <372A30CE.16C8A59D@boi.hp.com> Mark Lutz wrote: > > Jeff Bauer wrote (about Learning Python): > > Hey everyone. Check out what's featured on Amazon today > > under "Computers and Internet". > > It gets a little better: the book (and Python) > made amazon.com's home page today. It showed > up in a paragraph titled "Mighty Python", along > with Sarah McLachlan's new CD. > > Cheers, > > --Mark Lutz (http://rmi.net/~lutz) Cool, a new CD. 'bout time. :-) -- Bill Anderson Linux Administrator MCS-Boise (ARC) banderson at boi.hp.com My opinions are just that; _my_ opinions. From jbauer at rubic.com Sat Apr 24 11:06:26 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Sat, 24 Apr 1999 15:06:26 GMT Subject: PythonCE References: <3721380C.C545A15@rubic.com> <7fshcn$68n$1@pollux.ip-plus.net> Message-ID: <3721DDF2.E05C067E@rubic.com> Franz GEIGER wrote: > Is there a chance to have Tkinter someday on a CE > machine. Or is it too mem consuming and impossible > therefore? PythonWare's project-formerly-known-as-Topaz would probably fit the bill. It's a small, tightly coded Tk clone. We aren't likely to see it on the radar screen anytime soon, alas. (Hoping to get a rise out of /F, who will prove me wrong.) Another possibility would be for wxPython to run on CE. This isn't as far-fetched as it might first appear. Julian Smart's web site has already mentioned some interest in this direction. If wxWindows were ported to CE, wxPython/CE would be fairly straightforward. I am interested in promoting open source development in this direction (PythonCE applications). If anyone has specific, low-cost ideas, please discuss them on this newsgroup or contact me via email. Best regards, Jeff Bauer Rubicon, Inc. From tim_one at email.msn.com Sun Apr 25 13:13:26 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 25 Apr 1999 13:13:26 -0400 Subject: converting perl to python - simple questions. In-Reply-To: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: <000001be8f3e$eea9c3c0$d39e2299@tim> [sweeting at neuronet.com.my] > ... > Anyway, since I know that there are a few ex-perlmongers on the list, > would somebody be so kind as to confirm whether I've translated > the following code snippets correctly : > > a) Perl's "defined". > [perl] > if (defined($x{$token}) > > [python] > if (x.has_key(token) and x[token]!=None) : If should be enough to do if x.has_key(token): under the probably-correct theory that the Perl is just asking "does hash 'x' have key 'token'?" "None" is a specific valid value, not at all "undefined", so checking x[token] against None doesn't make sense unless you've established your own consistent program-wide convention of using None to *mean* something like undefined. Which is dicey. After e.g. "del x[token]", a reference to x[token] doesn't yield None, it raises the KeyError exception. > b) RE's. > [perl] > if ($mytext !~ /^\s$/) > > [python] > if not (re.match('^\s$'), mytext) Hmm. The Perl says "if mytext isn't a single whitespace character", which is an odd thing to check! If that's the intent, fine. Python's "match" already constrains the search to begin at the start of the string, so the leading "^" isn't needed (use Python's "search" if don't want that constraint). So: if not re.match(r"\s$", mytext): Get in the habit of using r-strings for writing regexps; they'll make your backslash life much easier. Another thing to note is that high-use regexps can be compiled, and if they're always used in the same way (match vs search) you can capture that choice too. So this may be more appropriate: is_single_whitespace = re.compile(r"\s$").match while whatever: ... if not is_single_whitespace(mytext): ... ... Hoisting the regexp compilation out of the loop can be a substantial win. > Since I know neither perl nor chinese, it would be nice if somebody > could help me remove one of the variables in my debugging. native-speakers-of-both-say-chinese-is-easier-to-read-ly y'rs - tim From doughellmann at mindspring.com Sat Apr 3 17:37:29 1999 From: doughellmann at mindspring.com (Doug Hellmann) Date: Sat, 03 Apr 1999 17:37:29 -0500 Subject: Tkinter problem (threads?) References: Message-ID: <37069828.89C5B08C@mindspring.com> Robert, You might want to look into the after_idle method available from the Tkinter widget classes. It basically registers a function to be called during the next "idle" period of the event loop. The idle period is either after or before all normal events have been processed (I don't know which). I have successfully used this technique in several applications to do my processing "in the background" while the interface remains responsive. The trick is to remember that while your idle function is running, the interface *won't* update. Only after you return (or call update_idletasks will it update. The best thing to do is make your idle function perform only a small piece of your processing. For instance, in one program I had an idle function that polled several pipes using select to see if any of them had output. When it found output, it would read a small buffer, process it, and return. When it found no output it would return immediately. That way, the interface was very responsive, since my function didn't hang it up for very long. I kept my state information (list of pipes, portion of buffer not processed, etc.) as member variables of my application class. The idle function was a method of the class, so I could access everything I needed from the application instance. Oh, one other thing you need to know is that calling after_idle only registers the function to be called one time. You will need to have your function re-register itself if it has more processing to do. Let me know if you run into trouble, I'd be happy to help. Doug Robert Vollmert wrote: > > I'm experiencing a problem while writing a simple plotting program > using Tkinter: I've created a Plot class which, after being > initialized with a canvas instance, gets new values through an add > method. > > How can I make Tk enter the mainloop (in order to show the plot) and > still add new values afterwards? > > TIA, Robert > > -- > Robert Vollmert rvollmert at gmx.net From arcege at shore.net Sat Apr 3 11:24:16 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sat, 03 Apr 1999 16:24:16 GMT Subject: Put exception information into a string? References: <8J6N2.457$Px6.74582@homer.alpha.net> Message-ID: Fabian wrote: : I've been having some odd problems.. : It works in certain circumstances. For example if I have an plainly invalid : object, it reports it right, such as "blah\n", or "import bad-name\n", but : if I have an error : such as "if a ==10\n b = 2\n" (missing ':'), it does not. what happens in : this circumstance is: :>:> lines = PyObject_CallFunction( :>:> traceback_format_exception, "OOO", exc, val, tb) : returns NULL into lines, and from then on the function does not want to : return -anything- but NULL. : Thanks for all the help so far.. This is atleast useful in a way, but any : ideas how to get it to work with these other situations? Without seeing your code, I can't say more. I tried this same string and get the following on stderr. ' File "", line 1\n if a == 10\n ^\nSyntaxError: invalid syntax\n' My little test code is below, maybe it can help. It compiled and ran with gcc 2.7.2.2 on Solaris for Intel 2.6 with Python 1.5.1. And sorry for all the typos in the program, as I said, I wasn't able to test it. :/ -Arcege #include #include #include int main(argc, argv) int argc; char *argv[]; { char cmdstr[256]; PyObject *traceback_format_exception; PyObject *string_joinfields; PyObject *mod, *moddict; PyObject *exc, *val, *tb; PyObject *lines, *exception_string; int rc; /* setup */ Py_Initialize(); mod = PyImport_ImportModule("traceback"); moddict = PyModule_GetDict(mod); traceback_format_exception = PyDict_GetItemString(moddict, "format_exception"); Py_DECREF(mod); Py_DECREF(moddict); mod = PyImport_ImportModule("string"); moddict = PyModule_GetDict(mod); string_joinfields = PyDict_GetItemString(moddict, "joinfields"); Py_DECREF(mod); Py_DECREF(moddict); /* strcpy(cmdstr, "import foobar"); */ strcpy(cmdstr, "if a == 10\n b = 2\n"); rc = PyRun_SimpleString(cmdstr); /* print the traceback to stderr */ if (PyErr_Occurred()) { PyErr_Fetch(&exc, &val, &tb); lines = PyObject_CallFunction( traceback_format_exception, "OOO", exc, val, tb ); exception_string = PyObject_CallFunction( string_joinfields, "Os", lines, "" ); Py_DECREF(lines); fprintf(stderr, PyString_AsString(exception_string)); Py_DECREF(exception_string); Py_DECREF(exc); Py_DECREF(val); Py_DECREF(tb); } } From fuchs at princeton.edu Wed Apr 21 13:35:02 1999 From: fuchs at princeton.edu (Ira H. Fuchs) Date: Wed, 21 Apr 1999 13:35:02 -0400 Subject: Reversing Long integers Message-ID: <371E0C46.E6FA76A9@princeton.edu> I am attempting to write an efficient Python program which can add an integer to its reverse. This is quite easy to do in Lisp and Mathematica but (mostly out of curiosity) I wanted to see how one might do this in Python. Converting an integer to a string and reversing it and converting back is quite easy (although not all of these ops are primitives) but the fact that Long integers have the letter L appended means that the loop must include moving the L to the end of the reversed string prior to summing. Can anyone think of a particularly clever way to do this? From hf at daisybytes.su.uunet.de Tue Apr 13 15:56:43 1999 From: hf at daisybytes.su.uunet.de (Holger Flörke) Date: 13 Apr 1999 19:56:43 GMT Subject: win32net.pyd--NetUserAdd Message-ID: <37131b6c.2250115@kelly> I am interested in adding user accounts on WinNT using python. The functions "NetUserAdd" and "NetUserSetGroups" in Win32 networking aren't implemented in then win32net.pyd-module. Does anyone have mapped these functions? Any other ideas? Thanks HolgeR From barry at scottbb.demon.co.uk Fri Apr 23 17:33:25 1999 From: barry at scottbb.demon.co.uk (Barry Scott) Date: Fri, 23 Apr 1999 22:33:25 +0100 Subject: Looking for db.h - its not in the 1.5.2 source kit Message-ID: <924903339.24130.0.nnrp-10.9e982a40@news.demon.co.uk> Can anyone point me at a copy of db.h that is required to build bsddb windows module please? Its missing from the final release 1.5.2 kit. BArry From aa8vb at vislab.epa.gov Mon Apr 5 08:48:19 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Mon, 5 Apr 1999 12:48:19 GMT Subject: Possible regex match bug (re module) Message-ID: <19990405084819.B802985@vislab.epa.gov> Re doesn't handle named groups in alternative patterns like it seems it should. Given an alternative pattern with a particular group name in each, it only assigns the match if the group name matches the last alterative. For example, the following example outputs: None def rather than: abc def (Note that I've simplified this example a good bit so the behavior is apparent.) Randall ------------------------------------------------------------------------------- import re pattern = '(---(?P[^-]*)---)|(===(?P[^=]*)===)' s = "---abc---" match = re.compile( pattern ).match(s,0) print match.group('id') s = "===def===" match = re.compile( pattern ).match(s,0) print match.group('id') From kranio at nospam.nospam.it Sat Apr 17 05:53:48 1999 From: kranio at nospam.nospam.it (Kranio) Date: Sat, 17 Apr 1999 09:53:48 GMT Subject: Beginner - Tkinter info Message-ID: <371c59e9.2723125@news.tin.it> I am just starting using python and I would like to learn more. I have about all the docs written by guido but I haven't found yet documentation about tkinter usage. Can you help me? Where I can find some example of both python and tkinter? Tnx Marco Buzzo marco.buzzo at usa.NOSPAM.net From sysadm at sysadm.cc Thu Apr 8 02:27:43 1999 From: sysadm at sysadm.cc (Julien Oster) Date: 08 Apr 1999 08:27:43 +0200 Subject: Lexical analyzers and parsers Message-ID: <7jn20jmxsw.fsf@gandalf.midearth.fuzzys.org> What about lexical analyzers and parsers? Under C I use bison/yacc and (f)lex. Under python, I can either implement this stuff using C or try to write my parsers on my own, which is real pain. Is there no module suitable for such tasks? What do you suggest? -- /--/ Julien Oster /---/ www.fuzzys.org <---> www.sysadm.cc /---/ /--/ OpenBSD 2.5 /---/ Greetings from Munich, Germany /---/ /--/ contact me : /---/ talk fuzzy at fuzzys.org or e-Mail me /---/ From news at dorb.com Sat Apr 3 17:13:33 1999 From: news at dorb.com (Darrell) Date: Sat, 3 Apr 1999 17:13:33 -0500 Subject: Rat sighting online References: <19990403170011.21264.rocketmail@web602.mail.yahoo.com> Message-ID: Just commented this line out and it worked. Tricky though, it comes up as a very small window that you have to look for. Darrell wrote in message news:p%uN2.960$8m5.1674 at newsr1.twcny.rr.com... > I created the struct.py module and got this error. Guess I'll wait for the > next version of Jpython. > JPython 1.0.3 on java1.1.4 > Copyright 1997-1998 Corporation for National Research Initiatives > >>> import sys > >>> sys.path.append('d:\\python\\lib') > >>> import graph > Traceback (innermost last): > File "", line 1, in ? > File "D:\at\sched\.\graph.py", line 202, in ? > File "D:\at\sched\.\graph.py", line 116, in __init__ > File "D:\at\sched\.\graph.py", line 131, in do_layout > TypeError: can't assign to this attribute in java instance: size > > > > > > From faassen at pop.vet.uu.nl Thu Apr 22 18:05:00 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Fri, 23 Apr 1999 00:05:00 +0200 Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> Message-ID: <371F9D0C.4F1205BB@pop.vet.uu.nl> Thooney Millennier wrote: > > Hello Everyone! > > I usually use C++ ,so I want to make programs like > I do using C++. Well, first of all, Python is not C++. Some C++ practices don't, and shouldn't, translate to Python, and vice versa. Python coding style is different than C++ coding style, just like Java is different yet again, etc, etc. > I don't figure out how to implement the followings > by Python. > If you know any solutions,Please Help! > > 1. #define statements > e.g. #define __PYTHON_INCLUDED__ Why would you need this? You can use a dictionary and store this kind of variable in there. > #define PYPROC(ARG) printf("%s",ARG) def pyproc(arg): print "%s" % arg Python doesn't have a preprocessor. > 2. stream class > e.g. cout << "hello python."< 3. const variables > e.g. const int NOCHAGE=1; Though trickery is possible, Python does not strictly have any constant variables. What you can do is use (global) variables with an preceding underscore. When importing the module these variables are not accessible. _like_this. > 4. access to class's members using "::" > e.g. some_class::static_value > e.g. some_class::static_func(x) Python does not support static methods (or 'class methods'). Usually a module level global function suffices for this purpose. A static value can be created like this (besides using a global variable in a module): class Foo: self.shared = 1 def __init__(self): print self.shared Other people will likely come up or refer to the more complicated ways to emulate these things in Python, but they're slower and nobody actually seems to use them in practice. Python is more dynamic than C++, and that is reflected in the way the language is used. I hope this helps. Regards, Martijn From akuchlin at cnri.reston.va.us Tue Apr 27 09:14:38 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Tue, 27 Apr 1999 09:14:38 -0400 (EDT) Subject: CGI post method In-Reply-To: <7g31ah$hk2$1@sparky.wolfe.net> References: <7g31ah$hk2$1@sparky.wolfe.net> Message-ID: <14117.47102.615236.362798@amarok.cnri.reston.va.us> Jon Cosby writes: >Can somebody tell me what's wrong with the following form tag: >
> >
> >My script isn't getting the text as input. It looks reasonable. Try changing the method to "GET" and see if you wind up with /cgi-bin/fibo.py?value=10. What error are you seeing? -- A.M. Kuchling http://starship.python.net/crew/amk/ "Mortal man?" "Yes?" "Beware of the dog." -- Charon warns Orpheus, in SANDMAN: "The Song of Orpheus" From kevin at cocreator.com Thu Apr 15 09:00:06 1999 From: kevin at cocreator.com (Kevin K. Ehmka) Date: Thu, 15 Apr 1999 09:00:06 -0400 Subject: PIL fonts - Where are you? References: <7jbR2.3071$YU1.5576@newsr2.twcny.rr.com> Message-ID: Oleg Broytmann wrote in message ... >On Wed, 14 Apr 1999, Kevin K. Ehmka wrote: >> Does anybody have some ready made fonts in PIL format they want to share? A > > I avn send you some. I'v compiled them from BDF fonts. English parts of >these fonts are ASCII, but characters from 128 up are Cyrillic (Russian). > If you have some BDF fonts, I could try to compile them to PIL format. > >> web site maybe? I was unsuccessful today creating any. > > What's the problem? > I'm using the compiled binaries of PIL (from Starship) and fail to get pilfont to work on several BDF fonts. I even used a font maker program and I get different errors. Using 1.0b I get encoder errors. Using 0.3 PIL I get array bounds errors. If you could, Oleg, please email me some of yours. Thank you. From mark at chem.uwa.edu.au Mon Apr 19 04:31:56 1999 From: mark at chem.uwa.edu.au (Mark C Favas) Date: 19 Apr 99 08:31:56 GMT Subject: Python-1.5.2 testing zlib References: Message-ID: piers at cs.su.oz.au (Piers Lauder) writes: >My "make check" fails with a core dump after "test_zlib". >Runng that test by hand shows: > Bus error - core dumped >(My system: > : s Python-1.5.2 ; uname -a > SunOS staff 5.6 Generic_105181-05 sun4u sparc SUNW,Ultra-2 > : s Python-1.5.2 ; ./python > Python 1.5.2 (#2, Apr 17 1999, 20:08:31) [GCC 2.8.1] on sunos5 Works just fine for me on both DEC Alpha (uname -a: OSF1 hostname V4.0 878 alpha, python: Python 1.5.2 (#1, Apr 16 1999, 15:49:36) [C] on osf1V4) and Solaris (uname -a: SunOS hostname 5.6 Generic sun4m sparc SUNW,SPARCstation-10, python: 1.5.2 (@1, Apr 16 1999, 17:38:58) [GCC egcs-2.90.29 980515 (egcs-1.0.3 re on sinos5) These are both with zlib-1.1.3. -- Email - mark at chem.uwa.edu.au ,-_|\ Mark C Favas Phone - +61 9 380 3482 / \ Department of Chemistry Fax - +61 9 380 1005 ---> *_,-._/ The University of Western Australia v Nedlands Loc - 31.97 S, 115.81 E Western Australia 6009 From python at pinky.cchem.berkeley.edu Tue Apr 20 04:28:08 1999 From: python at pinky.cchem.berkeley.edu (python at pinky.cchem.berkeley.edu) Date: 20 Apr 1999 08:28:08 GMT Subject: Tkinter: some Labels not updating Message-ID: <7fhdqo$dnl$1@agate.berkeley.edu> Hi, I'm writing a small app using Python and Tkinter and I'm having trouble with some Label objects not updating when I set the StringVar object attached to the textvariable of the Label. My Tkinter window has a Canvas with a bitmap image in one Frame, pull down menus in another Frame, and a few Buttons and Labels. The Labels are supposed to indicate the values of certain variables which change when the user clicks on the canvas. The first Label changes, but the others don't, they stay fixed at the values they had when I created the Label. Is there a trick here or something I don't get? I first create the StringVar: self.X1v=StringVar() Then I initialize X1v: self.X1v.set("X1: not entered") Then I make a Label object self.l1=Label(tb, textvariable=self.X1v) self.l1.pack(side=TOP) Then in the mouse callback (yes, it gets run, I have it print to stdout) self.X1v.set("X1: Got It") But no update of the text in the label happens. Updates _do_ happen in another Label object that is in a Frame by itself. Do I need a separate Frame for each Label? Do I have too many Label objects? Any workarounds? Post or e-mail replys. Thanks, JDM -- python enthusiast whose reach exceeds his grasp. :) From barry at scottbb.demon.co.uk Fri Apr 9 15:42:37 1999 From: barry at scottbb.demon.co.uk (Barry Scott) Date: Fri, 9 Apr 1999 20:42:37 +0100 Subject: Embedding python question: PyRun_String only returns None not what I calculate References: <923433832.14002.0.nnrp-07.9e982a40@news.demon.co.uk> <7ee5pk$qkm$1@m2.c2.telstra-mm.net.au> Message-ID: <923762064.17505.0.nnrp-03.9e982a40@news.demon.co.uk> >Hopefully someone with more time can give a better answer... > >But the short story is that PyRun_String works with statements, not >expressions. You can use it to, eg, import modules, and even call >functions, but you cant get the result. I guess I'll have to try and understand how the interactive python shell works. (I got lost in the details last time...) This whole area is in need of docs or extra comments in the sources. Barry From fuming at sup.phys.washington.edu Tue Apr 20 08:06:00 1999 From: fuming at sup.phys.washington.edu (Fuming Wang) Date: Tue, 20 Apr 1999 05:06:00 -0700 Subject: Quick fix to add "+=" In-Reply-To: References: <3717AB14.2926AF76@mediaone.net> <3717EE20.41343593@mediaone.net> Message-ID: Hi, On 17 Apr 1999, Bernhard Reiter wrote: > Your editor is your friend: > > Just use a macro in your favorite editor, which grabs the left > word of the curser postion and expands it into > =+ > Trigger the macro with "+=" and you type excactly what you > always type, just the result is more python like. > > For vim, the following does the trick (without the special word matching caps > new vim versions provide. the ":noh is for people using hlsearch in > vim 5.x version.) > > > :map!^[:s/\([a-zA-Z_][a-zA-Z0-9_]*\)$/\1=\1+/^M:noh^MA > > Bernhard > This works for me, except I got "no mapping found" when I enter the suggested command. I am using vim 5.3. Is this the problem? Thanks! Fuming From jschiotz at hotmail.com Tue Apr 27 10:39:36 1999 From: jschiotz at hotmail.com (Jakob Schiotz) Date: Tue, 27 Apr 1999 14:39:36 GMT Subject: WARNING: AIX and dynamic loading. Message-ID: <7g4i77$qif$1@nnrp1.dejanews.com> Hi everybody, I would like to warn developers using AIX against this trap waiting for us to fall into. (I am cross-posting this to the SWIG mailing list although it is not strictly a SWIG problems, as SWIG users will be doing just the kind of stuff that gets you into trouble). SCENARIO: You are developing a dynamically loaded C module for Python (or possibly for other languages). You place the module in a directory on the PYTHONPATH. That directory is NFS mounted. Or you are loading the module directly from the directory where you compiled it, and that directory is NFS mounted. SYMPTOMS: You are improving the code, but it does not seem to have any effect at all. Eventually you realise that Python is loading the buggy version of your module that you tried out this morning, although _all_ copies on disk are the new improved version you just wrote ! PROBLEM: If you copy the module to the PYTHONPATH directory using cp, the old file gets overwritten, but keeps the same inode number. Apparently, the AIX dynamical loader is caching the module somewhere, and does not discover that the file has been modified. (If the directory is not NFS mounted cp will fail with an error message saying that you cannot overwrite a running program - although the program has stopped.) It is _possible_ that this only occurs if the module you wrote causes python to dump core. It certainly makes it frustrating to fix the bug as you continue to get the version that dumps core loaded into python, even after you fixed the bug. SOLUTION: You makefile should remove the old module (the .so file) before copying the new version into the installation directory. Then the file gets a new inode number and the loader discovers that it has been changed. If you ever load the module directly from the development directory you should also remove the .so file before compiling/linking, as you will otherwise get hit by the same bug. I just wanted to warn you all about this bug in AIX. I wasted too much time on this last Friday :-( Best regards, Jakob Schiotz -- Jakob Schiotz, CAMP and Department of Physics, Tech. Univ. of Denmark, DK-2800 Lyngby, Denmark. http://www.fysik.dtu.dk/~schiotz/ This email address is used for newsgroups and mailing lists (spam protection). Official email: schiotz @ fysik . dtu . dk -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From jlcos at accessone.com Mon Apr 5 14:13:22 1999 From: jlcos at accessone.com (Jon Cosby) Date: Mon, 5 Apr 1999 11:13:22 -0700 Subject: Freeze for Windows Message-ID: <923335978.611.91@news.remarQ.com> Is it possible to configure 'freeze' for the Win32 binary installation of Python 1.52? If so, what do I need to do? Jon Cosby From ivanlan at callware.com Mon Apr 26 17:15:42 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 26 Apr 1999 21:15:42 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <37215EFB.433AFCA6@prescod.net> <3724B2D6.B468687A@prescod.net> Message-ID: <3724D77E.66254D78@callware.com> Pythonistas-- Roy Smith wrote: > > I hope this doesn't sound as bad as I fear it might, but part of being a > good programmer (or at least a good computer scientist) is to understand > performance issues like this. > > Regular expression theory hasn't changed a whole bunch in the last 20 > years; it's the same stuff in C, Perl, and any other language that has RE > functionality (either built-in or through some library). The idea of > factoring constant operations out of loops is the same today is it was 10, > 20, 30 years ago. > > If you don't know that RE's get compilied (and that the compilation stage > can be expensive), you don't understand the tool you're using. If you > don't understand that factoring the expensive constant compilation process > out of a loop is important to make your program run fast, you aren't a > good programmer. No programming language can help that. > Roy, you're absolutely right. However, the person who originally posted the question (and I'm sorry, but I've forgotten who) was speaking from a newbie's viewpoint. Stuff that most of us on the list take for granted is not always obvious to someone who is new both to the language and to the field in general. And, things that are obvious in C or C++ or some other language are not always obvious when moving to a new language, and some idioms simply don't exist in some languages. Look at the questions posted the other day by the person who wanted to know how to do things in Python that he had to do all the time in C++ ... it was just not obvious to him that those were neither necessary nor desirable in Python. In sum, I think tips on how to optimize source code need to be part of the introductory documentation of any language; not everyone has gone to school and learned these things in Pascal 101, and even if they have there are idioms that won't translate. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From euroibc at solair1.inter.NL.net Wed Apr 21 05:44:34 1999 From: euroibc at solair1.inter.NL.net (Martin van Nijnatten) Date: Wed, 21 Apr 1999 11:44:34 +0200 Subject: opening more than 1 file References: <371CB255.5FCAFBAF@solair1.inter.NL.net> <371CBF75.10FA1EE6@mojam.com> Message-ID: <371D9E02.B0511625@solair1.inter.NL.net> Thanks, this answers my question. Thanks, this answers my question. Skip Montanaro wrote: > martin van nijnatten wrote: > > > > I have a variable, which can have a value in the range from 1 to 20. > > > > If the value is 7, I have to open 7 files. > > > > What could be an elegant way of doing this? > > Well, how about: > > files = [] > for i in range(nfiles): > files.append(open("/tmp/file%03d"%i, "wb")) > > then access the i-th file as files[i]? > > -- > Skip Montanaro | Mojam: "Uniting the World of Music" > http://www.mojam.com/ > skip at mojam.com | Musi-Cal: http://www.musi-cal.com/ > 518-372-5583 From trashcan at david-steuber.com Thu Apr 22 21:41:52 1999 From: trashcan at david-steuber.com (David Steuber) Date: 22 Apr 1999 21:41:52 -0400 Subject: New python user seeks comments References: <371DA955.9F13B144@pop.vet.uu.nl> <371E2DEE.C2BD5A58@pop.vet.uu.nl> Message-ID: Martijn Faassen writes: -> Chad McDaniel wrote: -> -> ['in' is a reserved word so can't be used as a variable name] -> -> > It seems that Python could have mentioned that to the user. -> -> True, though it does say this: -> -> File "", line 2 -> in = open("test.txt", "r") -> ^ -> SyntaxError: invalid syntax -> -> Could be better, but easily could've been far worse.. This is what threw me. I got the syntax error. I had no clue what was wrong with the syntax though. I have gotten so used to using in for the input file and out for the output file in other languages. -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. .. The Anarchists' [national] anthem is an international anthem that consists of 365 raspberries blown in very quick succession to the tune of "Camptown Races". Nobody has to stand up for it, nobody has to listen to it, and, even better, nobody has to play it. -- Mike Harding, "The Armchair Anarchist's Almanac" From bxqiyh at virtualbanner.com Mon Apr 26 12:17:36 1999 From: bxqiyh at virtualbanner.com (bxqiyh at virtualbanner.com) Date: Mon, 26 Apr 1999 16:17:36 GMT Subject: Banner Exchange 8313 Message-ID: Has anyone seen that new banner exchange out there. Its called VirtualBanner. They are giving away 25000 free impressions just for signing up. They also have a FULL TIME 2:1 exchange ratio and do banner promotion. Check them out at http://www.virtualbanner.com odxfqsusqfltrtuxbpvihvuwuvbnxswwrdwhhfgsrxpllmuiqiidltnfoqogzpbvhyrerpflwloysukehcucgdfvnbnuybuinc From William.H.Duquette at jpl.nasa.gov Wed Apr 28 10:58:13 1999 From: William.H.Duquette at jpl.nasa.gov (William H. Duquette) Date: Wed, 28 Apr 1999 14:58:13 GMT Subject: try vs. has_key() References: Message-ID: <37247ea3.494305@news.jpl.nasa.gov> On Fri, 23 Apr 1999 14:13:59 +0300, Moshe Zadka wrote: >d={} >for word in words: > first_two=word[:2] > d[first_two]=d.get(first_two, []).append(word) > >Unfortunately, few people seem to know about the ``get'' method, which >is really good. This doesn't seem to work. For example, here's a python interpreter session: >>> d = {} >>> a = 'Foo' >>> d[a] = d.get(a, []).append('Bar') >>> d {'Foo': None} >>> I'd have expected to see {'Foo': 'Bar'}, but that's not what I get. I'm using Python 1.5.2, by the way. Will Duquette -------------------------------------------------------------------------- Will Duquette, JPL | William.H.Duquette at jpl.nasa.gov But I speak only | http://eis.jpl.nasa.gov/~will (JPL Use Only) for myself. | It's amazing what you can do with the right tools. From gscot at my-dejanews.com Thu Apr 8 12:28:16 1999 From: gscot at my-dejanews.com (gscot at my-dejanews.com) Date: Thu, 08 Apr 1999 16:28:16 GMT Subject: POST request Message-ID: <7eilen$g9o$1@nnrp1.dejanews.com> To All: I would like to write a short program that would play a game found on the Internet. I cannot find any documentation on how to make a POST request. It is a stock market game. You fill out a form with the symbol and number of share you want to buy or sell. The form uses the POST method to send the data. Since I cannot just put this information in the url I am not sure how to write a program to automate this procese. Is there any way to do that with Python. Thank you for your help. Gary -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From roy at popmail.med.nyu.edu Wed Apr 14 11:28:18 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Wed, 14 Apr 1999 11:28:18 -0400 Subject: forking + stdout = confusion References: <87n20caldg.fsf@spock.localnet.de> Message-ID: clarence at silcom.com (Clarence Gardner) wrote: > That does indeed do the trick, but you probably had to os.close(2) also. > (Both stdout and stderr normally are piped into Apache.) I don't know how all Apaches work, but at least on our machine, cgis get pipes for stdin and stdout, but stderr is connected directly to the error log file. I wrote a little test cgi which is just: > #!/bin/sh > sleep 300 opened http://my.host.name/cgi-bin/roy/sleeper.cgi and ran lsof, which is a neat utility which mucks about in the kernel's file tables and shows you what files a process has open. I got: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME sleep 25247 nobody 0r FIFO 0x04a6ff00 0 22787 sleep 25247 nobody 1w FIFO 0x04096e00 0 22788 sleep 25247 nobody 2w VREG 3049,395040 4420204 90 /www/logs/error_log -- Roy Smith New York University School of Medicine From davecook at home.com Thu Apr 29 06:13:48 1999 From: davecook at home.com (David M. Cook) Date: Thu, 29 Apr 1999 10:13:48 GMT Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> <7g99pj$b1$1@news.worldonline.nl> Message-ID: On Thu, 29 Apr 1999 11:54:58 +0200, Ilja Heitlager wrote: >OK, A UNIX guy (that will change ;-) Yes, soon you will *all* be Linux guys. Resistance is futile. You will be assimilated. Now to add something to the discussion, you might want to check out Extreme programming: http://c2.com/cgi/wiki?ExtremeProgrammingRoadmap It seems to be popular with SmallTalk people. Dave Cook From nhead at esoc.esa.de Mon Apr 26 03:21:18 1999 From: nhead at esoc.esa.de (Nigel Head) Date: Mon, 26 Apr 1999 09:21:18 +0200 Subject: precompiled MySQL.pyd anyone ? (NT workstation) References: <7fsu50$bss$1@nnrp1.dejanews.com> Message-ID: <372413EE.A2DE88C8@esoc.esa.de> I too have moved away from MySQL at the moment so I don't have any newer version than Jeff. In fact, Jeff probably has the only version as I seem to have misplaced my copies :-( Nigel. PS: Planning says I'll be back on MySQL July time frame .... I'll have to catch up on the version changes then (if s'one else hasn't already done it that is!). sweeting at neuronet.com.my wrote: > > Digging up a previous thread but asking anyone working on NT/Win32 : > is there a precompiled MySQL.pyd anywhere ? Have checked the starship > members' pages and python site without luck. [...] > >I have a copy of Nigel Head's (?) win32/MySQL dynamic > >link libraries: libmySQL.dll and MySQL.pyd. I've used [...] > > > >Jeff Bauer From a.eyre at optichrome.com Mon Apr 19 04:27:14 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Mon, 19 Apr 1999 08:27:14 GMT Subject: #!/usr/bin/env python -u In-Reply-To: <37175574.25EBDDBE@stuco.uni-klu.ac.at> References: <37175574.25EBDDBE@stuco.uni-klu.ac.at> Message-ID: <000501be8a3e$6e7269f0$2bcbd9c2@optichrome.com> > (I need the -u for unbuffered output) but when creating RPM files the > final rpms needs /usr/local/bin/python. How about a hack like this: import sys class UnbufferedStdout: def __init__(self, stdout): self.stdout = stdout def write(self, arg): self.stdout.write(arg) self.stdout.flush() sys.stdout = UnbufferedStdout(sys.stdout) -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From tomjenkins at my-dejanews.com Tue Apr 27 15:00:26 1999 From: tomjenkins at my-dejanews.com (tomjenkins at my-dejanews.com) Date: Tue, 27 Apr 1999 19:00:26 GMT Subject: GUI other than Tkinter References: <3721567f.1748033@news> <372360df.5406764@news.teleweb.at> Message-ID: <7g51g7$9m8$1@nnrp1.dejanews.com> In article <372360df.5406764 at news.teleweb.at>, e9025657 at stud3.tuwien.ac.at wrote: > >As far as I know, GTk has not been ported to the Win32 platform, yet. > thats not correct. have a look at > > http://user.sgic.fi/~tml/gimp/win32/ > > kaweh > While its true that GTK is being ported to Win32, I don't think that pyGTK can be used on Win32 yet. (for one there is a GTK.py and a gtk.py in the distribution, hmmm tain't gonna work on winders) Tom -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From Vladimir.Marangozov at inrialpes.fr Wed Apr 7 23:56:52 1999 From: Vladimir.Marangozov at inrialpes.fr (Vladimir Marangozov) Date: Thu, 08 Apr 1999 05:56:52 +0200 Subject: Chaning instance methods References: Message-ID: <370C2904.A6F4BD54@inrialpes.fr> Jody Winston wrote: > > I don't understand how to change instance methods. For example: > ... > What am I forgetting? On a first thought, you seem to forget Python's internals (that you're supposed to forget, BTW) and people helped you generously on this by introducing you, and me, to trickery. On a second thought, I'll follow their example ;-) but I'll try to do it the easy (OO) way; it's easy enough not to be described so far, but it seems more logical to me, so here goes. If Foo is a class and f is an instance of Foo, by changing the instance method f.m (for whatever insane reason), one augments f's behavior beyond the limits prescribed by Foo. By doing so, one withdraws f from the set of "similar" objects, instances of Foo, that share a common set of properties (operations), defined by the Foo class. (right, this is Object theory). Indeed, f becomes some particular object which is no more part of the Foo gang. Pushing that further, we have reasons to believe that after the change, we're in a situation where f belongs to some Bar gang, where Foo and Bar differ only in the 'm' method, just like if f were an instance of Bar from the start. In fact, it is Bar that has the desired augmented interface, not f. Bar is the incarnation of the desired incremental code evolution done the OO way through class inheritance (not with instance hacking). Thus we arrive at the easy & boring solution, which goes along these lines: (it's an instance hack too, but a recognized one in metaobject communities) >>> class Foo: ... def m(self): ... print "Foo.m" ... >>> f = Foo() >>> f.m() Foo.m >>> >>> def m2(self): ... print "m2" ... >>> class Bar(f.__class__): pass ... >>> Bar.m = m2 >>> >>> f.__class__ = Bar # f changes its camp >>> f.m() m2 Since we do ignore Python's internals, we do not notice that the price to pay by f for deserting the Foo gang & joining Bar's is an additional level of indirection for all accesses to Foo's methods. The good news are that if f is really a rebel instance and it wants to change camps frequently, one can use the dedicated Bar proxy class for storing new methods at will, without affecting Foo, nor its instances. In a sense, this also avoids the tricky solutions resulting from peculiarities of the class/instance implementation -- a good candidate for major changes in Python2. We won't escape these changes, unless we manage to increase bus traffic around CNRI or so ;-) To make a long story short, what you're trying to do is not very cool, so perhaps you don't get truly cool answers, but still, you can do it in Python. Fortunately, what you're asking here is not common practice, I hope! -- Vladimir MARANGOZOV | Vladimir.Marangozov at inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From jbauer at rubic.com Tue Apr 13 11:30:24 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Tue, 13 Apr 1999 15:30:24 GMT Subject: rfc822 date header Message-ID: <37136310.62A6BE1A@rubic.com> Jeremy Hylton wrote: > If you write it, I'll lobby :-). As a first pass, we could do lots worse than Chris Lawrence's GMT version (untested). def strdate(self, timeval=None): from time import gmtime, strftime, time if timeval is None: timeval = time() return "Date: %s" % strftime('%a, %d %b %Y %H:%M:%S GMT', gmtime(timeval)) -Jeff From scothrel at cisco.com Fri Apr 16 11:06:05 1999 From: scothrel at cisco.com (Scott Cothrell) Date: Fri, 16 Apr 1999 10:06:05 -0500 Subject: Change for compiling 1.5.2 on Windows NT Alpha References: <7f6l71$20e$1@towncrier.cc.monash.edu.au> Message-ID: <7f7je1$8t9$1@news-sj-3.cisco.com> Jonathan Giddy wrote in message <7f6l71$20e$1 at towncrier.cc.monash.edu.au>... >"Scott C" writes: > >>There needs to be the following change in file fpectlmodule.c, line 163: > >>Line currently reads: #elif defined(__alpha) > >>line should read: #elif defined(__alpha) && !defined(_MSC_VER) > >Or to follow the comments more obviously, change it to >#elif defined(__alpha) && defined(__osf__) > >Jon. Ya, that'd work :o) From bernhard at alpha1.csd.uwm.edu Tue Apr 20 13:19:05 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 20 Apr 1999 17:19:05 GMT Subject: Quick fix to add "+=" References: <3717AB14.2926AF76@mediaone.net> <3717EE20.41343593@mediaone.net> Message-ID: On Tue, 20 Apr 1999 05:06:00 -0700, Fuming Wang wrote: >On 17 Apr 1999, Bernhard Reiter wrote: >> For vim, the following does the trick (without the special word matching caps >> new vim versions provide. the ":noh is for people using hlsearch in >> vim 5.x version.) >> >> :map!^[:s/\([a-zA-Z_][a-zA-Z0-9_]*\)$/\1=\1+/^M:noh^MA >This works for me, except I got "no mapping found" when I enter the >suggested command. I am using vim 5.3. Is this the problem? uh, I have been not precise enough and just outlined the idea. :map! += ^[:s/\([a-zA-Z_][a-zA-Z0-9_]*\)$/\1=\1+/^M:noh^MA Where ":" means go into vim Commandmode "^[" means Esc, you have to enter it pressing Ctrl-v and then Esc "^M" means "Return', you have to enter pressing Ctrl-v and then Return Does that help? :) Bernhard From htrd90 at zepler.org Thu Apr 8 16:38:00 1999 From: htrd90 at zepler.org (Toby Dickenson) Date: Thu, 08 Apr 1999 20:38:00 GMT Subject: COM Event Sinks and Connection Points in Python References: <7eggfh$o0f$1@nnrp1.dejanews.com> <7egnl2$ca5$1@m2.c2.telstra-mm.net.au> Message-ID: <3711134d.17632096@news.freeserve.net> (posted, and copied to Mark) "Mark Hammond" wrote: > >cingram at my-dejanews.com wrote in message ><7eggfh$o0f$1 at nnrp1.dejanews.com>... >>I am trying to use functionality from a DLL that requires me to create a >COM >>event sink so that it can call back with events. I am trying to write this >>event sink in Python. However, when I try to create a SimpleConnection >>object, it gives this exception: "Unable to open the access token of the >>current thread". > >There appears to be some problem using connection points from Python.exe. >Some objects - mainly OCX controls - only fire event when running inside >Pythonwin as an OCX. For controls this is to be expected. They are allowed to be fairly non-functional until activated, which requires a control site. They might implement IDispatch, but they can not be used a 'just' an automation server. >The "threading bug" I mention isnt the same as this. The threading bug will >actually cause Python to die completely with an access violation. I am >fairly certain they are not related. I read that comment a while ago, and Ive been meaning to investigate since then. Well, my next project will be using events, and this post reminded me, so I thought I would take a look. If I remove the extra 'return' from testPyComTest.py then I always get a Fatal Python error: PyThreadState_Get: no current thread Is this the bug you mean? I think I have some answers.... I believe this problem is not caused by a bug in pythoncom, but by several bugs in PyCOMTest, the C++ server that complements this test harness. In PyCOMImpl.cpp, line 49, a new thread is started. That thread uses the Fire method of the CPyCOMTest object, however this breaks the COM apartment rules. To pass an object reference across apartments you need to use CoMarshalInterThreadInterfaceInStream, at least once. Secondly, the new thread does not call CoInitializeEx. Hopefully I will have time to dig further next week. I hope this helps, Toby Dickenson From mal at lemburg.com Fri Apr 9 11:53:57 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 9 Apr 1999 15:53:57 GMT Subject: OpenSSL/X.509 References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <3709C8BE.4257C9F1@lemburg.com> <14090.16807.950025.496495@bitdiddle.cnri.reston.va.us> <370A78B6.2C18D10F@lockstar.com> <370BE48E.2BA9750C@lemburg.com> <370E3C56.D035A3FB@lockstar.com> Message-ID: <370E2295.31A119F0@lemburg.com> Mordy Ovits wrote: > > M.-A. Lemburg wrote: > > > >>I have a fairly complete SWIGing of OpenSSL/SSleay working. I made it on > >>company time, so I have to get company permission to release it. If there is > >>real interest, I'll push for us to release it. It does all the X.509 stuff, is > > > very OO, and builds on win32 and unices. > > > Interested? > > > > Sure, but if your company is US based, then chances are high > > you won't be able to share the code outside the US... that's > > why I started mxCrypto, BTW.\ > > That's debatable. The SWIG bindings contain no crypto code in their own right. > It is merely glue to crypto code. I wouldn't be able to release statically > prebuilt libraries, but why would I want to anyway? Our lawyers keep waffling > on this, which is why I haven't released it already. I'm really pleased with > it, and would love give something back to the Python community. How > long before we Americans are reduced to doing Crypto with a deck of cards? (See > Bruce Schneier's Solitaire). Well, the NCSA folks did something similar in their WWW server (they included bindings to some crypto-lib for authentication) and were called back by the NSA... but maybe the situation is different now. -- Marc-Andre Lemburg Y2000: 266 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From mal at lemburg.com Fri Apr 23 05:43:34 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 23 Apr 1999 09:43:34 GMT Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> Message-ID: <372040C6.76C8320B@lemburg.com> Thooney Millennier wrote: > > Hello Everyone! > > 2. stream class > e.g. cout << "hello python."<>> import StringList,sys >>> cout = StringList.StringList() >>> endl = '\n' >>> cout << "hello python" << endl StringList: ['hello python', '\012'] >>> cout.pack() >> sys.stdout hello python -- Marc-Andre Lemburg Y2000: 252 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From tjreedy at udel.edu Sat Apr 24 21:58:48 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 25 Apr 1999 01:58:48 GMT Subject: wrapped around the axle on regexpressions and file searching References: <7frhe0$8g1$1@nnrp1.dejanews.com> Message-ID: <7ftsso$r0$1@news.udel.edu> [code to find and process files ending in .log] >2. is there a better, faster way of doing this??, For matching literal text, string.find, .rfind, .index, .rindex are faster that regexes. Since you want to match text at end only, if filename[-4:] == '.log' will be even faster. TJR From nickb at earth.ox.ac.uk Tue Apr 13 06:48:20 1999 From: nickb at earth.ox.ac.uk (Nick Belshaw) Date: Tue, 13 Apr 1999 11:48:20 +0100 Subject: How libpython1.5.so Message-ID: <371320F4.5338600B@earth.ox.ac.uk> If anyone can spare a second - Whilst trying to get Python plugins to work on Gnumeric-0.23 I bumped up against the need for libpython1.5.so.0.0.0 I have 'The Full Python' ( - thats the sequel to 'The Full Monty' !!! ) and can build xxxx.a no problem but what do I have to do to get xxxx.so Can't seem to find anything specific on it in the docs or readme or Setup and my knowledge is too superficial to allow me to be clever. Help anyone? cheers Nick/Oxford Geochemistry From tim_one at email.msn.com Thu Apr 29 03:07:17 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 29 Apr 1999 03:07:17 -0400 Subject: converting perl to python - simple questions. In-Reply-To: Message-ID: <000e01be920e$ea9e6880$199e2299@tim> [Aahz Maruch] > ... > Perl 5 has been out for more than two years, and there are so many > improvements that I don't know of *anyone* who's doing new work > in Perl 4. I do -- one crusty Unix sysadmin in particular who doesn't trust "all that new stuff", still using his "better the devil you know" old Perl4. He won't use Python either. I subscribe him to functional-language mailing lists just to keep him off balance . perl-has-72-iterations-to-go-to-catch-up-to-fortran77-ly y'rs - tim From trashcan at david-steuber.com Wed Apr 28 03:23:49 1999 From: trashcan at david-steuber.com (David Steuber) Date: 28 Apr 1999 03:23:49 -0400 Subject: Designing Large Systems with Python References: <3725CA37.2027327D@lemburg.com> Message-ID: "M.-A. Lemburg" writes: -> Not sure what your "cowboy" style looks like, but Python is just -> great for designing well-organized OO apps with components using -> pattern paradigms [...add all your favorite buzzwords here...]. Try to imagine object oriented spaghetti. This is what happens when analysis, design, and coding all happen at the same time. -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. So as your consumer electronics adviser, I am advising you to donate your current VCR to a grate resident, who will laugh sardonically and hurl it into a dumpster. Then I want you to go out and purchase a vast array of 8-millimeter video equipment. .. OK! Got everything? Well, *too bad, sucker*, because while you were gone the electronics industry came up with an even newer format that makes your 8-millimeter VCR look as technologically advanced as toenail dirt. This format is called "3.5 hectare" and it will not be made available until it is outmoded, sometime early next week, by a format called "Elroy", so *order yours now*. -- Dave Barry, "No Surrender in the Electronics Revolution" From aa8vb at vislab.epa.gov Fri Apr 23 08:37:14 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 23 Apr 1999 12:37:14 GMT Subject: Pointers to variables In-Reply-To: <021801be8d86$0d3ba7a0$f29b12c2@pythonware.com>; from Fredrik Lundh on Fri, Apr 23, 1999 at 02:37:27PM +0200 References: <19990422121403.A279051@vislab.epa.gov> <19990423080721.A344578@vislab.epa.gov> <021801be8d86$0d3ba7a0$f29b12c2@pythonware.com> Message-ID: <19990423083714.A321566@vislab.epa.gov> Fredrik Lundh: |> but this one doesn't: |> |> (3) min = 0 |> max = 0 |> for ( var, val ) in [( min, 1 ), ( max, 100 )]: |> var = val | |here, you tell python to change the binding for the name "var" |in the local name space so it points to the same thing as the |name "val". Ahh (light bulb goes on). Makes sense. I should have seen that (need my morning caffeine). When the "for" iterates, var is really an alias for min and max's storage -- what you want. But the problem is you can't "change" the value of storage with assignment to var (that just rebinds var). And Python being "pointerless" there is no: *var = val or: memcpy( var, val, sizeof(*var) ) -like construct. So you have to resort to other means (setattr). |> So basically this is just a little asymmetry in the language. Putting a |> variable in a list/tuple (valueof(var)) performs a shallow copy rather than |> a deep copy. | |nope. content is never copied. only references. all the time. |perfect symmetry. Thanks. Randall From lutz at rmi.net Sun Apr 4 15:48:29 1999 From: lutz at rmi.net (Mark Lutz) Date: Sun, 4 Apr 1999 13:48:29 -0600 Subject: Rat sighting online Message-ID: <7e8fd3$er2$1@news1.rmi.net> jkraai at murl.com writes about Learning Python: > I can't resist, can we refer to it as: > > _Nixon_in_a_Nutshell_? I don't care how you refer to it, as long as you do ;-). --Mark Lutz (http://rmi.net/~lutz) From lvirden at cas.org Tue Apr 6 08:10:21 1999 From: lvirden at cas.org (lvirden at cas.org) Date: 6 Apr 1999 12:10:21 GMT Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <7e30fp$8vf$1@news1.rmi.net> <14085.18282.936883.727575@bitdiddle.cnri.reston.va.us> Message-ID: <7ectjd$516$1@srv38s4u.cas.org> According to Jeremy Hylton : :This is really useless information, but I guess I along with most :Title Amazon.com Sales Rank :Learning Python 1,570 :Programming Python 1,685 :Python : Pocket Reference 3,218 :Internet Programming With Python 8,720 :Mastering Regular Expressions 931 :Programming Perl, 2nd ed. 81 :Perl Cookbook 136 :The C Programming Language 478 :The C++ Programming Language 1,003 :Tcl and the Tk Toolkit 3,362 Elsewhere in this thread there have been discussions regarding the fact that it's been several years since the last major Python book was released. However, notice that the C Programming Language book is in the top 500 and it is quite a few years old! Same for the Tcl and the Tk Toolkit book - that reflects Tcl 7.3 (5 or so yrs ago) and people are still buying it... -- Quote: Saving the world before bedtime. <*> O- Unless explicitly stated to the contrary, nothing in this posting should be construed as representing my employer's opinions. From peter.stoehr at weihenstephan.org Sat Apr 24 16:34:46 1999 From: peter.stoehr at weihenstephan.org (Dr. Peter Stoehr) Date: Sat, 24 Apr 1999 22:34:46 +0200 Subject: Python and "Hand held" computers Message-ID: <37222AE6.E6C8F713@weihenstephan.org> Hi Python-Fans, I'm a great fan of python and I'm now looking for an hand held computer (something smaller than a laptop) that can be programmed with python. Is there a WEB page or any other place were I can find information about this topic? Thanks in advance Peter -- --------------------------------------------------------------------------- Dr. Peter Stoehr --- Teisenbergweg 6 --- 85435 Erding --- 08122/47232 --------------------------------------------------------------------------- I'm the terror that flaps through the night From news at helen.demon.nl Tue Apr 27 08:29:35 1999 From: news at helen.demon.nl (Ilja Heitlager) Date: Tue, 27 Apr 1999 14:29:35 +0200 Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> Message-ID: <7g4a3l$atk$1@news.worldonline.nl> >What I am wondering about is the suitability of Python for specifying, >a large system and building a prototype. I have gotten myself rather >entrenched in the cowboy style and I would love it if Python supported >that for larger systems. My first contacts with Python were with JPython. I got interested for it's use in unit-testing Java-classes. Now I am building prototypes with C-Python and I love it. Both the C and Java versions allow me to harden the code and transform the Proto to production code, if speed is necessary To build larger systems you need classes and modules for abstraction and reuse. To build proto's you need interactive programming and short code-debug cycles. Need GUI's? MFC or tcl/tk? Networking, Parsers, XML, HTML, regex? ehh, Python? > One other thing. Is the documentation that comes with Python > sufficient to gain mastery of the language, or should I consider > buying (yet) another book? The online-documentation and examples were sufficient for me, but I love paper refs and everbody should have Programming Python From bwarsaw at python.org Thu Apr 29 18:46:57 1999 From: bwarsaw at python.org (bwarsaw at python.org) Date: Thu, 29 Apr 1999 18:46:57 -0400 (EDT) Subject: New JPython domain and website Message-ID: <14120.57697.662134.718114@anthem.cnri.reston.va.us> JPython users, I'm please to announce the new Web site for JPython, the 100% Pure Java implementation of Python. Please come visit http://www.jpython.org/ and update your links. The old site still exists but it will not be updated and will eventually go away. My thanks to Cathy Rey of CNRI for her help in getting the new site looking so good. A few other notables: - I'm starting a new bugs database using Jitterbug. The old bug reports won't (yet?) be converted but you should use the new system to report any future bugs. The URL for this is http://www.jpython.org/jpython-bugs - The next release of JPython will be covered by a new license, which I believe is more "open". All existing releases of JPython are still covered under the old license, but there will be a new release soon. For more information, please see http://www.jpython.org/newlicenses.html We also have updated permission forms for contributions (which we're encouraging!). See http://www.jpython.org/bugrelease.html for more information. - I'd like to collect a list of JPython users, similar to the one maintained for Python itself. If you're interested in being listed, please see http://www.jpython.org/Users.html Enjoy, and stay tuned for announcements of the next release. -Barry From joe at strout.net Fri Apr 23 20:19:14 1999 From: joe at strout.net (Joe Strout) Date: Fri, 23 Apr 1999 17:19:14 -0700 Subject: I NEED MAJOR HELP References: Message-ID: [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] In article , sportsnutz wrote: > Ive never programmed before and i need some tips on some command to work > this thing Tip #1: when you have a problem, ask a SPECIFIC question. Include what exactly you're trying to do, what kind of computer you're trying to do it on, what you've tried already, and what happened. Cheers, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From gony at my-dejanews.com Tue Apr 27 23:14:27 1999 From: gony at my-dejanews.com (gony at my-dejanews.com) Date: Wed, 28 Apr 1999 03:14:27 GMT Subject: HELP - FTP seesions using python???????? References: <7g328l$hga$1@nnrp1.dejanews.com> Message-ID: <7g5ueh$3pt$1@nnrp1.dejanews.com> thanks for the samples I'll work my way through them and figure out what they do and how they do it another small question in perl the #!/usr/local/bin/perl is not needed when run on a windows machine, does it matter for Python on a windows machine whether this line is present or not? In article , aahz at netcom.com (Aahz Maruch) wrote: > In article <7g328l$hga$1 at nnrp1.dejanews.com>, wrote: > > > >any links or tips etc on how to tackle automation of FTP sessions using python > >would be most appreciated. > > Here's a sample; there aren't any comments (proof that Python can be > almost as obscure as Perl ;-), but it shouldn't be *that* hard to read: > > #!/usr/local/bin/python > > import sys, os, ftplib, string > > def getpass(prompt = "Password: "): > import termios, TERMIOS, sys > fd = sys.stdin.fileno() > old = termios.tcgetattr(fd) > new = termios.tcgetattr(fd) > new[3] = new[3] & ~TERMIOS.ECHO # lflags > try: > termios.tcsetattr(fd, TERMIOS.TCSADRAIN, new) > passwd = raw_input(prompt) > finally: > termios.tcsetattr(fd, TERMIOS.TCSADRAIN, old) > print > return passwd > > if len ( sys.argv ) < 4 : > raise 'Must have three arguments: host[:path], user[:passwd], and file' > > HostPath = sys.argv[1] > pos = string.find ( HostPath, ':' ) > if pos > 0 : > host = HostPath[0:pos] > if ( pos + 1 ) == len ( HostPath ) : > path = "" > else: > path = HostPath[(pos+1):] > else : > host = HostPath > path = "" > > UserPass = sys.argv[2] > pos = string.find ( UserPass, ':' ) > if pos > 0 : > user = UserPass[0:pos] > if ( pos + 1 ) == len ( UserPass ) : > passwd = "" > else: > passwd = UserPass[(pos+1):] > else : > user = UserPass > passwd = getpass() > > filename = sys.argv[3] > pos = string.rfind ( filename, '/' ) > if pos > 0 : > basename = filename[pos:] > else : > basename = filename > > fd = open ( filename ) > ftp = ftplib.FTP ( host, user, passwd ) > ftp.cwd ( path ) > ftp.storbinary ( 'STOR %s' % basename, fd, 1024 * 16 ) > ftp.close() > > fd.close() > -- > --- Aahz (@netcom.com) > > Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ > Androgynous poly kinky vanilla queer het > > Hi! I'm a beta for SigVirus 2000! Copy me into your .sigfile! > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From japiinfo at aol.com Wed Apr 21 15:40:51 1999 From: japiinfo at aol.com (Japiinfo) Date: 21 Apr 1999 19:40:51 GMT Subject: Y2K Message-ID: <19990421154051.04475.00000063@ng-fz1.aol.com> Automatic Year 2000 data conversions/code verifications available from Japi Info Corporation. Free demos available. For more information, please visit our web site at: www.japiinfo.com or send us an E-mail to: y2k at japiinfo.com From Lance_Ellinghaus at marshall.com Wed Apr 7 19:03:15 1999 From: Lance_Ellinghaus at marshall.com (Lance Ellinghaus) Date: Wed, 7 Apr 1999 23:03:15 GMT Subject: oracledb-0.1.2 and python 1.5.2b2 Message-ID: <8825674C.007EA461.00@marshall.com> I got it to compile by adding the necessary makefile rules from a previous makefile into the makefile that is installed from 1.5.2b2. Once that was done, everything compiles fine. Sorry for taking list space. Lance -------From: Lance Ellinghaus on 4/7/99 3:59:40 PM------- From: Lance Ellinghaus To: python-list cc: Subject: oracledb-0.1.2 and python 1.5.2b2 Has anyone gotten these two things to compile together and run? I am having trouble with the compile. Looks like something changed in the Makefile on Python 1.5.2b2 from previous python make files that makes oracledb-0.1.2 not compile. Can anyone help?? Thanks, Lance From tismer at appliedbiometrics.com Fri Apr 30 09:02:43 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 30 Apr 1999 13:02:43 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <7g9qmo$luf$1@news.udel.edu> <372965CA.2B3FD2FE@appliedbiometrics.com> <19990430080805.B776752@vislab.epa.gov> Message-ID: <3729A9F3.75B2692B@appliedbiometrics.com> Randall Hopper wrote: > > Christian Tismer: > |Terry Reedy wrote: > |> A batch-mode optimizer analyzing an entire file (module) should be able to > |> detect whether or not function names are rebound. > |> > |> Perhaps module bindings should be considered immutable from outside the > |> module unless explicitly declared otherwise. > | > |I'm thinking of no new keyword, but a mechanism which allows me to lock a > |namespace somehow. > > I like this idea in concept. Though I would prefer a way to have > namespaces "lock by default". Examples: After a class definition, the > class function dictionary is locked. After a module is fully read, all > references are bound and the module namespace is locked. etc. Well, I wouldn't do that by default. By default, everything could stay as it is. First of all, this would not break any existing code. Then, many people will want to fine tune their modules, and they are perhaps not done after a class definition was ready. Then, what would you do with classes which depend on each other? You cannot lock them immediately, this would fail. Locking them after they both are defined is fine, since everything is defined then. With minimum effort and no language changes, this will be needed. Then think of all the more difficult systems which need more effort to become configured. The xml parsers together with SAX are an example. If I wanted to lock this, then this must be done with care. One would also not lock the mixin classes, but only the final workhorse class, bound with the correctly selected parser, and so on. It might also be necessary to find a way to specify which attributes may be locked and which not, since there exist indeed cases where Python's super-flexibility is needed :-) Depending on how exactly will be implemented, a single line at the end of a module should suffice to accomplish this stuff for the standard cases. Fine adjustment would take a little more. As a side effect, locking a module would also find all referenced but undefined symbols. Anyway, this is still no cakewalk and quite a lot of code is involved. Needs much more thinking... ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 akuchlin at cnri.reston.va.us Wed Apr 28 09:11:03 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Wed, 28 Apr 1999 09:11:03 -0400 (EDT) Subject: Python implementation of tar In-Reply-To: <372595AE.C27E7E50@phoenix-edv.netzservice.de> References: <7ftjjl$tim$1@nnrp1.dejanews.com> <372595AE.C27E7E50@phoenix-edv.netzservice.de> Message-ID: <14119.2190.827661.960717@amarok.cnri.reston.va.us> Holger Jannsen writes: >frankmcgeough at my-dejanews.com schrieb: >> Does someone has a tar implementation written in Python? Try Clement Hintze's tarlib.py: ftp://ftp.python.org/pub/python/contrib/System/tarlib.py -- A.M. Kuchling http://starship.python.net/crew/amk/ Things have been a little turbulent of late. *Late* being the operative word. -- Cain watches the Dreaming crumble, in SANDMAN #67: "The Kindly Ones:11" From david_ascher at yahoo.com Tue Apr 13 15:21:03 1999 From: david_ascher at yahoo.com (David Ascher) Date: Tue, 13 Apr 1999 19:21:03 GMT Subject: New Python Book err on Page 265 Message-ID: <19990413192103.6940.rocketmail@web606.mail.yahoo.com> --- Sam Schulenburg wrote: > I received the new Programming Python book Just for accuracy's sake, it's called "Learning Python" -- it is not a new edition of Mark's Programming Python. > and found an error on Page 265 in > the get_temperature(country,state,city) function. Thanks for the bug report (I wouldn't be surprised if it's due to a change in the web page format -- as we presciently =) talk about in our description of the program in the text -- then again, it could also be a production bug). We'll add your fix to the errata page, probably kept at Mark's site. In general, I suggest that bug reports about the book be sent directly either to Mark Lutz (lutz at rmi.net) or myself (da at python.net). No need to clutter the list with them. --David Ascher === --david ascher da at ski.org is my permanent address -- use it instead of david_ascher at yahoo.com _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From paul at prescod.net Tue Apr 27 13:51:25 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 27 Apr 1999 17:51:25 GMT Subject: RE's in Python syntax References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <37215EFB.433AFCA6@prescod.net> <3724B2D6.B468687A@prescod.net> <37252816.42634501@Lugoj.Com> Message-ID: <3725F91D.4F9D6373@prescod.net> Roy Smith wrote: > > The thread was moving in the direction of "my program using regex is too > slow, and I think the solution would be to move regex into the python core > to make it faster". I was just pointing out why that is flawed reasoning. But it isn't flawed reasoning. There are many arguments for moving something into the core and many arguments for keeping something OUT of the core, and "performance in the hands of a newbie" strikes me as a valid argument for inclusion. Simplicity of expression is another. I also completely understand the arguments *against* built-in REs. I haven't pushed this proposal because I realize that the costs and benefits are about equal. Had you enumerated the costs I would have agreed and the thread would be over. What I read in your message was an attempt to deprecate an entire class of benefit: performance in the hands of newbies. I personally think that this is one of the factors that we should continue to try and balance. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Microsoft spokesman Ian Hatton admits that the Linux system would have performed better had it been tuned." "Future press releases on the issue will clearly state that the research was sponsored by Microsoft." http://www.itweb.co.za/sections/enterprise/1999/9904221410.asp From nothing at nowhere.com Sun Apr 18 14:30:23 1999 From: nothing at nowhere.com (-------------) Date: Sun, 18 Apr 1999 13:30:23 -0500 Subject: Parsing C++ headers with Python Message-ID: <371A24BF.E3341937@nowhere.com> As part of an effort to make our documentation more automatic (at least to the degree that we can generate reports on header changes), I'd like to be able to parse out c++ headers from Python. I'm not looking for "complete" parsing abilitiies-- the parser can assume that the headers are syntactically correct, can ignore most macro preprocessors, etc. etc. Does anyone know of a package to do this? Does anyone have a good set of regular expressions to do this? Please email responses to ken at be.com, as unfortunately I don't get much of a chance to read newsgroups-- the connection to a newsgroup server from home is currently slow, and there is no newsgroup server at work. Thanks in advance! Ken McDonald Tech Writer, Be, Inc. ken at be.com From davecook at home.com Sat Apr 17 11:18:43 1999 From: davecook at home.com (David M. Cook) Date: Sat, 17 Apr 1999 15:18:43 GMT Subject: Beginner - Tkinter info References: <371c59e9.2723125@news.tin.it> Message-ID: On Sat, 17 Apr 1999 09:53:48 GMT, Kranio wrote: >Where I can find some example of both python and tkinter? Try http://www.pythonware.com Dave Cook From jam at newimage.com Mon Apr 26 08:18:42 1999 From: jam at newimage.com (jam) Date: Mon, 26 Apr 1999 08:18:42 -0400 Subject: timeout on urllib.urlopen? In-Reply-To: ; from Steffen Ries on Mon, Apr 26, 1999 at 07:59:50AM -0400 References: <7g0r7c$gn9$1@nnrp1.dejanews.com> <19990426061959.A18551@toast.internal> Message-ID: <19990426081842.C18551@toast.internal> On Mon, Apr 26, 1999 at 07:59:50AM -0400, Steffen Ries wrote: > > I used once SIGALRM to force a timeout. Maybe somebody could comment > on that approach? > > > /steffen > [..snipped code..] greetings, all well and good (the more ideas the better), except that if something goes wrong, all you get is that a timeout happened within 120 seconds.. with the 'select' approach, you have a chance to record the specific error that the socket had.. sometimes the server is down ('connection refused'), sometimes the web server itself is having problems, sometimes the network is down, etc.. you can import additional 'errno' symbols and trap them if necessary, and even specify a timeout to the select call, so you can trap that seperately as well. hope that helps. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From illume at gmx.net Thu Apr 22 05:43:10 1999 From: illume at gmx.net (Paul Kunysch) Date: 22 Apr 1999 11:43:10 +0200 Subject: bzip2 module for Python References: Message-ID: <87emldous1.fsf@illusion.tui-net> Laurence Tratt writes: Hi > [me 'announcing' pyBZlib] > >> As I said, I am interested to know if there is a demand for this, so > >> comments are appreciated. >> IMHO it would be nice to have a module like the current "gzip", which >> handles .bz2 .gz .Z and uncompressed files transparently. > Do you mean you would like to see a module where you give it a file (which > could be .bz2, .gz, .zip etc), and then get an uncompressed version back > without worrying what compression type was used? Yes. Well, not ".zip", since it's an archive, and not a compressed file. But please support plain uncompressed files, too. Why should a programmer use different interfaces if one could do everything? > Would you also want it to automatically untar files? Didn't think about it. Depends on the syntax. If it's easy enough that the user of our programs can specify some files as an tar-comonent without breaking existing code, why not. ( "somewhere/webmirror.tar.bz2/index.html" ? ) Hiding the "bzlib-functions" in the "urllib" might be more usefull. For example I'm currently playing around with Debian-Packages-files. They describe the contents of FTP-Sites. I just have to read them once, they could be located anywhere and they might be compressed. Debian doesn't use bz2 right now, but if they decide to do so in a year or two (when all computers have enough RAM) it would be great if a user could still use the old python-scripts. In a perfect world the this code ... file = sys.stdin.readline() fd = urllib.open(file) ... should work with "text" and with "rdist://some.ipv6.url/text.bz2" as input. We might expect from the user that he installs some modules (for uncommon things) but it would be nice if they would use the same interface. Bye From barry at scottbb.demon.co.uk Sat Apr 10 13:37:49 1999 From: barry at scottbb.demon.co.uk (Barry Scott) Date: Sat, 10 Apr 1999 18:37:49 +0100 Subject: 1.5.2c1 will not compile on Windows NT SP4 with VC++ 6.0 SP1 Message-ID: <923765974.19722.0.nnrp-03.9e982a40@news.demon.co.uk> I extracted the 1.5.2c1 kit into P:\ python15 error -------------------- VC++ 6.0 gives this error. Fatal error C1083: Cannot open source file: 'P:\Python-1.5.2c1\Modules\reopmodule.c': No such file or directory The file reopmodule.c is not in the kit. Having removed reopmodule.c from the project I get a link error LINK : fatal error LNK1104: cannot open file ".\PC\python_nt.def" This file is also missing. Removing python_nt.def from the project reveals files that need to be added to the project: object\bufferobject.c pc\initwinsound.c modules\_localemodule.c LINK needs winmm.lib added to it. Now I get a python15 built. pyhon error ---------------- The project cannot find python.c fatal error C1083: Cannot open source file: 'P:\Python-1.5.2c1\python\Modules\python.c': No such file or directory There is a extra "python" directory that is not in the kits layout. Fixed by replacing with 'P:\Python-1.5.2c1\Modules\python.c' Same path problem with python15.lib. Fixed by replacing with P:\Python-1.5.2c1\vc40\python15.lib Now I get a python.exe _tkinter ---------- The tk and tcl libs are named tk80.lib and tcl80.lib not tk80vc.lib and tcl80vc.lib. I used the Tcl/Tk that the 1.5.2c1 installation put on my system. Now I have _tkinter.dll How was the kit for Windows built given all the missing or misnamed files? Or is this a side effect of using VC++ 6.0? I also notice that the python.exe was built 8 apr 1999 but report sa dated of 12 Mar 1999 on the interactive command line. BArry From tshort at my-dejanews.com Tue Apr 20 13:56:09 1999 From: tshort at my-dejanews.com (tshort at my-dejanews.com) Date: Tue, 20 Apr 1999 17:56:09 GMT Subject: Installing 1.5.2 on WinNT without Admin privileges? Message-ID: <7fif3n$4m0$1@nnrp1.dejanews.com> Is it possible to install a Python 1.5.2 binary without Admin privileges on Windows NT? - Tom -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From trashcan at david-steuber.com Wed Apr 7 23:45:46 1999 From: trashcan at david-steuber.com (David Steuber) Date: 07 Apr 1999 22:45:46 -0500 Subject: povray.py References: Message-ID: Dave Mitchell writes: -> neat! does it have a documented API? I downloaded the source and -> browsed it for a bit, and don't see any specific extension api.. if -> there isnt one and you're not familiar with the code it would be tough -> to deal with... Are there any similar bindings for other languages -> that you could use for inspiration? If you are talking about the POV-Ray scene description language, it is documented in the POV distribution. All that is needed is to generate the POV sdl based on the computational results from Python, or any other scripting language or programming language for that matter. -- David Steuber http://www.david-steuber.com s/trashcan/david/ to reply by mail If you don't, I won't see it. As long as the answer is right, who cares if the question is wrong? From holger at phoenix-edv.netzservice.de Tue Apr 27 06:47:10 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Tue, 27 Apr 1999 10:47:10 GMT Subject: Python implementation of tar References: <7ftjjl$tim$1@nnrp1.dejanews.com> Message-ID: <372595AE.C27E7E50@phoenix-edv.netzservice.de> Hi there, that's what I'm interested in, too. Please, be so kind to email me the final result of your question. Please. (Cause I'm offline for more than 2 weeks and would miss the answers in this group...) 1000thanx, Holger frankmcgeough at my-dejanews.com schrieb: > > Does someone has a tar implementation written in Python? > > -----------== Posted via Deja News, The Discussion Network ==---------- > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From Friedrich.Dominicus at inka.de Fri Apr 30 01:42:13 1999 From: Friedrich.Dominicus at inka.de (Friedrich Dominicus) Date: Fri, 30 Apr 1999 07:42:13 +0200 Subject: while (a=b()) ... References: Message-ID: <372942B5.729506A6@inka.de> Nathan Clegg wrote: > > I have some deep-rooted "hates" in programming and don't even know where > some of them came from. One of them is "while 1" loops. They seem > somehow at the same level as goto statements and should be used, in my > mind, about as rarely. > > The ideal, of course, would be: > > while (c = curs.fetchone()): ... no definetly not. If you don't like while 1 why don't you try s.th like: false = 0 true = 1 exit = false; while exit != true: > > That is my only complaint about python, that statements cannot be > expressions. I havn't any problems with that. Ok it makes C so terse and it's nice just to write some stuff but I completly dislike the following. if ((fd = fopen("whatever", modus)) == NULL)) /* here is error handling */ or even worse if ((fd1 = fd2 = fopen("whatever", modus)) == NULL)) this clutters this line very much. Where's computation where is error handling this is just one example where in one line too much is mixed together. So better is not having that at all IMO Till then Friedrich From sdm7g at Virginia.EDU Fri Apr 23 21:35:32 1999 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 23 Apr 1999 21:35:32 -0400 (EDT) Subject: Efficient List Subtraction In-Reply-To: <3720EF73.CA7DDEFF@Colorado.edu> References: <3720EF73.CA7DDEFF@Colorado.edu> Message-ID: On Fri, 23 Apr 1999, KELLEY SCOTT T wrote: > > Does anyone out there have a simple way to compare two lists (some operator perhaps) and > return > a list of *differences*? By differences, I mean the following: If had two > lists like, > > a = [1, 4, 5, 100] > b = [4, 5] > > the difference between a and b (a-b) would be [1, 100]. I suppose you could > write a couple of for loops to go through each list and compare them, but I > thought there might be a simple way to do this. > > I'm also interested in a simple way to returning a list of what is identical between the > two lists. > In the case of the above lists, a and b, they both contain [4, 5]. > Well -- it's probably not the most efficient, but the simplest list intersection is probably: >>> a = [1,4,5,100] >>> b = [4,5] >>> filter( lambda x: x in a, b ) [4, 5] >>> filter( lambda x: x in b, a ) # order doesn't matter [4, 5] # for intersection # but it does for set-difference >>> filter( lambda x: x not in a, b ) # b - a [] >>> filter( lambda x: x not in b, a ) # a - b [1, 100] I don't think union or XOR can be done as concisely. ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- Caldera Open Linux: "Powerful and easy to use!" -- Microsoft(*) (*) From chad at vision.arc.nasa.gov Wed Apr 7 16:37:43 1999 From: chad at vision.arc.nasa.gov (Chad Netzer) Date: Wed, 07 Apr 1999 13:37:43 -0700 Subject: Tkinter and centering References: <370B88CF.993D8847@yahoo.com> Message-ID: <370BC217.FFF53A35@vision.arc.nasa.gov> Flbill Blipf wrote: > Hi, > > How do I center a window with Tkinter? If I use this: [Clipped] > > > The window appears in a semi-random location and then staggers to the > center. > > If I remove root.update(), winfo_width and winfo_height both return 1. Well, I don't know if you can ever get the window width and height without first mapping it (displaying). One option is to open it completely off the screen, then update it to the center, but I think many window managers won't do this (it might work on Windows, but not in Motif, etc.) Another option is to open the window as centered as possible, then update to the more correct position, which may be less disconcerting. For example: from Tkinter import * root = Tk() Label(root,text="Cough Cough Cough").pack() sw = root.winfo_screenwidth() sh = root.winfo_screenheight() w = 120 h = 30 newGeometry='+%d+%d' % ((sw/2)-(w/2), (sh/2)-(h/2)) root.geometry(newGeometry=newGeometry) root.update() w = root.winfo_width() h = root.winfo_height() newGeometry='+%d+%d' % ((sw/2)-(w/2), (sh/2)-(h/2)) root.geometry(newGeometry=newGeometry) root.mainloop() Here, the initial height of 30 and width of 120, is just a rough estimate, but is pretty close on my machine. At least the window comes up near the final resting place. :) You could also just leave initialize width and height to 1, but the movement is a bit jarring. Hope this helps a bit; I don't know if you'll be able to get exactly what you want, unless you hard code the window sizes (which can be a mess). Using 'wm_minsize' option may be a slight help. Chad Netzer chad at vision.arc.nasa.gov From stephan at pcrm.win.tue.nl Tue Apr 27 02:28:25 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 27 Apr 1999 08:28:25 +0200 Subject: To redirect stdin,out References: <37248549.6AD365AC@pk.highway.ne.jp> Message-ID: Thooney Millennier writes: > > import sys > sys.stdout = StdoutCatcher() > print 'foo' > > I am at a loss how to redirect standard input. > If you know any solutions,Please Help! Well, I tried the obvious analog of this code snippet: import sys sys.stdin = open("one_of_my_files.txt") print raw_input() And it seemded to work fine. Am I missing something? Greetings, Stephan From spamfranke at bigfoot.de Thu Apr 29 13:45:17 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Thu, 29 Apr 1999 17:45:17 GMT Subject: Emacs' python-mode buggy? References: <14120.30592.807745.732604@anthem.cnri.reston.va.us> Message-ID: <3728955e.19679327@news.omnilink.de> What bothers me most with the Emacs mode's TQSs is that editing gets terribly slow if there lots of them (and they are long). On each CR, Tab or : the current indent is computed, which takes *much* longer than outside the String. Can this be fixed? Stefan From tismer at appliedbiometrics.com Sun Apr 25 16:05:15 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sun, 25 Apr 1999 20:05:15 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> Message-ID: <3723757B.CF96D973@appliedbiometrics.com> "Magnus L. Hetland" wrote: > > Justin Sheehy writes: > > > mlh at idt.ntnu.no (Magnus L. Hetland) writes: > > > > > (And... How about builtin regexes in P2?) > > > > Um, why? I don't see any need at all for them to move from > > module-status to core-language-status. > [...] > > > > In all seriousness, what reason do you have for making that > > suggestion? I am willing to believe that there might be a good reason > > to do so, but it certainly isn't immediately obvious. > > Now, that's really simple -- because re.py is slow. I thought maybe > some of the slowness might be improved by a c-implementation, that's > all. Not too important to me... Now, true for re.py, but if you just care about speed, you can abuse the underlying pcre module which is compiled. For simple cases where I just needed to match something, the "code" attribute of a compiled re object can be used instead of the re object. I admit this is a hack, but it gave me a speedup of factor 3 for a simple matching case. pcre's speed seems to be in the same order of magnitude as regex was. In the long term, I think it makes sense to build the rest of re.py also into pcre. Then I still would not see any reason to embed its functionaliy into the language. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 eric at linux-hw.com Tue Apr 13 17:32:23 1999 From: eric at linux-hw.com (Eric Lee Green) Date: Tue, 13 Apr 1999 21:32:23 GMT Subject: threads In-Reply-To: <1288080841-20523503@hypernet.com> References: <1288080841-20523503@hypernet.com> Message-ID: On Tue, 13 Apr 1999, Gordon McMillan wrote: > Eric Lee Green wonders about Python threads: > > > My question is this: How "atomic" are basic Python variable > > operations? > > This exact question was asked not long ago. My reply, and Guido's > clarifications follow: Ah. Okay. So Python is doing user-land threads and not Posix (OS-level) threads? The difference between the two doesn't make a difference for my application, but I'd be curious to know in case I ever want to run this on an SMP machine (where only OS-level threads are schedulable on multiple processors). In any event, I'm relieved to know that basic operations are safe. As long as the semaphoring requirements are similar to "C", which appears to be the case, I am just fine. I do see, from reading the documentation, that file I/O operations are thread-safe. The only question then is whether Python's socket operations are thread-safe if we're doing user-land threads... I'd hate to bring all threads to a halt by reading from a socket, because that was the whole point (to be able to do things asynchronously). Be a real bummer if I have to stop what I'm doing and start re-writing it all into C++ :-(. (I am *NOT* fond of C++, it seems you have to spend eons writing basic classes to do things that Python does out of the box before you can even think about your application). -- Eric Lee Green eric at linux-hw.com http://www.linux-hw.com/~eric "People have grown used to thinking of computers as unreliable, and it doesn't have to be that way." -- Linus From jam at newimage.com Sun Apr 25 15:50:40 1999 From: jam at newimage.com (jam) Date: Sun, 25 Apr 1999 15:50:40 -0400 Subject: HELP! NumPy (Graphics) and Linux In-Reply-To: <7fvpsh$l8e$1@nnrp1.dejanews.com>; from kelvin_chu@my-dejanews.com on Sun, Apr 25, 1999 at 07:19:47PM +0000 References: <7fvpsh$l8e$1@nnrp1.dejanews.com> Message-ID: <19990425155040.A16440@toast.internal> On Sun, Apr 25, 1999 at 07:19:47PM +0000, kelvin_chu at my-dejanews.com wrote: > > Hi all; > > I've had great success with EZplot and now want to move my code to Linux- > based platforms in my lab. I am having significant difficulties building > the Graphics portion of NumPy. > > 0. I am running RedHat linux 5.2 > 1. I have installed Yorick in the cannonical place. > 2. Instead of libX11.a, I have a shared-object library, locatedin > /usr/X11R6/lib > > When I do the build (python makethis.py), I receive the following error: > > gcc -fpic -I/usr/local/lib/yorick/1.4/h -g -O2 > -I/usr/local/include/python1.5 -I/usr/local/include/python1.5 > -DHAVE_CONFIG_H -c ./Gist/Src/gistCmodule.c > ./Gist/Src/gistCmodule.c:75: arrayobject.h: No such file or directory > ./Gist/Src/gistCmodule.c:88: warning: `PyFPE_END_PROTECT' redefined > /usr/local/include/python1.5/pyfpe.h:169: warning: this is the location of > the previous definition > make: *** [gistCmodule.o] Error 1 > > > I suspect that I am going to run into multiple problems. There is a cryptic > statement in the README that indicates that I should do import_arrays() before > doing the build...where do I implement this? How much of this problem is > related to the shared object X libs? > > Thanks, I appreciate any light you can shed on this matter! > > Cheers, > > Kelvin > greetings, the error you posted doesn't appear to have anything to do with libX11.. it points to the location of (at least) this error.. the compiler is unable to find 'arrayobject.h', which is part of the python distribution. if you installed from rpms, did you remember to also install the 'python-devel' package? hope that helps.. please let us know! ;) Regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From arcege at shore.net Wed Apr 28 15:51:33 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 28 Apr 1999 19:51:33 GMT Subject: Maximize Benefit when Purchasing Learning Python References: Message-ID: <9FJV2.153$pX2.88806@news.shore.net> David Ascher wrote: : On Wed, 28 Apr 1999 jkraai at murl.com wrote: :> How can I help whom when purchasing Python books? : I'll dare to speak for Mark, and say that you should feel free to send : either Mark or I (or both) checks for any amount whatsoever. Skip the : middleman. Save trees -- don't buy the book, just send us cash. Don't : hesitate for a minute. Better yet. Secure web credit-card transfers? Saves the paper from the envelopes and checks/bills. ;) -Arcege From sdm7g at Virginia.EDU Fri Apr 23 14:59:31 1999 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 23 Apr 1999 14:59:31 -0400 (EDT) Subject: millisecond time accuracy In-Reply-To: <14112.46141.974182.785300@amarok.cnri.reston.va.us> References: <3720A4A6.125DA1C7@OMIT_THIS.us.ibm.com> <14112.46141.974182.785300@amarok.cnri.reston.va.us> Message-ID: On Fri, 23 Apr 1999, Andrew M. Kuchling wrote: > Kevin F. Smith writes: > >Is there a way to measure time accurate to milliseconds? > > > >For example, by calling the time.time() function I get seconds. Is > >there a comparable function that I could use to measure interval times > >down to at least millisecond accuracy? > > Nothing portable. However, time.time() actually returns a > floating point number, and the Python implementation tries to use the > most precise function available in the C library. If your system > supports gettimeofday(), which has microsecond resolution, then > time.time() will return a floating point number with microsecond > precision. > > Note that precision is not the same as accuracy! Python just > uses the C library, so the accuracy or lack thereof is up to the > library implementation. > I was having problems using time.time for benchmarking on the Mac, and was complaining to Jack about it returning integral number of seconds converted to a Python float, when I noticed in the Lib ref: clock () Return the current CPU time as a floating point number expressed in seconds. The precision, and in fact the very definiton of the meaning of ``CPU time'', depends on that of the C function of the same name, but in any case, this is the function to use for benchmarking Python or timing algorithms. i.e. time.clock() is supposed to be the best precision you can get. Now -- I'm not sure that is actually the case, but on the Mac time.clock() - time.clock() has a significant fractional part, while time.time() - time.time() doesn't. ( The offsets of the number of seconds returned by time and clock are different, which is why I'm expressing the value as difference of two pairs. ) On Mac Python, the resolution is 1/60 sec., however it's possible to get much better resolution by uncommenting a line(*) and rebuilding the C libraries, however, Jack was suggesting exporting an additional time.Microseconds() function. What I want is a standard & portable way of getting the best clock value on whatever platform. (*) note: > > [1.5] discovered in :MSL C:MSL Mac:Public Includes:timesize.mac.h > > that you can enable microsecond resolution by uncommenting: > > #define __TIMESIZE_DOUBLE__ > > which causes clock_t to be a double and redefines CLOCKS_PER_SEC. ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- Caldera Open Linux: "Powerful and easy to use!" -- Microsoft(*) (*) From christer.fernstrom at worldonline.fr Fri Apr 23 15:18:27 1999 From: christer.fernstrom at worldonline.fr (christer fernstrom) Date: Fri, 23 Apr 1999 21:18:27 +0200 Subject: GUI and printing Message-ID: <7fqkcu$7gj$1@mars.worldonline.fr> Anybody knows if any of the Pythonized GUI kits support printing of window contents AND cross-platform compatibility? (at least on NT and Mac)? Thx, christer From psychic777 at bigfoot.com Fri Apr 16 19:10:12 1999 From: psychic777 at bigfoot.com (psychic777 at bigfoot.com) Date: Fri, 16 Apr 1999 23:10:12 GMT Subject: A special message for python-list Message-ID: An HTML attachment was scrubbed... URL: From faassen at pop.vet.uu.nl Tue Apr 6 08:56:37 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Tue, 06 Apr 1999 14:56:37 +0200 Subject: mxDateTime in Python distribution References: <19990406070255.A867135@vislab.epa.gov> <19990406082704.A868024@vislab.epa.gov> Message-ID: <370A0485.EC244CF6@pop.vet.uu.nl> Randall Hopper wrote: > > Oleg Broytmann: [part of standard library vs installing modules, installation can be difficult, etc] The distutils SIG at http://www.python.org/sigs/distutils-sig/ is trying to make the cross platform distribution of Python modules (both Python and C extensions) and programs less of a hassle. You could browse over, subscribe to the list, and help out if you're interested in these matters. Regards, Martijn From wtanksle at dolphin.openprojects.net Mon Apr 19 18:11:59 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Mon, 19 Apr 1999 22:11:59 GMT Subject: Beginner Help - class problem or string copy semantics? References: <7fg8a0$3ib$1@nnrp1.dejanews.com> Message-ID: On Mon, 19 Apr 1999 21:47:47 GMT, cmedcoff at my-dejanews.com wrote: >As will soon be apparent I am totally new to Python. In the code fragment >below I expect to see the output "foobar", but I do not. Can anyone tell me >why? All the bookstores seem to be out of "Learning Python". Are they out of >print already or has the initial shipment still not released? I suspect that the store hasn't ordered any. Keep bugging them :). >class Test: > _name = "" > def __init__(self, name): > _name = name > def show(self): > print self._name First of all, I suspect that you're using the underscore because you want the variable to be private. If so, try a double underscore, like __name. >mytest = Test("foobar") >mytest.show() The problem is that you're setting "_name" (a variable local to the __init__ function) instead of "self._name". Add that "self." and you'll be fine. Also, you don't need to have a class variable named the same as your object variable -- it'll never get viewed. Feel free to remove the '_name = ""' line from the class definition. >Regards, >Chuck -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From ivanlan at callware.com Fri Apr 30 16:32:52 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Fri, 30 Apr 1999 20:32:52 GMT Subject: [PSA MEMBERS ANNOUNCE] Python documentation updated! References: <14122.3325.631762.383828@weyr.cnri.reston.va.us> Message-ID: <372A1374.6405E48B@callware.com> Hi Fred, All-- "Fred L. Drake" wrote: > > The documentation for Python 1.5.2 is now available. The online > version is available at: > > http://www.python.org/doc/ > Clicking on the HTML link gets me a 404 Doc not found error. ... Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From klm at digicool.com Thu Apr 29 00:42:17 1999 From: klm at digicool.com (Ken Manheimer) Date: Thu, 29 Apr 1999 00:42:17 -0400 Subject: Emacs' python-mode buggy? References: <199904282340.TAA19934@python.org> Message-ID: <3727E329.2E8F3C31@digicool.com> Markus Stenberg wrote: > At least by my experiences the Emacs mode (at least, two versions I tried, > 3.75 and whatever came with Python 1.5.2) seems to have tons of bugs; to be > more precise, it seems to think a lot more of my code than should be is > string (and therefore is green and indentation doesn't work). > > Funny thing is, it's colored properly when I load file but when I start > editing some files' some parts, they turn green (comment-ish) and > indentation starts to suck. > > Indentation being fairly neccessary feature for Python coding, is there > some option I am missing or am I fucked? (read: forced to use vim or > something) I can't speak to the intimacy issue, but the python-mode syntax recognition may be due to having a leading '(' open paren in the first column in one of your docstrings. If so, emacs' syntax confusion (not to be mistaken for poor gender identification) can be remedied by escaping the leading open paren with a '\' backslash, like so: \(this is what to do with parens in docstrings.) If it is the problem, well, it's emacs' problem, not pymode. If it's not, well, do track it down. Oh, does that bug constitute the "tons" you mention, or were there others? I never was good at estimating the weight of bugs - all that chiton, you know. Ken Manheimer klm at digicool.com From JamesL at Lugoj.Com Mon Apr 5 23:59:06 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 05 Apr 1999 20:59:06 -0700 Subject: SNMPy update References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <7ebtn1$dq$1@Starbase.NeoSoft.COM> Message-ID: <3709868A.CFCCE63@Lugoj.Com> Cameron Laird wrote: > > In article <14089.11820.416453.80124 at bitdiddle.cnri.reston.va.us>, > Jeremy Hylton wrote: > . > . > . > >encode/decode and on how to build a backend for SNACC. (A free-ish > >ASN.1 compiler; the only one?) > > Hardly. There are several ASN.1 compilers. MAVROS www-sop.inria.fr/rodeo/personnel/huitema/mavros-home.html> is > another. I know of none that's achieved SNACC's portability. MAVROS is free? From ivanlan at callware.com Thu Apr 22 16:52:24 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 22 Apr 1999 20:52:24 GMT Subject: What is it ? How can I learn it ? Where should I start ? Wha References: <1287305973-36728049@hypernet.com> Message-ID: <371F8C08.35432359@callware.com> Pythonistas-- Gordon ``The Klingon'' McMillan wrote: > > Ivan remembers... > > > ... and most of the real > > cannibals have been muzzled (Gordon excepted, so don't put any parts > > of you through his cage bars that you want to keep). ... > > and then forgets that I'm not poikilothermophagic... > Well, Gordon, if you don't eat poikilotherms, then this sounds to me like you're saying that you wouldn't take a bite out of Alexander the Newbie because he's a cold fish. Sounds like an insult to me! Alexander! Be insulted! > > PS: And just *where* is this job that (I should be so lucky) > > *REQUIRES* you to know Python???????? Why aren't they calling > > ME???? > > Now, Ivan, do you really have to ask? > > revenge-is-a-dish-best-eaten-raw-ly y'rs > -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From aahz at netcom.com Sat Apr 10 18:49:09 1999 From: aahz at netcom.com (Aahz Maruch) Date: Sat, 10 Apr 1999 22:49:09 GMT Subject: Python 2.0 compatibility References: Message-ID: In article , Paranoid User wrote: > >We have selected Python as the scripting language for the next generation of >one of our embedded systems. This is a very fast-track project scheduled to >ship near the end of the first quarter of 2000. > >I ran across a quote that said something to the effect that Python 2 will be >incompatible with Python 1. Before I make a decision as to whether we >freeze with Python 1.5.2, or migrate to Python 2 when it is released, I need >to find out the extent of truthfulness in the "quote". I'm not in the know about Python 2, but I do know this much: Python 2 will almost certainly not ship before your product. Python 2 has also not been completely designed yet, so nobody (not even Guido) knows the extent to which Python 2 will be incompatible. There's also the likely release of Python 1.6; I don't know whether that's in parallel with the Python 2 development. I suggest that you work with 1.5.2 and worry about future releases when there's more clarity. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het If they can get you asking the wrong questions, they don't have to worry about the answers. -- Thomas Pynchon (from EFF quote collection) From holger at phoenix-edv.netzservice.de Wed Apr 21 05:29:01 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Wed, 21 Apr 1999 09:29:01 GMT Subject: NT: Create a link Message-ID: <371D9A5D.76541E1E@phoenix-edv.netzservice.de> Hi, I'd like to know how to create a link to a file with python under WinNT? Perhaps there is a possibility to get access to 'IShellLink' (Win32Api)? Thank you, Holger (new under this snake;-)) From tismer at appliedbiometrics.com Thu Apr 22 14:11:00 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 22 Apr 1999 18:11:00 GMT Subject: Callbacks and "callable" objects References: <19990422113516.A278137@vislab.epa.gov> Message-ID: <371F6634.3ED0FD11@appliedbiometrics.com> Randall Hopper wrote: > > A while back I asked how to pass parameterized callbacks to Tkinter. > Now I need to explore how best to do partial resolution of callback > arguments. For example, define values for arguments 1 and 2 at > registration time, but leave argument 3 to be populated by Tkinter. With a speed penalty of about a factor 2, Don Beaudry's functor module provides you with the partial closure functionality which you would like. Please get the current version from ftp.python.org, it works with Python 1.5 . BTW, I think you will go back to the default parameter trick after a while, since it is faster, which might be an issue for callbacks. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 fredrik at pythonware.com Mon Apr 19 04:17:40 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Apr 1999 08:17:40 GMT Subject: Beginner - Tkinter info References: <371c59e9.2723125@news.tin.it> Message-ID: <017301be8a3e$d3696de0$f29b12c2@pythonware.com> Kranio wrote: > I am just starting using python and I would like to learn more. I have > about all the docs written by guido but I haven't found yet > documentation about tkinter usage. Can you help me? http://www.python.org/topics/tkinter/doc.html has the full story. From boud at rempt.xs4all.nl Tue Apr 6 03:21:30 1999 From: boud at rempt.xs4all.nl (boud at rempt.xs4all.nl) Date: Tue, 6 Apr 1999 07:21:30 GMT Subject: Python and Qt+KDE References: <36F940DC.44F08BDF@druga.com> <7dbtb8$38j$1@nnrp1.dejanews.com> <7dec78$977$1@Starbase.NeoSoft.COM> <36FB0C5F.E6CE768D@zarlut.utexas.edu> <199903290118.UAA05150@mira.erols.com> <3708D549.12844324@trust.ee> Message-ID: "A.M. Kuchling" wrote: > > (I'm looking into GUI alternatives to Tkinter, having looked > at PyGTK, but haven't yet examined PyKDE to any significant degree; > comments on it would probably be helpful for many people interested in > writing desktop apps in Python.) I've just decided to go with the pyKDE bindings for the application I'm developing (on linux). I've looked at tkInter (+ pmw), pyGTK, wWindows, Wpy, XForms, CGI, and the old kdebindings from python.org. The old kdebindings were obviously not up to date, although they were nicely structured and not very memory intensive. CGI can't deliver a complex interface, XForms I couldn't get to work. Wpy is based on the Microsoft Foundation Classes, which since I only work in VB on Windows isn't a plus from me, and doesn't seem to be very complete or full-featured. WxWindows was rather nice (and portable), but rather complicated to install. The documentation is very reasonable. Gtk is in so rapid a development that it would be difficult to decide which version to work with - and I didn't think much of the framework as presented by the example applications. TkInter looks nice - as can be seen from Grail or PySol - but is rather underdocumented. The KDE bindings are rather complete, and the documentation Troll delivers for Qt is very good - and useable with the Python bindings. I'm currently working my way through the KDE tutorials, translating from c++ (which I don't know much about) to Python (which I am learning quickly). The KDE bindings are a bit heavy on the memory - but that issue is being addressed. Qt has some great widgets. The KDE + Qt framework is very nice to work with, in my opinion, and the resulting applications look good. And the maintainer of the pyKde bindings reacted very quickly to some questions I had. This is just a description of the way I reached the decision to go with KDE - and I might have made mistakes along the way, so your mileage may vary, of course. All disclaimers apply. -- Boudewijn Rempt | www.xs4all.nl/~bsarempt From quinn at necro.ugcs.caltech.edu Sun Apr 25 13:28:22 1999 From: quinn at necro.ugcs.caltech.edu (Quinn Dunkan) Date: 25 Apr 1999 17:28:22 GMT Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: On Sun, 25 Apr 1999 15:51:29 GMT, Aahz Maruch wrote: >In article <7fvagp$8lm$1 at nnrp1.dejanews.com>, > wrote: >> >> [python] >> if not (re.match('^\s$'), mytext) > >I think you want > > if not (re.match('^\s$', mytext)) : >or > if not (re.match('^\s*$', mytext)) : Don't forget r'' in python when you have backslashes. if not (re.match(r'^\s*$', mytext)): From alrice at swcp.com Fri Apr 2 23:24:42 1999 From: alrice at swcp.com (Alex Rice) Date: Fri, 02 Apr 1999 21:24:42 -0700 Subject: disenchanted java user mumbles newbie questions Message-ID: <3705980A.1C7E9512@swcp.com> Hola, 1) In the Python 1.5 Tutorial, sec. 9.2 "Python Scopes and Name Spaces" there is the following passage: >> It is important to realize that scopes are determined textually: the global scope of a function defined in a module is that module's name space, no matter from where or by what alias the function is called. On the other hand, the actual search for names is done dynamically, at run time -- however, the language definition is evolving towards static name resolution, at ``compile'' time, so don't rely on dynamic name resolution! (In fact, local variables are already determined statically.) >> Where can I read more about this move towards for compile time, static name resolution and the reasons for it. For some reason I was envisioning Python as being less like Java and more like Objective-C or Smalltalk in terms of dynamic binding. 2) Which reminds me: does anyone have a URL for that Ousterhut (sp?) article at Sunlabs about Scripting languages and why scripting rulz and where he has a taxonomy of programming languages along 2 dimensions? Lost that bookmark and cannot find it again. 3) What's the Python equivalent of depends.exe? --something to find what modules your script is depending upon? It seems like one would be able to create a very slim distribution if one needed an .exe, couple of .dll only a handful of .py files. A Java+Swing application can be 1-2 MB not including the VM! bloat--ed. What's a typical size of a bare-bones Python distribution? Obviously the thread in this group "Free commercial Python application" is not representative... I hope. TIA! Alex Rice -- MindLube Software From mlh at idt.ntnu.no Fri Apr 23 09:55:53 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 23 Apr 1999 15:55:53 +0200 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> Message-ID: Arne Mueller writes: > Hi All, > > first off all: Sorry for that slightly provoking subject ;-) ... [...] > > The following python code does the job: [...] > f = open('my_very_big_data_file','r') # datafile with ~300000 records > read_write(f, stdout, {}) # for a simple test I don't exclude > anything! Well -- re is known to be slow. If you have to be fast, maybe you should try not to use regular expressions; You could perhaps use something from the string module (several options there) or maybe even consider fixed-length fields for the identifiers, which should speed up things a bit. > It took 503.90 sec on a SGI Power Challange (R10000 CPU). An appropiate > perl script does the same job in 32 sec (Same method, same loop > structure)! Hm. Perl probably has a more efficient implementation of Perl regexes than Python, naturally enough... > I'd realy like to know why python is so slow (or perl is so fast?) and > what I can do to improove speed of that routine. Well -- at least I have made one suggestion... Though it may not explain it all... > > I don't want to switch back to perl - but honestly, is python the right > language to process souch huge amount of data? > > If you want to generate a test set you could use the following lines to > print 10000 datasets to stdout: > > for i in xrange(1, 10001): > print > '>px%05d\nLSADQISTVQASFDKVKGDPVGILYAVFKADPSIMAKFTQFAGKDLESIKGTAPFETHAN\n\ > RIVGFFSKIIGELPNIEADVNTFVASHKPRGVTHDQLNNFRAGFVSYMKAHTDFAGAEAA\n\ > WGATLDTFFGMIFSKM\n' % i > > And if you don't believe me that perl does the job quicker you can try > the perl code below: [...] OK. Using your testset, I tried the following program (It may not work exactly like your script...) I have made the assumption that all the id's have a constant length of 7. ---------- import fileinput exclude = {'px00003': 1} skip = 0 for line in fileinput.input(): if line[0] == '>': id = line[1:8] if exclude.has_key(id): skip = 1 else: skip = 0 if not skip: print line, ----------- It took about 12 seconds. > > Please do convince me being a python programmer does not mean being slow > ;-) > At least I tried... > Thanks very much for any help, > > Arne -- > Hi! I'm the signature virus 99! Magnus > Copy me into your signature and join the fun! Lie Hetland http://arcadia.laiv.org From olipt at mayo.edu Sun Apr 25 21:03:12 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Sun, 25 Apr 1999 20:03:12 -0500 Subject: HELP! NumPy (Graphics) and Linux In-Reply-To: <7fvpsh$l8e$1@nnrp1.dejanews.com> References: <7fvpsh$l8e$1@nnrp1.dejanews.com> Message-ID: Glad to hear that you are using NumPy on Linux. I've been putting together the RPM's for NumPy and would definitely suggest you go that route initially. If you want to compile the packages yourself you can get the source RPM for Numpy from andrich.net or from my site at http://oliphant.netpedia.net and it will build 3 binary packages: NumPy, Gist (EzPlot), and RNG (random number generators). The packages come with quite a bit of documentation (all I could find). Installing a source RPM and then compiling amounts to: rpm -i package-name.src.rpm rpm -ba /usr/src/redhat/SPECS/package.spec This will build a binary package compiled on your system and place it in /usr/src/redhat/RPMS/i386 You can then install it like any other package. I would highly encourage learning to build from RPM sources. Grabbing a spec file is usually all you need to start building any package you want. If you stick with Oliver's RPM's you should be fine. I've had trouble in the past however with compiling my own RPM's (using gcc) and trying to import them into a python interpreter installed from Oliver's RPMS (compiled with pgcc). I get strange segfaults. I haven't tried for awhile so I don't know if the problem is still there but you might keep that in mind if you are mixing and matching compilers for different python packages. After that bit of rambling... The problem you are having is due to the fact that the gist module now looks for the arrayobject.h file in numerical/arrayobject.h which is not where your arrayobject.h header file likely is. So, change that #include line in the C-code and it should work. I had to do this to get the RPM's to work. Best, Travis From andrew at starmedia.net Wed Apr 21 10:08:37 1999 From: andrew at starmedia.net (Andrew Csillag) Date: Wed, 21 Apr 1999 14:08:37 GMT Subject: Problems with mod_pyapache and cPickle References: <371CC227.5BDF5C5A@starmedia.net> <5l4smau1xk.fsf@eric.cnri.reston.va.us> Message-ID: <371DDBE4.2C8326B6@starmedia.net> Guido van Rossum wrote: > > Or you could upgrade to Python 1.5.2, which gets rid of the > class_cache altogether. > -- > --Guido van Rossum (home page: http://www.python.org/~guido/) Ahhh. Handn't looked at the 1.5.2 cPickle code. Cool. Thanks. Drew Csillag -- "There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence." - Jeremy S. Anderson From claird at Starbase.NeoSoft.COM Tue Apr 6 09:27:32 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 6 Apr 1999 08:27:32 -0500 Subject: Python Chip References: <3703D175.85747FEE@pop.vet.uu.nl> <000501be7da7$450ddf20$879e2299@tim> Message-ID: <7ed244$ke9$1@Starbase.NeoSoft.COM> In article <000501be7da7$450ddf20$879e2299 at tim>, Tim Peters wrote: >[Martijn Faassen] >> This isn't official, but have you all heard about the Python chip? >> ... [recklessly premature disclosure deleted] ... > >[Chad Netzer] >> April fools, right? > >[Martin] >> No, no, this is as serious as a ten ton weight! Just ask Tim about the >> stress tests if you still don't believe it. :) >> >> Is-it-april-already-ly yours, > >As Martijn reported, the stress tests are going *amazingly* well, modulo a >subtle space/tab screwup in the hardware. I've completed VLSINANNY.py, >which will verify future hardware conformance to generally accepted >international leading whitespace principles, but the Russian part of the >team is refusing to cooperate in protest of Kosovo (although if you ask me, >they're just pissed at the Swedes for sneaking herring into the borscht ... >again). . . . The metajoke is that, as I've learned from the comp.arch crowd, it's all turtles anyway. That is, *no* chips actually run the instruction sets they present to their consumers; they all emulate, even, or perhaps especially, including Intel's latest mass-market offerings. Maybe we're just a tweaked microcode store away from the Python chip now, but it doesn't matter. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From jwtozer at my-dejanews.com Wed Apr 14 22:31:27 1999 From: jwtozer at my-dejanews.com (jwtozer at my-dejanews.com) Date: Thu, 15 Apr 1999 02:31:27 GMT Subject: Novice Question: two lists -> dictionary Message-ID: <7f3j1v$f6j$1@nnrp1.dejanews.com> How do I make the members of one list the key of a dictionary and the members of a second list the members of list values associated with with those keys? Given: ListA = ['10', '10', '20', '20', '20', '24'] ListB = ['23', '44', '11', '19', '57', '3'] Desired Result: Dict = {'10': ['23','44'],'20': ['11','19','57'], '24': ['3']} Any help will be much appreciated. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From olipt at mayo.edu Wed Apr 28 09:42:18 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Wed, 28 Apr 1999 08:42:18 -0500 Subject: Bug or Feature? In-Reply-To: References: <37208E69.4B022E0C@mediaone.net> <7fr3eg$bqr@world1.bellatlantic.net> <7g4jkg$llc@ds2.acs.ucalgary.ca> Message-ID: On 28 Apr 1999, Stephan Houben wrote: > nascheme at ucalgary.ca (Neil Schemenauer) writes: > > > I think the Numeric array should be added as a standard module. > > This is on the Python TODO list. I may do it myself it I get > > time. I don't know how much of Numeric should be added. Any > > comments? > > That would be cool. Here, here. > As you see, the "Numerical" part is by far the biggest, and if you make it > a standard part of Python, you increase the size of the standard distribution > by quite much. So that might be a reason not to do it. > > On the other hand, the biggest parts of "Numeric" are the blas lite and the > lapack lite, which together make up 1503K. So perhaps you could rely on > a preinsatalled BLAS and LAPACK, just as the standard Python distribution > relies on the readline library. > Having the Numeric extensions as part of the core would be excellent. I'd be interested to here from knowledgeable people (people who decide these things, i.e. Guido) what the arguments against doing so are. Not including blas and lapack in the core is fine as long as the user is informed of the need to get BLAS and LAPACK on their machine. It would be nice if you could count on someone using Numeric to have a full implementation of BLAS and LAPACK on their machine. Quite a few other libraries out there that would be nice extensions to Numeric depend on subroutines in those libraries. Travis Oliphant From behrends at cse.msu.edu Thu Apr 29 19:27:10 1999 From: behrends at cse.msu.edu (Reimer Behrends) Date: 29 Apr 1999 23:27:10 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <37272CA0.3F3F02A2@prescod.net> Message-ID: Paul Prescod (paul at prescod.net) wrote: > Markus Kohler wrote: > > You are right that one should choose the right tool for a problem, but > > I disagree that Python is optimized for the general case. Squeak a free > > Smalltalk implementation (www.squeak.org), is already much faster ( about > > 3 times actually ) than python and it has even a true Garbage > > Collector. > > This is a little off-topic but I'm curious whether squeak has an embedding > API. Is there any languge that is as easy to embed as Python, and also has > full garbage collection? Ruby. (Was discussed here before.) See http://www.netlab.co.jp/ruby/ I think it is actually easier to extend with C code (because you don't have to keep track of reference counts, among other things). On the other hand, I could live without some of the more Perl-inspired constructs in Ruby (nothing against Perl in general, it just happens that its feature set is just the opposite of what I personally like in a programming language -- i.e. thousands of different idioms and extensive use of punctuation symbols). Reimer Behrends From dieter at handshake.de Wed Apr 21 16:32:58 1999 From: dieter at handshake.de (Dieter Maurer) Date: 21 Apr 1999 20:32:58 +0000 Subject: Python 1.5.1/2 library incompatibilities Message-ID: Neither can a Python 1.5.1 interpreter use a 1.5.2 Python library (it results in a "NameError: buffer" on import of "types.py") nor can a 1.5.2 interpreter use a 1.5.1 library (this results in failing to find the (new) built in exception "EnvironmentError"; the interpreter switches back to string based exceptions which causes subsequent failure when the application uses class exceptions). This was (for a short time) an issue for us. We wanted to switch to Python 1.5.2; we had, however, 1.5.1 interpreters embedded in executables that could not all be replaced immediately. Installing Python 1.5.2 the standard way broke the old executables (because the 1.5.1 library was overwritten) while installing the new libraries in "/usr/local/lib/python1.5.2" let the new interpreter find the old modules. We solved the problem by changing the way, our local Python interpreter finds the library: it now uses the full version number to find its library rather than the base version number, only. This allows us, to have Python libraries with different version levels (e.g. 1.5.1 and 1.5.2) in the same "prefix" location. We could also have installed Python 1.5.2 with a different "prefix". However, this had led to a duplication of "site-python" or the use of an explicite PYTHONPATH. Both was considered unsatisfactory. - Dieter From hinsen at cnrs-orleans.fr Fri Apr 9 14:10:52 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 09 Apr 1999 20:10:52 +0200 Subject: Numeric: vector operations? References: Message-ID: Joe Strout writes: > Playing with Numeric today, I noticed an apparent lack of common vector > operations, like normalization, vector-length, and cross product. If you mean vectors as in 3D geometry, look at the module Vector in my collection of scientific modules (http://starship.python.net/crew/hinsen/scientific.html). For vectors in the sense of rank-one arrays, I am not aware of any available module that contains these operations (and the cross product is limited to 3D-space anyway), but they are also much less frequently needed for non-geometric work. > These are fairly easy to code for my own evil purposes, but it's > surprising that they're not in there. Am I missing something? Or are > they purposefully omitted for some reason (e.g., they only apply to > very restricted sorts of matrices whereas other operations are more > general)? I guess there is too little advantage in writing Numeric.vector_length(v) over Numeric.sqrt(Numeric.add.reduce(v**2)) -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From tismer at appliedbiometrics.com Wed Apr 21 11:30:25 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 21 Apr 1999 15:30:25 GMT Subject: Bit Arrays References: Message-ID: <371DEF11.6D06D79D@appliedbiometrics.com> Jeffrey Kunce wrote: > > Take a look at ./Demo/classes/bitvec.py in the python source distribution. It may be what you want, or at least give you some ideas. > > --Jeff Interesting. This demo has not been used very much from 1993 on, since it has a long-life bug: def __cmp__(self, other, *rest): #rprt(`self`+'.__cmp__'+`(other, ) + rest`+'\n') if type(other) != type(self): other = apply(bitvec, (other, ) + rest) #expensive solution... recursive binary, with slicing length = self._len if length == 0 or other._len == 0: return cmp(length, other._len) if length != other._len: min_lenght = min(length, other._len) ^- here! return cmp(self[:min_length], other[:min_length]) or \ cmp(self[min_length:], other[min_length:]) #the lengths are the same now... ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 stidolph at origin.ea.com Fri Apr 30 09:33:26 1999 From: stidolph at origin.ea.com (Stidolph, David) Date: Fri, 30 Apr 1999 13:33:26 GMT Subject: Errors Message-ID: <11A17AA2B9EAD111BCEA00A0C9B4179301E10E2B@forest.origin.ea.com> try this... tally = 0 for word in All_Words: z = 0 while z < len(word): if z == 0: tally = tally + alpha.index(word[z]) else: tally = tally + (alpha.index(word[z]) * 26) The right side of the '=' is being done before the left, so you are trying to read a variable that has not been initialized. -----Original Message----- From: smoothasice at geocities.com [mailto:smoothasice at geocities.com] Sent: Thursday, April 29, 1999 4:17 PM To: python-list at cwi.nl Subject: Errors Ok I have been using python and I have noticed that the errors aren't truly helpful.. I don't know if I just didn't learn this properly but I dont' know why this generates an error: for word in All_Words: z = 0 while z < len(word): if z == 0: tally = tally + alpha.index(word[z]) else: tally = tally + (alpha.index(word[z]) * 26) It gives me this: NameError: tally and I don't know why...... THanks, Anton From see at my.sig Thu Apr 22 00:24:37 1999 From: see at my.sig (dg) Date: Wed, 21 Apr 1999 21:24:37 -0700 Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> Message-ID: In article <371E964F.C531C2A at istar.ca>, eugened at istar.ca spoke thusly: > For programmers using languages other than Tcl. > > I recently "discovered" the latest stable version of Tcl/Tk (8.05) and > must say that was quite impressed by the simplicity and ease of use of > Tk. > > But I also found that while older versions of Tk were using lightweight > components (Some Java terminology :) the latest version is using native > components for things like scrollbars and buttons. > > I don't want to say that this is bad for Tcl users but what about all > the other languages that use Tk? Isn't writting multiplatform GUI harder > using native components.... Tk does all the hard work, depending on which platform it's compiled for. The gui programmer makes the same calls in either case. -- Don Groves (groves_acm_org) Replace underscores to get my email address From quinn at mark.ugcs.caltech.edu Fri Apr 16 17:28:06 1999 From: quinn at mark.ugcs.caltech.edu (Quinn Dunkan) Date: 16 Apr 1999 21:28:06 GMT Subject: pty, qwsv and Python References: <3717725B.34F2E34A@bogus.bogus.com> Message-ID: On Fri, 16 Apr 1999 14:24:44 -0300, Henrique Almeida wrote: >Warning: NO native speaker ahead. > >Hi. > >I'm new to Python (only started looking at the docs yesterday). I want >to know if it is possible to control a qwsv (quake world linux server) >using Python: ie do a "status" command in the qwsv every 5 minutes, >process the returned code, watch for some string in the pty... > >After searching the Python home page it looks like popen2() is the way >to go. Is it? Also, is it possible to use "screen" (a program that let >me "detach" the server) and "popen2" at the same time? I would like have >a interactive session to qwsv to do administration. > >Thanks. popen2() not going to help with the infamous stdio buffering problem. What you want is pyexpect. Look under System in www.python.org/download/Contributed.html From paul at prescod.net Wed Apr 28 16:04:00 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 28 Apr 1999 20:04:00 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: <372769B0.3CE8C0F3@prescod.net> William Tanksley wrote: > > And Oberon (SlimBinaries), and Eiffel (typing and general compile-time > error catching), and ... Actually, isn't Eiffel's type system famous for being full of holes? Regardless, wouldn't a better source of inspiration on typing be a language with *optional* compile-time error checking? -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Microsoft spokesman Ian Hatton admits that the Linux system would have performed better had it been tuned." "Future press releases on the issue will clearly state that the research was sponsored by Microsoft." http://www.itweb.co.za/sections/enterprise/1999/9904221410.asp From tismer at appliedbiometrics.com Fri Apr 9 10:17:27 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 9 Apr 1999 14:17:27 GMT Subject: import from user input? References: <816010E2456BD111A48700805FBBE2EEA63EB7@ex-quebec-u1.baan.com> Message-ID: <370E0BF7.D6E35B7A@appliedbiometrics.com> Gaetan Corneau wrote: > > Hello, > > I want to import modules at runtime, and get the module name from the user. > Is that possible? How? There is more than one way. The obvious one is to execute a generated statement in the correct environment, as in >>> import string >>> modname=string.strip(raw_input("which module do you want to import today?")) >>> exec "import "+modname >>> re # what I typed >>> But if you want to be less open to users who might type bad things like "sys ; sys.exit()", this version might be easier to handle: >>> globals()[modname] = __import__(modname) The advantage is that the builtin function __import__ is a function which requires a module name as a string parameter. No necessity to check for bad input, but by a try...except ImportError clause if the module isn't found. > Another question: is there a function to copy/move entire directory trees? There is a walk function in os.path which makes it an easy exercise to write such a function. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 pchristo at ic.sunysb.edu Tue Apr 13 14:13:14 1999 From: pchristo at ic.sunysb.edu (Pavlos Christoforou) Date: Tue, 13 Apr 1999 14:13:14 -0400 Subject: simple indexed file module? In-Reply-To: <7evg0s$spu$1@nnrp1.dejanews.com> References: <7evg0s$spu$1@nnrp1.dejanews.com> Message-ID: On Tue, 13 Apr 1999 aaron_watters at my-dejanews.com wrote: > In article , > Joe Strout wrote: > > For a CGI script I'm working on, I need to keep a couple of indexed > > files. These will contain variable-length data (descriptions), which > > may be changed fairly frequently. So I imagine that in addition to the > > data file, there will be an index file that keeps track of the position > > and length of each record. New or expanded records will be stuffed in > > wherever there is free space, or at the end if no sufficient free chunk > > is available. > I would suggest you use BoboPOS, the Object database used in Zope and available as a seperate component. It supports transactions, multiple versions and undo plus a lot of other cool things. It is very easy to use and very stable. Pavlos From wolfman at clara.com Wed Apr 21 08:04:53 1999 From: wolfman at clara.com (wolfman at clara.com) Date: Wed, 21 Apr 1999 12:04:53 GMT Subject: Should I? 2913 Message-ID: http://www.eureka-erotica.com/adultsex/pornplaza/ Go on then! Over 18s only. kbzlilnbhnqxghwtemoc From news at dorb.com Wed Apr 7 13:22:48 1999 From: news at dorb.com (Darrell) Date: Wed, 7 Apr 1999 13:22:48 -0400 Subject: Chaning instance methods References: Message-ID: As Tim says "so you've created a piece of immortal cyclic trash" I love the way that sounds. It sure would be nice to be able to walk a list of allocated memory and clean it up if you want to. Or discover what objects are eating the memory you have. > Hope this helps. > > >>> class X: > ... def y(self): > ... print 'y1' > ... > >>> x=X() > >>> x.y() > y1 > >>> def y2(self=x): > ... print 'y2' > ... > >>> setattr(x,'y',y2) > >>> x.y() > y2 > >>> > > From trashcan at david-steuber.com Wed Apr 28 04:00:16 1999 From: trashcan at david-steuber.com (David Steuber) Date: 28 Apr 1999 04:00:16 -0400 Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> Message-ID: "Ilja Heitlager" writes: -> To build larger systems you need classes and modules for abstraction and -> reuse. Python appears to have that. -> To build proto's you need interactive programming and short code-debug -> cycles. Python also seems to have that. I would like better python support in XEmacs. There is a python mode, but I haven't seen anything about evaluating Python code ineteractivly the way you can with Lisp and elisp. -> Need GUI's? MFC or tcl/tk? MFC???? I hope to seperate the functionality from the GUI to make both orthoganal to each other. If I can pull that off, I suppose a Windows version would be possible for what I want to do. I am expecting to go straight to XLib and OpenGL. If I need an abstraction layer over X, it would probably be xt. -> Networking, Parsers, XML, HTML, regex? I am not sure if I need to use networking. I am hoping to get concurrent development via outside tools like CVS. -> ehh, Python? It looks interesting. It is more C like than Lisp like. I was considering using Lisp, but for various reasons I have abandoned that idea. JavaScript is too weak. Perl is a strong scripting language, but it is a real bitch to create C++ style classes. The syntax is a nightmare. I'll keep it for text munching. -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. Drew's Law of Highway Biology: The first bug to hit a clean windshield lands directly in front of your eyes. From aahz at netcom.com Fri Apr 2 19:01:31 1999 From: aahz at netcom.com (Aahz Maruch) Date: Sat, 3 Apr 1999 00:01:31 GMT Subject: string.join() vs % and + operators References: <37054490.E79ADCC9@easystreet.com> Message-ID: In article <37054490.E79ADCC9 at easystreet.com>, Al Christians wrote: > >This ran amazingly fast on my Pentium 200 Mhz -- around 11 seconds for >Way 1, and 7 for Way 2. So, either way, Python can put together about >1 million little strings in a second. Way 3, the way that one would >expect to be bad, recreating the string with each concatenation, was >much slower, but only took about 1 minute. Surprisingly swift as well. > >Anybody have anything to add to this? Are there any related pitfalls >that I may have missed? Yup. Using '+' for strings really bites when you've got long (or potentially long) strings. The average size of the string you're concatenating is about a hundred characters; suppose you're doing CGI work with redirects, and you're looking at closer to three hundred characters a pop. Try adding a 1K pre-string to the front of each of your Ways and see what happens to the speed. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Why is this newsgroup different from all other newsgroups? From pecold at my-dejanews.com Tue Apr 20 14:02:27 1999 From: pecold at my-dejanews.com (pecold at my-dejanews.com) Date: Tue, 20 Apr 1999 18:02:27 GMT Subject: VB Nothing equivalent in win32com Message-ID: <7fiffg$4sb$1@nnrp1.dejanews.com> Does Python support something like VB Nothing object?? (Universal NULL pointer.) Petr -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From ruebe at aachen.heimat.de Tue Apr 27 11:51:32 1999 From: ruebe at aachen.heimat.de (Christian Scholz) Date: Tue, 27 Apr 1999 15:51:32 +0000 Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> Message-ID: <3725DD04.4452128F@aachen.heimat.de> Hi! Ilja Heitlager wrote: > > One other thing. Is the documentation that comes with Python > > sufficient to gain mastery of the language, or should I consider > > buying (yet) another book? > > The online-documentation and examples were sufficient for me, but I love > paper refs and > everbody should have Programming Python Well, I found Programming Python a bit too narrating.. I usually just want a quick overview of function or who I do this or that. Thus the library reference + the FAQ + The Python Quick Reference was quite enough for me.. (There are some interesting boxes in Programming Python though). But actually I also had programming experience before. best, Christian From fredrik at pythonware.com Fri Apr 16 09:28:43 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 16 Apr 1999 13:28:43 GMT Subject: Imperfections in ihooks.py? References: Message-ID: <00d301be880d$0ebcd000$f29b12c2@pythonware.com> > I apologise for the lousy use of language in this post. It's a subject > I find a bit confusing to think about, and I'm clearly not much better > a writing about it. > > Does anybody out there use ihooks? I'm having a couple of problems. Forget about ihooks.py. Greg Stein's imputil.py module is much easier to use, and much more powerful. It's in the "small distribution" kit, available from: http://www.lyra.org/greg/small/ From fredrik at pythonware.com Tue Apr 20 06:01:02 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Apr 1999 10:01:02 GMT Subject: Tkinter: some Labels not updating References: <7fhdqo$dnl$1@agate.berkeley.edu> Message-ID: <00b901be8b14$b45097e0$f29b12c2@pythonware.com> python at pinky.cchem.berkeley.edu wrote: > My Tkinter window has a Canvas with a bitmap image in one Frame, > pull down menus in another Frame, and a few Buttons and Labels. The > Labels are supposed to indicate the values of certain variables which > change when the user clicks on the canvas. The first Label changes, > but the others don't, they stay fixed at the values they had when > I created the Label. > > Is there a trick here or something I don't get? > > I first create the StringVar: > > self.X1v=StringVar() > > Then I initialize X1v: > > self.X1v.set("X1: not entered") > > Then I make a Label object > > self.l1=Label(tb, textvariable=self.X1v) > self.l1.pack(side=TOP) > > Then in the mouse callback (yes, it gets run, I have it print to stdout) > > self.X1v.set("X1: Got It") > > But no update of the text in the label happens. Updates _do_ happen > in another Label object that is in a Frame by itself. Do I need a > separate Frame for each Label? Do I have too many Label objects? as far as I can tell, your program should work. which means that there's probably something you forgot to tell us. try to make a small but complete program that illustrates the problem. (btw, if nothing else helps, you could skip the textvariables and use self.l1.config(text="X1: Got it") instead...) From tim_one at email.msn.com Sat Apr 24 00:42:18 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 24 Apr 1999 00:42:18 -0400 Subject: millisecond time accuracy In-Reply-To: <14112.46141.974182.785300@amarok.cnri.reston.va.us> Message-ID: <000201be8e0c$d60bc580$f09e2299@tim> [Kevin F. Smith] > Is there a way to measure time accurate to milliseconds? > > For example, by calling the time.time() function I get seconds. Is > there a comparable function that I could use to measure interval times > down to at least millisecond accuracy? [Andrew Kuchling] > Nothing portable. However, time.time() actually returns a floating > point number, and the Python implementation tries to use the > most precise function available in the C library. OTOH, so does time.clock(), which yields better-than-microsecond resolution on most Windows + Intel systems (and where time.time() is much cruder). Note that the Library Ref recommends time.clock() for benchmarking. over-ten-years-a-nanosecond-here-or-there-doesn't-amount-to-much- more-than-a-microsecond-ly y'rs - tim From claird at Starbase.NeoSoft.COM Tue Apr 6 00:46:10 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 5 Apr 1999 23:46:10 -0500 Subject: SNMPy update References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <7ebtn1$dq$1@Starbase.NeoSoft.COM> <3709868A.CFCCE63@Lugoj.Com> Message-ID: <7ec3ii$4su$1@Starbase.NeoSoft.COM> In article <3709868A.CFCCE63 at Lugoj.Com>, James Logajan wrote: >Cameron Laird wrote: . . . >> Hardly. There are several ASN.1 compilers. MAVROS > www-sop.inria.fr/rodeo/personnel/huitema/mavros-home.html> is >> another. I know of none that's achieved SNACC's portability. > >MAVROS is free? Jeremy asked about "free-ish" compilers. The referenced page says You can get a free licence for the MAVROS executable and/or source code for teaching and research use only. For commercial use please contact Alain Zahm. Is it important to someone to find a compiler that's other- than-SNACC and has a different license that MAVROS'? I'm confident that, too, is possible. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From kaz at ashi.FootPrints.net Thu Apr 22 14:22:32 1999 From: kaz at ashi.FootPrints.net (Kaz Kylheku) Date: Thu, 22 Apr 1999 18:22:32 GMT Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <371F11C2.3162025@ciril.fr> <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk> Message-ID: On Thu, 22 Apr 1999 18:01:27 GMT, Barry Margolin wrote: >In article <4fv$ECA+JyH3EwbN at jessikat.demon.co.uk>, >Robin Becker wrote: >>I take this completely differently; least astonishment for me is if >>program X looks and behaves the same way no matter what keyboard, mouse >>and screen I'm using. As a 'user' of the program X it shouldn't matter >>what OS/WM is executing the code. I certainly don't want vi or emacs to >>be different on the mac why should I treat word or excel differently? > >I would be very surprised if Netscape on the Macintosh presented a >Windows-like user interface, rather than adopting the standard Macintosh I'd be very surprised if even 10% of, say, comp.lang.c gave a damn. The pitiful dumbfuck who started this thread made a severe mistake in constructing the Newsgroups: header line, the moment he put in the first comma. I am setting Followup-to: to comp.lang.tcl. From bwarsaw at cnri.reston.va.us Thu Apr 29 11:15:12 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 29 Apr 1999 11:15:12 -0400 (EDT) Subject: Emacs' python-mode buggy? References: Message-ID: <14120.30592.807745.732604@anthem.cnri.reston.va.us> >>>>> "MS" == Markus Stenberg writes: MS> At least by my experiences the Emacs mode (at least, two MS> versions I tried, 3.75 and whatever came with Python 1.5.2) MS> seems to have tons of bugs; to be more precise, it seems to MS> think a lot more of my code than should be is string (and MS> therefore is green and indentation doesn't work). MS> Funny thing is, it's colored properly when I load file but MS> when I start editing some files' some parts, they turn green MS> (comment-ish) and indentation starts to suck. MS> Indentation being fairly neccessary feature for Python coding, MS> is there some option I am missing or am I fucked? (read: MS> forced to use vim or something) Contrary to what Tim says, pymode was so buggy when I got it from him that I renamed that pile of elisp `perl-mode' and rewrote the stuff from scratch. Tim being a clever bot embedded himself in three elisp defuns in the Python 1.5.2 version of the file. If you look at the code closely you'll see that every 19,453rd time he gets run, he decides to muck up your syntax coloring "just for the fun of it". Okay, like Tim I lied too (about the "clever bot" part, and maybe about the rest of it). Since you don't say, let me make some educated guesses. Are you running XEmacs (v20.something or 21.0)? In the code in question, do you have an open parenthesis in column zero someplace higher up in a triple quoted string (say a module docstring f'r instance)? This is a known lose on XEmacs -- but it's not a bug caused by pymode. XEmacs, and older versions of Emacs, makes an assumption that any character with `open' syntax (e.g. `(', `[', `{') in column zero starts a top level definition and thus short circuits X/Emacs' built-in parsing primitives. Works great for Lisp and C; useless suckage for Python. Unfortunately, AFAIK there's no way to disable this in Python buffers under XEmacs. The clue is the broken font-lockage for comments. This is all controlled by primitives driven by syntax tables, so there's little that pymode (or pymode's Legion of Corruptors) can mess up. So the answer is: don't put open parens in column zero inside triple quoted strings. Hope that answers it. If not, hit C-c C-b in a python-mode buffer, include a complete code sample and recipe for me to reproduce the problem, and email the message to python-mode at python.org -Barry From skip at mojam.com Wed Apr 21 23:08:35 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 22 Apr 1999 03:08:35 GMT Subject: Need someone to try some rarely used bsddb methods References: <7fa14m$vfm$1@nnrp1.dejanews.com> Message-ID: <371E9326.8472D97@mojam.com> A few days ago I asked for input about how the various bsddb object methods work with different storage types (btree, hash, recno). I got responses from several people whose findings were consistent with mine. The "last" and "previous" methods seemed to fail for hash databases. It turns out they aren't supported. A little digging around in the Berkeley DB code demonstrated that quite clearly. I will work on some patches to the bsddb module that catch the mistake and return a more meaningful error message along with the exception. I have yet to figure out what is happening with the recno format databases. My recommendation is that you only use the btree format for large databases. (Unfortunately, anydbm.open calls bsddb.hashopen when it's available.) I wound up writing the section for the library reference as well. I believe it's in the CVS repository now. Thanks to all who replied. -- Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/ skip at mojam.com | Musi-Cal: http://www.musi-cal.com/ 518-372-5583 From aa8vb at vislab.epa.gov Fri Apr 30 10:12:15 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 30 Apr 1999 14:12:15 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world In-Reply-To: <3729A9F3.75B2692B@appliedbiometrics.com>; from Christian Tismer on Fri, Apr 30, 1999 at 03:02:43PM +0200 References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <7g9qmo$luf$1@news.udel.edu> <372965CA.2B3FD2FE@appliedbiometrics.com> <19990430080805.B776752@vislab.epa.gov> <3729A9F3.75B2692B@appliedbiometrics.com> Message-ID: <19990430101215.A806665@vislab.epa.gov> Christian Tismer: |Randall Hopper wrote: |> Christian Tismer: |> |I'm thinking of no new keyword, but a mechanism which allows me to lock a |> |namespace somehow. |> |> I like this idea in concept. Though I would prefer a way to have |> namespaces "lock by default". Examples: After a class definition, the |> class function dictionary is locked. After a module is fully read, all |> references are bound and the module namespace is locked. etc. | |Well, I wouldn't do that by default. By default, everything could stay as |it is. First of all, this would not break any existing code. Right. I wasn't too clear. By default, I mean I don't want to have to insert some commands/declarations for every namespace (every class, every method, every module, etc.) to lock them. I want this to happen automagically based on a switch. A command-line option (-w), or something like Perl's "use strict" declaration would be a reasonable way to enable this behavior. |Then, what would you do with classes which depend on each |other? You cannot lock them immediately, this would fail. Could you give an example? |Depending on how exactly will be implemented, a single line |at the end of a module should suffice to accomplish this stuff |for the standard cases. This would prevent namespace binding and locking from occuring while the module is being parsed, wouldn't it? With a lock declaration at the beginning, Python could do this as it goes. Seems like that would be easier (Python sees end of function -> module.symbol referenced in the function was not defined -> flag error and abort parse). |As a side effect, locking a module would also find all |referenced but undefined symbols. That's the goal I'm rooting for. ;-) |Anyway, this is still no cakewalk and quite a lot of code |is involved. Needs much more thinking... Definitely. No doubt Guido and the other language experts have a better feel for this than I do. But I felt compelled to chime-in on this topic since it's important to me (and the squeaky wheel gets the grease. :-) Randall From geek+ at cmu.edu Mon Apr 5 12:36:56 1999 From: geek+ at cmu.edu (geek+ at cmu.edu) Date: 5 Apr 1999 12:36:56 -0400 Subject: Subattributes of classes Message-ID: Then spoke up and said: > Randall Hopper wrote: > > > Why? > > Because "attr" in class A is just an int, and has no attributes, > whereas "draw" in the Tkinter demo is a Canvas object, which has a > scrollX and scrollY attribute. Actually, this is both right and wrong. It doesn't matter whether or not the object has attributes. What matters is whether or not the object is mutable. An integer object is not mutable. This is one of the reasons there is no increment operator for integers. Such an operation is usually semantically "in place", where it would have to be a factory function (like +) in Python. -- ===================================================================== | JAVA must have been developed in the wilds of West Virginia. | | After all, why else would it support only single inheritance?? | ===================================================================== | Finger geek at cmu.edu for my public key. | ===================================================================== -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 266 bytes Desc: not available URL: From nathan.froyd at rose-hulman.edu Tue Apr 27 22:44:00 1999 From: nathan.froyd at rose-hulman.edu (Nathan Froyd) Date: 27 Apr 1999 21:44:00 -0500 Subject: running application config files written in Python Message-ID: Say I have an application whose configuration language I want to be Python. I have all my extra types implemented in C. Now what I'm wondering is what's the best way to run that file so that the functions, variables, etc. get imported into the Python interpreter embedded in my program? Along the same lines, once I have run the file, what's the easiest way to find out if a particular function/variable has been defined? For example, if I always wanted to run the user-defined function `startup_func', how would I go about doing that? -- Nathan | nathan.froyd at rose-hulman.edu | http://www.rose-hulman.edu/~froydnj/ God went through hell so we don't have to. ICQ:18861764 | AOL:myrlyn007 Avoid the gates of hell. Use Linux. Python:"x='x=%s;x%%`x`';x%`x`" Evolution is a million line computer program falling into place by accident. From ruebe at aachen.heimat.de Fri Apr 23 17:02:23 1999 From: ruebe at aachen.heimat.de (Christian Scholz) Date: Fri, 23 Apr 1999 21:02:23 +0000 Subject: Problem while Installing.. References: <3720DF98.8CEC8D8F@aachen.heimat.de> Message-ID: <3720DFDF.F25E6775@aachen.heimat.de> Christian Scholz wrote: > Hi everybody! > > I have a strange problem right now: > > 'import exceptions' failed; use -v for traceback > Warning! Falling back to string-based exceptions > Fatal Python error: Cannot create string-based exceptions > IOT trap/Abort I also made the same with the -v switch: ruebe at server:/exports/home/homes/ruebe/prg/udmsearch-if > /opt/python1.5/bin/python -v 'import exceptions' failed; traceback: lost sys.stderr Warning! Falling back to string-based exceptions Fatal Python error: Cannot create string-based exceptions IOT trap/Abort Just to let you know.. :) -- christian From da at ski.org Mon Apr 19 12:24:30 1999 From: da at ski.org (David Ascher) Date: Mon, 19 Apr 1999 16:24:30 GMT Subject: Tkinter performance In-Reply-To: <371B4B39.8B78BC7A@foreman.ac.rwth-aachen.de> References: <371B4B39.8B78BC7A@foreman.ac.rwth-aachen.de> Message-ID: On Mon, 19 Apr 1999, Greg Landrum wrote: > While I'm at it, I have a performance question about Tkinter. > > I am thinking about doing a python/Tkinter port of a program > which currently uses C/Xlib (or C/quickdraw on the Mac). I'd > love to get this to work because then I would (finally) have > a version which could work under Win95/98/NT. But I'm worried > about performance issues. > > The program does 3D graphics (molecular/crystal visualization > and orbital plots). I handle all of the perspective/transformation > stuff myself, so I don't need any 3D functionality. I do need > something which can draw reasonably quickly however. > > Suppose I need to draw a couple hundred circles and several > thousand line segments (these are mostly connected, so I can > use things like XDrawLines to cut down function calls) at > every update. > 1) Can Tkinter on a "typical" PC (say a P200) deliver a > "reasonable" update rate (a couple of frames per second > would probably cut it)? > 2) Is there anyway to do double-buffering to avoid flashing > during redraws? > > I am guessing that the answer to both of these of these questions > is "No", but I'd love to hear a contrary opinion. I'd suggest using PyOpenGL with the NumPy extension. In combination, it can be quite fast, by pushing the loops to C extension modules. The only portability problem is to the mac -- there is no Togl widget for the mac yet. http://starship.python.net/~da/PyOpenGL --david ascher From fatjim at home.com Fri Apr 23 11:25:28 1999 From: fatjim at home.com (Jim Meier) Date: Fri, 23 Apr 1999 15:25:28 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <37207685.F29BE1AB@ingr.com> Message-ID: <3720921A.5C1651D8@home.com> "Magnus L. Hetland" wrote: > Joseph Robertson writes: > > This way you can create views on your data without actually trying to load it > > all. The tradeoff of course is memory for fileaccess time, but I found > > fileaccess to be faster than doing all the work 'up front'. > > Hm. Yes. > > If the size (in lines) of the records is constant, then you could, of > course, use seek to skip all the data while processing as well... Of course, if you were really SERIOUS about finishing the project quickly, you could ignore "seek" and just skip processing the data at all... *shy grin* -Jim From nospam at bitbucket.com Fri Apr 9 14:26:09 1999 From: nospam at bitbucket.com (Phil Mayes) Date: Fri, 9 Apr 1999 11:26:09 -0700 Subject: PyMIDI ? References: <7ekagq$sjq$1@news1.cableinet.co.uk> Message-ID: Jason Cunliffe wrote in message <7ekagq$sjq$1 at news1.cableinet.co.uk>... >Hello > >I am looking for pointers to any MIDI work done with Python. [snip] The excellent "Python Contributed Software" page at http://www.python.org/download/Contributed.html has a MIDI link way down near the bottom. -- Phil Mayes pmayes AT olivebr DOT com Olive Branch Software - home of Arranger http://www.olivebr.com/ From joe at strout.net Thu Apr 8 12:33:30 1999 From: joe at strout.net (Joe Strout) Date: Thu, 08 Apr 1999 09:33:30 -0700 Subject: PIL font questions Message-ID: I'm trying to work with drawing fonts in the Python Imaging Library. Questions: 1. I've never heard of BDF and PCF font descriptiors, and I certainly don't have any on my Mac system. No fonts seem to be included with PIL, either. So where can I get some fonts to use? 2. There doesn't seem to be any way within ImageFont and ImageDraw to set the size of a font. To scale a font, do I have to just draw to a temporary Image, then copy (transparent?) to my destination image with scaling? 3. I presume the answer also applies to drawing rotated text, but (here's hoping!) is there an easier way? Thanks, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From claird at NeoSoft.com Fri Apr 9 00:52:29 1999 From: claird at NeoSoft.com (Cameron Laird) Date: 8 Apr 1999 23:52:29 -0500 Subject: README: Python-URL! - the weekly guide to Python resources (Apr 8) Message-ID: <7ek12d$402$1@Starbase.NeoSoft.COM> It's been several weeks since the most recent installment of "Python-URL!". That's a bit of an embarrassment for a digest designed for weekly appearances, and only exacerbated by the wealth of good material in comp.lang.python. This publishing pause is likely to continue into May; I have hopes that I can schedule time then to restore its operation. In the meantime, I ask for your patience. ========================================================================= 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 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 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 (once we resume), ask to subscribe. -- The Python-URL! Team-- -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From Martin.Preishuber at stuco.uni-klu.ac.at Sun Apr 18 06:04:24 1999 From: Martin.Preishuber at stuco.uni-klu.ac.at (Martin Preishuber) Date: Sun, 18 Apr 1999 10:04:24 +0000 Subject: #!/usr/bin/env python -u References: <37175574.25EBDDBE@stuco.uni-klu.ac.at> Message-ID: <3719AE28.64164417@stuco.uni-klu.ac.at> Bill Janssen wrote: > Martin, Hi, > I'm not a big fan of the /usr/bin/env approach for Python scripts, > because at PARC many people run without having Python on their paths. > Many, many packages at PARC, including Python and ILU, are installed in > their own directory tree under either /project (/project/ILU/) or > /import (/import/python-1.5/). People enable or disable various > packages depending on what they're up to. > > So I tend to depend on GNU configure when I'm installing a script. I > actually look for Python in the user's environment, then use sed to > hard-code that path into the scripts before installing them. Can this > be done with RPM? Actually I do use autoconf ... but when building a RPM file, you use rpm -ba ... then it creates RPMS and SRPMS by doing the usualy configure;make;make install (when specified) ... on my own machine every occurence of python is been replaced by /usr/local/bin/python and the RPM is built with that path ... and therefor the final RPM requires /usr/local/bin/python ... and that's what I want to avoid, so I thought about the /usr/bin/env solution ... Martin -- Martin Preishuber - Student, ECLiPt Core Member, SysAdmin http://eclipt.uni-klu.ac.at, mailto:Martin.Preishuber at stuco.uni-klu.ac.at Badges? We don't need no stinking badges. From aahz at netcom.com Sat Apr 17 09:37:37 1999 From: aahz at netcom.com (Aahz Maruch) Date: Sat, 17 Apr 1999 13:37:37 GMT Subject: Why no "=" in if? (was Re: Quick fix to add "+=") References: <3717EE20.41343593@mediaone.net> <000701be888f$12fe2920$ee9e2299@tim> Message-ID: I'm getting really sick of the way I have to use this stupid construct: x = foo() if x: ... instead of if x = foo(): ... Why doesn't Guido get off his duff and fix this?????????! In article <000701be888f$12fe2920$ee9e2299 at tim>, Tim Peters wrote: > >can't-wait-for-a-resumption-of-the-assignment-expression-thread-ly >y'rs - tim Be careful what you ask for. You may get it. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Sometimes, you're not just out of left field, you're coming in all the way from outer space. From fredrik at pythonware.com Wed Apr 14 11:23:19 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 14 Apr 1999 15:23:19 GMT Subject: Help! PIL compiled into Tkinter in 1.5.2 (Tricky Bits!) References: Message-ID: <00b501be868a$bbc6a840$f29b12c2@pythonware.com> frank wrote: > The Setup.in file lists the following 2 lines: > # *** Uncomment and edit for PIL (TkImaging) extension only: > # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ 1. unpack Imaging-1.0b1.tar.gz on the same level as you unpacked Python. $ ls -l drwxr-xr-x 8 eff effie 1024 Mar 29 11:11 Imaging-1.0b1 drwxr-xr-x 15 eff effie 1024 Mar 25 12:54 Python-1.5.2b2 drwxr-xr-x 14 eff effie 512 Mar 25 10:32 tcl8.0.5 drwxr-xr-x 16 eff effie 512 Mar 25 10:40 tk8.0.5 2. build a standard version of Python (preferrably with dynamically loaded extensions) 3. build PIL according to the instructions in Imaging-1.0b1/README. 4. in Python-1.5.2/Modules/Setup, change the Tkinter section to something like (this assumes that you've # *** Always uncomment this (leave the leading underscore in!): _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ # *** Uncomment and edit to reflect where your Tcl/Tk headers are: -I/usr/local/include \ # *** Uncomment and edit to reflect where your X11 header files are: -I/usr/include/X11 \ # *** Uncomment and edit for PIL (TkImaging) extension only: -DWITH_PIL -I../../Imaging-1.0b1/libImaging ../../Imaging-1.0b1/Tk/tkImaging.c \ # *** Uncomment and edit to reflect where your Tcl/Tk libraries are: -L/usr/local/lib \ # *** Uncomment and edit to reflect your Tcl/Tk versions: -ltk8.0 -ltcl8.0 \ # *** Uncomment and edit to reflect where your X11 libraries are: -L/usr/lib \ # *** Always uncomment this; X11 libraries to link with: -lX11 5. rebuild Python. (works for me, at least) From un4e at rz.uni-karlsruhe.de Wed Apr 28 05:53:54 1999 From: un4e at rz.uni-karlsruhe.de (Bjoern Giesler) Date: Wed, 28 Apr 1999 09:53:54 GMT Subject: running application config files written in Python In-Reply-To: from "David Steuber" at Apr 28, 1999 03:11:57 AM References: Message-ID: Hi, According to David Steuber: > wanted to point out that you will be executing actual code not unlike > the VBA macros in Microsoft Word with this technique. The Melissa > virus was written in VBA in a Word document. If there is a way to > sandbox such code, I would love to hear how Look at the documentation of the "rexec" module in the Library Reference; should do exactly what you want. Regards, --Bjoern PS David: a) Faking headers is Not A Good Thing. b) 12 lines of signature (even more in your previous mails) are Not A Good Thing Either. -- --------------------------------/\--One OS to rule them all---Windows NT----- Bjoern Giesler / \ One OS to find them / <> \ One OS to bring them all -----------------------------/______\--And in the Darkness bind them--------- From zorro at zipzap.ch Wed Apr 14 04:31:34 1999 From: zorro at zipzap.ch (Boris Borcic) Date: Wed, 14 Apr 1999 10:31:34 +0200 Subject: Python as an ODBC *source* on windoze ? References: <01BE8604.AE1D9CC0.richard@folwell.com> Message-ID: <37145266.1127FE06@zipzap.ch> Richard Folwell wrote: > > It is certainly possible to implement a DBMS in Python (check out Gadfly!), but > I suspect that you are asking a different question. (?) Indeed. It is my (untested) understanding that the MS Access Report writer (and gui) can be exploited with data from other vendor's databases through ODBC. I was wondering if it was possible to configure python to serve data appropriately to queries from the report writer -- this doesn't mean implementing a full DBMS in python, only to feed back appropriately patterned data to the report generator. BB From fdrake at cnri.reston.va.us Tue Apr 13 09:26:56 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Tue, 13 Apr 1999 13:26:56 GMT Subject: CVS module In-Reply-To: <7evbjf$85f$1@anguish.transas.com> References: <7evbjf$85f$1@anguish.transas.com> Message-ID: <14099.17952.830567.515429@weyr.cnri.reston.va.us> Michael Sobolev writes: > My quick attempt to find something that would help me to cope with CVS files > failed. Could anybody advise me whether such a module exist? Under "such a Sorry to say, but I don't know of anything like this. On the other hand, I'd love to learn of something like this as well! (Can we say "IDLE plugin"? ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From williampark at my-dejanews.com Fri Apr 23 02:05:52 1999 From: williampark at my-dejanews.com (williampark at my-dejanews.com) Date: Fri, 23 Apr 1999 06:05:52 GMT Subject: I want to Journal Input and Log Output, any Help??? References: <01be74eb$b634c200$01656565@fidget> Message-ID: <7fp2jv$2vj$1@nnrp1.dejanews.com> In article <01be74eb$b634c200$01656565 at fidget>, "Jonathan Polley" wrote: > Hi, > > I am using python to control the testing of a series of integrated > systems. To make it easier for some of our engineers, I would like to be > able to journal the scripts that they enter interactively. Once they enter > a command, I would like to log the output to a file (to make it easier to > verify the results of the test). I have been using IDLE as my python > environment, and would like some ideas as to how to make the required edits > (I have made some edits, but I think this is beyond by current abilities). > > Thanks, > > Jonathan Polley > polley at netins.net At least in Unix, 'python | tee stdout.log' will log you stdout. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From fredrik at pythonware.com Thu Apr 15 10:56:29 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Apr 1999 14:56:29 GMT Subject: Different methods with same name but different signature? References: <3716909C.D8D1B372@fedex.com> <005201be8748$51e0bab0$f29b12c2@pythonware.com> <3715f36d.74192342@news.oh.verio.com> Message-ID: <002901be8750$2727dd50$f29b12c2@pythonware.com> Kevin Dahlhausen wrote: > >imho, it's also an improvement over the pure visitor pattern, > >since it allows you to generate "logical events" that doesn't > >correspond to "physical" data instances in your model. > > I don't quite follow you. Can you explain this in a more detail? here's an example from my upcoming Python book: one chapter deals with a simple 2D animation system. its animation subsystem generates Movie object, which has a list of Frame objects, each of which contain a list of Sprite objects. this representation can be rendered to a display, to vector graphic file formats, or to raster images (e.g. GIF animations, or "ARG" files). the rendering machinery is implemented via visitors, using the following interface: class Renderer(MovieRenderer): def movie_start(self, movie) # called before any subframes def movie_end(self, movie) # called after all subframes def frame_start(self, frame) # called for each new Frame, before # any shapes are visited def frame_end(self, frame) # called for each Frame, after all # shapes def sprite(self, sprite) # called for each Sprite the render implementations need to do things both before and after each Frame (e.g. blank the image memory for each new Frame, and flush the result to disk afterwards). the Movie, Frame, and Sprite classes have methods looking something like: class Frame: ... def accept(self, visitor): visitor.frame_start(self) for sprite in self.sprites: sprite.accept(visitor) visitor.frame_end(self) etc. makes sense? anyone got a better solution? (but be warned that code that includes apply(self.__do[tuple(map(type, args))], (self,) + args) (*) or similar stuff is automatically disqualified ;-) *) taken from an old post of mine... what was I thinking... From florent.heyworth at radbit.com Sun Apr 11 06:57:58 1999 From: florent.heyworth at radbit.com (Florent Heyworth) Date: Sun, 11 Apr 1999 12:57:58 +0200 Subject: Python's object model References: <37102ED0.933EDDA6@usa.net> Message-ID: <37108036.3F33C237@radbit.com> Francois Bedard wrote: > Hello, > > I'm new at Python. In the following program, "stack_1 pops stack_2's > content" (that's actually what it prints), which is obviously not what > I'm after - nor would expect. Is this how Python's object model really > works (kindly explain), is there some arcane rule that I've missed, or > is there some obvious mistake I just can't see? > > Aside from a few such quirks, it's quite an interesting language (I'm > using 1.5.1 - on both Linux and NT). > > Thanks, > > Francois > > ------------------------------------- > > class Stack: > stack = [] > > def push(self, value): > self.stack.append(value) > > def pop(self): > result = self.stack[-1] > del self.stack[-1] > return result > > class System: > stack_1 = Stack() > stack_2 = Stack() > > def __init__(self): > self.stack_1.push('stack_1\'s content') > self.stack_2.push('stack_2\'s content') > print 'stack_1 pops', self.stack_1.pop() > > # 'main' > > system = System() Hi Francois what you're seeing is the difference between a class and an instance variable. To see the behaviour you want you need to modify your stack class as follows: class Stack: def __init__(self): self.stack = [] def push(self, value): self.stack.append(value) def pop(self): result = self.stack[-1] del self.stack[-1] return result Otherwise the stack is a class variable which can be referred as Stack.stack() (this would then act as a class global). Cheers Florent Heyworth From joe at strout.net Fri Apr 9 13:22:00 1999 From: joe at strout.net (Joe Strout) Date: Fri, 09 Apr 1999 10:22:00 -0700 Subject: Publishing 'live' Python objects References: <7ekq6v$of7$1@news2.xs4all.nl> Message-ID: In article <7ekq6v$of7$1 at news2.xs4all.nl>, Camiel Dobbelaar wrote: > I'm looking for advice on the following: > > Suppose I have a Python program that essentially does the following: > > while 1: > read from stdin > > update some buffer objects > > I now wish to take a look at snapshots of those buffer objects in > 'real-time'. (the program continues running and updating the buffers) > I'd like to do this with HTTP. I'd suggest you periodically, during , copy the buffer objects to a file, e.g. with pickle. Then you can have another Python CGI script read these files and display them upon request. Cheers, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From gmcm at hypernet.com Wed Apr 7 13:54:56 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 7 Apr 1999 17:54:56 GMT Subject: Unable to register TclNotifier window class In-Reply-To: <1288673916-74845510@hypernet.com> References: <1288673916-74845510@hypernet.com> Message-ID: <1288614601-78413274@hypernet.com> [Talking to myself] Still don't know what the real problem was, but once I changed it to keep a reference to a frame I was using for alignment, the problem went away... > OK Tk wizards (hi, /F-bot!) > > I'm getting "Unable to register TclNotifier window class". > What does this mean? > > Details: > Python 1.5.2b2 on NT SP4 > > I'm doing a tree control / form style window: > a big frame > another frame, packed 'left' with a Pmw.ScrolledListBox acting as a > > tree control. > Then I have three different frames, each holding a "form" for > displaying / editing a particular record type. > When a new item in the tree control is selected, I "pack_forget" > (if > the record type has changed) the right hand frame, then "pack" the > appropriate frame and fill the form. > > Works dandy for 2 of the three forms. Actually, the problem form > fills properly, too, it just does a St Vitus dance until I kill the > whole app (it appears to be continually re-packing itself). My > console window has the mystery error. > > The problem form is the most complex (has the most widgets), but > otherwise they are all clones of each other. > > - Gordon - Gordon From mlh at idt.ntnu.no Tue Apr 27 07:59:44 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 27 Apr 1999 13:59:44 +0200 Subject: help References: Message-ID: "Stone Cold" writes: > I just got python and I need some help getting started. I have no > programing knowlodge yet but I want to know all the languges. can someone > help? > When you have your interpreter running, you might want to check out http://www.idi.ntnu.no/~mlh/python/hacking.html It is a programming tutorial that uses Python. > -- > Hi! I'm the signature virus 99! Magnus > Copy me into your signature and join the fun! Lie Hetland http://arcadia.laiv.org From wware-nospam at world.std.com Wed Apr 7 14:06:30 1999 From: wware-nospam at world.std.com (Will Ware) Date: Wed, 7 Apr 1999 18:06:30 GMT Subject: Python for embedded controllers? References: <7e09r7$16r$1@news.clarkson.edu> Message-ID: There is an effort by the Ryerson Amateur Radio Club (in Toronto, Ontario, Canada) to develop a microcontroller SIMM board that can run Linux, discussed at: http://ryeham.ee.ryerson.ca/uClinux/simm/ This board is being designed with a 68EZ328 dragonball microcontroller, 4 meg of flash, and 8 meg of dram. On the mailing list for this project, Michael Gorlick wrote: > We are currently porting Python to run on the Palm > Pilot under the Palm OS. We have the Python > interpreter whittled down to about 124 kB and > should have a demonstration version running by the > end of April (barring unforeseen technical > obstacles). Porting it to the uCSIMM under Linux > should be quite straightforward. -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Will Ware email: wware[at]world[dot]std[dot]com PGP fp (new key 07/15/97) 67683AE2 173FE781 A0D99636 0EAE6117 From fdrake at cnri.reston.va.us Mon Apr 12 17:55:58 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Mon, 12 Apr 1999 21:55:58 GMT Subject: Client side cookies in Python In-Reply-To: References: Message-ID: <14098.27630.44323.990874@weyr.cnri.reston.va.us> Aamir Sehbai writes: > While I will be trying to make his code work with Yahoo, if anyone else > has information about something similar, please share. Grail 0.6 contains a file, utils/cookielib.py, that might be useful on the client side. Note that debugging was minimal, and Grail doesn't actually use it (I didn't have time to finish the integration code). Let me know if you find problems with it. Grail is available at http://grail.cnri.reston.va.us/grail/. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From mark.thomas at gsc.gte.com Tue Apr 20 11:59:07 1999 From: mark.thomas at gsc.gte.com (Justin Development) Date: Tue, 20 Apr 1999 11:59:07 -0400 Subject: Tkinter->Tcl->Wsm Message-ID: <7fi88s$eq4$1@news.gte.com> I have created a Tkinter widget and am trying to pass some of it's information (specifically it's winfo_id ) to the UNIX Window or Workspace Manger. If I am correct I first need to pass the Tkinter information to Tcl which will then allow me to work with the Wsm. How do I do this? Any links or examples would also be helpful. From Brian at digicool.com Fri Apr 23 10:34:45 1999 From: Brian at digicool.com (Brian Lloyd) Date: Fri, 23 Apr 1999 14:34:45 GMT Subject: Python too slow for real world Message-ID: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> > Hi All, > > first off all: Sorry for that slightly provoking subject ;-) ... > > I just switched from perl to python because I think python makes live > easyer in bigger software projects. However I found out that perl is > more then 10 times faster then python in solving the > following probelm: > > I've got a file (130 MB) with ~ 300000 datasets of the form: > > >px0034 hypothetical protein or whatever description > LSADQISTVQASFDKVKGDPVGILYAVFKADPSIMAKFTQFAGKDLESIKGTAPFETHAN > RIVGFFSKIIGELPNIEADVNTFVASHKPRGVTHDQLNNFRAGFVSYMKAHTDFAGAEAA > WGATLDTFFGMIFSKM > > The word floowing the '>' is an identifier, the uppercase > letters in the > lines following the identifier are the data. Now I want to read and > write the contens of that file excluding some entries (given by a > dictionary with identifiers, e.g. 'px0034'). > > The following python code does the job: > > from re import * > from sys import * > > def read_write(i, o, exclude): > name = compile('^>(\S+)') # regex to fetch the identifier > l = i.readline() > while l: > if l[0] == '>': # are we in new dataset? > m = name.search(l) > if m and exclude.has_key(m.group(1)): # excluding current > dataset? > l = i.readline() > while l and l[0] != '>': # skip this dataset > l = i.readline() > pass > o.write(l) > l = i.readline() > > f = open('my_very_big_data_file','r') # datafile with ~300000 records > read_write(f, stdout, {}) # for a simple test I don't exclude > anything! > > It took 503.90 sec on a SGI Power Challange (R10000 CPU). An > appropiate > perl script does the same job in 32 sec (Same method, same loop > structure)! > > Since I've to call this routine about 1500 times it's a very big > difference in time and not realy accaptable. > > I'd realy like to know why python is so slow (or perl is so fast?) and > what I can do to improove speed of that routine. > > I don't want to switch back to perl - but honestly, is python > the right > language to process souch huge amount of data? > > ... > Please do convince me being a python programmer does not mean > being slow > ;-) > > Thanks very much for any help, > > Arne > Arne, While I'm not going to go near comparing Python to Perl, I will comment that different languages are just that - different. As such, the approach you would take in one language may not be the most appropriate (or comparable in speed or efficiency) to the approach you would take in another. The question here (IMHO) is not Python's appropriateness for processing large datasets (a fair number of scientist-types do this all the time), or even the speed of Python in general, but using the most appropriate algorithms in the context of the language in use. For example, Perl is very regex-centric, so your example Perl implementation is probably perfectly appropriate for Perl. Python tends to be more optimized for the general case, and if it were _me_, I wouldn't bother with using regular expressions in this case,. Since you have a predictable file format, there are more specific (and efficient) Python tools that you could use here. There are also some general optimizations that can be used in places where speed is an issue, such as avoiding repeated attribute lookups (esp. in loops). This version of your read_write function uses the same basic algorithm, but forgoes re for more specific tools (slicing, string.split) and has some examples of optimizations to mimimize attribute lookups. I haven't timed it or anything, but I'd be surprised if it wasn't noticeably faster. Hope this helps! import sys, string def read_write(input, output, exclude): # These assignments will save us a lot of attribute # lookups over the course of the big loop... ignore=exclude.has_key readline=input.readline write=output.write split=string.split line=readline() while line: if line[0]=='>': # knowing that the first char is a '>' and that # the rest of the chars up to the first space are # the id, we can avoid using re here... key=split(line)[0][1:] if ignore(key): line=readline() while line and line[0] != '>': # skip this record line=readline() continue write(line) line=readline() file=open('my_very_big_data_file','r') # datafile with ~300000 records read_write(f, sys.stdout, {}) Brian Lloyd brian at digicool.com Software Engineer 540.371.6909 Digital Creations http://www.digicool.com From phd at sun.med.ru Thu Apr 15 03:20:07 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Thu, 15 Apr 1999 07:20:07 GMT Subject: PIL fonts - Where are you? In-Reply-To: <7jbR2.3071$YU1.5576@newsr2.twcny.rr.com> References: <7jbR2.3071$YU1.5576@newsr2.twcny.rr.com> Message-ID: On Wed, 14 Apr 1999, Kevin K. Ehmka wrote: > Does anybody have some ready made fonts in PIL format they want to share? A I avn send you some. I'v compiled them from BDF fonts. English parts of these fonts are ASCII, but characters from 128 up are Cyrillic (Russian). If you have some BDF fonts, I could try to compile them to PIL format. > web site maybe? I was unsuccessful today creating any. What's the problem? > Thanks > > -- > Kevin Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From achrist at easystreet.com Wed Apr 28 22:19:57 1999 From: achrist at easystreet.com (Al Christians) Date: Wed, 28 Apr 1999 19:19:57 -0700 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> Message-ID: <3727C1CD.83078225@easystreet.com> > > >Actually, isn't Eiffel's type system famous for being full of holes? > > I'm familiar with the covariance/contravariance argument, but I've never > before heard anyone say anything about Eiffel being full of holes. What > problems have you heard of? > I think it's called changing availability by type, or some such. It is possible to delete a feature in a descendant class, leaving a hole in polymorphic calls through the base class. Al From tim_one at email.msn.com Tue Apr 27 23:49:02 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 27 Apr 1999 23:49:02 -0400 Subject: "Compiling" scripts before execution ? In-Reply-To: <19990426104245.A504861@vislab.epa.gov> Message-ID: <000801be912a$0e7ed680$29a02299@tim> [Randall Hopper] > One concern I've been mulling over lately is the potential problem > maintaining Python scripts over time. For example: > > 1) It's easy to never create (or to sever) a link to a > imported symbol defined in another module, and you may never > know it until python tries to execute the referencing line of > script code. > > 2) If the signature of an imported method changes, and all > references to it in all scripts aren't updated, you may never know > it until Python tries to execute one of these "broken" line of > script code. > ... > What are folks doing to keep this class of errors from being a problem? I use a text editor with extremely fast file-based search-and-replace <0.5 wink>. Short of that, signatures and exported symbols are part of a module's advertised contract, and a module has no right to change its contract unilaterally in an incompatible way. This isn't as flippant as it sounds (*almost*, but not quite ...). Python argument lists are exceedingly flexible beasts, and it's almost always possible to maintain backwards compatibility when changing a signature. > Is there a way to "lint" or compile Python code such that it > forces symbols to resolve when seen (possibly disallowing some dynamic > symbol definition available in the language (e.g. adding methods to > classes after class definition). Nope, you'll have to deal with it. The best stab at a Python "lint" is Aaron Watters's kjpylint, available from http://www.chordate.com/kwParsing/index.html It's not trying to do cross-module analysis, though. Python2 may or may not introduce some notion of optional static typing, which could catch this stuff for those motivated enough to use it. That's a Types-SIG topic. the-downside-of-a-dynamic-language-is-its-dynamicism-ly y'rs - tim From Jcantrl at ix.netcom.com Tue Apr 27 05:52:24 1999 From: Jcantrl at ix.netcom.com (Jcantrl at ix.netcom.com) Date: Tue, 27 Apr 1999 09:52:24 GMT Subject: Please unsubscribe Message-ID: <372588D8.DEB86C58@ix.netcom.com> Please Usubscibe me from your mailing list,Thank you Sincerely Jcantrl at ix.netcom.com From xidicone at iname.com Mon Apr 19 07:22:41 1999 From: xidicone at iname.com (Jussi Jumppanen) Date: Mon, 19 Apr 1999 22:22:41 +1100 Subject: 'import exceptions' failed Message-ID: <371B1201.392B@iname.com> I have compiled the python source into a Windows DLL and using this DLL I have embedd python into and windows text editor. Now when I run the following macro script: import editor_functions def key_macro(): print "this is a macro."; key_macro() # run the macro the macro runs fine and produces the expected ouput in the text editor, but I also get the following messages sent to stderr: 'import exceptions' failed; use -v for traceback defaulting to old style exceptions 'import site' failed; use -v for traceback To run the macro it is saved to file and is run using the python API: PyRun_SimpleFile My question is have I missed something? What setup changes do I need to do to remove this error or how do I simulate -v using the Python API C functions so that this error is not generated? Thanks in advance. Cheers Jussi Jumppanen From sdm7g at Virginia.EDU Fri Apr 23 21:01:54 1999 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 23 Apr 1999 21:01:54 -0400 (EDT) Subject: controling a Python daemon with mail In-Reply-To: <84k8v3t4sw.fsf@mail.utexas.edu> References: <84k8v3t4sw.fsf@mail.utexas.edu> Message-ID: On 23 Apr 1999, Preston Landers wrote: > I've looked at the mailbox.UnixMailbox package. I am able to write a > script that retrieves each message in /var/spool/mail/myuser and > displays the sender, recipient, and subject. I am able to generate a > reply using /usr/bin/mail. But for the life of me, I cannot look at > the body of the incoming message. Silly me. Where in the > documentation is this describe? 10 points to anyone who can point out > the specific place to me. Yeah -- mailbox and rfc822 aren't the prettiest modules in the Python libraries! Here's where the class browser in the Mac Python IDE comes in handy, along with some interactive snooping. >>> mb = mailbox.UnixMailbox( open( 'OneGig:Python+11', 'r' )) >>> mb ## mb is a mailbox >>> dir(mb) ['fp', 'seekp'] >>> a = mb.next() >>> a ## a is a message. >>> dir(a) ['dict', 'fp', 'headers', 'seekable', 'startofbody', 'startofheaders', 'status', 'unixfrom'] >>> a >>> a.fp >>> a.fp.fp # a's _Subfile is what you want, speficially, for the message body: >>> print a.fp.read() > Periodically, I want my daemon to check a standard Unix mail spool > file for new messages. Under certain conditions, I want the script to > act on those messages (ie, do its thang on the contents of the message > and mail the results back to the sender.) However, the typical way to do this sort of thing on unix is to redirect all messages with a .forward file to dispatcher program that gets each message one at a time on it's standard input. Thus you don't have to check the spool periodically -- the program gets triggered as part of the mail delivery. There are unix programs like procmail & filter that already do this. ( and procmail has a companion program, formail, which among other things can split a mailbox up into separate messages, pipeing each one to a new procmail process, thus simulating the delivery process in batch mode. ) You can use a python script in place of procmail -- in which case, it doesn't have to split a mailbox into separate messages -- it gets a single message on it's standard input. Or, you can use procmail to selectively send particular messages to another script. Or, you can select a subset of messages and redirect them into a different file, which can be the input for your batch processing. You might also want to look a Mailman -- which is a mailing list manager written in Python. It may already have most of the tools you need for your responder. ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- Caldera Open Linux: "Powerful and easy to use!" -- Microsoft(*) (*) From cjw at connection.com Wed Apr 28 17:10:42 1999 From: cjw at connection.com (Colin J. Williams) Date: Wed, 28 Apr 1999 17:10:42 -0400 Subject: IDLE Problem Message-ID: <37277952.3551E595@connection.com> a= 99 print 'UGH' a= 101 When one steps through this code, the print statement hangs the Windows. This happens when one Steps Over the command or when one Steps and the Steps Out. Colin W. From KUNCEJ at mail.conservation.state.mo.us Fri Apr 23 11:01:27 1999 From: KUNCEJ at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Fri, 23 Apr 1999 15:01:27 GMT Subject: How do I use proxies with httplib? Message-ID: >I see that urllib has that covered. So I tried it out, only to run up >against a problem that I want to blame on urllib; it claims to not >recognize the http url type: proxies in urllib for 1.5.1 will work if you apply the two patches found on the [now somewhat buried] "Patches for Python 1.5.1" page: http://www.python.org/1.5/patches-1.5.1/ Or, as Chad suggested, upgrade to 1.5.2 --Jeff From trashcan at david-steuber.com Fri Apr 30 18:06:00 1999 From: trashcan at david-steuber.com (David Steuber) Date: 30 Apr 1999 18:06:00 -0400 Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> <7g99pj$b1$1@news.worldonline.nl> Message-ID: "Ilja Heitlager" writes: -> OK, A UNIX guy (that will change ;-) Why, has a better OS come out? -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. "BASIC is the Computer Science equivalent of `Scientific Creationism'." From tismer at appliedbiometrics.com Sat Apr 10 08:14:50 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sat, 10 Apr 1999 12:14:50 GMT Subject: import from user input? What about 'from'? References: <816010E2456BD111A48700805FBBE2EEA63EB9@ex-quebec-u1.baan.com> <370E0F51.E1D33D6@appliedbiometrics.com> <370E4EFB.3D9355BF@vision.arc.nasa.gov> Message-ID: <370F40BA.A1A28A1B@appliedbiometrics.com> Chad Netzer wrote: > Christian Tismer wrote: > > > Instead, one should cut off the first name before the first dot > > and put that into globals(). > > > > import string > > globals()[string.split(modname, ".")[0]] = __import__(modname) > > > > seems to do it better. > > Hmm, what if I want to do something like: > > exec 'from ' + module_name + ' import ' + class_name > > Can I use the __import__call, and then just save the specific module name in globals()? > ie. (minus exception checking): > > globals()[class_name] = getattr(__import__(module_name), class_name) Yes, this is ok with a single module and a single object in the module. But for a full from package.subpackage.module import object you need to read the description of __import__ in section 2.3 of the Python Library Reference and do a bit more. Using the full __import__ syntax of __import__ (name[, globals[, locals[, fromlist]]]) import package.subpackage.module must be handled in a way that "package" goes into your module, but "subpackage" gets imported into "package", and "module" gets imported into "subpackage". WHich means, our handle's name to be put into globals is "package". On the other hand, for a from package.subpackage.module import object we need to work downhill from "package" to "module" and pick the attribute "object", and we don't insert any module into globals. Example: >>> target = "constants" >>> modname = "win32com.client" >>> fromlist = ["client"] >>> glob = globals() >>> loc=locals() >>> glob[target] = getattr(__import__(modname, glob, loc, fromlist), target) >>> constants >>> This the exact equivalent of from win32com.client import constants Please don't ask me why fromlist has to be a list, dunno. But its non-emptiness makes __import__ return the last, not the first element in pi.pa.po . To get the full idea what happens, I'd further read the module knee.py, which is a description what happens internally today. Maybe someone can explain the details of fromlist to me :-) ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 mal at lemburg.com Sat Apr 3 08:30:54 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 3 Apr 1999 13:30:54 GMT Subject: Has anyone SWIGged libwww ? Message-ID: <3706180E.1E07D605@lemburg.com> Well, the subject says it all. libwww is a W3C library which implements HTTP 1.1, FTP, etc. and is available from: http://www.w3.org/Library/ -- Marc-Andre Lemburg Y2000: 272 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From john.michelsen at gte.net Wed Apr 7 13:29:29 1999 From: john.michelsen at gte.net (John Michelsen) Date: Wed, 7 Apr 1999 10:29:29 -0700 Subject: Tkinter MDI, dockable toolbars, tree, progressbar, flatbuttons Message-ID: <7eg2rd$4fm$1@news-2.news.gte.net> I've been working on some new widgets for Tkinter including a MDI, dockable toolbars, tree, progressbar, and flatbuttons. The MDI is almost done, though there are some problems with resizing the child windows and setting the focus to half-way buried child windows. Resizing only seems to make the child windows bigger, for some reason, and rarely smaller. Setting the focus to a buried child window is problematic because most of the time the child window has children of its own on top of it, and binding the child window's setFocus method to clicks on its children doesn't seem to do anything. Also, I have no idea how the widgets look on unix or mac, so they probably look pretty bad because of a mish-mash of styles (I copied the windows icons, etc. with gifs and canvas items). If anyone could send me gifs of widgets on other platforms, I could put in some platform specific code to make them look nicer there. Any help is appreciated - The files are available at: http://www2.zyvex.com/OpenChem/Widgets.zip John From jason at harlequin.com Thu Apr 29 06:48:23 1999 From: jason at harlequin.com (Jason Trenouth) Date: Thu, 29 Apr 1999 10:48:23 GMT Subject: Dylan vrs Python (was; Re: Python IS slow ! [was] Re: Python too slow for real world) References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> <7g89eg$vb0$1@brick.cswv.com> Message-ID: <375533c2.241102625@newshost> On 28 Apr 1999 19:34:24 -0500, neelk at brick.cswv.com (Neel Krishnaswami) wrote: > In article <372769B0.3CE8C0F3 at prescod.net>, > Paul Prescod wrote: > >William Tanksley wrote: > >> > >> And Oberon (SlimBinaries), and Eiffel (typing and general compile-time > >> error catching), and ... > > > >Actually, isn't Eiffel's type system famous for being full of holes? > > > >Regardless, wouldn't a better source of inspiration on typing be a > >language with *optional* compile-time error checking? > > I've been playing around with Dylan recently, and it seems like what > Python would be if you added "end" blocks and mated it with CLOS. Since > Dylan is nearly as dynamic as Python, I think it might be a good source > of inspiration for Python 2. (And it might even be the case that the > Dylan-to-C compiler might be a source of good bits to improve Python's > speed. I haven't looked at the source yet, though.) Conversely, I was just looking at Python recently (as related work for a paper). The Python community might like to take a look at Dylan: http://www.gwydiondylan.org http://www.harlequin.com/products/ads/dylan/ As a taster, here is the "invert" example in Python and Dylan: # Python def invert(table): index = {} # empty dictionary for key in table.keys(): value = table[key] if not index.has_key(value): index[value] = [] # empty list index[value].append(key) return index // Dylan define function invert (table) let index = make(); for (value keyed-by key in table) index[value] := add!(element(index, value, default: #()), key); end; index end; The "keyed-by" clause in the "for" statement is a slight cheat since it is a Harlequin extension (otherwise the Dylan code would be even more similar to the Python code). with-heavy-troll () What would you give for interactive development and native compilation and incremental gc and objects-all-the-way-down and extensible syntax and COM and CORBA and a great GUI toolkit? end; :-j __Jason From dkuhlman at netcom.com Sun Apr 18 18:24:02 1999 From: dkuhlman at netcom.com (G. David Kuhlman) Date: Sun, 18 Apr 1999 22:24:02 GMT Subject: binary References: <37171BD5.87CFA015@efes.net.tr> Message-ID: Just van Rossum wrote: > At 2:15 PM +0300 4/16/99, Murat Yeneroglu wrote: > >Hi, > >I want to ask that how I can convert a decimal number to binary in > >python ? > >THNX > Take a look at the "struct" module. > Just And, also look at xdrlib in the standard Python library. XDR is a binary format, right? And, it follows a standard, too. - Dave From SRichter at ixl.com Sun Apr 11 12:37:30 1999 From: SRichter at ixl.com (Stephan Richter) Date: Sun, 11 Apr 1999 11:37:30 -0500 Subject: gdmodule - additional fonts Message-ID: <923849189.1852633921@news.ixl.com> This message is in MIME format. From Marten.Hedman at btk.utu.fi Wed Apr 14 02:17:21 1999 From: Marten.Hedman at btk.utu.fi (=?iso-8859-1?Q?M=E5rten?= Hedman) Date: Wed, 14 Apr 1999 09:17:21 +0300 Subject: Help: Tkinter, bad event type Message-ID: <371432F0.28E2C614@btk.utu.fi> Many thanks to both Don and Fredrik for their prompt answers to my question. I searched my system an found old versions of both tk80.dll and tcl80.dll in C:\winnt\system32. When I deleted them, my python scripts worked fine. Thanks again. Marten Hedman Centre for Biotechnology Turku, Finland From basv at sara.nl Tue Apr 27 04:29:20 1999 From: basv at sara.nl (basv at sara.nl) Date: Tue, 27 Apr 1999 08:29:20 GMT Subject: Trouble with httplib and IRIX References: <7g219p$hvb$1@nnrp1.dejanews.com> <3724CF13.C4680904@bioreason.com> Message-ID: <7g3sgs$87n$1@nnrp1.dejanews.com> In article <3724CF13.C4680904 at bioreason.com>, Andrew Dalke wrote: > basv at sara.nl said: > > I'm running python 1.5.2 and running it on IRIX 6.5.3 systems. > > ... > > I have the following problem when i'm trying to connect to an > > non-existing machine the program hangs forever. > > I don't get that behaviour using 1.5.2c1 or 1.5.1 on either of > our 6.5.2m machines. > > max> pwd > /home/u05/dalke/ftps/Python-1.5.2c1 > max> env PYTHONPATH=Lib ./python > Python 1.5.2c1 (#4, Apr 14 1999, 16:29:33) [C] on irix6 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import socket > >>> import httplib > >>> httplib.__file__ > 'Lib/httplib.pyc' > >>> def main(): > ... h = httplib.HTTP() > ... h.set_debuglevel(100) > ... try: > ... h.connect("www.nsrc.nus.sg") > ... except socket.error, detail: > ... print 'Connect failed: %s' %detail > ... > >>> main() > connect: ('www.nsrc.nus.sg', 80) > Connect failed: host not found > >>> ^D > max> uname -aR > IRIX64 max 6.5 6.5.2m 11051732 IP30 > > Can you attach a debugger or force a core dump and see where it's > hanging? I have attached the debugger to the process (dbx -p ) and it gives the following message: Source (of /xlv57/6.5.3m/work/irix/lib/libc/libc_n32_M4/sys/nanosleep.s) not available for Process 344004 Below is the output of the first 9 lines from the 'dbx' output: 0 __nanosleep(0x7fff1af8, 0x0, 0xfb545b8, 0x0, 0x101a3ef9, 0x250000, 0xf, 0x77) ["/xlv57/6.5.3m/work/irix/lib/libc/libc_n32_M4/sys/nanosleep.s":15, 0xfaf6e38] 1 _usleep(0x186a0, 0x0, 0xfb545b8, 0x5f5e100, 0x101a3ef9, 0x250000, 0xf, 0x77) ["/xlv57/6.5.3m/work/irix/lib/libc/libc_n32_M4/gen/usleep.c":46, 0xfa52f60] 2 _ns_lookup(0x7fff1af8, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0xf) ["/xlv57/6.5.3m/work/irix/lib/libc/libc_n32_M4/ns/ns_lookup.c":175, 0xfaa8610] 3 _gethostbyname_r(0x7fff1af8, 0x101970c0, 0x101a3ef0, 0x0, 0x101a3ef9, 0x250000, 0xf, 0x77) ["/xlv57/6.5.3m/work/irix/lib/libc/libc_n32_M4/ns/ns_hosts.c":470, 0xfb165f8] 4 _gethostbyname(0x101a03e4, 0x0, 0xfb545b8, 0x0, 0x101a3ef9, 0x250000, 0xf, 0x77) ["/xlv57/6.5.3m/work/irix/lib/libc/libc_n32_M4/ns/ns_hosts.c":532, 0xfb16880] 5 setipaddr(0x101a03e4, 0x0, 0xfb545b8, 0x0, 0x101a3ef9, 0x250000, 0xf, 0x77) ["/home/sara/bas/src/applications/Python/Python-1.5.2/Modules/socketmodule.c" :404, 0x1006f6d0] 6 getsockaddrarg(0x7fff1af8, 0x0, 0x0, 0x0, 0x101a3ef9, 0x0, 0xf, 0x77) ["/home/sara/bas/src/applications/Python/Python-1.5.2/Modules/socketmodule.c" :544, 0x1006f980] 7 PySocketSock_connect(0x0, 0x0, 0xfb545b8, 0x0, 0x101a3ef9, 0x250000, 0xf, 0x77) ["/home/sara/bas/src/applications/Python/Python-1.5.2/Modules/socketmodule.c" :851, 0x100701c8] 8 call_builtin(0x2, 0x0, 0xfb545b8, 0x0, 0x101a3ef9, 0x250000, 0xf, 0x77) ["/home/sara/bas/src/applications/Python/Python-1.5.2/Python/ceval.c":2359, 0x1003d798] 9 PyEval_CallObjectWithKeywords(0x1019c028, 0x101970e0, 0x0, 0x0, 0x101a3ef9, 0x250000, 0xf, 0x77) ["/home/sara/bas/src/applications/Python/Python-1.5.2/Python/ceval.c":2324, 0x1003d4b0] -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From downstairs at home.com Thu Apr 8 01:25:30 1999 From: downstairs at home.com (TM) Date: Thu, 08 Apr 1999 05:25:30 GMT Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <7e30fp$8vf$1@news1.rmi.net> <14085.18282.936883.727575@bitdiddle.cnri.reston.va.us> <7ectjd$516$1@srv38s4u.cas.org> Message-ID: > > Elsewhere in this thread there have been discussions regarding the fact > that it's been several years since the last major Python book was released. Now that you mentioned it, I remember hearing that someone was writeing a Python TKinter book......what the hell ever happened to that?!?! Tom From jeremy at cnri.reston.va.us Thu Apr 29 10:44:06 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 29 Apr 1999 10:44:06 -0400 (EDT) Subject: try vs. has_key() In-Reply-To: <372789d8.27766891@news.jpl.nasa.gov> References: <37247ea3.494305@news.jpl.nasa.gov> <372789d8.27766891@news.jpl.nasa.gov> Message-ID: <14120.28625.776623.556213@bitdiddle.cnri.reston.va.us> >>>>> "WD" == William H Duquette writes: WD> As someone pointed out, append() returns None, explaining the WD> result I got. However, the following code works just fine: d = {} a = 'foo' # Append an entry to d[a], whether it has been initialized or not: d[a] = d.get(a, []) d[a].append('Bar') However, you're doing two dictionary lookups when only one is necessary. It would be more efficient to store the results of the get in a temporary variable -- temp = d[a] = d.get(a, []) -- and use the temporary variable for the append. Jeremy From news at dorb.com Mon Apr 5 13:33:24 1999 From: news at dorb.com (Darrell) Date: Mon, 5 Apr 1999 13:33:24 -0400 Subject: swig or not to swig ? Message-ID: <4p6O2.1348$8m5.2126@newsr1.twcny.rr.com> Coding a 'C' interface to python seems straight forward. Is swig worth the trouble ? I want to access some shared libs. I tried the dl module which isn't obvious how it works. import dl fails. From tim_one at email.msn.com Sun Apr 11 16:42:51 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 11 Apr 1999 20:42:51 GMT Subject: Python Chip In-Reply-To: <3709CFC0.BCB0990A@pop.vet.uu.nl> References: <3709CFC0.BCB0990A@pop.vet.uu.nl> Message-ID: <000a01be845b$de38b020$2a9e2299@tim> [Martijn Faassen] > Hi everybody, > > For those who are still anxiously itching to get their hands on a Python > machine, this was of course an April Fool's joke. :) Oh, *now* you tell me, just hours before we were to tape out final silicon! Wonder whether I can get my money back. > You can now all come to destroy me now. (any other jokes in this > newsgroup which I missed?) Marc posted a nice amendment to his conference's menu, but all in all c.l.py was a deadly serious gaggle of humorless geekoids this year. Maybe that's appropriate, though, since Guido *was* run over by an April 1st bus. thank-god-for-the-fully-automated-python-release-process-ly y'rs - tim From mike.steed at natinst.com Thu Apr 29 11:20:38 1999 From: mike.steed at natinst.com (Mike Steed) Date: Thu, 29 Apr 1999 10:20:38 -0500 Subject: GUI and creating GIF References: <7g7u2k$fr0$1@wanadoo.fr> <3727CA5A.68BD@ccms.net> <372806B7.E050A0CF@vic.bigpond.net.au> Message-ID: <372878C6.2CD3858A@natinst.com> John Leach wrote: > > I'd also like to use gdmodule but I can't understand the documentation > (I've emailed to ask Richard Jones for more docs). I'm new to Python. > Does anyone have any sample programs they can send? You might look at Richard's httpd logfile reporting tool (graph.py uses gdmodule). http://starship.python.net/~richard/httpd_log/ Also, below is a simple demo that used to be distributed with gdmodule, although it doesn't appear to be on Richard's site anymore. I don't have "demoin.gif", so you will have to tweak the code some.... -Mike ----- #!/usr/local/bin/python -i import gd import sys # our test output image im_out=gd.image((128,128)) white = im_out.colorAllocate((255,255,255)) im_out.colorTransparent(white) # input image im_in=gd.image("demoin.gif") im_in.copyResizedTo(im_out,(16,16),(0,0),(96,96)) red = im_out.colorAllocate((255,0,0)) green = im_out.colorAllocate((0,255,0)) blue = im_out.colorAllocate((0,0,255)) # test origin - switch to lower left type origin im_out.origin((0,128),1,-1) im_out.line((50,0),(128,50), red) im_out.origin((0,0),1,1) # rectangle im_out.line((8,8), (120,8), green) im_out.line((120,8), (120,120), green) im_out.line((120,120), (8,120), green) im_out.line((8,120), (8,8), green) im_out.string(gd.gdFontLarge, (16,16), "hi", red) im_out.stringUp(gd.gdFontSmall, (32,32), "hi", red) im_out.arc((64,64), (30,10), 0, 360, blue) im_out.arc((64,64), (20,20), 45, 135, blue) im_out.fill((4,4), blue) im_out.polygon(((32,0),(0,64),(64,64)),green) # a brush im_out.setBrush(gd.image(im_in,(8,8))) im_out.setStyle((0,0,0,0,0,0,0,1)) im_out.line((128,0),(0,128),gd.gdStyledBrushed) im_out.interlace(1) im_out.writeGif("demoout.gif") From mnot at pobox.com Wed Apr 28 18:17:08 1999 From: mnot at pobox.com (Mark Nottingham) Date: Wed, 28 Apr 1999 22:17:08 GMT Subject: HTML "sanitizer" in Python References: <19990428152042.A708@better.net> Message-ID: <00e501be91c4$db944f20$0301a8c0@cbd.net.au> There's a better (albeit non-Python) way. Check out http://www.w3.org/People/Raggett/tidy/ Tidy will do wonderful things in terms of making HTML compliant with the spec (closing tags, cleaning up the crud that Word makes, etc.) As a big bonus, it will remove all tags, etc, and replace them with CSS1 style sheets. Wow. It's C, and is also available with a windows GUI (HTML-Kit) that makes a pretty good HTML editor as well. On Unix, it's a command line utility, so you can use it (clumsily) from a Python program. I suppose an extension could also be written; will look into this (or if anyone does it, please tell me!) ----- Original Message ----- From: William Park Newsgroups: comp.lang.python To: Sent: Thursday, April 29, 1999 5:20 Subject: Re: HTML "sanitizer" in Python > On Wed, Apr 28, 1999 at 12:49:55PM -0400, Scott Stirling wrote: > > Hi, > > > > I am new to Python. I have an idea of a work-related project I want > > to do, and I was hoping some folks on this list might be able to > > help me realize it. I have Mark Lutz' _Programming Python_ book, > > and that has been a helpful orientation. I like his basic packer > > and unpacker scripts, but what I want to do is something in between > > that basic program and its later, more complex manifestations. > > > > I am on a Y2K project with 14 manufacturing plants, each of which > > has an inventory of plant process components that need to be tested > > and/or replaced. I want to put each plant's current inventory on > > the corporate intranet on a weekly or biweekly basis. All the plant > > data is in an Access database. We are querying the data we need and > > importing into 14 MS Excel 97 spreadsheets. Then we are saving the > > Excel sheets as HTML. The HTML files bloat out with a near 100% > > increase in file size over the original Excel files. This is > > because the HTML converter in Excel adds all kinds of unnecessary > > HTML code, such as for every single > > cell in the table. Many of these tables have over 1000 cells, and > > this code, along with its accompanying closing FONT tag, add up > > quick. The other main, unnecessary code is the ALIGN="left" > > attribute in
tags (the default alignment _is_ left). The > > unnecessary tags are consistent and easy to identify, and a routine > > sh! > > ould be writable that will automate the removal of them. > > > > I created a Macro in Visual SlickEdit that automatically opens all > > these HTML files, finds and deletes all the tags that can be > > deleted, saves the changes and closes them. I originally wanted to > > do this in Python, and I would still like to know how, but time > > constraints prevented it at the time. Now I want to work on how to > > create a Python program that will do this. Can anyone help? Has > > anyone written anything like this in Python already that they can > > point me too? I would really appreciate it. > > > > Again, the main flow of the program is: > > > > >> Open 14 HTML files, all in the same folder and all with the .html > > >> extension. Find certain character strings and delete them from > > >> the files. In one case (the tags) it is easier to find the > > >> whole tag with attributes and then _replace_ the original tag > > >> with a plain . Save the files. Close the files. Exit the > > >> program. > > Hi Scott, > > I shall assume that a tag occurs in one line. Try 'sed', > for i in *.html > do sed -e 's///g" $i > /tmp/$i && mv /tmp/$i $i > done > or, in Python, > for s in open('...', 'r').readlines(): > s = string.replace('', '', s) > print string.strip(s) > > If tag spans over more than one line, then read the file in > whole, like > for s in open('...', 'r').read(): > > If the tag is not consistent, then you may have to use regular > expression with 're' module. > > Hopes this helps. > William > > > > > > More advanced options would be the ability for the user to set > > parameters for the program upon running it, to keep from hard-coding > > the find and replace parms. > > To use command line parameters, like > $ cleantd 'ALIGN="left"' > change to > s = string.replace('' % sys.argv[1], '', s) > > > > > OK, thanks to any help you can provide. I partly was turned on to > > Python by Eric Raymond's article, "How to Become a Hacker" (featured > > on /.). I use Linux at home, but this program would be for use on a > > Windows 95 platform at work, if that makes any difference. I do > > have the latest Python interpreter and editor for Windows here at > > work. > > > > Yours truly, > > Scott > > > > Scott M. Stirling > > Visit the HOLNAM Year 2000 Web Site: http://web/y2k > > Keane - Holnam Year 2000 Project > > Office: 734/529-2411 ext. 2327 fax: 734/529-5066 email: sstirlin at holnam.com > > > > > > -- > > http://www.python.org/mailman/listinfo/python-list > > > > From tismer at appliedbiometrics.com Mon Apr 26 11:07:42 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Mon, 26 Apr 1999 15:07:42 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> Message-ID: <3724813E.ED53908F@appliedbiometrics.com> Moshe Zadka wrote: > > On 25 Apr 1999, Magnus L. Hetland wrote: ... > > Now, that's really simple -- because re.py is slow. I thought maybe > > some of the slowness might be improved by a c-implementation, that's > > all. Not too important to me... > > Um....two wrong assumptions here: > 1. C implementation is /not/ the same as core status: C extension modules > are numerous and wonderful, for example... As Mark already pointed out, what's the difference? You will not see any performance change, wether a module is in the core or in an extra dll. The calling mechanism is always the same, (well, the call instr under X86 takes 1 byte more to the dll :-) and not very fast. So the less calls, the better. > 2. re.py is a (very thin) wrapper around pcre, a C extension module for > Perl Compatible Regular Expressions. Right, but it carries the class protocol overhead all the time. Returning mathes always involves creation of an instance of a match object, and a number of tuple building operations are involved. This is where unnecessary interpreter overhead can be saved, and results could be created more efficiently from a c extension, since it is not forced to hold every intermediate result by a Python object which involves memory allocation, and so on. > Which just goes to say that while pcre can certainly be optimized, it > can't be done by simply rewriting it in C. > <0.5 wink> Surely not since it is written in C <1.5 wink>. If you are referring to re.py, a (nearly) direct translation into C would indeed not help too much. P2C does that, but since it can only remove the interpreter overhead, you will not save more than 30-40 percent. A hand-coded C version would try to avoid as much overhead as possible. The main difference is that you know the data types which you are dealing with, so you will optimize this case, instead of having to take care of the general case as Python does. But if Python had an optional strong type concept already, plus some sealing option for modules and classes which would allow to use compiled method tables instead of attribute lookups, things could change dramatically. Given that, re.py could be made fast enough without involving C, I believe. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 fredrik at pythonware.com Tue Apr 20 11:06:59 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Apr 1999 15:06:59 GMT Subject: Tkinter canvas scaling does not work for Images?? References: <87hfqbjtne.fsf@linux01.prc.tno.nl> Message-ID: <02cb01be8b3f$71912250$f29b12c2@pythonware.com> John van der Koijk wrote: > I'm playing around with Pmw and (thus Tkinter). After some > experiments, I found out that I can scale lines and such, but Images > do not seem to respond to similar requests. The docs don't seem to > mention this interesting limitation. answer 1: the "scale" method modifies the item coordinates only. since bitmaps, images, windows, and text strings have a single coordinate pair, they can only move around, not change size... answer 2: resizing images and fonts on the fly is a non-trivial problem, especially if you want both performance and port- ability. so Tk simply passes on this one... in other words, you're on your own. it can be done, but it takes some work... From tismer at appliedbiometrics.com Fri Apr 30 13:20:07 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 30 Apr 1999 17:20:07 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <7g9qmo$luf$1@news.udel.edu> <372965CA.2B3FD2FE@appliedbiometrics.com> <19990430080805.B776752@vislab.epa.gov> <3729A9F3.75B2692B@appliedbiometrics.com> <19990430101215.A806665@vislab.epa.gov> <3729CD92.43477316@appliedbiometrics.com> <19990430130807.A812795@vislab.epa.gov> Message-ID: <3729E647.B38DFE72@appliedbiometrics.com> Randall Hopper wrote: [me, trying to give an example of forward references] > Well, I personally would call this "broken". :-) > Base class A calling subclass B's method M without declaring a virtual > method M itself is very perverse IMO. Then please go and tell this to Jim Fulton (Bobo/Zope) or look into the XML-sig's parsers. A mixin class is a mixin, which is not supposed to produce prototypes for everybody who uses it. This is a different idea which is implied by multiple inheritance, IMHO. > If we have: > class parserops: > "mixin class" > def general_method1(self, *args): > self.parser_method(self.scanner, args) > def parser_method(self,...) > """ Pure virtual method """ > pass > ... > > Then there's no problem. self.parse_method will always resolve, possibly > to a subclass method but at least to this pure virtual stub. > > |It will also not resolve self.magic, since it doesn't > |inherit from abstractparser. > > I bet you 5 bucks you know what I'm going to say. :-) > Accessing attributes of a sibling base class united by a future subclass? > [Cringe!] Sheesh. I wouldn't want to try to follow _that_ code, much less > debug it. We were not talking style or how to do things, but theory. Existing code would break. Some could be fixed, some not, all-in-all I don't want to change the language, but have my (at least:) programs run very fast. > > |Yes, but this would limit Python down to Pascal like name spaces. > |You would need all kinds of tricks to write recoursions like > | > |def two(arg): > | if arg % 2 == 0: > | return three(arg-1) > | return arg > | > |def three(arg): > | if arg % 3 == 0: > | return two(arg-1) > | return arg > > Good point for deferring resolution until the end of the module. > I'm sold. I'd prefer this to having to use forward declarations. There'se also a lot more of possible flexibility which we should keep. Some modules tend to produce code on-the-fly, invent functions dynamically, whatever. Also I often see initialization code like import string my_split = string.split del string and doing some more. During creation (execution) of the module code, the name space is changing quite much. Some module are stable afterwards, and they can be completely frozen, but, of course, this would be about the last line of code. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 mnot at pobox.com Sun Apr 25 01:18:16 1999 From: mnot at pobox.com (Mark Nottingham) Date: Sun, 25 Apr 1999 05:18:16 GMT Subject: pickling and unpickling on the same file? References: Message-ID: <01c001be8edb$066c5ea0$0301a8c0@cbd.net.au> Have you looked at the shelve module? ----- Original Message ----- From: Nathan Froyd Newsgroups: comp.lang.python To: Sent: Sunday, April 25, 1999 1:48 Subject: pickling and unpickling on the same file? > Is there any way to implement the above beast? Something like: > > p = Pickler(file) > u = Unpickler(file) > > file.seek(random_pos) > x = u.load() > > z = [7, 8, 9] > p.dump(z) > > would be perfect > -- > Nathan | nathan.froyd at rose-hulman.edu | http://www.rose-hulman.edu/~froydnj/ > God went through hell so we don't have to. ICQ:18861764 | AOL:myrlyn007 > Avoid the gates of hell. Use Linux. Python:"x='x=%s;x%%`x`';x%`x`" > Evolution is a million line computer program falling into place by accident. > > From tismer at appliedbiometrics.com Thu Apr 22 14:04:36 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 22 Apr 1999 18:04:36 GMT Subject: Pointers to variables References: <19990422121403.A279051@vislab.epa.gov> Message-ID: <371F64B4.8DF3FF24@appliedbiometrics.com> Randall Hopper wrote: > > This doesn't work: > > for ( var, str ) in [( self.min, 'min_units' ), > ( self.max, 'max_units' )]: > if cnf.has_key( str ): > var = cnf[ str ] > del cnf[ str ] > > It doesn't assign values to self.min, self.max (both integers). The values > of these variables are inserted into the tuples and not references to the > variables themselves, which is the problem. > > How can I cause a reference to the variables to be stored in the tuples > instead of their values? There is simply no direct way to use references. You need to use an object which itself has a reference. One way to achive the wanted effect is to use setattr, while paying some speed penalty, of course: for ( var, str ) in [( 'min', 'min_units' ), ( 'max', 'max_units' )]: if cnf.has_key( str ): setattr(self, var, cnf[ str ]) del cnf[ str ] ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 robin at alldunn.com Mon Apr 26 22:33:00 1999 From: robin at alldunn.com (Robin Dunn) Date: Mon, 26 Apr 1999 19:33:00 -0700 Subject: Looking for db.h - its not in the 1.5.2 source kit References: <924903339.24130.0.nnrp-10.9e982a40@news.demon.co.uk> Message-ID: You can find the Berkeley DB library at http://www.sleepycat.com/db/, you'll need to build this first, and then you can build the bsddb Python module. (You'll first need to change db.h to db_185.h in bsddbmodule.c) For a more complete wrapping of the Berkeley DB library, see my Starship page, http://starship.python.net/crew/robind/index.html (Although it may not be entirly compatible with the latest DB release. It's been a while since I've updated my copy.) -- Robin Dunn robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! Try http://AllDunn.com/laughworks/ for a good laugh. Barry Scott wrote in message <924903339.24130.0.nnrp-10.9e982a40 at news.demon.co.uk>... >Can anyone point me at a copy of db.h that is required to build bsddb >windows >module please? Its missing from the final release 1.5.2 kit. > > BArry > > From doylep at ecf.toronto.edu Thu Apr 29 15:25:23 1999 From: doylep at ecf.toronto.edu (doylep at ecf.toronto.edu) Date: Thu, 29 Apr 1999 19:25:23 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> Message-ID: <7gabmt$jm$1@nnrp1.dejanews.com> In article , Markus Kohler wrote: > > As far as I remember Eiffel requires a global system analysis to be type > safe at compile time. Well, the story is a bit more complicated. The bottom line is that current compilers use run-time checks in the dangerous situations, and that the dangerous situations are easily avoided anyway. If you avoid covariant arguments and feature hiding, as many do, Eiffel is statically typesafe with no global analysis. Personally, I'd prefer if Eiffel didn't offer these language "features" at all. -- Patrick Doyle doylep at ecf.toronto.edu -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From jeremy at cnri.reston.va.us Tue Apr 27 12:01:22 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 27 Apr 1999 12:01:22 -0400 (EDT) Subject: threading/events questions In-Reply-To: <3725a47f.96308574@scout> References: <3725a47f.96308574@scout> Message-ID: <14117.54695.658787.508940@bitdiddle.cnri.reston.va.us> >>>>> "C" == Chris writes: C> Hello... After experimenting with the modules thread and C> threading I have some open questions. I've written the famous C> ping-pong program. I'm not familiar with the ping-pong problem in general. I wonder if the code you posted is doing exactly what you intended. The event you're using could be used to allow communicate/synchronization between the threads, but instead it's being used to sleep; the Quit.wait() call only returns after the timeout period. So you could just as easily call sleep: def f(t, msg): print msg ## Quit.wait(t) ## if Quit.isSet(): ## return time.sleep(t) f(t, msg) You could also replace the recursive function call with a loop: def f(t, msg): while 1: print msg Quit.wait(t) if Quit.isSet(): break C> With that program, the threads are running for 60 seconds. But, C> how can I stop one thread and not both? I don't want to write an C> additional function doing exactly the same except dealing with a C> different Event. You could make the event a parameter instead of a global variable: def f(timeout, event, msg): print msg event.wait(timeout) if event.isSet(): return f(timeout, event, msg) C> My second problem is sending an event with a message. C> ChangeOutput = Event() and send the event ChangeOutput('something C> different than ping-pong') to one thread. After receiving this C> message, the thread should change the recursive call to f(t, C> 'something different, than ping-pong'). Event objects don't have associated messages be default. You would need to create a new object that also had an associated message. You could create an object that has the functionality you're interested in and an associated event. You could manage the two separately, although it seems like you do less bookkeeping if the object has the event as an instance variable. Not sure if there are pitfalls lurking... import threading class MessageHolder(threading._Event): def __init__(self, msg): threading._Event.__init__(self) self.msg = msg def set_msg(self, msg): self.msg = msg self.set() def get_msg(self): return self.msg def f2(timeout, msg_obj): while 1: print msg_obj.get_msg() msg_obj.wait(timeout) if msg_obj.isSet(): msg_obj.clear() C> How can I wait for events (more than one)? In the code above, C> I am just waiting for one event with a proper timeout. How can I C> react on the additional event ChangeOutput? Good question! I don't have a good answer. You might have some arrangement with hierarchical events (or conditions), so that one event is set only when one of the events under it is set. So you can wait on the upper event, and when it is set, check each of the underlying events. Jeremy From ppessi at hut.fi Sun Apr 18 16:41:16 1999 From: ppessi at hut.fi (Pekka Pessi) Date: 18 Apr 1999 23:41:16 +0300 Subject: SNMPy update References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> Message-ID: Jeremy Hylton writes: >I'll second your sentiment! I did some work on an X.509 library >written entirely in Python. Like you friend's SNMP code, it will >probably never be released; I don't have time to finish it nor did I >expect that I'd want to release it given the export control hassles. >However, it seemed clear to me that an ASN.1 compiler could be written >to generate the encode/decode routines. If someone is interested in >that, I've got some design notes and rough code on how to do the >encode/decode and on how to build a backend for SNACC. (A free-ish >ASN.1 compiler; the only one?) There certainly are other free ASN.1 compilers; however, they tend to be a bit incomplete. I have written BER, CER, DER, and a bit incomplete PER decoding/encoding classes in pure Python. Based on them, I've written LDAP client and server libraries in Python. However, as they are developed on the company time, I'd have to talk with my boss in order to release them. I'd certainly be interested in a SNACC backend generating Python. -- Pekka.Pessi at hut.fi From jasonic at nomadicsltd.com Fri Apr 9 03:33:41 1999 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Fri, 9 Apr 1999 08:33:41 +0100 Subject: PyMIDI ? Message-ID: <7ekagq$sjq$1@news1.cableinet.co.uk> Hello I am looking for pointers to any MIDI work done with Python. I can see several ways to handle MIDI in Python: - wrapping MIDI c libraries with SWIG - Direct binary MIDI file i/o parsing in Python - but will this be fast enough? - linking to an existing optimized MIDI toolkit such as Tim Thompson's superb openSource xplatform 'Keykit' language http://209.233.20.72/keykit/ (check it out) - on Win32 via COM use a toolkit like Mabry's MIDII/o http://www.mabry.com - ??? Thanks in advance any ideas - Jason From tratt at dcs.kcl.ac.uk Mon Apr 19 17:26:42 1999 From: tratt at dcs.kcl.ac.uk (Laurence Tratt) Date: Mon, 19 Apr 1999 22:26:42 +0100 Subject: bzip2 module for Python Message-ID: <2fbf63f548.tratt@tratt.freeserve.co.uk> In message Andreas Jung wrote: > Is there a module for the bzip2 compression library available or in the > making ? I have put together a quick interface to the bzip2 compression system which - for a couple of days or so - has a temporary home at: http://yi.com/home/TrattLaurence/pybzlib.tar I'm putting this out to see if there's any interest in developing it further. At the moment, the module has two methods: 'compress' & 'decompress'. It's not been tested much, but the main parts seem to work. As I said, I am interested to know if there is a demand for this, so comments are appreciated. Laurie From cs at spock.rhein-neckar.de Tue Apr 13 06:02:51 1999 From: cs at spock.rhein-neckar.de (Carsten Schabacker) Date: 13 Apr 1999 12:02:51 +0200 Subject: forking + stdout = confusion References: Message-ID: <87n20caldg.fsf@spock.localnet.de> clarence at silcom.com (Clarence Gardner) writes: > I thought that maybe sys.stdout was using a dup()'ed copy of stdout, > but I checked sys.stdout.fileno() and it was 1, so that doesn't seem > to be the case. No, the child and the parent share the SAME filedescriptors. This is true for ALL open files! So if you don't need the descriptors in a child or a parent you should close them. Apache waits for the end of the file, so all processes (parents and childs) must close the file! greetings from germany Carsten From hyoon at bigfoot.com Sun Apr 18 15:13:41 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Sun, 18 Apr 1999 15:13:41 -0400 Subject: restore sources from PYC [Q] References: <37177D8E.FF43BF65@bigfoot.com> <000801be8891$f238d980$ee9e2299@tim> Message-ID: <371A2EE5.90262EC6@bigfoot.com> Yep, just more defensive mech from the old school. ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From tismer at appliedbiometrics.com Tue Apr 20 16:45:44 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Tue, 20 Apr 1999 20:45:44 GMT Subject: pythonw.exe doesn't work References: <371cd0de.15002206@news.mysolution.com> Message-ID: <371CE778.1E9CDEF4@appliedbiometrics.com> Ken Power wrote: > > Another windows problem. Python scripts won't run on my system > (when I do the double-click scenario). I'm using Python 1.5.2 on > win95b. The .py and .pyw extension is associated with pythonw.exe, but > they don't appear to work. Also, double-clicking pythonw.exe doesn't > accomplish anyhting. Any clues, hints? The association of Pythonw.exe with the .py extension is wrong. Pythonw is a Python without a console, so it most probably does what it should do: execute a script and vanish. You should change the .py association back to python.exe . Pythonw is there for running COM server processes, applications which create their own windows, and so on. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 bend at realeducation.com Mon Apr 26 15:09:23 1999 From: bend at realeducation.com (Benjamin Derstine) Date: Mon, 26 Apr 1999 13:09:23 -0600 Subject: Using the compression module Message-ID: <7g2ddf$dra$1@birch.prod.itd.earthlink.net> Hello, I'm looking for a simple example of how to use the compression module, gzip. All I want to do is a make a compressed copy of a file. From the gzip documentation I see how to open a file for compression but I'm not sure what to do with it after that. From the gzip documentation: open (fileobj[, filename[, mode[, compresslevel]]]) Returns a new GzipFile object on top of fileobj, which can be a regular file, a StringIO object, or any object which simulates a file. Okay, so I opened this file object : f=open('/Audit.dbf','r') test=gzip.GzipFile('Auditc','r','9',f) So now how do I produce a compressed version of it? Thanks, Ben From MHammond at skippinet.com.au Wed Apr 21 20:15:05 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 22 Apr 1999 10:15:05 +1000 Subject: permissions on win32 [Q] References: <7fk8r0$7ng$1@m2.c2.telstra-mm.net.au> <002401be8c03$4f21d380$6eba0ac8@kuarajy.infosys.com.ar> Message-ID: <7flpkv$6je$1@m2.c2.telstra-mm.net.au> Bruno Mattarollo wrote in message <002401be8c03$4f21d380$6eba0ac8 at kuarajy.infosys.com.ar>... >Thanks Mark... > > All this is supposed to run on sunday and it's Mission Critical, so I >presume wiill be doing it by hand, but anyway thanks. I am looking forward >to be able to do this on NT... :-) > > FYI we will be running another mission critical process on Sunday and it >will be a small Python app that will run on NT ... I love Python ... :-) Actually, overnight I thought of a different solution you could use - use a "template file". Although the help file omits this information, you could use "win32security.GetFileSecurity()", and name a file that has the permissions you wish to "copy". This will give you a SECURITY_DESCRIPTOR object. Once you have the object, you can even manipulate the contents - the only thing missing from 124 was the ability to create a brand-new, empty SECURITY_DESCRIPTOR - all the functionality to manipulate them is there.... Mark. From kiffney at my-dejanews.com Thu Apr 22 10:27:47 1999 From: kiffney at my-dejanews.com (Gustin Kiffney) Date: Thu, 22 Apr 1999 14:27:47 GMT Subject: pythonwin/mapi crystal ball needed Message-ID: <7fnbks$ga1$1@nnrp1.dejanews.com> I've had great results with Python under Linux (doing a host of CGI chores that I was too lazy or stupid to figure out with Perl) and am now hoping that Pythonwin can save me from the many-headed Visual Basic dragon under windows - (nothing particular against Visual Basic except that it kept me locked in a dungeon over holidays cursing myself for listening to its siren song -"hey, this looks easy doesn't it - come this way" and later getting enmeshed in its buggy coils) Anyway I've long put off learning much about MFC/COM/MAPI because it looked too hard, but now have to find a way to implement a MAPI service provider (an address book). I've looked at the MAPI stuff in the python win32all distribution and it looks pretty complete (anyway, it looks like lots of stuff that I don't understand yet is there). Can anyone who has entered these swamps before predict for me whether trying to do this using Python has a chance of success, or should I instead sit with a couple thousand page MFC/MAPI/C++ books as being more likely to succeed (perhaps, at finally rendering me completely insane)... -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From tim_one at email.msn.com Sun Apr 25 17:29:34 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 25 Apr 1999 17:29:34 -0400 Subject: converting perl to python - simple questions. In-Reply-To: <7fvstg$nqo$1@nnrp1.dejanews.com> Message-ID: <000101be8f62$b66e4700$669e2299@tim> [sweeting at neuronet.com.my] [Perl "exists"/"defined" vs Python "None"] > For years, I've been thinking of "None" in Python as "null" in javascript, > meaning "no value set" Really not the same! > and so it was actually quite interesting to see that Perl has "exists" > and "defined" functions for dictionaries.... Perl is much more reluctant than Python to raise errors, and tends to return "the undefined value" in situations where Python would kick you. So e.g. %d = (); ($d{'hasa'}) = ('cat' =~ /(a)/); print exists $d{'hasa'} ? "exists" : "not exists", "\n"; print defined $d{'hasa'} ? "defined" : "not defined", "\n"; ($d{'hasa'}) = ('dog' =~ /(a)/); print exists $d{'hasa'} ? "exists" : "not exists", "\n"; print defined $d{'hasa'} ? "defined" : "not defined", "\n"; print 2 + $d{'hasa'}, "\n"; prints: exists defined exists not defined 2 I'd rather get kicked <0.1 wink>. To be fair, adding 2 to the undefined value will print a "use of uninitialized value" warning if Perl is run with -w. I'd still rather get kicked. (BTW, always run Perl with -w! Even Perl-heads will advise that . If the script you're translating relies on extreme Perlish subtleties, -w will probably alert you to them.) >> Get in the habit of using r-strings for writing regexps; >> they'll make your backslash life much easier. > Thank you for pointing that out - the perl stuff's been screwing > with my head and making me confused, \s being ok in that language. That's the problem! \s is fine in a Python string too. But other things aren't, and without using r-strings you're responsible for remembering which is which. For example, the regexp r"\bthe" matches "the" starting at a word boundary, but the regexp "\bthe" matches "the" following a backspace character. Perl actually has the same problem, but it's *usually* hidden by "regexp context"; e.g.; $string =~ /\bthe/ matches "the" starting at a word boundary, while $pattern = "\bthe"; $string =~ /$pattern/ matches "the" following a backspace character. Perl treats string escape sequences differently depending on whether the string is or isn't in regexp context; Python has no concept of context, so always treats string escapes the same way; the feature of Python r-strings is that they don't do *any* backslash substitutions, allowing the callee (in this case, re and pcre) to treat them as *it* wants to. Subtleties aside, most Perl5 regexps work fine in Python after replacing the bracketing / and / with r" and ". OTOH, if you can use a facility from the string module instead, it's usually clearer and faster; e.g., the original $x !~ /^\s$/ may be better as not (len(x) == 1 and x in string.whitespace) depending on what the original line is *really* trying to do (did they really want all of " ", "\n", " \n", and "\n\n" to match? beats me ... and that's one reason a string version is clearer). all-bleeding-stops-ly y'rs - tim From trashcan at david-steuber.com Wed Apr 28 03:18:57 1999 From: trashcan at david-steuber.com (David Steuber) Date: 28 Apr 1999 03:18:57 -0400 Subject: python and SOCKS firewall References: Message-ID: "Jeffrey Kunce" writes: -> I just found a way to get python on a Windows machine to talk through a SOCKS firewall. I sympathize with the fact that you are stuck using Novell GroupWise for USENET. However, could you please find a way to limit you line lengths? You posted long lines that are a PITA to read. FYI. -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. "I refuse to have a battle of wits with an unarmed person." From bwarsaw at cnri.reston.va.us Fri Apr 16 19:52:35 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: 16 Apr 1999 19:52:35 -0400 Subject: restore sources from PYC [Q] References: <000101be879c$8aed0670$6eba0ac8@kuarajy.infosys.com.ar> <37177D8E.FF43BF65@bigfoot.com> <7f80ii$7m0@journal.concentric.net> <61r9pk1h2t.fsf@anthem.cnri.reston.va.us> <7f84mq$a7c@chronicle.concentric.net> Message-ID: <61n20815to.fsf@anthem.cnri.reston.va.us> >>>>> "CP" == Christopher Petrilli writes: CP> Get a life, Barry ;-) Been reading too much comp.emacs.xemacs lately! From aa8vb at vislab.epa.gov Tue Apr 20 11:28:37 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 20 Apr 1999 15:28:37 GMT Subject: Tkinter performance In-Reply-To: <19990420083759.A133486@vislab.epa.gov>; from Randall Hopper on Tue, Apr 20, 1999 at 08:37:59AM -0400 References: <371B4B39.8B78BC7A@foreman.ac.rwth-aachen.de> <19990420083759.A133486@vislab.epa.gov> Message-ID: <19990420112837.A136681@vislab.epa.gov> Randall Hopper: |Greg Landrum: | |Suppose I need to draw a couple hundred circles and several | |thousand line segments (these are mostly connected, so I can ... | |1) Can Tkinter on a "typical" PC (say a P200) deliver a | |"reasonable" update rate (a couple of frames per second | |would probably cut it)? ... |The plus for OpenGL is of course the use of its display lists which makes |redraws much faster. Hopefully TkGS will take off in the Tk world and |OpenGL-accelerate the canvas by default when OpenGL is available. A correction. I assumed TkGS's plan to use OpenGL when available implied it would use OpenGL display lists. That's not the case. I just swapped mail with Frederic BONNET of TkGS and he said current plans don't call for using OpenGL display lists in TkGS. (I asked him to reconsider this design choice.) Randall From jbauer at rubic.com Sat Apr 24 19:28:42 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Sat, 24 Apr 1999 23:28:42 GMT Subject: Python and "Hand held" computers References: <37222AE6.E6C8F713@weihenstephan.org> Message-ID: <372253AA.8FDFBFCB@rubic.com> "Dr. Peter Stoehr" wrote: > I'm a great fan of python and I'm now looking for an > hand held computer (something smaller than a laptop) > that can be programmed with python. This must be PythonCE week. Three requests in 3 days. Brian Lloyd's original PythonCE port: http://www.digicool.com/~brian/PythonCE/ Mark Hammond has extended it: http://starship.python.net/crew/mhammond/ce/ There is also a mailing list: http://www.egroups.com/group/python-ce/ Briefly, you should be able to run Python on any of the CE family. Practically, this means CE devices based on the MIPS or Hitachi processors. The developers working on PythonCE all have MIPS systems, I believe. (At least that's true for Mark Hammond, Brian Lloyd, and myself.) Best regards, Jeff Bauer Rubicon, Inc. From quinn at necro.ugcs.caltech.edu Wed Apr 14 23:56:51 1999 From: quinn at necro.ugcs.caltech.edu (Quinn Dunkan) Date: 15 Apr 1999 03:56:51 GMT Subject: Novice Question: two lists -> dictionary References: <7f3j1v$f6j$1@nnrp1.dejanews.com> Message-ID: On Thu, 15 Apr 1999 02:31:27 GMT, jwtozer at my-dejanews.com wrote: >How do I make the members of one list the key of a dictionary and the members >of a second list the members of list values associated with with those keys? > >Given: > >ListA = ['10', '10', '20', '20', '20', '24'] >ListB = ['23', '44', '11', '19', '57', '3'] > >Desired Result: > >Dict = {'10': ['23','44'],'20': ['11','19','57'], '24': ['3']} > >Any help will be much appreciated. d = {} for a, b in map(None, ListA, ListB): if not d.has_key(a): d[a] = [b] else: d[a].append(b) Notice that python does elementary pattern-matching (and calls it "tuple unpacking"). You can actually do nested pattern-matching like: lst1 = ( (1, 2), (3, 4), ) lst2 = ('a', 'b') for (a, b), c in map(None, lst1, lst2): print a, b, c Also, if you have mxTools, you can do: import NewBuiltins d = dict(map(None, ListA, ListB)) Actually, this will give you {10: 44, 20: 57, 24: 3}, which is not what you want, but it should be faster :) I find the above map(None, ...) idiom useful for iterating over multiple sequences at the same time (like haskell's zip function). I bring up pattern-matching because it seems to be an area of python which is not extensively discussed in the documentation. (?) From kc5tja at bigfoot.com Mon Apr 5 15:38:05 1999 From: kc5tja at bigfoot.com (Samuel A. Falvo II) Date: Mon, 5 Apr 1999 12:38:05 -0700 Subject: Doing the "right thing" with timezones on Linux (patch) References: <19990329003313.A3517@quango.watervalley.net> <199903291915.OAA01148@eric.cnri.reston.va.us> <7dp9tm$hv2$1@towncrier.cc.monash.edu.au> Message-ID: <3708a324@fermi.armored.net> Jonathan Giddy wrote in message <7dp9tm$hv2$1 at towncrier.cc.monash.edu.au>... >Guido van Rossum writes: > >I'm not sure whether it actually affects the code itself, but the comment >#else /* !HAVE_TZNAME && !__GNU_LIBRARY__ */ >is actually: >#else /* !HAVE_TZNAME || __GNU_LIBRARY__ */ Incorrect -- it should be: #else /* !( HAVE_TZNAME || __GNU_LIBRARY__ ) */ Note the order of operations. Unary ! has higher precedence than || in C. Just thought I'd mention this... :) From phd at sun.med.ru Tue Apr 20 06:17:04 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Tue, 20 Apr 1999 10:17:04 GMT Subject: bzip2 module for Python In-Reply-To: References: Message-ID: Hello! On Tue, 20 Apr 1999, Laurence Tratt wrote: > pyBZlib What is it? Sounds good! Where is it? > Laurie Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From PTSex at PTSex.PTSex Thu Apr 8 13:38:16 1999 From: PTSex at PTSex.PTSex (PTSex) Date: 8 Apr 1999 17:38:16 GMT Subject: ENTER NOW...... GREAT AND 100% FREE LIVE SEX Message-ID: <7eipi8$j6l$12101@duke.telepac.pt> Looking for sex for the BEST 100% FREE SEX WORLD?? Go to: http://members.theglobe.com/esqueleto/index.htm Will find here the BESTLive Sex Shows...... DO YOU LIKE TO VIEW??? What are you wating for?????? http://members.theglobe.com/esqueleto/index.htm From scothrell at austin.rr.com Fri Apr 9 01:18:15 1999 From: scothrell at austin.rr.com (Scott C) Date: Fri, 09 Apr 1999 05:18:15 GMT Subject: Python on Alpha NT...anyone? References: <82gP2.685$87.74444@typhoon.austin.rr.com> Message-ID: Oh Fudge! Now I see that Guido has released 1.5.2c1...errrrr Scott C wrote in message news:82gP2.685$87.74444 at typhoon.austin.rr.com... > I'm getting ready to compile Python on my Alpha processor NT box...in fact > I've tried it and am "fixing bugs" as I go... Has anyone else done this? > and are there "lessons" learned anywhere (re: porting). > > Scott Cothrell > > > From pygmy at eskimo.com Tue Apr 20 12:51:19 1999 From: pygmy at eskimo.com (Frank Sergeant) Date: Tue, 20 Apr 1999 11:51:19 -0500 Subject: interfacing to Dragon from a Python app References: <000801be89dd$d407a0c0$ed9e2299@tim> Message-ID: In article <000801be89dd$d407a0c0$ed9e2299 at tim>, "Tim Peters" wrote: > FYI, people curious about speech recognition under Windows might want to > give Microsoft's implementation a try; see the little-known > > http://www.microsoft.com/iit/ Thanks for the pointer. I browsed around the site for awhile. > This is not for the Windows-ignorant, weak-hearted, or slow-modem'ed , I couldn't quite bring myself to start the 21MB download. I'm still pondering my approach to the whole Speech Recognition (SR) thing. I'm gradually getting some hardware set up that might support it and considering the Dragon Preferred product (around $135 somewhere on the net) versus saving up for the Dragon developer's kit. Third in line, I guess, is Microsoft's 21MB download. Although ... I'm also thinking of overall priorities -- in that that SR might not be able to make a silk purse out of a sow's ear (then again, a sow's ear may be better at SR than a silk purse). -- Frank frank.sergeant at pobox.com From fredrik at pythonware.com Thu Apr 29 11:30:51 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 29 Apr 1999 15:30:51 GMT Subject: Q on Tkinter Scrollbar References: <370CFAC8.32EB0B29@ingr.com> <7g2g0f$km7$1@mlv.mit.edu> <3726C342.1DF7C6D6@ug.cs.usyd.edu.au> Message-ID: <013201be9256$07c02bf0$f29b12c2@pythonware.com> Bradley Baetz wrote: > Is it possible to find out the location of the top and bottom character > of a tkinter text object currently showing? I want to be able to seardch > for a tag on the currently viewable portion, but I can find out the > start and end positions of the text. you can use the "@x,y" index syntax for this; the start of the visible text is "@0,0", the end is "@x,y" where x and y is the window size (or anything larger, like "@10000,10000"). also see the attached example. # # tk053.py -- find visible region of a text widget # # fredrik lundh, may 1999 # # fredrik at pythonware.com # http://www.pythonware.com # from Tkinter import * root = Tk() # create a scrolled text widget frame = Frame(root, bd=2, relief=SUNKEN) scrollbar = Scrollbar(frame, orient=VERTICAL) scrollbar.pack(fill=Y, side=RIGHT) text = Text(frame, bd=0) text.pack() for i in range(1, 1000): text.insert(END, "line %s\n" % i) # attach scrollbar text.config(yscrollcommand=scrollbar.set) scrollbar.config(command=text.yview) frame.pack() label = Label(root) label.pack() def report_position(): # get (beginning of) first visible line top = text.index("@0,0") # get (end of) last visible line bottom = text.index("@0,%d" % text.winfo_height()) # update the label label.config(text="top: %s\nbottom: %s" % (top, bottom)) root.after(100, report_position) # update 10 times a second report_position() mainloop() From trashcan at david-steuber.com Mon Apr 26 19:06:29 1999 From: trashcan at david-steuber.com (David Steuber) Date: 26 Apr 1999 19:06:29 -0400 Subject: Designing Large Systems with Python Message-ID: Over my programming life, I have used a 'cowboy' programming style. Once I have a general idea for a solution to a problem, I start coding, using the text editor as sort of an etch-o-scetch. This works fine for programs under about 10klocs (thousand lines of code), but it is rather fragile and doesn't hold up to larger programs or the requested additions of un-anticipated features. I've noticed the acedemic and industry attempts to solve the problem. OOA/OOD, UML, design patterns, et al are all proposed solutions. Meanwhile, languages like Ansi Common Lisp have had features that allow you to prototype and build a large system at the same time. That is, the specification of the system becomes the system. People have done the same thing with Visual Basic, so I am told. What I am wondering about is the suitability of Python for specifying, a large system and building a prototype. I have gotten myself rather entrenched in the cowboy style and I would love it if Python supported that for larger systems. One other thing. Is the documentation that comes with Python sufficient to gain mastery of the language, or should I consider buying (yet) another book? -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. A long memory is the most subversive idea in America. From da at ski.org Wed Apr 28 17:36:43 1999 From: da at ski.org (David Ascher) Date: Wed, 28 Apr 1999 14:36:43 -0700 (Pacific Daylight Time) Subject: Maximize Benefit when Purchasing Learning Python In-Reply-To: <9FJV2.153$pX2.88806@news.shore.net> Message-ID: On Wed, 28 Apr 1999, Michael P. Reilly wrote: > David Ascher wrote: > : On Wed, 28 Apr 1999 jkraai at murl.com wrote: > > :> How can I help whom when purchasing Python books? > > : I'll dare to speak for Mark, and say that you should feel free to send > : either Mark or I (or both) checks for any amount whatsoever. Skip the > : middleman. Save trees -- don't buy the book, just send us cash. Don't > : hesitate for a minute. > > Better yet. Secure web credit-card transfers? Saves the paper from the > envelopes and checks/bills. ;) If the amounts involved are enough to warrant the infrastructure costs, I'll be glad to oblige. I somehow think I didn't make a huge commitment in that last sentence. --david From davem at magnet.com Wed Apr 7 11:27:26 1999 From: davem at magnet.com (Dave Mitchell) Date: Wed, 7 Apr 1999 15:27:26 GMT Subject: povray.py In-Reply-To: References: Message-ID: On 6 Apr 1999, David Steuber wrote: > mlh at idt.ntnu.no (Magnus L. Hetland) writes: > > -> "TM" writes: > -> > -> > Has anyone created a pov ray module for python? > -> > -> I have been thinking about it, but haven't done it yet... What do you > -> think it should contain? > > This is a relatively off the cuff response. But I think such a module > should provide python classes for the POV types. Then, instead of > using the POV scene description language, you would use Python. You > could algorithmicly create a scene or animation sequence. Then you > would pass the data structure (a list or other sequence) to a Python > function that renders it in POV scene description language for POV to > digest and render. neat! does it have a documented API? I downloaded the source and browsed it for a bit, and don't see any specific extension api.. if there isnt one and you're not familiar with the code it would be tough to deal with... Are there any similar bindings for other languages that you could use for inspiration? > > Another thing I would like to see is a module for generating RIB > files. In fact, a Python RenderMan module would be quite nice, > complete with shading language support. Anything out there like that? There is one of those, by Ture Palsson, I dont know how complete it is, see http://www.lysator.liu.se/~ture/terry.html for info. -dave From tismer at appliedbiometrics.com Sat Apr 24 09:36:54 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sat, 24 Apr 1999 15:36:54 +0200 Subject: learning Python (rat book) References: Message-ID: <3721C8F6.610E9A7B@appliedbiometrics.com> David Ascher wrote: ... > > I'm currently working on the German translation. it will be > > ready by end of July. I will try to adjust the index to mention > > every person who plays a role in the book. > > Great -- make sure to check in with Mark and I about the fixes we make > for the next printing, and let us know of the other bugs you find in the > process. Sure I will. I also owe Mark a correction list for the Pocket Reference. On extracting names: I'm setting up a batch process which turns all the Framemaker files into MIF files. Then I will run a Python script which extracts every possible name, and checks it against my name list. The name list is generated form my email archives which have everything until Oct 1996, so I'm pretty sure I will find everybody who mailed on some list, and I can use the intersection with the extracted name candidates to amend the index. :-) ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 guido at eric.cnri.reston.va.us Mon Apr 26 19:08:18 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 26 Apr 1999 19:08:18 -0400 Subject: webchecker on Windows References: Message-ID: <5logkbrndp.fsf@eric.cnri.reston.va.us> Des Barry writes: > I have just recently downloaded 1.5.2(final) and tried to use webchecker > on a local file tree. > > I am unable to get it to work - as it did in 1.5.2b2 (with a patch > applied to urllib) > > The arguments to webchecker that I use are: > > -x file:///D|/test1/test2/index.htm > > this does not find the file! > > -x file:/D|/test1/test2/index.htm > > this is able to read the file but not able to process any links > contained in the file (all local links are internally created like > file:xxx.htm) Unfortunately, you're right. I think that the change has to do with the changes in urllib.py regarding when to use url2pathname() and pathname2url() -- the new policy is much more useful, but webchecker was counting on the old policy. (The policy change is that the url argument to open(), open_file(), open_local_file() and the like must always be in url format.) Below is a patch that I think makes it work, but it still requires that you use forward slashes in the file: URL you give it. It supports drive letters but only if you use the form "file:/D|/path"; the form "file:///D|/path" doesn't seem to work due to the way urlparse works. I hope someone else can continue the analysis from here... --Guido van Rossum (home page: http://www.python.org/~guido/) From rhww at erols.com Tue Apr 20 00:21:46 1999 From: rhww at erols.com (R Wentworth) Date: Tue, 20 Apr 1999 00:21:46 -0400 Subject: Beginner Help - class problem or string copy semantics? References: <7fg8a0$3ib$1@nnrp1.dejanews.com> Message-ID: <371C00DA.895423A6@erols.com> cmedcoff at my-dejanews.com wrote: > > As will soon be apparent I am totally new to Python. In the code fragment > below I expect to see the output "foobar", but I do not. Can anyone tell me > why? ... > class Test: > _name = "" > def __init__(self, name): > _name = name > def show(self): > print self._name > > mytest = Test("foobar") > mytest.show() The line "_name = name" should be "self._name = name". Unlike C++, Python does not supply an implicit "this" or "self". (Once you get used to it, this is actually a good thing.) The "_name" you assigned to is simply a local variable within the __init__() method; it vanishes as soon as the method ends. From jand at easics.be Fri Apr 23 06:52:19 1999 From: jand at easics.be (Jan Decaluwe) Date: Fri, 23 Apr 1999 12:52:19 +0200 Subject: Running idle as a package Message-ID: <372050E3.9D05CE8F@easics.be> I was trying to run idle as a package, so I turned the idle directory into a python package. But then I got: Python 1.5.2 (#2, Apr 21 1999, 17:14:19) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from idle import idle Failed to load extension 'SearchBinding' Traceback (innermost last): File "/usr/local/lib/python1.5/site-packages/idle/EditorWindow.py", line 470, in load_standard_extensions self.load_extension(name) File "/usr/local/lib/python1.5/site-packages/idle/EditorWindow.py", line 481, in load_extension mod = __import__(name) ImportError: No module named SearchBinding ... Apparently the problem is caused by the call to __import__, that is not aware of the intra-package shortcut. I have been able to solve this for my case as follows: diff -r1.1 EditorWindow.py 481c481,482 < mod = __import__(name) --- > pck = __import__('idle.' + name) > mod = getattr(pck, name) Regards, Jan -- =================================================================== Jan Decaluwe === Easics === Design Manager === VHDL-based ASIC design services === Tel: +32-16-395 600 =================================== Fax: +32-16-395 619 Interleuvenlaan 86, B-3001 Leuven, BELGIUM mailto:jand at easics.be http://www.easics.com From fredrik at pythonware.com Thu Apr 22 08:19:54 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Apr 1999 12:19:54 GMT Subject: Directory of current file References: <371F0BD2.7D40A957@rubic.com> Message-ID: <00ee01be8cba$6e98dcb0$f29b12c2@pythonware.com> Jeff Bauer wrote: > David Ascher wrote: > > Tip: To find out the directory of the currently executing program, use: > > > > import sys, os > > if __name__ == '__main__': > > _thisDir = '' > > else: > > _thisDir = os.path.split(sys.modules[__name__].__file__)[0] > > David, what are the advantages over this? > > _thisDir = os.path.split(sys.argv[0])[0] as far as I can tell, David's method works for everything *except* the main module, while your method works for the main module, but not for anything else... how about a combination? import sys, os if __name__ == '__main__': _thisDir = sys.argv[0] else: _thisDir = sys.modules[__name__].__file__ _thisDir = os.path.split(_thisDir)[0] From ivanlan at callware.com Thu Apr 15 14:53:36 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 15 Apr 1999 18:53:36 GMT Subject: [Crew] squid References: <7DB1CEC958A9D1119E5200A0C999411612AC6C@TAL_ENT> Message-ID: <371635B0.1362E7B1@callware.com> If you take it off the list put me on the cc: !!! Thanks! -ly y'rs, Ivan;-0 Tom Funk wrote: > > >> [having windows] Puts me in a mischievous mood. > > > > You had me going. You'd think it was April 1st, not Tax Day. > > Consider yourself blessed -- you have windows, fresh air, etc. I work in a > basement-like environment. I have a potted plant and a calendar with _pix_ > of the outdoors. Not quite the same. > > >> I actually love it ! I grew up on it. (it has to be > >> fresh and properly cooked). > > This seems to be a recurring theme. > > >> PS if you get the chance try them cooked in wine and olive oil. > > Pavlos, please send more info. *This* sounds very interesting. A buddy of > mine has "Guest Chef" days at his home. Wine-and-olive-oil Calimari (or is > it Calamari?) might be interesting to bring. Plus, there's a very nice > fresh seafood store nearby where I can (probably) get fresh squid. Is there > more to this recipe? Some garlic perhaps, some white pepper maybe? > "Enquiring" minds want to know. > > (Should we take the crew out of the loop on this thread since this is *way* > off-topic for this list -- unless we plan on discussing wine-and-olive-oil > snake strips? ) > > -=< tom >=- > > _______________________________________________ > Crew maillist - Crew at starship.python.net > http://starship.python.net/mailman/listinfo/crew -- ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From petrilli at trump.amber.org Thu Apr 29 00:39:00 1999 From: petrilli at trump.amber.org (Christopher Petrilli) Date: 28 Apr 1999 21:39:00 PDT Subject: Emacs' python-mode buggy? References: <000401be91d0$5faab280$199e2299@tim> Message-ID: <7g8np4$kvf@chronicle.concentric.net> Tim Peters wrote: > [Markus Stenberg] >> At least by my experiences the Emacs mode (at least, two versions I >> tried, 3.75 and whatever came with Python 1.5.2) seems to have tons of >> bugs; > Yes, that would be entirely Barry Warsaw's fault -- pymode had no bugs when > I worked on it, and Barry is a known drug addict. Well, all right, I was > the drug addict, and I lied about Barry -- but I'm sure it's still all his > fault . Barry's a musician, 'nuff said. :-) But he likes Indian food, so he must be Dutch... do those cancel out? :-) >> to be more precise, it seems to think a lot more of my code than should >> be is string (and therefore is green and indentation doesn't work). > Offhand, that sounds like one bug. Try posting a minimal failing example? > Amorphous griping doesn't help. If you searched DejaNews before posting, > you may have noticed that reports of pymode bugs are conspicuous by absence. WEll, I have noticed some problems with tripple-quoted strings on occasion, but I see similar problems in other modes, so I THINK it's something to do with how (x)emacs applie the font-lock-mode parameters. Chris -- | Christopher Petrilli ``Television is bubble-gum for | petrilli at amber.org the mind.''-Frank Lloyd Wright From nascheme at m67.enme.ucalgary.ca Wed Apr 14 19:00:22 1999 From: nascheme at m67.enme.ucalgary.ca (Neil Schemenauer) Date: 14 Apr 1999 23:00:22 GMT Subject: reval builtin References: <19990331160323.21601.00000471@ng-fi1.aol.com> <7du3ab$3ag@chronicle.concentric.net> <371219E9.9EA91839@home.com> Message-ID: <7f36m6$koq@ds2.acs.ucalgary.ca> On Mon, 12 Apr 1999 15:59:05 GMT, Jim Meier wrote: >This introduces some major security problems, and is a little difficult >to edit, but there is very little parsing needed to make it usable. Does >anyone know of a way to limit the damage a user can do to such a file? It would be nice to have an "reval" builtin that would only evaluate literals. That would make building things like config files safe and easy. I have two ideas on how to accomplish this: 1. Create a new start symbol "reval_input" in the Grammar/Grammar and add a "builtin_reval" function in Python/bltinmodule.c. Sound easy? Well, the connection between these two changes is long and twisted. 2. Use something like lex and yacc to create an extension module that does the Right Thing(TM). I think the problem with this approach is making it conform to the real Python grammar. If I get time I will try it. Perhaps some guru can explain an easy way to accomplish this and same me some time. Neil From schorsch at schorsch.com Thu Apr 15 05:39:05 1999 From: schorsch at schorsch.com (Georg Mischler) Date: Thu, 15 Apr 1999 09:39:05 GMT Subject: what do you do with Python References: <3714C9EA.86C0A4E@earthlink.net> Message-ID: <7f4c3o$3ur$1@nnrp1.dejanews.com> susan e paolini wrote: > I never see jobs with Python advertised so what is it that Python does? > Thanks for the advice I am writing a user interface and project management application based on one of the most advanced physically based lighting simulation toolkits available. This is a commercial project, and will probably end up with more than 20 kloc of python. In any other language that could decently solve the task, this would result in about five times as much code, which would mean that I'd have to hire one or two programmers to help me. Since I can't afford that, the project would have simply died without python. You will often find similar situations, where one python programmer can eliminate several job offers for other language programmers. Somehow, python is slowing down it's own growth through its key strength here... Have fun! -schorsch -- Georg Mischler -- simulation developper -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From guido at eric.cnri.reston.va.us Thu Apr 29 09:02:55 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 29 Apr 1999 09:02:55 -0400 Subject: IDLE Problem References: <37277952.3551E595@connection.com> Message-ID: <5l676fbmv4.fsf@eric.cnri.reston.va.us> "Colin J. Williams" writes: > a= 99 > print 'UGH' > a= 101 > > When one steps through this code, the print statement hangs > the Windows. > > This happens when one Steps Over the command or when one > Steps and the Steps Out. Colin, can you give more information over what exactly you have tried? I presume this is not the complete code you are debugging (if only because when you enter this in the Python Shell window, it would be three separate unrelated statements). One thing you may not realize is that the print statement gets redirected by code inside IDLE that displays the text in the Python Shell window. Stepping through this code in the debugger takes some time, even if you use 'Out'. Perhaps you need to have a little more patience? --Guido van Rossum (home page: http://www.python.org/~guido/) From sweeting at neuronet.com.my Sat Apr 10 13:51:07 1999 From: sweeting at neuronet.com.my (sweeting at neuronet.com.my) Date: Sat, 10 Apr 1999 17:51:07 GMT Subject: Search Engines, Chinese and Python. Message-ID: <7eo32a$tbr$1@nnrp1.dejanews.com> The "how do you build a search engine in Python ?" question has been asked and answered enough times so I'll spare you all the agony. Given the choice, I'd use Ultraseek*, WAIS or something rather than rebuild this again myself; but I need this to work in Chinese. Forseeing a great demand for this (for myself and in general) and failing to find a decent ready-made solution, I figured that I may as well have a stab at it. (If all else fails, at least I may improve my Mandarin). Snipping from a thread last December : [snip] >Richard Jones wrote: >: The short answer is "you don't". > The big answer might be (this not a Gadlfy answer, but hey): (This uses indexing on item submission to speed fetching.) A pair of (g)dm's. One that stores your entries under some unique per item id. Churn through each new item looking for words. "Stop and stem" this list (ie. kill "and" "at" "the", standardise case, collapse "runner", "running" -> "run" or whatever. Can be tricky :-) You can automate the stop-list just by counting word occurences) The HTML parser and rfc822 et all could also be used to pull out details for searches like "url:www.host.com". The second file holds a relation between words and the documents that contain them. ie. an inverted list. Query comes in: search for "python programming": list1 = db2["python"] list2 = db2["programming"] The intersection of the list are the documents that contain both words. As things get big, you may need to overload the getitem to return a smaller list and store things like the number times the word appears in an item (you can then sort the inverted lists on this attribute). Hope this helps. (Start small!) -- James Preston, waiting for Godot. [/snip] Is it really as easy as that ? It seems that the real work is in the indexing and this is going to be even more of a chore with Chinese because words aren't separated by spaces - so we'll also have to build a parsing engine to work that out :( If anybody has worked with Chinese text and has any caveats with regards the above project or programming double-byte characters in general, I'm all ears.. I'm still struggling with getting my servers/scripts to write Chinese to the screen of Chinese-Windows machines let alone programming this into a database. Thank you very much, chas -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From mal at lemburg.com Thu Apr 8 15:26:52 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 8 Apr 1999 19:26:52 GMT Subject: OpenSSL/X.509 References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <3709C8BE.4257C9F1@lemburg.com> <14090.16807.950025.496495@bitdiddle.cnri.reston.va.us> <370A78B6.2C18D10F@lockstar.com> <370BE48E.2BA9750C@lemburg.com> <14092.42263.897530.425040@amarok.cnri.reston.va.us> Message-ID: <370D02FC.5FA7D302@lemburg.com> Andrew M. Kuchling wrote: > > M.-A. Lemburg writes: > >Sure, but if your company is US based, then chances are high > >you won't be able to share the code outside the US... that's > >why I started mxCrypto, BTW. > > Note that Pat Knight has a UK-based project to SWIG SSLeay; > could you work using that as a base? http://www.ktgroup.co.uk/~pat/ I've looked at that code before I started off into mxCrypto. Pat's approach uses pointers in the internal OpenSSL's data structure as basis for doing the wrapping. Unfortunately, those pointers seem to not work properly anymore in more recent versions of OpenSSL. Also, he swigged the BIO and SSL parts in OpenSSL, mxCrypto takes care of most of the crypto routines. X.509 and ASN.1 are not handled in Pat's version. Thanks for the tip anyway :-) -- Marc-Andre Lemburg Y2000: 267 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From gemodek at t-online.de Sat Apr 24 13:34:49 1999 From: gemodek at t-online.de (gemodek) Date: Sat, 24 Apr 1999 19:34:49 +0200 Subject: MS Access under Linux Message-ID: <372200B9.102E20E1@t-online.de> Hi, I want to rund a Linux fileserver. On this fileserver, Win95 Clients will put their Access97 *.mdb databases. Now I would like to analyse these *.mdb databases with Python under Linux (for creating web reports). Does somebody know a module which can this?? thanks Stephan From tim_one at email.msn.com Sat Apr 24 02:31:01 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 24 Apr 1999 02:31:01 -0400 Subject: Time complexity of dictionary insertions In-Reply-To: <8DB21A313Me@news.rdc1.ct.home.com> Message-ID: <000c01be8e1c$05a9dfc0$f09e2299@tim> > This attempt at one-ups-man-ship would be a lot cuter if the STL had any > kind of hashed containers, associative or otherwise, whose performance > could be quoted! > > ... > > Argumentatively y'rs - dan. I specifically had in mind http://www.sgi.com/Technology/STL/HashedAssociativeContainer.html and its derivatives. I understand that this goes beyond the officially blessed C++ STL, even to the point of being useful <0.9 wink>. no-guts-no-glory-ly y'rs - tim From gmcm at hypernet.com Tue Apr 6 22:51:56 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 7 Apr 1999 02:51:56 GMT Subject: Writing lines longer than 80 charc ! In-Reply-To: References: Message-ID: <1288668783-75154173@hypernet.com> Sunit asks: > I'm wondering if someone knew of a way of writing a line of more > than 80 characters to a file in way that it won't split it into two > lines. That's an artifact of the way you're viewing it. None of the ways of writing characters to a file do anything special at 80 characters. >>> open('test.txt','w').write('a'*1024) >>> txt = open('test.txt', 'r').read() >>> len(txt) 1024 >>> txt == 'a'*1024 1 See? Nothing but 'a's. - Gordon From sweeting at neuronet.com.my Sun Apr 11 01:03:50 1999 From: sweeting at neuronet.com.my (sweeting at neuronet.com.my) Date: Sun, 11 Apr 1999 05:03:50 GMT Subject: Search Engines, Chinese and Python. References: <7eo32a$tbr$1@nnrp1.dejanews.com> Message-ID: <7epafj$qlg$1@nnrp1.dejanews.com> I have a sneaky feeling that somebody on the Python list first mentioned this URL a couple of years back but I've just rediscovered the great resource on CJK processing (I knew I bookmarked it for a reason) : http://www.ora.com/people/authors/lunde/cjk_inf.html so I answer the second half of my own question. Now if maybe the Infoseek guys are interested in porting their engine to the most widely-spoken language in the world ;-) chas *just as an aside, it was due to Infoseek that I first looked at Python; always thought it was the best search engine, read that they used Python just as I was despairing with another P-language... haven't looked back since. :) sweeting at neuronet.com.my wrote: > The "how do you build a search engine in Python ?" question has been > asked and answered enough times so I'll spare you all the agony. Given > the choice, I'd use Ultraseek*, WAIS or something rather than rebuild > this again myself; but I need this to work in Chinese. Forseeing a > great demand for this (for myself and in general) and failing to find a > decent ready-made solution, I figured that I may as well have a stab at > it. (If all else fails, at least I may improve my Mandarin). > > Snipping from a thread last December : > > [snip] > >Richard Jones wrote: > >: The short answer is "you don't". > > > The big answer might be (this not a Gadlfy answer, but hey): > > (This uses indexing on item submission to speed fetching.) > > A pair of (g)dm's. One that stores your entries under some unique per > item id. > > Churn through each new item looking for words. "Stop and stem" this > list (ie. kill "and" "at" "the", standardise case, collapse "runner", > "running" -> "run" or whatever. Can be tricky :-) You can automate > the stop-list just by counting word occurences) > The HTML parser and rfc822 et all could also be used to pull out > details for searches like "url:www.host.com". > > The second file holds a relation between words and the documents that > contain them. ie. an inverted list. > > Query comes in: search for "python programming": > list1 = db2["python"] > list2 = db2["programming"] > > The intersection of the list are the documents that contain both > words. As things get big, you may need to overload the getitem > to return a smaller list and store things like the number times > the word appears in an item (you can then sort the inverted lists > on this attribute). > > Hope this helps. > > (Start small!) > -- James Preston, waiting for Godot. > [/snip] > > Is it really as easy as that ? > > It seems that the real work is in the indexing and this is going to be > even more of a chore with Chinese because words aren't separated by > spaces - so we'll also have to build a parsing engine to work that out :( > > If anybody has worked with Chinese text and has any caveats with regards the > above project or programming double-byte characters in general, I'm all ears.. > I'm still struggling with getting my servers/scripts to write Chinese to > the screen of Chinese-Windows machines let alone programming this into a > database. > > Thank you very much, > > chas > > -----------== Posted via Deja News, The Discussion Network ==---------- > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From bernhard at alpha1.csd.uwm.edu Sat Apr 17 00:57:37 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 17 Apr 1999 04:57:37 GMT Subject: Quick fix to add "+=" References: <3717AB14.2926AF76@mediaone.net> <3717EE20.41343593@mediaone.net> Message-ID: Your editor is your friend: Just use a macro in your favorite editor, which grabs the left word of the curser postion and expands it into =+ Trigger the macro with "+=" and you type excactly what you always type, just the result is more python like. For vim, the following does the trick (without the special word matching caps new vim versions provide. the ":noh is for people using hlsearch in vim 5.x version.) :map!^[:s/\([a-zA-Z_][a-zA-Z0-9_]*\)$/\1=\1+/^M:noh^MA Bernhard On Fri, 16 Apr 1999 22:12:48 -0400, Fuming Wang wrote: >I have searched dejanews. They don't like the "+=" characters. Could you >be more specific about how to modify the interpreter? I desperate >here.:) >Blake Winton wrote: >> On Fri, 16 Apr 1999 17:26:44 -0400, Fuming Wang wrote: >> >Any one knows a quick fix to add "+=" function. I am really getting >> >tired of typing long names twice. >> >> += has been left out of the language for a good reason, and thus it's >> probably not likely that there's an easy way to add it. I think you >> will have to recompile the interpreter to get it to do what you want, >> and even then, I don't think that you really want what it would do. From steffen at cyberus.ca Mon Apr 26 07:59:50 1999 From: steffen at cyberus.ca (Steffen Ries) Date: 26 Apr 1999 07:59:50 -0400 Subject: timeout on urllib.urlopen? References: <7g0r7c$gn9$1@nnrp1.dejanews.com> <19990426061959.A18551@toast.internal> Message-ID: jam writes: > On Mon, Apr 26, 1999 at 04:48:44AM +0000, Kevin L wrote: > > > > I'm trying to use urllib.urlopen() on a big list of urls, some of which are > > dead (they don't return a 404, just no response). And the function just waits. > > Is there any way to specify a timeout period for this function? thanks, .... > attached, please find a short lightly tested module that might do what you > are looking for.. please let me know if this is what you need. it's a piece > of code I wrote for a larger application, and it seems to get the job done > nicely. suggestions for optimizations, etc, accepted. I used once SIGALRM to force a timeout. Maybe somebody could comment on that approach? /steffen --8<----8<----8<----8<-- import signal def alarmHandler(*args): """ signal handler for SIGALRM, just raise an exception """ raise "TimeOut" .... signal.signal(signal.SIGALRM, alarmHandler) try: # set timeout signal.alarm(120) #... urllib.urlretrieve pages except "TimeOut": # some error handling signal.alarm(0) --8<----8<----8<----8<-- -- steffen at cyberus.ca <> Gravity is a myth -- the Earth sucks! From greg.ewing at compaq.com Wed Apr 7 18:03:54 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 08 Apr 1999 10:03:54 +1200 Subject: Select weirdness on Solaris 2.4 References: <199903301125.GAA23793@python.org> <199903301418.JAA03146@eric.cnri.reston.va.us> <7dr952$1s2$1@nnrp1.dejanews.com> Message-ID: <370BD64A.84E29479@compaq.com> Georg Mischler wrote: > > Balk means: list two handle_writes and a socket.error: "socket > not connected". When select returns true for an operation, it doesn't necessarily mean that the operation will succeed - only that the call won't block. From bill_seitz at my-dejanews.com Wed Apr 14 14:45:22 1999 From: bill_seitz at my-dejanews.com (bill_seitz at my-dejanews.com) Date: Wed, 14 Apr 1999 18:45:22 GMT Subject: stupid Win-CGI getting started question References: <7f0f0h$pfb$1@nnrp1.dejanews.com> <8DA86302Bduncanrcpcouk@news.rmplc.co.uk> Message-ID: <7f2no0$n80$1@nnrp1.dejanews.com> In article <8DA86302Bduncanrcpcouk at news.rmplc.co.uk>, Duncan Booth wrote: > seitz at mail.medscape.com wrote in <7f0f0h$pfb$1 at nnrp1.dejanews.com>: > > >Installed the basic Python stuff. I can run the interpreter. But not clear on > >getting it configured properly to talk CGI with my WinNT Netscape Enterprise > >server. I set a CGI folder path properly, but I get a nasty error message. > >But it's not a file-not-found, so I know it's finding the .py file. So I'm > >guessing it's not finding the executable. > I tried all sorts of configuration changes to get it to run .py files directly, > and eventually gave it up as a bad job (mostly because I didn't want to risk > breaking the server). > > The way I get CGI scripts to run with Netscape Enterprise server on NT is to > put them in .cmd files instead of .py files. So nobody can run .py files as CGI? Is this a known problem? What's its scope? Only Netscape/NT? What about IIS? What about Netscape/Solaris? I'm trying to keep my code generic enough that it can be moved to other platforms/servers down the road (which is why I haven't been looking at nsapy or Medusa or ZopeHTTP...), so I don't want to work around a problem now and just have it hit me again later. I'd like to understand the nature of the problem enough to evaluate alternative solutions. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From Friedrich.Dominicus at inka.de Fri Apr 30 13:26:37 1999 From: Friedrich.Dominicus at inka.de (Friedrich Dominicus) Date: Fri, 30 Apr 1999 19:26:37 +0200 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: <3729E7CD.6D42AD0B@inka.de> Markus Kohler wrote: > > >>>>> "Mitchell" == Mitchell Morris writes: > > [deletia] > > Mitchell> If it's not too much trouble, could you post your > Mitchell> benchmark code and results, either here or on a web > Mitchell> page? > > Of course I only did useless microbenchmarks ;-) If you have some of them please send me a copy and allow me to add them too: http://edt.vol.cz:81/bench/ I like to collect more and more of them to get more values to get it more fair. Of course I'll write them in other languages too for comparison. If you do such a test would you be so kind to document how long the development took and how much bugs you have to fix? This is IMO another important point to judge when a language is appropriate and when not. Regards Friedrich From cgw at fnal.gov Tue Apr 20 15:06:36 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Tue, 20 Apr 1999 19:06:36 GMT Subject: Bit Arrays In-Reply-To: <7fi9i8$n2u$1@info3.fnal.gov> References: <7fi9i8$n2u$1@info3.fnal.gov> Message-ID: <14108.53308.746874.201296@buffalo.fnal.gov> Laura Paterno writes: > Hello all, > > I want to write a python program that has 26 Bit Arrays that each contain > 1113 bits. Is there a structure in python that one can use to represent a > bit array? > Hi Laura. If memory efficiency is not an issue you could just use a string (or list of strings). If you really need to pack bits, then this takes a bit more work. You could use an array object (either from the built-in array class or the fancy Array object from the Numeric extension) and do the bit-slicing yourself in Python, something like this (you could put in more type-checking, etc.) import array import exceptions class MyObject: def __init__(self): self.data = [] for i in range(26): self.data.append(array.array(140,'b')) def __setitem__(self, key, value): if len(key)!=2: raise exceptions.ValueError, "expected two indices" if value not in (0,1): raise exceptions.ValueError, "value must be 0 or 1" if key[0]>25 or key[0]<0: raise exceptions.ValueError, "index out of range"%key[0] if key[1]>139 or key[1]<0: raise exceptions.ValueError, "index out of range" arr = self.data[key[0]] offset, bit = divmod(key[1],8) arr[offset] = arr[offset] | 1< Hi All, first off all: Sorry for that slightly provoking subject ;-) ... I just switched from perl to python because I think python makes live easyer in bigger software projects. However I found out that perl is more then 10 times faster then python in solving the following probelm: I've got a file (130 MB) with ~ 300000 datasets of the form: >px0034 hypothetical protein or whatever description LSADQISTVQASFDKVKGDPVGILYAVFKADPSIMAKFTQFAGKDLESIKGTAPFETHAN RIVGFFSKIIGELPNIEADVNTFVASHKPRGVTHDQLNNFRAGFVSYMKAHTDFAGAEAA WGATLDTFFGMIFSKM The word floowing the '>' is an identifier, the uppercase letters in the lines following the identifier are the data. Now I want to read and write the contens of that file excluding some entries (given by a dictionary with identifiers, e.g. 'px0034'). The following python code does the job: from re import * from sys import * def read_write(i, o, exclude): name = compile('^>(\S+)') # regex to fetch the identifier l = i.readline() while l: if l[0] == '>': # are we in new dataset? m = name.search(l) if m and exclude.has_key(m.group(1)): # excluding current dataset? l = i.readline() while l and l[0] != '>': # skip this dataset l = i.readline() pass o.write(l) l = i.readline() f = open('my_very_big_data_file','r') # datafile with ~300000 records read_write(f, stdout, {}) # for a simple test I don't exclude anything! It took 503.90 sec on a SGI Power Challange (R10000 CPU). An appropiate perl script does the same job in 32 sec (Same method, same loop structure)! Since I've to call this routine about 1500 times it's a very big difference in time and not realy accaptable. I'd realy like to know why python is so slow (or perl is so fast?) and what I can do to improove speed of that routine. I don't want to switch back to perl - but honestly, is python the right language to process souch huge amount of data? If you want to generate a test set you could use the following lines to print 10000 datasets to stdout: for i in xrange(1, 10001): print '>px%05d\nLSADQISTVQASFDKVKGDPVGILYAVFKADPSIMAKFTQFAGKDLESIKGTAPFETHAN\n\ RIVGFFSKIIGELPNIEADVNTFVASHKPRGVTHDQLNNFRAGFVSYMKAHTDFAGAEAA\n\ WGATLDTFFGMIFSKM\n' % i And if you don't believe me that perl does the job quicker you can try the perl code below: #!/usr/local/bin/perl -w open(IN,"test.dat"); my %ex = (); read_write(%ex); sub read_write{ $l = ; OUTER: while( defined $l ){ if( (($x) = $l =~ /^>(\S+)/) ){ if( exists $ex{$x} ){ $l = ; while( defined $l && !($l =~ /^>(\S+)/) ){ $l = ; } next OUTER; } } print $l; $l = ; } } Please do convince me being a python programmer does not mean being slow ;-) Thanks very much for any help, Arne From tim_one at email.msn.com Fri Apr 9 02:43:31 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 9 Apr 1999 06:43:31 GMT Subject: Chaning instance methods In-Reply-To: <370CC27E.ED2D0D59@inrialpes.fr> References: <370CC27E.ED2D0D59@inrialpes.fr> Message-ID: <000f01be8254$489a7b60$14a02299@tim> [Tim] > When I signed my exposition of instance-method trickery "subclassing-is- > a-lot-easier-ly y'rs", I had exactly this in mind: > > class Bar(Foo): > def m(self): > print "m2" > > f = Bar() [Vladimir Marangozov] > Careful! I usually am . > We'll eventually see what you had exactly in mind if you change the > last line from > > (1) f = Bar() > > to > > (2) f.__class__ = Bar Nope, I didn't have that in mind at all. Turns out (to judge from his followup) that this is what *Jody* had in mind, but not me. Most people who have asked this question over the years really could have done just fine using vanilla inheritance from the start, perhaps augmented by a factory function to choose the object's class with more care. > While (1) resets f's internal state and makes a brand new instance, > (2) preserves that state (which reflects f's past existence as an > instance of Foo) by changing only its interface to that of Bar > "on the fly". The difference is quite fundamental. Fundamental is too weak a word, but I know what you mean . Changing an object's class after-the-fact is not an approach I'd recommend to anyone. That doesn't mean I don't approve of it , it's just that people far too often start playing absurd tricks with Python's highly dynamic features when straightforward methods work fine. > We all knew that you meant (2) in your sig, but making it slightly > more explicit does not hurt :-) the-things-we-know-that-aren't-true-could-fill-a-bottomless- ocean-to-a-depth-of-half-an-invisible-inch-ly y'rs - tim From nbecker at fred.net Mon Apr 12 14:14:02 1999 From: nbecker at fred.net (nbecker at fred.net) Date: 12 Apr 1999 14:14:02 -0400 Subject: threads need -DREENTRANT? Message-ID: I see that building --with-threads doesn't automatically add -DREENTRANT. Is it needed? From charles.choi at computer.org Thu Apr 22 06:42:13 1999 From: charles.choi at computer.org (Charles Y. Choi) Date: Thu, 22 Apr 1999 03:42:13 -0700 Subject: 1.5.2 Build Snag Message-ID: <43DT2.3365$56.12822@typhoon-sf.pbi.net> Folks - In trying to build Python 1.5.2 on a Sparc Solaris 2.5.1 machine using gcc 2.8.1 I get this: -- ar cr libpython1.5.a getbuildinfo.o ranlib libpython1.5.a true cd Modules; make OPT="-g -O2" VERSION="1.5" \ prefix="/usr/local" exec_prefix="/usr/local" \ LIBRARY=../libpython1.5.a link make[1]: Entering directory `/export/home/cchoi/src/Python-1.5.2/Modules' gcc python.o \ ../libpython1.5.a -lsocket -lnsl -ldl -lm -o python Undefined first referenced symbol in file __muldi3 ../libpython1.5.a(longobject.o) ld: fatal: Symbol referencing errors. No output written to python make[1]: *** [link] Error 1 make[1]: Leaving directory `/export/home/cchoi/src/Python-1.5.2/Modules' make: *** [python] Error 2 -- Anybody here have a similar experience? Strangely enough, I get a successful build using gcc version 2.5.6. Thanks! -Charles From fdrake at cnri.reston.va.us Tue Apr 27 16:04:28 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Tue, 27 Apr 1999 20:04:28 GMT Subject: Python classes for postscript In-Reply-To: References: Message-ID: <14118.6220.972207.444585@weyr.cnri.reston.va.us> Victor S. Miller writes: > Are there packages available for formatted output (with nice fonts, > etc.)? Presumably one could create individual pages use some sort of > GUI like tkinter, but that would be one page at a time. Also, the XML Victor, You may want to look at the material in the "printing" package in Grail; it won't be a ready-to-use application, but it may be fairly useful depending on your application. If you're basically presenting text, it shouldn't be too difficult to use. It essentially provides a "writer" object that produces PostScript output; see the formatter module documentation for information on the "writer" interface: http://www.python.org/doc/lib/module-formatter.html Grail 0.6 is available at: http://grail.cnri.reston.va.us/grail/ -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From jeremy at cnri.reston.va.us Fri Apr 2 17:57:38 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Fri, 2 Apr 1999 17:57:38 -0500 (EST) Subject: add type predicates to types module? In-Reply-To: References: Message-ID: <14085.18842.492142.484721@bitdiddle.cnri.reston.va.us> This is a really good idea. I know I've got type predicates of many different flavors in code I've been working on recently. The tough question, I think, is how to decide which predicates are needed and how to implement them. The folkloric "file-like object" type is a good example. When people say "file-like object" they mean an object that responds in a reasonable way to the particular subset of methods on a builtin file object that they are interested in. isSequence might be a better example, since you want to capture instances that implement the sequence protocol along with tuples, lists, and strings. I use: def isSequence(s): try: 0 in s except TypeError: return 0 else: return 1 def isCallable(obj): if type(obj) in (types.BuiltinFunctionType, types.BuiltinMethodType, types.LambdaType, types.MethodType): # XXX could include types.UnboundMethodType return 1 if type(obj) == types.InstanceType: return hasattr(obj, '__call__') return 0 In the particular application I needed, I know I would not want to include UnboundMethodTypes. In the general case, though, I think it should be included. Jeremy From tseaver at palladion.com Thu Apr 29 00:36:38 1999 From: tseaver at palladion.com (Tres Seaver) Date: Wed, 28 Apr 1999 23:36:38 -0500 Subject: Designing Large Systems with Python References: Message-ID: <3727E1D6.B57F6371@palladion.com> boud at rempt.xs4all.nl wrote: > > David Steuber wrote: > > : Meanwhile, languages like Ansi Common Lisp have had features that > : allow you to prototype and build a large system at the same time. > : That is, the specification of the system becomes the system. People > : have done the same thing with Visual Basic, so I am told. > : > > Yes, they do. I should know - I'm working on a whopping great > big laboratory erp system built in Visual Basic. First there was > the prototype and it looked like a Windows program. Then there wasn't > enough time to start again and discard the prototype, so the prototype > became the specification, and in time, the system. Then the project > was delayed by about a year. Then there were performance problems > caused by conceptual errors that had to be rectified by hacking around. > Then suddenly, the whole blasted !@#$%^&* was more than ten million > lines, more than hundred dll's, numerous OCX'es, and countless forms, > all built by twenty to thirty novices in the art of programming, of whom > fifteen had left the company. It's more than painful or embarrasing... > And it's not the first time I've seen that happen. Sorry for the rant - > I just had to get it of my chest. I don't think Python really insures > you against these mistakes. VB is notorious for insuring THAT a project makes those mistakes. :) -- ========================================================= Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From herzog at online.de Fri Apr 9 15:04:29 1999 From: herzog at online.de (Bernhard Herzog) Date: 09 Apr 1999 21:04:29 +0200 Subject: _tkinter.c, threads and C-modules Message-ID: A few weeks ago, there was a bug report on c.l.py regarding an incompatibility between Sketch and Python 1.5.2b2. It seems to me that the cause for the problems is the new Tcl-lock in 1.5.2. The tcl-lock was introduced for better thread support in Tkinter. Whenever _tkinter calls the tcl interpreter, it releases the python-lock and acquires the tcl-lock. Sketch defines some tcl-callbacks in C, which in turn may call the python interpreter, but without releasing the tcl.lock and acquiring the python-lock. I think that this is the cause, because compiling just the _tkinter module without thread support cures the problem. The question now is, how do I make Sketch work correctly with a threadable _tkinter? AFAICT, Sketch would have to have access to some static variables in _tkinter.c. The best solution IMO would be to give third-party C-modules access to the functionality of the macros ENTER_TCL, LEAVE_TCL, etc, via some C-functions to access those variables and a _tkinter headerfile installed with the other Python headerfiles. Any chance to get something like this into Python 1.5.2 final? Bernhard -- Bernhard Herzog | Sketch, a python based drawing program herzog at online.de | http://www.online.de/home/sketch/ From jant at igd.fhg.de Tue Apr 20 10:44:10 1999 From: jant at igd.fhg.de (Jan Thomczek) Date: Tue, 20 Apr 1999 16:44:10 +0200 Subject: User-defined variables / compilation Message-ID: <371C92BA.2C6C883F@igd.fhg.de> Hello, I?m new to this newsgroup and maybe you?ll say "Wow! What a stupid question..." I think you?re right- I used to program in Turbo-Pascal 6. I installed Python on my NT 4.0-machine. I wonder how is the procedure to define the varibles by a user like "readln(x);" I?m sure there is a simple way to do so. Another question is: How do I *compile* the lines I have written to an *.exe-file? Thanks in advance, Jan Thomczek -- o---------------------------------------------------o | JAN THOMCZEK | o---------------------------------------------------o | Marketing und Kommunikation | o---------------------------------------------------o | Telefon: +49 (0)6151 / 155-437 | | Fax: +49 (0)6151 / 155-446 | | E-mail: jant at igd.fhg.de | | jant at zgdv.de | | URL: http://www.igd.fhg.de/~jant | o---------------------------------------------------o | Scientists have shown that the moon is moving | | away a small measurable distance from the earth | | every year. You can calculate that 65 million | | years ago the moon was orbiting the earth at a | | distance of about 10 meters from the surface... | | This would explain the death of the dinosaurs. | o---------------------------------------------------o From greg.ewing at compaq.com Sun Apr 18 18:21:40 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Mon, 19 Apr 1999 10:21:40 +1200 Subject: Motif GUI Builder References: <3717DA3C.8D91A592@sunrise.com> Message-ID: <371A5AF4.6D78A16E@compaq.com> Fred Sells wrote: > > Is there any interest in a Motif GUI builder that > includes a Python interface???. > > The Python would be freebie or shareware... > > I need to decide whether to get it out there on the web > or deep six it. Are you talking about making the whole GUI builder open source? If so, I'm sure there would be many people interested. Greg From sdm7g at virginia.edu Fri Apr 23 19:40:33 1999 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Fri, 23 Apr 1999 23:40:33 GMT Subject: Style/efficiency question using 'in' In-Reply-To: <3720C3F3.CFF6D739@callware.com> References: <3720C3F3.CFF6D739@callware.com> Message-ID: On Fri, 23 Apr 1999, Ivan Van Laningham wrote several variations on 'for x in y' : And just to confuse the new user even further, lets add pseudo sequences onto the pile. The actual protocol that 'for' uses is to get the next item in the sequence until an IndexError is raised. Earlier versions of Python compared the index to len() each time thru. I think I can claim some credit in inspiring Guido to change that behaviour by writing some Really Ugly classes which lied about their length in order to implement indefinite or lazy sequences. Now, it's a snap: all you have to do is implement __getitem__ to make something appear as a sequence to 'for' and 'in'. For example, rather than reading in a entire file and splitting it into tokens or chunks all at once, you can make a lazy sequence which reads another chunk of the file if needed and parses the next token each time __getitem__ is called with a larger index. You main loop would be something like 'for tok in Tokens( filename ): ' A simpler example: >>> class Squares: ... def __init__( self, n ): ... self.n = n ... def __getitem__( self, i ): ... if i < self.n : return i*i ... else: raise IndexError ... >>> sq = Squares(10) >>> for x in sq: print x ... 0 1 4 9 16 25 36 49 64 81 >>> if 4 in sq : print 'YES' ... YES >>> ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- Caldera Open Linux: "Powerful and easy to use!" -- Microsoft(*) (*) From thecrow at cyberdude.com Wed Apr 21 19:27:25 1999 From: thecrow at cyberdude.com (bryce) Date: Wed, 21 Apr 1999 23:27:25 GMT Subject: Python/Windows question (GUI) Message-ID: <371e5e52.6580435@news.prodigy.net> I have a window class instance. For example: x = Window ( "hey there") x.show () I think I am having some trouble when the window closes with the window object being freed. I want the object to be destroyed regardless of how many references there are to it when the WM_DESTROY message is received. Any help is *much* appreciated. Thanks. Bryce From samschul at ix.netcom.com Tue Apr 13 18:41:10 1999 From: samschul at ix.netcom.com (Sam Schulenburg) Date: Tue, 13 Apr 1999 15:41:10 -0700 Subject: Windows install has problems. Guido asked that I use this newsgroup to discus further References: <924039873.18221.0.nnrp-12.9e982a40@news.demon.co.uk> <924040766.18823.0.nnrp-12.9e982a40@news.demon.co.uk> Message-ID: <7f0h5p$n41@dfw-ixnews4.ix.netcom.com> I find that if I copy the Tcl/Tk DLLS to the DLLs folder after installing Python152 that I have no problems. This has worked for me with both WinNT and Win95/98 I also use wise installer to distrubute this release along with my modified IDLE files to the engineers that I support. I just have my installer perform this copy after executing the Python release process. Sam Schulenburg Barry Scott wrote in message news:924040766.18823.0.nnrp-12.9e982a40 at news.demon.co.uk... > >I wish I could. The installer is very stupid. Windows sucks :-( > > Is the WISE installer unable to deal with Win 9X vs. NT and handle > registry queries and updates? I'm sure that I can do this with > InstallShield (a poorly designed, annoying, but functional installer). > > As for the tcl80.dll problems. Either assume that tcl80.dll is in the > standard (english) installation place > %systemdrive%\program files\tcl\bin\tcl80.dll. > > OR release note that users must add the Tcl bin dir to there PATH. > > As the python lib does not have a module to access the registry it makes > getting the info from the registry hard. > > Maybe 1.6 needs a windows registry module to solve this and > other problems. > > BArry > > From mryan at localhost.netaxs.com Sun Apr 25 13:09:22 1999 From: mryan at localhost.netaxs.com (Michael W. Ryan) Date: 25 Apr 1999 17:09:22 GMT Subject: GUI other than Tkinter References: <3721567f.1748033@news> Message-ID: On 25 Apr 1999 09:23:35 -0400, Russell Nelson wrote: >mrfusion at bigfoot.com writes: > >> Well, I've just about given up on EVER getting Tkinter to work on my >> Win98 machine. Is there any other GUI module that I can get that ^^^^^ >> doesn't require TCL/TK to be installed on my machine? Isn't there >> something called GD? > >There's pygtk, which uses the gtk toolkit. As far as I know, GTk has not been ported to the Win32 platform, yet. -- Michael W. Ryan | OTAKON 1999 mryan at netaxs.com | Convention of Otaku Generation http://www.netaxs.com/~mryan/ | http://www.otakon.com/ PGP fingerprint: 7B E5 75 7F 24 EE 19 35 A5 DF C3 45 27 B5 DB DF PGP public key available by fingering mryan at unix.netaxs.com (use -l opt) From mlh at idt.ntnu.no Sun Apr 25 13:31:47 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 25 Apr 1999 19:31:47 +0200 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> Message-ID: Justin Sheehy writes: > mlh at idt.ntnu.no (Magnus L. Hetland) writes: > > > (And... How about builtin regexes in P2?) > > Um, why? I don't see any need at all for them to move from > module-status to core-language-status. [...] > > In all seriousness, what reason do you have for making that > suggestion? I am willing to believe that there might be a good reason > to do so, but it certainly isn't immediately obvious. Now, that's really simple -- because re.py is slow. I thought maybe some of the slowness might be improved by a c-implementation, that's all. Not too important to me... > > -Justin > -- > Hi! I'm the signature virus 99! Magnus > Copy me into your signature and join the fun! Lie Hetland http://arcadia.laiv.org From mnot at pobox.com Fri Apr 30 20:18:34 1999 From: mnot at pobox.com (Mark Nottingham) Date: Sat, 1 May 1999 00:18:34 GMT Subject: mktime() like function to produce GMT? References: <00be01be9308$c649cf60$0301a8c0@cbd.net.au><3729B855.3A7C6B5A@lemburg.com> <5lu2ty9lpx.fsf@eric.cnri.reston.va.us> Message-ID: <00d301be9368$277ae580$0301a8c0@cbd.net.au> Marc-Andre: Thanks. I'll take a look at it (shame it's not in the std library). Guido: I had tried a similar approach; date = mktime(rfc822.parsedate(datestring)) - time.timezone Neither this or mktime_tz will work; both will sometimes return dates that are off by one hour, depending on dst. I think this is because I'm parsing dates that may fall at any arbitrary time in the past, when the machine doesn't (AFAIK) have perfect knowledge about dst. Ultimately, I'm trying to parse a UTC datestring (HTTP Last-Modified header in one of the three accepted formats) into a rfc1123-format datestring (as well as a number to play with); the date should never have to even know about localtime (which is causing all of the problems, in this case). With either the above solution or mktime_tz(), some dates will parse back to themselves, while others will have a one hour offset. One such date (in my tz - aust eastern) is "Tue, 18 Mar 1997 05:32:18 GMT" which, after munging, will think it's 04:32:18. I'm testing with: #!/usr/bin/env python import sys, time, rfc822 g = list(rfc822.parsedate_tz(sys.argv[1])) g[9] = 0 date = rfc822.mktime_tz(tuple(g)) print time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(date)) > Huh? The C library function gmtime() *returns* a time tuple in UTC > (the polutically correct name for GMT). > > The standard way to use mktime() with a UTC is to add or subtract the > timezone offset (I admit I can never remember which :-) and force the > DST flag off. > > The following function in rfc822 may be helpful (it takes a 10-tuple > whose last item is the tz offset; set this to 0 for UTC): > > def mktime_tz(data): > """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp.""" > if data[9] is None: > # No zone info, so localtime is better assumption than GMT > return time.mktime(data[:8] + (-1,)) > else: > t = time.mktime(data[:8] + (0,)) > return t - data[9] - time.timezone From tom at spirit.gcrc.upenn.edu Tue Apr 6 10:54:00 1999 From: tom at spirit.gcrc.upenn.edu (Tom Fenn) Date: Tue, 06 Apr 1999 10:54:00 -0400 Subject: Rat sighting online References: <7e8fd3$er2$1@news1.rmi.net> Message-ID: <370A2008.2AE0AECF@spirit.gcrc.upenn.edu> I actually like the cover. It has that "There everywhere but you can't see them" idea that I associate with Python. Mark Lutz wrote: > > jkraai at murl.com writes about Learning Python: > > I can't resist, can we refer to it as: > > > > _Nixon_in_a_Nutshell_? > > I don't care how you refer to it, as long as you do ;-). > > --Mark Lutz (http://rmi.net/~lutz) From gmcm at hypernet.com Wed Apr 7 13:51:03 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 7 Apr 1999 17:51:03 GMT Subject: Crappy Software was Re: [OffTopic: Netscape] Re: How should In-Reply-To: <370c7a2d.35857749@news.bctel.ca> References: <370c7a2d.35857749@news.bctel.ca> Message-ID: <1288614834-78399188@hypernet.com> guppy wrote: > And another kick at Netscape: Having recently ported a sophisticated applet using JNI (Sun's new native interface) to JRI (older Netscape) and RNI (older IE), I too can kick and scream. Despite the fact that JNI is modelled on JRI, it was _much_ easier to port to RNI. Besides taking a whole lot more code (you have to do the whole silly "plugin" thing), Netscape was prone to crash at strange times for unknown reasons. There's even a difference between exiting from the file menu and closing from the title bar. When's the last time you closed a GUI from the file menu?? Sheesh. - Gordon From sdm7g at Virginia.EDU Thu Apr 22 20:54:13 1999 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Thu, 22 Apr 1999 20:54:13 -0400 (EDT) Subject: Emulating C++ coding style In-Reply-To: References: <371F8FB7.92CE674F@pk.highway.ne.jp> Message-ID: On Fri, 23 Apr 1999 06:08:07 +0900, Thooney Millennier asked about Python equivalents to C++ code. > > >2. stream class > > e.g. cout << "hello python."< VERY bad idea. Bad even in C++. > > sys.stdout.write("hello python." + "\n"); However, if you *REALLY* want to have that sort of C++ syntax, you can get it in Python with something like: endl = '\n' class OutStream: def __init__( self, file ): if hasattr( file, 'write' ): self.file = file else: self.file = open( file, 'w' ) def write( self, what ): self.file.write( what ) def close( self ): self.file.close() def __lshift__(self, what ): self.write( str(what)+' ') return self import sys out = OutStream( sys.stdout ) out << "Hello" << "World" << endl out << "The answer is" << 3+4 << endl ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- Caldera Open Linux: "Powerful and easy to use!" -- Microsoft(*) (*) From mal at lemburg.com Tue Apr 13 03:39:45 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 13 Apr 1999 07:39:45 GMT Subject: rfc822 date header References: <3712D863.2A8148BC@rubic.com> Message-ID: <3712F4C1.52327AF4@lemburg.com> Jeff Bauer wrote: > > Is there a reasonably bulletproof way to generate an > rfc822-compliant date header using the time module? > > The reason I ask is I recall a number of subtle > errors in this regard, reported by Chris Lawrence, > among others. According to the RFC, time.ctime() should do the trick... but it's probably locale aware which the RFC doesn't account for. A better way is to use the ARPA submodule in mxDateTime: http://starship.skyport.net/~lemburg/mxDateTime.html ...even if it's just for looking up the string format ;-) -- Marc-Andre Lemburg Y2000: 262 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From sjb at rockford.crosswinds.net Sat Apr 17 21:23:03 1999 From: sjb at rockford.crosswinds.net (Samuel Bridgeland) Date: Sun, 18 Apr 1999 01:23:03 GMT Subject: goes with last message Message-ID: Really sould've put this in my last message. From what I can tell python isn't loading any modules. For instance when I try to start xrpm or grail it tells me I probably havn'r configured it and that it can't find the tkinter module. -- Samuel Bridgeland sjb at rockford.crosswinds.net http://www.crosswinds.net/rockford/~sjb/ From dperkins at snmpinfo.com Tue Apr 6 12:04:26 1999 From: dperkins at snmpinfo.com (dperkins at snmpinfo.com) Date: Tue, 6 Apr 1999 09:04:26 -0700 Subject: SNMPy update In-Reply-To: <7ebtn1$dq$1@Starbase.NeoSoft.COM> References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <7ebtn1$dq$1@Starbase.NeoSoft.COM> Message-ID: HI, I cannot tell the context of the orginal question. But yet again, to write an SNMP agent or manager, do not fall for the belief that you need an ASN.1 compiler. Also, do not fall for the believe that you need an ASN.1 compiler for processing MIB modules. Whether one or not a asn.1 compiler is free does not matter, because you really donot need one! On 5 Apr 1999, Cameron Laird wrote: > In article <14089.11820.416453.80124 at bitdiddle.cnri.reston.va.us>, > Jeremy Hylton wrote: > . > . > . > >encode/decode and on how to build a backend for SNACC. (A free-ish > >ASN.1 compiler; the only one?) > > Hardly. There are several ASN.1 compilers. MAVROS www-sop.inria.fr/rodeo/personnel/huitema/mavros-home.html> is > another. I know of none that's achieved SNACC's portability. > -- > > Cameron Laird http://starbase.neosoft.com/~claird/home.html > claird at NeoSoft.com +1 281 996 8546 FAX > Regards, /david t. perkins From aa8vb at vislab.epa.gov Mon Apr 5 12:20:58 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Mon, 5 Apr 1999 16:20:58 GMT Subject: Subattributes of classes In-Reply-To: <3708D83E.BBE87D60@appliedbiometrics.com>; from Christian Tismer on Mon, Apr 05, 1999 at 05:35:26PM +0200 References: <19990405104408.A807008@vislab.epa.gov> <3708D83E.BBE87D60@appliedbiometrics.com> Message-ID: <19990405122058.A815978@vislab.epa.gov> Christian Tismer: |> self.draw = Canvas(self, width="5i", height="5i", |> background="white", |> scrollregion=(0, 0, "20i", "20i")) |> self.draw.scrollX = Scrollbar(self, orient=HORIZONTAL) |> self.draw.scrollY = Scrollbar(self, orient=VERTICAL) |> ^^^^^^^^^^^^ | |This is since the self.draw is assigned a Canvas instance |which is itself an object with attributes. Thanks to all who replied. I was foiled by "print self.draw" printing something that looked like a primitive string type (the Tk widget name), and so I didn't think it was a class and thus couldn't have attributes. I'll not forget __str__/__repr__ so easily next time. :-) Thanks, Randall From mwh21 at cam.ac.uk Fri Apr 16 02:54:10 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 16 Apr 1999 07:54:10 +0100 Subject: restore sources from PYC [Q] References: <000101be879c$8aed0670$6eba0ac8@kuarajy.infosys.com.ar> Message-ID: "Bruno Mattarollo" writes: > Hi! > > By mistake I am unable to find the PY files (source) from a project I was > working on. I only have the PYC files... Is there a way to recover the > sources from the PYC? I only need my sources, I don't give a d... for the > comments... Well.... The pyc files are marshalled code objects (after an eight byte header), and there's the standard module dis which can disassemble code objects, from which you could have a stab at rewriting your code. You certainly wouldn't *want* to do it this way. It would probably be within the bounds of possibility to write a decompiler, though unless you've lost a vast heap of code this is going to be a much bigger project than rewriting your code. Anyway, if it helps, here's a function that'll pull the code out of a .pyc file and disassemble that code: def dis_pyc(pyc_name): import marshal,dis file=open(pyc_name,'rb') file.read(8) code=marshal.load(file) did.dis(code) (NB: This isn't much use because defined functions and classes are in their own code objects stored as constants - they're still accessible, in code.co_consts, but this code doesn't go looking for them) > TIA > > /B > > Bruno Mattarollo > ... proud to be a PSA member Good luck! Michael From mso at jimpick.com Fri Apr 9 20:47:25 1999 From: mso at jimpick.com (Mike Orr) Date: Sat, 10 Apr 1999 00:47:25 GMT Subject: ConfigParser module and alternatives (flad, flan) References: <19990331160323.21601.00000471@ng-fi1.aol.com> <7du3ab$3ag@chronicle.concentric.net> Message-ID: William Annis wrote: >> As one of many people whose grimy hands have touched this module---and >> potentially the only person known to Guido who USES it, I can only say this. I use ConfigParser to parse the data files in a Mad Lib CGI program. See it at http://mso.oz.net/python/madbibs/ (When I add/change a story, I run a script that parses the files, creates the HTML, and stores the preprocessed data structures in a cPickle file for the CGI script.) I'm not sure if I'll use ConfigParser for the next version. I don't really need the sections (multiple files work just fine, using the filename for the section name), and I haven't found a use for the the %(other_key)s substitutions. On the other hand, it doesn't handle multiple values (the same key repeated within a record), which I sometimes need. Attached is a wrapper class for ConfigParser which supports booleans and can also return an entire section as a dictionary (or all the sections as nested dictionaries). I find these make it a little more convenient. I have a home-grown module flan.py that I use for most parsings. It's loosely based on Flad, but with a different approach. Rather than returning dictionaries, it returns a list (each record) of lists (each field) of triples (key, value, linno). Of course, it requires more code in the calling program to move the records in and out of objects. But it allows more flexibility, because the calling program can decide whether to allow multiple values (duplicate keys), can remember the original order of the keys if desired, and, if there's a data error parsing a particular field (e.g., a certain number must be between 1 and 100), it can put the file's line number in the exception string. [I'd like to figure out how to print the original line with the caret indicating the position of the error, a la SyntaxError, but haven't succeeded yet.] Flan doesn't handle sections or %(other_key)s substitutions, but it does know how to write files (without comments at this point). It's a bit too long to post, but I can send it to anybody who's interested. ################### BEGIN ConfigParser2.py ###################### """ConfigParser2.py -- wrapper for ConfigParser with additional features. Differences from the original ConfigParser class: * The *getboolean* method accepts symbolic words as well as '1' or '0'. Anything beginning with 't' or 'y' means '1' (true/yes). Anything beginning with 'f' or 'n' is accepted as '0' (false/no). Case is insignificant. * New method *options_dict*(section) returns a copy of the dictionary corresponding to that direction WITH THE DEFAULTS ADDED TO IT. * New method *sections_dict*() returns a dictionary containing each section, with the default section under the key 'DEFAULT'. The other sections do NOT contain copies of the entries from the default section. These methods do not resolve %(key)s interpolations: you must do that yourself. Testing status: Tested getboolean, options_dict, sections_dict 23-JAN-1999. Module written by Mike Orr, mso at jimpick.com, 23-JAN-1999. Public domain. """ import ConfigParser; _cp = ConfigParser; del ConfigParser import string class ConfigParser(_cp.ConfigParser): def getboolean(self, section, option): v = self.get(section, option) val = string.strip(v) val = string.lower(v[0:1]) if val in ('1', 't', 'y'): return 1 elif val in ('0', 'f', 'n'): return 0 raise ValueError, 'Not a boolean: %s' % v def options_dict(self, section): ret = self._ConfigParser__defaults.copy() if section == _cp.DEFAULTSECT: return ret try: section_dict = self._ConfigParser__sections[section] except KeyError: raise _cp.NoSectionError(section) ret.update(section_dict) return ret def sections_dict(self): ret = { 'DEFAULT': self._ConfigParser__defaults.copy() } ret.update(self._ConfigParser__sections) return ret ########### END ConfigParser2.py ##################################### > -- > William Annis - System Administrator - Biomedical Computing Group > (608) 263 8625 annis at biostat.wisc.edu PGP ID:1024/FBF64031 > Mi parolas Esperanton - La Internacia Lingvo www.esperanto.org Saludon, William. Ankaux mi parolas Esperanton. -- -Mike Orr, mso at jimpick.com From rgruet at ina.fr Wed Apr 14 14:05:51 1999 From: rgruet at ina.fr (Richard GRUET) Date: Wed, 14 Apr 1999 19:05:51 +0100 Subject: 1.5.2 install problems on NT Message-ID: <3714D8FF.634655C5@ina.fr> Hi everybody I'd like to contribute to the "best install problem contest" actually in progress... ;-) I've upgraded today from 1.5.1 to 1.5.2 on NT 4.0. Python seems to work at 1st glance, but : Registry problems: ---------------------- -Unlike stated in the "python use of registry" document (and unlike previous releases) there is no more "CurrentVersion" key under key: HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore (it's not convenient for me because some of my programs use this key!); Furthermore there is no key "1.5.2" for the new release, and it seems that a "1.5" key is used instead. Since I used to define keys under HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\1.5.x\PythonPath for adding dirs to the Python path (as advised in the doc), this time I had to copy manually my PythonPath under the 1.5 key. Maybe I'm missing a readme or something... - File associations: when associating '.py' and '.pyw' files with python.exe, the python.exe path lacks enclosing "", causing troubles if the path contains a space (as in 'program files'). Tcl problems: --------------- shared by many ! see Hoon Yoon for instance... wish80;exe works (hence I conclude that tcl is installed properly) but IDLE or Tkdb don't, with insults like: C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl: bad event type bad event type or keysym "MouseWheel" while executing "bind Listbox { %W yview scroll [expr - (%D / 120) * 4] units }" (file "C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/listbox.tcl invoked from within "source [file join $tk_library listbox.tcl]" (file "C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl" lin invoked from within "source C:/PROGRA~1/PYTHON/TCL/lib/tk8.0/tk.tcl" ("uplevel" body line 1) invoked from within "uplevel #0 [list source $tkfile]" This probably means that Tk wasn't installed properly. Eagerly waiting for the fixes.... regards, Richard From evan at tokenexchange.com Fri Apr 16 16:58:15 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Fri, 16 Apr 1999 15:58:15 -0500 Subject: Zope question References: <37178D4B.7D933209@swcp.com> Message-ID: Looks like the pcgi wrapper either can't find the var directory, or doesn't have sufficient permissions in it. Check the paths in your Zope.cgi, and make sure the var directory is writable by "nobody" (or whatever your Apache runs as). I went so far as to make my var directory mode 2770 and chgrp it and its contents to "nobody". nobody-is-going-to-write-to-*my*-zope/var-ly yrs, Evan Alex Rice wrote in message <37178D4B.7D933209 at swcp.com>... [snip] This is on a Cobalt RaQ. This is a MIPS processor with Linux 2.0.34. Basically a RedHat box. I built Python 1.5.1 and Zope-1.10.2-src with no problems. I'm using Apache. When I go to this URL: http://zope.swcp.com/Zope/ I see Zope.cgi process, then I see in my browser after about 15 sec: ! Temporarily Unavailable The resource you requested is temporarily unavailable - please try again later. (102) failure during connect In /usr/share/zope/var, I have only Data.bbb Data.bbb.in (pcgi.* seem to be missing?) From SSTirlin at holnam.com Thu Apr 29 09:42:18 1999 From: SSTirlin at holnam.com (Scott Stirling) Date: Thu, 29 Apr 1999 09:42:18 -0400 Subject: HTML "sanitizer" in Python Message-ID: Will, Thank you. So far you are the only person who has offered the kind of practical HOW-TO that I was mainly hoping for! This is not to disparage the many other helpful and interesting suggestions I have received. I should reiterate that I have 14 fairly large HTML files that I want to _batch process_, taking out a few specific HTML tags that Excel adds unnecessarily. I don't have the time or the inclination to write an HTML generator and process the Access data from scratch. I also have to work with a team of people who don't care at all about doing things smarter or trying out new programming languages. Besides, someone on the team has already put a lot of effort into writing a VB program that batch processes the Excel sheets from an Access query. And, as I said, I have a Visual SlickEdit macro that does exactly what I need very quickly. I am out to learn a little Python more than anything. So, while any more suggestions and comments are welcome, I will ask some more specific questions in the meantime. And then you can see how far I am from writing even the simplest program in Python! 1) What is the Python syntax for opening a file in MS Windows? I was following Guido's tutorial yesterday, but I could not figure out how to open a file in Windows. 2) How do I find a string of text in the open file and delete it iteratively? 3) How do I save the file in Windows after I have edited it with the Python program? How do I close it? 4) If someone helps me out, I think I should be able to use this info. and the tutorial and the Lutz book to loop the process and make the program run until all *.htm files in a folder have been handled once. What do you say? Scott >>> William Park 04/28 3:20 PM >>> On Wed, Apr 28, 1999 at 12:49:55PM -0400, Scott Stirling wrote: > Hi, > > I am new to Python. I have an idea of a work-related project I want > to do, and I was hoping some folks on this list might be able to > help me realize it. I have Mark Lutz' _Programming Python_ book, > and that has been a helpful orientation. I like his basic packer > and unpacker scripts, but what I want to do is something in between > that basic program and its later, more complex manifestations. > > I am on a Y2K project with 14 manufacturing plants, each of which > has an inventory of plant process components that need to be tested > and/or replaced. I want to put each plant's current inventory on > the corporate intranet on a weekly or biweekly basis. All the plant > data is in an Access database. We are querying the data we need and > importing into 14 MS Excel 97 spreadsheets. Then we are saving the > Excel sheets as HTML. The HTML files bloat out with a near 100% > increase in file size over the original Excel files. This is > because the HTML converter in Excel adds all kinds of unnecessary > HTML code, such as for every single > cell in the table. Many of these tables have over 1000 cells, and > this code, along with its accompanying closing FONT tag, add up > quick. The other main, unnecessary code is the ALIGN="left" > attribute in tags (the default alignment _is_ left). The > unnecessary tags are consistent and easy to identify, and a routine > sh! > ould be writable that will automate the removal of them. > > I created a Macro in Visual SlickEdit that automatically opens all > these HTML files, finds and deletes all the tags that can be > deleted, saves the changes and closes them. I originally wanted to > do this in Python, and I would still like to know how, but time > constraints prevented it at the time. Now I want to work on how to > create a Python program that will do this. Can anyone help? Has > anyone written anything like this in Python already that they can > point me too? I would really appreciate it. > > Again, the main flow of the program is: > > >> Open 14 HTML files, all in the same folder and all with the .html > >> extension. Find certain character strings and delete them from > >> the files. In one case (the tags) it is easier to find the > >> whole tag with attributes and then _replace_ the original tag > >> with a plain . Save the files. Close the files. Exit the > >> program. Hi Scott, I shall assume that a tag occurs in one line. Try 'sed', for i in *.html do sed -e 's///g" $i > /tmp/$i && mv /tmp/$i $i done or, in Python, for s in open('...', 'r').readlines(): s = string.replace('', '', s) print string.strip(s) If tag spans over more than one line, then read the file in whole, like for s in open('...', 'r').read(): If the tag is not consistent, then you may have to use regular expression with 're' module. Hopes this helps. William > > More advanced options would be the ability for the user to set > parameters for the program upon running it, to keep from hard-coding > the find and replace parms. To use command line parameters, like $ cleantd 'ALIGN="left"' change to s = string.replace('' % sys.argv[1], '', s) > > OK, thanks to any help you can provide. I partly was turned on to > Python by Eric Raymond's article, "How to Become a Hacker" (featured > on /.). I use Linux at home, but this program would be for use on a > Windows 95 platform at work, if that makes any difference. I do > have the latest Python interpreter and editor for Windows here at > work. > > Yours truly, > Scott > > Scott M. Stirling > Visit the HOLNAM Year 2000 Web Site: http://web/y2k > Keane - Holnam Year 2000 Project > Office: 734/529-2411 ext. 2327 fax: 734/529-5066 email: sstirlin at holnam.com > > > -- > http://www.python.org/mailman/listinfo/python-list -- http://www.python.org/mailman/listinfo/python-list __________________________________________________________________ | Scott M. Stirling | | Visit the HOLNAM Year 2000 Web Site: http://web/y2k | | Keane - Holnam Year 2000 Project | | Office: 734/529-2411 ext. 2327 fax: 734/529-5066 email: sstirlin at holnam.com | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From mal at lemburg.com Tue Apr 20 05:00:05 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 20 Apr 1999 09:00:05 GMT Subject: How alter maximum recurtion depth References: <371B2660.ECE4660A@data-dealeren.dk> Message-ID: <371C4215.66EF2A5D@lemburg.com> Uffe Koch wrote: > > How do I alter the maximum recursion depth for my Python interpreter? Compile the interpreter with MAX_RECURSION_DEPTH set to the new value, e.g. add a line #define MAX_RECURSION_DEPTH 20000 to your config.h file. -- Marc-Andre Lemburg Y2000: 255 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From ivanlan at callware.com Wed Apr 21 15:26:00 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 21 Apr 1999 19:26:00 GMT Subject: How many of us are there? Message-ID: <371E2648.DED123AE@callware.com> Hello, Pythonistas-- Does anyone out there have some idea how many people subscribe to the mailing list, or read the newsgroup? -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From nascheme at m67.enme.ucalgary.ca Fri Apr 16 18:30:27 1999 From: nascheme at m67.enme.ucalgary.ca (Neil Schemenauer) Date: 16 Apr 1999 22:30:27 GMT Subject: ANN: LParser 0.1 - A Python literal expression parser Message-ID: <7f8dm3$koe@ds2.acs.ucalgary.ca> Version 0.1 April 16, 1999 Neil Schemenauer http://www.ucalgary.ca/~nascheme/ This extension module parses Python literals from a file. An intended use is for human readable data storage (configuration files, data files, etc.). It is copyrighted under a Python style license. The format of the input is the same as Python (with some extensions). Lists, tuples, dictionaries, floats, integers, strings, and comments are recognized. Triple quoted strings are not recognized. Long integers and complex numbers are not recognized. Numbers are returned as integers if possible. All sequences are returned as lists. The extensions to the syntax are: = is accepted in place of : for dictionaries. Commas separating items are optional. Quotes may be left off strings if they do not include any of the following characters " \\t\\n#[](){}:=". The LParser.parse method takes an optional parameter specifices parsing start mode. If it is LParser.DICT then the parser behaves as if the input is wrapped in { and }. The option LParser.LIST is similar except the input is wrapped in [ and ]. Finally, the option LParser.VALUE indicates that no wrapping should be done. In this case all input may not be read. The value None is returned for end of file. The default start mode is LParser.DICT. A example data file using these extensions looks like this: --------------------------------------------------------------------- option1 = 10 option2 = (1 2 3) # some useful commentary subsystem1 = { option1 = 10.102 # a little comment option2 = "This is a quoted string" good_option = on } --------------------------------------------------------------------- when parsed that the following dictionary is returned: {'option1': 10, 'subsystem1': {'option1': 10.102, 'good_option': 'on', 'option2': 'This is a quoted string'}, 'option2': [1, 2, 3]} On a parse error, an LParserError exception is raised. The value of the exception gives the line number and a short description of what when wrong. Features: --------- nulls handled correctly no arbitrary limits fast (compared to eval) safe (compared to eval) Known Bugs: ----------- [ ... ) and ( ... ] are treated as valid lists. String escape processing may not be the same as Python. \r may not be handled correctly. Nulls in input can affect error reporting. Error reporting is somewhat limited. Data must come from a real file, not a StringIO etc. Download: --------- http://www.ucalgary.ca/~nascheme/python/ From mcicogni at siosistemi.it Thu Apr 22 19:17:36 1999 From: mcicogni at siosistemi.it (Mauro Cicognini) Date: Fri, 23 Apr 1999 01:17:36 +0200 Subject: Windows install has problems. Guido asked that I use this newsgroup to discus further References: <924039873.18221.0.nnrp-12.9e982a40@news.demon.co.uk> <924040766.18823.0.nnrp-12.9e982a40@news.demon.co.uk> Message-ID: <371FAE0F.43B33158@siosistemi.it> Barry Scott wrote: > >I wish I could. The installer is very stupid. Windows sucks :-( > > Is the WISE installer unable to deal with Win 9X vs. NT and handle > registry queries and updates? I'm sure that I can do this with > InstallShield (a poorly designed, annoying, but functional installer). WISE sure can. We use it every other day and it really works a lot better than InstallShield. > As for the tcl80.dll problems. Either assume that tcl80.dll is in the > standard (english) installation place > %systemdrive%\program files\tcl\bin\tcl80.dll. Mmm, since I'm not an English-language OS user, I'd rather see that as %programfolder%\tcl\bin\tcl80.dll (I don't remember exactly, but I'm sure there is a way to refer in a language-independent way to the folder that the US version calls "Program Files" since we use it in our installations. > OR release note that users must add the Tcl bin dir to there PATH. > Might as well (and make them aware that they need it some way or another). > As the python lib does not have a module to access the registry it makes > getting the info from the registry hard. > > Maybe 1.6 needs a windows registry module to solve this and > other problems. > ? We use Mark Hammond's extensions and have no problem at all in fetching things from the registry. Might just ask him and fold in the registry-access stuff. > > BArry Mauro -------------- next part -------------- A non-text attachment was scrubbed... Name: mcicogni.vcf Type: text/x-vcard Size: 381 bytes Desc: Card for Mauro Cicognini URL: From nospam at morhp.dircon.co.uk Wed Apr 21 15:47:19 1999 From: nospam at morhp.dircon.co.uk (Pete Jewell) Date: Wed, 21 Apr 1999 20:47:19 +0100 Subject: Project for newbie Message-ID: <70alf7.qc6.ln@loopback> Hi I've read my way through the tutorial, and am now stuck - where do I go from here? I want to learn how to use Python, but don't have any pressing projects at the moment - can anyone suggest a program I should have a go at writing, to help me learn the language further? TIA -- Pete morph at softhome.net ---------------------------------------------------------------- Linux Registered User # 100652 - Uptime 100 hours, and counting... -- A Bugless Program is an Abstract Theoretical Concept. -- From gmcm at hypernet.com Mon Apr 19 23:57:28 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 20 Apr 1999 03:57:28 GMT Subject: accessing calling scripts from called scripts at run time In-Reply-To: References: Message-ID: <1287541644-22552815@hypernet.com> John Michelsen says: > I'm having trouble accessing a calling script from a called script > at run time. Here is an example: > > #first file, will call second > from Tkinter import * > import tkFileDialog, string > > root = None > > def importScript(): > filename = tkFileDialog.askopenfilename() > if filename != '': > list = string.split(filename, '/') > filename = list[-1] > #dir = string.join(list[:-1], '/') > #sys.path.append(dir) > exec "import %s" % filename[:-3] > > if __name__ == "__main__": #? > root = Tk() > b = Button(root, text="import script", command=importScript) > b.pack() root.mainloop() > > > #another file, picked by tkFileDialog at run time by user > from importTest import root > root.config(bg='green') > > > If I put the "if __name__ == '__main__':" in, the second file can't > get at the root properly. If I leave it out, when I import root in > the second file, it creates a new root window. How can I get at the > root without making a new one? > The straightforward way: Give all the dialog-modules a run(...) method. Use mod = __import__(filename) mod.run(root, ....) - Gordon From dkuhlman at netcom.com Tue Apr 6 20:09:24 1999 From: dkuhlman at netcom.com (G. David Kuhlman) Date: Wed, 7 Apr 1999 00:09:24 GMT Subject: Embedding python question: PyRun_String only returns None not what I calculate References: <923433832.14002.0.nnrp-07.9e982a40@news.demon.co.uk> Message-ID: This is not the most convenient solution to your problem, but may be useful in your case. When you embed Python in an application, the application often exposes functions that are callable from Python scripts. You could provide a function named setReturnValue(value), which when called, passed a Python object (the value). The script calls this function, and then, when it exits, the embedding application (the caller of PyRun_String or PyRun_SimpleString) uses the Python value saved by this function. My application needs to do something similar. It needs to be able to evaluate scripts, passing in one or more values and to "catch" a value returned by the script. Effectively, we want scripts to be functions. If you find a smoother way to do this than what I described above, please let me know. - Dave Barry Scott wrote: > What I want to do is call python to run python code and return the results > to > my app. But I cannot find anyway to do this. > It would seem that I should be using PyRun_String to run a piece of python > and return a result object to me. But I can only get a return value of None. > NULL is returned if the code does not run. > How do I get python to return 2 to me when I ask it what 1+1 is? > Below is a fragment of code that I'm using to investigate PyRun_String. > BArry > // > // Test getting an object back from a command > // > char *command = "1+1"; > PyObject *m = PyImport_AddModule("__main__"); > if (m == NULL) > return EXIT_FAILURE; > PyObject *d = PyModule_GetDict(m); > PyObject *v = PyRun_String(command, Py_file_input, d, d); > if (v == NULL) > { > PyErr_Print(); > return EXIT_FAILURE; > } > PyObject *result = PyObject_Str( v ); > char *string = PyString_AsString( result ); > printf("Python returned: %s", string ); > Py_DECREF(result); > Py_DECREF(v); From phd at sun.med.ru Wed Apr 14 04:17:33 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Wed, 14 Apr 1999 08:17:33 GMT Subject: bug in PyGreSQL module In-Reply-To: <14099.48588.851795.102448@bitdiddle.cnri.reston.va.us> References: <14099.48588.851795.102448@bitdiddle.cnri.reston.va.us> Message-ID: On Tue, 13 Apr 1999, Jeremy Hylton wrote: > The nulls have been converted to 0. This seems straightforward given > the C code in getresult. If the field is an integer, the libpq value > is always handed off to PyInt_FromLong. I would think that there > should be an explicit check for NULLs in pg_getresult that converts > them to None. Have you subscribed to PyGres mailing list? Contact the list and report this. > Jeremy > Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From faassen at pop.vet.uu.nl Tue Apr 27 12:16:59 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Tue, 27 Apr 1999 18:16:59 +0200 Subject: help References: <37257B0A.AF4C8E4C@pop.vet.uu.nl> Message-ID: <3725E2FB.F7E46CED@pop.vet.uu.nl> Robert Meegan wrote: > > I've become known for appending a lengthy appendix to each design document > that explains what Python is and why averyone should be using it. So far > I've made a number of converts. All it takes is an experienced coder with > an open mind and *pow* they're hooked. This is how we push the programmer population slowly up that exponential curve. :) Regards, Martijn From markusk at bidra241.bbn.hp.com Thu Apr 15 11:19:44 1999 From: markusk at bidra241.bbn.hp.com (Markus Kohler) Date: 15 Apr 1999 17:19:44 +0200 Subject: Is there a 'make' replacement written in python ? Message-ID: I'm looking for a replacement for the 'make' command similiar to Cons : http://www.telerama.com/~bgarcia/cons/ Also the concepts of Cons look promising to me it is written in perl and the build rules are specified in perl. As we all know perl sucks and python rules ;-) Therefore something like Cons written in python would be really cool. Markus -- Markus Kohler mailto:markus_kohler at hp.com From akuchlin at cnri.reston.va.us Thu Apr 8 09:07:30 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Thu, 8 Apr 1999 13:07:30 GMT Subject: OpenSSL/X.509 In-Reply-To: <370BE48E.2BA9750C@lemburg.com> References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <3709C8BE.4257C9F1@lemburg.com> <14090.16807.950025.496495@bitdiddle.cnri.reston.va.us> <370A78B6.2C18D10F@lockstar.com> <370BE48E.2BA9750C@lemburg.com> Message-ID: <14092.42263.897530.425040@amarok.cnri.reston.va.us> M.-A. Lemburg writes: >Sure, but if your company is US based, then chances are high >you won't be able to share the code outside the US... that's >why I started mxCrypto, BTW. Note that Pat Knight has a UK-based project to SWIG SSLeay; could you work using that as a base? http://www.ktgroup.co.uk/~pat/ -- A.M. Kuchling http://starship.python.net/crew/amk/ Autumn, to me the most congenial of seasons: the University, to me the most congenial of lives. -- Robertson Davies, _The Rebel Angels_ From savageb at pacbell.net Thu Apr 22 22:28:58 1999 From: savageb at pacbell.net (savageb) Date: Thu, 22 Apr 1999 19:28:58 -0700 Subject: learning Python (rat book) Message-ID: The rat has landed! I managed to get my hands a copy at the Stanford University Bookstore today. good luck gettin' yours, Bob Savage From spamfranke at bigfoot.de Wed Apr 14 07:12:19 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Wed, 14 Apr 1999 11:12:19 GMT Subject: Can't run Win32 Debugger outside PythonWin Message-ID: <371475d6.77664796@news.omnilink.de> I just upgraded my NT4 SP3 Workstation to Python 1.5.2 and win32all build 124. Unluckily I can't start the debugger any longer from outside PythonWin. That is, typing pywin.debugger.fail works fine, but running fail.py from the shell gives D:\Programme\Python\Pythonwin\pywin\debugger>fail.py Traceback (innermost last): File "D:\Programme\Python\Pythonwin\pywin\debugger\fail.py", line 50, in ? a() File "D:\Programme\Python\Pythonwin\pywin\debugger\fail.py", line 18, in a pywin.debugger.post_mortem(sys.exc_info()[2]) File "D:\Programme\Python\Pythonwin\pywin\debugger\__init__.py", line 75, in p ost_mortem p = _GetCurrentDebugger() File "D:\Programme\Python\Pythonwin\pywin\debugger\__init__.py", line 28, in _ GetCurrentDebugger currentDebugger = debugger.Debugger() AttributeError: Debugger It seems the Scintilla.DLL can't be found (even the latest update from the author's hompage). However, sys.path is OK: D:\Programme\Python\Pythonwin\pywin\debugger>python Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import debugger Traceback (innermost last): File "", line 1, in ? File "D:\Programme\Python\Pythonwin\pywin\debugger\debugger.py", line 24, in ? from pywin.framework import app, interact, editor File "D:\Programme\Python\Pythonwin\pywin\framework\editor\__init__.py", line 90, in ? LoadDefaultEditor() File "D:\Programme\Python\Pythonwin\pywin\framework\editor\__init__.py", line 39, in LoadDefaultEditor mod = __import__(prefModule) File "D:\Programme\Python\Pythonwin\pywin\framework\editor\color\coloreditor.p y", line 39, in ? dllid = win32api.LoadLibrary("Scintilla.DLL") pywintypes.api_error: (126, 'LoadLibrary', 'Das angegebene Modul wurde nicht gef unden.') [The German error msg says "module not found"] >>> import sys >>> for x in sys.path: print x D:\Programme\Python D:\Programme\Pythonwin D:\Programme\Python\Pythonwin D:\Programme\Python\win32 D:\Programme\Python\win32\lib D:\Programme\Python D:\Programme\Python\Lib\plat-win D:\Programme\Python\Lib D:\Programme\Python\DLLs D:\Programme\Python\Lib\lib-tk D:\Programme\Python\DLLs D:\Programme\Python\lib D:\Programme\Python\lib\plat-win D:\Programme\Python\lib\lib-tk D:\Programme\Python Stefan From kernr at mail.ncifcrf.gov Fri Apr 30 23:31:01 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Fri, 30 Apr 1999 23:31:01 -0400 Subject: PythonOS anyone? Message-ID: <372A7575.1FEF98E@mail.ncifcrf.gov> Probably not likely I know, but has anyone looked at OSKit from the Flux Research Group at the University of Utah? From the website (http://www.cs.utah.edu/projects/flux/oskit/): """The OSKit a framework and a set of 31 component libraries oriented to operating systems, together with extensive documentation. By providing in a modular way not only most of the infrastructure "grunge" needed by an OS, but also many higher-level components, the OSKit's goal is to lower the barrier to entry to OS R&D and to lower its costs. The OSKit makes it vastly easier to create a new OS, port an existing OS to the x86 (or in the future, to other architectures supported by the OSkit), or enhance an OS to support a wider range of devices, file system formats, executable formats, or network services.""" >From a paper describing OSKit (ftp://mancos.cs.utah.edu/papers/oskit-sosp97.html): """ 6.1.4 Java Finally, in a project to create a Java [19] environment on the raw hardware, we started with Kaffe [34], a freely available and portable Java virtual machine and just-in-time compiler. Kaffe is written for a standard POSIX environment, requiring support for file I/O calls such as open and read, as well as BSD's socket API. It implements its own user-level thread system, for which it relies on some minimal signal handling facilities and timer support. Our implementation goals were to provide a prototype Java-based ``network computer'' called Java/PC, and an active network router. Our research goals are to explore resource management issues, comparing this Java system on the bare hardware to a Java system atop the Fluke microkernel. Building Java/PC atop the OSKit was remarkably easy: one Utah student, at that time not a major contributor to the OSKit, took just 14 hours to get the system to run a ``Hello, World'' Java application; large single-threaded applications, such as Sun's Java compiler, ran the next day. Less than three weeks later he had built a usable system that ran complex applications such as the Jigsaw Web Server [7], making extensive use of threads, timers, and file and network I/O. The resulting system is similar in function to Sun's JavaOS [33] but with a dramatically different implementation. Whereas almost all components in our system reuse existing C-based components provided by the OSKit, Sun's was primarily written anew in Java and took much longer to build. """ Is it possible to do the same for Python as well? I don't know of any real value in doing so beyond providing ammunition for language wars, but I think it would simply be extremely cool if nothing else. -- Robert Kern | ----------------------|"In the fields of Hell where the grass grows high This space | Are the graves of dreams allowed to die." intentionally | - Richard Harter left blank. | From tismer at appliedbiometrics.com Fri Apr 30 04:11:54 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 30 Apr 1999 08:11:54 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <7g9qmo$luf$1@news.udel.edu> Message-ID: <372965CA.2B3FD2FE@appliedbiometrics.com> Terry Reedy wrote: > > In article , > wtanksle at dolphin.openprojects.net says... > > >The reason it's slow is its runtime model. _Every_ function call requires > >a lookup in a hash table, just on the off-chance that the programmer > >changed the meaning of the function. > > A batch-mode optimizer analyzing an entire file (module) should be able to > detect whether or not function names are rebound. > > Perhaps module bindings should be considered immutable from outside the > module unless explicitly declared otherwise. (This would of course require a > new keyword and would break the rare existing code that does this until the > new directive was added.) I'm thinking of no new keyword, but a mechanism which allows me to lock a namespace somehow. At the end of a library module, this function could be called for the module, and all functions would be bound to a special table. I would also like to be able to do this with functions and classes. A function would be modified by resolving all identifiers once. For classes, I would do a similar snapshot, which would collect once every function/method which can be seen by inheritance. This is of course a semantic change, but it is an option for people who know the implications. There is no need for a library module to be slow, if it just suffers from flexibility. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 frank.mcgeough at synchrologic.com Thu Apr 22 10:34:57 1999 From: frank.mcgeough at synchrologic.com (Frank McGeough) Date: Thu, 22 Apr 1999 10:34:57 -0400 Subject: Embedding Python - Win32 - Request for Info/Opinions Message-ID: <371f32af.0@news.inet-systems.net> Hi, I've gotten Python to embed in a Win32 COM dll. (It's very simple, thanks to everyone that worked on the PCBuild stuff). I wanted to ask a couple of general questions because I'm curious about how I can use this in an actual app. What do I need to install when I put this on a target machine? I start off with creating a Python directory. If I put my COM dll, atl.dll and the python15.dll in this directory I can get my wrapper to register...but do I need to set PythonPath? do I need to install common py files? Where would I put these? Do I just mirror (in a very small way) what the Python install does? What is commonly done by people who are using Python commercially? If I want to use win32com stuff what else do I need to install? Again, does it mirror the Python Windows install? I would think I grab the following files: In win32com directory : __init__.pyc, olectl.pyc, storagecon.pyc, util.pyc In client directory: All the pyc files In server directory: All the pyc files And I'd put them in a directory structure that mirrors the install under the directory where I'll put the python dll. Is this correct? Is the Python interpreter thread-safe? In what I've done so far I've got an in-proc dll marked as free-threaded. I have a com object that wraps the Python interpreter and lets me pass files or strings into the interpreter. What I want is to instantiate this COM object from different threads and have those threads run scripts. Is this going to work? What have people done to achieve the same kind of functionality? That is, use Python in a server environment and get lots of different scripts executing at the same time. Do they launch the interpreter at the command line as a separate process? I am going to be working over the next couple days to answer these questions on my own but if someone already has the answers then that would help me quite a bit. Thank you. -- Frank McGeough Synchrologic,Inc. www.synchrologic.com E-mail: fm at synchrologic.com From tim_one at email.msn.com Mon Apr 12 22:40:39 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 13 Apr 1999 02:40:39 GMT Subject: Problems with InteractiveInterpreter In-Reply-To: <370F80BE.30B889A9@isoe.ch> References: <370F80BE.30B889A9@isoe.ch> Message-ID: <001001be8557$04b9ffa0$97a02299@tim> [Marcel Lanz, runs this: from code import InteractiveInterpreter lines = open('test2.py', 'r').readlines() ii = InteractiveInterpreter() for line in lines: ii.runsource(line) over input containing for i in 'hello': print i and gets an error] > any ideas? Sure! Stick "print " in front of your ii.run... line, look at the return values it prints, then read runsource's docstring. You can't expect it to work feeding it one line at a time; you need to feed it a complete executable fragment; & the return values tell you whether you've fed it enough. You'll get a bit closer doing this instead: input = "" for line in lines: input = input + line status = ii.runsource(input) if status == 0: input = "" But then you'll find that for i in 'hello': print i print "OK!" doesn't work as you want. At that point, you're ready to study the InteractiveConsole class (also in code.py) to see what's really needed. try-to-think-like-the-interpreter-ly y'rs - tim From guido at eric.cnri.reston.va.us Thu Apr 22 08:25:30 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 22 Apr 1999 08:25:30 -0400 Subject: Directory of current file References: <371F0BD2.7D40A957@rubic.com> <00ee01be8cba$6e98dcb0$f29b12c2@pythonware.com> Message-ID: <5lvheosuyt.fsf@eric.cnri.reston.va.us> "Fredrik Lundh" writes: > how about a combination? > > import sys, os > if __name__ == '__main__': > _thisDir = sys.argv[0] > else: > _thisDir = sys.modules[__name__].__file__ Eh, what's wrong with simply using __file__? It's a global in your own module, remember! > _thisDir = os.path.split(_thisDir)[0] One more refinement: instead of os.path.split(x)[0], use os.path.dirname(x). The whole thing could become a one-liner: _thisDir = os.path.dirname(__name__ == '__main__' and sys.argv[0] or __file__) You could also use the little-known fact that sys.path[0] is the script's directory; or the empty string if it's the current directory: if __name__ == '__main__': _thisDir = sys.path[0] or os.curdir else: _thisDir = os.path.dirname(__file__) --Guido van Rossum (home page: http://www.python.org/~guido/) From ivnowa at hvision.nl Sun Apr 25 19:19:02 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Sun, 25 Apr 1999 23:19:02 GMT Subject: Hear ye! Snippets! Python-DX 1.5.2! Message-ID: <199904252216.AAA17995@axil.hvision.nl> I'm posting this to comp.lang.python because for some reason (moving?) this messages did not show up in c.l.py.anncounce. ------- Forwarded Message Follows ------- Howdy y'all, A short announcement: *) Python-DX, my Python version for DOS, is now updated to 1.5.2 (was: 1.5). The binaries are there, I will probably upload some makefiles too, and am still thinking about uploading the complete source somewhere (but I don't have so much homepage space, and the code really isn't that different from the original...) Go to http://www.cuci.nl/~hnowak/html/python-dx.html *) The Python Snippets page has been updated. It now has 62 snippets. Not really a vast collection yet, but it's growing. (And YOU can help, too. ;^) Of course it's still under construction, but the snippets should be visible all right. Go to http://www.hvision.nl/~ivnowa/snippets/ or http://browse.to/python.snippets Veel liefs, + Hans Nowak (Zephyr Falcon) + Homepage (under construction): http://www.cuci.nl/~hnowak/ + You call me a masterless man. You are wrong. I am my own master. + May a gossiping bitch rescue your rice rocket! From phd at sun.med.ru Fri Apr 9 11:14:43 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Fri, 9 Apr 1999 15:14:43 GMT Subject: import from user input? In-Reply-To: <370E0BF7.D6E35B7A@appliedbiometrics.com> References: <370E0BF7.D6E35B7A@appliedbiometrics.com> Message-ID: Hi! > > Another question: is there a function to copy/move entire directory trees? There are functions in shutil.py; look for copytree()... Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From annis at biostat.wisc.edu Tue Apr 20 10:45:11 1999 From: annis at biostat.wisc.edu (William Annis) Date: 20 Apr 1999 09:45:11 -0500 Subject: Killing popen-generated children Message-ID: Is there any convenient way to get the PID of a process created via os.popen? I've written a little GUI tool which takes the output of some program and shoves it into a Text widget. (Yes, I know that's a little silly, but it's sometimes useful in the context of larger systems.) The GUI works via a filehandler, which means that a program like 'ping -s somehost' (Solaris) will keep shoving output into the Text widget... exactly what I want. The problem is that for programs that run forever, when you quit GUI tool, the program you're catching the output of is orphaned, and keeps running. Further, any attempt to close the pipe blocks forever. This does not happen if you're collecting the output of a program which quits on it's own ('ls', for example). So... I need to send a kill the offending children. I suppose I could poke around in one of the Stevens books and reimplement popen to give me a PID, but I'd rather not if someone else has found a solution already. -- William Annis - System Administrator - Biomedical Computing Group annis at biostat.wisc.edu PGP ID:1024/FBF64031 Mi parolas Esperanton - La Internacia Lingvo www.esperanto.org From ljz at asfast.com Mon Apr 26 11:10:48 1999 From: ljz at asfast.com (Lloyd Zusman) Date: 26 Apr 1999 11:10:48 -0400 Subject: GUI other than Tkinter References: <3721567f.1748033@news> <7g1a8h$fae$1@Starbase.NeoSoft.COM> Message-ID: claird at Starbase.NeoSoft.COM (Cameron Laird) writes: > In article <3721567f.1748033 at news>, wrote: > >Well, I've just about given up on EVER getting Tkinter to work on my > >Win98 machine. Is there any other GUI module that I can get that > >doesn't require TCL/TK to be installed on my machine? Isn't there > . > . > . > I appreciate this useful list. Also ... I noticed a refernce to `fltk' on this list, and I downloaded and built it. However, I don't notice any Python support as part of this distribution, and I'm wondering why `fltk' is on this "Python GUI" list. Is there somewhere else where a Python interface to `fltk' might exist? Thanks in advance. -- Lloyd Zusman ljz at asfast.com From hinsen at cnrs-orleans.fr Wed Apr 28 06:35:02 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 28 Apr 1999 12:35:02 +0200 Subject: WARNING: AIX and dynamic loading. References: <7g4i77$qif$1@nnrp1.dejanews.com> <3726DDD9.19A1@mailserver.hursley.ibm.com> Message-ID: Paul Duffin writes: > > PROBLEM: > > If you copy the module to the PYTHONPATH directory using cp, the old > > file gets overwritten, but keeps the same inode number. Apparently, On my system (running AIX 4.3.1), it is *impossible* to overwrite a shared library that has ever been loaded; all you get is an error message claiming that the file is being used. > > SOLUTION: > > You makefile should remove the old module (the .so file) before copying the > > new version into the installation directory. Then the file gets a new This is what I had to do as well, in order to be able to copy a new version. With that I never had any problems. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From guido at eric.cnri.reston.va.us Fri Apr 30 11:22:50 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 30 Apr 1999 11:22:50 -0400 Subject: mktime() like function to produce GMT? References: <00be01be9308$c649cf60$0301a8c0@cbd.net.au> <3729B855.3A7C6B5A@lemburg.com> Message-ID: <5lu2ty9lpx.fsf@eric.cnri.reston.va.us> > Mark Nottingham wrote: > > > > I need a function to produce a Unix epoch time from a time tuple, a la > > time.mktime(). Problem is, mktime() gives you the tuple in localtime, which > > is dangerous if you're dealing with GMT times in the past (like in the > > HTTP). > > > > Is there a function that will make a GMT epoch time straight from a time > > tuple? "M.-A. Lemburg" replies: > On some platforms there is gmtime() which does exactly this. > > It's available through mxDateTime, BTW, which also offers a > work-around solution for those platforms where it is not > available. See the Python Pages below. Huh? The C library function gmtime() *returns* a time tuple in UTC (the polutically correct name for GMT). The standard way to use mktime() with a UTC is to add or subtract the timezone offset (I admit I can never remember which :-) and force the DST flag off. The following function in rfc822 may be helpful (it takes a 10-tuple whose last item is the tz offset; set this to 0 for UTC): def mktime_tz(data): """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp.""" if data[9] is None: # No zone info, so localtime is better assumption than GMT return time.mktime(data[:8] + (-1,)) else: t = time.mktime(data[:8] + (0,)) return t - data[9] - time.timezone --Guido van Rossum (home page: http://www.python.org/~guido/) From aaron_watters at my-dejanews.com Mon Apr 19 15:50:52 1999 From: aaron_watters at my-dejanews.com (aaron_watters at my-dejanews.com) Date: Mon, 19 Apr 1999 19:50:52 GMT Subject: Memory and swapping question References: <371B5ED8.A9C82170@appliedbiometrics.com> Message-ID: <7fg1ep$t5s$1@nnrp1.dejanews.com> In article <371B5ED8.A9C82170 at appliedbiometrics.com>, Christian Tismer wrote: > due to a question which came up in the tutor list, I'd like > to ask if somebody can explain the following:.... timings on making huge lists of integers... > On my system, creation takes about 10 times as for big/2, > this is ok. But the del takes at least three times as long. > Besides the fact that integers are never really disposed but > build up a freelist, why is deletion so much slower now? Could be wrong, but this may be a case of a famous database problem. The OS (typically) swaps out pages by picking the "least recently used" page, but when you are decreffing (scanning) a HUGE list of sequentially allocated objects this guarantees that the page you need next will be swapped out by the time you get to it. Yikes! Allocation is faster because you are really only "paging things out" (the first time) and the write to the disk can be buffered until the disk is ready, allowing the program to proceed (?I think?). This is one reason why Oracle and Sybase, etc, like to do their own memory and disk management ("gimme them sectors -- don't need no g.d. filesystem, thanks!"). Just a guess, but a not completely uneducated one. -- Aaron Watters === stop procrastinating tomorrow. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From cmedcoff at my-dejanews.com Thu Apr 22 22:36:03 1999 From: cmedcoff at my-dejanews.com (cmedcoff at my-dejanews.com) Date: Fri, 23 Apr 1999 02:36:03 GMT Subject: help with os.popen() Message-ID: <7fomaj$oo9$1@nnrp1.dejanews.com> Hello, I'm new to python and need a bit of help with os.popen(). What is wrong with the following? What am I doing wrong? (I'm running 1.52 on WinNT 4.0) >>>import os >>> p = os.popen("dir", "rt", 1024) Traceback (innermost last): File "", line 1, in ? p = os.popen("dir", "rt", 1024) OSError: (0, 'Error') >>> Regards, Chuck -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From aa8vb at vislab.epa.gov Tue Apr 20 13:02:08 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 20 Apr 1999 17:02:08 GMT Subject: Bug with makesetup on FreeBSD In-Reply-To: <371CB31A.474D6FF@starmedia.net>; from Andrew Csillag on Tue, Apr 20, 1999 at 01:02:18PM -0400 References: <19990416143607.B1546743@vislab.epa.gov> <19990416215633.C2020@ipass.net> <19990417112344.A1624668@vislab.epa.gov> <371CB31A.474D6FF@starmedia.net> Message-ID: <19990420130208.A125414@vislab.epa.gov> |I figured it out! If you build out of the ports tree, it's Tkinter |configuration is all on one line (see |/usr/ports/lang/python/files/Setup.tk), not broken by using backslash |continuation as is in the distributed Setup file. I was building from |the source release from www.python.org, not from the ports tree as you |did, hence why you didn't run into it and I did. Ahh, makes sense. Glad you got to the bottom of it. Randall From gemodek at t-online.de Thu Apr 29 15:49:51 1999 From: gemodek at t-online.de (gemodek) Date: Thu, 29 Apr 1999 21:49:51 +0200 Subject: Read MS Access 97 *.mdb files with python?? References: <37287369.D6E67313@t-online.de> <3728867D.94B5BBF9@appliedbiometrics.com> <3728A903.CF75B41A@pop.vet.uu.nl> Message-ID: <3728B7DF.80E23481@t-online.de> Martijn Faassen wrote: > > Christian Tismer wrote: > > > > gemodek wrote: > > > > > > Does somebody know some > > > piece of soft which can this?? > > ... ... > > Unfortunately, all this advice may be useless, as I noticed that he's > the same guy who asked about accessing an Access database on Linux. I > know Linux can do ODBC, but I doubt there are Access drivers for ODBC on > linux.. > First: Thanks for the fast response :-) But,.. yes I am the guy who asked about accessing Access database on Linux. My idea is the following: At my company we are running 4 Win95 PC's on a network which works sometimes and crash sometimes (some days no reboot, some days 5-10 times). Now I am tired of the whole Win stuff, and I will install an Linux Server with Samba. (OK, the clients are still Win95, but at least the server is linux). We use also a software which is based on Access. The whole database (mdb files) will reside on the Linux server. So far so good. But now, I want to extract some information out of the access database to create html files which everybody in our company is alowed to view. And for this I need "access to Access". Thats the whole story. I'm searching also for a format description of access, but I did not find anything (up to now!). bye Stephan From kranio at nospam.nospam.it Thu Apr 29 17:57:14 1999 From: kranio at nospam.nospam.it (Kranio) Date: Thu, 29 Apr 1999 21:57:14 GMT Subject: info Message-ID: <37260fc0.3063146@news.tiscalinet.it> Where I can find any docs about Python' semantics ? Tnx Kranio From dobbe at xs3.xs4all.nl Fri Apr 9 08:01:35 1999 From: dobbe at xs3.xs4all.nl (Camiel Dobbelaar) Date: 9 Apr 1999 12:01:35 GMT Subject: Publishing 'live' Python objects Message-ID: <7ekq6v$of7$1@news2.xs4all.nl> Hi Pythoneers, I'm looking for advice on the following: Suppose I have a Python program that essentially does the following: while 1: read from stdin update some buffer objects I now wish to take a look at snapshots of those buffer objects in 'real-time'. (the program continues running and updating the buffers) I'd like to do this with HTTP. Is this possible? I gave Zpublisher a try, but I don't think it can do what I want. Should I look into using threads? Thanks, Camiel From gsez020 at kryten.bedford.waii.com Wed Apr 28 07:09:58 1999 From: gsez020 at kryten.bedford.waii.com (Pete Forman) Date: 28 Apr 1999 12:09:58 +0100 Subject: WARNING: AIX and dynamic loading. References: <7g4i77$qif$1@nnrp1.dejanews.com> Message-ID: Did you try running slibclean? That flushes out dynamic libraries that are no longer being used from memory. This forces a reload from disk when a library is next used. -- Pete Forman Western Geophysical pete.forman at westgeo.com From kj7ny at email.com Sat Apr 3 02:57:14 1999 From: kj7ny at email.com (kj7ny at email.com) Date: Fri, 2 Apr 1999 23:57:14 -0800 Subject: TIFF, Python, and LibTiff References: <6E5FB8BFB7CDD2118F6700A0C9E5871623B853@apexnews.rl.gov> Message-ID: <7e4be9$ido$1@paperboy.owt.com> Sorry about this post. I originally posted this message close to a year ago. I have no idea where it came from again. I assume there was a server problem on our end. I took Guido's advise (way back then) and a just wrote my own TiffLib module. It works great and I couldn't have done it without Python!!!!!!!!! The module not only creates Multi-Page Tiffs (MPT) out of Single-Page Tiffs (SPT), but it has the ability to create what I call "Streaming Multi-Page Tiffs". The first version I wrote merely grabbed all of the SPT files, combined them into a single MPT file, and stored it on magnetic. That took up too much storage and was too limiting. I rewrote it to have the option to stream the MPT back to the client without storing a copy on magnetic. The user can now select any range of pages (e.g. pages 50-60 out of 1037 pgs) to speed download and get just the pages they need. For some reason, testing shows that the download time is consistently a few seconds faster if the file is created on the fly than if it already existed and was just downloaded (go figure?). If you're curious, the application can be seen at http://www2.hanford.gov/declass You'd have to drill down through "Advanced Search" and find a document to get to the streaming. ...couldn't have done it without Python!!!!... Later, From gmcm at hypernet.com Thu Apr 22 18:06:26 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 22 Apr 1999 22:06:26 GMT Subject: Embedding Python - Win32 - Request for Info/Opinions In-Reply-To: <371f32af.0@news.inet-systems.net> References: <371f32af.0@news.inet-systems.net> Message-ID: <1287303503-36876650@hypernet.com> Frank McGeough writes: > > I've gotten Python to embed in a Win32 COM dll. (It's very simple, > thanks to everyone that worked on the PCBuild stuff). I wanted to > ask a couple of general questions because I'm curious about how I > can use this in an actual app. > > What do I need to install when I put this on a target machine? I > start off with creating a Python directory. If I put my COM dll, > atl.dll and the python15.dll in this directory I can get my wrapper > to register...but do I need to set PythonPath? do I need to install > common py files? Where would I put these? Do I just mirror (in a > very small way) what the Python install does? What is commonly done > by people who are using Python commercially? You can take complete control by providing exceptions.py and a site.py in the app's current directory. Use site.py to force whatever twisted perverted setup you desire. See http://www.mcmillan-inc.com/install.html > If I want to use win32com stuff what else do I need to install? The above package has something that will determine all your dependencies, both scripts and (since you have MSVC), binary. For COM servers, COM needs to be able to find your stuff. That used to mean installing on the PATH somewhere, but I think build 124 of Mark's stuff fixes that. > Is the Python interpreter thread-safe? In what I've done so far I've > got an in-proc dll marked as free-threaded. This should work fine. Python is thread safe for Python-created threads. Getting it to work with C-created threads is do-able, but a headache. > I have a com object that > wraps the Python interpreter and lets me pass files or strings into > the interpreter. What I want is to instantiate this COM object from > different threads and have those threads run scripts. Is this going > to work? What have people done to achieve the same kind of > functionality? That is, use Python in a server environment and get > lots of different scripts executing at the same time. We've seen postings from people working towards this same idea, but I've never been clear on why you'd run have one process executing a bunch of independent scripts. It's a lot less work and not much more load on the OS to run separate processes. - Gordon From befletch at my-dejanews.com Tue Apr 13 13:39:16 1999 From: befletch at my-dejanews.com (befletch at my-dejanews.com) Date: Tue, 13 Apr 1999 17:39:16 GMT Subject: ZopeHTTP speed problem. References: <7etton$j4q$1@nnrp1.dejanews.com> <371358fb.4741377@news.omnilink.de> Message-ID: <7evvg3$b4e$1@nnrp1.dejanews.com> In article <371358fb.4741377 at news.omnilink.de>, spamfranke at bigfoot.de (Stefan Franke) wrote: > [...] > > I found I have to use > >my machine's numeric IP address, not 'localhost' as the docs indicate. > > Do you get the long response times even *with* using your > localhost's IP address? Yes, I do. And yes, eliminating the reverse DNS lookup as you suggested made it work properly. That along with the "-t" threads option gives me enough responsiveness to evaluate Zope properly. Thanks for the help, - Bruce -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From mwh21 at cam.ac.uk Tue Apr 13 05:59:59 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 13 Apr 1999 10:59:59 +0100 Subject: Lexical analyzers and parsers References: <7jn20jmxsw.fsf@gandalf.midearth.fuzzys.org> <14092.48400.954787.617539@amarok.cnri.reston.va.us> Message-ID: "Andrew M. Kuchling" writes: > Julien Oster writes: > >What about lexical analyzers and parsers? > > > >Under C I use bison/yacc and (f)lex. Under python, I can either implement this > >stuff using C or try to write my parsers on my own, which is real pain. > > There are actually a bunch of different systems available; see > http://starship.python.net/crew/amk/python/string.html#parsing > for a list. (If I've missed any, let me know.) A lot of those links are a bit dated: kwParsing should probably link www.chordate.com, not the starship mcf.pars seems to have gone missing; I can't find it at any rate. "A parser generator based on M.-A. Lemburg's mxTextTools" likewise The link to PyBison got me a "connection refused"; this may be temporary (or not) These are the first four on the list, which is a little disconcerting! All the others work. Now I have to find one I can use.. HTH Michael Hudson From tismer at appliedbiometrics.com Mon Apr 5 10:08:14 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Mon, 5 Apr 1999 14:08:14 GMT Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <37009C12.4C0E6B0B@earth.ox.ac.uk> <922837384snz@vision25.demon.co.uk> <7dtbu1$rpn$1@nnrp1.dejanews.com> <37025110.1BA742B@appliedbiometrics.com> Message-ID: <3708C3CE.1044311F@appliedbiometrics.com> Jim Richardson wrote: [about printed Python docs] > I used mpage to condense them down to 2 pages per 8x11 sheet, and > then printed odd/even, cycled the paper throgh the laser printer twice, > bound them with those little springy plastic spiral things, and > viola, a 5x8, Reference with the tutorial, the api, &etc all at once. > Took something a little over 100 pages. I would have printed 4 to a page > but I couldn't figure how to make mpage do the registering properly for > 2 stage double sided printing. Well, not bad. :-) 4 to a page would be a mess for my eyes, BTW. I printed the manuals once when 1.4 was out, then never again. But I would buy it as a book if it were available. Therefore, I decided to take this as a toy project, and to turn this all into a real book, with Framemaker. I'm currently seeking for a publisher who wants it, and I will prepare a book with the Python docs around July (being occupied before). I hope that this will be already for Python 1.6. cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 jlee at fastech.com Mon Apr 12 16:47:55 1999 From: jlee at fastech.com (Jaeho Lee) Date: Mon, 12 Apr 1999 20:47:55 GMT Subject: how to use exec Message-ID: <7etm5o$bvm$1@nnrp1.dejanews.com> Hi folks, I'm making test tools based on python. I want to test script includes python script and test tools execute the command dynamically. "exec" is good for this. But if exec runs assign statement, it stores the variable in local area. I want to put the variable in global area. How can I do this? I saw this in python pocket reference. exec codestring [in globaldict [, localdict]] But this syntax does not work. Could somebody let me know how to use exec? -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From samschul at ix.netcom.com Fri Apr 2 23:43:16 1999 From: samschul at ix.netcom.com (Sam Schulenburg) Date: Fri, 2 Apr 1999 20:43:16 -0800 Subject: How do you access a windows printer from python? Message-ID: <7e46o8$sln@sjx-ixn9.ix.netcom.com> I would like to add a print function to the IDLE file menu, but do not have any idea on how to access a win32 printer from Python. I know that i could add this functionality to a dll and call the dll routine to accomplish my task. I thought I would see if their is a beater way :>) Sam Schulenburg From phd at sun.med.ru Thu Apr 8 12:27:36 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Thu, 8 Apr 1999 16:27:36 GMT Subject: GadFly - MemoryError In-Reply-To: <7eih6b$ck2$1@nnrp1.dejanews.com> References: <7eih6b$ck2$1@nnrp1.dejanews.com> Message-ID: Hi! On Thu, 8 Apr 1999 aaron_watters at my-dejanews.com wrote: > It would be interesting to try this, but my guess is that this would be > slower than the first query since equalities are optimized and "in" is not. > I hope oleg is using gadfly 1.0 too (not beta 0.2 or whatever). -- Aaron > Watters I started playing with GadFly a few weeks ago, so I downloaded latest versions of GadFly and kjBuckets. Yesterday I found a way to use kjSet in my program. BTW, what are "kw" in "kwParsing" and "kj" in "kjBuckets"? Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From guido at eric.cnri.reston.va.us Fri Apr 30 00:38:04 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 30 Apr 1999 00:38:04 -0400 Subject: Trouble with proxies References: <7gasj8$g79$1@nnrp1.dejanews.com> Message-ID: <5lzp3qafkj.fsf@eric.cnri.reston.va.us> befletch at my-dejanews.com writes: > I have tried all the suggestions people have sent me, and I have tried all > the local debugging I could think of, but I still can't see the world from > behind my proxy server. Can anyone find a possible solution to this? I've > had to modify my URL lines with (colin-slash-slash) to get past DejaNews' > Draconian posting filters: > > C:\>SET http_proxy=http(colin-slash-slash)10.187.200.230 > > C:\>"C:\Program Files\Python\python.exe" > Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import urllib > >>> u=urllib.urlopen('http(colin-slash-slash)www.yahoo.com') > Traceback (innermost last): > File "", line 1, in ? > File "C:\Program Files\Python\Lib\urllib.py", line 59, in urlopen > return _urlopener.open(url) > File "C:\Program Files\Python\Lib\urllib.py", line 157, in open > return getattr(self, name)(url) > File "C:\Program Files\Python\Lib\urllib.py", line 266, in open_http > errcode, errmsg, headers = h.getreply() > File "C:\Program Files\Python\Lib\httplib.py", line 121, in getreply > line = self.file.readline() > File "C:\Program Files\Python\Lib\plat-win\socket.py", line 117, in readline > new = self._sock.recv(self._rbufsize) > IOError: [Errno socket error] (10054, 'winsock error') > >>> A quick lookup in errno.errorcode shows that that error is WSAECONNRESET, in other words the connection is reset by the server. This apparently happens after the proxy has read your headers. Could it be that the proxy server requires some kind of magic header? Ask the sysadmin who is responsible for the proxy. At least find out what the proxy software is, you can probably find the specs on the web.... If you have a way to snoop network packets, it would be interesting to see what traffic happens when your regular browser (IE or netscape) connects to the proxy from the same client machine (I'm assuming that works!). --Guido van Rossum (home page: http://www.python.org/~guido/) From phd at sun.med.ru Mon Apr 19 05:56:02 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Mon, 19 Apr 1999 09:56:02 GMT Subject: How to merge data in a existant file In-Reply-To: <7feqbf$pr6$1@nnrp1.dejanews.com> References: <7feqbf$pr6$1@nnrp1.dejanews.com> Message-ID: Hi! On Mon, 19 Apr 1999 fquiquet at lemel.fr wrote: > I know how to write data in a new file : > > f=open('file.name','w') > f.write('data') > f.close() > > I don't know what is the function that permit to add data whithout erase > existing data. f=open('file.name', 'a') ^ append Other file modes are 'r+' and 'w+'. Read python documenataion on file modes and open(). Remember to use 'b' when working with binary files (mode = 'rb', for example.) > Thank's for your response to fquiquet at lemel.fr Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From tjreedy at udel.edu Tue Apr 6 22:31:00 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 7 Apr 1999 02:31:00 GMT Subject: Xbase++ preprocessor implementation in Python References: <37097A3A.F772205@magna.com.au> Message-ID: <7eeg14$35f$1@news.udel.edu> In article <37097A3A.F772205 at magna.com.au>, garys at magna.com.au says... >Attached please find a Python implementation of the Xbase++ preprocessor. ... >Oh, and it is *dead slow*! - hundreds of times slower I think! ... I do not know re's well enough to comment on whether they can be rewritten to run faster. I believe there is a python profiler which might give indications on where to start to speed things up. Terry J. Reedy From dgp at clover.cam.nist.gov Tue Apr 13 10:58:59 1999 From: dgp at clover.cam.nist.gov (Don Porter) Date: 13 Apr 1999 10:58:59 -0400 Subject: Help: Tkinter, bad event type References: <37134F3B.8C583E0@btk.utu.fi> Message-ID: <7evm3j$217$1@clover.cam.nist.gov> wrote: > I'm running Python 1.5.2c1 under Win NT with SP4 and Tcl/Tk 8.05. When I > try to run any script that uses Tkinter, even hello.py from the Tkinter > Life Preserver, I get two identical error messages: > > bad event type or keysym "MouseWheel" > while executing "bind Listbox ..." invoked from > /listbox.tcl > ... > invoked from /tk.tcl I've not used Python or Tkinter, but that message appears when a pre-8.0.4 Tk library tries to evaluate the initialization scripts distributed with Tk 8.0.4 or later. Can you check the value of the Tcl variable 'tk_patchLevel' to see for sure that your apps are using matching versions of the Tk library and the initialization scripts? Perhaps they're linking to an earlier version of the Tk shared library which is somewhere on your system? Perhaps there's an old tk80.dll in your .../Windows/System area? > I can work around this by editing listbox.tcl and commenting out the > "bind Listbox ..." statement, but I have to do this every > time I install a new version of Tcl/Tk, and it's annoying. Rather than comment out, wrap these statements (there's also one in text.tcl) in code which tests the value of the global variable tk_patchLevel, and evaluates the MouseWheel binding only if tk_patchLevel reports that the Tk library 8.0.4 or later is in use. ...but you still have to do that for every new 8.0.x release of Tk unless you can convince Scriptics to fix this bug. To report it to them, use their WWW Bug Report Form: http://www.scriptics.com/support/bugForm.tcl -- | Don Porter, D.Sc. Mathematical and Computational Sciences Division | | donald.porter at nist.gov Information Technology Laboratory | | http://math.nist.gov/mcsd/Staff/DPorter/ NIST | |______________________________________________________________________| From peter.stoehr at weihenstephan.org Sun Apr 11 16:41:56 1999 From: peter.stoehr at weihenstephan.org (Dr. Peter Stoehr) Date: Sun, 11 Apr 1999 22:41:56 +0200 Subject: idle : Setting breakpoints within the debugger Message-ID: <37110914.938829F3@weihenstephan.org> Hi out there, I hope this is not a FAQ, but I didn't find something in the docs of idle :-(. I try to set a breakpoint while debugging a script using the built in debugger by pressing the right mouse button. Well, all I get is a "beep" and no breakpoint is set. Am I doing something wrong and if what ? Any help is welcome Peter -- --------------------------------------------------------------------------- Dr. Peter Stoehr --- Teisenbergweg 6 --- 85435 Erding --- 08122/47232 --------------------------------------------------------------------------- I'm the terror that flaps through the night From mal at lemburg.com Mon Apr 12 18:00:23 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 12 Apr 1999 22:00:23 GMT Subject: ANN: Python Database API Specification 2.0 Message-ID: <37126CF7.79F8AF72@lemburg.com> The Python Database SIG is proud to announce a new revision of the database interface specification for Python: *** Python Database API Specification 2.0 *** The new version of the specification fixes some important short comings of the old 1.0 version. Most notably, the dbi abstraction module was folded into the interface module and new abstract data type constructors were added. You can find the version 2.0a15 document on the DB-SIG web-site at www.python.org (this URL will become the official citation URL for the specification): http://www.python.org/topics/database/DatabaseAPI-2.0.html Until the above page is updated, you can find the final 2.0 version on Starship: http://starship.skyport.net/~lemburg/DatabaseAPI-2.0.html Here are a few more links that should be of interest if you intend to do database related work with Python: The DB-SIG homepage: http://www.python.org/sigs/db-sig/ The Database Topic Guide: http://www.python.org/topics/database/ The old version 1.0 of the specification: http://www.python.org/topics/database/DatabaseAPI-1.0.html We hope that this long needed update will be welcomed by the Python database community. Enjoy !

Hey all... I'm interested in writing a Python script that can be controlled by email. I've read all the relevant Library documentation and the FAQ and searched the howto's but have not found some specific bits of information I need. That's when I turn to comp.lang.python. ;-) Periodically, I want my daemon to check a standard Unix mail spool file for new messages. Under certain conditions, I want the script to act on those messages (ie, do its thang on the contents of the message and mail the results back to the sender.) I've looked at the mailbox.UnixMailbox package. I am able to write a script that retrieves each message in /var/spool/mail/myuser and displays the sender, recipient, and subject. I am able to generate a reply using /usr/bin/mail. But for the life of me, I cannot look at the body of the incoming message. Silly me. Where in the documentation is this describe? 10 points to anyone who can point out the specific place to me. Many thanks, Preston Landers Austin, Texas From polley at netins.net Mon Apr 5 20:46:11 1999 From: polley at netins.net (Jonathan Polley) Date: 6 Apr 1999 00:46:11 GMT Subject: FYI: Conflict Between Python1.5.2b2 and win32all-123 Message-ID: <01be7fc6$af6c11e0$01656565@fidget> I have installed Python 1.5.2b2 then installed win32all-123. When I invoke IDLE with a file name on the commandline, I get the following error: Traceback (innermost last): File "C:\Program Files\Python\Pythonwin\pywin\framework\scriptutils.py", line 236, in RunScript exec codeObject in __main__.__dict__ File "C:\PROGRA~1\PYTHON\TOOLS\IDLE\idle.py", line 3, in ? PyShell.main() File "C:\PROGRA~1\PYTHON\TOOLS\IDLE\PyShell.py", line 780, in main aPath = os.path.abspath(os.path.dirname(filename)) File "C:\Program Files\Python\Lib\ntpath.py", line 398, in abspath return win32api.GetFullPathName(path) api_error: (161, 'GetFullPathName', 'The specified path is invalid.') If I remove pythonwin, the error goes away. Since I don't plan on running IDLE with files as arguments, the current behavior is not an issue for me. I have noticed that there is a 124 version on Marks Hammond's web site and will see if the problem exists with that update. Jon Polley polley at netins.net From joe at strout.net Fri Apr 9 16:48:46 1999 From: joe at strout.net (Joe Strout) Date: Fri, 09 Apr 1999 13:48:46 -0700 Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> <370E4F3E.F9C2CD07@lockstar.com> Message-ID: In article , Quinn Dunkan wrote: > pov.py v0.0: > http://www.calarts.edu/~elaforge/pov/ > > I guess it's released now :) Cool! Looks very neat. I'm not quite clear on how you're planning to handle animations. Will your Python script spit out a different POV-Ray script for each time point? Or will it spit out a whole series of them? Some things, like flocking behavior, are really hard to implement in a clock-independent way. Also, I see matrix transforms are on your to-do list. I suggest you use the Numeric module. Use dot(m1,m2) or dot(m1,v) to combine matrices or apply a transformation matrix to a vector, respectively. Cheers, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From dalke at bioreason.com Thu Apr 29 20:51:57 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Thu, 29 Apr 1999 18:51:57 -0600 Subject: converting perl to python - simple questions. References: <000201be929f$636d10a0$5fa02299@tim> Message-ID: <3728FEAD.CF650A4@bioreason.com> Uncle Tim said: > Here's a topic for civil debate: Resolved: returning different stuff > depending on whether an expression is in array or scalar context is no > worse than killing those of your classmates wearing shirts with sports > insignia . Using the formalism of symbolic algebra we start with the universe of concepts denoted U. We choose two items, A,B which are elements of U such that: A = "returning different stuff depending on whether an expression is in array or scalar context" and B = "killing those of your classmates wearing shirts with sports insignia" It is obvious that there exists some metric M which induces an ordering in U such that if X,Y are elements of U then the statement "X is worse than Y" is either correct or incorrect. We denote "X is worse than Y" by the expressions "X > Y" or "Y < X". The other standard expression for equality and inequality apply as normal, and it should be observed that this is a partial ordering as there can be some X,Y in U where X < Y and X > Y are both incorrect (so X == Y) using M but X is not identical to Y in U. We can derive such a metric M through newscasts and other forms of media. From this it is a relatively trivial matter to conclude that A < B given M(media) on U. Hence it is seen that it is not true that B >= A and so the statement proposed by in his paper <000201be929f$636d10a0$5fa02299 at tim>. "returning different stuff depending on whether an expression is in array or scalar context is no worse than killing those of your classmates wearing shirts with sports insignia" is a correct one, and that we can make the even stronger assertion "returning different stuff depending on whether an expression is in array or scalar context is less worse than killing those of your classmates wearing shirts with sports insignia" as the equivalence case has been shown to be false for the given M(media). It remains to be seen if there exists some M for which these statements are incorrect. (Whew - got that math lingo coursing through my system now, and hence we see that I should halt before I further such discussions :) Andrew dalke at acm.org From KUNCEJ at mail.conservation.state.mo.us Wed Apr 21 16:55:11 1999 From: KUNCEJ at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Wed, 21 Apr 1999 20:55:11 GMT Subject: How do I use proxies with httplib? Message-ID: >I want to use httplib through a proxy server and I can't seem to get >it to work. Someone in this group suggested setting an environment >variable, like: > >SET http_proxy="12.189.130.200:80" I don't know that that will work for httplib. I know it *does* work with urllib. An example from memory (not tested): import os, urllib os.environ['http_proxy']="http://12.189.130.200:80" f = urllib.urlopen('http://www.python.org') data = f.read() --Jeff From hyoon at bigfoot.com Wed Apr 14 08:57:40 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Wed, 14 Apr 1999 08:57:40 -0400 Subject: Delphi Linux and Python Message-ID: <371490C4.F19BA4F5@bigfoot.com> Hi, I heard about this free Delphi for Linux being developed by http://www.megido.org/ & There is a free 32-bit Pascal compiler for Linux at http://www.brain.uni-freiburg.de/~klaus/fpc/fpc.html & GNU General Public License (GPL) Pascal and Basic Linux RAD IDE Lazarus http://www.pcpros.net/~vbman/ Given that Python can be extended & embedded directly into/by Delphi, can same be use to by Delphi in Unix environment like Linux and Solaris? Have anyone tried it? Inquiring minds wanna know. Thanks, -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From boud at rempt.xs4all.nl Wed Apr 14 18:00:20 1999 From: boud at rempt.xs4all.nl (boud at rempt.xs4all.nl) Date: Wed, 14 Apr 1999 22:00:20 GMT Subject: Tutorial Python References: <3714BAA0.12F180F3@xs4all.nl> <3714E1D8.AE305670@earthlink.net> Message-ID: susan e paolini wrote: : : Python + KDE Tutorial : : Perhaps this will help Frank : Um, not really. What my tutorial teaches you is the rudiments of programming in Python using the KDE and Qt libraries. What Frank needs is a tutorial that focuses on the rudiments of Python and the interaction between Python and CGI. The only part where CGI programming is mentioned is the introduction, where I give it as part of the reason I went over to Python. I learned CGI programming with Python from Guido's Python tutorial and the cgi module documention - which did not prevent me from asking a silly question on this group. But it should be enough to get him started. -- Boudewijn Rempt | www.xs4all.nl/~bsarempt From guido at CNRI.Reston.VA.US Thu Apr 8 19:22:52 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Thu, 8 Apr 1999 23:22:52 GMT Subject: Python 1.5.2c1 -- release candidate for 1.5.2 final Message-ID: <199904082322.TAA05234@eric.cnri.reston.va.us> Steven Cummings reminded me that a new Tcl version (8.0.5) has been available for a while. I've now updated the Python installer for Windows to include Tcl 8.0.5 instead of 8.0.4, to make the release candidate more valuable. If you downloaded it before 8 April 7:10pm Eastern time (that would be 9 April 1:10am in most of Europe) you had the version with Tcl 8.0.4. There's an update to a source file too (the installer script) but I won't bother to update the source release candidate. If you want it, you can get it from the CVS tree (http://www.python.org/psa/cvs.html). --Guido van Rossum (home page: http://www.python.org/~guido/) From stephan at pcrm.win.tue.nl Fri Apr 23 10:34:06 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 23 Apr 1999 16:34:06 +0200 Subject: Suggestion for alternative to map/filter functions References: Message-ID: "Evan Simpson" writes: > What language are we speaking of here? I'm sure somebody here would be > interested in a description of this mystery construct, if it's sufficiently > elegant. Sorry, I find your post amusingly cryptic. My guess would be that he's talking about list comprehension. (Did I spell that last word correctly.) That looks something like this (pseudo Haskell/Python alert): strlist = [str(i) | i <- intlist ] ,which is supposed to do the same thing as strlist = map(str,intlist). To filter out all negative numbers: strlist = [str(i) | i <- intlist | i >= 0] You see, mapping and filtering in one fellow swoop! Cool! Sorts of, at least. Greetings, Stephan From mal at lemburg.com Wed Apr 28 09:18:13 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 28 Apr 1999 15:18:13 +0200 Subject: ANN: mxCGIPython Version 0.2.0 Message-ID: <37270A95.2E33A840@lemburg.com> ANNOUNCING: mxCGIPython Version 0.2.0 Setup scripts to build one-file easy-to-install Python interpreters >From the web-page: If you are in the CGI scripting business, then you know how hard it can sometimes be getting the sysadmins to install Python for you. I ran into such situations a few times. Fortunately it's not a big problem, if you can get a grip on a pre-compiled binary for the machine the ISP is running. Since installing a complete package with many files through a FTP-only connection is not exactly fun, we need something different here. This were the freeze tool can help: with it you can wrap the interpreter together with the whole standard library and the builtin modules into one single file. All that remains is to FTP that binary to the ISP and off you go. Ok, so much for the theory. Now where do you get that pre-compiled binary from ? That's where this campaign starts... I encourage everybody on this list and in the news group to have a look at this package and help build a library of pre-compiled single file interpreters. This would certainly help a lot of CGI writers out there in making a decision whether to use Python or Perl... More infos are available on my Starship pages: http://starship.skyport.net/~lemburg/mxCGIPython.html -- Marc-Andre Lemburg Y2000: 247 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From cgw at fnal.gov Mon Apr 19 12:50:47 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Mon, 19 Apr 1999 16:50:47 GMT Subject: How libpython1.5.so In-Reply-To: <199904190114.VAA03514@207-172-39-16.s16.tnt10.ann.va.dialup.rcn.com> References: <371320F4.5338600B@earth.ox.ac.uk> <199904190114.VAA03514@207-172-39-16.s16.tnt10.ann.va.dialup.rcn.com> Message-ID: <14107.24295.964592.782833@buffalo.fnal.gov> A.M. Kuchling writes: > Here's a patch to the top-level Makefile.in which adds a "shared" > target. Can people please try this and see if it works on your > favorite Unix variant? I tried this on Linux 2.2.5 with GCC, on Solaris 5.5.1 with the Sun C compiler (SC4.0 18 Oct 1995 C 4.0) and on Irix 5.3 with the SGI compiler. Good news is that it works on all of those platforms. Minor bug is that the generated library is called, on all 3 platforms, libpython1.5..so (with an extra "." in there) From tim_one at email.msn.com Mon Apr 12 11:52:50 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 12 Apr 1999 15:52:50 GMT Subject: bug report: profiler In-Reply-To: <7es542$94v$1@beta.EMBL-Heidelberg.DE> References: <7es542$94v$1@beta.EMBL-Heidelberg.DE> Message-ID: <000001be84fc$84ba9d00$ac9e2299@tim> [Ralph Heinkel] > when trying to run the profiler calibration explained in the python > documentation, I got the following error: > > Python 1.5.1 (#8, Dec 18 1998, 09:42:46) [GCC 2.7.2.1] on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import profile > >>> pr = profile.Profile() > >>> print pr.calibrate(100) > Traceback (innermost last): > File "", line 1, in ? > File "/usr/local/lib/python1.5/profile.py", line 498, in calibrate > self.instrumented() > File "/usr/local/lib/python1.5/profile.py", line 515, in instrumented > self.profiler_simulation(a, a, a) > File "/usr/local/lib/python1.5/profile.py", line 520, in > profiler_simulation > t = t[0] + t[1] > AttributeError: __getitem__ Suggest you wait a day or two for 1.5.2 final to be released, or at least extract a 1.5.2 profile.py; this was fixed quite some time ago (the profiler uses one of several timing methods depending on the platform, but profiler_simulation *assumed* a particular one was in use -- presumably the one in use on the platform on which it was written ). BTW, calibration is a touchy process, and in my experience unless you always run on a dedicated dead-quiet machine, the result of fiddling with it is anomalies like negative reported runtimes. Profiling to get a feel for where the *bulk* of the time is being spent works fine without bothering. a-percent-or-two-here-or-there-may-vary-with-the-humdity-ly y'rs - tim From dozier at bellatlantic.net Thu Apr 22 09:25:02 1999 From: dozier at bellatlantic.net (Bill Dozier) Date: Thu, 22 Apr 1999 09:25:02 -0400 Subject: unpickling an NT object in Solaris? References: <5lzp42smtd.fsf@eric.cnri.reston.va.us> Message-ID: In article <5lzp42smtd.fsf at eric.cnri.reston.va.us>, Guido van Rossum wrote: >dozier at bellatlantic.net (Bill Dozier) writes: >> >> The text mode of pickling is not cross-platform and seems to expect UNIX >> linefeeds. :P > >Nonsense. However you must open the file you're pickling to in binary >mode: open(filename,'wb'). > Unfortunately, this detail is not found in the documentation. It certainly does not seem obvious that one should write a text file in binary mode. From dubois1 at llnl.gov Mon Apr 19 13:52:45 1999 From: dubois1 at llnl.gov (Paul F. Dubois) Date: Mon, 19 Apr 1999 17:52:45 GMT Subject: LLNL distribution 11 available Message-ID: xfiles.llnl.gov and ftp-icf.llnl.gov are now back up, and I have fought my way back through the security changes so I was able to fix the links to make them point to version 11. Versions 9 and 10 are also available via the ftp site. At version 11 the Windows distribution changes from a .exe file (an installer) to a .zip file that has a simple installation script you run with Python. This installation procedure requires Python 1.5. If you do not have Python 1.5 you will have to install by hand in whatever way you choose. Those of you who tried to use the link to LLNLDistribution.zip and failed were victims of the sudden LLNL shutdown, for which we are sorry. I also discovered that I had failed to upload the gifs and style sheet for the HTML version of the Numerical Python document. That is fixed too. Another reason to prefer PDF.(:->. From MHammond at skippinet.com.au Fri Apr 9 20:22:57 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 10 Apr 1999 10:22:57 +1000 Subject: Pythonwin problem in HookNotify References: Message-ID: <7em5ke$f60$1@m2.c2.telstra-mm.net.au> Phil Mayes wrote in message ... >of it. What are the odds of anyone using this rather obscure >area? Any opinions on the best way to handle this? Mark? Ive fixed it! Mark. From vdhome at idas.cz Thu Apr 22 16:43:44 1999 From: vdhome at idas.cz (vaclav.dvorak.) Date: Thu, 22 Apr 1999 20:43:44 GMT Subject: thread problem on Linux Message-ID: <924813824.1@idas.cz> Hello! I have an account on some Linux machine in school, so I thought I would test Python's portability, one of the reasons why I love it. I use OS/2, so I only had experience with Python on OS/2, but I assumed everything should work the same on Linux. There was Python 1.5.1 on the Linux machine. My first problem was that it didn't have the thread module. So I downloaded the most recent RPM of Oliver Andrich with Python 1.5.2 for Linux, but because I don't have sufficient rights on the machine to install the whole RPM, I only extracted the one executable file to my home directory and tried again. The thread module is there, but doesn't work! thread.start_new_thread doesn't throw an exception, but the new thread simply doesn't run. When I accidentally pressed Ctrl+D, it seemed to run for a while, but then the whole script froze. Would somebody please have an idea of what could be wrong? I admit that my knowledge of Unix is very limited, so perhaps this is an issue with Linux???? Bye, Vaclav/2. (vdhome at idas.cz) From duncan at rcp.co.uk Thu Apr 15 04:49:13 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 15 Apr 1999 08:49:13 GMT Subject: stupid Win-CGI getting started question References: <7f0f0h$pfb$1@nnrp1.dejanews.com> <8DA86302Bduncanrcpcouk@news.rmplc.co.uk> <7f2no0$n80$1@nnrp1.dejanews.com> Message-ID: <8DA9637FEduncanrcpcouk@news.rmplc.co.uk> bill_seitz at my-dejanews.com wrote in <7f2no0$n80$1 at nnrp1.dejanews.com>: >> The way I get CGI scripts to run with Netscape Enterprise server on NT is to >> put them in .cmd files instead of .py files. > >So nobody can run .py files as CGI? > >Is this a known problem? What's its scope? Only Netscape/NT? What about IIS? >What about Netscape/Solaris? > I didn't say it was impossible to run .py files as CGI, simply that I had problems getting it to work. Since my number one priority was not to take the web server off-line at all, there were limits to how far I could play around with it. I'm sure there must be some way to get it to work, but I got enough for my purposes. -- Duncan Booth duncan at dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan From glenn at gacela.demon.co.uk Thu Apr 22 16:29:08 1999 From: glenn at gacela.demon.co.uk (Glenn Rogers) Date: Thu, 22 Apr 1999 21:29:08 +0100 Subject: Project for newbie References: <70alf7.qc6.ln@loopback> <14110.12533.232498.655489@amarok.cnri.reston.va.us> Message-ID: In article <14110.12533.232498.655489 at amarok.cnri.reston.va.us>, Andrew M. Kuchling wrote: >Pete Jewell writes: >>I've read my way through the tutorial, and am now stuck - where do I go >>from here? I want to learn how to use Python, but don't have any >>pressing projects at the moment - can anyone suggest a program I should >>have a go at writing, to help me learn the language further? > > Having third parties provide ideas usually doesn't result in >anything interesting. I have a list of projects on my Web page, but >they're all extremely unlikely to appeal to anyone who isn't me (and >even I'm a bit cool on some of them). > For what it's worth, my first project (5ish months ago) was an internet-utility type thing: opening/closing connection, timing the period online, getting a list of mail waiting for me, telling me when I've stopped getting news etc. My second one was for work doing the same sort of thing over a telnet connection. Then several simple text filtering/processing utilities, and I'm now doing something that started life as an addressbook (storing in a database) but has now got rather more ambitious. What did everyone else do? -- Glenn the Gazelle From SunitJoshi at email.msn.com Tue Apr 6 20:09:04 1999 From: SunitJoshi at email.msn.com (SunitJoshi) Date: Tue, 6 Apr 1999 19:09:04 -0500 Subject: Writing lines longer than 80 charc ! Message-ID: I'm wondering if someone knew of a way of writing a line of more than 80 characters to a file in way that it won't split it into two lines. thanks Sunit sjoshi at ingr.com From richard at folwell.com Tue Apr 13 17:36:07 1999 From: richard at folwell.com (Richard Folwell) Date: Tue, 13 Apr 1999 21:36:07 GMT Subject: Python as an ODBC *source* on windoze ? Message-ID: <01BE8604.AE1D9CC0.richard@folwell.com> On 13 April 1999 14:57, Boris Borcic [SMTP:zorro at zipzap.ch] wrote: > Is there a way to have Python on windows to act as an ODBC source (server) on windoze ? > > Reason : to use the MS Access report generator component. Can you state your problem more generally? Reason I am asking is that it is not clear what you are trying to do. Python can work with databases. ODBC is a standard(ish) way of working with databases. You can use Python to addto/change/etc data in databases (both directly and via ODBC - search the Python website for "ODBC" for more details - I have used Sam Rushing's ODBC access stuff with success, but there are other approaches available). You can then use Access to manipulate/create reports on/etc such databases. It is certainly possible to implement a DBMS in Python (check out Gadfly!), but I suspect that you are asking a different question. (?) Richard From bernhard at alpha1.csd.uwm.edu Fri Apr 9 02:15:30 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 9 Apr 1999 06:15:30 GMT Subject: DLL Prob Win32com Message-ID: Get strange errors, when using PythonWin (win32all-124) with Python 1.5.2b2 or 1.5.2c1 on this Windows 95 machine here. The installprogram said that AXScript, Python Interpreter and Python Dictionary couldn't be registered. Should be registered manually. How can I do that? When importing COM stuff, I get: import pythoncom Traceback (innermost last): File "", line 1, in ?ImportError: DLL load failed: A device attached to the system is not functioning. Reading documentation I know about possible old COM dlls as noted on http://starship.python.net/crew/mhammond/bigpond/Downloads.html but my error message seems to be different. That why I though I just ask again. :-) (Python.org is not reachable from here right now, so I cannot follow the link on Hammond's page to find out more about that DLLs.) Is it save to install them? Another thing: The example in the architecture.html file seems to be out of data. It should be: from pywin.mfc import dialog (it is just not nice, if beginners stumble over on of the first examples.) Regards, Bernhard From tim_one at email.msn.com Mon Apr 12 22:06:20 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 13 Apr 1999 02:06:20 GMT Subject: role of semilcolon In-Reply-To: References: Message-ID: <000801be8552$393f1300$97a02299@tim> [Reuben Sumner] > In the python interpreter doing 'a=1;b=2;b=3' does what I would > expect, three seperate assignments. However ; doesn't seem to appear > in the language reference except in the list of delimeters. Is the > above example formally valid python? Yup, and the semicolon's formal role in the grammar is captured in the non-terminal "stmt_list", which you'll find in the manual's chapter on compound statements. Note that you'll hardly ever see a semicolon in an experienced Python programmer's code, though! "a, b, c = 1, 2, 3" is more idiomatic for what you did above, and in general Python is succinct so you can afford to write code readably and still fit a major algorithm on a single screen. > BTW as you can tell I am a newbie Yes: nobody else ever looks at the reference manual . > but I am impressed with the ease at which I was able to implement > some number theoretic algorithms (gcd, primaility testing, pollard > rho factoring, jacobian...) So let's pick on gcd. Here's the bare-bones idiomatic way to spell that: def gcd(a, b): while b: a, b = b, a % b return a Close to what you did? Finding the *fastest* way to write gcd in Python is something I've been working on for years . > Is there a big practical difference between using long numbers and > the mpz package? (is the latter faster) Python's bigint implementation is straightforward, very compact (in code size), and extremely portable. It wasn't aiming at speed or completeness. In contrast, the GNU GMP package has been labored over for years, with hyper-optimized core assembler routines on most major platforms. If you need peak speed, use that. At one time Andrew Kuckling combined the two, but don't know how usable that still is; see the first link at: http://starship.python.net/crew/amk/python/code.html big-ints-for-big-brains-ly y'rs - tim From fm at synchrologic.com Mon Apr 26 09:06:01 1999 From: fm at synchrologic.com (fm at synchrologic.com) Date: Mon, 26 Apr 1999 13:06:01 GMT Subject: GNU GUIs in Python (was Re: GUI other than Tkinter (wxPython)) References: <3721567f.1748033@news> <7fs9to$rlr$1@nnrp1.dejanews.com> <19990426080609.A503367@vislab.epa.gov> Message-ID: <7g1obm$97o$1@nnrp1.dejanews.com> There is an exception to the GPL in the license.txt file for wxWindows. It states: The exception is that you may use, copy, link, modify and distribute under the user's own terms, binary object code versions of works based on the Library. In article <19990426080609.A503367 at vislab.epa.gov>, Randall Hopper wrote: > On a related note, is wxWindows/wxPython GPLed? It isn't bold in stating > it, but I noticed in the Copyright section: > > http://web.ukonline.co.uk/julian.smart/wxwin/manuals/html/wx2/wx1.htm#topic0 > > it says: > > "Please see the wxWindows licence files (preamble.txt, lgpl.txt, gpl.txt, > licence.txt, licendoc.txt) for conditions of software and documentation > use." > > Many developers are familiar with the GNU license policy (you link with GNU > ==> you're GNU) which discourages use of any GNU product for commercial > purposes where you need to link at the factory. > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From phd at sun.med.ru Thu Apr 22 07:37:40 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Thu, 22 Apr 1999 15:37:40 +0400 (MSD) Subject: Pyton setuid program? In-Reply-To: <7fn0u5$9jm$1@news.rz.uni-karlsruhe.de> Message-ID: Hi! On 22 Apr 1999, Bjoern Giesler wrote: > is it possible to have a Python script run setuid? If so, how do I do > that? Having setuid script is big security issues. Most modern operating systems do not allow to do this. Perl has special provisions for making perl scripts setuid. In python please avoid it. Write setuid wrapper for your script. Standard python distribution has a file Misc/setuid-prog.c. It is a template for writing good setuid wrappers. > Or could that be a Linux problem? It is OS-specific. Yes, Linux (thanks a lot) is among other OSes that disable setuid scripts. > TIA, > --Bjoern > -- > | thank you for your time, worship the antichrist, and have a nice day /\ > +---------------------------------------------------------------------/()\ > | pgp key available on request /____\ Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From cgw at fnal.gov Thu Apr 29 18:14:08 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Thu, 29 Apr 1999 22:14:08 GMT Subject: Errors In-Reply-To: <3728CD26.907ED9A1@geocities.com> References: <3728CD26.907ED9A1@geocities.com> Message-ID: <14120.55728.975548.357835@buffalo.fnal.gov> smoothasice at geocities.com writes: > for word in All_Words: > z = 0 > while z < len(word): > if z == 0: > tally = tally + alpha.index(word[z]) > else: > tally = tally + (alpha.index(word[z]) * 26) > > It gives me this: NameError: tally > and I don't know why...... Try putting "tally = 0" somewhere. You get a NameError because when you execute the line tally = tally + alpha.index(word[z]) for the first time, Python evaluates the right-hand side of the assignment, and since "tally" has never been assigned to before, it has no value - it's an undefined name - hence the NameError. Once you fix this I think you will discover another problem - you need to increment "z" or else the "while z" loop never terminates. From brunomadv at ciudad.com.ar Fri Apr 16 10:42:31 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Fri, 16 Apr 1999 14:42:31 GMT Subject: restore sources from PYC [ANSWER] In-Reply-To: <000101be879c$8aed0670$6eba0ac8@kuarajy.infosys.com.ar> References: <000101be879c$8aed0670$6eba0ac8@kuarajy.infosys.com.ar> Message-ID: <001c01be8817$5b614800$6eba0ac8@kuarajy.infosys.com.ar> Hi! Thanks to all that replyed to my original posting ... I will rewrite my code ... :-) Thanks again. /B Bruno Mattarollo ... proud to be a PSA member > -----Original Message----- > From: python-list-request at cwi.nl [mailto:python-list-request at cwi.nl]On > Behalf Of Bruno Mattarollo > Sent: Thursday, April 15, 1999 9:03 PM > To: Python list > Subject: restore sources from PYC [Q] > > > Hi! > > By mistake I am unable to find the PY files (source) from a > project I was > working on. I only have the PYC files... Is there a way to recover the > sources from the PYC? I only need my sources, I don't give a d... for the > comments... > > TIA > > /B > > Bruno Mattarollo > ... proud to be a PSA member > From quinn at necro.ugcs.caltech.edu Fri Apr 23 19:12:15 1999 From: quinn at necro.ugcs.caltech.edu (Quinn Dunkan) Date: 23 Apr 1999 23:12:15 GMT Subject: vim5 + python: can't resolve symbol Message-ID: I gather there are some vim users around here... I've been having trouble getting vim's python mode to work properly. It doesn't want to load .so modules: When importing anything that loads a .so from vim (:py import ...), I get a screen full of "can't resolve symbol"s. Things like PyExc_OverflowError, Py_BuildValue, Py_InitModule4, etc. Some modules will load (like string), but some will ImportError: Unable to resolve symbol (like math). I can do ':py import vim' and do some elementary stuff, but I want my modules! The system is Linux 2, python 1.5.2b1, vim 5.0. Has anyone else experienced this? Suggestions, ideas? thanks! From tseaver at palladion.com Thu Apr 8 10:05:51 1999 From: tseaver at palladion.com (Tres Seaver) Date: Thu, 08 Apr 1999 09:05:51 -0500 Subject: Extreme Programming ( XP ) in python ? References: <199904080900.KAA17021@brahms.scom> Message-ID: <370CB7BF.CC27DDBA@palladion.com> Dave Dench wrote: > > Dear All, > I recently attended the OT99 conference at Oxford University. > One of the highlights was the inspiring keynote speech by Kent Beck > on his experiences with Extreme Programming ( XP ) . > ( ref: http://c2.com/cgi/wiki?ExtremeProgrammingRoadmap ) > Unfortunately, he was using Java as his particular language vehicle, > but that is not mandatory. > It would seem to me that XP and python is a marriage made in heaven. > Has anyone on this list had any experiences with XP on their projects? Given that XP is originally a Smalltalk methodology (Beck is one of the uber-gurus of the Smalltalk world), it can't be very wedded to Java. I was employing a semi-heretical[*] version of XP in most of my consulting work (C++/Delphi/Java) when I found Python: DING! [*] I don't quite hold with "you're not gonna need it!", which taints my orthodoxy. :) > PPS It would also seem that XML is starting to get linked with CORBA very > productively by passing content-rich strings. ( perhaps this is old news ? ) XML does provide an interesting, "Pythonesqu" alternative to CORBA's (new) object-by-value feature: passing self-describing objects as strings, rather than as "valutypes," trades off compile-time typechecks for a reduction in the dependency jitter. There are some downsides, however: the reduction in encapsulation can make for headaches. -- ========================================================= Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From dfan at harmonixmusic.com Thu Apr 22 15:31:45 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 22 Apr 1999 15:31:45 -0400 Subject: Reversing Long integers References: <371E0C46.E6FA76A9@princeton.edu> Message-ID: "Ira H. Fuchs" writes: | I am attempting to write an efficient Python program which can add | an integer to its reverse. This is quite easy to do in Lisp and | Mathematica but (mostly out of curiosity) I wanted to see how one | might do this in Python. Converting an integer to a string and | reversing it and converting back is quite easy (although not all of | these ops are primitives) but the fact that Long integers have the | letter L appended means that the loop must include moving the L to | the end of the reversed string prior to summing. Can anyone think of | a particularly clever way to do this? This isn't particularly clever, but it does the job. The time spent dealing with checking for longs should be negligible compared to the rest of it. s = `i` m = map (None, s) # Turn into an array of characters is_long = 0 if m[-1] == 'L': m, is_long = m[0:-1], 1 m.reverse() s2 = string.join (m, '') if (is_long): i2 = long(s2) else: i2 = int(s2) -- Dan Schmidt -> dfan at harmonixmusic.com, dfan at alum.mit.edu Honest Bob & the http://www2.thecia.net/users/dfan/ Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/ Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/ From fredrik at pythonware.com Mon Apr 19 15:15:59 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Apr 1999 19:15:59 GMT Subject: Beginner - Tkinter info References: <371c59e9.2723125@news.tin.it> <371B453E.C3F83831@foreman.ac.rwth-aachen.de> Message-ID: <004301be8a99$0faf7920$f29b12c2@pythonware.com> > "Introduction to Tkinter" > 1) It's a work in progress (which means: "woefully incomplete"). woeful: lamentably bad or serious; deplorable, afflictive, calamitous, dire, distressing, grievous, heartbreaking, lamentable, regrettable, unfortunate. ouch. > 2) It isn't available as one download (if it is, I couldn't find > it and I looked pretty hard). there's something called websucker.py down in the Tools directory in the Python distribution: $ cd Tools/webchecker $ python websucker.py http://www.pythonware.com/library/tkinter/introduction/index.htm gives you a local copy in no time at all. > 3) It is woefully incomplete. you already said that. From tim_one at email.msn.com Wed Apr 21 22:22:57 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 22 Apr 1999 02:22:57 GMT Subject: How many of us are there? In-Reply-To: <371E2648.DED123AE@callware.com> References: <371E2648.DED123AE@callware.com> Message-ID: <000301be8c67$08dd6600$959e2299@tim> [Ivan Van Laningham] > Hello, Pythonistas-- > Does anyone out there have some idea how many people subscribe to the > mailing list, or read the newsgroup? Yes, I keep exact daily tallies of both, along with the precise number of Python programmers broken down by industry, application, age, gender, income, countries of origin and residence, employer and life goals. While I can't pass this information out for free, it's available for a price. How do you think all those spammers got your email address ? python's-demographics-make-perl's-look-like-cobol's-ly y'rs - tim From guido at eric.cnri.reston.va.us Fri Apr 30 09:01:49 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 30 Apr 1999 09:01:49 -0400 Subject: while (a=b()) ... References: <19990430000141.A5867@shalott> <3728F8D0.5E91C0F5@bioreason.com> Message-ID: <5lwvyu9s8y.fsf@eric.cnri.reston.va.us> Andrew Dalke writes: > The usual answers when this is asked (quick, checking if this is > in the FAQ as it is a faq -- nope) are: It is now. Thanks for suggesting this! (Why don't more PSA members occasionally contribute to the FAQ wizard? The password is in your welcome-to-the-PSA mail!) --Guido van Rossum (home page: http://www.python.org/~guido/) From hew at hons.cs.usyd.edu.au Mon Apr 12 03:07:06 1999 From: hew at hons.cs.usyd.edu.au (Matthew Robert Gallagher) Date: Mon, 12 Apr 1999 17:07:06 +1000 Subject: RPC and XDR with python Message-ID: <37119B99.B3E2633C@hons.cs.usyd.edu.au> Does anybody know where these resource are located. python.org has a couple of ref but nothing concrete It would be better find an example thou thanks hew From pereira at research.att.com Thu Apr 29 22:58:58 1999 From: pereira at research.att.com (Fernando Pereira) Date: Fri, 30 Apr 1999 02:58:58 GMT Subject: FP exception, core dump in Python 1.5.2 (Tim's doing ) References: Message-ID: <290419992258582791%pereira@research.att.com> In article , Mark C Favas wrote: > [Tim Peters suggests some code to generate INFs and NANs] > > [Mark tries it, and...] > > On my platform, (DEC Alpha, Digital Unix 4.0D, Python 1.5.2) I get... a core > dump! (exclamation because it's one of the few Python core dumps I've seen). Unfortunately, the Alpha implementation of IEEE FP does not handle overflow gracefully. With the default C compilation flags, the code generated cannot recover from an overflow to stuff an Inf in the result, so the only thing the OS can do is to kill the process. Alternatively, with appropriate flags (can't remember them from the top of my head, had to deal with this 6 months ago), the C compiler adds machine instructions to allow recovery from FP exceptions, including storing Inf as a result of overflow. Unfortunately, FP performance in this mode is not nearly as good. None of the other machines I use (SGI, Sun, Intel, Mac) have this problem. On the other hand, none of them comes close to an Alpha in FP performance (with the dafault `fast' compilation setting). Tradeoffs... -- -- F From dnagata at creo.com Sun Apr 11 13:42:24 1999 From: dnagata at creo.com (Dale Nagata) Date: Sun, 11 Apr 1999 10:42:24 -0700 Subject: bug or feature? traceback with python -x off by one line Message-ID: <3710DF00.DF5@creo.com> I'm using Python 1.5.1 on Windows NT 4.0 Service Pack 3. If I run a script the "normal" way, the exception traceback prints the correct source file line numbers: E:\home\dale\test\>python testx.py Traceback (innermost last): File "E:\home\dale\test\testx.py", line 18, in ? main() File "E:\home\dale\test\testx.py", line 14, in main f = open( 'foo.txt', 'r' ) IOError: (2, 'No such file or directory') However, if I run the exact same script with the Python -x command line option to skip the first line of the script, the reported line numbers are consistently off by one: E:\home\dale\test>python -x testx.py Traceback (innermost last): File "testx.py", line 17, in ? try: File "testx.py", line 13, in main def main(): IOError: (2, 'No such file or directory') Is this the way it's *supposed* to work? I package a lot of Python scripts as ready-to-run Windows NT batch files by prepending the line @python -x %~f0 %* & goto :EOF which means "without echoing to the console window, run Python with the -x option, passing it the full path to this batch file with the rest of the commmand line arguments, and after it finishes executing, jump to the end of the batch file so it doesn't try to interpret the remainder of the file as native NT batch language". So when an error occurs in one of these Python-scripts-disguised- as-NT-batch-files, the traceback line numbers are always off by one. I've seen this enough times now that if I'm not too lazy or tired, I can grudgingly remember to adjust the line numbers, but since I've managed to convince a growing number of co-workers to start using Python and indeed make it an essential part of our software development, it's becoming an increasing source of confusion. Any ideas on the best way to resolve this? How, from within a script, can I detect that the -x option is in effect? Or do I have to go hack the interpreter source? Thanks in advance, -- Dale Nagata | tel : +1 604.451.2700 ext. 2254 (UTC-0800) Software Developer | fax : +1 604.437.9891 Creo Products Inc. | pgr : +1 604.691.8279 Burnaby BC Canada | http://www.creo.com/ From aa8vb at vislab.epa.gov Tue Apr 27 08:11:09 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 27 Apr 1999 08:11:09 -0400 Subject: Cross-references between dynamically loaded modules under AIX In-Reply-To: <7g42o5$d8u$1@nnrp1.dejanews.com>; from Jakob Schiotz on Tue, Apr 27, 1999 at 10:15:35AM +0000 References: <7g42o5$d8u$1@nnrp1.dejanews.com> Message-ID: <19990427081109.C579158@vislab.epa.gov> Jakob Schiotz: |I wrote a small function to convert a C pointer to a NumPy array (I am |using SWIG), ... it coredumps under AIX ... the dynamical loader under |AIX cannot resolve symbols in one module that refers to another module. Not knowing NumPy, my assumption is you are failing on a .so-to-.so module dynamic link. If so... I did something like this with SWIG recently myself, albeit on IRIX. Does AIX have the equivalent of an RPATH (check the ld man page, and search for rpath)? If so, just augment RPATH for the wraper module (.so) to point to the directory where your wrapped C shared libraries (.so's) live. FWIW, here is what I use to build my SWIG wrapper libraries. Note that the core C libraries they wrap live (or rather, are linked) to the current directory, so adding the current directory ($PWD) to the rpath is sufficient for my case: LINK_SO = ld -shared -rdata_shared -w -o32 -KPIC -rpath $(PWD) -L $(PWD) You can also use LD_LIBRARY_PATH, but for a number of reasons, it's better to use RPATH when you can. Randall From bryan.hann at pobox.com Sun Apr 11 13:34:04 1999 From: bryan.hann at pobox.com (Bryan Hann) Date: Mon, 12 Apr 1999 01:34:04 +0800 Subject: two questions References: <370dbbe7.71248459@scout> Message-ID: <3710DD0C.42B9FCD3@pobox.com> Chris... wrote: > 2) Is there an way to mimic Perls > perl -p -e s/pattern1/pattern2/ > command line? Perhaps you can derive something from the fileinput module. It might be handy :) (I.e., share if you do :) -- ================================================================== Bryan Hann -- bryan.hann at pobox.com -- www.pobox.com/~bryan.hann The RITE Group: Researching Information Technology in Education. ================================================================== From tim_one at email.msn.com Sun Apr 4 03:15:50 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 4 Apr 1999 07:15:50 GMT Subject: Why are they? Re: Module Documentation Strings In-Reply-To: References: Message-ID: <001101be7e6a$f7cea220$ea9e2299@tim> [Jeff "evil Japh" Pinyan] > Why are there documentation strings? ... why not just use > comment lines? D:\Python>python Python 1.5.2b2 (#0, Feb 16 1999, 17:09:09) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> dir([]) ['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort'] >>> print [].pop.__doc__ [].pop([index]) -> item -- remove and return item at index (default last) >>> Comments aren't available for introspection or interactive use. that's-all-ly y'rs - tim From sca at isogmbh.de Fri Apr 9 04:47:11 1999 From: sca at isogmbh.de (Chris...) Date: Fri, 09 Apr 1999 08:47:11 GMT Subject: two questions Message-ID: <370dbbe7.71248459@scout> Hello... Since I am new to python (ver 1.5 under NT), these may be silly, anyhow: 1) How can I copy files with python? At first I planned to run the DOS-command "copy" from python, but couldn't find the right function. Second, I thought, there might be a python command to do it. Until now, I didn't succeed. 2) Is there an way to mimic Perls perl -p -e s/pattern1/pattern2/ command line? Thanks a lot in advance bye Chris... From faassen at pop.vet.uu.nl Thu Apr 29 14:46:27 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Thu, 29 Apr 1999 20:46:27 +0200 Subject: Read MS Access 97 *.mdb files with python?? References: <37287369.D6E67313@t-online.de> <3728867D.94B5BBF9@appliedbiometrics.com> Message-ID: <3728A903.CF75B41A@pop.vet.uu.nl> Christian Tismer wrote: > > gemodek wrote: > > > > Does somebody know some > > piece of soft which can this?? > > Use PythonWin, create an interface for > Microsoft DAO (your version) with the > makepy utility, and then use COM to access Access. > > Something like > > import win32com.client > engine=win32com.client.Dispatch("dao.dbengine.35") > > Then you can use every method of the database > engine, as you can find in the VBA help file > of your copy of the MS Access distribution. You can also use ODBC, part of PythonWin as well: import dbi, odbc # note import them in this order # open database db = odbc.odbc("mydatabase_odbc_alias") # get cursor cur = db.cursor() # sql statement sql = "select * from whatever" # execute sql statement cur.execute(sql) # fetch all data data = cur.fetchall() More information is at: http://www.python.org/topics/database/ Look at the database API specs (version 1 is still used in PythonWin, I think). Unfortunately, all this advice may be useless, as I noticed that he's the same guy who asked about accessing an Access database on Linux. I know Linux can do ODBC, but I doubt there are Access drivers for ODBC on linux.. > > Or does somebody know if the description of > > the format ia avaible (for free of course). > > That's a long awaited feature which I guess will never > be available. What you could try for Linux is use a Windows script to convert the stuff to something else, and then put it into some Linux database. You use that one from there. The problem of course that it's hard to keep everything synchronized and up to date that way. Regards and good luck, Martijn From mambuhl at earthlink.net Thu Apr 22 22:26:45 1999 From: mambuhl at earthlink.net (Martin Ambuhl) Date: Thu, 22 Apr 1999 22:26:45 -0400 Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <7fmv24$agu$1@m1.cs.man.ac.uk> Message-ID: <371FDA65.804D7F8B@earthlink.net> "Donal K. Fellows" wrote: > > In article <371E964F.C531C2A at istar.ca>, > Eugene Dragoev wrote: > > Is there going to be any Tk implementation that will continue using > > lightweight components? Other than comp.lang.tcl, where this should be topical, and comp.lang.c, where it definitely is not, I have no idea which of the other 4 of the 6 groups give a tinker's damn about this. I have reset the followups to this message as comp.lang.tcl. Please do something similar in your subsequent postings. Please stop the inane childish massive crossposting. If you want to be known as unwelcome antisocial polluters of other newsgroups, why don't you just join the Meow group? In case you can't understand the above: Take this junk out of the newsgroups where it does not belong. Think before you you start another idiotic crosspost. Despite what you might think, usenet is divided into newsgroups for a reason. -- Martin Ambuhl (mambuhl at earthlink.net) Note: mambuhl at tiac.net will soon be inactive From duncan at rcp.co.uk Wed Apr 14 04:43:26 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 14 Apr 1999 08:43:26 GMT Subject: stupid Win-CGI getting started question References: <7f0f0h$pfb$1@nnrp1.dejanews.com> Message-ID: <8DA86302Bduncanrcpcouk@news.rmplc.co.uk> seitz at mail.medscape.com wrote in <7f0f0h$pfb$1 at nnrp1.dejanews.com>: >Installed the basic Python stuff. I can run the interpreter. But not clear on >getting it configured properly to talk CGI with my WinNT Netscape Enterprise >server. I set a CGI folder path properly, but I get a nasty error message. >But it's not a file-not-found, so I know it's finding the .py file. So I'm >guessing it's not finding the executable. > >How should that first #! be changed for Windows users? Could that be it? > >Could the fact that all my Python stuff is under >d:\program files\python\ >be part of the problem (the long folder name with a space in it)? I tried all sorts of configuration changes to get it to run .py files directly, and eventually gave it up as a bad job (mostly because I didn't want to risk breaking the server). The way I get CGI scripts to run with Netscape Enterprise server on NT is to put them in .cmd files instead of .py files. For example: ---------test.cmd---------------- @c:\Progra~1\Python\python -x "%~f0" %* & goto :EOF import os print "Content-type: text/html" print print "Test" print "Hello world from python.

" for k in os.environ.keys(): print k, os.environ[k], "
" print "" ---------end of test.cmd--------- You would need to change the path to reflect the location of your copy of Python, either use the 8.3 filename as above, or put the filename in quotes: @"c:\Program Files\Python\python" -x "%~f0" %* & goto :EOF works. To get Bobo (now ZPublisher) working, I use a wrapper .cmd file like this: --------------form.cmd---------------- @c:\Progra~1\Python\pythonw -x "%~f0" %* & goto :EOF import traceback, sys try: sys.path[0:0] = ["h:\\staff\\tvoc\\python"] import cgi_module_publisher cgi_module_publisher.publish_module("form") except: print 'Content-type: text/plain\n\n' print 'An error occured in attempting to set up the environment for this application.' -------------end of form.cmd------------------- sys.path needs to be set to include the directory with the python code you want to publish, but the python code need not be visible to the web users. I then set up a redirect in the Netscape server configuration so that an ordinary URL with an html extension gets redirected to form.cmd and the end user doesn't even need to know that any CGI is involved. -- Duncan Booth duncan at dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan From phd at sun.med.ru Fri Apr 9 06:13:10 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Fri, 9 Apr 1999 10:13:10 GMT Subject: simple dbm question In-Reply-To: <370D55D9.B75ECE47@hons.cs.usyd.edu.au> References: <370D55D9.B75ECE47@hons.cs.usyd.edu.au> Message-ID: On Fri, 9 Apr 1999, Matthew Robert Gallagher wrote: > import anydbm > file = anydbm.open('hew') > > error appears as > Traceback (innermost last): > File "/usr/local/lib/python1.5/anydbm.py", line 54, in open > return _mod.open(file, flag, mode) > gdbm.error: (2, 'No such file or directory') Is there GDBM database "hew"? If not - you need to create it: import anydbm file = anydbm.open('hew', 'w') > thanks > > hew > > Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From dalke at bioreason.com Fri Apr 23 00:11:15 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Thu, 22 Apr 1999 22:11:15 -0600 Subject: Built-in Modules gl, GL for SGI IRIX References: Message-ID: <371FF2E3.7FB17EBD@bioreason.com> David Steuber asked: > How difficult is it to set up the gl and GL modules to > look on the system for Mesa, GL or Windows OpenGL dlls and use the > appropriate shared objects for a Python program? GL and OpenGL are quite different libraries, with different function names, different ways of viewing the world, and even different transformation matricies (post- vs. pre- multiply). It would be hard to make them work together at the level you want. However, since you don't have to worry about supporting SGI hardware from about 1996 or earlier, just use the PyOpenGL module http://starship.python.net/crew/da/PyOpenGL/ and ignore that section in the Python manual. Andrew dalke at acm.org From aahz at netcom.com Fri Apr 23 09:44:43 1999 From: aahz at netcom.com (Aahz Maruch) Date: Fri, 23 Apr 1999 13:44:43 GMT Subject: try vs. has_key() References: Message-ID: Thanks for all the responses, it's a lot clearer now. As a side note, people who cc their posts by e-mail should stick the phrase "[posted and e-mailed]" at the top; it's disconcerting when one doesn't know whether something is intended to be private, and e-mail almost always arrives faster than news. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "You often don't really understand the problem until after the first time you implement a solution." - Eric S. Raymond From aa8vb at vislab.epa.gov Mon Apr 26 08:06:09 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Mon, 26 Apr 1999 08:06:09 -0400 Subject: GNU GUIs in Python (was Re: GUI other than Tkinter (wxPython)) In-Reply-To: <7fs9to$rlr$1@nnrp1.dejanews.com>; from fm@synchrologic.com on Sat, Apr 24, 1999 at 11:28:58AM +0000 References: <3721567f.1748033@news> <7fs9to$rlr$1@nnrp1.dejanews.com> Message-ID: <19990426080609.A503367@vislab.epa.gov> fm at synchrologic.com: |mrfusion at bigfoot.com wrote: |> Well, I've just about given up on EVER getting Tkinter to work on my |> Win98 machine. Is there any other GUI module that I can get that |> doesn't require TCL/TK to be installed on my machine? Isn't there |> something called GD? | |I am a real big fan of wxPython. I've gotten everyone at our company |hooked on it. We use it for prototyping apps now because it's so much |faster than any other tool (that is, VB). It has a full set of controls |(tree, list, grid). Actually, wxWindows on which it's based is pretty |nice as well (though C++ requires 10-20 times more typing). Check out |http://www.alldunn.com/wxPython/ and |http://web.ukonline.co.uk/julian.smart/wxwin/. I think you'll be pretty |happy with it. Good luck. On a related note, is wxWindows/wxPython GPLed? It isn't bold in stating it, but I noticed in the Copyright section: http://web.ukonline.co.uk/julian.smart/wxwin/manuals/html/wx2/wx1.htm#topic0 it says: "Please see the wxWindows licence files (preamble.txt, lgpl.txt, gpl.txt, licence.txt, licendoc.txt) for conditions of software and documentation use." Many developers are familiar with the GNU license policy (you link with GNU ==> you're GNU) which discourages use of any GNU product for commercial purposes where you need to link at the factory. Has anyone taken a look at how/whether this affects scripting code like Python scripts? Here you're usually not "linking" to anything until the program is run, and then it's the user actually responsible for the linking. This is similar to LKMs (loadable kernel modules) where the user makes the choice. (Though a snag might be if you have to relink the Python interpreter at the factor [like Tkinter] to support use of the GUI in scripts.) Randall From news at helen.demon.nl Tue Apr 27 15:47:08 1999 From: news at helen.demon.nl (Ilja Heitlager) Date: Tue, 27 Apr 1999 21:47:08 +0200 Subject: Designing Large Systems with Python References: Message-ID: <925242516.13209.0.rover.c3ade4b2@news.demon.nl> >Yes, they do. I should know - I'm working on a whopping great >big laboratory erp system built in Visual Basic. First there was >the prototype and it looked like a Windows program. [Very nice anekdote about (failure of) software management] > I don't think Python really insures you against these mistakes. You are right, maybe The Commando Returns by David Thielen and Larry Constantine in SD magazine. http://www.sdmagazine.com/supplement/ppm/homepage.shtml might be interesting Ilja From aahz at netcom.com Sun Apr 25 20:58:41 1999 From: aahz at netcom.com (Aahz Maruch) Date: Mon, 26 Apr 1999 00:58:41 GMT Subject: converting perl to python - simple questions. References: <000001be8f3e$eea9c3c0$d39e2299@tim> Message-ID: In article <000001be8f3e$eea9c3c0$d39e2299 at tim>, Tim Peters wrote: >[sweeting at neuronet.com.my] >> ... >> Anyway, since I know that there are a few ex-perlmongers on the list, >> would somebody be so kind as to confirm whether I've translated >> the following code snippets correctly : >> >> a) Perl's "defined". >> [perl] >> if (defined($x{$token}) >> >> [python] >> if (x.has_key(token) and x[token]!=None) : > >If should be enough to do > > if x.has_key(token): > >under the probably-correct theory that the Perl is just asking "does hash >'x' have key 'token'?" Try "definitely wrong theory" ;-). In Perl, exists($x{$token}) is precisely equivalent to Pyton's x.has_key(token), and you can either use defined($x{$token}) or $x{$token}!=undef to make sure that a value exists for that key. Thing is, in Perl you can go straight to checking the value because a non-existant key is not an error. (I won't quite call myself a Perl expert, but I'm pretty close to an expert on Perl hashes.) -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Hi! I'm a beta for SigVirus 2000! Copy me into your .sigfile! From SunitJoshi at email.msn.com Mon Apr 5 20:04:15 1999 From: SunitJoshi at email.msn.com (SunitJoshi) Date: Mon, 5 Apr 1999 19:04:15 -0500 Subject: Help! Parsing file Message-ID: I have a text file with two cols like: ADDBBD 'This is a test file that spans two lines' I was wondering if someone could point out the best way to scan this file so that I can create an output file like: ADDBBD This is a test file that spans two lines i.e without the single quotes thanks Sunit From tim_one at email.msn.com Fri Apr 23 00:12:48 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 23 Apr 1999 04:12:48 GMT Subject: unpickling an NT object in Solaris? In-Reply-To: References: Message-ID: <000201be8d3f$8d3269e0$9a9e2299@tim> [Bill Dozier] > The text mode of pickling is not cross-platform and seems to > expect UNIX linefeeds. :P [Guido] > Nonsense. However you must open the file you're pickling to in binary > mode: open(filename,'wb'). [Bill] > Unfortunately, this detail is not found in the documentation. It > certainly does not seem obvious that one should write a text file > in binary mode. It does if you've tried to port any other kind of text file from Windows to Unix, whether via Python or C -- there's nothing unique to pickle in this! Windows text files aren't properly read by Unix libc file routines, and that's all there is to it. text-files-aren't-portable-period-ly y'rs - tim From ranjan.bagchi at pobox.com Tue Apr 13 11:03:54 1999 From: ranjan.bagchi at pobox.com (ranjan.bagchi at pobox.com) Date: Tue, 13 Apr 1999 15:03:54 GMT Subject: Help? Newbie COM Question Message-ID: <7evmck$2en$1@nnrp1.dejanews.com> Hi -- I'm checking Python out for automating COM objects and fast GUI development. The COM objects in question are developed in VisualJ++, and in other COM enviromments (tcl with the tcom package), I can get lists of methods and properties offered by the object. Is there an easy way to do this in WinPython? Thanks in advance! -rj -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From Norbert.Klamann at pobox.com Tue Apr 27 01:29:45 1999 From: Norbert.Klamann at pobox.com (Norbert.Klamann at pobox.com) Date: Tue, 27 Apr 1999 05:29:45 GMT Subject: HELP - FTP seesions using python???????? References: <7g328l$hga$1@nnrp1.dejanews.com> Message-ID: <7g3i05$uo9$1@nnrp1.dejanews.com> In article <7g328l$hga$1 at nnrp1.dejanews.com>, gony at my-dejanews.com wrote: > any links or tips etc on how to tackle automation of FTP sessions using python > would be most appreciated. Here is a batch example, it is an extract so it comes with no warranty :) It implements a 'put'-Operation on a file from Windows NT to an IBM-Host import ftplib def doit(): ftp = ftplib.FTP(FTPNameHost) ftp.login(FTPUserId,FTPPasswort) fileA= open(AuftragSammelDateiName,'r') ftp.storlines("STOR '" + AuftragHostDateiname + "'" ,fileA) ftp.quit() fileA.close() The 'STOR' and the "'" - Delimiters are specific for the FTP-Implementation on an IBM Host. Hope that helps ! -- Norbert Klamann Klamann Software & Beratung Erftstadt Germany Klamann.Software at pobox.com -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From trashcan at david-steuber.com Tue Apr 6 16:46:12 1999 From: trashcan at david-steuber.com (David Steuber) Date: 06 Apr 1999 15:46:12 -0500 Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> Message-ID: mlh at idt.ntnu.no (Magnus L. Hetland) writes: -> "TM" writes: -> -> > Has anyone created a pov ray module for python? -> -> I have been thinking about it, but haven't done it yet... What do you -> think it should contain? This is a relatively off the cuff response. But I think such a module should provide python classes for the POV types. Then, instead of using the POV scene description language, you would use Python. You could algorithmicly create a scene or animation sequence. Then you would pass the data structure (a list or other sequence) to a Python function that renders it in POV scene description language for POV to digest and render. Another thing I would like to see is a module for generating RIB files. In fact, a Python RenderMan module would be quite nice, complete with shading language support. Anything out there like that? -- David Steuber http://www.david-steuber.com s/trashcan/david/ to reply by mail If you don't, I won't see it. From gscot at my-dejanews.com Sat Apr 10 00:52:06 1999 From: gscot at my-dejanews.com (gscot at my-dejanews.com) Date: Sat, 10 Apr 1999 04:52:06 GMT Subject: Internet Robot References: <7ehe9m$hbs$1@nnrp1.dejanews.com> Message-ID: <7emldl$rh9$1@nnrp1.dejanews.com> David Steuber: Thank you for the reply (and Thanks to every one that replied). It was a big help to read over the rfc 1945 and rfc 2068. It is the first time that I have every looked at one and they are pretty informative. I can now POST my request but the server is asking for authentication. You mentioned that it might be helpful to capture and look at the client?s out put. How do I do that. I am using linux RedHat 5.0. I read in ?TCP/IP Network Administration? from O?Reilly (A great book) and they suggested using snoop or tcpdump. I could not find a version of snoop for linux. I tried tcpdump, but it gave me a lot of what looked like Greek to me (I am not at my own computer or I would add some of tcpdump produced). I had expected to see thing in English. Thank you again for your previous reply and thanks in advance for any information you can give me with this. Gary In article , David Steuber wrote: > gscot at my-dejanews.com writes: > > -> To All, I would like to write a Python robot to play an Internet > -> game. I do not know how to make a POST request. Thanks to anyone in advance > -> that can point me in the right direction. Gary > > There are two ways to post data. I remember one way, but the other is > a little trickier. The simple way is to send up a URL encoded string > as the body of the request. The other is to send a multi-part mime > document. I suggest you go with the former if possible. A post would > look something like this: > > POST /URI HTTP/1.0 > Content-Length: octets > Content-Type: > > URL+Encoded+Data+as+name+value+pairs > > A good thing to do would be to capture the output of an HTTP client > posting form data. Also see RFC-1945 and RFC-2068. > > -- > David Steuber > http://www.david-steuber.com > > s/trashcan/david/ to reply by mail > If you don't, I won't see it. > > A LISP programmer knows the value of everything, but the cost of > nothing. > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From banderson at boi.hp.com Mon Apr 5 17:35:52 1999 From: banderson at boi.hp.com (Bill Anderson) Date: Mon, 05 Apr 1999 21:35:52 +0000 Subject: Python books References: <7dtsa4$b6p$1@nnrp1.dejanews.com> <7e0t19$1de$1@nnrp1.dejanews.com> <7e2vol$8c6$1@news1.rmi.net> <37090160.C52377BA@boi.hp.com> <3709119F.59ACCC73@spacenet.tn.cornell.edu> Message-ID: <37092CB8.C958CCBE@boi.hp.com> Tom Loredo wrote: > > Bill Anderson wrote: > > > So what other publisher has a Python book out, and what is the name of > > it? > > You could of course find this out at python.org, but FWIW the answer is: > > *Internet Programming With Python* which includes Mr. Python himself > in the author list. Despite its title, it has very good *general* > coverage of Python, including extending and embedding it; the > chapters on creating HTML documents and writing CGI scripts should > be viewed merely as nice examples showing off some of the capability > described more generally in the earlier chapters. I think the > title is a bit unfortunate. > > -Tom Loredo Have that one. In a momentary lapse of memory forgot it wasn't published by O'Reilly %-} I agree that it's usefullness exceeds the title. -- Bill Anderson Linux Administrator MCS-Boise (ARC) banderson at boi.hp.com My opinions are just that; _my_ opinions. From MHammond at skippinet.com.au Tue Apr 13 03:43:54 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 13 Apr 1999 17:43:54 +1000 Subject: Python without registry entries References: <370fb711.28093946@news.demon.co.uk> <7eol16$1l2$1@m2.c2.telstra-mm.net.au> <37121820.3758204@news.netmeg.net> <37116F7B.3E3088EB@prescod.net> Message-ID: <7eushr$see$1@m2.c2.telstra-mm.net.au> Paul Prescod wrote in message <37116F7B.3E3088EB at prescod.net>... > I would prefer if PythonWin did what Netscape does which is put the vast > majority of setup information in a text file in the Netscape directory and Actually, this is done in .py code. A single MFC call allows you to toggle this behaviour. Would certainly be possible to have most Pythonwin config info in a .ini file with only very minor changes. But this is only info like the recent file list, window positions, editor preferences etc - not pythonpath type information - pythonwin leaves that to Python (as as Fredrik mentions, site and sitecustomize are good mechanisms for that) Mark. From paul at prescod.net Fri Apr 16 05:44:20 1999 From: paul at prescod.net (Paul Prescod) Date: Fri, 16 Apr 1999 09:44:20 GMT Subject: Simple module installation Message-ID: <37170674.F77233A6@prescod.net> I was just installing Fnorb and it was as painless an installation as a sane person could ask for but I got to thinking...couldn't this be less painless? The reason I ask is because I'm thinking of distributing code that depends on code that depends on code that depends on Fnorb and I need each installation part to be as simple as possible. So this isn't meant to pick on Fnorb in particular but to use it as a random sample package with binary and Python parts. The only thing that makes it extremely mildly painful is that it requires setting a few environment variables: FNORB_HOME PYTHONPATH PATH The PYTHONPATH and PATH would be unneccessary if Fnorb used the Windows registry. Even so, I think that a Python-managed, portable, text file-based registry (like JPython's) would be better than depending upon the over-centralized Windows registry. FNORB_HOME seems to only exist in order to implement a feature that Andrew Kuchling has asked for before. Fnorb has a bunch of tiny scripts that do this: @python.exe "%FNORB_HOME%"\Fnorb\script\fnendian %1 %2 %3 %4 %5 %6 %7 %8 %9 If Python could find scripts in its PYTHONPATH then this wouldn't be necessary. So this is a feature request for that feature. I can implement it if people agree it would be a good idea: python -r script: run the script named "script.py" in the PYTHONPATH If we put my idea for a Python-managed registry together with the "-r" idea then Fnorb could register itself on Windows or Unix like this: python -r register Fnorb /path/to/fnorb -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "In spite of everything I still believe that people are basically good at heart." - Anne Frank From marduk at manson.ddns.org Thu Apr 8 21:52:19 1999 From: marduk at manson.ddns.org (marduk at manson.ddns.org) Date: 9 Apr 1999 01:52:19 GMT Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> Message-ID: TM says: >I would love a copy. I've only written a few (simple) modules, >but I'd sure like to try and help you out. > Second that. Perhaps it would be easier putting it on a web/ftp site. marduk at python.net -- ---------------------------------------------------------------- (c) Copywight 1992 Elmer Fudd. All wights wesewved. From djosephs at citiscape.com Tue Apr 13 06:27:17 1999 From: djosephs at citiscape.com (DMJ) Date: Tue, 13 Apr 1999 10:27:17 GMT Subject: Python list removal References: <3709C492.EED3BF03@parkey.com> <370A7E0A.3C8D79B9@metricom.com> Message-ID: <37131C03.63C86F43@citiscape.com> > To Whom it May concern, Please remove djosephs at citiscape.com, fadler at citiscape.com and media at citiscape.com from the newsgroup mailing list for questions Thank you David Josephs CFO CITISCAPE From MHammond at skippinet.com.au Thu Apr 8 21:11:40 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 9 Apr 1999 11:11:40 +1000 Subject: How to use long names in python for windows References: <370e9080.37656309@news.interaccess.com> Message-ID: <7ejk3a$5ir$1@m2.c2.telstra-mm.net.au> Bob Hays, Computer Geek wrote in message <370e9080.37656309 at news.interaccess.com>... >I'm on Win95, I've downloaded python 1.5.1 and pythonwin (123 I >think). I've been using pythonwin for development and that works >great. Now, I want to create a set of batch files to run processes >for me - I'm getting the following error from python: > >ValueError: Module name too long This is very strange. Internally, Python will throw this error when it is asked to import a module name over 255 characters long - certainly isnt an "8.3" issue. You could try adding to the start of your script: import sys for path in sys.path: print path When the script fails, see what the values are, and if there are any insanely long paths that somehow got themselves in... >Is there a problem with long file name support in python 1.5.1 on >Windows95? Is there some startup script I need to execute first to Nope - long file names (up to 255 characters) should work fine... Mark. From mal at lemburg.com Fri Apr 16 07:19:42 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 16 Apr 1999 11:19:42 GMT Subject: ANN: mxStack Package - Version 0.3.0 Message-ID: <37171CCE.656F3EF6@lemburg.com> ANNOUNCING: mxStack Version 0.3.0 A Python Extension Package providing a fast and memory efficient stack implementation. WHAT IT IS: mxStack is an extension package that provides a new type called Stack. The type works like a stack with an implementation that is optimized for speed. Memory usage is comparable to that of Python lists. The package also includes a UserStack implementation written entirely in Python. Apart from providing access to this type to Python programmers, the extension also exports a C API object useable by third party extensions. This API gives direct access to the implementation through C function calls. WHAT'S NEW ? The 0.3.0 version fixes a memory leak and adds a few more methods to the type, making it more versatile and efficient. An up-to-date pre-compiled Windows PYD file is included in the package. WHERE CAN I GET IT ? The full documentation and instructions for downloading and installing can be found at: http://starship.skyport.net/~lemburg/mxStack.html WHAT DOES IT COST ? mxStack comes with a Python-style license, but is otherwise free for commercial and non-commercial use. WHERE CAN I GET SUPPORT ? I am offering commercial support for this package through Python Professional Services Inc. (http://www.pythonpros.com). Look on their support pages for details or contact me directly. REFERENCE:

Hi All.. New to OpenGL so please bear with me. I'm trying to create an OpenGL port in my application to display images--only way to show more than 256 colors here on our SGIs. I've been having some difficulties: 1.) Any way to scroll via. scrollbars the OpenGL port? (like attaching to a canvas but that didn't seem to do the trick) 2.) My Images are always offset about 25% up and left using this code: glLoadIdentity() gluOrtho2d(0,portWidth,0,portHeight) glRasterPos2i(0,0) glDrawPixels(imWid,imHeight, GL_RGBA, GL_UNSIGNED_BYTE, im) At least I can see the image, but I don't understand where the offset is coming in. I've looked for a simple "DisplayImage" demo but haven't found one. Thanks in advance! Mark A. McGuire mcguire at rhythm.com Rhythm & Hues Studios, Inc. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From mwh21 at cam.ac.uk Mon Apr 19 05:32:38 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Apr 1999 10:32:38 +0100 Subject: How libpython1.5.so References: <371320F4.5338600B@earth.ox.ac.uk> <199904190114.VAA03514@207-172-39-16.s16.tnt10.ann.va.dialup.rcn.com> Message-ID: "A.M. Kuchling" writes: > Nick Belshaw writes: > > Whilst trying to get Python plugins to work on Gnumeric-0.23 I bumped up > > against the need for libpython1.5.so.0.0.0 > > Here's a patch to the top-level Makefile.in which adds a "shared" > target. Can people please try this and see if it works on your > favorite Unix variant? It works on mine (bog standard redhat5.2/i686 glibc2 egcs 1.1.2) and now gnumeric loads Python extensions! Yippee! I had to make a small change to the patch, see below. > It doesn't verify that you've compiled all the > code with -fPIC or whatever's required; I'm not sure how to check or > enforce that. (It could do "make clean ; make CCFLAGS=", > but is that too extreme?) The proper answer is to use libtool I suppose. You need to build with "make OPT='-g -O2 -fPIC'" rather then CCFLAGS, btw. > Index: Makefile.in > =================================================================== > RCS file: /projects/cvsroot/python/dist/src/Makefile.in,v > retrieving revision 1.80 > diff -C2 -r1.80 Makefile.in > *** Makefile.in 1999/02/23 15:43:15 1.80 > --- Makefile.in 1999/04/19 00:53:28 > *************** > *** 214,217 **** > --- 214,226 ---- > libtool -o $(LDLIBRARY) -dynamic $(OTHER_LIBTOOL_OPT) $(LIBRARY) -framework System @LIBTOOL_CRUFT@ > > + # Target to make a shared library containing the interpreter > + > + shared: $(LIBRARY) > + test -d .shared || mkdir .shared ; \ > + (cd .shared;ar x ../$(LIBRARY); $(LDSHARED) -o ../libpython$(VERSION).$(SO) *.o ); \ -----------------------------------------------------------------------------^ This period shouldn't be here. > + /bin/rm -rf ./.shared > + > + > + > $(SUBDIRS): Makefiles > > > -- > A.M. Kuchling http://starship.python.net/crew/amk/ > Since I killed my son... the Dreaming has not been the same ... or perhaps I > was no longer the same. I still had my obligations... But even the freedom of > the Dreaming can be a cage, of a kind, my sister. > -- Dream, in SANDMAN #69: "The Kindly Ones:13" Thanks a lot! Michael From morse at harborcom.net Thu Apr 15 10:07:52 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Thu, 15 Apr 1999 14:07:52 GMT Subject: overloading ( was Different methods with same name but different signature? ) - overloadinginpython.tar.gz (0/1) References: <3716909C.D8D1B372@fedex.com> Message-ID: <3715f152.73653197@news.oh.verio.com> Here's some code by Bjorn Pettersen that implements a scheme for overloaded member functions. I've not messed RTTI in user types, but I think you might need to overload whatever handles the type info for a user class in each of your user classes. Bjorn's code uses the types of all parameters passed to a function as key into a dictionary containing the correct function for various types of input paramters. It works very well. frederic pinel wrote: >Hello, > >While trying to implement the visitor pattern in Python, I ran into the >following problem: > >My class needs to have 2 (or more) different methods, but with the same >name, the difference being the signature (an object in my case), >unfortunately Pyhton interprets this as an overidding, and only >considers the last method defined. >C++ being able to switch to the right method, based on the signature, I >thought Python would. From donn at u.washington.edu Tue Apr 27 11:43:10 1999 From: donn at u.washington.edu (Donn Cave) Date: 27 Apr 1999 15:43:10 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <37215EFB.433AFCA6@prescod.net> <3724B2D6.B468687A@prescod.net> <37252816.42634501@Lugoj.Com> Message-ID: <7g4lue$qsq$1@nntp6.u.washington.edu> roy at popmail.med.nyu.edu (Roy Smith) writes: |James Logajan wrote: |> When an SME finds the tool too slow, it would be nice if they could post |> their problem to a group like this without fear of insult, intended or not. | | There was no intent to insult. | | The thread was moving in the direction of "my program using regex is too | slow, and I think the solution would be to move regex into the python core | to make it faster". I was just pointing out why that is flawed reasoning. I didn't read any insult. You venture into a somewhat sensitive area when you start making distinctions like ``good programmer'', and I reckon some criticism is inevitable. It's going to take a while to come to terms with this issue (Python for people who don't qualify as expert programmers), and in this process we need to feel free to speak up without too much fear of saying something politically incorrect. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From faassen at pop.vet.uu.nl Tue Apr 6 05:11:28 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Tue, 06 Apr 1999 11:11:28 +0200 Subject: Python Chip References: <3703C591.FE65E94D@pop.vet.uu.nl> Message-ID: <3709CFC0.BCB0990A@pop.vet.uu.nl> Hi everybody, For those who are still anxiously itching to get their hands on a Python machine, this was of course an April Fool's joke. :) You can now all come to destroy me now. (any other jokes in this newsgroup which I missed?) Martijn From fredrik at pythonware.com Mon Apr 19 04:28:18 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Apr 1999 08:28:18 GMT Subject: [Image-SIG] PIL 1.0b1 bug report References: <199904170334.XAA06683@python.org> Message-ID: <017401be8a3e$d6f37f00$f29b12c2@pythonware.com> Piers Lauder wrote: > I had to add the following code just before the last #include > in each of Jpeg{En|De}code.c > #undef METHODDEF > #define METHODDEF(A) static A > #undef GLOBAL > #define GLOBAL(A) A > > Without that, the macros produced code of the form > static (void) XXX this is not a bug. you're using an old version of the JPEG libraries (older than 6a, which is the oldest version listed in the PIL README). recent versions of the JPEG library can be obtained from: http://www.ijg.org/ (but now that you've fixed this, version 6 should work just as well as 6a!) Cheers /F fredrik at pythonware.com http://www.pythonware.com From fredp at multimania.com Mon Apr 26 17:15:28 1999 From: fredp at multimania.com (Fred Pacquier) Date: Mon, 26 Apr 99 21:15:28 GMT Subject: Python and "Hand held" computers References: <37222AE6.E6C8F713@weihenstephan.org> Message-ID: <7g2l65$92k$1@minus.oleane.net> In article <37222AE6.E6C8F713 at weihenstephan.org>, peter.stoehr at weihenstephan.org wrote: >Hi Python-Fans, > >I'm a great fan of python and I'm now looking for an hand held computer >(something smaller than a laptop) that can be programmed with python. > >Is there a WEB page or any other place were I can find information about >this >topic? > Python 1.5.1 was ported last year to the Psion Series 5 by an Englishman, and it works quite well. I can find the Web site if you're interested... From MHammond at skippinet.com.au Wed Apr 14 00:26:56 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 14 Apr 1999 14:26:56 +1000 Subject: Freezing an App References: Message-ID: <7f15dj$bq4$1@m2.c2.telstra-mm.net.au> Calishar wrote in message ... > The part I am having problems with is using win32api. It runs, doesnt set >the registry values it is suppoed to, and exits without giving any errors. Im not sure what you mean here. Firstly, you could consider simply shipping win32api.pyd - ie, dont freeze it. You should definately try to get your frozen application working with win32api.pyd before attempting to freeze it. You do this simply by excluding win32api from the freeze using "-x win32api" If you want to freeze the win32api sources into your app, the process then is: * Download the sources to the win32api module. * Check out the .ini file that comes with freeze. It is used to locate the source to win32apimodule.cpp. Run freeze - it may complain it cant find the file. If so, ensure the environment variable it uses is set. I can't recall exactly what that is. This could do with more work - Im happy to discuss ways you can help to make this better for the next person :-) Mark. From bmcd at es.co.nz Thu Apr 29 18:51:19 1999 From: bmcd at es.co.nz (Ben Caradoc-Davies) Date: 29 Apr 1999 22:51:19 GMT Subject: Python and Perl (was: converting perl to python) Message-ID: [This is not intended to start another pointless language war. Well, at least not between Perlers and Pythonistas. :-) ] On Thu, 29 Apr 1999 20:29:45 +0300, Moshe Zadka wrote: >I wonder if Randal came here (2 messages in this group) to spread the >regular Perl propaganda (summarized by "This language is icky because >programmers are icky").... >Randal, while I'm sure you're a good guy, and I liked ``Learning Perl'', >most of us at c.l.py heard more about Perl then we'll ever want to -- >in fact, I think many of us moved to Python from Perl, and never looked >back. (Or we'd turn into salt) >(And hey, Randal, when you wake up and start using Python, I'm sure you'll >be one of the best c.l.py posters <0.5 wink>) Hmm ... Randal did have a rather Python-friendly .sig ... I would be reluctant to start hassling him. I think that between Tom C. and Randal, some of the nicest things that I have heard said about Python have come from Perlers. In my opinion, Perl is one of the best things Python has going for it; 1) Perl has, because of it's extreme usefulness, very deep "market penetration" (ugh, I'm sounding like a suit). 2) Perl has established the credibility of dynamically typed high level languages (I'm trying to stamp out the term "scripting languages") for general purpose programming. 3) The nice people in c.l.p.m mention Python from time to time, and point people in the right direction. And then there's Tom C's web page comparing Perl and Python. Perl is a fertile breeding ground for Pythonistas. I'm sure many expand into Python from Perl. But Perlers never forget their roots. Some things are just too succint in perl to do any other way. e.g. deformatting a document, when you need extended regex and text which sed can't handle; perl -e "while(<>){s/\s/\n/g;print;}" file1.txt > temp1.txt perl -e "while(<>){s/\s/\n/g;print;}" file2.txt > temp2.txt diff temp1.txt temp2.txt And this was on a machine which didn't have python (yet!). Even if it had, I would have still used perl. Perl is going to be around for a long time. This is a very good thing for Python. -- Ben Caradoc-Davies From news at dorb.com Thu Apr 8 17:44:18 1999 From: news at dorb.com (Darrell) Date: Thu, 8 Apr 1999 17:44:18 -0400 Subject: Python is working HARD to make you cash! Message-ID: This must be Guido's money making arm of the PSA >From: sales at pythonvideo.com >Subject: Python pays 50% commission for live Amsterdam sex shows > >Dear Webmaster, > >Python is proud to introduce our newest plan to make you more money! > >We have increased our commissions on both the gay and straight Amsterdam >Live Sex Show. > >Now, instead of a one time 40% payout, you'll get 50% recurring commission! > >Check it out at http://www.pythonvideo.com/products/amls.phtml > >Just another way Python is working HARD to make you cash! > >Sincerely, > >David van der Poel >Vice President of Sales & Marketing >Python Communications Inc. >sales at pythonvideo.com From sweeting at neuronet.com.my Sun Apr 25 10:57:30 1999 From: sweeting at neuronet.com.my (sweeting at neuronet.com.my) Date: Sun, 25 Apr 1999 14:57:30 GMT Subject: converting perl to python - simple questions. Message-ID: <7fvagp$8lm$1@nnrp1.dejanews.com> In my ongoing saga to build a chinese-language search engine, I've found a great deal of groundwork already. The bad news (for me) is that this was all in Perl so I've had a rather distressing day : (a) learning perl (b) converting the scripts to python so that I can build objects with them. Anyway, since I know that there are a few ex-perlmongers on the list, would somebody be so kind as to confirm whether I've translated the following code snippets correctly : a) Perl's "defined". [perl] if (defined($x{$token}) [python] if (x.has_key(token) and x[token]!=None) : b) RE's. [perl] if ($mytext !~ /^\s$/) [python] if not (re.match('^\s$'), mytext) Since I know neither perl nor chinese, it would be nice if somebody could help me remove one of the variables in my debugging. Thanking you :) chas -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From bwarsaw at cnri.reston.va.us Fri Apr 16 19:54:28 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: 16 Apr 1999 19:54:28 -0400 Subject: Python.org scheduled down time References: <14103.22251.209537.804890@anthem.cnri.reston.va.us> <7f86kr$bd2@ds2.acs.ucalgary.ca> Message-ID: <61iuaw15qj.fsf@anthem.cnri.reston.va.us> >>>>> "NS" == Neil Schemenauer writes: NS> Is ftp.python.org mirrored anywhere? Lots of places. See http://www.python.org/Mirrors.html (which you can do now that the main site is back up again :-) -Barry From Bjoern.Giesler at stud.uni-karlsruhe.de Mon Apr 12 16:17:52 1999 From: Bjoern.Giesler at stud.uni-karlsruhe.de (Bjoern Giesler) Date: Mon, 12 Apr 1999 20:17:52 GMT Subject: Stupid Tkinter question References: <99041222110400.01382@dominion> Message-ID: <99041222210800.02403@dominion> Hi, On Mon, 12 Apr 1999 I wrote myself: [snip] >[snip] >#!/usr/bin/env python > >from Tkinter import * >from sys import * > >def makeToolbar(aFrame): > toolbar = Frame(aFrame) > markimage = BitmapImage(file = "Mark.xbm") > markbutton = Button(toolbar, > image = markimage, > command = exit) > > markbutton.pack() > return toolbar > >def makeUI(anApp): > frame = Frame(anApp) > toolbar = makeToolbar(frame) > > toolbar.pack() > frame.pack() > >app = Tk() >makeUI(app) >app.mainloop() >[snip] I've just found out why the example above doesn't work: If I add a "global markimage" to the function makeToolbar, it works. Now my question: Why does markimage have to be global, since it's only used by markbutton? And why, by analogy, doesn't markbutton have to be global? --Bjoern -- + thanks for your time, worship the antichrist, and have a nice day /\ +----------------------------------------------------------------- /()\ + support privacy on the 'net: mail me for pgp public key /____\ From bwinton at tor.dhs.org Fri Apr 16 19:04:07 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Fri, 16 Apr 1999 23:04:07 GMT Subject: Quick fix to add "+=" References: <3717AB14.2926AF76@mediaone.net> Message-ID: On Fri, 16 Apr 1999 17:26:44 -0400, Fuming Wang wrote: >Any one knows a quick fix to add "+=" function. I am really getting >tired of typing long names twice. Heh. I can't wait to see the other replies... :) += has been left out of the language for a good reason, and thus it's probably not likely that there's an easy way to add it. I think you will have to recompile the interpreter to get it to do what you want, and even then, I don't think that you really want what it would do. Surely there's some discussion about += in dejanews which would provide more enlightenment that I can. Later, Blake. From jody at ldgo.columbia.edu Tue Apr 6 16:34:08 1999 From: jody at ldgo.columbia.edu (Jody Winston) Date: 06 Apr 1999 16:34:08 -0400 Subject: Chaning instance methods Message-ID: I don't understand how to change instance methods. For example: class Foo: def __init__(self): self.data = 42 def m(self): print "Foo.m" print dir(self) def m2(self): print "m2" print dir(self) f = Foo() f.m() # this fails # f.m = m2 # f.m() Foo.m = m2 # Changes all instances of Foo.m f.m() f2 = Foo() f2.m() What am I forgetting? -- Jody Winston Manager SeisRes Lamont-Doherty Earth Observatory RT 9W, Palisades, NY 10964 jody at ldeo.columbia.edu, 914 365 8526, Fax 914 359 1631 Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. From rdr_nl at my-dejanews.com Tue Apr 13 12:10:44 1999 From: rdr_nl at my-dejanews.com (Henk Jansen) Date: Tue, 13 Apr 1999 16:10:44 GMT Subject: Lexical analyzers and parsers References: <7jn20jmxsw.fsf@gandalf.midearth.fuzzys.org> <14092.48400.954787.617539@amarok.cnri.reston.va.us> Message-ID: <7evq9s$68n$1@nnrp1.dejanews.com> In article <14092.48400.954787.617539 at amarok.cnri.reston.va.us>, "Andrew M. Kuchling" wrote: > Julien Oster writes: > >What about lexical analyzers and parsers? > > > >Under C I use bison/yacc and (f)lex. Under python, I can either implement this > >stuff using C or try to write my parsers on my own, which is real pain. > > There are actually a bunch of different systems available; see > http://starship.python.net/crew/amk/python/string.html#parsing > for a list. (If I've missed any, let me know.) I've tried out a few of the Python based parser-generator tools for a non-trivial language (Modelica). I found kwParsing and PyLR too slow, PyLR wasn't complete (and AFAIK still isn't). I was most successful with YAPPS and liked it because it's a recursive-decendent parser, ala ANTLR, but only LL(1). Finally, I've decided to use the Java-based ANTLR tool because it's mature, actively being used and supported by a wide users group. Moreover, it has great support for AST building and translation (I wouldn't like thinking of figuring out all this myself...). I'll probably use JPython to mix the best of both, simply because Python is great. Henk -- ===================================================================== Henk Jansen -- Delft University of Technology -- Dept. of Mathematics hjansen at math.tudelft.nl http://dutita0.twi.tudelft.nl/WAGM/people/H.Jansen.html -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From tim_one at email.msn.com Wed Apr 14 21:36:38 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 15 Apr 1999 01:36:38 GMT Subject: reval builtin In-Reply-To: <7f36m6$koq@ds2.acs.ucalgary.ca> References: <7f36m6$koq@ds2.acs.ucalgary.ca> Message-ID: <001701be86e0$68574a60$589e2299@tim> [Neil Schemenauer] > It would be nice to have an "reval" builtin that would only evaluate > literals. That would make building things like config files safe and > easy. I have two ideas on how to accomplish this: > > 1. Create a new start symbol "reval_input" in the Grammar/Grammar > and add a "builtin_reval" function in Python/bltinmodule.c. ... > > 2. Use something like lex and yacc to create an extension module > that does the Right Thing(TM). ... > > Perhaps some guru can explain an easy way to accomplish this and same me > some time. The /F-bot already did -- this is Python, and nothing is *that* hard . Even builtins are looked up dynamically at runtime, so all that's required is to take away eval's normal context. As a one-liner: def reval(string): return eval(string, {"__builtins__": {}}) This tells eval to use the dict {"__builtins__": {}} for both local and global lookups. "__builtins__" is the only key, so is the only name that *can* be looked up successfully. It's a semi-magical key that Python accesses internally when all other attempts to resolve a name fail, and in this case its value is an empty dict, so that makes Python's last-resort name-lookup fail too. >>> reval('1+2') 3 >>> reval('int("3")') Traceback (innermost last): File "", line 1, in ? reval('int("3")') File "", line 2, in reval return eval(string, {"__builtins__": {}}) File "", line 0, in ? NameError: int >>> Caution: it does not work to pass eval an empty dict: >>> eval('int("3")', {}) 3 >>> That may be obscure . The reason is this: >>> empty = {} >>> eval('int("3")', empty) 3 >>> empty.keys() ['__builtins__'] >>> That is, if the dict you pass to eval (or exec) doesn't have a "__builtins__" key, Python inserts one for you, with the same value as the current module's __builtins__. This is to make the normal use of eval/exec easier. So to stop Python cold, you have to supply your own "__builtins__" key. If you're determined to allow only literals (I don't see any harm in allowing e.g. 1+3), probably easiest to feed the string to the std parser module, then crawl over the AST looking for things to complain about. syntactic-cleansing-ly y'rs - tim From tismer at appliedbiometrics.com Fri Apr 23 15:07:07 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 23 Apr 1999 19:07:07 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> Message-ID: <3720C4DB.7FCF2AE@appliedbiometrics.com> Arne Mueller wrote: > > Hi All, > > I can't read in the whole file as a single block, it's too big, if > readline/write is slow the program will never get realy fast :-( Please try this one. For me, it was about 6-7 times faster than the first one. I don't read by line, also I don't read all in one. Let me know how it performs on your machine. I think I'm down to measuring I/O time. Well, the code is a bit long. But fast :-) I believe nothing more can be done, but to use P2C to get the interpreter overhead away. def read_write_bulk(input, output, exclude): bufsize = 1 << 16 splitter = ">" ignore=exclude.has_key split=string.split No = None buffer = input.read(bufsize) got = len(buffer) while len(buffer)>1 : pieces = split(buffer, splitter) idx = 0 inner = pieces[1:-1] for piece in inner: idx = idx+1 ; key = split(piece, No, 1)[0] if ignore(key): del inner[idx] ; idx = idx-1 output.write("<") output.write(string.join(inner, splitter)) if got==0: break chunk = input.read(bufsize) buffer = splitter+pieces[-1] + chunk got = len(chunk) if got==0: buffer = buffer+splitter # spill last one #:-) end of hack -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 steeds at ccms.net Wed Apr 28 22:56:26 1999 From: steeds at ccms.net (Mike Steed) Date: Wed, 28 Apr 1999 21:56:26 -0500 Subject: GUI and creating GIF References: <7g7u2k$fr0$1@wanadoo.fr> Message-ID: <3727CA5A.68BD@ccms.net> Frank.Derville wrote: > > Hello, > > I would like to > 1) create a GIF file under Python by drawing lines, text, ... I have looked > at Tk which can create bitmaps and photoimage but their seem to be no > possibility to transform a canvas into a photoimage. > 2) rotate some text on a canvas. > > Does anyone has a tip to do it under Tk, wxWindows or any other GUI? > > Thanks by advance I recommend you look at gdmodule by Richard Jones. I have a pre-compiled Win32 binary if you need it. http://starship.python.net/~richard/gdmodule/ -Mike From mlh at idt.ntnu.no Sun Apr 25 16:25:27 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 25 Apr 1999 22:25:27 +0200 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <3723757B.CF96D973@appliedbiometrics.com> Message-ID: Christian Tismer writes: > "Magnus L. Hetland" wrote: > > [...] > > In the long term, I think it makes sense to build the rest of > re.py also into pcre. Then I still would not see any reason > to embed its functionaliy into the language. Agreed. I guess this is what I really wanted. :) -- > Hi! I'm the signature virus 99! Magnus > Copy me into your signature and join the fun! Lie Hetland http://arcadia.laiv.org From jwpolley at cacd.rocwell.com Tue Apr 6 12:04:18 1999 From: jwpolley at cacd.rocwell.com (Jonathan Polley) Date: Tue, 06 Apr 1999 11:04:18 -0500 Subject: Did I build 1.5.2b2 wrong????? Message-ID: <370A3081.CCBE15BE@cacd.rocwell.com> Hi, I just brought version 1.5.2b2 of python down and got it built using tcl/tk 8.0 (on Solaris 2.5.1) and am running IDLE. When I press the right mouse button I get the following traceback: Exception in Tkinter callback Traceback (innermost last): File "/net/mayhem/usr/lfs/v1/users/jwpolley/Python-1.5.2b2/Lib/lib-tk/Tkinter.py", line 764, in __call__ return apply(self.func, args) File "EditorWindow.py", line 214, in right_menu_event rmenu.tk_popup(event.x_root, event.y_root) File "/net/mayhem/usr/lfs/v1/users/jwpolley/Python-1.5.2b2/Lib/lib-tk/Tkinter.py", line 1492, in tk_popup self.tk.call('tk_popup', self._w, x, y, entry) TclError: invalid command name "tk_menuSetFocus(.2899048.text.3256864)" I know this works fine under NT, but I was able to download the executable and didn't have a chance to mess it up. Does anyone have any ideas as to what I may have done wrong in building python??? Any help would be appreciated! Jon Polley jwpolley at collins.rockwell.com From phd at sun.med.ru Tue Apr 20 12:12:34 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Tue, 20 Apr 1999 16:12:34 GMT Subject: unpickling an NT object in Solaris? In-Reply-To: References: Message-ID: On Tue, 20 Apr 1999, Bill Dozier wrote: > ImportError exception ("No module named __main__^M") when I try to ^^ It seems you ftp'd file in text mode. Try binary ftp. Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From mal at lemburg.com Thu Apr 29 18:15:31 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 30 Apr 1999 00:15:31 +0200 Subject: Python and CGI References: <37286538.5EAE0173@lemburg.com> Message-ID: <3728DA03.431E34BF@lemburg.com> M.-A. Lemburg wrote: > > Hi everybody, > > Yesterday, I mailed an announcement for mxCGIPython, a drop-in > setup extension for the Python source distribution that allows > compiling a one-file executable containing the standard Python > interpreter + the standard library + the default builtin > modules. The result is a complete Python installation in one > single file -- easy to install and ship around. > > Although there were a number of hits on the web-page, I'm not > sure whether the announcement got the message through... this > is intended to be a campaign with the goal of promoting Python > as CGI engine. Ok, the first compiled version are being submitted. Good sign :-) So far, I've received these setups: cgipython-1.5.2-Linux-2.0.35-i586-unknown.gz cgipython-1.5.2-Linux-2.0.36-i586-unknown.gz cgipython-1.5.2-Linux-2.0.35-i686-unknown.gz Hmm, maybe I should include the libc version/name too. > Hope this campaign becomes a success... > > http://starship.skyport.net/~lemburg/mxCGIPython.html > -- Marc-Andre Lemburg Y2000: 246 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From jbkerr at sr.hp.com Wed Apr 21 11:54:46 1999 From: jbkerr at sr.hp.com (Jim Kerr) Date: Wed, 21 Apr 1999 08:54:46 -0700 Subject: problem running 1.5.2 on Win95 Message-ID: <371DF4C6.C1276E96@sr.hp.com> Hello, I tried installing the 1.5.2 binaries on my Win95b machine, and the results weren't happy. I opted to install both Python and Tcl/Tk, and the process seemed to go smoothly. Since there were no warnings to the contrary, I installed on top of my existing 1.5.1 files. The problem is, when I try to run PythonWin or IDLE, an error dialog comes up: + Microsoft Visual C++ Runtime Library + + Runtime Error! + Program: C:\PROGRAM FILES\PYTHON\PYTHONWIN\PYTHONWIN.EXE + + abnormal program termination Any ideas what's wrong here? -Jim -- Jim Kerr Hewlett-Packard Santa Rosa Systems Division 1400 Fountaingrove Pkwy, MS 3USZ Santa Rosa, CA 95403 From hj_ka at my-dejanews.com Sat Apr 17 21:33:46 1999 From: hj_ka at my-dejanews.com (hj_ka at my-dejanews.com) Date: Sun, 18 Apr 1999 01:33:46 GMT Subject: NT: win32api and win32ui import error Message-ID: <7fbcpq$2jb$1@nnrp1.dejanews.com> Help! I have previously used win32api and win32ui in Windows 95 without problem. However, I have now installed Python 1.5.2 and Pythonwin 124 (win32all-124.exe) on a brand new Windows NT machine, and I get errors when importing win32api or win32ui: >>> import win32api "exceptions.ImportError: DLL load failed: The process cannot access the file because it is being used by another process." The problem is confined to Windows NT only. Windows 95 and Windows 98 have no problem. --------------- I don't know whether this is also related: when I installed win32all-124.exe, I got a few warnings: "Registration of the (AXScript/Python Interpreter/Python Dictionary) failed. Installation will continue, but this server will require manual registration before it will function." regards, Hung Jung -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From alexandre.ferrieux at cnet.francetelecom.fr Thu Apr 22 04:23:04 1999 From: alexandre.ferrieux at cnet.francetelecom.fr (Alexandre Ferrieux) Date: Thu, 22 Apr 1999 10:23:04 +0200 Subject: Kosovo database; Python speed References: <371DAAC2.D9046550@cs.utwente.nl> <371DB466.32097FE5@pop.vet.uu.nl> <7flalp$n10$1@nnrp1.dejanews.com> Message-ID: <371EDC68.38E1@cnet.francetelecom.fr> aaron_watters at my-dejanews.com wrote: > > It also depends on what you expect the queries to be. For this > kind of problem "grep" might work pretty well, actually. Seconded. Next step being 'glimpse'. -Alex From dfan at harmonixmusic.com Wed Apr 21 12:18:16 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 21 Apr 1999 12:18:16 -0400 Subject: problem running 1.5.2 on Win95 References: <371DF4C6.C1276E96@sr.hp.com> Message-ID: Jim Kerr writes: | Hello, | | I tried installing the 1.5.2 binaries on my Win95b machine, | and the results weren't happy. | | I opted to install both Python and Tcl/Tk, and the process | seemed to go smoothly. Since there were no warnings to the | contrary, I installed on top of my existing 1.5.1 files. | | The problem is, when I try to run PythonWin or IDLE, an | error dialog comes up: | | | + Microsoft Visual C++ Runtime Library | + | + Runtime Error! | + Program: C:\PROGRAM FILES\PYTHON\PYTHONWIN\PYTHONWIN.EXE | + | + abnormal program termination | | | Any ideas what's wrong here? This happened to me too (I also installed 1.5.2 on top of 1.5.1). Then I de-installed 1.5.1, and re-installed 1.5.2 from scratch, and everything worked fine. I think I had neglected to install the 1.5.2 version of win32all. I wouldn't be surprised if your problem were the same. In any case, doing a clean install is safest. -- Dan Schmidt -> dfan at harmonixmusic.com, dfan at alum.mit.edu Honest Bob & the http://www2.thecia.net/users/dfan/ Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/ Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/ From dfan at harmonixmusic.com Tue Apr 27 09:39:00 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 27 Apr 1999 09:39:00 -0400 Subject: Designing Large Systems with Python References: Message-ID: David Steuber writes: | One other thing. Is the documentation that comes with Python | sufficient to gain mastery of the language, or should I consider | buying (yet) another book? If you've done a bunch of programming before, the Tutorial in the online docs should serve you well. I recently read through Learning Python and thought it was excellent. One nice thing is that it presents a bunch of the standard modules, which otherwise you have to learn simply by reading the reference. I would recommend either of those as an introduction to the language over Programming Python. You'll want to pick it up at some point (I found its discussion on embedding Python to be very useful, for example), but I found it difficult to learn the language from; the reader is overwhelmed with detail from the very start. -- Dan Schmidt -> dfan at harmonixmusic.com, dfan at alum.mit.edu Honest Bob & the http://www2.thecia.net/users/dfan/ Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/ Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/ From claird at Starbase.NeoSoft.COM Tue Apr 6 13:19:03 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 6 Apr 1999 12:19:03 -0500 Subject: Understanding Tk References: <7eabbe$pbu$1@Starbase.NeoSoft.COM> Message-ID: <7edfm7$19u$1@Starbase.NeoSoft.COM> In article <7eabbe$pbu$1 at Starbase.NeoSoft.COM>, I exhorted: >Are you in the position of explaining Tk(inter) to others, or >simply want to understand it better for yourself? The PerlTk . [complicated URL; my one-sentence synopsis of Tk; and so on] . . A gentle correspondent pointed out that my language in this article was indistinguishable from that of mass marketers. That was *not* my aim. Here's what I have to say: 1. comp.lang.perl.tk has recently discussed Nancy Walsh's *Learning Perl/Tk* book. This thread interests me. I think the testimony of some of its readers bears weight for subjects well beyond PerlTk. First, much of what's said about PerlTk applies immediately to Tk, Tkinter, SchemeTk, ... Beyond that, several of the remarks on style, tone, and approach is pertinent to anyone aiming to teach any scripting language or extension. Therefore, I commend this thread to the attention of everyone writing references or documents or tutorials. The URL I gave looks ugly because I haven't yet figured out a better one. DejaNews made yet another cursed change in its syntax, and it's now painful to direct readers to an appropriate view of a thread. 2. Lots of Tk is common to any WIMP system or toolkit ("design interface carefully ... mouse ... blah-blah ..."). People *really* start to enjoy and benefit from Tk (PerlTk, Tkinter, ...), though, when they "get" a few key ideas. It's impor- tant to think deeply about what makes Tk special. I hope book authors do this. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From tim_one at email.msn.com Sat Apr 10 20:44:03 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 11 Apr 1999 00:44:03 GMT Subject: 1.5.2c1 will not compile on Windows NT SP4 with VC++ 6.0 SP1 In-Reply-To: <923765974.19722.0.nnrp-03.9e982a40@news.demon.co.uk> References: <923765974.19722.0.nnrp-03.9e982a40@news.demon.co.uk> Message-ID: <000001be83b4$65c95d80$7fa22299@tim> [Barry Scott, reports several weird problems trying to build 1.5.2c1 under VC 6 on NT] Barry, you didn't say how you *started* your build, but I suspect you followed the instructions in PC\readme.txt without reading the first paragraph: (NOTE: the project files for MS VC++ 5.x are now in the PCbuild directory. See the file readme.txt there for instructions.) If so, throw out everything you did, and start over in the PCbuild directory, where a full-blown .dsw file awaits your building pleasure. Had no problems building either release or debug Pythons starting from there, under Win95 using VC 5. I doubt VC 6 or NT have anything to do with what you're seeing, since e.g. the reopmodule.c you report a complaint about is mentioned only in the PC directory, not in the (correct) PCbuild directory. Note: I did not attempt to build _tkinter. i-try-to-be-helpful-but-ain't-masochistic-ly y'rs - tim PS to Guido: A fellow at work tripped over much the same thing when building one of the 1.5.2bx releases. I figured the odds of somebody else skipping over the first paragraph of the PC readme too were so slim that it wasn't worth reporting. The problem may be that an experienced Windows-head decides to start partying the instant they see the PC\vc40.mak file (which, I believe, tries to do all the obsolete stuff Barry reported)! From bwinton at tor.dhs.org Sun Apr 18 18:47:40 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Sun, 18 Apr 1999 22:47:40 GMT Subject: Why no "=" in if? (was Re: Quick fix to add "+=") References: <3717EE20.41343593@mediaone.net> <000701be888f$12fe2920$ee9e2299@tim> Message-ID: On Sat, 17 Apr 1999 14:30:04 GMT, Aahz Maruch wrote: >In article , >John W. Baxter wrote: >>In article , aahz at netcom.com (Aahz Maruch) wrote: >>> >>> Why doesn't Guido get off his duff and fix this?????????! >> >>Because it's not broken. > >Yes, it is. Hitler! Hitler! Hitler! You're all Hitler! Later, Blake. From nospam at take.it Thu Apr 8 14:55:06 1999 From: nospam at take.it (Salmaso Raffaele) Date: Thu, 08 Apr 1999 18:55:06 GMT Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <37009C12.4C0E6B0B@earth.ox.ac.uk> <922837384snz@vision25.demon.co.uk> <7dtbu1$rpn$1@nnrp1.dejanews.com> <37025110.1BA742B@appliedbiometrics.com> Message-ID: <370cfb74.23483@194.247.160.50> On 4 Apr 1999 17:45:54 GMT, warlock at eskimo.com (Jim Richardson) wrote: If it can help (I use it to print almost everythings). #!/bin/sh case $1 in # quarta e prima f) psbook $2 | mpage -bA4 -o -2 -dp | psselect -o -r | lpr ;; # seconda e terza r) psbook $2 | mpage -bA4 -o -2 -dp | psselect -e | lpr ;; # comando errato *) cat << EOF libretto (c) 1999 Salmaso Raffaele usage: libretto f/r file.ps f print even page r print odd page EOF ;; esac -- (o- T | Unix is simple and coherent , but it takes a genius to understand //\ U | and appreciate its simplicity . V_/_ X | Dennis Ritchie . email: r.salmaso (at) flashnet.it | salmaso.raffaele (at) iname.com From Robert.Meegan at wcom.com Tue Apr 27 08:55:40 1999 From: Robert.Meegan at wcom.com (Robert Meegan) Date: Tue, 27 Apr 1999 12:55:40 GMT Subject: help In-Reply-To: <37257B0A.AF4C8E4C@pop.vet.uu.nl> References: <37257B0A.AF4C8E4C@pop.vet.uu.nl> Message-ID: I've become known for appending a lengthy appendix to each design document that explains what Python is and why averyone should be using it. So far I've made a number of converts. All it takes is an experienced coder with an open mind and *pow* they're hooked. --- Robert -------------------------------- Robert Meegan MCIWorldCom - Cedar Rapids, Iowa 319.375.2416 From William.H.Duquette at jpl.nasa.gov Wed Apr 28 18:23:00 1999 From: William.H.Duquette at jpl.nasa.gov (William H. Duquette) Date: Wed, 28 Apr 1999 22:23:00 GMT Subject: try vs. has_key() References: <37247ea3.494305@news.jpl.nasa.gov> Message-ID: <372789d8.27766891@news.jpl.nasa.gov> On Wed, 28 Apr 1999 14:58:13 GMT, William.H.Duquette at jpl.nasa.gov (William H. Duquette) wrote: >>>> d = {} >>>> a = 'Foo' >>>> d[a] = d.get(a, []).append('Bar') >>>> d >{'Foo': None} >>>> > >I'd have expected to see {'Foo': 'Bar'}, but that's not what I get. As someone pointed out, append() returns None, explaining the result I got. However, the following code works just fine: d = {} a = 'foo' # Append an entry to d[a], whether it has been initialized or not: d[a] = d.get(a, []) d[a].append('Bar') Will -------------------------------------------------------------------------- Will Duquette, JPL | William.H.Duquette at jpl.nasa.gov But I speak only | http://eis.jpl.nasa.gov/~will (JPL Use Only) for myself. | It's amazing what you can do with the right tools. From philh at vision25.demon.co.uk Thu Apr 29 21:47:12 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Fri, 30 Apr 99 01:47:12 GMT Subject: while (a=b()) ... References: <19990430000141.A5867@shalott> Message-ID: <925436832snz@vision25.demon.co.uk> In article <19990430000141.A5867 at shalott> m.mariani at imola.nettuno.it "Marco Mariani" writes: > Hi all language lawyers! > > Which one is more ugly? > ===== > c = curs.fetchone() > while c: > print c > c = curs.fetchone() > ===== > while 1: > c = curs.fetchone() > if c: > print c > else: > break > ===== > > Is there an elegant way? How about: while 1: c = curs.fetchone() if not c: break print c > while curs.fetchone() > print $_ This would mean nothing to me if I hadn't already seen the python examples -- it is very obscure. -- Phil Hunt....philh at vision25.demon.co.uk From aahz at netcom.com Mon Apr 26 21:50:51 1999 From: aahz at netcom.com (Aahz Maruch) Date: Tue, 27 Apr 1999 01:50:51 GMT Subject: HELP - FTP seesions using python???????? References: <7g328l$hga$1@nnrp1.dejanews.com> Message-ID: In article <7g328l$hga$1 at nnrp1.dejanews.com>, wrote: > >any links or tips etc on how to tackle automation of FTP sessions using python >would be most appreciated. Here's a sample; there aren't any comments (proof that Python can be almost as obscure as Perl ;-), but it shouldn't be *that* hard to read: #!/usr/local/bin/python import sys, os, ftplib, string def getpass(prompt = "Password: "): import termios, TERMIOS, sys fd = sys.stdin.fileno() old = termios.tcgetattr(fd) new = termios.tcgetattr(fd) new[3] = new[3] & ~TERMIOS.ECHO # lflags try: termios.tcsetattr(fd, TERMIOS.TCSADRAIN, new) passwd = raw_input(prompt) finally: termios.tcsetattr(fd, TERMIOS.TCSADRAIN, old) print return passwd if len ( sys.argv ) < 4 : raise 'Must have three arguments: host[:path], user[:passwd], and file' HostPath = sys.argv[1] pos = string.find ( HostPath, ':' ) if pos > 0 : host = HostPath[0:pos] if ( pos + 1 ) == len ( HostPath ) : path = "" else: path = HostPath[(pos+1):] else : host = HostPath path = "" UserPass = sys.argv[2] pos = string.find ( UserPass, ':' ) if pos > 0 : user = UserPass[0:pos] if ( pos + 1 ) == len ( UserPass ) : passwd = "" else: passwd = UserPass[(pos+1):] else : user = UserPass passwd = getpass() filename = sys.argv[3] pos = string.rfind ( filename, '/' ) if pos > 0 : basename = filename[pos:] else : basename = filename fd = open ( filename ) ftp = ftplib.FTP ( host, user, passwd ) ftp.cwd ( path ) ftp.storbinary ( 'STOR %s' % basename, fd, 1024 * 16 ) ftp.close() fd.close() -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Hi! I'm a beta for SigVirus 2000! Copy me into your .sigfile! From bellman at lysator.liu.se Fri Apr 16 12:40:46 1999 From: bellman at lysator.liu.se (Thomas Bellman) Date: 16 Apr 1999 16:40:46 GMT Subject: Bug in Python 1.5.1 (with all patches) on Solaris 7? References: <7f76eh$ijj@news2.newsguy.com> Message-ID: <7f7p6e$mhj$1@newsy.ifm.liu.se> "Fredrik Nehr" writes: > I'm experience different behaivors when running the same instructions as > script and interactively, the interactive behaivor is correct. > Example: > 603 ~ $ cat foo.py > import string > print string.lower('ABC123???') > 604 ~ $ python foo.py > abc123??? > 605 ~ $ python > Python 1.5.1 (#1, Mar 22 1999, 17:07:44) [GCC 2.8.1] on sunos5 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import string > >>> print string.lower('ABC123???') > abc123??? > >>> Your interactive Python probably has readline support, and you have $LC_CTYPE set to iso_8859_1 or something. Readline seems to call setlocale(LC_CTYPE, "") or something when loaded, which makes tolower(), toupper(), and so on, behaving according to your locale settings. If you want that behaviour even without readline, just do import locale locale.setlocale(locale.LC_CTYPE, "") before doing your string manipulations. Locale settings are unfortunately global to the entire process, making it awkward to process text in different languages in different parts of the program. :-( To return to the default behaviour, you should set your locale to "C". -- Thomas Bellman, Lysator Computer Club, Link?ping University, Sweden "This isn't right. This isn't even wrong." ! bellman @ lysator.liu.se -- Wolfgang Pauli ! Make Love -- Nicht Wahr! From clarence at silcom.com Wed Apr 14 12:36:39 1999 From: clarence at silcom.com (Clarence Gardner) Date: Wed, 14 Apr 1999 16:36:39 GMT Subject: forking + stdout = confusion References: <87n20caldg.fsf@spock.localnet.de> Message-ID: Clarence Gardner (clarence at silcom.com) wrote: : However, your first thought also works, with the same caveat about stderr. : stdin, stdout, and stderr all have the __xxx__ copy in the sys module : (which I was not aware of). Mea culpa. The os.close() *is* still necessary. Is there yet another copy of these file objects? I tried to find that function that returns the reference count, but don't see it in the manual. -- -=-=-=-=-=-=-=-= Clarence Gardner AvTel Communications Software Products and Services Division clarence at avtel.com From joe at strout.net Fri Apr 9 13:23:45 1999 From: joe at strout.net (Joe Strout) Date: Fri, 09 Apr 1999 10:23:45 -0700 Subject: Numeric: vector operations? Message-ID: Playing with Numeric today, I noticed an apparent lack of common vector operations, like normalization, vector-length, and cross product. These are fairly easy to code for my own evil purposes, but it's surprising that they're not in there. Am I missing something? Or are they purposefully omitted for some reason (e.g., they only apply to very restricted sorts of matrices whereas other operations are more general)? Thanks, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From jimmyth at my-dejanews.com Mon Apr 26 07:51:01 1999 From: jimmyth at my-dejanews.com (jimmyth at my-dejanews.com) Date: Mon, 26 Apr 1999 11:51:01 GMT Subject: os.exec Message-ID: <7g1jv4$5eh$1@nnrp1.dejanews.com> Is there a way to send the output from a python-spawned external program straight to the script without having to deal with the OS's piping and such? I want to be able to say: bob = get_output_from(os.execv('runme.exe', ('parm1', 'parm2'))) or something to that effect. Thanks, Jimmy -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From jno at glasnet.ru Thu Apr 22 07:42:35 1999 From: jno at glasnet.ru (jno at glasnet.ru) Date: 22 Apr 1999 11:42:35 GMT Subject: ``if t'' vs ``if t is not None'' Message-ID: <7fn1vb$rbo$1@news.glas.net> hi there, i faced a VERY strange behaviour of if-test operation! ``if t'' != ``if t is not None'' where ``t'' is None or a class instance i was writing a threader for a news reader. and found occasional hangs of a routine which builds the sequence of message numbers for "read next" operation. digging deeper brought me strange results: replacing ``if t'' with ``if t is not None'' speeded up the things dramatically! the call contecst: for x in self.keys() : m, t = self.mesg_list[ x ] self.Sequence.append( m.num ) if t is not None : t.buildSequence(i+1) self.Sequence.extend( t.Sequence ) del t.Sequence ; t.Sequence = None # trash extra data can anyone explain me such a phenomenon??? -- SY, [ mailto:jno at glas.apc.org ] jno (PRIVATE PERSON) [ http://www.glasnet.ru/~jno ] a GlasNet techie [ http://www.aviation.ru/ ] If God meant man to fly, He'd have given him more money. From guido at CNRI.Reston.VA.US Tue Apr 6 23:07:42 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Tue, 6 Apr 1999 20:07:42 -0700 (PDT) Subject: fix for posix_fsync under SunOS 4.1.x In-Reply-To: Your message of "Sat, 03 Apr 1999 07:29:50 GMT." <199904030729.XAA24695@igce.igc.org> Message-ID: <199904070307.UAA12597@igce.igc.org> >> Here's a patch to make sure that posix_fsync will compile on all operating >> systems (specifically needed for SunOS 4.1.x). >> >> This unified diff was made against Python 1.5.2 beta 2 . >> >> -scott >> >> --- Modules/posixmodule.c~ Tue Feb 16 11:38:04 1999 >> +++ Modules/posixmodule.c Fri Apr 2 22:18:03 1999 >> @@ -647,6 +647,8 @@ >> "fsync(fildes) -> None\n\ >> force write of file with filedescriptor to disk."; >> >> +extern int fsync(int); /* Prototype just in case */ >> + >> static PyObject * >> posix_fsync(self, args) >> PyObject *self; > >On how many other operating systems have you tried this patch? I have >found that almost invariably when you use an extern declaration of a >standard function that is defined in the system headers on most modern >systems, there's at least one system out there where what they have in >the headers causes a conflict with what you declare! It would be >better if you put it insude an #ifdef specific for the SunOS 4.x >platform. I've only tried it on SunOS 4 and Solaris 2. I originally put my extern inside #ifdef HAVE_UNISTD_H /* XXX These are for SunOS4.1.3 but shouldn't hurt elsewhere */ extern int rename(); extern int pclose(); extern int lstat(); extern int symlink(); #else /* !HAVE_UNISTD_H */ But then I noticed that posix_fdatasync had extern int fdatasync(int); /* Prototype just in case */ static PyObject * posix_fdatasync(self, args) so I did it that way to be "consistent". I don't really know which way is better (or if a third way is needed). -scott From tim_one at email.msn.com Sun Apr 25 22:26:05 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 26 Apr 1999 02:26:05 GMT Subject: Handling backspace chars in a string... In-Reply-To: <3723bd8c.603427371@news2.bga.com> References: <3723bd8c.603427371@news2.bga.com> Message-ID: <000201be8f8c$22f186c0$d5a02299@tim> [Purple] > I didn't post the code for that bit [newlines] as it seems easy enough > to take care of processing those with something like > map(string.strip,string.split(stringWithNewlines,"\n") > > Unless there's a better way to do that too? :) I don't know what you're trying to do. What that code *does* is break the string into chunks as separated by newlines, strips leading and trailing whitespace of all kinds from each resulting chunk, and leaves the result as a list of strings. That doesn't sound like what you *wanted* to do, but if it is I can't think of a better to do that . > ... > [code using lists snipped] > I may well go that route... Is it any slower or faster to do this > using lists rather than counting up the backspaces and slicing around > the bits that need to be snipped? from time import clock How big are the strings? What's the expected distribution of backspaces? Etc. The list code is worst-case linear-time (in practice although not in theory); the string slicing worst-case quadratic (although "acts linear" until strings reach a platform-dependent size). There's no definitive answer to which is faster without a strong characterization of your data. Don't bother telling me, time it . in-the-end-is-it-faster-to-run-or-walk?-yes-ly y'rs - tim From alrice at swcp.com Mon Apr 19 16:17:58 1999 From: alrice at swcp.com (Alex Rice) Date: Mon, 19 Apr 1999 14:17:58 -0600 Subject: Zope question References: <37178D4B.7D933209@swcp.com> Message-ID: <371B8F76.AAAC9C1C@swcp.com> Evan Simpson wrote: > nobody-is-going-to-write-to-*my*-zope/var-ly yrs, > Evan That was it! Thanks. Turns out Apache is configured to run as user "httpd" on this Cobalt. I chown -R httpd *'d and all is well so far. Alex Rice From morse at harborcom.net Thu Apr 15 11:15:29 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Thu, 15 Apr 1999 15:15:29 GMT Subject: Tutorial Python References: <3714BAA0.12F180F3@xs4all.nl> Message-ID: <3716022c.77967200@news.oh.verio.com> It's not a tutorial, but I have a simple DBF cgi search script on: http://www.geocities.com/siliconvalley/peaks/4673/python.html From spamfranke at bigfoot.de Wed Apr 21 07:47:11 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Wed, 21 Apr 1999 11:47:11 GMT Subject: New python user seeks comments References: Message-ID: <371db9cb.5622314@news.omnilink.de> On 21 Apr 1999 00:33:10 -0400, David Steuber wrote: >Er, uh, hmm. > >I wrote my first Python program today. It took longer than I >expected. Who would have guessed that you couldn't give a file object >the name 'in'? Or at least that was one of the weirder obstacles. Maybe a reserved keyword-aware editor could have saved you from this? You could try IDLE, which comes with the lastest Python distribution or PythonWin, if you are using Windows. There's a very clever Python Emacs mode as well... Stefan From Bjoern.Giesler at stud.uni-karlsruhe.de Mon Apr 12 16:02:11 1999 From: Bjoern.Giesler at stud.uni-karlsruhe.de (Bjoern Giesler) Date: Mon, 12 Apr 1999 20:02:11 GMT Subject: Stupid Tkinter question Message-ID: <99041222110400.01382@dominion> Hi, I want to display a button in my application that shows a bitmap (.xbm). I'm going crazy. Why does this fragment work (adapted from imageview.py in Guido's Tkinter demos): [snip] #!/usr/bin/env python from Tkinter import * import sys def main(): filename = sys.argv[1] root = Tk() img = BitmapImage(file=filename) label = Button(root, text=filename, image=img, command=sys.exit) label.pack() root.mainloop() main() [snip] .... but this doesn't: [snip] #!/usr/bin/env python from Tkinter import * from sys import * def makeToolbar(aFrame): toolbar = Frame(aFrame) markimage = BitmapImage(file = "Mark.xbm") markbutton = Button(toolbar, image = markimage, command = exit) markbutton.pack() return toolbar def makeUI(anApp): frame = Frame(anApp) toolbar = makeToolbar(frame) toolbar.pack() frame.pack() app = Tk() makeUI(app) app.mainloop() [snip] As far as I can see, the two are doing exactly the same. The first example displays the bitmap, and the button is clickable, the second displays a button the size of the bitmap, but which has nothing in it, and which isn't clickable. HELP! TIA, --Bjoern PS Python 1.5.1 on Linux, if that is important. -- + thanks for your time, worship the antichrist, and have a nice day /\ +----------------------------------------------------------------- /()\ + support privacy on the 'net: mail me for pgp public key /____\ From aa8vb at vislab.epa.gov Fri Apr 30 08:08:05 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 30 Apr 1999 08:08:05 -0400 Subject: Python IS slow ! [was] Re: Python too slow for real world In-Reply-To: <372965CA.2B3FD2FE@appliedbiometrics.com>; from Christian Tismer on Fri, Apr 30, 1999 at 08:11:54AM +0000 References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <7g9qmo$luf$1@news.udel.edu> <372965CA.2B3FD2FE@appliedbiometrics.com> Message-ID: <19990430080805.B776752@vislab.epa.gov> Christian Tismer: |Terry Reedy wrote: |> A batch-mode optimizer analyzing an entire file (module) should be able to |> detect whether or not function names are rebound. |> |> Perhaps module bindings should be considered immutable from outside the |> module unless explicitly declared otherwise. | |I'm thinking of no new keyword, but a mechanism which allows me to lock a |namespace somehow. I like this idea in concept. Though I would prefer a way to have namespaces "lock by default". Examples: After a class definition, the class function dictionary is locked. After a module is fully read, all references are bound and the module namespace is locked. etc. Randall From boud at rempt.xs4all.nl Wed Apr 28 10:29:19 1999 From: boud at rempt.xs4all.nl (boud at rempt.xs4all.nl) Date: Wed, 28 Apr 1999 14:29:19 GMT Subject: Designing Large Systems with Python References: Message-ID: David Steuber wrote: : : I never heard it being _that_ bad. I am hoping that the modular : nature of Python allows me to throw away the stuff that turns out to : be crap and insert replacement code without a complete re-write. : Mind you, I was talking about a VB-5 project (which also won't compile under VB-6, but that's another issue...), but the general problem is that after your first millionth line you won't be able to guess as to what to throw away, even if you program in Python. On the other hand, after an absence of two weeks I've spent today the whole day in rebuilding my development environment to the point where I could compile code again... That's a problem Python wouldn't have, anyway. And I've never come across problems with corrupted type libraries or the like in Python. : : This is assuming I actually get my but in gear and go ahead with the : project I have in mind. It is a project of the ambitious sort where : the word hubris is a hopelessly inadequate description of my state of : mind in even contemplating the thing. : I don't know anything about Lisp, apart from having gone through 'The Little Lisper', and my adventures with Eiffel have been brief, so I don't know about those, but my feeling is that if you want to start a really big project you need two things: organization and robust wrists... Anyway, I have decided to use Python for my personal projects and whatever it's qualities for multi-million line projects, I'm a happy, productive and creative programmer, no longer plagued by pointer arithmetic and the amount of code I have to type has decreased enormously. So I'd say that whatever you plan, short of a new operating system, go with Python. -- Boudewijn Rempt | www.xs4all.nl/~bsarempt From behrends at cse.msu.edu Thu Apr 29 19:51:39 1999 From: behrends at cse.msu.edu (Reimer Behrends) Date: 29 Apr 1999 23:51:39 GMT Subject: while (a=b()) ... References: <19990430000141.A5867@shalott> Message-ID: Marco Mariani (m.mariani at imola.nettuno.it) wrote: > Hi all language lawyers! > > Which one is more ugly? [...] Both. > Is there an elegant way? while curs.fetchone(): print curs.item Remember that objects have state. Reimer Behrends From aa8vb at vislab.epa.gov Thu Apr 8 07:46:12 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Thu, 8 Apr 1999 11:46:12 GMT Subject: Python x-windows GUI example needed In-Reply-To: <7eg741$5t1$2@news.inet.tele.dk>; from Lone H. og Lars G. on Wed, Apr 07, 1999 at 08:12:27PM +0200 References: <7eg741$5t1$2@news.inet.tele.dk> Message-ID: <19990408074612.A983383@vislab.epa.gov> Lone H. og Lars G.: |To get started with phyton x-windows GUI programming I would appreciate any |code examples or references. By x-windows programming do you mean: 1) Conventional Xlib/Xt/ programming? OR 2) Use of any GUI toolkit system that will display on an X/Windows display server? If the latter, check out: http://www.python.org/topics/tkinter/doc.html for some links to Tkinter, Python's defacto GUI standard. This is but one of the GUI development toolkits supported in Python. (If you aren't tied to Xlib/Xt/..., I wouldn't recommend using it unless you need to. Lots of flexibility, but it's the assembly language of X GUI development.) Randall From bgue at my-dejanews.com Sun Apr 4 16:18:10 1999 From: bgue at my-dejanews.com (bgue at my-dejanews.com) Date: Sun, 04 Apr 1999 20:18:10 GMT Subject: plea for kjbuckets for pywin Message-ID: <7e8hds$5i7$1@nnrp1.dejanews.com> Has anybody compiled kjbuckets against Pywin 1.5 or 1.5.1, and if so, could I trouble you for a copy? I lack a compiler on my Windows partition. Thanks, Brian -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From antrobus at innocent.com Thu Apr 8 02:04:14 1999 From: antrobus at innocent.com (Greg) Date: Thu, 08 Apr 1999 06:04:14 GMT Subject: mxDateTime in Python distribution References: <19990406070255.A867135@vislab.epa.gov> <19990406082704.A868024@vislab.epa.gov> <370A0485.EC244CF6@pop.vet.uu.nl> Message-ID: <7ehgss$jfj$1@nnrp1.dejanews.com> I agree with the original poster. mxDateTime is *essential* and should be intergrated into Python. I don't even care about all the nice features and functions of mxDateTime; it's just completely insane being stuck with the C library's unix epoch limitation... ouch. And it's VERY necessary for the DBAPI as well... -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From illume at gmx.net Tue Apr 20 00:56:11 1999 From: illume at gmx.net (Paul Kunysch) Date: 20 Apr 1999 06:56:11 +0200 Subject: bzip2 module for Python References: <2fbf63f548.tratt@tratt.freeserve.co.uk> Message-ID: <87zp43gaac.fsf@illusion.tui-net> Laurence Tratt writes: > As I said, I am interested to know if there is a demand for this, so > comments are appreciated. IMHO it would be nice to have a module like the current "gzip", which handles .bz2 .gz .Z and uncompressed files transparently. Bye From MHammond at skippinet.com.au Wed Apr 7 18:54:12 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 8 Apr 1999 08:54:12 +1000 Subject: COM Event Sinks and Connection Points in Python References: <7eggfh$o0f$1@nnrp1.dejanews.com> Message-ID: <7egnl2$ca5$1@m2.c2.telstra-mm.net.au> cingram at my-dejanews.com wrote in message <7eggfh$o0f$1 at nnrp1.dejanews.com>... >I am trying to use functionality from a DLL that requires me to create a COM >event sink so that it can call back with events. I am trying to write this >event sink in Python. However, when I try to create a SimpleConnection >object, it gives this exception: "Unable to open the access token of the >current thread". There appears to be some problem using connection points from Python.exe. Some objects - mainly OCX controls - only fire event when running inside Pythonwin as an OCX. The "threading bug" I mention isnt the same as this. The threading bug will actually cause Python to die completely with an access violation. I am fairly certain they are not related. Events seem a black art. Im happy to help you track this down, but I havent much time... Mark. From hyoon at bigfoot.com Thu Apr 15 08:58:18 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Thu, 15 Apr 1999 08:58:18 -0400 Subject: Q about OCXtest.py example Message-ID: <3715E26A.F17BA8BD@bigfoot.com> Thanks to Mark. I think I am getting hang of COM. I finally got this example, but one more Q. Let's say I have two controls either 2 calendar or 1 calendar & 1 timer for instance. I guess doing it the second one will be easy, I will just have to inherit one more control in class MyCal(activex.Control, calendarParentModule.Calendar, timerParentModule.timer): and just specify the Ondefs; however, what do I do when I have 2 controls same controls on the dialog or inherited Ondefs have same name? Do someone have some example they don't mind sharing? --------------------------------------------------------- def GetTestCalendarClass(): global calendarParentModule win32ui.DoWaitCursor(1) calendarParentModule = gencache.EnsureModule("{8E27C92E-1264-101C-8A2F-040224009C02}", 0, 7, 0) win32ui.DoWaitCursor(0) if calendarParentModule is None: return None class TestCalDialog(dialog.Dialog): def OnInitDialog(self): class MyCal(activex.Control, calendarParentModule.Calendar): # <---------********* def OnAfterUpdate(self): print "OnAfterUpdate" -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From wtanksle at dolphin.openprojects.net Thu Apr 22 19:15:11 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 22 Apr 1999 23:15:11 GMT Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> Message-ID: On Fri, 23 Apr 1999 06:08:07 +0900, Thooney Millennier wrote: >Hello Everyone! Hi! >I usually use C++ ,so I want to make programs like >I do using C++. Bad idea. How many other languages do you know? If you only know C++, you're now privledged to learn a second language. Part of that is learning that Good Ideas in one language are Bad Ideas in another. >I don't figure out how to implement the followings >by Python. Okay... >If you know any solutions,Please Help! >1. #define statements > e.g. #define __PYTHON_INCLUDED__ Meaningless in Python. A bad idea in C++, except for #include control (which isn't needed in Python). > #define PYPROC(ARG) printf("%s",ARG) A very bad idea in C++ -- you're supposed to use inline templatized functions. In Python, just define a function: def PYPROC(ARG): sys.stdout.write(ARG) >2. stream class > e.g. cout << "hello python."<3. const variables > e.g. const int NOCHAGE=1; Mediocre idea in C++. Not possible in Python, because in Python variables aren't supposed to be typed in any way -- instead, they hold things which are typed. Why is it only a mediocre idea in C++? Because a constant is part of an interface, and a free constant is as bad as a free function; it pollutes the global namespace. In proper C++, your const will be contained inside a class (probably static) to keep it out of the global namespace. In proper Python, your const will also be contained inside a class -- and __setattr__ will be redefined to disallow changing any values. class __myConsts: NOCHAGE = 1 SOMECHAGE = 2 # now make sure nobody can hack my values... def __setattrs__(self,attrname,value): raise "can't modify my constants!" consts = __myConsts() Now, after you import this module, you can access all your constants through expressions such as consts.NOCHAGE, but you can't change them. Well, not quite. It turns out that you CAN change them, but only like this: __myConsts.NOCHAGE = 2 ...and that only works from within the same file (because names beginning with underscores are private), so it's probably what you wanted anyhow (more like Java's 'final' keyword). >4. access to class's members using "::" > e.g. some_class::static_value > e.g. some_class::static_func(x) In Python, "." works for ALL object access. Pointers, class variables, and so on don't matter. To be fair, I think this isn't a bad part of C++; :: notation makes some things more clear. But Python isn't C++. >Thanks for reading. Good luck. >Thooney Millennier. -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From phd at sun.med.ru Wed Apr 14 04:04:35 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Wed, 14 Apr 1999 08:04:35 GMT Subject: real time scheduler In-Reply-To: <3713AE36.A1EA255B@arlut.utexas.edu> References: <3713AE36.A1EA255B@arlut.utexas.edu> Message-ID: On Tue, 13 Apr 1999, Bryan VanDeVen wrote: > Is there a module for scheduling events in real time? I have events > that need to be repeated indefinitely, each at a given time period. The > periods are large (at least one minute) and precision requirements are > not that great (within a few seconds). Is anyone aware of code to do > this? I saw EventLoop module somewhere on ftp.python.org (or was it Contributer.html?) Pretty simple, but may be adequate. > -- > Bryan Van de Ven > Applied Research Labs > University of Texas, Austin > Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From MHammond at skippinet.com.au Thu Apr 29 19:56:07 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 30 Apr 1999 09:56:07 +1000 Subject: How to read stdin while debuggingin PythonWin References: <7g9utu$kin$1@nnrp1.dejanews.com> Message-ID: <7garhi$hqi$1@m2.c2.telstra-mm.net.au> he he - this is broken. Pythonwin does not provide a valid stdin (like it does for stdout and stderr). However, if you use input or raw_input, a dialog will be displayed. Im not sure why this would be different under the debugger, but when I try that from the Pythonwin window I get: >>> sys.stdin.read() Traceback (innermost last): File "", line 0, in ? IOError: [Errno 9] Bad file descriptor >>> Which is what I expect. Mark. From thooney at pk.highway.ne.jp Wed Apr 14 14:50:48 1999 From: thooney at pk.highway.ne.jp (Thooney Millennier) Date: Thu, 15 Apr 1999 03:50:48 +0900 Subject: python interface to c++ class Message-ID: <3714E388.CD434E8A@pk.highway.ne.jp> Hello, everyone. I am now working on building Python interface to my C++ matrix library. for example In C++,we can enjoy following operations. (f_matrix: matrix class for float, d_matrix: for double) 1. f_matrix x1,x2; float y; x2=y*x1; (operation between different types) 2. x1(1,2)=3.4; (substitution for matrix element) 3. d_matrix z; z=x1; (auto conversion from float matrix to another type(d_matrix)) Is it possible by "PyNumberMethods" ? I would like to know how to implement above with Python. Thanks for reading. Thooney Millennier. From bwarsaw at cnri.reston.va.us Wed Apr 28 00:11:40 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: 28 Apr 1999 00:11:40 -0400 Subject: help References: Message-ID: <61lnfdjseb.fsf@anthem.cnri.reston.va.us> >>>>> "MZ" == Moshe Zadka writes: MZ> Don't we all know that feeling? Fortunately, we don't have that problem too much around here :-) From guido at CNRI.Reston.VA.US Mon Apr 19 13:31:26 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Mon, 19 Apr 1999 17:31:26 GMT Subject: Memory and swapping question In-Reply-To: Your message of "Mon, 19 Apr 1999 18:50:33 +0200." <371B5ED8.A9C82170@appliedbiometrics.com> References: <371B5ED8.A9C82170@appliedbiometrics.com> Message-ID: <199904191731.NAA03862@eric.cnri.reston.va.us> > Now, create a list of numbers with the half of big, > and count the seconds. Afterwards, delete the list > and again count the seconds. > > >>> x=range(big/2) > >>> del x > >>> > > This will be quite fast, and the deletion will be somewhat > faster than the creation. > > Now for the big WHY? > Do the same with big. > > >>> x=range(big) > >>> del x > >>> > > On my system, creation takes about 10 times as for big/2, > this is ok. But the del takes at least three times as long. > Besides the fact that integers are never really disposed but > build up a freelist, why is deletion so much slower now? Clearly in the second case you're exceeding your physical memory and paging VM pages in and out of swap space? My guess: when creating the list you are allocating new VM pages, which don't require any overhead until they need to be written, but when deleting it, each page gets read from swap space, modified, and then written back. Thus, you're I/O bound, and deleting requires more I/O. --Guido van Rossum (home page: http://www.python.org/~guido/) From tim_one at email.msn.com Tue Apr 27 23:48:59 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 27 Apr 1999 23:48:59 -0400 Subject: SMTPLIB accessing MicroSoft SMTP mail server In-Reply-To: <7g5o9g$ues$1@nnrp1.dejanews.com> Message-ID: <000701be912a$0cf52940$29a02299@tim> [max at rightworks.com] > I had reported a problem that when sending mail to a MS SMTP > server my code was hanging. The fix is in the data() method the > msg text is terminated by sending "\n.\n" It appears that MicroSoft > requires a full CRLF. By changing the line from self.send("\n.\n") > to self.send(CRLF+"."+CRLF) problem is fixed. Aha! This msg crossed with my reply to c.l.py. As that reply suggested-- but as you no longer need to know --this is already fixed in 1.5.2. upgrade!-ly y'rs - tim From morse at harborcom.net Tue Apr 6 07:39:03 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Tue, 06 Apr 1999 11:39:03 GMT Subject: swig or not to swig ? References: <4p6O2.1348$8m5.2126@newsr1.twcny.rr.com> Message-ID: <3709f149.2262513@news.oh.verio.com> >Didn't have much luck with bgen. >modulator seems handy, Is there a reason to prefer swig ? Ahh, because it works really well? :) Seriously, depending on the library, it can make creating wrappers trivial. It can do most of the work itself, you just have to help it with ambiguos parameters - like int * refererring to a list of ints or something. Python is very well documented on the swig site. Give it a shot. Having said that. I would guess - not having used modulator - that a reason not to prefer swig is that you need to compile a shared module. does the modulator produce a pure python source result? From mal at lemburg.com Mon Apr 26 14:59:21 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 26 Apr 1999 20:59:21 +0200 Subject: I need test .py files References: <37249009.AA2B13CA@abo.fi> Message-ID: <3724B789.C514B05@lemburg.com> Raul Parra Bacete FS wrote: > > Hi, > > I have ported the python interpreter to the sh1 hitachi, and now I would > like to get .py programs to test my python interpreter... that programs > should not have any import statment or any reference to files, so I need > some BASIC .py programs to test my python The scripts in Lib/test/ of the Python source distribution are intended to be a relatively complete test suite for the interpreter and many of the standard libs modules. See Lib/test/regrtest.py for details on how to run the suite. -- Marc-Andre Lemburg Y2000: 249 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From MHammond at skippinet.com.au Tue Apr 13 19:44:13 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 14 Apr 1999 09:44:13 +1000 Subject: Help? Newbie COM Question References: <7evmck$2en$1@nnrp1.dejanews.com> Message-ID: <7f0kqs$bv6$1@m2.c2.telstra-mm.net.au> There are a number of ways: * PythonCOM/Pythonwin comes with a clunky OLE Viewer you could use. * VB, VC or VJ object viewers can still be used. * If you use makepy (check out the documentation that comes with the package) you can read the generated source code. * You can find a freeware or shareware object viewer. * (You could help make the pythoncom object viewer less clunky :-) Mark. ranjan.bagchi at pobox.com wrote in message <7evmck$2en$1 at nnrp1.dejanews.com>... >Hi -- > >I'm checking Python out for automating COM objects and fast GUI development. >The COM objects in question are developed in VisualJ++, and in other COM >enviromments (tcl with the tcom package), I can get lists of methods and >properties offered by the object. > >Is there an easy way to do this in WinPython? From gemodek at t-online.de Thu Apr 29 10:57:45 1999 From: gemodek at t-online.de (gemodek) Date: Thu, 29 Apr 1999 16:57:45 +0200 Subject: Read MS Access 97 *.mdb files with python?? Message-ID: <37287369.D6E67313@t-online.de> Does somebody know some piece of soft which can this?? Or does somebody know if the description of the format ia avaible (for free of course). Thanks Stephan From astro at nospam.tne.net.au Sun Apr 25 23:11:13 1999 From: astro at nospam.tne.net.au (Tim Auld) Date: Mon, 26 Apr 1999 12:41:13 +0930 Subject: Using Python for Modular Artificial Intelligence code Message-ID: Hi all, I've been designing a large game project, and I want it to be easily extensible. It's a space combat/exploration/trade game, in the spirit of the original Elite. What I want to be able to do is add new units to the game while the player is in the middle of a game that has lasted weeks (or any arbitrary length of time) already. I've started looking into Python as the AI scripting language for this purpose, but I'm having trouble seeing exactly how I could do this. I want a message passing architecture - so one object in the game world sends a message to another for interpretation (along with a Python tuple for the parameters of the message perhaps). This requires a two way interface between my C++ code and the Python script loaded for the particular game object. My question is, how can I load the Python script, let my C++ object call functions within the Python script, and provide a callback for the Python script to call methods in the C++ object? Thanks, Tim ________________________ astro at tne.net.au tim at ratbaggames.com From cgw at fnal.gov Tue Apr 20 13:40:04 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Tue, 20 Apr 1999 17:40:04 GMT Subject: Tkinter hangs in Emacs in 1.5.2 on Win32 In-Reply-To: <371ca96f.0@nnrp1.news.uk.psi.net> References: <371ca96f.0@nnrp1.news.uk.psi.net> Message-ID: <14108.48116.801905.475712@buffalo.fnal.gov> Pat Knight writes: > I often prototype fragments of Tkinter code using the interactive Python mode > in NT emacs. Since installing 1.5.2 the interpreter hangs when run > interactively inside Emacs. Do you have the latest version of python-mode.el? Do you have "py-python-command-args" set to ("-i") ? You might also try a setting of ("-i" "-u") if that doesn't work From fmwang at mediaone.net Fri Apr 16 22:12:48 1999 From: fmwang at mediaone.net (Fuming Wang) Date: Fri, 16 Apr 1999 22:12:48 -0400 Subject: Quick fix to add "+=" References: <3717AB14.2926AF76@mediaone.net> Message-ID: <3717EE20.41343593@mediaone.net> I have searched dejanews. They don't like the "+=" characters. Could you be more specific about how to modify the interpreter? I desperate here.:) Thanks, Fuming Blake Winton wrote: > > On Fri, 16 Apr 1999 17:26:44 -0400, Fuming Wang wrote: > >Any one knows a quick fix to add "+=" function. I am really getting > >tired of typing long names twice. > > Heh. I can't wait to see the other replies... :) > > += has been left out of the language for a good reason, and thus it's > probably not likely that there's an easy way to add it. I think you > will have to recompile the interpreter to get it to do what you want, > and even then, I don't think that you really want what it would do. > > Surely there's some discussion about += in dejanews which would provide > more enlightenment that I can. > > Later, > Blake. From trashcan at david-steuber.com Wed Apr 28 03:36:58 1999 From: trashcan at david-steuber.com (David Steuber) Date: 28 Apr 1999 03:36:58 -0400 Subject: Designing Large Systems with Python References: Message-ID: boud at rempt.xs4all.nl writes: -> Then suddenly, the whole blasted !@#$%^&* was more than ten million -> lines, more than hundred dll's, numerous OCX'es, and countless forms, -> all built by twenty to thirty novices in the art of programming, of whom -> fifteen had left the company. It's more than painful or embarrasing... -> And it's not the first time I've seen that happen. Sorry for the rant - -> I just had to get it of my chest. I don't think Python really insures -> you against these mistakes. I never heard it being _that_ bad. I am hoping that the modular nature of Python allows me to throw away the stuff that turns out to be crap and insert replacement code without a complete re-write. This is assuming I actually get my but in gear and go ahead with the project I have in mind. It is a project of the ambitious sort where the word hubris is a hopelessly inadequate description of my state of mind in even contemplating the thing. -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. Review Questions (1) If Nerd on the planet Nutley starts out in his spaceship at 20 KPH, and his speed doubles every 3.2 seconds, how long will it be before he exceeds the speed of light? How long will it be before the Galactic Patrol picks up the pieces of his spaceship? (2) If Roger Rowdy wrecks his car every week, and each week he breaks twice as many bones as before, how long will it be before he breaks every bone in his body? How long will it be before they cut off his insurance? Where does he get a new car every week? (3) If Johnson drinks one beer the first hour (slow start), four beers the next hour, nine beers the next, etc., and stacks the cans in a pyramid, how soon will Johnson's pyramid be larger than King Tut's? When will it fall on him? Will he notice? From phd at sun.med.ru Tue Apr 27 12:00:27 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Tue, 27 Apr 1999 20:00:27 +0400 (MSD) Subject: Directories In-Reply-To: <3725DDD2.149DF47F@geocities.com> Message-ID: On Tue, 27 Apr 1999 smoothasice at geocities.com wrote: > Hi, i'm curious if there is a python command or set of commaneds that > could be used like the dir() command in dos prompt. I am trying to > write a program in python that would allow me to list the files of a > certain data type in a few directories but I need to know how I would do > that ...thanks a bundle. fnmatch standard module pretty good on it. Full listsing could also be generated by os.listdir(). > Anton Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From phd at sun.med.ru Mon Apr 26 03:38:50 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Mon, 26 Apr 1999 11:38:50 +0400 (MSD) Subject: timeout on urllib.urlopen? In-Reply-To: <7g0r7c$gn9$1@nnrp1.dejanews.com> Message-ID: Hello! On Mon, 26 Apr 1999, Kevin L wrote: > I'm trying to use urllib.urlopen() on a big list of urls, some of which are > dead (they don't return a 404, just no response). And the function just waits. > Is there any way to specify a timeout period for this function? thanks, this is well-known problem with sockets. No, there is no simple way to specify timeout. You should rewrite your program to use either fork() or threads. One thread (or parent process, if you use fork()) controlls another, and after timeout kill watching thread/process. Recently I rewrote my URL checker to use fork() (the very checker is under debuggung and soon to be published). > Kevin Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From MHammond at skippinet.com.au Mon Apr 19 19:23:27 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 20 Apr 1999 09:23:27 +1000 Subject: 'import exceptions' failed References: <371B1201.392B@iname.com> Message-ID: <7fgdrm$8rc$1@m2.c2.telstra-mm.net.au> You are obviously investing serious time with Python, so you should try and go to the next level. Compile the whole shabang with Debugging symbols, and work it out :-) The biggest advantage is that it will give you a good understanding of the internals, making many of these questions suddenly become either obvious or moot. For example, you ask how to turn "-v" on from the API - simple - go to the Python sources, work out how it does -v, then do the same thing! Should be easy to find. Similarly with the path issue. Set a breakpoint where Python is about to start building your sys.path. Step through it, and understand exactly why it is building a sys.path that does not include the directory where your "exceptions.py" and "site.py" live. The answer will then be obvious (even though I have no idea what it is :-) Hope this helps, even if it points to a slightly longer, but far more beneficial road. Mark. BTW - what editor control are you using? - I happen to know this guy who has written a really cool free one that Pythonwin now uses - Ive got some big plans :-) Jussi Jumppanen wrote in message <371B1201.392B at iname.com>... >I have compiled the python source into a Windows DLL and using >this DLL I have embedd python into and windows text editor. Now >when I run the following macro script: From gmcm at hypernet.com Mon Apr 19 23:57:28 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 20 Apr 1999 03:57:28 GMT Subject: calldll windll instantiation In-Reply-To: <371bdcbf.0@news.dbtech.net> References: <371bdcbf.0@news.dbtech.net> Message-ID: <1287541642-22552898@hypernet.com> Karl & Mel ask: > Need some help. > I think?(scarry moment)? that I need to create more that one > instance of a dll. > > 1. Can this be done? Nope. Perhaps if you made a second copy (of the dll file) and gave it a different name. Or perhaps the dll uses thread local storage, and if you attach from different threads it will act like each thread has its own copy. But I doubt it. Different processes will get different copies, so maybe you could use IPC between 2 python scripts... - Gordon From akuchlin at cnri.reston.va.us Mon Apr 26 15:36:49 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Mon, 26 Apr 1999 15:36:49 -0400 (EDT) Subject: Using the compression module In-Reply-To: <7g2ddf$dra$1@birch.prod.itd.earthlink.net> References: <7g2ddf$dra$1@birch.prod.itd.earthlink.net> Message-ID: <14116.48932.822574.914523@amarok.cnri.reston.va.us> Benjamin Derstine writes: >From the gzip documentation: >open (fileobj[, filename[, mode[, compresslevel]]]) > Returns a new GzipFile object on top of fileobj, which can be a regular >file, a StringIO object, or any object which simulates a file. Are you sure that's what the documentation says? The current documentation has filename, mode, compresslevel, fileobj, which matches the code. Check the current documentation on www.python.org/doc/lib/ . >f=open('/Audit.dbf','r') >test=gzip.GzipFile('Auditc','r','9',f) The first line opens Audit.dbf for reading. However, if you want to make a compressed version of it, the second line is wrong; it's trying to make a compressed file object from the uncompressed /Audit.dbf. Instead, you need to open a compressed file for writing: f=open('/Audit.dbf','r') test=gzip.GzipFile('Auditc', 'w') test.write() will then write data to the compressed file, so you need a loop to copy between the two files: while 1: chunk = f.read(4096) # Work in chunks of 4K if chunk == "": break # End-of-file? Break out of the loop test.write( chunk ) f.close() test.close() -- A.M. Kuchling http://starship.python.net/crew/amk/ I had known him for years in a casual way, but I had never seen very deeply into him. He seemed to me to have more conscience than is good for any man. A powerful conscience and no sense of humour -- a dangerous combination. -- Robertson Davies, _The Rebel Angels_ From tbryan at zarlut.utexas.edu Sun Apr 25 21:50:47 1999 From: tbryan at zarlut.utexas.edu (Tom Bryan) Date: Sun, 25 Apr 1999 20:50:47 -0500 Subject: perl v python References: <37238A6A.E245337D@btinternet.com> Message-ID: <3723C677.7A6DB767@zarlut.utexas.edu> "Mark E. Owen" wrote: > > I've been using perl quite some time, just starting looking > at Python. > > what's peoples views/comparisons of both languages? > > Cheers > Mark This comes up often. You can probably find scores of responses if you do a PowerSearch of comp.lang.python at DejaNews. As a Perl hacker, you might be interested to read what Tom Christiansen said about the two languages several years ago. http://language.perl.com/versus/python Although a lot of time has passed since that message was written, it's still a nice, polite, concise summary. Of course, both languages have developed since then. I think there are many more Python users than there were at the time he was writing. I originally started using Python at the recommendation of my co-workers when I started trying to learn about Perl's references so that I could build better data structures for my scripts. The syntax alone was driving me crazy. I started using Python, and I haven't written a Perl program of more than 10 lines since then. I don't program full time, and Python is simply easier to remember when I've been away from the language for a few weeks. As an extra bonus, I find that I write code that's much easier to reuse when I'm writing in Python. The language really encourages it. The thing that really motivated me to try Python was when I wrote a Perl script that *grew* to over 1000 lines. I was away from it for a while, and then I had to use it again...and modify it. It took me over an hour to figure the code out. It took me an afternoon to rewrite so that it could cope with the changes that I needed to make. Nothing like that has happened since I started using Python. Try it. You'll like it. :-) ---Tom P.S. Christiansen's article seems to imply that Python doesn't have a variety of ways to accomplish the same task: "Another thing people consider a feature in Python over Perl is that no one is ever going to turn around and write the whole thing in an entirely different way as they might in Perl." There's more than one way to do it in Python, too. There just aren't so many ways that you always have to delve into some dark corner of the language every time you read a different programmer's code. I'm finding that out now as I try to port some old Perl code to Python. -- tbryan at zarlut.utexas.edu Remove the z from this address to reply. Stop spam! http://spam.abuse.net/spam/ From tjreedy at udel.edu Thu Apr 8 22:59:32 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 9 Apr 1999 02:59:32 GMT Subject: Q: newbie win95 - python path navigation assignment strategies needed References: <7eibtm$igb$1@news1.cableinet.co.uk> Message-ID: <7ejqek$cuh$2@news.udel.edu> In article <7eibtm$igb$1 at news1.cableinet.co.uk>, jasonic at nomadicsltd.com says... >I do not understand the relationships between modules, namespace, path and >the Python shell. When I am in the python shell at the prompt I can The main differences between batch and interactive mode are that the latter: 1. echoe the value of expressions; 2. requires a blank line to terminate blocks (if, while, for, def, class). A module, once imported, is (or becomes) a namespace. Path is where to fine the text for modules. >But how and when do I need to change the working directory? >I cannot seem to find a setcwd() command or similar.. Am I missing >something? Yes. For 'how', check contents of ntpath. For when, when you want to import modules not on explicit paths in sys.pyth (so that they are in '.') or when you want to open files for reading and writing by simple name without a path. I'm not sure about some of other questions. Hope this helps. I also work on Win95 and have few problems. Terry J. Reedy From moshez at math.huji.ac.il Wed Apr 21 15:32:58 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 21 Apr 1999 22:32:58 +0300 Subject: New python user seeks comments In-Reply-To: <371db9cb.5622314@news.omnilink.de> References: <371db9cb.5622314@news.omnilink.de> Message-ID: On Wed, 21 Apr 1999, Stefan Franke wrote: > On 21 Apr 1999 00:33:10 -0400, David Steuber wrote: > > >Er, uh, hmm. > > > >I wrote my first Python program today. It took longer than I > >expected. Who would have guessed that you couldn't give a file object > >the name 'in'?Or at least that was one of the weirder obstacles. > > Maybe a reserved keyword-aware editor could have saved you > from this? You could try IDLE, which comes with the lastest Python > distribution or PythonWin, if you are using Windows. > There's a very clever Python Emacs mode as well... Just my 0.02$: Recent versions of vim are also Python syntax aware. And, though its name is misleading, the ``cheatsheet'' is wonderful: lists of reserved words, etc. -- Moshe Zadka . QOTD: What fun to me! I'm not signing permanent. From duncan at rcp.co.uk Thu Apr 29 05:11:18 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 29 Apr 1999 09:11:18 GMT Subject: 'sourcing' Python scripts? References: <372713AD.6ABA444@cern.ch> Message-ID: <8DB767BD4duncanrcpcouk@news.rmplc.co.uk> Haimo G. Zobernig wrote in <372713AD.6ABA444 at cern.ch>: >Dear Python experts, > >this might be a unix rather than a Python problem, but I need to set >environment variables from a Python program *in the parent process* >that is running the Python script ( a la os.environ['BAR'] = 'foo' ). >In other words, I want to achieve the equivalent of 'sourcing' the >Python script. Can this be done? Even better would be a solution that >also works on the various WinAbominations... (well, NT at least) About the only way to make this work would be to make the python program output a shell script that sets the environment variables and 'source' the output. Something similar should work on NT/95 although you would have to output appropriate syntax for the system in use. For example, the following abomination works on Windows NT 4 SP4: --------- something.bat or something.cmd -------------- @echo off set XYZZY="------------------" echo XYZZY is %XYZZY% for /F "tokens=*" %%i in ('d:\progra~1\python\python.exe test.py') do %%i echo XYZZY is %XYZZY% ------------------------------------------------------- ---------- test.py ------------------- print "SET XYZZY=Hello World" -------------------------------------- -- Duncan Booth duncan at dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan From ngps at my-dejanews.com Wed Apr 21 02:30:50 1999 From: ngps at my-dejanews.com (ngps at my-dejanews.com) Date: Wed, 21 Apr 1999 06:30:50 GMT Subject: Raw binary string --> long integer? Message-ID: <7fjrar$avb$1@nnrp1.dejanews.com> Hi, I'm looking for a way to do the following in pure Python. Given a binary string, e.g., '\003\004\005', convert the string into a long. So the example should become (3<<8|4)<<8|5 == 110000010000000101 == 197,637. The binary strings can be arbitrarily long. (Ok, up to about 256 bytes for an RSA public key. ;-) Hints appreciated. Cheers. - PS -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From paul at prescod.net Wed Apr 28 11:43:28 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 28 Apr 1999 15:43:28 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: <37272CA0.3F3F02A2@prescod.net> Markus Kohler wrote: > > > You are right that one should choose the right tool for a problem, but > I disagree that Python is optimized for the general case. Squeak a free > Smalltalk implementation (www.squeak.org), is already much faster ( about > 3 times actually ) than python and it has even a true Garbage > Collector. This is a little off-topic but I'm curious whether squeak has an embedding API. Is there any languge that is as easy to embed as Python, and also has full garbage collection? -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Microsoft spokesman Ian Hatton admits that the Linux system would have performed better had it been tuned." "Future press releases on the issue will clearly state that the research was sponsored by Microsoft." http://www.itweb.co.za/sections/enterprise/1999/9904221410.asp From tjreedy at udel.edu Tue Apr 6 22:56:09 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 7 Apr 1999 02:56:09 GMT Subject: Xbase++ preprocessor implementation in Python References: <37097A3A.F772205@magna.com.au> Message-ID: <7eehg9$3at$1@news.udel.edu> In article <37097A3A.F772205 at magna.com.au>, garys at magna.com.au says... >Attached please find a Python implementation of the Xbase++ preprocessor. ... >Oh, and it is *dead slow*! - hundreds of times slower I think! ... I do not know re's well enough to comment on whether they can be rewritten to run faster. I believe there is a python profiler which might give indications on where to start to speed things up. Terry J. Reedy From np2 at doc.ic.ac.uk Fri Apr 30 13:38:37 1999 From: np2 at doc.ic.ac.uk (Nat Pryce) Date: Fri, 30 Apr 1999 18:38:37 +0100 Subject: CORBA IDL AND SCRIPTS References: <3729E026.D9D29B1@ppllc.com> Message-ID: <3729EA9D.51C630C6@doc.ic.ac.uk> > My question is: Is there any support for generating Scripting > language bindings from CORBA IDL or a > translator (less preferable) that can translate from CORBA IDL to a > scripting language IDL ?? Any scripting language that has a binding to the CORBA Dynamic Invocation Interface (DII) and Interface Repository (IR) can safely invoke operations on CORBA objects without knowing their types at compile time. If you make all the APIs you want to be scriptable available through an ORB then the scripting interfaces will be available "for free". Cheers, Nat. -- +------------------------------------------+---------------------+ | Name: Nat Pryce MEng ACGI | Dept. of Computing, | | Email: np2 at doc.ic.ac.uk | Imperial College, | | Tel: +44 (0)171 594 8394 | 180 Queen's Gate, | | Fax: +44 (0)171 581 8024 | London SW7 2BZ, | | WWW: http://www-dse.doc.ic.ac.uk/~np2 | United Kingdom | +------------------------------------------+---------------------+ From fredrik at pythonware.com Tue Apr 13 03:32:13 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 13 Apr 1999 07:32:13 GMT Subject: Python without registry entries References: <370fb711.28093946@news.demon.co.uk> <7eol16$1l2$1@m2.c2.telstra-mm.net.au> <37121820.3758204@news.netmeg.net> <37116F7B.3E3088EB@prescod.net> Message-ID: <00f601be857f$ff9ef1a0$f29b12c2@pythonware.com> Paul Prescod wrote: > I would prefer if PythonWin did what Netscape does which is put the vast > majority of setup information in a text file in the Netscape directory and > make a single pointer to that from the registry. sitecustomize.py still works, afaik (see the comments in site.py for details). iirc, most of the stuff in the registry isn't really there for plain python usage; it's there to make sure COM and other windows-specific goodies work as they should. (btw, if you want a really plain python-on-windows installation, our py15 distribution doesn't touch the registry or the system directories at all...) From jkraai at murl.com Thu Apr 29 15:31:00 1999 From: jkraai at murl.com (jkraai at murl.com) Date: Thu, 29 Apr 1999 19:31:00 GMT Subject: padding strings Message-ID: <009301be9276$e20531a0$8b7125a6@cpda6686.mcit.com> padchar = ' ' N = 50 str = 'I need to be padded' padded = (str+padchar*N)[:N] print '>'+padded+'<' print 'len:',len(padded) --jim -----Original Message----- From: Roy Smith Newsgroups: comp.lang.python To: python-list at cwi.nl Date: Thursday, April 29, 1999 2:01 PM Subject: padding strings >Given a string, I want to generate another string which is exactly N >characters long. If the first string is less than N, I want to blank-pad >it. If the first string is greater than N, I want to truncate it. > >What's the most straight-forward way to do that? > >-- >Roy Smith >New York University School of Medicine > From faassen at pop.vet.uu.nl Wed Apr 14 15:19:46 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Wed, 14 Apr 1999 21:19:46 +0200 Subject: what do you do with Python References: <3714C9EA.86C0A4E@earthlink.net> Message-ID: <3714EA52.B0E4D2C6@pop.vet.uu.nl> susan e paolini wrote: > > I never see jobs with Python advertised so what is it that Python does? > Thanks for the advice I write software with Python. Python is one of the nicest programming languages I know (and I know quite a few). I write scripts to do various boring database stuff (luckily less boring due to Python), I've written a CGI script, I'm working on building a web site in Zope (which is a Python based web application platform). I play around with Python a lot too. It's great to do prototyping in. I'm planning to use Python to drive several of my larger pet programming projects; use fast C or C++ where necessary, but use Python to do the rest (and the rest is big; user interfaces, analysis of data, scripting, etc). Anyway, I'm making money doing mostly Python stuff. I introduced Python here myself, it wasn't advertized, but now they're stuck with it (as they're going for Zope). Python isn't a bad language to be stuck with; one of the best languages to be stuck with, in fact, so I'm doing them a favor. :) Python, by the way, is a clear, powerful, object oriented interpreted language with one of the most intelligent and civilized internet user communities I've yet encountered; and they like a good joke too. :) As I've expressed before in previous posts, Python is probably edging towards the 'zooming off into infinity' part of the exponential growth curve just about now. One or two years from now no one in computing will be able to ask your question. bold-prediction-mode-off-ly yours, Martijn From tjreedy at udel.edu Thu Apr 29 10:35:04 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 29 Apr 1999 14:35:04 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: <7g9qmo$luf$1@news.udel.edu> In article , wtanksle at dolphin.openprojects.net says... >The reason it's slow is its runtime model. _Every_ function call requires >a lookup in a hash table, just on the off-chance that the programmer >changed the meaning of the function. A batch-mode optimizer analyzing an entire file (module) should be able to detect whether or not function names are rebound. Perhaps module bindings should be considered immutable from outside the module unless explicitly declared otherwise. (This would of course require a new keyword and would break the rare existing code that does this until the new directive was added.) TJR From jcosby at wolfenet.com Sun Apr 18 17:57:52 1999 From: jcosby at wolfenet.com (Jon Cosby) Date: Sun, 18 Apr 1999 14:57:52 -0700 Subject: Sorting tuples Message-ID: <7fdkhf$12d$1@sparky.wolfe.net> I have a list of tuples [('a','p','q'),('b','r','s'),('c','t','u'),('a','v','w'),('b','x','y')], and I want to print out a : p, q, v, w b : r, s, x, y c : t, u Can somebody tell me what command will do this? Jon Cosby From jbauer at rubic.com Fri Apr 23 23:18:36 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Sat, 24 Apr 1999 03:18:36 GMT Subject: PythonCE References: Message-ID: <3721380C.C545A15@rubic.com> Rich Holm wrote: > Does anyone know the status of PythonCE? I would like to get > an updated copy, 1.5.2? Also, where is the source? I wouldn't > mind recompiling and extending it. Brian Lloyd's original PythonCE port: http://www.digicool.com/~brian/PythonCE/ Mark Hammond has extended it: http://starship.python.net/crew/mhammond/ce/ PythonCE is stable, even useful for certain tasks, especially http/ftp communication with your handheld. The only drawback (IMO) is that a GUI application will require you to write directly to the Win32/CE API. Mark provides an excellent example of how to do this -- he includes a shell written completely in Python. Best regards, Jeff Bauer Rubicon, Inc. From mal at lemburg.com Tue Apr 6 14:37:42 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 06 Apr 1999 20:37:42 +0200 Subject: SNMPy update References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <3709C8BE.4257C9F1@lemburg.com> <14090.16807.950025.496495@bitdiddle.cnri.reston.va.us> Message-ID: <370A5476.3AE3A7C1@lemburg.com> Jeremy Hylton wrote: > > >>>>> "MAL" == M -A Lemburg writes: > > MAL> Jeremy Hylton wrote: > >> I'll second your sentiment! I did some work on an X.509 library > >> written entirely in Python. Like you friend's SNMP code, it will > >> probably never be released; I don't have time to finish it nor > >> did I expect that I'd want to release it given the export control > >> hassles. > > MAL> Just want to note that SSLeay/OpenSSL includes a pretty > MAL> complete X.509 lib and also routines to do ASN.1 encoding an > MAL> decoding. The main argument for using OpenSSL in this context > MAL> is, of course, that no export control restrictions apply. > > Absolutely! There are a number of good reasons for using OpenSSL > other than export control as well. OpenSSL buys you all of SSL as > well as a lot of X.509 (and more of that every day). A Python > application built on a SWIGed OpenSSL, however, has a *lot* of C code > underneath it -- with all the problems a large C program has. A pure > Python implementation of X.509 could be easier to understand, debug, > and maintain. Luckily, there's a whole team of people looking into this and it is already pretty well debugged, so this may not be a serious issue. The size is a problem though: you wouldn't want OpenSSL sitting around in your memory on e.g. Windows CE :-) > >> However, it seemed clear to me that an ASN.1 compiler could be > >> written to generate the encode/decode routines. If someone is > >> interested in that, I've got some design notes and rough code on > >> how to do the encode/decode and on how to build a backend for > >> SNACC. (A free-ish ASN.1 compiler; the only one?) > > MAL> Not sure what you mean with "ASN.1" compiler. If you want a > MAL> compiler that does ASN.1 description -> Python function calling > MAL> de/encoding routines kind of thing, then I guess the ASN.1 > MAL> stuff in OpenSSL could help you getting started quite fast. > > It seems awfully hard to separate the ASN.1 specific stuff out of > OpenSSL. It uses it owns I/O abstractions and some moderately hair C > data structures to manage the results. It's a lot simpler to just > write the encode/decode routines in pure Python. True. Using the struct module should get you the same results on all supported platforms. > MAL> Note that I have a project running with the intention to wrap > MAL> OpenSSL in an OO manner called mxCrypto (see the link below). > > Looking forward to seeing it. When do you think you might have an > alpha release ready? I'm planning to wrap the ASN.1 stuff in the near future, since it comes in handy when en/decoding keys used by the public key algorithms. Not sure when an alpha will be ready though. Right now I have all the ciphers and hash functions wrapped, as well as RSA and Diffie-Hellman. All takes a little longer, since I want to do the wrapping in nice OO and not just simply tear out the functions and use them on the raw data. Maybe you could write the ASN.1 compiler stuff with an OO structure in mind ?! That would make it possible to use it for the stuff in mxCrypto too (with a speed gain I suppose). -- Marc-Andre Lemburg Y2000: 269 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From sdm7g at Virginia.EDU Fri Apr 23 13:00:16 1999 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 23 Apr 1999 13:00:16 -0400 (EDT) Subject: Bug or Feature? In-Reply-To: <37208E69.4B022E0C@mediaone.net> References: <37208E69.4B022E0C@mediaone.net> Message-ID: On Fri, 23 Apr 1999, Fuming Wang wrote: > > Hi, > > I found this little surprise with Python 1.5.1: > > > >list = [[0]*2]*4 > >list > [[0, 0], [0, 0], [0, 0], [0, 0]] > >list[0][1] = 9 > >list > [[0, 9], [0, 9], [0, 9], [0, 9]] > > Is this a bug or a feature that I don't know about? > It's a Frequently Discussed Feature. [0]*2 concatenates two _copies_ of the list [0] to each other, and the "*4" concatenates four _copies_ of that list together. While we're on the subject of map (in another thread nearby), try: list = [[0]*2]*4 list = map( lambda x: x[:], list ) list[0][1] = 9 ( Looks like copy.deepcopy is too smart to do what I want here. ) ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- From jbauer at rubic.com Fri Apr 30 00:11:24 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Fri, 30 Apr 1999 04:11:24 GMT Subject: Rat sited on Amazon Message-ID: <37292D6C.5684BF72@rubic.com> Hey everyone. Check out what's featured on Amazon today under "Computers and Internet". Has David or Mark ever refused to buy you a free drink? Now's your chance to get even and write a negative review. It's never too late for blackmail, or what we of the genteel persuasion prefer to call "negotiation". ethics-at-$3-a-round-ly yr's Jeff Bauer Rubicon, Inc. From cmedcoff at my-dejanews.com Thu Apr 29 11:47:11 1999 From: cmedcoff at my-dejanews.com (cmedcoff at my-dejanews.com) Date: Thu, 29 Apr 1999 15:47:11 GMT Subject: How to read stdin while debuggingin PythonWin Message-ID: <7g9utu$kin$1@nnrp1.dejanews.com> I may be overlooking something obvious... I'm debugging a script in PythonWin's debugger. I get to the statement "answer = sys.stdin.read()" and the program stops as expected; but where to I provide the input?! -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From smoothasice at geocities.com Thu Apr 29 17:16:50 1999 From: smoothasice at geocities.com (smoothasice at geocities.com) Date: Thu, 29 Apr 1999 21:16:50 GMT Subject: Errors Message-ID: <3728CD26.907ED9A1@geocities.com> Ok I have been using python and I have noticed that the errors aren't truly helpful.. I don't know if I just didn't learn this properly but I dont' know why this generates an error: for word in All_Words: z = 0 while z < len(word): if z == 0: tally = tally + alpha.index(word[z]) else: tally = tally + (alpha.index(word[z]) * 26) It gives me this: NameError: tally and I don't know why...... THanks, Anton From andrew at starmedia.net Tue Apr 20 13:02:18 1999 From: andrew at starmedia.net (Andrew Csillag) Date: Tue, 20 Apr 1999 17:02:18 GMT Subject: Bug with makesetup on FreeBSD References: <19990416143607.B1546743@vislab.epa.gov> <19990416215633.C2020@ipass.net> <19990417112344.A1624668@vislab.epa.gov> Message-ID: <371CB31A.474D6FF@starmedia.net> Randall Hopper wrote: > > Andrew Csillag: > |Randall Hopper wrote: > |> Andrew Csillag: > |> |makesetup in Python 1.5.1 and 1.5.2 bombs on lines in the Setup file > |> |that use backslash continuation to break a module spec across lines on > |> |FreeBSD. > |> > |> BTW FWIW, I just built 1.5.2 last night on 3.0-RELEASE using the 1.5.2c1 > |> port. Worked fine. But it may not invoke makesetup under the hood. > | > |It does invoke makesetup (that's how the Makefile in Modules gets > |written). I'm also running FreeBSD 2.2.8, so it may be a bug in /bin/sh > |that has been subsequently fixed... The quick test is to try this on > |your 3.0 machine > | > |$ read line > |some text here\ > | > |On my 2.2.8 machine after I hit return after the \, I get a command line > |prompt, not a "blank prompt" that would mean that the read wasn't done. > > It must be something else then, because here with stock Bourne shell: > > |$ read line > |some text here\ > |$ echo $line > |some text here\ > > I get the same behavior you describe, but no build breakage. > > Randall I figured it out! If you build out of the ports tree, it's Tkinter configuration is all on one line (see /usr/ports/lang/python/files/Setup.tk), not broken by using backslash continuation as is in the distributed Setup file. I was building from the source release from www.python.org, not from the ports tree as you did, hence why you didn't run into it and I did. -- "There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence." - Jeremy S. Anderson From aa8vb at vislab.epa.gov Tue Apr 6 07:02:55 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 6 Apr 1999 11:02:55 GMT Subject: mxDateTime in Python distribution Message-ID: <19990406070255.A867135@vislab.epa.gov> I'd like to add my vote toward integrating Marc Lemburg's mxDateTime functionality into the next Python release. I needed to do some date/time arithmetic recently and found that core Python didn't have this functionality. I was a little skeptical about using a seperate extension for portability reasons. Randall From stephan at pcrm.win.tue.nl Thu Apr 22 06:54:01 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 22 Apr 1999 12:54:01 +0200 Subject: Controlling Linux serial port w/ Python ... References: <924762349.809295488@news.intergate.bc.ca> Message-ID: Gerald Gutierrez writes: > I understand that POSIX termios, for which Python has a binding, may be able to > do this. Can someone point me to an example somewhere? Alternatively, can > someone direct me to where this type of information is available? What about the Serial-Programming-HOWTO ? It describes how to do it in C, but my guess is it's pretty similar in Python. Greetings, Stephan From fdrake at cnri.reston.va.us Mon Apr 5 15:04:56 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Mon, 5 Apr 1999 19:04:56 GMT Subject: Fwd: gzip/zlib module Doc bug (1.5.2b2 Library Reference) In-Reply-To: <199904051825.NAA29396@alpha1.csd.uwm.edu> References: <199904051825.NAA29396@alpha1.csd.uwm.edu> Message-ID: <14089.2392.607974.602129@weyr.cnri.reston.va.us> Bernhard Reiter writes: > This leaves the impression that the gzip module can decompress > all the files the gzip program can decompress, which is not true. > The gzip program can also deflate data compressed with "compress" > and "pack". The python module cannot do this. I've made changes to make this more clear. > This is not true for Windows, where you need and have to use an > additional "b" in the mode argument. At least I needed to do it, Good point; the modules were written and tested on Unix systems, so this wasn't caught here. I've fixed the documentation and made the module always use the binary the default flavor for 'mode'. > Both bugs sucked in some of my time. > I hope this helps to improve! ;-> I'm sorry this cost you some time, but I'm glad to have the bug report! Thanks for pointing this out! These changes will be included in the next documentation release; your prize is one free download. ;-) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From MHammond at skippinet.com.au Thu Apr 22 19:19:44 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 23 Apr 1999 09:19:44 +1000 Subject: pythonwin/mapi crystal ball needed References: <7fnbks$ga1$1@nnrp1.dejanews.com> Message-ID: <7foapn$iij$1@m2.c2.telstra-mm.net.au> Gustin Kiffney wrote in message <7fnbks$ga1$1 at nnrp1.dejanews.com>... >Anyway I've long put off learning much about MFC/COM/MAPI because >it looked too hard, but now have to find a way to implement a MAPI >service provider (an address book). I've looked at the MAPI stuff >in the python win32all distribution and it looks pretty complete (anyway, >it looks like lots of stuff that I don't understand yet is there). Unfortunately, Python can not do this. The MAPI support allows us to _use_ MAPI objects, whereas implementing an Address Book provider requires you to implement them. The only way to go this route is to enhance the MAPI support to be able to do this. This would not be trivial - I would allow myself 1 week to do this. However, as writing an Address Book provider is very hard, and lots of code, I personally would probably still go this route - I think the week invested would buy me time... Sorry I can't be more help, or give better news... Mark. From gmcm at hypernet.com Tue Apr 13 18:10:51 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 13 Apr 1999 22:10:51 GMT Subject: Tools for three way merge of Python source files? In-Reply-To: References: Message-ID: <1288080836-20523748@hypernet.com> Milton L. Hankins writes: > Are there tools to help with 3-way merges of Python sources and/or > indentation conversion? I can help with the indentation conversion. http://www.mcmillan-inc.com/dnld/tabcleaner.py This converts leading whitespace to whatever tab / spaces configuration you want. It uses tokenize.py to determine indents and dedents, so it's Guido doing the parsing, not me. (Anyone who's had trouble with this before - it's been completely rewritten, and no longer gets fooled by certain triple-quoted strings). Another way (for your purposes) might be to always filter everything through pindent.py. > I'm using Python on a Real Project and I need to do a 3-way merge. > Certain whitespace characters must be ignored -- specifically, > carriage returns. I have a diff tool which ignores blanks but then > I run into problems where a block of code has been indented further > (inside a new block). > > I wish I could rely on the parser to catch this sort of thing, but > it won't detect all possible follies, such as this one: > > > if foo: > if bar: > baz() > else: > frob() > > > if foo: > if bar: > baz() > else: > frob() > > Here, the merge result (using blank ignorance) would not incorporate > the changes from . > > One correct solution seems to be to strip CR from CRLF. But I'm > afraid of having too many conflicting sections (false negatives) > where the spacing difference is actually benign. Perhaps I should > just tell my fellow developers not to change indentation unless they > have to. > > So, it also appears that I need a Python-aware indentation converter > -- something that converts a source file to use a minimal number of > tabs (or perhaps spaces, as long as it were consistent) for block > indents. > > If anyone has had similar experiences or knows of a solution I'd > love to hear about it. Email is preferred. Thanks. > > > (I really hope this doesn't start Yet Another Whitespace War.) > > -- > Milton L. Hankins -=- > > Software Engineer, Raytheon Systems Company -=- RayComNet > 7-225-4728 > http://amasts.msd.ray.com/~mlh -=- ><> Isaiah 64:6 > ><> > > - Gordon From zorro at zipzap.ch Wed Apr 14 04:25:30 1999 From: zorro at zipzap.ch (Boris Borcic) Date: Wed, 14 Apr 1999 10:25:30 +0200 Subject: Python as an ODBC *source* on windoze ? References: <816010E2456BD111A48700805FBBE2EEA63EDE@ex-quebec-u1.baan.com> Message-ID: <371450FA.EA31CB69@zipzap.ch> Gaetan Corneau wrote: > [GC] > The easy way is just to dump your data to a text file (comma or tab > delimited) and read it with MS Access: there is a Text ODBC driver that > works well. > > Hope this helps, The voice of reason ;-) BB From phil at geog.ubc.ca Thu Apr 29 20:09:42 1999 From: phil at geog.ubc.ca (Phil Austin) Date: 29 Apr 1999 17:09:42 -0700 Subject: Designing Large Systems with Python References: <3725CA37.2027327D@lemburg.com> <37274e10.12544588@nntp1.ba.best.com> Message-ID: bkhunter at best.com (Bill) writes: > On Tue, 27 Apr 1999 16:31:19 +0200, "M.-A. Lemburg" > wrote: > >Projects around 50k are still well manageable using an editor > >like Xemacs; larger projects probably need the help of systems > >like SNIFF (which offers Python support). > > Are you talking about SNIFF+ from TakeFive Software? I browsed their > site and could only find mention of C++ and Java support. Any > pointers? It's at: http://starship.python.net/crew/scharf/sn4py/ -- ------------------------------------------------------------ Phil Austin (phil at geog.ubc.ca) Department of Geography, Tel: (604) 822-2663 University of British Columbia, B.C. Fax: (604) 822-6150 From calishar at *remove*this*.home.com Wed Apr 14 20:22:48 1999 From: calishar at *remove*this*.home.com (Calishar) Date: Thu, 15 Apr 1999 00:22:48 GMT Subject: Freezing an App References: <7f15dj$bq4$1@m2.c2.telstra-mm.net.au> Message-ID: > > The part I am having problems with is using win32api. It runs, doesnt set > >the registry values it is suppoed to, and exits without giving any errors. > > Im not sure what you mean here. okay, basically I am using Python to automate a process at a client site. in this application, I have about 4 different functions which each get called by button clicks. One of the routines is supposed to set a registry key based on an environment variable. The lines follow: the_key=win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE,"Software\Stac\Rea chout\8.0") win32api.RegSetValueEx(the_key,"Computer Name",0,win32con.REG_SZ,mac_name) At the moment, this is the only part of the application I dont have working on my non-development system, unfortunately it happens to be kind of important. > Firstly, you could consider simply shipping win32api.pyd - ie, dont freeze This was my first thought, I made sure that I had the .pyd file in the same directory as the program I am running. It doesnt do it. > You do this simply by excluding win32api from the freeze using "-x win32api" Tried doing this, then copying the files needed over to my '95 test system (not the same OS,but should be close enough for this part) and when I ran it, it crashed at line 3 of the code (import win32api) > If you want to freeze the win32api sources into your app, the process then > is: > * Download the sources to the win32api module. > * Check out the .ini file that comes with freeze. It is used to locate the > source to win32apimodule.cpp. > > Run freeze - it may complain it cant find the file. If so, ensure the > environment variable it uses is set. I can't recall exactly what that is. Okay, then I did this section, and when I ran freeze at the end it said: generating table of frozen modules No definition of module _tkinter in any specified map file. No definition of module win32api in any specified map file. Warning: unknown modules remain: _tkinter win32api Which looks the same as what I had the first time. I did notice that for win32api it was using the win32api.pyd file rather than the source code specified in the .ini file. > This could do with more work - Im happy to discuss ways you can help to make > this better for the next person :-) Thanks for the help, I'm really starting to feel like a dummy here. Here is the command line I am using for freeze python freeze.py -p e:\src\python1.5.2c1 -o e:\bins e:\ghostit.py Calishar From ferradajj at ornl.gov Fri Apr 30 13:41:59 1999 From: ferradajj at ornl.gov (Juan Ferrada) Date: Fri, 30 Apr 1999 13:41:59 -0400 Subject: graphics using Python 1.2 in DOS Message-ID: <3.0.32.19990430134156.006fe674@tin2.cad.ornl.gov> At Oak Ridge National Laboratory, we developed a chemical process simulation program using C++ that works in a DOS environment. It is a graphic interface and process diagrams are created by putting different icons that are dragged and dropped in the screen. It has worked very nicely for us for the last four years. Four years ago, we were after a scripting language that could simplify the model writing. Each icon (that represents a specif engineering process) can be model using an executable in any language. For example, we use executables written in Fortran, Pascal, Prolog, C, C++ etc and our program launches those executable when they are needed. By using an scripting language the modeling would be simplified. In fact, 4 years ago we downloaded the current version of Python and we integrate it with our code and produce the executable of our application. We called it FLOW. It has been very successful. Many students that do their internship with us have learned the basic principles of Python and some of the classes and objects that we created for our own purpose. After just two weeks of tutorials they are capable of producing their models and run them with the rest of the application. The only problem we have is that when we go from the FLOW graphic interface and want to interact with the user and ask them some question, for example what is the input pressure of your bomb? or what is the diameter of your tank? we go to the traditional black screen of the DOS environment. We would like to improve this by putting, for example, the figure of a pump and show the user the question directly on the graphic. We believe that we could use a graphic library like the one you developed and being able to develop the graphics we want. Is it possible to use your library in the DOS environment? So when we invoke the library, as we do with other libraries that we have developed earlier(from ourlyb import * at the beginning of the program), we can get the desired effects. We downloaded the Python version 1.2, April 1995 and we compiled with our C++ code. We are looking for a library that works with that version so we can invoke the library by simply writing: from graphiclibrary import *, so we don't have to recompiled everything again. Do you think this is possible and if it is how can we get to that library and where we need to put it to make it work. We currently put everything writting in Python in a directory like this: C:\flow\python and every fiel *.py goes there including the libraries. I would really appreciate your help. I have a couple of students working with me that really need this feature. thank you very much Juan J. Ferrada From srowland at biocryst.com Fri Apr 16 10:17:30 1999 From: srowland at biocryst.com (srowland at biocryst.com) Date: Fri, 16 Apr 1999 14:17:30 GMT Subject: 1.5.2 broke IRIX module loading References: <19990414110116.A1374923@vislab.epa.gov> <37161C26.C121CA1E@bioreason.com> Message-ID: <7f7gpf$r4a$1@nnrp1.dejanews.com> In article <37161C26.C121CA1E at bioreason.com>, Andrew Dalke wrote: > Randall Hopper said: > > I built and tried 1.5.2 this morning, and it failed to load a module > > that worked fine on 1.5.1. > Does this failure occur for all modules including standard Python Library modules or is it limited to some specialized module? Scott Rowland -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From hyoon at bigfoot.com Thu Apr 15 09:19:35 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Thu, 15 Apr 1999 09:19:35 -0400 Subject: TCL_LIBRARARY and making it work References: <3714B880.22F87048@bigfoot.com> <3714BB3A.54BF2531@bigfoot.com> Message-ID: <3715E767.4DE62C8@bigfoot.com> Thanks Duncan, As soon as I added c:\python\TCL\bin path and then killed off tcl80.dll, tclpip80.dll, and tk80.dll from \WINNT\system32, everything was fine! Hoon Yoon wrote: > > Hi, > > I think I found the problem by setting TKPATH, but now I got a > different prob. All this used to work fine prior to install. I don't > know what's going on. > > Traceback (innermost last): > File "", line 1, in ? > File "c:\TEMP\python-BEAf6p", line 2, in ? > Tkinter._test() > File "C:\Python\Lib\lib-tk\Tkinter.py", line 1947, in _test > root = Tk() > File "C:\Python\Lib\lib-tk\Tkinter.py", line 886, in __init__ > self.tk = _tkinter.create(screenName, baseName, className) > TclError: Can't find a usable tk.tcl in the following directories: > {C:\Python\TCL\lib\tk8.0} . C:/Python/TCL/lib/tk8.0 ./tk8.0 > ./lib/tk8.0 ./library ./tk8.0/library ./library > C:/Python/TCL/tk8.0/library > > C:/Python/TCL/lib/tk8.0/tk.tcl: bad event type or keysym "MouseWheel" > bad event type or keysym "MouseWheel" > while executing > "bind Listbox { > %W yview scroll [expr - (%D / 120) * 4] units > }" > (file "C:/Python/TCL/lib/tk8.0/listbox.tcl" line 179) > invoked from within > "source [file join $tk_library listbox.tcl]" > (file "C:/Python/TCL/lib/tk8.0/tk.tcl" line 151) > invoked from within > "source C:/Python/TCL/lib/tk8.0/tk.tcl" > ("uplevel" body line 1) > invoked from within > "uplevel #0 [list source $tkfile]" > C:/Python/TCL/lib/tk8.0/tk.tcl: bad event type or keysym "MouseWheel" > bad event type or keysym "MouseWheel" > while executing > "bind Listbox { > %W yview scroll [expr - (%D / 120) * 4] units > }" > (file "C:/Python/TCL/lib/tk8.0/listbox.tcl" line 179) > invoked from within > "source [file join $tk_library listbox.tcl]" > (file "C:/Python/TCL/lib/tk8.0/tk.tcl" line 151) > invoked from within > "source C:/Python/TCL/lib/tk8.0/tk.tcl" > ("uplevel" body line 1) > invoked from within > "uplevel #0 [list source $tkfile]" > > This probably means that Tk wasn't installed properly. > > > -- > > ***************************************************************************** > > S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, > > yelled at yahoo.com hoon at bigfoot.com(w) > > "Miracle is always only few standard deviations away, but so is > > catastrophe." > > * Expressed opinions are often my own, but NOT my employer's. > > "I feel like a fugitive from the law of averages." Mauldin > > ***************************************************************************** > > > > ------------------------------------------------------------------------ > > > > Hoon Yoon > > > > Hoon Yoon > > > > Netscape Conference Address > > Netscape Conference DLS Server > > Additional Information: > > Last Name > > First Name Hoon Yoon > > Version 2.1 > > -- > ***************************************************************************** > S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, > yelled at yahoo.com hoon at bigfoot.com(w) > "Miracle is always only few standard deviations away, but so is > catastrophe." > * Expressed opinions are often my own, but NOT my employer's. > "I feel like a fugitive from the law of averages." Mauldin > ***************************************************************************** > > ------------------------------------------------------------------------ > > Hoon Yoon > > Hoon Yoon > > Netscape Conference Address > Netscape Conference DLS Server > Additional Information: > Last Name > First Name Hoon Yoon > Version 2.1 -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From Gaetan_Corneau at baan.com Fri Apr 9 10:18:19 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Fri, 9 Apr 1999 14:18:19 GMT Subject: import from user input? Message-ID: <816010E2456BD111A48700805FBBE2EEA63EB9@ex-quebec-u1.baan.com> Chris, > >>> globals()[modname] = __import__(modname) [GC] Exactly what I was looking for. I read about the __import__ function in the doc, but I didn't know that I had to assign it that way. > > Another question: is there a function to copy/move entire directory > trees? > There is a walk function in os.path which makes it > an easy exercise to write such a function. [GC] Thanks a lot, Chris. ______________________________________________________ Gaetan Corneau Software Developer (System integration Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 654-1454 ext. 252 ______________________________________________________ "Profanity is the one language all programmers know best" From jschiotz at hotmail.com Wed Apr 28 08:27:41 1999 From: jschiotz at hotmail.com (Jakob Schiotz) Date: Wed, 28 Apr 1999 12:27:41 GMT Subject: SOLUTION: Cross-references between dynamically loaded modules under AIX References: <7g42o5$d8u$1@nnrp1.dejanews.com> <19990427081109.C579158@vislab.epa.gov> Message-ID: <7g6urp$v5u$1@nnrp1.dejanews.com> In a recent post, I wrote: > I wrote a small function to convert a C pointer to a NumPy array (I am > using SWIG), ... it coredumps under AIX ... the dynamical loader under > AIX cannot resolve symbols in one module that refers to another module. It turns out is was NOT a dynamic loading problem after all. One of my colleagues found a new NumPy manual (March 99) that contains a chapter on how to extend NumPy. And it turns out that one should call the function import_array() in the modules initialization function. Then it works! Now the only mystery is why it worked on the Alpha architecture without that call... :-) BTW, it looks like a very nice NumPy manual: ftp://ftp-icf.llnl.gov/pub/python/numericalpython.pdf Thanks for all your suggestions! Jakob -- Jakob Schiotz, CAMP and Department of Physics, Tech. Univ. of Denmark, DK-2800 Lyngby, Denmark. http://www.fysik.dtu.dk/~schiotz/ This email address is used for newsgroups and mailing lists (spam protection). Official email: schiotz @ fysik . dtu . dk -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From jon at rdt.monash.edu.au Fri Apr 16 02:26:41 1999 From: jon at rdt.monash.edu.au (Jonathan Giddy) Date: 16 Apr 1999 06:26:41 GMT Subject: Change for compiling 1.5.2 on Windows NT Alpha References: Message-ID: <7f6l71$20e$1@towncrier.cc.monash.edu.au> "Scott C" writes: >There needs to be the following change in file fpectlmodule.c, line 163: >Line currently reads: #elif defined(__alpha) >line should read: #elif defined(__alpha) && !defined(_MSC_VER) Or to follow the comments more obviously, change it to #elif defined(__alpha) && defined(__osf__) Jon. From tim_one at email.msn.com Sat Apr 24 01:17:10 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 24 Apr 1999 05:17:10 GMT Subject: Time complexity of dictionary insertions In-Reply-To: References: Message-ID: <000901be8e11$b4842560$f09e2299@tim> [someone asks about the time complexity of Python dict insertions] [Tim replies] > Min O(1), Max O(N), Ave O(1). If the hash function is doing > a terrible job (e.g. maps every key to the same hash value), make > those all O(N). [one person confuses the issue] > C++ STL junkies know this as "amortized constant time". [and another compounds it] > So does anyone who has ever studied much at all about algorithms, data > structures, and optimization. > > It's not a C++ thing. It's a computer science thing. This one-ups-man-ship would be a lot cuter if Python's dict insertion were in fact amortized constant time <0.9 wink>. It's not, and the answer I gave doesn't imply that it is. Insertion in STL hashed associative containers isn't ACT either. reassuringly y'rs - tim From free at good.pt Wed Apr 7 02:36:56 1999 From: free at good.pt (FREE and GOOD SEX) Date: 7 Apr 1999 06:36:56 GMT Subject: PTSex - The best SEX for FREE... Message-ID: <7eeue8$7m4$12102@duke.telepac.pt> Looking for sex for FREE?? Go to: http://www.sapo.pt/cgi/getid?id=http://members.theglobe.com/esqueleto/index.htm&server= Here you will find the best pictures collection in a portuguese SITE Will find there too, FOR FREE, the best Live Sex Shows What are you wating for?????? http://www.sapo.pt/cgi/getid?id=http://members.theglobe.com/esqueleto/index.htm&server= From Martin.Preishuber at stuco.uni-klu.ac.at Mon Apr 26 02:50:55 1999 From: Martin.Preishuber at stuco.uni-klu.ac.at (Martin Preishuber) Date: Mon, 26 Apr 1999 06:50:55 +0000 Subject: Strange fork() behaviour References: <37203066.6B4A58D9@stuco.uni-klu.ac.at> Message-ID: <37240CCF.EF01D299@stuco.uni-klu.ac.at> Harald Hanche-Olsen wrote: > | There are some strange things with fork() and python 1.5.2 going > | on here. > | > | I do have some main program which is basically > | > | while 1: > | fork() > | > | The program forks under certain conditions and works as expected > | but somewhen the main process dies even though it is in the > | while 1: loop ... there's no error message ... did anyone > | see anything similar ? the program worked fine with 1.5.1 > | (this is all on a linux box running rh 5.2 and kernel 2.2.6-ac1) > This is a joke, right? What I would expect the above program to do is > to fork processes until the process table is full or you hit the > per-user process limit, at which point fork() will begin to fail, > which will then most likely terminate the calling process (unless you > trap the error). No sorry, this is definitely not the _full_ code ... it just forks under some condition (usually, there are never more than 3 or 4 children) ... the point is that the father should never die, but it does ! > I'd be curious to know how this could have worked earlier, or how you > could expect it to behave differently. It does, believe me ;-) Martin -- Martin Preishuber - Student, ECLiPt Core Member, SysAdmin http://eclipt.uni-klu.ac.at, mailto:Martin.Preishuber at stuco.uni-klu.ac.at I respect faith, but doubt is what gives you an education. -- Wilson Mizner From zak at wiggins-t.co.uk Fri Apr 16 10:09:37 1999 From: zak at wiggins-t.co.uk (Zacharias Pigadas) Date: Fri, 16 Apr 1999 15:09:37 +0100 Subject: PythonScript in web page Message-ID: <924271602.14980.0.nnrp-02.c224787d@news.demon.co.uk> hello I am trying to make an ASP using python, I have a question, How do I access the contents of a form in the document? I tried it javascript way and i got the message: password=document.formTest.passTest.value RuntimeError: Instance-method attributes not accesible in restricted method. What does that mean and is this the correct way to use it?? Any suggestions on how to overcome it? Thanks, Zach From moshez at math.huji.ac.il Sun Apr 25 18:36:05 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Mon, 26 Apr 1999 01:36:05 +0300 Subject: Python too slow for real world In-Reply-To: References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> Message-ID: On 25 Apr 1999, Magnus L. Hetland wrote: > > Um, why? I don't see any need at all for them to move from > > module-status to core-language-status. > [...] > > > > In all seriousness, what reason do you have for making that > > suggestion? I am willing to believe that there might be a good reason > > to do so, but it certainly isn't immediately obvious. > > Now, that's really simple -- because re.py is slow. I thought maybe > some of the slowness might be improved by a c-implementation, that's > all. Not too important to me... Um....two wrong assumptions here: 1. C implementation is /not/ the same as core status: C extension modules are numerous and wonderful, for example... 2. re.py is a (very thin) wrapper around pcre, a C extension module for Perl Compatible Regular Expressions. Which just goes to say that while pcre can certainly be optimized, it can't be done by simply rewriting it in C. <0.5 wink> but-we-can-always-call-Perl-on-the-fly-to-evaluate-regular-expression-ly y'rs, Z. -- Moshe Zadka . QOTD: What fun to me! I'm not signing permanent. From mwh21 at cam.ac.uk Fri Apr 16 10:43:53 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 16 Apr 1999 15:43:53 +0100 Subject: Imperfections in ihooks.py? References: <00d301be880d$0ebcd000$f29b12c2@pythonware.com> Message-ID: "Fredrik Lundh" writes: > > I apologise for the lousy use of language in this post. It's a subject > > I find a bit confusing to think about, and I'm clearly not much better > > a writing about it. > > > > Does anybody out there use ihooks? I'm having a couple of problems. > > Forget about ihooks.py. Greg Stein's imputil.py module > is much easier to use, and much more powerful. > > It's in the "small distribution" kit, available from: > > http://www.lyra.org/greg/small/ > > Ah! Fantastic! Usual case; I start to think about a problem, ask about it and find someone else has solved the problem already. Not perfection yet though - imputil.py contains these lines: def _reload_hook(self, module): raise SystemError, "reload not yet implemented" which was one of the things I was moaning about in my post. Thanks! Michael From marcel.lanz at isoe.ch Sat Apr 17 13:11:41 1999 From: marcel.lanz at isoe.ch (Marcel Lanz) Date: Sat, 17 Apr 1999 19:11:41 +0200 Subject: Sleeping threads References: <3718042D.EE5D36A8@hons.cs.usyd.edu.au> Message-ID: <3718C0CD.814F3506@isoe.ch> Matthew Robert Gallagher wrote: > > I've been looking at threads and time but how do you sleep threads hi, if you use low-level threads: simply sleep with the time.sleep() method in the thread-method you choosed. import time, thread ... ... def x(): print 'too high' time.sleep(0.5) thread.start_new_thread(x, ()) greetings marcel From tismer at appliedbiometrics.com Thu Apr 22 12:58:05 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 22 Apr 1999 16:58:05 GMT Subject: Directory of current file References: <371F0BD2.7D40A957@rubic.com> <00ee01be8cba$6e98dcb0$f29b12c2@pythonware.com> <5lvheosuyt.fsf@eric.cnri.reston.va.us> Message-ID: <371F551D.5F40782F@appliedbiometrics.com> Guido van Rossum wrote: > > "Fredrik Lundh" writes: > > > how about a combination? > > > > import sys, os > > if __name__ == '__main__': > > _thisDir = sys.argv[0] > > else: > > _thisDir = sys.modules[__name__].__file__ > > Eh, what's wrong with simply using __file__? It's a global in your > own module, remember! [I think we had that some months ago, already] > if __name__ == '__main__': > _thisDir = sys.path[0] or os.curdir > else: > _thisDir = os.path.dirname(__file__) Since these come up again and again, I still see no reason why we don't support __file__ for __main__? Wouldn't it be much clearer to 1) provide an absolute path for __file__ always 2) provide __file__ for __main__ as abs_path(sys.path[0] or os.curdir) + name_of_sciptfile? If there is no scriptfile, well we'd take the empty string. The other proposals are not as foolproof, since they depend on weak stuff as os.curdir which has dynamic meaning, while paths of files are a static thing, a "compile time" property with early binding. I'd like to be able to always use: _thisDir = os.path.dirname(__file__) _script = os.path.basename(__file__) if _script: # well, we have a script file always? Even better _thisdir, _script = os.path.split(__file__) What is the background to keep this thing complicated for the user (where complicated means to use more than one function call), instead of the above? ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 smoothasice at geocities.com Wed Apr 21 16:53:08 1999 From: smoothasice at geocities.com (smoothasice at geocities.com) Date: Wed, 21 Apr 1999 20:53:08 GMT Subject: Python Win Message-ID: <371E3B80.A6D5379@geocities.com> Ok i've been playing Python for a long time and I am just now wanting to expand to learning the visual portion of it.(A.k.a Gui/MFC) but I have found that there is a diffinite lack of information on the site and I Haven't been able to find a book and I was wondering if there is anyone out there that could help me out or perhaps direct me towards where I could find info on it. Thanks , Anton From quinn at necro.ugcs.caltech.edu Fri Apr 30 19:18:23 1999 From: quinn at necro.ugcs.caltech.edu (Quinn Dunkan) Date: 30 Apr 1999 23:18:23 GMT Subject: Read MS Access 97 *.mdb files with python?? References: <37287369.D6E67313@t-online.de> <3728867D.94B5BBF9@appliedbiometrics.com> <3728A903.CF75B41A@pop.vet.uu.nl> <3728B7DF.80E23481@t-online.de> Message-ID: On Thu, 29 Apr 1999 16:02:25 -0400, Darrell wrote: >I'm no expert but... >Put some data base package on your Linux machine that supports ODBC. I would >think that with lots of luck Access running on the Win boxes could connect >to it. > >--Darrell Hmm, I have a somewhat similar situation... I have databases in Access. Currently, they are converted to cvs and read into mysql, which then serves them to python via iODBC + mxODBC. Of course, I would much rather have Access talk to mysql directly and be just a front-end for mysql, and the iODBC stuff seems to imply this can be done... But I still can't figure out how to get Access to do this... Anyone have a similar setup? thanks! From pfjakub at earthlink.net Sun Apr 25 19:35:48 1999 From: pfjakub at earthlink.net (Peter Jakubowicz) Date: Sun, 25 Apr 1999 23:35:48 GMT Subject: Beginner Needs Help Compiling/Running Module Message-ID: <3723a436.9965940@news.earthlink.net> Hi, This is a very rudimentary questions; I just started trying to learn Python last night w/ Learning Python. What I need to know is how to compile and run a simple module. I am running WinPython 1.5.2 under Win 98. I have placed C:\program files\python\lib in my path. I am saving my modules in a directory called pythonsource. When I am in that directory I try to invoke python by typing python MyModule.py and an command line arguments, as in Java, but apparently I cannot do this. Alternatively, when I have the python window console open I cannot get at my module at all, tho I can invoke the python interpreter. If someone could either point me tostep-by-step instructions for compiling and running the equivalent of a Hello World module using WinPython, or tell me all the steps, I would greatly appreciate it. TIA From dkuhlman at netcom.com Wed Apr 28 11:24:46 1999 From: dkuhlman at netcom.com (G. David Kuhlman) Date: Wed, 28 Apr 1999 15:24:46 GMT Subject: Using Python for Modular Artificial Intelligence code References: Message-ID: Tim Auld wrote: > Hi all, ... > My question is, how can I load the Python script, let my C++ object call > functions within the Python script, and provide a callback for the Python > script to call methods in the C++ object? Get the Python documentation at http://www.python.org/doc, then look at the sections on "Extending and Embedding" and "Python/C API". There is lot's there on this topic. Also download the Python source distribution. In the demo directory you will find an example on embedding. Play with and expand on that to learn how to do it yourself. Then ask some more questions on this news group. - Dave - Dave > ________________________ > astro at tne.net.au > tim at ratbaggames.com From Frank.Derville at wanadoo.fr Wed Apr 28 17:17:14 1999 From: Frank.Derville at wanadoo.fr (Frank.Derville) Date: Wed, 28 Apr 1999 23:17:14 +0200 Subject: GUI and creating GIF Message-ID: <7g7u2k$fr0$1@wanadoo.fr> Hello, I would like to 1) create a GIF file under Python by drawing lines, text, ... I have looked at Tk which can create bitmaps and photoimage but their seem to be no possibility to transform a canvas into a photoimage. 2) rotate some text on a canvas. Does anyone has a tip to do it under Tk, wxWindows or any other GUI? Thanks by advance From geek+ at cmu.edu Mon Apr 5 11:42:04 1999 From: geek+ at cmu.edu (geek+ at cmu.edu) Date: 5 Apr 1999 11:42:04 -0400 Subject: Subattributes of classes Message-ID: Then spoke up and said: > > class A: > def __init__( self ): > self.attr = 123 > self.attr.subattr = 456 # <--------- Error! > > a = A() > > > This generates an error as I would have expected. > > However, I see the same syntax in: > demos/tkinter/matt/canvas-with-scrollbars.py because in the demo you pointed to, they are setting sub-attributes of an integer. The object 123 is immutable. Do it this way: class foo: pass f = foo() f.bar = foo() f.bar.baz = 123 -- ===================================================================== | JAVA must have been developed in the wilds of West Virginia. | | After all, why else would it support only single inheritance?? | ===================================================================== | Finger geek at cmu.edu for my public key. | ===================================================================== -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 266 bytes Desc: not available URL: From MHammond at skippinet.com.au Wed Apr 21 20:19:09 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 22 Apr 1999 10:19:09 +1000 Subject: Python Win References: <371E3B80.A6D5379@geocities.com> Message-ID: <7flpsj$6rg$1@m2.c2.telstra-mm.net.au> For now, a good MFC book is really required to learn MFC and Pythonwin at the same time. Pythonwin is great for building slick windows specific apps, but the learning curve is steep if you dont know MFC. You way like to fiddle with Tkinter - you will probably find far more tutorial type information available...After playing with it, you can decide if it is suitable for your intended use. Mark. smoothasice at geocities.com wrote in message <371E3B80.A6D5379 at geocities.com>... >Ok i've been playing Python for a long time and I am just now wanting >to expand to learning the visual portion of it.(A.k.a Gui/MFC) but I >have found that there is a diffinite lack of information on the site and >I Haven't been able to find a book and I was wondering if there is >anyone out there that could help me out or perhaps direct me towards >where I could find info on it. > >Thanks , >Anton From da at ski.org Fri Apr 23 23:49:54 1999 From: da at ski.org (David Ascher) Date: Fri, 23 Apr 1999 20:49:54 -0700 (PDT) Subject: learning Python (rat book) In-Reply-To: <37206351.DB8025EF@appliedbiometrics.com> Message-ID: On Fri, 23 Apr 1999, Christian Tismer wrote: > Unfortunately, names seem to appear just by the chance that > material was used. I was astonished to find quite a couple > of names, but no Aaron Watters, no Barry Warsaw. Indices refer to text, so yes, names will show up based on whether they show up in the text. As such, Aaron and Barry's names should have appeared in the index, since they are mentioned in the text (Aaron for gadfly and IPP, Barry for his PSA work -- he should be mentioned in the context of JPython as well, but maybe that change happened too late for the first printing. Anyway, all this to say that these omissions were not deliberate, and will be fixed in future printings if they don't affect the page count (I believe that's the rule). In fact, I wish to make public an acknowledgement which was omitted unintentionally in the final rush of production -- Jim Hugunin provided valuable assistance in the the JPython program development. I'll try and get that fixed in the next printing as well. We'll add Christian as well for the Starship reference, of course. > But when mentioning SWIG, it should had better put a reference > to Dave Beazley into the index as well. Agreed. > I'm currently working on the German translation. it will be > ready by end of July. I will try to adjust the index to mention > every person who plays a role in the book. Great -- make sure to check in with Mark and I about the fixes we make for the next printing, and let us know of the other bugs you find in the process. --David Ascher From akuchlin at cnri.reston.va.us Fri Apr 23 09:59:20 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Fri, 23 Apr 1999 09:59:20 -0400 (EDT) Subject: opening more than 1 file In-Reply-To: <7fpteh$cik$1@news1.xs4all.nl> References: <371CB255.5FCAFBAF@solair1.inter.NL.net> <371CCAE0.7DE87F8A@aw.sgi.com> <7fpteh$cik$1@news1.xs4all.nl> Message-ID: <14112.31139.164770.168982@amarok.cnri.reston.va.us> Gornauth writes: >>files = map(lambda i: open("file%02d"%i, 'w'), range(N)) > >I'm not completely sure how that one-liner works. To be honest, I have no >clue whatsoever. It would be equally workable to just use a for loop: files = [] for i in range(N): files.append( open("file%02d"%i, 'w') ) Using map() is tricky, but lets you keep the line count down; generally one shouldn't care too much about line count. :) Take it step by step: * What does range(N) do? It returns a list containing the numbers 0,1,2, ... that are less than N. range(5) returns [0, 1, 2, 3, 4]. * What does map() do? map(F, L), where F is some function and L is some list (actually, any sequence type) returns a new list containing the result of F applied to each element of L. map(F, range(N)) returns [ F(0), F(1), ... F(N-1) ]. map(string.upper, ["This", "is", "a", "test"] ) returns ['THIS', 'IS', 'A', 'TEST'] * What does lambda do? It defines a function which doesn't have a name (it's an anonymous function), and can only contain an expression whose value is returned. It's possible to assign the anonymous function to a name, and it will act like any other Python function. >>>f = lambda x: x+1 >>> f(0) 1 >>> f(3) 4 However, to define a named function it's clearer to just use def f(x): return x+1 . lambda is therefore usually used with map() and its cousins filter() and reduce(), where you often need a function which does something simple. In that case, the function is only needed for that one map(), so people are reluctant to write: def opener(i): return open("file%02d"%i, 'w') files = map(opener, range(N) ) The above two lines are equivalent to the one-liner using lambda; the only difference is that now there's an opener() function lying around in the namespace. -- A.M. Kuchling http://starship.python.net/crew/amk/ ... but whenever optimization comes up, people get sucked into debates about exciting but elaborate schemes not a one of which ever gets implemented; better to get an easy 2% today than dream about 100% forever. -- Tim Peters, 22 Mar 1998 From barry at scottbb.demon.co.uk Tue Apr 6 17:22:17 1999 From: barry at scottbb.demon.co.uk (Barry Scott) Date: Tue, 6 Apr 1999 22:22:17 +0100 Subject: Embedding python question: PyRun_String only returns None not what I calculate Message-ID: <923433832.14002.0.nnrp-07.9e982a40@news.demon.co.uk> What I want to do is call python to run python code and return the results to my app. But I cannot find anyway to do this. It would seem that I should be using PyRun_String to run a piece of python and return a result object to me. But I can only get a return value of None. NULL is returned if the code does not run. How do I get python to return 2 to me when I ask it what 1+1 is? Below is a fragment of code that I'm using to investigate PyRun_String. BArry // // Test getting an object back from a command // char *command = "1+1"; PyObject *m = PyImport_AddModule("__main__"); if (m == NULL) return EXIT_FAILURE; PyObject *d = PyModule_GetDict(m); PyObject *v = PyRun_String(command, Py_file_input, d, d); if (v == NULL) { PyErr_Print(); return EXIT_FAILURE; } PyObject *result = PyObject_Str( v ); char *string = PyString_AsString( result ); printf("Python returned: %s", string ); Py_DECREF(result); Py_DECREF(v); From guido at eric.cnri.reston.va.us Fri Apr 30 23:35:14 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 30 Apr 1999 23:35:14 -0400 Subject: mktime() like function to produce GMT? References: <00be01be9308$c649cf60$0301a8c0@cbd.net.au> <3729B855.3A7C6B5A@lemburg.com> <5lu2ty9lpx.fsf@eric.cnri.reston.va.us> <00d301be9368$277ae580$0301a8c0@cbd.net.au> Message-ID: <5logk5a2dp.fsf@eric.cnri.reston.va.us> "Mark Nottingham" writes: > Guido: I had tried a similar approach; > > date = mktime(rfc822.parsedate(datestring)) - time.timezone > > Neither this or mktime_tz will work; both will sometimes return dates that > are off by one hour, depending on dst. I think this is because I'm parsing > dates that may fall at any arbitrary time in the past, when the machine > doesn't (AFAIK) have perfect knowledge about dst. > > Ultimately, I'm trying to parse a UTC datestring (HTTP Last-Modified header > in one of the three accepted formats) into a rfc1123-format datestring (as > well as a number to play with); the date should never have to even know > about localtime (which is causing all of the problems, in this case). With > either the above solution or mktime_tz(), some dates will parse back to > themselves, while others will have a one hour offset. > > One such date (in my tz - aust eastern) is "Tue, 18 Mar 1997 05:32:18 GMT" > which, after munging, will think it's 04:32:18. > > I'm testing with: > > #!/usr/bin/env python > import sys, time, rfc822 > g = list(rfc822.parsedate_tz(sys.argv[1])) > g[9] = 0 > date = rfc822.mktime_tz(tuple(g)) > print time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(date)) Hmm... For me, in the US Eastern timezone, with Python 1.5.2, this works. It's been a long time but I really believe that the theory of mktime predicts that it *should* work -- if you tell it not to use daylight savings time it shouldn't. Which Python version are you using? (There has been some weirdness in previous versions.) What Unix platform? It's sometimes hard to get time.timezone to be the right value (very convoluted code in timemodule.c, which has changed again in 1.5.2). Could it that there's a bug there because your DST is on the other half of the year? --Guido van Rossum (home page: http://www.python.org/~guido/) From jwbaxter at olympus.net Fri Apr 30 01:25:49 1999 From: jwbaxter at olympus.net (John W. Baxter) Date: Thu, 29 Apr 1999 22:25:49 -0700 Subject: Rat sited on Amazon References: <37292D6C.5684BF72@rubic.com> Message-ID: In article <37292D6C.5684BF72 at rubic.com>, jeffbauer at bigfoot.com wrote: > Hey everyone. Check out what's featured on Amazon today > under "Computers and Internet". > > Has David or Mark ever refused to buy you a free drink? > > Now's your chance to get even and write a negative review. > > It's never too late for blackmail, or what we of the > genteel persuasion prefer to call "negotiation". > > ethics-at-$3-a-round-ly yr's > > Jeff Bauer > Rubicon, Inc. My (preordered) copy came with a little "surprise" folded into the book. Stapled together: a packing slip for 40 copies and an invoice for 57 copies. Once I recovered enough to read, I noted that the packing slip and invoice were O'Reilly shipping to and invoicing Amazon. I felt much better then. (Or was this Amazon attempting to improve quarterly results? ;-)) --John -- If nothing is pressing, putter about with this or that. (Fortune cookie) John W. Baxter Port Ludlow, WA USA jwb at olympus.net From tismer at appliedbiometrics.com Fri Apr 9 11:26:28 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 9 Apr 1999 15:26:28 GMT Subject: import from user input? References: <816010E2456BD111A48700805FBBE2EEA63EB9@ex-quebec-u1.baan.com> <370E0F51.E1D33D6@appliedbiometrics.com> <14094.6366.328759.966352@buffalo.fnal.gov> Message-ID: <370E1C24.A2C4F159@appliedbiometrics.com> Charles G Waldman wrote: > > Christian Tismer writes: > > > > import string > > globals()[string.split(modname, ".")[0]] = __import__(modname) > > > > seems to do it better. > > > > Why not just > > exec "import "+modname See my former post. It works for you and me, but if I have to be aware of users trying things like modname = "sys;sys.exit()" to name a quite harmless idea, you would have more work to prevend this than by a string which is no parsed command. I think it's not clean to give the user full access to your namespace and interpreter. Not if you are the user, of course. But if you allow arbitrary strings to be executed, you are poking a big hole into your software. How about modname = "sys;None=5" This was just a concern, which would more apply to Internet CGI scripts. Using these concepts thoughtlessly with the proper pickled string, would let your user break into your module completely. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 dozier at bellatlantic.net Tue Apr 20 10:57:49 1999 From: dozier at bellatlantic.net (Bill Dozier) Date: Tue, 20 Apr 1999 10:57:49 -0400 Subject: unpickling an NT object in Solaris? Message-ID: Hi, I created an object running python on NT and pickled it. I have no problem unpickling on NT, but when I ftp'd the file over to Solaris, I get an ImportError exception ("No module named __main__^M") when I try to unpickle it. Is this a 1.5.2 (on NT) vs. 1.5.1 (on Solaris) problem, or am I mistaken in expecting the pickled objects to work cross-platform? Thanks! From jeffp at crusoe.net Fri Apr 9 18:30:04 1999 From: jeffp at crusoe.net (evil Japh) Date: Fri, 9 Apr 1999 18:30:04 -0400 Subject: OrderedDict.py Message-ID: Is there a need for a module which allows for ordered processing of an dictionary? I have one written, and it works fine I think. Basically, it allows for a dictionary to be treated like a list, but have the data structure of dictionary. Key-value pairs retain the order you entered them in. Unless you specifically change them. I'm currently working on more methods, to allow it to be sliced like an array. currently, it wouldn't allow for numeric keys, because the __getitem__ finds out what you sent, an integer (numeric index) or a string (a dictionary key). the __getslice__ and __setslice__ aren't a problem. I could make a special class for indices for getting dict[4]... something like: dict[Index(4)] instead of dict[4] but I'd like to be as seamless as possible. I'll be putting the code on my web site soon. -- Jeff Pinyan (jeffp at crusoe.net) www.crusoe.net/~jeffp Crusoe Communications, Inc. 732-728-9800 www.crusoe.net From dhfx at bga.com Mon Apr 26 22:40:30 1999 From: dhfx at bga.com (dhfx at bga.com) Date: Tue, 27 Apr 1999 02:40:30 GMT Subject: IDLE ! References: <371ADC8C.54C4CDBE@zipzap.ch> Message-ID: <7g382v$mkk$1@nnrp1.dejanews.com> In article <371ADC8C.54C4CDBE at zipzap.ch>, Boris Borcic wrote: > I am having my first look at 1.5.2 and IDLE (on Win95). > > Very nice. Thank you (once again), Guido. > > Boris Borcic > Seconded. Many thanks, Guido. The colors look nice. Just one minor detail. I'm running 1.5.2 on a Win95 box, and I happen to have changed the color scheme to give me white text on a dark background; it's really much easier on the eyes. I've noticed that a number of W95 apps implicitly assume that text will always be black; they set the background color to white (or something close to it) but don't bother setting the default foreground color - so I get WHITE ON WHITE! Sadly, the current version of IDLE is one of these. I don't even see the banner lines that come up when the window opens! Guido, if you could please put on your TODO list to set a default background color (black, presumably) for text, I'd be most appreciative. David Friedman -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From tincho.NO at SPAM.crl.com Fri Apr 9 09:06:03 1999 From: tincho.NO at SPAM.crl.com (Martin Bertolino) Date: Fri, 9 Apr 1999 08:06:03 -0500 Subject: Python 1.5.2c1 -- release candidate for 1.5.2 References: <199904082148.RAA04479@eric.cnri.reston.va.us> Message-ID: <7eku4f$2gt8$1@nnrp9.crl.com> Is there any documentation on what is planned/in devlopment for Python 2.0? How it will be different from the 1.5.X releases? Thanks Martin Bertolino Guido van Rossum wrote in message <199904082148.RAA04479 at eric.cnri.reston.va.us>... >On 8 April 1999, Python 1.5.2c1 was released. This is a release >candidate for 1.5.2 final - only showstopping bugs will be fixed >before 1.5.2 is released. > >*** Please help making 1.5.2 rock solid by banging on the release >candidate in all possible ways! *** > >I hope to release the final version of 1.5.2 on 13 April. That will >conclude the 1.5 development cycle; while I may release some essential >patches later, my main development focus will be on Python 1.6 (with >2.0 on the horizon; 1.6 will probably be the last of the 1.x >versions). > >Go to http://www.python.org/1.5/ for more info, or download directly: > >ftp://ftp.python.org/pub/python/src/py152c1.tgz (source, 2.5M) >ftp://ftp.python.org/pub/python/win32/py152c1.exe (Windows installer, 5.0 M) > >--Guido van Rossum (home page: http://www.python.org/~guido/) From aa8vb at vislab.epa.gov Thu Apr 22 12:14:03 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Thu, 22 Apr 1999 12:14:03 -0400 Subject: Pointers to variables Message-ID: <19990422121403.A279051@vislab.epa.gov> This doesn't work: for ( var, str ) in [( self.min, 'min_units' ), ( self.max, 'max_units' )]: if cnf.has_key( str ): var = cnf[ str ] del cnf[ str ] It doesn't assign values to self.min, self.max (both integers). The values of these variables are inserted into the tuples and not references to the variables themselves, which is the problem. How can I cause a reference to the variables to be stored in the tuples instead of their values? Thanks, Randall From MHammond at skippinet.com.au Tue Apr 20 20:29:57 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 21 Apr 1999 10:29:57 +1000 Subject: Installing 1.5.2 on WinNT without Admin privileges? References: <7fif3n$4m0$1@nnrp1.dejanews.com> Message-ID: <7fj64d$6cc$1@m2.c2.telstra-mm.net.au> At this stage, no. the only real reason is that making an installer handle both cases it just too hard, and installing stuff so it is available machine-wide (rather than just the current user) seemed more useful - especially for people hoping to use it with CGI etc. You should be able to copy to binaries to your machine, set a PYTHONPATH variable, and all should be well.. Mark. tshort at my-dejanews.com wrote in message <7fif3n$4m0$1 at nnrp1.dejanews.com>... >Is it possible to install a Python 1.5.2 binary without Admin privileges on >Windows NT? > >- Tom > >-----------== Posted via Deja News, The Discussion Network ==---------- >http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From frankmcgeough at my-dejanews.com Sun Apr 25 18:45:44 1999 From: frankmcgeough at my-dejanews.com (frankmcgeough at my-dejanews.com) Date: Sun, 25 Apr 1999 22:45:44 GMT Subject: perl v python References: <37238A6A.E245337D@btinternet.com> Message-ID: <7g05un$v80$1@nnrp1.dejanews.com> I believe you may be able to find an analysis on the www.python.org website giving several links to comparison pages. The pluses for python (IMHO) are : lends itself to more readable and thus more maintainable code; is easily usable for programs involving data structures (thus more complicated programs); has oo constructs from the start so they seem more natural than Perl's additions. We didn't run into too many problems when converting our test framework from Perl to Python. > I've been using perl quite some time, just starting looking > at Python. > what's peoples views/comparisons of both languages? -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From arcege at shore.net Tue Apr 13 11:25:20 1999 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 13 Apr 1999 15:25:20 GMT Subject: CVS module References: <7evbjf$85f$1@anguish.transas.com> Message-ID: Michael Sobolev wrote: : My quick attempt to find something that would help me to cope with CVS files : failed. Could anybody advise me whether such a module exist? Under "such a : module" I mean something that permits to get the complete information about the : given file: : cvsfile = CVSFile () : from pprint import pprint : pprint (cvsfile.revisions) : or something alike. I have some modules that I wrote a year ago. Nothing of production quality, but they were usable (and stable). I used them a lot in my SCM/RM duties. Read the cvslib.py doc for usage. The URL is: http://www.shore.net/~arcege/python/Pycvs.tar.gz -Arcege From pj at sgi.com Fri Apr 16 13:24:39 1999 From: pj at sgi.com (Paul Jackson) Date: 16 Apr 1999 17:24:39 GMT Subject: #!/usr/bin/env python -u References: <37175574.25EBDDBE@stuco.uni-klu.ac.at> Message-ID: <7f7ron$ur2o@fido.engr.sgi.com> Not that this is any help, but other kernels besides Linux don't pass #! arguments in full generality. For example, the Irix system I'm on right now is doing pretty much the same thing. Part of this is the convention, apparent on both my Linux and Irix boxes, to pass the name of the script file as argv[2], which leaves argv[1] stuck with the entire trailing argument list from the #! line. -- ======================================================================= 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 bwarsaw at cnri.reston.va.us Fri Apr 16 11:27:39 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Fri, 16 Apr 1999 11:27:39 -0400 (EDT) Subject: Python.org scheduled down time Message-ID: <14103.22251.209537.804890@anthem.cnri.reston.va.us> Folks, parrot.python.org, the machine that hosts web, mail and ftp, will be taken down today 16-Apr-1999 at 4pm GMT -0500 for approximately 1/2 hour. We need to install some new hardware. Thanks, -Barry From mstenber at cc.helsinki.fi Thu Apr 29 00:48:21 1999 From: mstenber at cc.helsinki.fi (Markus Stenberg) Date: 29 Apr 1999 07:48:21 +0300 Subject: Emacs' python-mode buggy? In-Reply-To: Ken Manheimer's message of "Thu, 29 Apr 1999 00:42:17 -0400" References: <199904282340.TAA19934@python.org> <3727E329.2E8F3C31@digicool.com> Message-ID: Ken Manheimer writes: > Markus Stenberg wrote: > I can't speak to the intimacy issue, but the python-mode syntax recognition > may be due to having a leading '(' open paren in the first column in one of > your docstrings. If so, emacs' syntax confusion (not to be mistaken for > poor gender identification) can be remedied by escaping the leading open > paren with a '\' backslash, like so: Ah, what's causing that problem? > \(this is what to do with parens in docstrings.) > > If it is the problem, well, it's emacs' problem, not pymode. If it's not, > well, do track it down. > > Oh, does that bug constitute the "tons" you mention, or were there others? > I never was good at estimating the weight of bugs - all that chiton, you > know. Think there is two, as one of my (moderately large) modules has no docstrings with ('s yet still exhibits that behavior. (ok, I got carried away, but I was moderately frustrated over the feature :-P) > Ken Manheimer > klm at digicool.com -Markus -- Markus Stenberg Finger fingon at mpoli.fi for PGP key -- PGP key id: 1024/5DAC7D21 From kj7ny at email.com Sat Apr 3 03:05:16 1999 From: kj7ny at email.com (kj7ny at email.com) Date: Sat, 3 Apr 1999 00:05:16 -0800 Subject: Python on Apache and traceback Message-ID: <7e4bta$ild$1@paperboy.owt.com> Before you flame my socks off, I know this is NOT the right place to probably ask this question, but I guarantee you there is no where better to get the right answer. I am using Python on Apache on Win98. Has anyone figured out how to get at the traceback errors when using Python on Apache? They are not automatically returned to the browser as they are on IIS and PWS. Thanks, kj7ny at email.com From duncan at rcp.co.uk Tue Apr 20 04:42:59 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 20 Apr 1999 08:42:59 GMT Subject: Date/Time conversions References: <371BEBA7.5DBC1B0F@qut.edu.au> Message-ID: <8DAE62F4Dduncanrcpcouk@news.rmplc.co.uk> Rico Albanese wrote in <371BEBA7.5DBC1B0F at qut.edu.au>: >I am writing a web based database application and I am having problems >in creating a string that contains an integer in it. I wish to store >the login time as an integer so that I may do some time difference >calculations based on the stored login time (ie. the integer). The SQL >statement string creation fails when I have the integer variable >"logtime" in it but not when it is removed. I believe that my problem >is caused by trying to insert an integer into a string. The database >works fine (ie I can add integers to the column "LogTime"). > > Your problem is that you are trying to concatenate a string with an integer. The arguments to the '+' operator should both be numbers, or both strings, you cannot mix strings and numbers here. There are two obvious solutions. One is to convert logtime to a string. e.g. thesql=thesql + frontpar + str(logtime) + "," The other, possibly better one is to build up your SQL string using the '%' operator. For example, your SQL statement may be build up something like this: SQLtemplate = '''INSERT INTO CSJobs.compjobs (LogTime,Caller,Phone_Extension,Caller_Category,Location,Job_Description,Jo b_Priority,LogNumb,Log_Date,Finished) VALUES (%(logtime)s, '%(Caller)s', '%(Ph)s', '%(Sch)s', '%(Loc)s', '%(JbDes)s', '%(JbPr)s', '%(LogN)s', '%(logdate)s', 'n') ''' thesql = SQLtemplate % locals() crsr.execute(thesql) Which does all the neccessary conversions to strings as you go. -- Duncan Booth duncan at dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan From holger at phoenix-edv.netzservice.de Tue Apr 27 06:09:35 1999 From: holger at phoenix-edv.netzservice.de (Holger Jannsen) Date: Tue, 27 Apr 1999 10:09:35 GMT Subject: sort of multiple dictonaries References: <371F28CA.2240BB7B@phoenix-edv.netzservice.de> Message-ID: <37258CDF.1B3AC266@phoenix-edv.netzservice.de> Thank ya' Michael, Ciao, Holger Michael Hudson schrieb: > > Holger Jannsen writes: > > Hi there, > > > > perhaps a typical newbie-question: > > > > I've got a list of dictonaries like that: > > > > mydics=[{'sortit': 'no412', 'mode': 'nothing'}, > > {'sortit': 'no112', 'mode': 'something'}, > > {'sortit': 'no02', 'mode': 'something else'}] > > > > Is there an easy way to get that list sorted like that: > > > > def sortDictonary(aDictonary, theSortKey="sortit"): > > .... > > > > Result have to be: > > > > mydics=[{'sortit': 'no02', 'mode': 'something else'}, > > {'sortit': 'no112', 'mode': 'something'}, > > {'sortit': 'no412', 'mode': 'nothing'}] > > > > Any hints? > > Well, it's actually a list you're sorting isn't it? > > mydics.sort(lambda x,y:cmp(x['sortit'],y['sortit'])) > > should work, if I understand the problem. > > HTH > Michael From trashcan at david-steuber.com Wed Apr 21 00:33:10 1999 From: trashcan at david-steuber.com (David Steuber) Date: 21 Apr 1999 00:33:10 -0400 Subject: New python user seeks comments Message-ID: Er, uh, hmm. I wrote my first Python program today. It took longer than I expected. Who would have guessed that you couldn't give a file object the name 'in'? Or at least that was one of the weirder obstacles. Anyway, I am not at all used to thinking in Python. I was wondering if anyone would care to offer comments on my Python script. It is quite small and is responsible for my sig. Feel free to scarf it. -------------- next part -------------- #! /usr/bin/env python # Tue Apr 20 17:31 # This is my first python program. It is intended to generate signature # files for mail and news using the fortune program. # The first step is to open a template file that contains the constant # portion of the signature. For flexability, I would like to get # the file name from the command line. So really, the first step is # to read the command line. # imports section import sys import os import commands import time # Test the number of arguments to see that it is the required number. if len (sys.argv) != 3: print 'usage: siggen.python template pipe' sys.exit(0) # The first argument is the input file, the second argument is the # output file which should be a named pipe. template = sys.argv[1] npipe = sys.argv[2] if not os.path.isfile(template): print template + ' is not a file!' sys.exit(0) if not os.path.exists(npipe): os.mkfifo(npipe) # Time to get into it. Go into an infinite loop where we open the # template file, copy it line by line to the pipe, then execute the # fortune program and send it out the pipe while 1: fin = open(template, 'r', 1) fout = open(npipe, 'w', 0) fout.writelines(fin.readlines()) fin.close() fout.writelines([commands.getoutput('/usr/bin/fortune -a'),'\n']) fout.close() time.sleep(1) -------------- next part -------------- -- David Steuber http://www.david-steuber.com s/trashcan/david/ to reply by mail | while you're at it, you might also If you don't, I won't see it. | want to track down and kill bulk | mailers, aka spammers. Vote for ME -- I'm well-tapered, half-cocked, ill-conceived and TAX-DEFERRED! From ivnowa at hvision.nl Sun Apr 11 16:37:07 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Sun, 11 Apr 1999 20:37:07 GMT Subject: best way to copy a file [Q] In-Reply-To: <000201be8441$7965d4d0$6eba0ac8@kuarajy.infosys.com.ar> References: <000201be8441$7965d4d0$6eba0ac8@kuarajy.infosys.com.ar> Message-ID: <199904111935.VAA24485@axil.hvision.nl> On 11 Apr 99, Ce'Nedra took her magical amulet and heard Bruno Mattarollo say: >Hi! > > I need to copy a file (can be binary or ascii) from one path to another. I >have tryied to do: > line = fd.readline() > while line: > fd2.write(line) > line = fd.readline() > fd.close() > fd2.close() > > It only works for ascii files ... How can I do a 'copy' ...? I need to run >this on NT ...:( And I don't want to open a shell to do a copy from >there... I also tryied fd.read() ... No success neither. Sure can: fin = open("myfile", "rb") # notice the 'rb' fout = open("target", "wb") # ...and the 'wb' data = fin.read(1000) # or any amount of bytes you want to read while data: fout.write(data) data = fin.read(1000) fin.close() fout.close() This should work. For large files, a larger number than 1000 may be desirable. + Hans Nowak (Zephyr Falcon) + Homepage (under construction): http://www.cuci.nl/~hnowak/ + You call me a masterless man. You are wrong. I am my own master. + May a plumber throw eggs at your dead presidents! From barry at scottbb.demon.co.uk Tue Apr 13 17:57:30 1999 From: barry at scottbb.demon.co.uk (Barry Scott) Date: Tue, 13 Apr 1999 22:57:30 +0100 Subject: Windows install has problems. Guido asked that I use this newsgroup to discus further References: <924039873.18221.0.nnrp-12.9e982a40@news.demon.co.uk> Message-ID: <924040766.18823.0.nnrp-12.9e982a40@news.demon.co.uk> >I wish I could. The installer is very stupid. Windows sucks :-( Is the WISE installer unable to deal with Win 9X vs. NT and handle registry queries and updates? I'm sure that I can do this with InstallShield (a poorly designed, annoying, but functional installer). As for the tcl80.dll problems. Either assume that tcl80.dll is in the standard (english) installation place %systemdrive%\program files\tcl\bin\tcl80.dll. OR release note that users must add the Tcl bin dir to there PATH. As the python lib does not have a module to access the registry it makes getting the info from the registry hard. Maybe 1.6 needs a windows registry module to solve this and other problems. BArry From guido at eric.cnri.reston.va.us Tue Apr 20 22:45:11 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 20 Apr 1999 22:45:11 -0400 Subject: Problems with mod_pyapache and cPickle References: <371CC227.5BDF5C5A@starmedia.net> Message-ID: <5l4smau1xk.fsf@eric.cnri.reston.va.us> Or you could upgrade to Python 1.5.2, which gets rid of the class_cache altogether. -- --Guido van Rossum (home page: http://www.python.org/~guido/) From nickb at earth.ox.ac.uk Wed Apr 14 11:53:29 1999 From: nickb at earth.ox.ac.uk (Nick Belshaw) Date: Wed, 14 Apr 1999 16:53:29 +0100 Subject: REPOST:pretty please - Help re libpython1.5.so Message-ID: <3714B9F9.30285D74@earth.ox.ac.uk> I'm gonna start taking this personally soon !!! You bright guys out there..................................... If anyone can spare a second - Whilst trying to get Python plugins to work on Gnumeric-0.23 I bumped up against the need for libpython1.5.so.0.0.0 I have 'The Full Python' ( - thats the sequel to 'The Full Monty' !!! ) and can build xxxx.a no problem but what do I have to do to get xxxx.so Can't seem to find anything specific on it in the docs or readme or Setup and my knowledge is too superficial to allow me to be clever. Help anyone? cheers Nick/Oxford Geochemistry From samschul at ix.netcom.com Tue Apr 13 19:00:41 1999 From: samschul at ix.netcom.com (Sam Schulenburg) Date: Tue, 13 Apr 1999 16:00:41 -0700 Subject: Keyboard interrupt handling response under IDLE Message-ID: <7f0iad$nqj@dfw-ixnews4.ix.netcom.com> Keyboard interrupt handling response under IDLE The following function performs a call to a DLL that handles issuing commands to an external SCSI hard disk drive. def test(): while(1): try: io6(0x12,0x00,0x00,0x00,0xff,0x00) print '*', except KeyboardInterrupt: key = raw_input('Key board interrupt detected: do you want to continue Y/N ') if(upper(key) != 'Y'): break The io6(0x12,0x00,0x00,0x00,0xff,0x00) function resides within the DLL and will report all errors back to Python via this function call: static void vLogP(UCHAR *ucMsgStr,UCHAR ucIndex) { UCHAR ucPyString[200]; if( iERRORMSG == 1) { wsprintf(ucPyString,"sys.stderr.write(\'%s\')",ucMsgStr); PyRun_SimpleString(ucPyString); wsprintf(ucPyString,"print \"\""); PyRun_SimpleString(ucPyString); } else { wsprintf(ucPyString,"print \"%s\"",ucMsgStr); PyRun_SimpleString(ucPyString); } }; The problem occurrs when the function within the DLL has an error and the reported error occurrs continously. What appears to happen is that the IDLE enviroment detects the error as shown below but does not always throw the exception *Drive is not available for testing: Traceback (innermost last): File "", line 1, in ? File "D:\Python152\Tools\idle\PyShell.py", line 598, in write self.shell.write(s, self.tags) File "D:\Python152\Tools\idle\PyShell.py", line 589, in write raise KeyboardInterrupt # Detected the exception but continued with the main loop KeyboardInterrupt *Drive is not available for testing: *Drive is not available for testing: Traceback (innermost last): File "", line 1, in ? File "D:\Python152\Tools\idle\PyShell.py", line 598, in write self.shell.write(s, self.tags) File "D:\Python152\Tools\idle\PyShell.py", line 589, in write raise KeyboardInterrupt # Detected the exception but continued with the main loop KeyboardInterrupt *Drive is not available for testing: *Drive is not available for testing: *Drive is not available for testing: *Drive is not available for testing: *Drive is not available for testing: *Drive is not available for testing: Traceback (innermost last): File "", line 1, in ? File "D:\Python152\Tools\idle\PyShell.py", line 598, in write self.shell.write(s, self.tags) File "D:\Python152\Tools\idle\PyShell.py", line 589, in write raise KeyboardInterrupt KeyboardInterrupt # Detected the exception but continued with the main loop *Drive is not available for testing: *Drive is not available for testing: * Key board interrupt detected: do you want to continue Y/N n # Finally caught the exception From quelle at NO_SPAM_infrasystems.com Tue Apr 13 19:58:03 1999 From: quelle at NO_SPAM_infrasystems.com (Reinhardt Quelle) Date: Tue, 13 Apr 1999 23:58:03 GMT Subject: Windows install has problems. Guido asked that I use this newsgroup to discus further References: <924039873.18221.0.nnrp-12.9e982a40@news.demon.co.uk> <924040766.18823.0.nnrp-12.9e982a40@news.demon.co.uk> Message-ID: Barry Scott wrote in message news:924040766.18823.0.nnrp-12.9e982a40 at news.demon.co.uk... > >I wish I could. The installer is very stupid. Windows sucks :-( > > Is the WISE installer unable to deal with Win 9X vs. NT and handle > registry queries and updates? I'm sure that I can do this with > InstallShield (a poorly designed, annoying, but functional installer). > I have an older version of WISE - it reports the OS version as well as supports reading and writing to the registry (and trivially adding things to the path in autoexec) From akuchlin at cnri.reston.va.us Tue Apr 27 09:05:50 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Tue, 27 Apr 1999 09:05:50 -0400 (EDT) Subject: examples for beginners In-Reply-To: <3724e511.441513@news.tin.it> References: <3724e511.441513@news.tin.it> Message-ID: <14117.46113.146923.36938@amarok.cnri.reston.va.us> Kranio writes: >Could you suggest me where to find some script just for studying? http://www.strout.net/python/tidbits.html http://starship.python.net/crew/amk/python/simple.html The Demo directory that comes with Python is also helpful. -- A.M. Kuchling http://starship.python.net/crew/amk/ By undue profundity we perplex and enfeeble thought; and it is possible to make even Venus herself vanish from the firmament by a scrutiny too sustained, too concentrated, or too direct. -- E.A. Poe, "The Murders in the Rue Morgue" From Stuart.Ramsden at anu.edu.au Tue Apr 13 20:26:44 1999 From: Stuart.Ramsden at anu.edu.au (Stuart Ramsden) Date: Wed, 14 Apr 1999 10:26:44 +1000 Subject: real time scheduler References: <3713AE36.A1EA255B@arlut.utexas.edu> Message-ID: <3713E0C4.2AD4FCCB@anu.edu.au> Bryan VanDeVen wrote: > Is there a module for scheduling events in real time? I have events > that need to be repeated indefinitely, each at a given time period. The > periods are large (at least one minute) and precision requirements are > not that great (within a few seconds). Is anyone aware of code to do > this? I wrote a midi scheduler based on the priority queues described in Guido's python book. My biggest problem was the latency - I tried a few mechanisms, including tk's 'after' and a mixture of long and short sleeps - the best was a tight loop polling for the next time event. Have a look at the source and ignore the midi stuff (will only run under SGI and Python 1.2-1.4 anyway) http://anusf.anu.edu.au/~sjr/midiplayer.py From mstenber at cc.Helsinki.FI Wed Apr 28 17:27:17 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 29 Apr 1999 00:27:17 +0300 Subject: Emacs' python-mode buggy? Message-ID: At least by my experiences the Emacs mode (at least, two versions I tried, 3.75 and whatever came with Python 1.5.2) seems to have tons of bugs; to be more precise, it seems to think a lot more of my code than should be is string (and therefore is green and indentation doesn't work). Funny thing is, it's colored properly when I load file but when I start editing some files' some parts, they turn green (comment-ish) and indentation starts to suck. Indentation being fairly neccessary feature for Python coding, is there some option I am missing or am I fucked? (read: forced to use vim or something) -Markus -- Microsoft is not the answer. Microsoft is the question. NO (or Linux) is the answer. From hew at hons.cs.usyd.edu.au Thu Apr 8 21:20:25 1999 From: hew at hons.cs.usyd.edu.au (Matthew Robert Gallagher) Date: Fri, 09 Apr 1999 11:20:25 +1000 Subject: simple dbm question Message-ID: <370D55D9.B75ECE47@hons.cs.usyd.edu.au> could someone please tell me why this dbm doesn't work import anydbm file = anydbm.open('hew') error appears as Traceback (innermost last): File "/usr/local/lib/python1.5/anydbm.py", line 54, in open return _mod.open(file, flag, mode) gdbm.error: (2, 'No such file or directory') thanks hew From ucvocnmb at somethingfunny.net Tue Apr 13 14:41:30 1999 From: ucvocnmb at somethingfunny.net (ucvocnmb at somethingfunny.net) Date: Tue, 13 Apr 1999 18:41:30 GMT Subject: $$$ Make Money While Surfing $$$ Message-ID: An unregistered copy of Newsgroup AutoPoster 95 was used to post this article! --- This e-mail is about a new company that has a completely mindblowing business model. They launched their service Monday, at Midnight eastern time, 9 pm Pacific. Without sounding corny or salesy, I want to encourage everyone to read this e-mail as soon as possible, because you can make a lot of money and the earlier you sign up, the more you can make. This is not a joke or a trick, it's not play money or worthless stock. It's cash. it is a new, free, Internet membership company. Because there is no money to put up front, no sales to make, no sales person contacting you, and no need to purchase anything, ther is NO RISK! This e-mail is long, because the concept needs explaining, but once you read it, you'll be stunned at how simple this is. We've all witnessed how the Internet is changing the rules of the game. Well a bunch of Stanford Computer Science PhDs are changing the way advertisers pay to reach consumers. Throughout time, advertisers have paid anyone who can aggregate a large quantity of people. TV Networks, Radio Stations, Magazine and Newspaper publishers, whoever can do it. The consumers, who advertisers are paying to reach, never get a dime of that money. These guys are changing that. They're essentially going to "unionize" consumers, so that consumers get paid by the advertisers, not the companies who aggregate those consumers. This idea is so simple that it's crazy. But it will work and anyone can sign up for free and make serious money. Please keep reading. I know you think I've lost my mind, but keep reading. This company is called AllAdvantage. (http://www.alladvantage.com/go.asp?refid=ATE-943) Here's how it works. It's completely free to participate. You don't have to buy anything, you don't have to sell anything, you don't have to change your web usage. If you go to their site and sign up, you'll have to enter you name, address, and the member number of who referred you. [That's me, Member ID# ATE-943] You'll get your own Member ID number, and you'll soon be sent a little file to download, which appears as a long thin window that'll be open below your web browser. In this window will be a standard online advertisement, a rectangular banner like the one's you see on most web sites. You can open it or close the window whenever you'd like, but for every hour you have that window open, you'll get $0.50. Up to 40 hours a month, so you could make $20 a month. Nice so far, but that's just the beginning...even better if you have a browser open most of the day at work. They are doing a pyramid payment plan to create a model where everyone is getting everyone else to sign up. Remember, it's completely free to participate, and you can always choose whether or not you want the window open. They'll pay you 10 cents for every hour that a person you refer has this window open. For anyone those people refer, you get a nickel for every hour. For everyone they refer, you get a nickel also, and so on for 4 levels. This will generate big money for people who get in early. AN EXAMPLE Let's say everyone has 10 people who joined entering their Member ID number. And let's also say everyone has this window open for 10 hours a month. You could easily make over $50,000 a month! Here's how. --You're on the web with this window open for 10 hours a month. 50 cents an hour is $5.00 --The ten people who were referred by you have it open for 10 hours a month, that's 100 user-hours. 10 cents per hour is $10.00 --Each of those 10 refer 10, that's 100 people, each on for 10 hours a month, that's 1000 user hours. 5 cents per hour is $50.00 --Each of those 100 refer 10, that's 1000 people, each on for 10 hours a month, that's 10,000 user hours. 5 cents per hour is $500.00 --Each of those 1000 refer 10, that's 10,000 people, each on for 10 hours a month, that's 100,000 user hours. 5 cents per hour is $5,000.00 --Each of those 10,000 refer 10, that's 100,000 people, each on for 10 hours a month, that's 1,000,000 user hours. 5 cents per hour is $50,000.00 That's it. $55,565.00 per month. Just for getting 10 people to sign up and put your number in as who referred them. And if you get more people, you make more money. There's no limit. They're counting on the fact that you'll get tons of people. There are over 50 million internet users, and many have multiple PCs. People who get in early, could literally retire. WHY ARE THEY DOING THIS? You're probably thinking that they'll have to pay out hundreds of millions of dollars to people, and your right, they will have to pay out hundreds of millions of dollars to consumers. But don't look at it from the macro level. Look at it from the micro level. It's so simple. AllAdvantage is paying 80 cents for every hour a user has this window open. (50 cents to the user, 10 cent to whoever referred them, 5 cents to the person who referred them, 5 cents to the person who referred them, 5 cents to the person who referred them, and 5 cents to the person who referred them). Every 20 seconds, a different ad rotates into the window, so 3 ads every minute, 180 ads every hour. If they can sell the 180 ads for more than 80 cents they're instantly profitable, and they'll be able to sell the ads for more. That's it. That's the whole thing. If they sell $10 million in advertising, they'll distribute $9 million or so to the users, and keep the rest. Everyone wins. Companies who rely on advertising spend a lot of money to attract an audience, and build and staff a product. AllAdvantage is just going to pay you as a valuable consumer and reward you for attracting an audience. A TV Network might put 90% of their ad revenue into programming and operations, and keep 10% as profits. This company will give 90% of their ad revenue to people who use them, and keep 10% for themselves. I told you it was simple. WHY WOULD YOU DO THIS? Why not? It's completely free, and you can make a lot of money, finally getting paid for advertisers to reach you. It doesn't effect or interrupt your time on the web, you still spend the same time surfing as you always have, the same way you always have, the same sites you always have. The only difference is that you can have this window open below your web browser if you want to, and you'll get paid for it. And if you tell a lot of people who also sign up, you'll get paid even more. Just sign up at http://www.alladvantage.com/go.asp?refid=ATE-943. THE SOONER THE BETTER No matter when you sign up for this, you'll make some extra money. But the people who sign up earliest, will make loads of money. People are probably going to get very creative about how to tell as many people as quickly as possible. Some people may rent out e-mail lists and send it out to thousands of people at a time, or mention it in chat rooms or user groups. Others are spreading the word on college campuses and internationally. Who knows? The more you sign up the more you make, and the more they make. IS THIS A PYRAMID SCEME? It's really not. It's kind of built on a similar premise, but it's totally free. There's no scheme! You don't pay anything or sell anything or spend your time any differently. In a pyramid scheme the last people in, lose. With this, the last person in still gets cash every month. Just not as much as the people who get in early. Just sign up, tell friends, and keep the window open if you want to. Advertisers will pay money to be in that window, and you'll get a very nice share of that money. You may have seen similar ideas where companies are giving away stock, or other things. This is different.. It's real. OK, the race is on. My Member ID number is ATE-943. Please go to http://www.alladvantage.com/go.asp?refid=ATE-943 and sign up. ID number. You'll be issued your own user number. Then cut and paste this email, changing the URL and the member ID number to your user number, and e-mail it to as many people as you can think of. Or mention this when you're talking to friends, or in a chat room, or where ever! The more people who sign up, the more advertising revenue AllAdvantage generates, and the more we all get paid. Don't ignore this because it's "too simple" or "too good to be true". If you have any questions, please just go to the site and check it out. It's self explanatory. I love the Internet! WWB http://www.alladvantage.com/go.asp?refid=ATE-943 All Advantage Member ID# ATE-943 From harms at mbnet.mb.ca Tue Apr 20 15:13:24 1999 From: harms at mbnet.mb.ca (SH) Date: Tue, 20 Apr 1999 19:13:24 GMT Subject: Multiple menu-bars and processes under Tk? Message-ID: Background: Newbie to programming, who chose Python on a Linux box as the road to enlightenment. Problem: Pharmacokinetic calculations of multiple drugs given to a patient during an Anesthetic should be displayed in a drugCollectionWindow for easy overview, simulations and controll of drug infusions. This drugCollectionWindow would be similair or analog to a filing cabinet drawer, with multiple "folders" or CalculatorInstances in place. Each "folder" can be viewed either closed or open. In the closed position, the appearance is similair to a horisontal menu-bar. One or more of the horisontal menubars can be expanded to reveal more detail of the CalculatorInstance. New menu-bars can be added on the fly. The order of these menu-bars can be changed by the user and are not simply a function of the sequence that new drugInstances were created. Each CalculatorInstance would represent a separate pharmacokinetic drug calculation process that continues regardless whether the "folder" is open or closed. (And possibly whether the drugCollectionWindow is open or closed as well.) A screenshot of the proposed interface: gasnet.med.yale.edu/lamdi/21_lamdi.html Questions: 1. Is there an existing Python/TK way of doing this under Linux ? I looked at the PMW, but I could not find an example. 2. Would you suggest to make a separate frame for each CalculatorInstance? Can new ones be added on the fly? 3. Let's say that the drugCollectionWindow is being closed. Is there a way that the calculations can be continued and tracking resumed upon opening another window? I.e. how can the program be designed that each of the CalculatorInstances is a separate process (less chance of them all crashing at the same time), but they can all be viewed and controlled from one single window? Thank you for your consideration. From Jack.Jansen at oratrix.com Tue Apr 13 06:10:33 1999 From: Jack.Jansen at oratrix.com (Jack Jansen) Date: Tue, 13 Apr 1999 12:10:33 +0200 Subject: Error loading 'binascii' References: <19990413032855.10759.qmail@nw179.netaddress.usa.net> Message-ID: <37131819.A8372E9E@oratrix.com> VICTOR KOLOSOV wrote: > % python > Python 1.5.1 (#2, Oct 12 1998, 15:11:45) [GCC 2.7.2.1] on freebsd3 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import binascii > Traceback (innermost last): > File "", line 1, in ? > ImportError: /usr/local/lib/python1.5/lib-dynload/binascii.so: Undefined > symbol "PyDict_SetItemString" > >>> Victor, could it be that you're trying to load a 1.5.2b-something dynamic module into a 1.5.1 Python? -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen at oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From da at ski.org Sat Apr 24 00:00:33 1999 From: da at ski.org (David Ascher) Date: Fri, 23 Apr 1999 21:00:33 -0700 (PDT) Subject: PyOpenGL -- Scrollbars? In-Reply-To: <7fq8se$5ti$1@nnrp1.dejanews.com> Message-ID: On Fri, 23 Apr 1999 mamcguire at my-dejanews.com wrote: > Hi All.. > > New to OpenGL so please bear with me. I'm trying to create an OpenGL port > in my application to display images--only way to show more than 256 colors > here on our SGIs. I've been having some difficulties: > > 1.) Any way to scroll via. scrollbars the OpenGL port? (like attaching > to a canvas but that didn't seem to do the trick) No -- but you can find out from the scrollbars what the shift in coordinates would be and adjust your drawing code in OpenGL to do the appropriate thing. I will be posting code in the next PyOpenGL release which might do a lot of what you need. Keep an eye out for it. --david From jkraai at murl.com Wed Apr 28 14:37:55 1999 From: jkraai at murl.com (jkraai at murl.com) Date: Wed, 28 Apr 1999 18:37:55 GMT Subject: Maximize Benefit when Purchasing Learning Python Message-ID: <00e401be91a6$4d581750$8b7125a6@cpda6686.mcit.com> How can I help whom when purchasing Python books? Haven't seen enough about this on the list lately & thought it should come up again. I see on python.org a link to Amazon. I've seen in the past that such links can generate a percentage to the linking page. If I buy via this link, will python.org get something from Amazon? If not, who does/can? If python.org can't get it, I'd like to see that Mark Lutz gets a little more compensation for his efforts. I'd rather direct the percentage to someone other than Amazon (or O'Reiley) if I can. (I have nothing against these fine companies.) Thanks, --jim From news at dorb.com Tue Apr 6 22:09:29 1999 From: news at dorb.com (Darrell) Date: Tue, 6 Apr 1999 22:09:29 -0400 Subject: Chaning instance methods References: Message-ID: Hope this helps. >>> class X: ... def y(self): ... print 'y1' ... >>> x=X() >>> x.y() y1 >>> def y2(self=x): ... print 'y2' ... >>> setattr(x,'y',y2) >>> x.y() y2 >>> From invalid.address at do.not.email Wed Apr 21 23:23:06 1999 From: invalid.address at do.not.email (guppy) Date: Thu, 22 Apr 1999 03:23:06 GMT Subject: Python Win References: <371E3B80.A6D5379@geocities.com> Message-ID: <371f956b.70694328@news.bctel.ca> On Wed, 21 Apr 1999 20:53:08 GMT, smoothasice at geocities.com wrote: >Ok i've been playing Python for a long time and I am just now wanting >to expand to learning the visual portion of it.(A.k.a Gui/MFC) but I >have found that there is a diffinite lack of information on the site and >I Haven't been able to find a book and I was wondering if there is >anyone out there that could help me out or perhaps direct me towards >where I could find info on it. Could try wxPython. -- MSpeak: in-no-va-tion, n. 1. extending or modifying existing standards in undocumented ways. 2. creating new, undocumented standards. --de-com-mod-it-ize, v. From barry at scottbb.demon.co.uk Fri Apr 9 15:44:41 1999 From: barry at scottbb.demon.co.uk (Barry Scott) Date: Fri, 9 Apr 1999 20:44:41 +0100 Subject: Embedding python question: PyRun_String only returns None not what I calculate References: <923433832.14002.0.nnrp-07.9e982a40@news.demon.co.uk> Message-ID: <923762066.17505.1.nnrp-03.9e982a40@news.demon.co.uk> G. David Kuhlman wrote in message ... >This is not the most convenient solution to your problem, but may >be useful in your case. > >When you embed Python in an application, the application often >exposes functions that are callable from Python scripts. You could >provide a function named setReturnValue(value), which when called, >passed a Python object (the value). The script calls this >function, and then, when it exits, the embedding application (the >caller of PyRun_String or PyRun_SimpleString) uses the Python value >saved by this function. I thought of that buts its not a help accept in a few cases. BArry From tim_one at email.msn.com Thu Apr 29 01:47:02 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 29 Apr 1999 01:47:02 -0400 Subject: Emacs' python-mode buggy? In-Reply-To: <7g8np4$kvf@chronicle.concentric.net> Message-ID: <000901be9203$b4c32e40$199e2299@tim> [Christopher Petrilli] > ... > WEll, I have noticed some problems with tripple-quoted strings on > occasion, but I see similar problems in other modes, so I THINK it's > something to do with how (x)emacs applie the font-lock-mode parameters. The Emacs language modes rely on heavy-duty functions written in C to do the bulk of their parsing. These Emacs parsing functions are configurable, but not quite configurable enough to capture all of Python's rules. In particular, triple-quoted strings aren't in their repertoire and can't be added, so given something like """ "Hi!" I'm a doc string """ Emacs "sees" it as a sequence of 4 strings with some crap in the middle: "" "\n " Hi! " I'm a doc string\n " "" elisp is too slow to do the character-at-a-time parsing that would be needed to fix cases like this, so-- like all other language modes --pymode settles for what it can get. AFAIK it should *never* screw up in the absence of triple-quoted strings, though, and you can help it make sense of those by pretending you're the Emacs C parsing function, using judicious backslash escapes until you stop confusing yourself . you-want-to-see-a-nightmare-try-perl-mode-ly y'rs - tim From rgruet at ina.fr Thu Apr 15 10:45:08 1999 From: rgruet at ina.fr (Richard GRUET) Date: Thu, 15 Apr 1999 15:45:08 +0100 Subject: 1.5.2 install problems on NT References: <3714D8FF.634655C5@ina.fr> <8DA968455duncanrcpcouk@news.rmplc.co.uk> Message-ID: <3715FB74.37EB984@ina.fr> Duncan Booth a ?crit : > Richard GRUET wrote in <3714D8FF.634655C5 at ina.fr>: > > >Tcl problems: > >--------------- > >...... > > > >This probably means that Tk wasn't installed properly. > > > > I had exactly that problem. I think it means that you upgraded an old Tcl > system but there are still copies of the old Tcl80.dll files lying around > somewhere and python is finding those in preference to the new ones. > Delete tcl80.dll from the \winnt\system32 directory or wherever they > are, and add the tcl bin directory (e.g. D:\Progra~1\Tcl\Bin) to the end of > your path in the control manager/system/environment settings. You're right, I have an old Tcl80.dll in my windows\system32 directory. I've removed it and added the Tcl\bin path to my Path variable. The old problem disappeared, but now when I launch for instance idle.pyw, I get an error: "The procedure entry point _Tcl_Gets could not be located in the dynamic linl library tcl80.dll". There is no other copy of Tcl80.dll anywhere on my computer. My Tcl80.dll is 362 Kb and dated 99/03/08; and it actually doesn't export any _Tcl_Gets procedure !! I precise that during install of the Python upgrade to 1.5.2, I've selected the Tcl upgrade. Do you know the reason for that problem ? Thanks Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From tismer at appliedbiometrics.com Mon Apr 19 14:00:12 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Mon, 19 Apr 1999 18:00:12 GMT Subject: Memory and swapping question References: <371B5ED8.A9C82170@appliedbiometrics.com> <199904191731.NAA03862@eric.cnri.reston.va.us> Message-ID: <371B6F2C.D48C63BE@appliedbiometrics.com> Guido van Rossum wrote: ... > > >>> x=range(big) > > >>> del x > > >>> > > > > On my system, creation takes about 10 times as for big/2, > > this is ok. But the del takes at least three times as long. > > Besides the fact that integers are never really disposed but > > build up a freelist, why is deletion so much slower now? > > Clearly in the second case you're exceeding your physical memory and > paging VM pages in and out of swap space? Yes, this was what I wanted to check out. > My guess: when creating the list you are allocating new VM pages, > which don't require any overhead until they need to be written, but > when deleting it, each page gets read from swap space, modified, and > then written back. Thus, you're I/O bound, and deleting requires more > I/O. Now I've got it. Right, since the structures almost fit main memory, there is a little but not too much swapping, just pushing other processes memory away. Then, all the integers are deallocated which means they are not deleted at all, but written again since they build up the free list. This ensures that my whole memory gets written to the disk. The same would happen if I'd read once through the list. But, not really. Doesn't this suggest to do memory deallocation from the end to the start of a list? I could imagine that the probability to touch something in memory is higher in this case. Did someone try this before? (before I waste time) thanks & cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 nathan at islanddata.com Fri Apr 30 12:32:46 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Fri, 30 Apr 1999 09:32:46 -0700 (PDT) Subject: while (a=b()) ... In-Reply-To: <372942B5.729506A6@inka.de> Message-ID: Just because the language allows it doesn't mean you have to program it that way. You could just as easily: fd = fopen("whatever", modus); if (fd == NULL) { ... which is just as clean as python. A little self-restraint should always be preferrable over new mandates. Yer talkin' prohibition to stop drunk driving. > I havn't any problems with that. Ok it makes C so terse and it's nice > just to write some stuff but I completly dislike the following. > > > if ((fd = fopen("whatever", modus)) == NULL)) > /* here is error handling */ ---------------------------------- Nathan Clegg nathan at islanddata.com From MHammond at skippinet.com.au Fri Apr 9 20:26:02 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 10 Apr 1999 10:26:02 +1000 Subject: DLL Prob Win32com References: Message-ID: <7em5q8$fh6$1@m2.c2.telstra-mm.net.au> I would appreciate if you could confirm or deny the following (just so I can get some data on this problem). Check your Windows\System directory for pywintypes15.dll and pythoncom15.dll. Using Windows Explorer, view the properties of these files, and there should be a "Version" tab. Check the build number in the version. My guess is that the version is not the 124 version - for some reason the installer neglected to overwrite the existing one. If this is true, you can use winzip to open win32all-124.exe and extract the files, and replace the ones in your system directory. It should then work. Please let me know either way if this was your problem? Mark. Bernhard Reiter wrote in message ... >Get strange errors, when using PythonWin (win32all-124) >with Python 1.5.2b2 or 1.5.2c1 on this Windows 95 machine here. >The installprogram said that > AXScript, Python Interpreter and Python Dictionary >couldn't be registered. Should be registered manually. > >How can I do that? > >When importing COM stuff, I get: >import pythoncom >Traceback (innermost last): File "", line 1, >in ?ImportError: >DLL load failed: A device attached to the system is not functioning. > >Reading documentation I know about possible old COM dlls as noted on >http://starship.python.net/crew/mhammond/bigpond/Downloads.html >but my error message seems to be different. > >That why I though I just ask again. :-) >(Python.org is not reachable from here right now, so I cannot >follow the link on Hammond's page to find out more about that DLLs.) >Is it save to install them? > > >Another thing: >The example in the architecture.html file seems to be out of >data. It should be: > from pywin.mfc import dialog > >(it is just not nice, if beginners stumble over on of the first examples.) > >Regards, > Bernhard From aa8vb at vislab.epa.gov Fri Apr 16 14:14:34 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 16 Apr 1999 18:14:34 GMT Subject: 1.5.2 broke IRIX module loading In-Reply-To: <7f7gpf$r4a$1@nnrp1.dejanews.com>; from srowland@biocryst.com on Fri, Apr 16, 1999 at 02:17:30PM +0000 References: <19990414110116.A1374923@vislab.epa.gov> <37161C26.C121CA1E@bioreason.com> <7f7gpf$r4a$1@nnrp1.dejanews.com> Message-ID: <19990416141434.A1545732@vislab.epa.gov> srowland at biocryst.com: |> Randall Hopper: |> > I built and tried 1.5.2 this morning, and it failed to load a module |> > that worked fine on 1.5.1. | |Does this failure occur for all modules including standard |Python Library modules or is it limited to some specialized module? The latter. It's an unresolved symbol issue that before didn't make any difference. The new dlopen flags basically force every symbol to resolve at link time whether they are used or not. Randall From l.szyster at ibm.net Wed Apr 21 10:08:18 1999 From: l.szyster at ibm.net (Laurent Szyster) Date: Wed, 21 Apr 1999 16:08:18 +0200 Subject: Kosovo database; Python speed References: <371DAAC2.D9046550@cs.utwente.nl> Message-ID: <371DDBD2.A37EB85E@ibm.net> Richard van de Stadt wrote: > > Suppose we were going to make a database to help Kosovars locate > their family members. This would probably result in hundreds of > thousands of records (say 1 record (file) per person). > > Would Python be fast enough to manage this data, make queries on > the data, or should compiled programs be used? Given the purpose I would suggest the following: 1. Design an XML document which represents the entry form refugees would fill in. Make it as complete as possible, since you don't know what kind of statistics you will have to produce from those forms. 2. Make a small web application that collects those documents and automatically store them in a Web as XML and HTML. Basically it would consist of a CGI upload form. 3. Use a web search engine to index the HTML web. What you end with is a effective way to collect data inputed off-line, to publish and search it worldwide. With no need to distribute software (everything happen on the web server). Later you may build your own database(s) from the web, once there is enough data and you know which statistics you want ;-) Then mySQL should prove to be good enough. Laurent -------------- next part -------------- A non-text attachment was scrubbed... Name: l.szyster.vcf Type: text/x-vcard Size: 254 bytes Desc: Card for Laurent Szyster URL: From fmwang at mediaone.net Fri Apr 16 17:26:44 1999 From: fmwang at mediaone.net (Fuming Wang) Date: Fri, 16 Apr 1999 17:26:44 -0400 Subject: Quick fix to add "+=" Message-ID: <3717AB14.2926AF76@mediaone.net> Any one knows a quick fix to add "+=" function. I am really getting tired of typing long names twice. Thanks a lot! Fuming From bwarsaw at cnri.reston.va.us Thu Apr 22 23:31:33 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 22 Apr 1999 23:31:33 -0400 (EDT) Subject: try vs. has_key() References: <371FC9A7.D3C77413@bioreason.com> Message-ID: <14111.59797.258298.283889@anthem.cnri.reston.va.us> >>>>> "AD" == Andrew Dalke writes: AD> Barry's results showed that if 5% of the cases or AD> less were "exceptional" then try/except is faster, otherwise, AD> use has_key. Alas, I cannot find the URL for that paper. (sorry, I lost the on-line version of the longer paper) I did the tests as part of my presentation at IPC6, against Python 1.5. While the numbers and exact trade-off might be different now, I believe the general recommendations are still valid. If you expect to get a hit on the key less than ~90% of the time, use has_key(). The one pattern where you might be better off with try/except would be if you're using a dictionary as a cache, where you'll only get a miss once. Note that since then, dictionaries grew a get() method, which will usually be better than both has_key() and try/except, depending on the application. E.g.: dict[counterkey] = dict.get(counterkey, 0) + 1 With only one dictionary access and no exceptions, this is about as fast as you're gonna get. -Barry From mrfusion at bigfoot.com Sat Apr 24 01:31:31 1999 From: mrfusion at bigfoot.com (mrfusion at bigfoot.com) Date: Sat, 24 Apr 1999 05:31:31 GMT Subject: GUI other than Tkinter Message-ID: <3721567f.1748033@news> Well, I've just about given up on EVER getting Tkinter to work on my Win98 machine. Is there any other GUI module that I can get that doesn't require TCL/TK to be installed on my machine? Isn't there something called GD? Thanks, Frustrated in Frisco..... From thooney at pk.highway.ne.jp Mon Apr 26 11:24:57 1999 From: thooney at pk.highway.ne.jp (Thooney Millennier) Date: Tue, 27 Apr 1999 00:24:57 +0900 Subject: To redirect stdin,out Message-ID: <37248549.6AD365AC@pk.highway.ne.jp> Hello,everyone. I want to redirect standard input and output to my C++ stream object and use something like PyRun_InteractiveLoop(). It seems we can redirect standard output by ... (quoted from http://www.python.org/doc/FAQ.html) class StdoutCatcher: def __init__(self): self.data = '' def write(self, stuff): self.data = self.data +stuff ToCppObject(self.data) #pass data to C++ object import sys sys.stdout = StdoutCatcher() print 'foo' I am at a loss how to redirect standard input. If you know any solutions,Please Help! Thanks for reading. Thooney Millennier From fredrik at pythonware.com Tue Apr 20 09:48:50 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Apr 1999 13:48:50 GMT Subject: Tkinter performance References: <371B4B39.8B78BC7A@foreman.ac.rwth-aachen.de> <19990420083759.A133486@vislab.epa.gov> Message-ID: <020701be8b34$8960b810$f29b12c2@pythonware.com> Randall Hopper wrote: > Note that the canvas seems to have respectable optimizations in place so > the less that is visible (e.g. the more you're zoomed in, the faster > redraws get. Also if only a partial area needs redrawn, it redraws it > fairly quickly relative to the full-expose frame rate. It's obvious > there's some optimization going on when you load to make drawing faster. some background: the canvas widget uses a straight-forward "damage/repair" model. changes to the canvas, and external events such as Expose, all update a single "dirty rectangle". they also register an idle task (after_idle) which redraws the canvas when you get back to the main loop. when it's time to redraw the canvas, the widget starts by allocating a pixmap (on X windows, this is an image memory stored on the display) with the same size as the dirty rectangle. it then loops over the canvas items, and redraws *all* items whose bounding box touch the dirty rectangle (this means that diagonal lines may be redrawn also if they don't actually cover the rectangle, but this is usually no big deal). finally, the widget copies the pixmap to the display (this last step is a very fast operation on all modern hardware), and releases the pixmap. a few additional notes: -- most Tk widgets use double-buffering to prevent flicker (this includes simple widgets like buttons and labels). there's no way to change this in current version of Tk. -- most Tk widgets also use delayed drawing. that is, they respond to modifications and external events by scheduling an idle task, not by updating the screen directly. there's no way to change this in current versions of Tk. -- the repeated allocation of pixmaps can seriously affect performance if you're animating stuff in a maximized window on a large truecolor display... (we all have 1800x1440 24-bit displays, don't we?) -- since the canvas uses a *single* dirty rectangle, you can get better performance in some situations by forcing updates. for example, if you're changing things in different parts of the canvas without returning to the main loop, adding explicit calls to update_idletasks() allows the canvas to update a few small rectangles, instead of a large one with many more objects. -- the text widget is a bit smarter than the canvas... -- guess I should mention uiToolkit here, but I'll leave that for another day... From tismer at appliedbiometrics.com Mon Apr 19 12:50:33 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Mon, 19 Apr 1999 16:50:33 GMT Subject: Memory and swapping question Message-ID: <371B5ED8.A9C82170@appliedbiometrics.com> Hi folks, due to a question which came up in the tutor list, I'd like to ask if somebody can explain the following: (This is true for Python 1.5 under Win98 and Suse Linux at least) Remember the size of your machine's main memory in MB. On my machine, this is 64. Start a fresh Python session with not many other tasks active at the same time. Now, divide the number by 16 and multiply by a million. >>> my_mb = 64 >>> big = my_mb / 16 * 1000000 >>> big 4000000 (16 is a good guess for one integer entry in a list: 4 bytes the pointer, 12 bytes the object). Now, create a list of numbers with the half of big, and count the seconds. Afterwards, delete the list and again count the seconds. >>> x=range(big/2) >>> del x >>> This will be quite fast, and the deletion will be somewhat faster than the creation. Now for the big WHY? Do the same with big. >>> x=range(big) >>> del x >>> On my system, creation takes about 10 times as for big/2, this is ok. But the del takes at least three times as long. Besides the fact that integers are never really disposed but build up a freelist, why is deletion so much slower now? cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 Fri Apr 30 02:24:01 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 30 Apr 1999 02:24:01 -0400 Subject: FP exception, core dump in Python 1.5.2 (Tim's doing ) In-Reply-To: <290419992258582791%pereira@research.att.com> Message-ID: <001401be92d2$09dcb800$5fa02299@tim> [Fernando Pereira] > Unfortunately, the Alpha implementation of IEEE FP does not handle > overflow gracefully. With the default C compilation flags, the code > generated cannot recover from an overflow to stuff an Inf in the > result, so the only thing the OS can do is to kill the process. > Alternatively, with appropriate flags (can't remember them from the top > of my head, had to deal with this 6 months ago), the C compiler adds > machine instructions to allow recovery from FP exceptions, including > storing Inf as a result of overflow. Mark (Favas) got around this by recompiling with -ieee. However, the Python code I posted still didn't work for him. Code that does is attached, and those with a passion for fp esoterica will be rolling on the floors with childlike glee, delighting in the extreme convolutions this required . > Unfortunately, FP performance in this mode is not nearly as good. None > of the other machines I use (SGI, Sun, Intel, Mac) have this problem. The Alpha is a silly chip <0.9 wink>. Denorms are a pain in the butt when designing fast FP HW, but overflowing to an infinity is trivial (consider that it's already got the logic to detect the overflow and signal an exception as a result -- all they need to do instead is pass on a fixed, simple bit pattern as the result). > On the other hand, none of them comes close to an Alpha in FP > performance (with the dafault `fast' compilation setting). Tradeoffs... Luckily, Python's FP performance is poor on every platform . the-alpha-is-a-cray-cpu-that-somehow-forgot-the-vectors-ly y'rs - tim """Module ieee: exports a few useful IEEE-754 constants and functions. PINF positive infinity MINF minus infinity NAN a generic quiet NaN PZERO positive zero MZERO minus zero isnan(x) Return true iff x is a NaN. """ def _make_inf(): x = 2.0 x2 = x * x i = 0 while i < 100 and x != x2: x = x2 x2 = x * x i = i + 1 if x != x2: raise ValueError("This machine's floats go on forever!") return x # NaN-testing. # # The usual method (x != x) doesn't work. # Python forces all comparisons thru a 3-outcome cmp protocol; unordered # isn't a possible outcome. The float cmp outcome is essentially defined # by this C expression (combining some cross-module implementation # details, and where px and py are pointers to C double): # px == py ? 0 : *px < *py ? -1 : *px > *py ? 1 : 0 # Comparing x to itself thus always yields 0 by the first clause, and so # x != x is never true. # If px and py point to distinct NaN objects, a strange thing happens: # 1. On scrupulous 754 implementations, *px < *py returns false, and so # does *px > *py. Python therefore returns 0, i.e. "equal"! # 2. On Pentium HW, an unordered outcome sets an otherwise-impossible # combination of condition codes, including both the "less than" and # "equal to" flags. Microsoft C generates naive code that accepts # the "less than" flag at face value, and so the *px < *py clause # returns true, and Python returns -1, i.e. "not equal". # So with a proper C 754 implementation Python returns the wrong result, # and under MS's improper 754 implementation Python yields the right # result -- both by accident. It's unclear who should be shot . # # Anyway, the point of all that was to convince you it's tricky getting # the right answer in a portable way! def isnan(x): """x -> true iff x is a NaN.""" # multiply by 1.0 to create a distinct object (x < x *always* # false in Python, due to object identity forcing equality) if x * 1.0 < x: # it's a NaN and this is MS C on a Pentium return 1 # Else it's non-NaN, or NaN on a non-MS+Pentium combo. # If it's non-NaN, then x == 1.0 and x == 2.0 can't both be true, # so we return false. If it is NaN, then assuming a good 754 C # implementation Python maps both unordered outcomes to true. return 1.0 == x == 2.0 PINF = _make_inf() MINF = -PINF NAN = PINF - PINF if not isnan(NAN): raise ValueError("This machine doesn't have NaNs, " "'overflows' to a finite number, " "suffers a novel way of implementing C comparisons, " "or is 754-conformant but is using " "a goofy rounding mode.") PZERO = 0.0 MZERO = -PZERO From phd at sun.med.ru Sat Apr 3 09:35:10 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Sat, 3 Apr 1999 14:35:10 GMT Subject: GadFly - MemoryError Message-ID: Hello! I tried to add yeat another database backend to my project "Bookmarks database". My database contains now about 3000 URLs, not too much, I think. I subclass by BookmarksParser to parse bookmarks.html into gadfly database and got a database of 500 Kbytes - very small database, I hope. Then I tried to find duplicates (there are duplicates). I ran the query: SELECT b1.rec_no, b2.rec_no, b1.URL FROM bookmarks b1, bookmarks b2 WHERE b1.URL = b2.URL AND b1.rec_no < b2.rec_no GadFly eats all memory and fails with MemoryError. Is it that gadfly really constructs multiplication of b1 and b2, thus getting 3000*3000 pairs? Or I just did something wrong? I tried to create indicies, but this was not of any help. BTW, where are indicies stored? After creating ones I didn't find additional files - only one file in the database changed. Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From jcosby at wolfenet.com Mon Apr 26 20:44:44 1999 From: jcosby at wolfenet.com (Jon Cosby) Date: Mon, 26 Apr 1999 17:44:44 -0700 Subject: CGI post method Message-ID: <7g31ah$hk2$1@sparky.wolfe.net> Can somebody tell me what's wrong with the following form tag:

My script isn't getting the text as input. Jon Cosby From Gaetan_Corneau at baan.com Wed Apr 14 14:17:21 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Wed, 14 Apr 1999 18:17:21 GMT Subject: what do you do with Python Message-ID: <816010E2456BD111A48700805FBBE2EEA63EFA@ex-quebec-u1.baan.com> Susan, To see what Python does, take a look at http://www.python.org If you want python job ads, take a look at http://www.dice.com There are many :) Ciao, ______________________________________________________ Gaetan Corneau Software Developer (System integration Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 654-1454 ext. 252 ______________________________________________________ "Profanity is the one language all programmers know best" > -----Original Message----- > From: susan e paolini [SMTP:tville at earthlink.net] > Sent: Wednesday, April 14, 1999 1:02 PM > To: python-list at cwi.nl > Subject: what do you do with Python > > I never see jobs with Python advertised so what is it that Python does? > Thanks for the advice > > From MHammond at skippinet.com.au Tue Apr 13 19:50:06 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 14 Apr 1999 09:50:06 +1000 Subject: Event in COM References: <3713C3A5.59CB36E5@bigfoot.com> Message-ID: <7f0l5u$cg5$1@m2.c2.telstra-mm.net.au> You can only get events from an OCX by using code from within Pythonwin. You can subclass from the generated code. You should check out the Pythonwin demos. Depending on the version you have, these will be either in "pywin\Demos" or "pywin\Demos\ocx". You should look for "ocxserialtest.py", "ocxtest.py", "webbrowser.py" and a later one "msoffice.py" Mark. Hoon Yoon wrote in message <3713C3A5.59CB36E5 at bigfoot.com>... >Hi, > > Can anyone show me some code or recommend me a book for this problem? >I look through the newsgroup and tried to read the source, but I cannot >figuire it out. (Thanks in Adv) > I am trying to write an event handler for a ocx control that receives >real time data. Obviously, I cannot retrieve anything without event >handelers. From bwarsaw at cnri.reston.va.us Fri Apr 16 15:49:30 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: 16 Apr 1999 15:49:30 -0400 Subject: restore sources from PYC [Q] References: <000101be879c$8aed0670$6eba0ac8@kuarajy.infosys.com.ar> <37177D8E.FF43BF65@bigfoot.com> <7f80ii$7m0@journal.concentric.net> Message-ID: <61r9pk1h2t.fsf@anthem.cnri.reston.va.us> >>>>> "CP" == Christopher Petrilli writes: CP> Seriously, this is a non-event that people use to spread FUD, CP> but it exists in all languages. The simplicity with which it CP> can be done changes, but it's never more than a freshman CP> college project. Which is why almost every binary license I've ever stayed awake to fully read includes text like "you may not decompile, disassemble, reverse-engineer" blah, blah, blah! :-) From aa8vb at vislab.epa.gov Fri Apr 30 08:40:34 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 30 Apr 1999 08:40:34 -0400 Subject: IDLE - How to change shell color Message-ID: <19990430084034.A783805@vislab.epa.gov> I have a monitor with good brightness, so its very hard to read the brightly colored text on a bright white background. How do I change the background color to something a little dimmer? (What is IDLE's equivalent to -xrm "*gui_resource: value"?) Thanks, Randall From phd at sun.med.ru Thu Apr 22 06:49:34 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Thu, 22 Apr 1999 14:49:34 +0400 (MSD) Subject: 1.5.2 Build Snag In-Reply-To: <43DT2.3365$56.12822@typhoon-sf.pbi.net> Message-ID: Hi! On Thu, 22 Apr 1999, Charles Y. Choi wrote: > In trying to build Python 1.5.2 on a Sparc Solaris 2.5.1 machine > using gcc 2.8.1 I get this: I had no problems building on exactly the same environment: >>> python Python 1.5.2 (#1, Apr 15 1999, 12:17:41) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From aa8vb at vislab.epa.gov Tue Apr 6 07:26:49 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 6 Apr 1999 11:26:49 GMT Subject: Possible regex match bug (re module) In-Reply-To: <000001be7fc9$bdb0fec0$65a22299@tim>; from Tim Peters on Mon, Apr 05, 1999 at 09:06:45PM -0400 References: <19990405084819.B802985@vislab.epa.gov> <000001be7fc9$bdb0fec0$65a22299@tim> Message-ID: <19990406072649.A867123@vislab.epa.gov> Tim Peters: |> Re doesn't handle named groups in alternative patterns like it |> seems it should. Given an alternative pattern with a particular group |> name in each, it only assigns the match if the group name matches the |> last alterative. | |re should raise an exception here -- it never intended to allow your |pattern. The deal is that symbolic group names are no more than that: |names for numbered groups. Like so: Thanks for the reply Tim. BTW, what's "re never intended...". A little AI at work in that module? :-) Well, to the point, it seems to me it would be more intuitive to have named groups in alternatives to be assigned strings only when an alternative is matched. It certainly yields more readable regexes: '(---(?P[^-]*)---)|(===(?P[^=]*)===)' r"([-=])\1\1(?P((?!\1).)*)\1\1\1" In which is it more apparent what the patterns are? Or even how many there are? Also, as I noted, I simplified this example a good bit so that the re behavior would be apparent. The original regex was a good bit more complex. Basically it was parsing fields from a spreadsheet text import file, where the fields are delimeted by commas, but fields can be single or double quoted so that commas and spaces can be embedded: 1,"Brown, Charlie",127.37,Hi The field match regex for this wouldn't be as simple to collapse into a single regex as you did above, and assuming it is possible, the result would have been very tough to decipher. I think we're also stuck in attempting to do this if the prefixes don't match the suffixes, and the named group matches aren't virtually identical. I'll post the regex later. I'm not at the box it's sitting on right now. BTW, what I ended up doing (again, continuing with the trivial example regex), was something like this: '(---(?P[^-]*)---)|(===(?P[^=]*)===)' str = id1 or id2 It just seemed to make since that I should be able to use "id" for both and just say "str = id". Thanks, Randall From moshez at math.huji.ac.il Wed Apr 7 03:53:15 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 7 Apr 1999 09:53:15 +0200 Subject: Python and the Singleton Pattern In-Reply-To: <7ee4si$sec$2@antiochus.ultra.net> References: <37048D53.5D1ED05F@lemburg.com> <7ee4si$sec$2@antiochus.ultra.net> Message-ID: On Tue, 6 Apr 1999, Neelakantan Krishnaswami wrote: > Isn't it possible to make use of Python's dynamism to turn any > class into a singleton class, as needed? The problem with that, of course, is that it makes inheritance from a singleton class impossible. How about: class MySingleton: class _my_dummy: pass _dummy=_my_dummy() _initialized=0 def __init__(self, ....): if initialized: return ...... def __getattr__(self, attr): return _dummy.__dict__[attr] def __setattr__(self, attr, val): _dummy.__dict__[attr]=val (I haven't tested it, but is seems like it should work) -- Moshe Zadka . QOTD: What fun to me! I'm not signing permanent. From saric at bph.ruhr-uni-bochum.de Thu Apr 29 04:06:27 1999 From: saric at bph.ruhr-uni-bochum.de (Marc Saric) Date: Thu, 29 Apr 1999 10:06:27 +0200 Subject: IDLE ! References: <371ADC8C.54C4CDBE@zipzap.ch> <3728126B.E35F4464@bph.ruhr-uni-bochum.de> Message-ID: <37281303.73BB69A4@bph.ruhr-uni-bochum.de> Boris Borcic wrote: > > I am having my first look at 1.5.2 and IDLE (on Win95). Had that look too, and found it a very nice and usefull tool: Some things I would like to see in an updated version: Cursor-up-and-down-history in the command shell, like in PTUI. Some key-bindings seem to be problematic (at least with a german keyboard; you cant press "CTRL+ [" for indentation for example). On Unix (SuSE 6.0 to be exact) I can't manage to get proper Windows-style copy and paste (CTRL+C, CTRL+V) (I don' like the Unix-key-bindungs, and therefore changed that to the windows-settings). Maybe it's just me who is too stupid, and someone may help me... -- Bye, Marc Saric Lehrstuhl fuer Biophysik Projektgruppe Theoretische Biophysik http://www.bph.ruhr-uni-bochum.de/ Ruhr-Universitaet Bochum Germany From moshez at math.huji.ac.il Sat Apr 24 13:41:16 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 24 Apr 1999 20:41:16 +0300 Subject: CSV Module Message-ID: I wonder if there is some standard module out there that can parse ``CSV'' files. Or, if anyone knows where the documentation of that format can be had. Here is my meek attempt at an answer. It is not certain to work, as I am not sure about the format -- I was guessing from looking at the file. -------------- begin python code ------------------ import re csv_entry=re.compile('(?:"[^"]*",)|(?:[^,]*,)') eol=re.compile('\015?\012') CSVError='csv.CSVError' def csv2list(line): line, n = eol.subn(',', line) if not n: raise CSVError, 'record not complete' ret=[] while 1: m=csv_entry.match(line) if not m: break len = m.end() field, line = line[:len], line[len:] if field[0]=='"': field=field[1:-2] else: field=field[:-1] ret.append(field) return ret ----------------- end python code ----------------------------- Thanks in advance. -- Moshe Zadka . QOTD: What fun to me! I'm not signing permanent. From clarence at silcom.com Mon Apr 12 03:03:13 1999 From: clarence at silcom.com (Clarence Gardner) Date: Mon, 12 Apr 1999 07:03:13 GMT Subject: forking + stdout = confusion Message-ID: I have a program running in Python 1.5.1 under FreeBSD 2.1.7. It happens to be a nph-type CGI program. Normally, it runs a report that can take quite a while, and I'm trying to add an option to delay the start. I defined this function: def LateShift(): OutputID = `os.getpid()` Child = os.fork() if Child: print 'content-type: text/plain' print print '''The program is waiting to run later. The output will be available with the id number of %s. ''' % OutputID sys.exit(0) sys.stdin.close() sys.stdout.close() sys.stderr.close() sys.stdout = open(os.path.join(SpoolDir, OutputID), 'w') sys.stderr = sys.stdout time.sleep(15) The idea is that, after forking, one of the processes will tell the user how to get the report output later, then exit, and the other will wait until some appropriate time and the run the report, with the output going to a file that normally goes to the web browser. The problem is that the browser's connection to the server is not being closed until the actual report is done (i.e., until the caller of this function exits). It seems to me that the three standard I/O streams are closed (which they are immediately in both processes), that should do it. Being an nph program, there should be no connection to the HTTP server (which is Apache), but just in case it was waiting for the child process to exit, I had the parent (Apache's child) exit immediately and its child do the waiting, but it works the same either way. I thought that maybe sys.stdout was using a dup()'ed copy of stdout, but I checked sys.stdout.fileno() and it was 1, so that doesn't seem to be the case. Can anyone hazard a guess (or see right off the top of his head) what's going on here? Thanks for any help. -- -=-=-=-=-=-=-=-= Clarence Gardner AvTel Communications Software Products and Services Division clarence at avtel.com From claird at Starbase.NeoSoft.COM Tue Apr 27 17:55:34 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 27 Apr 1999 16:55:34 -0500 Subject: Python and C References: <37243B44.AE6231AE@serop.abb.se> Message-ID: <7g5bom$g4n$1@Starbase.NeoSoft.COM> In article <37243B44.AE6231AE at serop.abb.se>, thstr wrote: >Hi > >I'm writing a function-test-program i C (no C++ involved). >It will parse header-files, extracting functions and types to some >information module. That module should be used for declaring variables >and calling functions. One module for every logically grouped set of >functions (like a class). >I would like to add some kind of command interpreter to which you can >type commands like "test functionA(arg1, arg2, ...)" and automatically >find a declaration for this function i above mentioned module. >For some reasons I'd like this interpreter in Python (like a static >module), linked with C at compile time, is this possible?? . . . It's more than possible. It's a well-established practice. comp.lang.python is the newsgroup where you'll find the best help on this topic. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From gmcm at hypernet.com Tue Apr 13 21:47:48 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 14 Apr 1999 01:47:48 GMT Subject: threads In-Reply-To: References: <1288080841-20523503@hypernet.com> Message-ID: <1288067824-21306356@hypernet.com> Eric Lee Green writes: > Ah. Okay. So Python is doing user-land threads and not Posix > (OS-level) threads? Nope. Those are OS threads. It's just that there's an interpreter lock, which only gets released every N byte-code instructions. Except, of course, that blocking operations (like socket I/O) will release the lock before doing their thing, then reacquire it to get the stuff back into Python. Check the archives of the thread-SIG for more than you could ever possibly want to know... > The difference between the two doesn't make a difference for my > application, but I'd be curious to know in case I ever want to run > this on an SMP machine (where only OS-level threads are schedulable > on multiple processors). Sorry. SMP won't get you any benefit at this stage. - Gordon From joe at strout.net Thu Apr 29 13:45:02 1999 From: joe at strout.net (Joe Strout) Date: Thu, 29 Apr 1999 10:45:02 -0700 Subject: GUI and creating GIF References: <7g7u2k$fr0$1@wanadoo.fr> Message-ID: [[ This message was both posted and mailed: see the "To," "Cc," and "Newsgroups" headers for details. ]] In article <7g7u2k$fr0$1 at wanadoo.fr>, Frank.Derville wrote: > I would like to > 1) create a GIF file under Python by drawing lines, text, ... I have looked > at Tk which can create bitmaps and photoimage but their seem to be no > possibility to transform a canvas into a photoimage. > 2) rotate some text on a canvas. You can do this with PIL (Python Imaging Library), but it's a little painful. You can also try PIDDLE, which is still under development -- but it can do this if you're brave. It's the piddlePIL backend that you'd want. See: http://www.strout.net/python/piddle/ for more info. Cheers, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From barry at scottbb.demon.co.uk Tue Apr 13 17:42:21 1999 From: barry at scottbb.demon.co.uk (Barry Scott) Date: Tue, 13 Apr 1999 22:42:21 +0100 Subject: Windows install has problems. Guido asked that I use this newsgroup to discus further Message-ID: <924039873.18221.0.nnrp-12.9e982a40@news.demon.co.uk> THis is Guido's reply to my comments that tcl80.dll is not found by IDLE on a default installation. > > > Running "IDLE (Python GUI)" reports that tcl80.dll is > > > not in my path then the shell comes up and I can > > > use Tkinter from the shell. > > > > > > Just in case this might be involved my Windows NT system > > > is on G: not C:. > > > > To solve this one, I think you'll have to edit your autoexec.bat to > > add the Tcl directory (containing that DLL) to the PATH variable. For > > various reasons I do not believe it is a good idea to copy the Tcl/Tk > > DLL files into the Python directory, nor do I think it is possible to > > reliably edit autoexec.bat in the installer. Instead, Tkinter.py > > imports a hack module, FixTk.py, which searches for tcl80.dll in a few > > places and then patches the PATH environment variable of the running > > process, but this is not failsafe either. :-( > > It would be nice if I did not have to edit the path manually. > Suggest that the install edits the path or you use the registry > to find the tcl80.dll image. I wish I could. The installer is very stupid. Windows sucks :-( > 1) The PATH is a registry key on NT. I don't have an autoexec.bat, > isn't for MS-DOS compatibility only these days? No, it's still needed on Windows 98 and 98. > The machines PATH is in > > HKEY_LOCAL_MACHINE\CurrentControlSet\Control\Session Manager\Environment > > 2a) I notice that HKEY_CLASSES_ROOT\TclShell\shell\open\command > contains a default value which is how to run wish. e.g. > > G:\PROGRA~1\Tcl\bin\wish80.exe "%1" > > tcl80.dll is in the same dir as wish80.exe. > > 2b) HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SharedDlls > lists all the shared files on the system. There is an value > "G:\Program Files\Tcl\bin\tcl80.dll" with the date 0x0000001 against it. > > 2c) HKEY_LOCAL_MACHINE\SOFTWARE\Scriptics\Tcl\8.0 > contains the default value field with the data G:\PROGRA~1\Tcl > > The DLL being in data + "\tcl80.dll". > > BArry Please take it up on the newsgroup -- there are many people with similar interests and more understanding of Windows than I have! --Guido van Rossum (home page: http://www.python.org/~guido/) From arcege at shore.net Tue Apr 6 10:24:53 1999 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 06 Apr 1999 14:24:53 GMT Subject: [IRC] Has anyone created a useful IRC module? References: Message-ID: Alexander Williams wrote: : Has anyone written a module in the spirit of telnetlib that would : facilitate writing an IRC bot that connects to the server and can : communicate with the core? Such a beast would definitely facilitate : writing decent Bots ... such as the one I'd like to put together. I have a preliminary IRC application framework. It has a working Tkinter and curses interface, but it was designed for just about any interface, including a bot. The API is the based on the IRC command set (not any one client) and the protocol. The URL is http://www.shore.net/~arcege/python/Pyirc-1.5.tar.gz. As, I said it is preliminary so there isn't much (any) documentation. But it should give you some ideas. And before you ask *wink*, no I didn't want just a single module. There are too many features that a bot/client will want to make just a "simple" module, IMO. -Arcege From sweeting at neuronet.com.my Sat Apr 24 13:14:10 1999 From: sweeting at neuronet.com.my (sweeting at neuronet.com.my) Date: Sat, 24 Apr 1999 17:14:10 GMT Subject: precompiled MySQL.pyd anyone ? (NT workstation) Message-ID: <7fsu50$bss$1@nnrp1.dejanews.com> Digging up a previous thread but asking anyone working on NT/Win32 : is there a precompiled MySQL.pyd anywhere ? Have checked the starship members' pages and python site without luck. Thank you, chas -------------------------------------------------------------- >Randy Trigg wrote: >> So my question is, does anyone have a pre-compiled win32 >> module for use with mxODBC that contains this DriverConnect >> function? (Judging from the source, it looks like a >> compile-time flag may determine whether your mxODBC pyd >> includes that function or not.) > >Randy, > >I have a copy of Nigel Head's (?) win32/MySQL dynamic >link libraries: libmySQL.dll and MySQL.pyd. I've used >them long enough to test access from NT to a database >running on Solaris ... and promptly fled back to the >safety of Unix. ;-) > >If the libraries aren't available elsewhere, I'll place >them on the starship. > >Best regards, > >Jeff Bauer >Rubicon, Inc. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From aa8vb at vislab.epa.gov Fri Apr 16 14:48:31 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 16 Apr 1999 18:48:31 GMT Subject: Tkinter - the app that wouldn't quit Message-ID: <19990416144831.A1548022@vislab.epa.gov> I'm writing a test wrapper for a dialog module that doesn't terminate the application. How can I exit the test program when the dialog is dismissed? Attached is a minimal version that illustrates the problem. When it self.destroy()'s itself, we're hung. mainloop() is still spinning. As you can see, I did try WM_DELETE_WINDOW. Thanks for any tips, Randall -------------- next part -------------- #!/usr/bin/env python import sys from Tkinter import * from ScrolledText import ScrolledText class CommandWindow(ScrolledText): def __init__(self, master=None, **cnf): apply(ScrolledText.__init__, (self, master), cnf) class CommandWindowDialog(Toplevel): def __init__(self, master=None, **cnf): apply(Toplevel.__init__, (self, master), cnf ) self.title( 'COMMAND OUTPUT' ) win = CommandWindow( self ) win.pack(expand=1, fill=X) btn = Button( self, text="Quit", command=self.destroy ) btn.pack() root = Tk() w = CommandWindowDialog( root ) w.protocol( 'WM_DELETE_WINDOW', sys.exit ) root.wm_withdraw() w.mainloop() From han.holl at pobox.com Fri Apr 9 14:38:32 1999 From: han.holl at pobox.com (Han Holl) Date: 9 Apr 1999 18:38:32 GMT Subject: simple dbm question References: <370D55D9.B75ECE47@hons.cs.usyd.edu.au> Message-ID: <370E4927.B5E03D52@pobox.com> > > Is there GDBM database "hew"? If not - you need to create it: > > import anydbm > file = anydbm.open('hew', 'w') > Actually, it should be: file = anydbm.open('hew', 'c') 'w' is for read/write an _existing_ database. (Of course, for ordinary file open, you need 'w'! ) Han From flight at mathi.uni-heidelberg.de Wed Apr 21 15:53:57 1999 From: flight at mathi.uni-heidelberg.de (Gregor Hoffleit) Date: 21 Apr 1999 19:53:57 GMT Subject: Buglet: egcs' name is too long for Python startup message Message-ID: A small annoyance: When I compile Python on a Debian system with egcc, the startup message is cut-off strangely: freefly:1> python Python 1.5.2 (#0, Apr 21 1999, 14:13:38) [GCC egcs-2.91.66 Debian GNU/Linux (egc on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> This is due to a short printf field in Python/getversion.c. Certainly Guido didn't think that some compiler might use a 54 char __VERSION__ like "egcs-2.91.66 Debian GNU/Linux (egcs-1.1.2 release)" :-) Therefore, the correct startup message would be: Python 1.5.2 (#0, Apr 21 1999, 14:49:42) [GCC egcs-2.91.66 Debian GNU/Linux (egcs-1.1.2 release)] on linux2 The following patch should do no harm to anything else, therefore I'd like to see it applied. Gregor --- python-1.5.2.orig/Python/getversion.c +++ python-1.5.2/Python/getversion.c @@ -39,7 +39,7 @@ Py_GetVersion() { static char version[100]; - sprintf(version, "%.10s (%.40s) %.40s", PY_VERSION, + sprintf(version, "%.10s (%.40s) %.80s", PY_VERSION, Py_GetBuildInfo(), Py_GetCompiler()); return version; } From tim_one at email.msn.com Sat Apr 17 13:08:39 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 17 Apr 1999 17:08:39 GMT Subject: sys.path.insert - how to make it global? In-Reply-To: <19990417113121.A1627033@vislab.epa.gov> References: <19990417113121.A1627033@vislab.epa.gov> Message-ID: <000301be88f4$f0096d60$ee9e2299@tim> [Stefan Franke] > sys.path *is* already global, though only accessible via the > sys module's namespace. Just give it a try. [Randall Hopper] > I'd already tried that. It's effect doesn't appear to be global: > > # Augment search path to pull in our C library wrappers > sys.path.insert( 0, '/home/mylogin/Wrappers' ) > > import MapFile > > This allows Python to find MapFile, but this doesn't allow MapFile to > import other modules in that same Wrappers directory. Randall, try posting a minimal set of failing code. This works for everyone else on the face of the earth, so the hope is that in trying to whittle your code down you'll come face to face with the demon who's clouding your mind . If MapFile is C code, it's more likely that you're writing C-level imports incorrectly. debugging-as-exorcism-ly y'rs - tim From gmcm at hypernet.com Wed Apr 7 15:10:45 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 7 Apr 1999 19:10:45 GMT Subject: File objects in extension module In-Reply-To: <370B9414.68053816@natinst.com> References: <370B9414.68053816@natinst.com> Message-ID: <1288610052-78686891@hypernet.com> Mike Steed writes: > > I am trying to use a file object passed from Python to a C extension > module (Windows 98). All the C runtime calls crash when I pass them > the FILE pointer (fwrite, fflush, etc.) > > The pointer I get back from PyFile_AsFile seems okay -- the struct > members have reasonable values, etc. > > I have seen the same behavior with MS VC++ (4.2) and egcs/mingw32 > (1.1.2), and with Python-1.5.1 and 1.5.2b2. > > What am I missing? You need the same build / link options as Python - specifically, you need to use the Multithreaded DLL for c runtime support. Otherwise you're trying to manipulate one file from 2 separate copies of the c runtime. Kablooie. - Gordon From wesc at rocketmail.com Fri Apr 16 18:43:36 1999 From: wesc at rocketmail.com (Wesley J. Chun) Date: Fri, 16 Apr 1999 22:43:36 GMT Subject: what do you do with Python References: <3714C9EA.86C0A4E@earthlink.net> <199904142107.XAA19293@axil.hvision.nl> Message-ID: <7f8eem$nak$1@nnrp1.dejanews.com> In article <199904142107.XAA19293 at axil.hvision.nl>, "Hans Nowak" wrote: > On 14 Apr 99, Ce'Nedra took her magical amulet and heard susan e paolini say: > > >I never see jobs with Python advertised so what is it that Python does? hi susan, yes, you have to still look somewhat *deep* to find jobs with "python* there, but they *are* there. contracting jobs as well as full-time. in fact, my group at work is hiring someone where python would be a good skill to have (although unfortunately not a full-time python job!) > > Hmm, seriously though, it's good for a lot of things. I'm sure that there are > lots of people around who can explain it better than I can, but I'll give it > a try anyway. Python is a highly flexible and dynamic language, useful for > programs ranging from simple scripts to large projects (for instance, the > Grail web browser). It's also very readable and thus maintainable. It > provides ways for object-oriented, procedural and even functional programming > (to some extent). If Python itself doesn't do what you want, you can extend > it in C, or possibly another language if your platform allows it. it is esp. great for when c/c++/java is too "heavy" to use, but shell scripts, etc., are too weak to handle. it's the perfect, "in-between" language! > > Myself, I'm using it for just about everything now. I wrote a Magic the > Gathering database & search engine, a Vedic astrology program, a board game, > a signature file generator, a spell checker, a card game, an ftp thingy, etc. > etc. and *lots* of little scripts to make life easier. stuff we have done with python... let's see, lots of scripts as mentioned above, software that manages all the dirty nightly tasks, statistics gathering programs, schedule-management stuff, hardware monitoring systems, web-based email systems :-), etc. some day soon, not only will you *see* python in the job descrip- tion, but it will also be "required." :*) -wesley ------------------------------------------------------------------------ "A computer never does what you want... only what you tell it." Wesley J. Chun -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From moshez at math.huji.ac.il Sat Apr 10 04:27:32 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Sat, 10 Apr 1999 10:27:32 +0200 Subject: Idiom for Getting Slices of a List Message-ID: Hi. I want a clean, and relatively efficient method to do the following: I have an array of length, n*m and I want to make it an array of length m, where each member is an array of length n. Example: n=2, m=3 [0, 1, 2, 3, 4, 5] ==> [[0, 1], [2, 3], [4, 5]] Anyone? -- Moshe Zadka . QOTD: What fun to me! I'm not signing permanent. From arcege at shore.net Wed Apr 28 14:28:52 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 28 Apr 1999 18:28:52 GMT Subject: Python implementation of tar References: <7ftjjl$tim$1@nnrp1.dejanews.com> Message-ID: frankmcgeough at my-dejanews.com wrote: : Does someone has a tar implementation written in Python? I don't know of one, but I just wrote this in the last 45 minutes or so. http://www.shore.net/~arcege/python/tar.py It only reads the tarfiles for now, and doesn't handle blocking (yet). -Arcege From aahz at netcom.com Mon Apr 19 10:38:04 1999 From: aahz at netcom.com (Aahz Maruch) Date: Mon, 19 Apr 1999 14:38:04 GMT Subject: Why no "=" in if? (was Re: Quick fix to add "+=") References: <3717EE20.41343593@mediaone.net> <371B2C29.594AE647@pop.vet.uu.nl> Message-ID: In article <371B2C29.594AE647 at pop.vet.uu.nl>, Martijn Faassen wrote: >Blake Winton wrote: > >[assignment in expression rears its head again] > >> Hitler! Hitler! Hitler! >> You're all Hitler! > >Hey, that doesn't work; intentional calling upon Nazis to end a thread >isn't support to work. I read it in a FAQ on this (I forget the name for >the 'law') just recently. :) Godwin's Law. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "You often don't really understand the problem until after the first time you implement a solution." - Eric S. Raymond From befletch at my-dejanews.com Thu Apr 29 20:13:31 1999 From: befletch at my-dejanews.com (befletch at my-dejanews.com) Date: Fri, 30 Apr 1999 00:13:31 GMT Subject: Trouble with proxies Message-ID: <7gasj8$g79$1@nnrp1.dejanews.com> Hello again everyone, I have tried all the suggestions people have sent me, and I have tried all the local debugging I could think of, but I still can't see the world from behind my proxy server. Can anyone find a possible solution to this? I've had to modify my URL lines with (colin-slash-slash) to get past DejaNews' Draconian posting filters: C:\>SET http_proxy=http(colin-slash-slash)10.187.200.230 C:\>"C:\Program Files\Python\python.exe" Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import urllib >>> u=urllib.urlopen('http(colin-slash-slash)www.yahoo.com') Traceback (innermost last): File "", line 1, in ? File "C:\Program Files\Python\Lib\urllib.py", line 59, in urlopen return _urlopener.open(url) File "C:\Program Files\Python\Lib\urllib.py", line 157, in open return getattr(self, name)(url) File "C:\Program Files\Python\Lib\urllib.py", line 266, in open_http errcode, errmsg, headers = h.getreply() File "C:\Program Files\Python\Lib\httplib.py", line 121, in getreply line = self.file.readline() File "C:\Program Files\Python\Lib\plat-win\socket.py", line 117, in readline new = self._sock.recv(self._rbufsize) IOError: [Errno socket error] (10054, 'winsock error') >>> I'm just out of ideas on how to solve this one. Thanks for any pointers, - Bruce -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From claird at Starbase.NeoSoft.COM Mon Apr 26 16:05:41 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 26 Apr 1999 15:05:41 -0500 Subject: GUI other than Tkinter References: <3721567f.1748033@news> <7g1a8h$fae$1@Starbase.NeoSoft.COM> Message-ID: <7g2gul$faf$1@Starbase.NeoSoft.COM> In article , Lloyd Zusman wrote: >claird at Starbase.NeoSoft.COM (Cameron Laird) writes: >> . >> . >> . >> > >I appreciate this useful list. You're welcome. Please be aware that I often know more than what appears in these documents; I might not get around to expressing it readably, though, until someone expresses a definite interest. When you ask particular questions, as you do below, sometimes I can unpack other notes of mine and update the documents to make them more useful. That's what I'm working to do now with the fltk reference. > >Also ... I noticed a refernce to `fltk' on this list, and I downloaded >and built it. However, I don't notice any Python support as part of >this distribution, and I'm wondering why `fltk' is on this "Python GUI" >list. Is there somewhere else where a Python interface to `fltk' >might exist? I've sent a copy of your question to a couple of people likely to know more. . . . -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From steve at blighty.com Sat Apr 24 10:52:51 1999 From: steve at blighty.com (Steve Atkins) Date: Sat, 24 Apr 1999 14:52:51 GMT Subject: wrapped around the axle on regexpressions and file searching References: <7frhe0$8g1$1@nnrp1.dejanews.com> <1287155028-45807148@hypernet.com> Message-ID: <372ed9f3.497562737@192.168.1.1> On Sat, 24 Apr 1999 15:21:03 GMT, "Gordon McMillan" wrote: >msrisney writes: >> here are my questions: 1. this prints out not only files with the >> file extensions ".log" but also any file name that has "log" in it's >> name. how would I rewrite to avoid?? > >In a regex, a "." is a wildcard character. If you want a literal "." >you need to escape it: > re.compile('\\.log') >or > re.compile(r'\.log') Wouldn't that be re.compile('\\.log$'), so as to avoid things like tree.log.jpg? doesn't-yet-grok-python-but-does-grok-regexps-ly y'rs Steve -- -- Steve Atkins -- steve at blighty.com From dacut at kanga.org Fri Apr 23 20:21:53 1999 From: dacut at kanga.org (David Cuthbert) Date: Fri, 23 Apr 1999 20:21:53 -0400 Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> Message-ID: <7fr2q8$4ne@world1.bellatlantic.net> William Tanksley wrote: > On Fri, 23 Apr 1999 06:08:07 +0900, Thooney Millennier wrote: > >2. stream class > > e.g. cout << "hello python."< > VERY bad idea. Bad even in C++. Out of curiosity, why is this a "VERY bad idea"? Personally, I really like the ideas behind the streams interface in C++ (though the implementations are usually somewhat lacking) and use Python file objects in the same manner. Am I doing something wrong? For that matter, I don't see how C++ streams are really any different than Python's file objects. To summarise: In C++: Base interface definition in {i,o}stream and streambuf. In Python: Base interface definition in file objects. In C++: New streams are defined by inheriting from {i,o}stream and streambuf, and by providing an implementation for the relevant methods. In Python: New streams are defined by providing methods with the same name and arguments as those for files. In C++: User-defined classes are streamed in/out by providing: ostream& operator << (ostream&, UserClass const&) istream& operator >> (istream&, UserClass&) methods/functions (or by using a persistence library). In Python: Classes are streamed in/out by providing a __str__() method or by using one of the (nicely built-in :-) persistence modules. The biggest difference that I can see is that C++ methods are static (i.e., checked and linked at compile time) vs. dynamic in Python (which is how you get away without inheriting from a file base class). But this isn't specific to streams. From spamfranke at bigfoot.de Tue Apr 20 16:17:18 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 20 Apr 1999 20:17:18 GMT Subject: Bit Arrays References: <7fi9i8$n2u$1@info3.fnal.gov> Message-ID: <371cdadc.73180347@news.omnilink.de> There is no bit or bit array type directly supported by Python. Are you in need of a memory-optimal solution? In that case I would suggest to use the array module. Otherwise it should be no problem using a list of lists. What about NumPy? Stefan On Tue, 20 Apr 1999 11:21:24 -0500, "Laura Paterno" wrote: >Hello all, > >I want to write a python program that has 26 Bit Arrays that each contain >1113 bits. Is there a structure in python that one can use to represent a >bit array? > >Laura Paterno > From aa8vb at vislab.epa.gov Tue Apr 27 07:47:49 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 27 Apr 1999 07:47:49 -0400 Subject: Problem while Installing.. In-Reply-To: <3720DF98.8CEC8D8F@aachen.heimat.de>; from Christian Scholz on Fri, Apr 23, 1999 at 09:01:13PM +0000 References: <3720DF98.8CEC8D8F@aachen.heimat.de> Message-ID: <19990427074749.B579158@vislab.epa.gov> Christian Scholz: |Hi everybody! | |I have a strange problem right now: | |'import exceptions' failed; use -v for traceback |Warning! Falling back to string-based exceptions |Fatal Python error: Cannot create string-based exceptions |IOT trap/Abort | |This I get when I try to install a new compiled Python 1.5.2 on my Linux |Box. It was working before and did this after I told configure to use |threads.. This message appears when the installation process wants to |start compiling the modules (compileall.py). I tried importing it then |by hand with my installed python which worked (The actual python |interpreter is installed before the compile process, right?) and I then |changed the Makefile to use the installed python which worked. But now |when I want to use Python it says the same. | |Any idea what happens? Yeah, been there done that :-) This may not be your problem, but see if $PYTHONPATH is set. If so, unset it until you finish building and installing python. It confuses the build (it overrides the configured system search path, so python can't find itself). Randall From cgw at fnal.gov Tue Apr 27 16:52:21 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Tue, 27 Apr 1999 20:52:21 GMT Subject: Long integers getting short shrift? Message-ID: <14118.9093.292465.438475@buffalo.fnal.gov> The functions Py_BuildValue and PyArg_ParseTuple don't seem to be listed in the index of the Python/C API documentation. They are only described in the Embedding and Extending docs. The "L" format code for Long integers is not described anywhere, AFAICT. I discovered it by reading source. It seems that if you are on a system without the "long long" type then the "L" format char is not available. The "L" format performs the same function as the "PyLong_FromLongLong" function, but there's no format character to get me the equivalent of "PyLong_FromLong". So, if I am calling a Python function from C which is expecting a long int as an arg, I am forced to write result = PyObject_CallFunction(func, "O", PyLong_FromLong(x)); which isn't terrible but isn't as nice as writing result = PyObject_CallFunction(func, "L", x); which I can only do if the system has "long long" and x is of that type... I'd like to be able to get regular C integers into Python long's. One reason for wanting this is that I often use long's in Python to hold what would be in C an "unsigned int" - since there's no "unsigned" type in Python, to represent a 32-bit value without sign-bit I use a Python long. From fdrake at cnri.reston.va.us Fri Apr 30 16:05:17 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Fri, 30 Apr 1999 20:05:17 GMT Subject: Python documentation updated! Message-ID: <14122.3325.631762.383828@weyr.cnri.reston.va.us> The documentation for Python 1.5.2 is now available. The online version is available at: http://www.python.org/doc/ Archives of the documentation in HTML, LaTeX, PDF, and PostScript formats are available at the same location, and may also be downloaded via FTP from: ftp://ftp.python.org/pub/python/doc/ If you have any questions or comments on the documentation, please send email to: python-docs at python.org Many modules have been documented (166 total!), including both new and old modules. There have been some additional refinements of the "look" of the online version, especially for those of you with CSS enabled in your Web browsers. There is also more extensive hyperlinking within the Python Library Reference for your convenience. A new document, "Documenting Python", is now included. Though still young, this is a useful reference for documentation contributors. It includes a great deal of information on the markup used for the Python documentation, as well as a discussion of where we'll go from here. Windows users: If you installed Python using the installer rather than by building from source, you can get the updated documentation by downloading the HTML archive and unpacking it into the "Doc" directory of your installation. Some re-organization of the documentation area on the Web site should make it easier to locate and download documentation. Thanks go out to all the individuals who have contributed sections or sent in comments and bug reports; this release of the documentation is substantially better thanks to the efforts of the Python community! Enjoy! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From cgw at fnal.gov Fri Apr 9 11:12:30 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Fri, 9 Apr 1999 15:12:30 GMT Subject: import from user input? In-Reply-To: <370E0F51.E1D33D6@appliedbiometrics.com> References: <816010E2456BD111A48700805FBBE2EEA63EB9@ex-quebec-u1.baan.com> <370E0F51.E1D33D6@appliedbiometrics.com> Message-ID: <14094.6366.328759.966352@buffalo.fnal.gov> Christian Tismer writes: > > import string > globals()[string.split(modname, ".")[0]] = __import__(modname) > > seems to do it better. > Why not just exec "import "+modname ? From janssen at parc.xerox.com Fri Apr 30 13:46:26 1999 From: janssen at parc.xerox.com (Bill Janssen) Date: Fri, 30 Apr 1999 17:46:26 GMT Subject: CORBA IDL AND SCRIPTS In-Reply-To: <3729E026.D9D29B1@ppllc.com> References: <3729E026.D9D29B1@ppllc.com> Message-ID: IDL support is available for both Python and Perl. That is, you can take your IDL specs and generate scripting-language support for the types and interfacees specified in that IDL. With systems like ILU, you can do the same sort of thing that SWIG does -- link your C (or other language) code with your Python, glued together automatically by code generated by ILU from your IDL. There's an example of doing this in the examples/multlang directory of the ILU source release. More ILU info at ftp://ftp.parc.xerox.com/pub/ilu/ilu.html. Bill From dcalvelo at lailp2pc2.univ-lille1.fr Mon Apr 26 09:13:40 1999 From: dcalvelo at lailp2pc2.univ-lille1.fr (Daniel Calvelo) Date: 26 Apr 1999 13:13:40 GMT Subject: HELP! NumPy (Graphics) and Linux References: <7fvpsh$l8e$1@nnrp1.dejanews.com> Message-ID: <7g1oq4$hi6$1@netserv.univ-lille1.fr> kelvin_chu at my-dejanews.com wrote: : Hi all; Hi, Kelvin. : I've had great success with EZplot and now want to move my code to Linux- : based platforms in my lab. I am having significant difficulties building : the Graphics portion of NumPy. : 0. I am running RedHat linux 5.2 : 1. I have installed Yorick in the cannonical place. : 2. Instead of libX11.a, I have a shared-object library, locatedin : /usr/X11R6/lib : When I do the build (python makethis.py), I receive the following error: : gcc -fpic -I/usr/local/lib/yorick/1.4/h -g -O2 : -I/usr/local/include/python1.5 -I/usr/local/include/python1.5 : -DHAVE_CONFIG_H -c ./Gist/Src/gistCmodule.c : ./Gist/Src/gistCmodule.c:75: arrayobject.h: No such file or directory : ./Gist/Src/gistCmodule.c:88: warning: `PyFPE_END_PROTECT' redefined : /usr/local/include/python1.5/pyfpe.h:169: warning: this is the location of : the previous definition : make: *** [gistCmodule.o] Error 1 This is a matter of gcc not finding arrayobject.h which is in ../Numerical/Include/ To uglily bypass this, try *after the failure* to do a make CC='gcc -I../Numerical/Include/' in the LLNL/Graphics/ directory This should override the CC variable of the Makefile written by makethis.py, so the make-generated command does find the .h : I suspect that I am going to run into multiple problems. There is a cryptic : statement in the README that indicates that I should do import_arrays() before : doing the build...where do I implement this? How much of this problem is : related to the shared object X libs? Up to now, unrelated. Look for trouble of the same kind in linking the final .so. IIRC, the only problem I had compiling this myself was the broken include. : Kelvin HTH, Daniel. From mkersey at metricom.com Tue Apr 6 17:35:06 1999 From: mkersey at metricom.com (Michael Kersey) Date: Tue, 06 Apr 1999 16:35:06 -0500 Subject: Python under ASP/MTS References: <3709C492.EED3BF03@parkey.com> Message-ID: <370A7E0A.3C8D79B9@metricom.com> If you instantiate the Python COM object at the application level, then it should be resident and available immediately. You could instantiate one or more of these COM objects at the Application level and keep them in a pool. This should eliminate any unloading/reloading problem. Allocate them to incoming ASP requests as needed. Good Luck, Michael D. Kersey Carol Parkey wrote: > We have to build something quickly for a client, but we have to fit > within their ASP/MTS mandate. > I have developed the first cut of a Python COM object which sits under > Microsoft Transaction Server, and can be called from an Active Server > Page in VBScript/JavaScript (thanks to Mark Hammond and all the FAQ > writers). The requirement is perfect for Python, since it has to > convert between user requests in XML and mainframe messages in some > hideous format, plus some other fiddly bits. > I am concerned, though, about whether I will experience performance > problems, with the interpreter being loaded and unloaded. Am I worrying > needlessly, or is there something I should be doing (like forcing the COM > object's reference count to never drop to zero)? > All suggestions gratefully received > > regards > > jp From arcege at shore.net Sun Apr 18 08:17:17 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sun, 18 Apr 1999 12:17:17 GMT Subject: Python-1.5.2 testing zlib References: Message-ID: Piers Lauder wrote: : My "make check" fails with a core dump after "test_zlib". : Runng that test by hand shows: : : s Python-1.5.2 ; ./python Lib/test/test_zlib.py : 0xe5c1a120 0x43b6aa94 : 0xbd602f7 0xbd602f7 : expecting Bad compression level : expecting Invalid initialization option : expecting Invalid initialization option : normal compression/decompression succeeded : compress/decompression obj succeeded : decompress with init options succeeded : decompressobj with init options succeeded : Bus error - core dumped : Adding a print at the start of the last loop: : : s Python-1.5.2 ; ./python Lib/test/test_zlib.py : 0xe5c1a120 0x43b6aa94 : 0xbd602f7 0xbd602f7 : expecting Bad compression level : expecting Invalid initialization option : expecting Invalid initialization option : normal compression/decompression succeeded : compress/decompression obj succeeded : decompress with init options succeeded : decompressobj with init options succeeded : Decompress: flush mode=0, level=0 : Memory fault - core dumped : Anyone else seen this? : (My system: : : s Python-1.5.2 ; uname -a : SunOS staff 5.6 Generic_105181-05 sun4u sparc SUNW,Ultra-2 : : s Python-1.5.2 ; ./python : Python 1.5.2 (#2, Apr 17 1999, 20:08:31) [GCC 2.8.1] on sunos5 : Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam : ) Yes, I found this on Solaris for Intel 2.6 as well. I hadn't gotten time to look into it more. For now, I've removed the zlib module from the build and continued on with my own system tests. I was thinking I just had a _very_ old version of libz (Oct 97). Since I didn't get time to download the libz, I couldn't test this on the AIX 4.2 systems at work. SunOS golem 5.6 Generic_105182-05 i86pc i386 i86pc Python 1.5.2 (#5, Apr 17 1999, 14:07:59) [GCC 2.7.2.2] on sunos5 -Arcege From oakley at channelpoint.com Thu Apr 22 14:38:06 1999 From: oakley at channelpoint.com (Bryan Oakley) Date: Thu, 22 Apr 1999 12:38:06 -0600 Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <371F11C2.3162025@ciril.fr> <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk> Message-ID: <371F6C8E.6631E8F1@channelpoint.com> Barry Margolin wrote: > > In article <4fv$ECA+JyH3EwbN at jessikat.demon.co.uk>, > Robin Becker wrote: > >I take this completely differently; least astonishment for me is if > >program X looks and behaves the same way no matter what keyboard, mouse > >and screen I'm using. As a 'user' of the program X it shouldn't matter > >what OS/WM is executing the code. I certainly don't want vi or emacs to > >be different on the mac why should I treat word or excel differently? > > I would be very surprised if Netscape on the Macintosh presented a > Windows-like user interface, rather than adopting the standard Macintosh > user interface. Most end users don't switch between platforms much, so > it's more important that all the programs on their system conform to their > expectations, than that a particular program work the same across different > platforms. I would have to agree with that statement. While there are those who think retaining the same look and feel across platforms is necessary, I would wager they are in the distinct minority. That's not to invalidate their position, but merely to put it in context. _Most_ users of software want a package to look and feel like the other packages on a given system. I hate, for example, the artsy (-fartsy) graphic programs that have some weird UI instead of a more traditional UI. On the other hand, to some degree this is application-dependent rather than user-dependent. For example, if I were to have a requirement to write a air traffic control program that had to run on BeOS, MacOS, NT and *nix, I would think there would be significant advantages to keeping it 100% identical across all platforms. So, to some degree it depends on the application, or the targeted user base. My point being, there's a need in the world for both models. Only, the model where applications should adhere to native conventions is (I'm guessing) far and away the most commonly expected model by most users. Which is why I think using native windows on Tk is a win -- it meets the needs of the majority (though definitely not all) of the users in the world. -- Bryan Oakley mailto:oakley at channelpoint.com ChannelPoint, Inc. http://purl.oclc.org/net/oakley From stephan at pcrm.win.tue.nl Fri Apr 23 04:48:07 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 23 Apr 1999 10:48:07 +0200 Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> Message-ID: Thooney Millennier writes: > Hello Everyone! > > I usually use C++ ,so I want to make programs like > I do using C++. Perhaps it would be better to learn how to these things in Python. > I don't figure out how to implement the followings > by Python. > If you know any solutions,Please Help! > > 1. #define statements > e.g. #define __PYTHON_INCLUDED__ This one is not needed in Python. Python's module mechanism, being considerably less brain-dead than C++'s excuse for a module system, can actually figure out itself whether a particular module has already been loaded (gasp!). > #define PYPROC(ARG) printf("%s",ARG) Even in C(++), I would solve this like: int pyproc(const char *arg) { return printf("%s", arg); } Why bother with the #define ? > 2. stream class > e.g. cout << "hello python."< 3. const variables > e.g. const int NOCHAGE=1; Sorry, no constants in Python. > 4. access to class's members using "::" > e.g. some_class::static_value > e.g. some_class::static_func(x) Well, you can do: class MyClass: static_value = 1 def static_func(x): print x and then: MyClass.static_value = 2 MyClass.static_func("hello") However, you get Strange Results(TM) if you access static_value and static_func() via an instance of MyClass. So I guess you better ignore this idiom. There are several other suggestions to simulate a "real" static member in Python. Read Dejanews for more info. However, the best thing to do is to just use some other idiom. For "static methods": If you really feel they belong to your class, you just create a method that ignores its "self" parameter. Otherwise, use a global function. For "static variables": Make them module-global. Of course, mutations should go via accessor functions (IMHO), so see "static methods" for more info. Greetings, Stephan From wtanksle at dolphin.openprojects.net Mon Apr 26 00:30:56 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Mon, 26 Apr 1999 04:30:56 GMT Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> <3720675C.FF7A9E99@gssec.bt.co.uk> Message-ID: On Fri, 23 Apr 1999 13:28:12 +0100, Alan Gauld wrote: >> >2. stream class >> > e.g. cout << "hello python."<> VERY bad idea. Bad even in C++. >Why? Very good question. Okay, so I like hyperbole. Thanks for calling me on it ;-). You're right. >Its one of the 'improvements' over C that allows >overridding of the << operator so that you can >write a class to any stream. Python does similar >with the _str_ mechanism but that doesn't allow >chaining of types together, which I do like in C++ >so why is it a bad idea? The reason I don't like it -- or why I didn't when I posted -- is that it's a yukky overloading. It makes a symbol mean something _entirely_ different from its usual meaning. The reason I'm eating my words is that although it may be bad to _design_ an operator function which behaves so badly, it's not always bad to use an already (badly) designed operator, so long as it's unambiguous. And whatever I might say about C++'s << operator, it's not ambiguous in practice. In other words, the designer(s) of C++ may have given the C++ world a bad example with the << op, but they sure did a good job choosing which operator to implement. >Since its off-topic for the group respond by email >if you want... Someone else asked, so I figger it's okay. Plus, since Python 2.0 is in its early requirements-gathering phase, maybe it wouldn't hurt to think about issues like this. >> In proper C++, your const will be contained inside a class (probably >> static) to keep it out of the global namespace. >Hopefully not. It should be contained within a C++ namespace. Okay, I'll bite. Why "hopefully not" a class? I know namespaces are new and cool, but classes seem to have done the job very well in the past. Have they been secretly causing bloat in our code all along ;-)? >Alan G. -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From trashcan at david-steuber.com Mon Apr 26 16:35:06 1999 From: trashcan at david-steuber.com (David Steuber) Date: 26 Apr 1999 16:35:06 -0400 Subject: Built-in Modules gl, GL for SGI IRIX References: <371FF2E3.7FB17EBD@bioreason.com> Message-ID: Andrew Dalke writes: -> However, since you don't have to worry about supporting SGI -> hardware from about 1996 or earlier, just use the PyOpenGL module -> -> http://starship.python.net/crew/da/PyOpenGL/ -> -> and ignore that section in the Python manual. Thanks for the link, Andrew. I'll let you guys know how it works out for me in the uncertain future. -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. Trying to be happy is like trying to build a machine for which the only specification is that it should run noiselessly. From neale-news at pobox.com Mon Apr 5 13:38:14 1999 From: neale-news at pobox.com (Neale Pickett) Date: 05 Apr 1999 11:38:14 -0600 Subject: [IRC] Has anyone created a useful IRC module? References: Message-ID: Alexander Williams writes: > Has anyone written a module in the spirit of telnetlib that would > facilitate writing an IRC bot that connects to the server and can > communicate with the core? Such a beast would definitely facilitate > writing decent Bots ... such as the one I'd like to put together. I have. Check out irc.py at http://www.pobox.com/~neale/src/net/ You might want to look at lovebot.tar.gz, too. I'll go ahead and put this up on the modules section of the web page. Neale From iam at not.you Tue Apr 20 15:11:36 1999 From: iam at not.you (Ken Power) Date: Tue, 20 Apr 1999 19:11:36 GMT Subject: pythonw.exe doesn't work Message-ID: <371cd0de.15002206@news.mysolution.com> Another windows problem. Python scripts won't run on my system (when I do the double-click scenario). I'm using Python 1.5.2 on win95b. The .py and .pyw extension is associated with pythonw.exe, but they don't appear to work. Also, double-clicking pythonw.exe doesn't accomplish anyhting. Any clues, hints? -------------------------------- Ken Power uncle_wiggly at bigfoot dot com get that? -------------------------------- From markus_kohler at hp.com Thu Apr 29 04:17:41 1999 From: markus_kohler at hp.com (Markus Kohler) Date: 29 Apr 1999 10:17:41 +0200 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: >>>>> "William" == William Tanksley writes: [deletia] William> Your data is correct (Python is slow for many things, William> slower than it needs to be), but your conclusion is William> wrong. Python isn't slow because its bytecode engine is William> slow; actually, although there's a lot of room for William> improvement, its bytecode engine is faster than many of William> the others out there. It seems to me that *most* of the byte code engine is ok. William> The reason it's slow is its runtime model. _Every_ William> function call requires a lookup in a hash table, just on William> the off-chance that the programmer changed the meaning of William> the function. That is the same in Smalltalk (squeak). You can build new classes and new methods at runtime and everything still works as expected. >> It seems to me that without a redesign of at least the bytecode >> for function calls python's speed will not take off. William> Bytecode won't help enough -- the whole calling model William> needs to be examined. Fortunately, that's one of the William> things the 2.0 design process will be looking at. Like William> you, I hope that they consider Smalltalk as an example. I hope so too. My point was exactly that the bytecode for doing the function call seems to be the problem. William> And Oberon (SlimBinaries), and Eiffel (typing and general William> compile-time error catching), and ... OPTIONAL types would be cool. Markus -- Markus Kohler mailto:markus_kohler at hp.com From alex at somewhere.round.here Fri Apr 16 10:01:20 1999 From: alex at somewhere.round.here (Alex) Date: 16 Apr 1999 10:01:20 -0400 Subject: binary References: <37171BD5.87CFA015@efes.net.tr> Message-ID: There were a whole lot of solutions to this posted here a little while ago. I'm not sure if I'm duplicating an earlier method. Anyway, this might be a bit slow, but it seems to work for any base: ************************************************************** import math chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' def base_repr (number, base = 2, padding = 0): if number < base: \ return (padding - 1) * chars [0] + chars [int (number)] max_exponent = int (math.log (number)/math.log (base)) max_power = long (base) ** max_exponent lead_digit = int (number/max_power) return chars [lead_digit] + \ base_repr (number - max_power * lead_digit, base, \ max (padding - 1, max_exponent)) print map (base_repr, 17 * [17], range (2, 19)) ************************************************************** The result is ['10001', '122', '101', '32', '25', '23', '21', '18', '17', \ '16', '15', '14', '13', '12', '11', '10', 'H'] If you just want binary, there is a slightly slicker way: ************************************************************** import math, operator, string def binary_repr (number, max_length = 32): # This will only work reliably for relatively small numbers. # Increase the value of max_length if you think you're going # to use long integers assert number < 2L << max_length shifts = map (operator.rshift, max_length * [number], \ range (max_length - 1, -1, -1)) digits = map (operator.mod, shifts, max_length * [2]) if not digits.count (1): return 0 digits = digits [digits.index (1):] return string.join (map (repr, digits), '') print binary_repr (17) ************************************************************** See you. Alex. From banderson at boi.hp.com Mon Apr 5 14:30:56 1999 From: banderson at boi.hp.com (Bill Anderson) Date: Mon, 05 Apr 1999 18:30:56 +0000 Subject: Python books References: <7dtsa4$b6p$1@nnrp1.dejanews.com> <7e0t19$1de$1@nnrp1.dejanews.com> <7e2vol$8c6$1@news1.rmi.net> Message-ID: <37090160.C52377BA@boi.hp.com> Mark Lutz wrote: > > Wesley J. Chun wrote in message <7e0t19$1de$1 at nnrp1.dejanews.com>... > >o'reilly appears to be very hesitant to publish more python > >books in a timely fashion. this "learning python" was slated > >for release last fall, then it became march, and now it's april. > > > > [...] > >same say that they want to see how "learning" does before mak- > >ing any more committments to python. due to their lack of en- > >thusiasm, i am looking for other publishers who are more inter- > >ested in getting more python books on the market. > > Hold on a minute, friend. > > Next week, O'Reilly will begin shipping the first major > Python book to hit the shelves since 1996 (Learning Python). > That will make 3 Python books in their catalog--3 times as > many as any other publisher. So what other publisher has a Python book out, and what is the name of it? -- Bill Anderson Linux Administrator MCS-Boise (ARC) banderson at boi.hp.com My opinions are just that; _my_ opinions. From moshez at math.huji.ac.il Fri Apr 16 08:40:41 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Fri, 16 Apr 1999 15:40:41 +0300 Subject: Word Counting -- A Novell Approach Message-ID: There was a thread here about word counting, when reading in arbitary chunks, instead of line-by-line. I have a friend who continually reminds me "In Rome, do as the Romans", so it seems to me the right way is to count with an object you 'feed()' data into, like other non-line-based Python parsers (XML, HTML, etc.). So I wrote a small word counting class, whose interface is: * feed: Feed some data into the counter. * flush: Force a word break. The next feed will force new words. This is useful, for example, when counting words in multiple files, to make sure words are not concatenated across files. * items: Will return a list of (word, count) pairs. (This is an excerpt from the documentation) I will happily mail this class to anyone who wants. -- Moshe Zadka . QOTD: What fun to me! I'm not signing permanent. From SSTirlin at holnam.com Thu Apr 29 09:26:18 1999 From: SSTirlin at holnam.com (Scott Stirling) Date: Thu, 29 Apr 1999 09:26:18 -0400 Subject: HTML "sanitizer" in Python Message-ID: Thanks, Mark! That is a very cool tool. It will make a nice HTML editor for me here at work. The only feature I immediately saw lacking (but maybe I missed it--I just downloaded it this AM) is the ability to record macros. For my Excel problem, I really need the ability to batch process the HTML files because there are 14 of them. Anyway, this is a great reference. Thank you again. Scott >>> "Mark Nottingham" 04/28 6:17 PM >>> There's a better (albeit non-Python) way. Check out http://www.w3.org/People/Raggett/tidy/ Tidy will do wonderful things in terms of making HTML compliant with the spec (closing tags, cleaning up the crud that Word makes, etc.) As a big bonus, it will remove all tags, etc, and replace them with CSS1 style sheets. Wow. It's C, and is also available with a windows GUI (HTML-Kit) that makes a pretty good HTML editor as well. On Unix, it's a command line utility, so you can use it (clumsily) from a Python program. I suppose an extension could also be written; will look into this (or if anyone does it, please tell me!) __________________________________________________________________ | Scott M. Stirling | | Visit the HOLNAM Year 2000 Web Site: http://web/y2k | | Keane - Holnam Year 2000 Project | | Office: 734/529-2411 ext. 2327 fax: 734/529-5066 email: sstirlin at holnam.com | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From bwinton at tor.dhs.org Mon Apr 5 21:11:32 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Tue, 06 Apr 1999 01:11:32 GMT Subject: help References: <7e1fr0$6cio$1@titan.xtra.co.nz> Message-ID: On Mon, 05 Apr 1999 04:39:21 GMT, SH wrote: >In article , I wrote: >> On Fri, 2 Apr 1999 15:58:52 +1200, nfbb wrote: >> >I'm running Windows 98 and was wondering what the best program for >> >writing python Source code is under this operating system? >> IDLE (Guido's IDE) is also up on my favourites list. >Where do you find the latest IDLE? Searches on the web are not >helpful, and on the Python.org site the search points to the CVS >directories? It comes with the latest Python source release, available from the usual places. Later, Blake. From eugened at istar.ca Sat Apr 24 02:22:21 1999 From: eugened at istar.ca (Eugene Dragoev) Date: Sat, 24 Apr 1999 02:22:21 -0400 Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <7fmv24$agu$1@m1.cs.man.ac.uk> Message-ID: <3721631D.8642F0AA@istar.ca> Where could I find more info about TkGS? "Donal K. Fellows" wrote: > > In article <371E964F.C531C2A at istar.ca>, > Eugene Dragoev wrote: > > Is there going to be any Tk implementation that will continue using > > lightweight components? > > No current Tk implementation uses lightweight components. All are > heavy (which actually merely means that they have their own window > each.) One of the things that might come out of the TkGS work at some > point may be lightweight components. There are other issues being > resolved there first though... From tismer at appliedbiometrics.com Fri Apr 23 08:36:56 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 23 Apr 1999 14:36:56 +0200 Subject: Pointers to variables References: <19990422121403.A279051@vislab.epa.gov> <19990423080721.A344578@vislab.epa.gov> Message-ID: <37206968.C1E548BD@appliedbiometrics.com> Randall Hopper wrote: ... [you are beginning to understand the concept] ... > but this one doesn't: > > (3) min = 0 > max = 0 > for ( var, val ) in [( min, 1 ), ( max, 100 )]: > var = val > > So basically this is just a little asymmetry in the language. Putting a > variable in a list/tuple (valueof(var)) performs a shallow copy rather than > a deep copy. > > Does this sound about right? Not completely. There is no asymmetry if you take the right position. I'll try to adjust jour sight a little :-) There is sometimes a little confusion since people talk of Python, passing "variables" by "reference", which is wrong. Python passes objects by reference, but no variables at all, in the sense of a "C" variable. (You might find some more about this in the tutor archive). It is better to think of labels, sticked to boxes which are the objects. By "min = 0", you stick the label "min" to the object "0". By "var = val", you pick the object which has the label "val", and stick label "var" to it as well. While passign the values around between the lables, Python indeed uses reverences to the objects, although in this example, it makes no difference, since the values of unchangeable (immutable) objects like numbers cannot be changed. You will recognze the difference, if you use different objects like lists. In a = [1, 2, 3] I've put a label "a" to a list object with three numbers. Now I can use a as a handle to the list, it gives me a reference to the object which I now can change, like a[1] = "howdy", which reads now >>> a [1, 'howdy', 3] >>> Now you will understand that I did not change the "variable a". I also did not change the "label a", but I modified the list object where a was my handle. while 1: if vanished("asymmetry"): break think_again() #:-) Hope this helps - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 aahz at netcom.com Sat Apr 17 10:30:04 1999 From: aahz at netcom.com (Aahz Maruch) Date: Sat, 17 Apr 1999 14:30:04 GMT Subject: Why no "=" in if? (was Re: Quick fix to add "+=") References: <3717EE20.41343593@mediaone.net> <000701be888f$12fe2920$ee9e2299@tim> Message-ID: In article , John W. Baxter wrote: >In article , aahz at netcom.com (Aahz Maruch) wrote: >> >> Why doesn't Guido get off his duff and fix this?????????! > >Because it's not broken. Yes, it is. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Sometimes, you're not just out of left field, you're coming in all the way from outer space. From arcege at shore.net Wed Apr 28 11:57:28 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 28 Apr 1999 15:57:28 GMT Subject: 'sourcing' Python scripts? References: <372713AD.6ABA444@cern.ch> Message-ID: Haimo G. Zobernig wrote: : Dear Python experts, : this might be a unix rather than a Python problem, but I need to set : environment variables from a Python program *in the parent process* : that is running the Python script ( a la os.environ['BAR'] = 'foo' ). : In other words, I want to achieve the equivalent of 'sourcing' the : Python script. Can this be done? Even better would be a solution that : also works on the various WinAbominations... (well, NT at least) : Haimo G. Zobernig : Haimo.Zobernig at cern.ch Are both programs written in Python? If so, then you could make something like: def environ_save(filename, environ): file = open(filename, 'w') lines = [ 'environ = {}\n' ] for (key, value) in environ.items(): lines.append('environ[%s] = %s\n' % (repr(key), repr(value))) open(filename, 'w').writelines(lines) def environ_load(filename, other_environ): execfile(filename) # this creates a local variable called 'environ' for (key, value) in environ.items(): other_environ[key] = value Call "environ_save" from the child process, and "environ_load" from the parent. Also, this relies on the data being reproducable from repr(). Which, if it is from os.environ, it should be. :) Now, I haven't tested this, but I don't see any problems. A pickle solution can be left to the reader. -Arcege From basv at sara.nl Tue Apr 27 07:52:54 1999 From: basv at sara.nl (basv at sara.nl) Date: Tue, 27 Apr 1999 11:52:54 GMT Subject: Trouble with httplib and IRIX References: <7g219p$hvb$1@nnrp1.dejanews.com> <3724CF13.C4680904@bioreason.com> <7g3sgs$87n$1@nnrp1.dejanews.com> Message-ID: <7g48el$hjt$1@nnrp1.dejanews.com> In article <7g3sgs$87n$1 at nnrp1.dejanews.com>, basv at sara.nl wrote: > In article <3724CF13.C4680904 at bioreason.com>, > Andrew Dalke wrote: > > basv at sara.nl said: > > > I'm running python 1.5.2 and running it on IRIX 6.5.3 systems. > > > ... > > > I have the following problem when i'm trying to connect to an > > > non-existing machine the program hangs forever. > > > > I don't get that behaviour using 1.5.2c1 or 1.5.1 on either of > > our 6.5.2m machines. This is a bug in 6.5.3, ping and telnet also hangs forever. I just phoned SGI and they said that it will be fixed in 6.5.4 ******************************************************************** * * * Bas van der Vlies e-mail: basv at sara.nl * * SARA - Academic Computing Services phone: +31 20 592 8012 * * Kruislaan 415 fax: +31 20 6683167 * * 1098 SJ Amsterdam * * * ******************************************************************** -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From houseofmelange.bassment at teleweb.at Thu Apr 22 14:41:45 1999 From: houseofmelange.bassment at teleweb.at (Alexander M. Dietrich) Date: Thu, 22 Apr 1999 18:41:45 GMT Subject: What is it ? How can I learn it ? Where should I start ? What can you do with it ? Message-ID: I just heard about it, it's required for a job I will eventually apply to. I have C programming experience . Is that a plus ? From dave at zeus.hud.ac.uk Wed Apr 7 07:21:36 1999 From: dave at zeus.hud.ac.uk (Dave Dench) Date: Wed, 7 Apr 1999 11:21:36 GMT Subject: Confused by COM Message-ID: <199904071121.MAA16569@brahms.scom> Dear All, on this thread, perhaps someone can explain the following. I am starting to play with COM. I have read the tutorial and looked at the demos and am now playing with Andy Robinson's SpamServer/SpamCan demo. Everything seems fine on the face of it. The standalone python part works, the COM facilities seem to work. BUT after uninstalling the SpamServer and the SpamCan components, I still see an entry for SpamCan using the COM Browser that comes with pythonwin. It appears to be the correct UUID as the one that I install, as after installing there are only the two entries under the PythonServer entry, and the UUID tallys. I don't understand why the SpamServer uninstalls correctly(?) but the SpamCan doesn't. Similarly using the Registry Editor that comes with Nortons, I can remove the SpamCan entry but still see it using the pythonwin COM browser? Thanks, David ________________________________________________________________________________ ************************************************ * David Dench * * The University of Huddersfield , UK * * Tel: 01484 472083 * * email: d.j.dench at hud.ac.uk * ************************************************ ________________________________________________________________________________ From call at 83331002.wong Sat Apr 24 06:55:50 1999 From: call at 83331002.wong (Mr Wong) Date: 24 Apr 1999 10:55:50 GMT Subject: make your first $1 million. Message-ID: <7fs7vm$pga$11125@hfc.pacific.net.hk> HANG CHEONG INTERNATIONAL A new successful marketing tactic to increase your sales : Do you always have problems to find channels to increase your sales? The advertise in newspapers, magazines and doing some Direct Mailing, but still can not achieve you goal, so why still dumping your money to a media that could not help your sales and not using the most efficient and modern way of selling stragies E-MAIL.Now many big companies are using this, because it is economical, fast and efficient, and the other way is selling by fax through the internets, and the result are remarkable. According to report pointed out that the ratio of internet selling is 1,000:1.5 that is 20,000,000 names x 0.0015 = 30,000. These 30,000 clients will buy from you and if your net profit is $50 that is to say your total profit is: HK$50 x 30,000 = HK$1,500,000. 1.5 Million Dollars !!! How to make your first 1 million in your life, now it is quite possible that you can make your first 1 million within one month. But the thing is ??Are you selling the right products, through the right media.?? *************************************************************************** A full set of sales tool with 20 million of client??s names will make you a SUPER SALES. A professional mail software (no need to go through any ISP Mail Server,making your computer as the professional Mail Server, its super speed. Easy to use. * 500,000 E-mail addresses in Hong Kong * 1,000,000 E-mail address in Taiwan * 20,000,000 E-mail address in the World (latest revised on 10th April 1999.) * A free revision one year (around 100,000 every month) * Free of charge of 200,000 names of fax addresses in Hong Kong for 1999. * Door to door installation * Technical support * software replacement. * Using CD-R dish and CD-AutoRun Menu. (Only HK$680 for one full set) for unlimited use. HK$680 is very small amount, you may not need it now but you will sure to use it when you have every thing ready. *************************************************************************** If you need any E-mail address, call us any time!! *************************************************************************** Don??t miss this chance, you may make lots of money with this new marketing technique. Booking Hotline : (852) 8333 1002 Mr Wong 2ND FL.FRONT BLOCK HING YIP HOUSE.24,SAI YEE ST,HK _________________________________________________________________________________________ ???????? HANG CHEONG INTERNATIONAL ?s???\???????P ?z?O?_?g?`???p?????i???P???D??????? ?Z?n????,???x?s?i???l?H???? (Direct Mail)?O?_?w?g?L?k?F???z?w?????s?i???G? ?P???N?????M???????O?b?????????????????P?????W,?????z?????t?M?s?n???k?? ???N?{?????s?i???P????.?????s?i???P???????O???h?H?O???O???s?i?O???M?s?i ???q????????????,?]???\?h?j???q?g?L?f?V?????????w?????????g?????t?B???G ???n??"?????????????s?i???P ?? ???u?s?i???P" ?]?N?O--?????????????o?e?s?i, ?]?????T???g?????t???B?Q???????I ?g???i???????????P???C1000?? 1.5 . ???Y,20000000?U???W???? 0.0015????30000 ?]?N?O?T?U???????|???z?R,?p?z???f?~???b?Q??50??,???A?i???? 50??30000??1500000,?@?????Q?U!!!!! ?????H???????@???@???U?A?n?p????,?{?b?N???i???@?????N???@???U. ?Q?????h???????g?P???~????.?u?n???????~.???P?????S???D. ________________________________________________________________________________ ???M???P?u???X??,2000?U??????E-MAIL?H?c?a?}.???A????????SUPER SALES. ?M?~???t?o?q?l?n??.(?????n?z?L????ISP??MAIL SERVER,???A???q?????M?~MAIL SERVER ?t???W??).????????. *???????Q?U??????E-MAIL?H?c?a?}. *?x?W?@???U??????E-MAIL?H?c?a?}. *?@???G?d?U??????E-MAIL?H?c?a?}. (???????s??????99?~4??10??) *???i1?~?K?O???s(???C???Q?U??)* *(?A?e????99?~?u???~20?U?????????u???X(?????~,?a??,???q?W,?s?n??)* *?s?W???w?? *???N???? *?n?????s *????CD-R??????????.(????CD-AutoRun??????????????) (???M?u?? $680 ) ???[?L?????????C 680???u???L?O???p?????A?]?\?A?{?b?????n?A?????O?H???n???P?u?@?W?? ???~???A???????n?I *************************************************************************** ?????q???????j?????A???A?M???????????U???U?~ Email Address?A ???n?U???U?~???? Email Address?A???H???p???????I *************************************************************************** ???n???????L?o???????????|???I (?q?????u)-(852)-83331002?????? ?a?}:?????E?s?????~????24?????~??3???e?y. _____________________________________________________________________ From e9025657 at stud3.tuwien.ac.at Sun Apr 18 18:58:11 1999 From: e9025657 at stud3.tuwien.ac.at (Kaweh Kazemi) Date: Sun, 18 Apr 1999 22:58:11 GMT Subject: Parsing C++ headers with Python References: <371A24BF.E3341937@nowhere.com> Message-ID: <371a61b8.648812@news.teleweb.at> >As part of an effort to make our documentation more automatic (at least to the >degree that we can generate reports on header changes), I'd like to be able to >parse out c++ headers from Python. I'm not looking for "complete" >parsing abilitiies-- there is a tool written in perl for this purpose. see http://friga.mer.utexas.edu/mark/perl/perceps/ for more information. the reason i am posting this, is because i would be interested to port this tool to python, mainly because i am familiar with python and have no clue about perl. i would take the time to port it, and make the port available to the python community, if someone could help me in understanding what perl is doing (mainly regarding structure and regular expressions). kaweh kazemi (e9025657 at stud3.tuwien.ac.at) From bwarsaw at cnri.reston.va.us Wed Apr 28 00:15:28 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: 28 Apr 1999 00:15:28 -0400 Subject: smtplib hang on send "data " to MS SMTP server References: <7g5euo$m7e$1@nnrp1.dejanews.com> <000601be9124$1846dce0$29a02299@tim> Message-ID: <61hfq1js7z.fsf@anthem.cnri.reston.va.us> >>>>> "TP" == Tim Peters writes: TP> Also be clear about which version of Python you're using, and TP> which OS. smtplib.py has changed a *lot* since 1.5.1 (have TP> you tried 1.5.2?). There's even a patch that was made to smtplib.py /after/ Python 1.5.2 final was released. You can grab the latest version from the CVS tree http://www.python.org/download/cvs.html -Barry From pradeepj at delhi.tcs.co.in Tue Apr 13 03:10:50 1999 From: pradeepj at delhi.tcs.co.in (pradeepj at delhi.tcs.co.in) Date: Tue, 13 Apr 1999 07:10:50 GMT Subject: lexical analyzer Message-ID: <7euqlm$aru$1@nnrp1.dejanews.com> Question 1 : The following syntax-directed translation scheme is used with a shit reduce (bottom up) parser that perform the action in braces immediately after any reduction the corresponding production A-> aB { print "0" }, A-> c {print "1"}, B-> Ab {print "2"}. The string printed when the parser input is aacbb is a) 00122 b) 02021 c) 10202 d) 12020 Question 2 : (I) The task of lexical analyzer is to translate the input source language text into tokens and determine how groups of tokens are inter-related. (ii) Two basic approaches to translation are generation and interpretation. (iii) A load-and-go compiler is capable of translating the source language text on a host machine A that can be later run on any machine B. Which of the following is true ? a) All are true b) Only (I) and (III) are true c) Only (I) is true d) Only (III) is false -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From fdrake at cnri.reston.va.us Tue Apr 27 14:07:55 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Tue, 27 Apr 1999 18:07:55 GMT Subject: Built-in Modules gl, GL for SGI IRIX In-Reply-To: References: <371FF2E3.7FB17EBD@bioreason.com> Message-ID: <14117.64763.590661.415595@weyr.cnri.reston.va.us> Andrew Dalke writes: > However, since you don't have to worry about supporting SGI > hardware from about 1996 or earlier, just use the PyOpenGL module > > http://starship.python.net/crew/da/PyOpenGL/ > > and ignore that section in the Python manual. I'll add a reference to this in the "gl" section of the Python Library Reference. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From mal at lemburg.com Thu Apr 15 11:49:17 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 15 Apr 1999 15:49:17 GMT Subject: timezone stuff driving me bonkers!!! References: <371604B6.C6267011@quantisci.co.uk> Message-ID: <37160A7D.72AD2893@lemburg.com> Stephen Crompton wrote: > > Pretty obvious from the header I guess. > > I want to convert from a UTC tuple to the time since the epoch. As far > as I can tell this should definitely be timezone, DST, etc. independent. > However, there is a notable absence of this functionality in the time > module (presumably due to C library absences ?) Try the utc2local() function in mxDateTime (an extension package which can download from my Python Pages). It will convert a DateTime instance using UTC values to a DateTime instance using local time. The .ticks() method on that instance will get you the time since epoch value. Cheers, -- Marc-Andre Lemburg Y2000: 260 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From fredrik at pythonware.com Tue Apr 20 05:34:24 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 20 Apr 1999 09:34:24 GMT Subject: Tkinter hangs on mainloop References: <371c19bb.60709557@news> Message-ID: <008a01be8b11$e17fb320$f29b12c2@pythonware.com> wrote: > I've done a complete install of python ver 1.5.2 on my > windows98 system and I've run into a problem with Tkinter (no big > surprise!) I can import it with the line : from Tkinter import * I assume you're running this from the command line, right? > widget.mainloop() > > It hangs. not really. it doesn't hang, it just doesn't return immediately. in fact, it won't return until you've closed the root window. > If I wait for a while and then hit Ctr-C I get the > following error: > > Traceback (innermost last): > File "", line 1, in ? > File "k:\python\lib\lib-tk\Tkinter.py", line 492, in mainloop > self.tk.mainloop(n) > KeyboardInterrupt before you to this, look in the task bar. click on the Tk icon, and the (quite small) window will pop up. http://www.pythonware.com/library/tkinter/introduction/intro01.htm has some more information on the mainloop function. From aaron_watters at my-dejanews.com Wed Apr 21 15:58:51 1999 From: aaron_watters at my-dejanews.com (aaron_watters at my-dejanews.com) Date: Wed, 21 Apr 1999 19:58:51 GMT Subject: Kosovo database; Python speed References: <371DAAC2.D9046550@cs.utwente.nl> <371DB466.32097FE5@pop.vet.uu.nl> Message-ID: <7flalp$n10$1@nnrp1.dejanews.com> In article <371DB466.32097FE5 at pop.vet.uu.nl>, M.Faassen at vet.uu.nl wrote: > Richard van de Stadt wrote: > > > > Suppose we were going to make a database to help Kosovars locate > > their family members. This would probably result in hundreds of > > thousands of records (say 1 record (file) per person). > > > > Would Python be fast enough to manage this data, make queries on > > the data, or should compiled programs be used? > > Depends on what queries you make, but if used smartly, Python can > probably be fast enough. From what I've heard Gadfly is (a database > implemented in Python). It also depends on what you expect the queries to be. For this kind of problem "grep" might work pretty well, actually. Gadfly is best at the moment when you are doing a lot of exact matches, so I'd expect if you were doing matches on last/first name by exact spelling gadfly would be okay on a sufficiently large machine. However for inexact matches I'd recommend other methods, like grep for example. Generally if all you have is one big table something like gadfly is less compelling than if you have many interrelated structures to manage and query. Also look at dbm, gdbm, bplustree, and similar. http://www.chordate.com/gadfly.html http://starship.skyport.net/crew/aaron_watters/bplustree/ -- Aaron Watters === % ping elvis elvis is alive % _ -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From aaron_watters at my-dejanews.com Wed Apr 14 08:01:02 1999 From: aaron_watters at my-dejanews.com (aaron_watters at my-dejanews.com) Date: Wed, 14 Apr 1999 12:01:02 GMT Subject: Python as an ODBC *source* on windoze ? References: <01BE8604.AE1D9CC0.richard@folwell.com> <37145266.1127FE06@zipzap.ch> Message-ID: <7f201s$1ml$1@nnrp1.dejanews.com> In article <37145266.1127FE06 at zipzap.ch>, Boris Borcic wrote: > Richard Folwell wrote: > > > > It is certainly possible to implement a DBMS in Python (check out Gadfly!), but > > I suspect that you are asking a different question. (?) > > Indeed. It is my (untested) understanding that the MS Access Report writer (and gui) > can be exploited with data from other vendor's databases through ODBC. > > I was wondering if it was possible to configure python to serve data appropriately > to queries from the report writer -- this doesn't mean implementing a full DBMS > in python, only to feed back appropriately patterned data to the report generator. I briefly looked into what it would take to do this and I decided that it looked almost as hard as implementing a full dbms in Python. :) I didn't look all that hard though. It's mainly a matter of generating python callbacks from the ODBC C calls. It should be possible to do this by modifying examples from the ODBC SDK, I think, but it would be tedious. ODBC is a fairly complex API. A simpler approach, if this is acceptible, is to simply use the ODBC client api provided with pythonwin to load data into MSJET on an as needed basis and then use plain old Access to generate the reports or whatever and then unload the data out again if it changes. It's not ideal but it can be done now without too much effort. I'm hoping something like XML-RPC or COM+ will make it much easier to interface python modules (or other modules) to existing APIs like ODBC, but this doesn't seem to be happening too fast, comments Greg, Bill, Mark? -- Aaron Watters === We have met the enemy and he is us. -- Pogo -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From mwh21 at cam.ac.uk Mon Apr 26 08:43:18 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 26 Apr 1999 13:43:18 +0100 Subject: os.exec References: <7g1jv4$5eh$1@nnrp1.dejanews.com> Message-ID: jimmyth at my-dejanews.com writes: > Is there a way to send the output from a python-spawned external program > straight to the script without having to deal with the OS's piping and such? > I want to be able to say: > > bob = get_output_from(os.execv('runme.exe', ('parm1', 'parm2'))) > > or something to that effect. There's commands.py, a library module: Python 1.5.2 (#2, Apr 14 1999, 13:02:03) [GCC egcs-2.91.66 19990314 (egcs-1.1.2 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import commands >>> bob=commands.getoutput ('echo "bill"') >>> print bob bill >>> or there's popen: Python 1.5.2 (#2, Apr 14 1999, 13:02:03) [GCC egcs-2.91.66 19990314 (egcs-1.1.2 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import os >>> bob=os.popen('echo "bill"').read() >>> print bob bill >>> which is pretty much what commands.py does under the hood. There's also popen2: Python 1.5.2 (#2, Apr 14 1999, 13:02:03) [GCC egcs-2.91.66 19990314 (egcs-1.1.2 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import popen2 >>> o,i,e=popen2.popen3('echo "stdout"; echo "stderr" >& 2') >>> o.read() 'stdout\012' >>> e.read() 'stderr\012' >>> Or you can roll your own (I'd recommend starting with popen2.py). These are more likely to do what you expect on unix-ish OSes than windows, but I think the first two will work on windows too. HTH Michael From hew at hons.cs.usyd.edu.au Fri Apr 16 23:10:45 1999 From: hew at hons.cs.usyd.edu.au (Matthew Robert Gallagher) Date: Sat, 17 Apr 1999 13:10:45 +1000 Subject: Scheduling in Python Message-ID: <3717FBB5.6FA30769@hons.cs.usyd.edu.au> I'm currently writing a CPU scheduler for an active network in python but I"m unable to find suitable routine to place Restricted Execution environments to sleep Does anybody know how this is done thanks hew From guido at CNRI.Reston.VA.US Thu Apr 8 17:48:12 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Thu, 8 Apr 1999 21:48:12 GMT Subject: Python 1.5.2c1 -- release candidate for 1.5.2 Message-ID: <199904082148.RAA04479@eric.cnri.reston.va.us> On 8 April 1999, Python 1.5.2c1 was released. This is a release candidate for 1.5.2 final - only showstopping bugs will be fixed before 1.5.2 is released. *** Please help making 1.5.2 rock solid by banging on the release candidate in all possible ways! *** I hope to release the final version of 1.5.2 on 13 April. That will conclude the 1.5 development cycle; while I may release some essential patches later, my main development focus will be on Python 1.6 (with 2.0 on the horizon; 1.6 will probably be the last of the 1.x versions). Go to http://www.python.org/1.5/ for more info, or download directly: ftp://ftp.python.org/pub/python/src/py152c1.tgz (source, 2.5M) ftp://ftp.python.org/pub/python/win32/py152c1.exe (Windows installer, 5.0 M) --Guido van Rossum (home page: http://www.python.org/~guido/) From befletch at my-dejanews.com Fri Apr 30 15:30:57 1999 From: befletch at my-dejanews.com (befletch at my-dejanews.com) Date: Fri, 30 Apr 1999 19:30:57 GMT Subject: Trouble with proxies References: <7gasj8$g79$1@nnrp1.dejanews.com> <5lzp3qafkj.fsf@eric.cnri.reston.va.us> Message-ID: <7gd0dh$add$1@nnrp1.dejanews.com> In article <5lzp3qafkj.fsf at eric.cnri.reston.va.us>, Guido van Rossum wrote: > A quick lookup in errno.errorcode shows that that error is > WSAECONNRESET, in other words the connection is reset by the server. > This apparently happens after the proxy has read your headers. Could > it be that the proxy server requires some kind of magic header? Ask > the sysadmin who is responsible for the proxy. At least find out what > the proxy software is, you can probably find the specs on the web.... > > If you have a way to snoop network packets, it would be interesting to > see what traffic happens when your regular browser (IE or netscape) > connects to the proxy from the same client machine (I'm assuming that > works!). The proxy server is WinProxy Lite, V2.1. It is running on an NT4 server. Yes, IE and Netscape both work fine through the proxy server, and no, the sysadmin doesn't know anything more about WinProxy than how to install it and configure it for normal http/ftp/smtp/pop3 clients. Following suggestions from several kind people, I have also tried the following: import os, urllib os.environ['http_proxy'] = "http(colon-slash-slash)10.187.200.230" f = urllib.urlopen('http://www.python.org') data = f.read() This gets as far as the f.read() call before it fails in the same fashion. Appending ":80" or ":8080" to the proxy URL yield the same results, too. I'm going to try to contact the WinProxy folks and see if they have any insight into this problem, but if anyone here can help, it would of course be appreciated. Thanks, - Bruce -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From dcl at panix.com Wed Apr 14 11:05:18 1999 From: dcl at panix.com (David C. Lambert) Date: 14 Apr 1999 11:05:18 -0400 Subject: HTMLgen in Java? Message-ID: <7f2are$kqq$1@panix.com> I'm looking for a Java class library (freeware) that is more or less parallel to HTMLgen in its capabilities and structure. (That is, classes encapsulating the programmatic generation of the major HTML structures). If anyone knows of such a beast, I'd appreciate a pointer. TIA. - David C. Lambert dcl at panix.com From s.havemann at tu-bs.de Mon Apr 26 13:36:40 1999 From: s.havemann at tu-bs.de (Sven Havemann) Date: Mon, 26 Apr 1999 19:36:40 +0200 Subject: SOLUTION: Triangulation of the unit sphere Message-ID: <3724A428.138357DC@tu-bs.de> Hi! === I have a neat C++ solution for the problem of finding a triangulation of n random points distributed on the unit sphere. The algorithm runs in O(n*sqrt(n)) with a nice small constant, as you can see below (SGI O2 with 250 MHz MIPS R10000). Python (www.python.org) and PyOpenGL (http://starship.python.net/crew/da/PyOpenGL/) have been _very_ helpful, and there's a nice unit sphere viewer and algorithm visualization included in the 8K .tgz for those unixers who have it installed (I can build a windows VC++ version on demand). Have a look: ftp://ftp.cg.cs.tu-bs.de/pub/cg/people/havemann/sdelaunay-1.00.tgz Greetings, Sven. =============================================================== 1004 faces, 504 vertices, 0.065275 seconds 2004 faces, 1004 vertices, 0.138277 seconds 3004 faces, 1504 vertices, 0.213124 seconds 4004 faces, 2004 vertices, 0.323524 seconds 5004 faces, 2504 vertices, 0.416665 seconds 6004 faces, 3004 vertices, 0.520598 seconds 7004 faces, 3504 vertices, 0.655553 seconds 8004 faces, 4004 vertices, 0.757154 seconds 9004 faces, 4504 vertices, 0.887238 seconds 10004 faces, 5004 vertices, 1.024282 seconds 11004 faces, 5504 vertices, 1.160054 seconds 12004 faces, 6004 vertices, 1.327187 seconds 13004 faces, 6504 vertices, 1.466274 seconds 14004 faces, 7004 vertices, 1.627190 seconds 15004 faces, 7504 vertices, 1.818125 seconds 16004 faces, 8004 vertices, 1.988085 seconds 17004 faces, 8504 vertices, 2.169752 seconds 18004 faces, 9004 vertices, 2.370354 seconds 19004 faces, 9504 vertices, 2.549433 seconds 20004 faces, 10004 vertices, 2.751907 seconds -- __________________________________________________________________ dipl-inform. Sven Havemann Institut fuer ComputerGraphik Odastrasse 6 Rebenring 18 38122 Braunschweig - Germany 38106 Braunschweig - Germany Tel. 0531/2808955 Tel. 0531/391-2108, Fax: -2103 mailto:s.havemann at tu-bs.de http://www.cg.cs.tu-bs.de From jeuguang at cm1.hinet.net Wed Apr 14 07:32:45 1999 From: jeuguang at cm1.hinet.net (Wang Cheng-cheng) Date: Wed, 14 Apr 1999 19:32:45 +0800 Subject: [comp.lang.python.*] Posting guidelines -- bi-weekly posting References: Message-ID: <37147CDD.6C2A@cm1.hinet.net> Markus Fleck wrote: > > Archive-name: python-faq/python-newsgroup-faq > Comp-lang-python-announce-archive-name: python-newsgroup-faq > Comp-lang-python-archive-name: python-newsgroup-faq > Posting-Frequency: biweekly > Last-modified: 1998/08/20 > Version: 1.4 > > Changes in 1.4: - now also cross-posting to comp.answers and news.answers > > > HOW TO post to comp.lang.python[.announce] < > ------------------------------------------------ > posted bi-weekly to comp.lang.python.announce, > comp.lang.python, comp.answers, news.answers > > About Python > ------------ > > From the Python FAQ: > > "Python is an interpreted, interactive, object-oriented programming > language. It incorporates modules, exceptions, dynamic typing, very high > level dynamic data types, and classes. Python combines remarkable power > with very clear syntax. It has interfaces to many system calls and > libraries, as well as to various window systems, and is extensible in C or > C++. It is also usable as an extension language for applications that need > a programmable interface. Finally, Python is portable: it runs on many > brands of UNIX, on the Mac, and on PCs under MS-DOS, Windows, Windows NT, > and OS/2. > > To find out more, the best thing to do is to start reading the tutorial > from the documentation set at ." > > Example: "Hello World" in Python > -------------------------------- > > The original task can be accomplished by a one-liner: > > print "Hello World!" > > Here is a longer example, a function that returns a string > containing a series of multiple "Hello World!" greetings: > > def my_hello(how_often): > retval = how_often * "Hello World! " # "multiply" string > return retval[:-1] # strip off trailing space > > Usage: > >>> my_hello(5) > 'Hello World! Hello World! Hello World! Hello World! Hello World!' > > Note that block structure in Python is defined by indentation, rather than > block delimiters (as used in many other programming languages such as Perl, > Java and C/C++). > > comp.lang.python > ---------------- > > comp.lang.python (or c.l.py for short) is the general discussion newsgroup > for users of the Python language. It is also available as a mailing list; > see below for instructions on subscribing to c.l.py through the mailing list. > > If you have questions regarding the use of Python, please take the time to > consult the Python "Frequently Asked Questions" (FAQ) list first before > posting to comp.lang.python: it's at . > > comp.lang.python.announce > ------------------------- > > The comp.lang.python.announce newsgroup (or c.l.py.a for short) has been > created in early 1998 as a companion newsgroup for comp.lang.python focused > on Python-related announcements. The newsgroup charter is as follows: > > "comp.lang.python.announce is a moderated, low-volume newsgroup for > announcements regarding the Python programming language, including: > > - new releases of the core distribution and contributed software > - events (user group meetings, conferences, training, etc.) > - periodic postings (FAQs) > - other items of general interest to the Python community > > This is not a discussion group. Posts are expected to have > Followup-To: headers set to "poster" or an appropriate newsgroup; > posts that omit this header will have a Followup-To: comp.lang.python > inserted by the moderator." > > comp.lang.python.announce posting guidelines > -------------------------------------------- > > In addition to honoring the c.l.py.a charter (see above), you are asked > to consider the following things when submitting announcements for > comp.lang.python.announce: > > 1. It is often very helpful to INCLUDE SOME BACKGROUND INFORMATION if > you are announcing a very specialized package or event. Submissions > will be rejected by the moderators if a casual c.l.py.a reader > cannot understand the utility or context of your announcement. > > 2. INCLUDE A URL (web address) for your announcement. Hint: a "real" > web page often looks better than a mere FTP address and offers more > possibilites to present your package "at a glance". > > 3. GIVE YOUR PACKAGE A VERSION NUMBER. If you give your package a version > number from the start, it will be easier to identify different releases > in the future. Even "small" packages should have version numbers. > > 4. Clarify the LICENSE that you release your package under. If you want to > release something as free software, you might want to have a look at > the "Open Source Definition", , > and pick one of the licenses mentioned there under "Example Licenses". > > 5. You should INCLUDE YOUR E-MAIL ADDRESS in the body text of your > posting or in the trailing .signature block. Please do *not* sign > your announcement with PGP; most people would not know your public > PGP key anyway and would get a warning message. > > 6. Avoid excessive cross-posting. Messages that are cross-posted to > several moderated news groups will usually be approved by the > moderator of the first group in the list. > > 7. To make it easier to include your announcement on www.python.org's > front page, please include 2-3 lines of HTML code at the very end > of your submission, using the following template: > >
void main(); static void allWsCB(); /*------------------------------------------------------------- * Occupy All Workspaces Function */ static void occupyAllWs (w, client_data, call_data) Widget w; /* widget id */ XtPointer client_data; /* data from application */ XtPointer call_data; /* data from widget class */ { DtWsmOccupyAllWorkspaces (XtDisplay(toplevel), XtWindow(toplevel)); } Thanks Look out....Rookie on board!!! -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From MHammond at skippinet.com.au Mon Apr 5 22:24:59 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 6 Apr 1999 12:24:59 +1000 Subject: Conflict Between Python1.5.2b2 and win32all-123 References: <01be7fc6$af6c11e0$01656565@fidget> Message-ID: <7ebr9i$n62$1@m2.c2.telstra-mm.net.au> Jonathan Polley wrote in message <01be7fc6$af6c11e0$01656565 at fidget>... >I have installed Python 1.5.2b2 then installed win32all-123. When I invoke >IDLE with a file name on the commandline, I get the following error: > >Traceback (innermost last): > File "C:\Program Files\Python\Lib\ntpath.py", line 398, in abspath > return win32api.GetFullPathName(path) >api_error: (161, 'GetFullPathName', 'The specified path is invalid.') > > >If I remove pythonwin, the error goes away. Since I don't plan on running >IDLE with files as arguments, the current behavior is not an issue for me. This is because of a bug in the new version of ntpath.py - I never noticed it attempts to use win32api before. When you install win32all, you get win32api, so the functionality of ntpath changes. The problem is that win32api.GetFullPathName actually fails if the path name is invalid, whereas the version that works without win32api does not. I suggest the following patch ntpath.py (note - against the CVS tree, not the b2 release - but it should be obvious to apply manually): Mark. RCS file: /projects/cvsroot/python/dist/src/Lib/ntpath.py,v retrieving revision 1.18 diff -c -r1.18 ntpath.py *** ntpath.py 1999/03/19 21:03:54 1.18 --- ntpath.py 1999/04/06 02:19:25 *************** *** 388,394 **** """Return the absolute version of a path""" try: import win32api ! return win32api.GetFullPathName(path) except ImportError: if not isabs(path): path = join(os.getcwd(), path) --- 388,397 ---- """Return the absolute version of a path""" try: import win32api ! try: ! return win32api.GetFullPathName(path) ! except win32api.error: ! return path # Bad path - return unchanged. except ImportError: if not isabs(path): path = join(os.getcwd(), path) From alex at somewhere.round.here Thu Apr 15 18:52:24 1999 From: alex at somewhere.round.here (Alex) Date: 15 Apr 1999 18:52:24 -0400 Subject: Novice Question: two lists -> dictionary References: <7f3j1v$f6j$1@nnrp1.dejanews.com> <3716B321.A0652382@fedex.com> Message-ID: Here's a way using functional programming that also seems to work. It's rather horrible, though. Dict = {} map (operator.setitem, len (ListA) * [Dict], ListA, \ map (copy.copy, len (ListA) * [[]])) map (apply, map (getattr, map (operator.getitem, \ len (ListA) * [Dict], ListA), \ len (ListA) * ['append']), \ map (tuple, ListB)) print Dict Alex. From guido at CNRI.Reston.VA.US Tue Apr 6 16:43:29 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Tue, 06 Apr 1999 16:43:29 -0400 Subject: Tkinter bug in Misc.tkraise, Canvas.tkraise In-Reply-To: Your message of "Tue, 06 Apr 1999 16:20:26 EDT." <199904062020.QAA05784@python.org> References: <199904062020.QAA05784@python.org> Message-ID: <199904062043.QAA21700@eric.cnri.reston.va.us> > It is not a bug with either code, it is a naming problem. The > Canvas.tkraise is calling the correct code, but it should be called > tag_raise, not tkraise (see the Text widget for naming choice). > > Fredrik or Guido, is this something you can change for before 1.5.2 is > released? (I don't see anything on www.python.org/1.5/ that says when > 1.5.2 will be done except "mid March", which has gone by.) You are right that there is a naming conflict. Unfortunately the default rules for naming Tk subcommands yield this conflict and I didn't catch it when I (or whoever it was) originally created the Canvas class. The Canvas.bind() method shows a precedent for naming it tag_raise() as you propose. Unfortunately, I cannot make this change without breaking all existing code that was using Canvas.tkraise() for raising Canvas items (instead of raising the Canvas itself). I can add tag_raise() and then in 1.6 we can delete the tkraise() and lift() names. Other issues: - As someone else suggested, the proper solution is Misc.tkraise(canvasobject). - /Fredrik Lundh is responsible for *documenting* Tkinter, but not for its maintenance (although he contributed a bunch of support modules). The maintenance of Tkinter is strictly my responsibility. (Not that I asked for it. :-) - 1.5.2 will more likely be released around mid-April. --Guido van Rossum (home page: http://www.python.org/~guido/) From tismer at appliedbiometrics.com Fri Apr 9 10:31:45 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 9 Apr 1999 14:31:45 GMT Subject: import from user input? References: <816010E2456BD111A48700805FBBE2EEA63EB9@ex-quebec-u1.baan.com> Message-ID: <370E0F51.E1D33D6@appliedbiometrics.com> Gaetan Corneau wrote: > > Chris, > > > >>> globals()[modname] = __import__(modname) > [GC] > Exactly what I was looking for. I read about the __import__ function in the > doc, but I didn't know that I had to assign it that way. Actually, I did no good job by suggesting that. It will work for simple module names. But if you try with things like "win32com.client", it will break. The import will work, but the module will not be accessible in the way a user would expect. Instead, one should cut off the first name before the first dot and put that into globals(). import string globals()[string.split(modname, ".")[0]] = __import__(modname) seems to do it better. -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 aa8vb at vislab.epa.gov Fri Apr 16 17:20:11 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 16 Apr 1999 21:20:11 GMT Subject: sys.path.insert - how to make it global? Message-ID: <19990416172011.A1551755@vislab.epa.gov> If I want to augment my Python module search path inside a Python script (so that it affects itself and imported modules), what's the best way to do this? Randall From akuchlin at cnri.reston.va.us Tue Apr 6 16:02:05 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Tue, 6 Apr 1999 20:02:05 GMT Subject: Python and Qt+KDE In-Reply-To: References: <36F940DC.44F08BDF@druga.com> <7dbtb8$38j$1@nnrp1.dejanews.com> <7dec78$977$1@Starbase.NeoSoft.COM> <36FB0C5F.E6CE768D@zarlut.utexas.edu> <199903290118.UAA05150@mira.erols.com> <3708D549.12844324@trust.ee> Message-ID: <14090.26424.368839.128874@amarok.cnri.reston.va.us> boud at rempt.xs4all.nl writes: >I'm currently working my way through the KDE tutorials, translating from >c++ (which I don't know much about) to Python (which I am learning >quickly). Might I encourage you to make your translations available, whether as a tar file or as a revised Qt-Examples howto? (http://www.python.org/doc/howto/qt-examples/) They'd probably be very useful to other people trying to learn Qt. Also, is there a mailing list where the pyKDE bindings are discussed? There doesn't seem to be much discussion on kde-devel about them. -- A.M. Kuchling http://starship.python.net/crew/amk/ He spoke to the scar-dancers, to the straw-dust-women, to the old man with a swan's arm who tends the back stairs, to the three children of the autopsy, to the painters and the scriveners and the walls. -- From a week in Dream's life, in SANDMAN #64: "The Kindly Ones:8" From arcege at shore.net Sat Apr 24 13:48:38 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sat, 24 Apr 1999 17:48:38 GMT Subject: Extension Doc bug Message-ID: I just spent the morning trying to find a very obscure bug related to the passing keyword arguments to a builtin method/function. I have a method that I defined with METH_VARARGS|METH_KEYWORDS, and found when I called the method with a single argument it worked fine, but after calling it a second time I would get a SystemError exception with the string "bad argument to internal function". It turns out that if no keywords are given in the call, then the third argument passed to the C function is NULL, not an empty PyDictObject. This causes havok with PyArg_ParseTupleAndKeywords() and other functions. The exception is a side-effect of this havok (since my function was returning Py_None, not NULL). The workaround for users of PyArg_ParseTupleAndKeywords() is to check the third argument first. static int my_func(PyObject *self, PyObject *args, PyObject *keywds) { if (keywds == NULL) { if (PyArg_ParseTuple(args, ...)) { ... } } else { if (PyArg_ParseTuple(args, keywds, ...)) { ... } } ... } There should be a note in section 1.8 of _Extending and Embedding the Python Interpreter_ stating that "keywds" might be passed NULL instead of a dictionary. Thanks, -Arcege From bbosware at vic.bigpond.net.au Thu Apr 29 03:13:59 1999 From: bbosware at vic.bigpond.net.au (Bosware Pty Ltd) Date: Thu, 29 Apr 1999 17:13:59 +1000 Subject: GUI and creating GIF References: <7g7u2k$fr0$1@wanadoo.fr> <3727CA5A.68BD@ccms.net> Message-ID: <372806B7.E050A0CF@vic.bigpond.net.au> I'd also like to use gdmodule but I can't understand the documentation (I've emailed to ask Richard Jones for more docs). I'm new to Python. Does anyone have any sample programs they can send? Thanks in advance, John Leach Mike Steed wrote: > > Frank.Derville wrote: > > > > Hello, > > > > I would like to > > 1) create a GIF file under Python by drawing lines, text, ... I have looked > > at Tk which can create bitmaps and photoimage but their seem to be no > > possibility to transform a canvas into a photoimage. > > 2) rotate some text on a canvas. > > > > Does anyone has a tip to do it under Tk, wxWindows or any other GUI? > > > > Thanks by advance > > I recommend you look at gdmodule by Richard Jones. I have a > pre-compiled Win32 binary if you need it. > > http://starship.python.net/~richard/gdmodule/ > > -Mike From chad at vision.arc.nasa.gov Wed Apr 7 18:27:28 1999 From: chad at vision.arc.nasa.gov (Chad Netzer) Date: Wed, 07 Apr 1999 15:27:28 -0700 Subject: Tkinter and centering References: <370B88CF.993D8847@yahoo.com> <370BC217.FFF53A35@vision.arc.nasa.gov> Message-ID: <370BDBD0.5657AC26@vision.arc.nasa.gov> Alexander Schliep wrote: > Chad Netzer writes: > > > Well, I don't know if you can ever get the window width and height without > > first mapping it (displaying). One option is to open it completely off the > > I found a solution in Effective Tcl/Tk. You have to call update_idletasks() > which forces geometry calculations first and then you can move the window. Cool, this works! Although, my quick testing seems to show that the after_idle() callback combined w/ update_idletasks() is required for it to work. Also, the winfo_reqwidth() call must be used instead of winfo_width(). This will help me with the scrolling frame widget I have devised (like the Pmw widget, but automatically packs to the correct size, rather than using a specific size. Anyway, thanks for the tip. Here is my version of the original poster's demo, fixed to work like he requested: from Tkinter import * def CenterOnScreen(): root.update_idletasks() sw = root.winfo_screenwidth() sh = root.winfo_screenheight() w = root.winfo_reqwidth() h = root.winfo_reqheight() newGeometry='+%d+%d' % ((sw/2)-(w/2), (sh/2)-(h/2)) root.geometry(newGeometry=newGeometry) root = Tk() Label(root,text="Cough Cough Cough").pack() root.after_idle(CenterOnScreen) root.update() root.mainloop() Chad Netzer chad at vision.arc.nasa.gov From mli389 at merle.acns.nwu.edu Thu Apr 15 21:53:43 1999 From: mli389 at merle.acns.nwu.edu (Matthew T Lineen) Date: 16 Apr 1999 01:53:43 GMT Subject: HTML Authentication with Python References: <7f5iru$rlm@news.acns.nwu.edu> <14102.27498.772779.5941@bitdiddle.cnri.reston.va.us> Message-ID: <7f6577$8kp@news.acns.nwu.edu> Jeremy Hylton (jeremy at cnri.reston.va.us) wrote: > If you configure the server properly, users won't be able to run your > CGI scripts until the server has checked their username and password. Actually, I want the script to run because it pulls the "REMOTE_USER" key and populates a field in a form. If I knew that authentication through the server would allow me to pull this key, I wouldn't be authenticating through the script. Maybe the question / issue is that I don't understand the use of the REMOTE_USER key. From tim_one at email.msn.com Sun Apr 11 03:24:52 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 11 Apr 1999 07:24:52 GMT Subject: by-passing exception [Q] In-Reply-To: <000101be83d7$6a77dc80$6eba0ac8@kuarajy.infosys.com.ar> References: <000101be83d7$6a77dc80$6eba0ac8@kuarajy.infosys.com.ar> Message-ID: <000501be83ec$64157180$6b9e2299@tim> [Bruno Mattarollo] > Perhaps this is a stupid question, but it's saturday and > it's almost 2AM, so you may understand my state-of-mind :-) It's after 3AM now, so you may understand mine . > I have a script that has to check a directory for the > existence of a file, so I do a os.stat(path-to-file) ... But I want > to continue processing even if this file doesn't exist, so I tryed > this: > > try: > os.stat(path-to-file) > except IOError, msg: > blah blah .... > > But I get an exception ... and it doesn't go into the > except statement... If you had written up a complete problem report, showing the traceback, the answer would have bit you in the nose: >>> import os >>> os.stat("nothing") Traceback (innermost last): File "", line 1, in ? OSError: [Errno 2] No such file or directory: 'nothing' >>> That is, it raises OSError, not IOError. So try that: >>> try: ... os.stat("nothing") ... except OSError, detail: ... print "oops!", detail ... oops! [Errno 2] No such file or directory: 'nothing' >>> > Should I be doing a os.listdir(path-to-dir-where-file-resides) > and checking there? >>> dir(os.path) ['__builtins__', '__doc__', '__file__', '__name__', 'abspath', 'basename', 'commonprefix', 'dirname', 'exists', 'expanduser', 'expandvars', 'getatime', 'getmtime', 'getsize', 'isabs', 'isdir', 'isfile', 'islink', 'ismount', 'join', 'normcase', 'normpath', 'os', 'split', 'splitdrive', 'splitext', 'splitunc', 'stat', 'string', 'varchars', 'walk'] >>> # ponder, ponder, ... >>> print os.path.exists.__doc__ Test whether a path exists >>> os.path.exists("nothing") 0 >>> > I am a little bit confused ... Perhaps it's time to go to > bed or to stop drinking beer while working ... :-) Let's not go to extremes. Interactive mode is a programmer's best friend, especially when tired and drunk at 2AM! just-try-getting-a-dog-to-tell-you-whether-a-file-exists-ly y'rs - tim From hiren at c526184-a.frmt1.sfba.home.com Tue Apr 13 04:13:04 1999 From: hiren at c526184-a.frmt1.sfba.home.com (Red Hat Linux User) Date: Tue, 13 Apr 1999 08:13:04 GMT Subject: Internet Robot References: <7ehe9m$hbs$1@nnrp1.dejanews.com> <7emldl$rh9$1@nnrp1.dejanews.com> Message-ID: On Sat, 10 Apr 1999 04:52:06 GMT, gscot at my-dejanews.com wrote: > I can now POST my request but the server is asking for authentication. >You mentioned that it might be helpful to capture and look at the client?s >out put. How do I do that. Here's one way to do it - -----------------http_portmon.py---------------------------- #!/usr/bin/env python # sits between a http client and http server and # outputs data going either way. # Todo: # 1. Add getopt switches # 2. Add host name options # 3. Modify to use select to detect data on either end. # "@(#) Module Name: portmon.py Version: 1.2 Date: 96/12/09"; import sys import SocketServer import string import os import posix import mimetools from socket import * import urlparse import re BUFSIZE = 1024 class PortServer(SocketServer.ForkingMixIn,SocketServer.TCPServer): def printDebug(self): pass def collect_children(self): print 'doing a waitpid' try: pid,errorStatus = os.waitpid(0,os.WNOHANG) except posix.error,x: print 'no children' return print 'after waitpid' if not pid: return print 'pid = ', pid print 'pidlist = ', self.active_children if pid in self.active_children: self.active_children.remove(pid) def is_gif(cmd): import regex pattern = '\.gif' prog = regex.compile(pattern) index = prog.search(cmd) if index >= 0 : return 1 else: return 0 def is_external(host): # assume that if the host name is of the # form xxx.xxx.xxx then it is external # else it is internal. x = string.splitfields(host,'.') if len(x) > 1: return 1 else : return 0 class RequestHandler(SocketServer.StreamRequestHandler): MessageClass = mimetools.Message def handle(self): self.raw_requestline = self.rfile.readline() requestline = self.raw_requestline if requestline[-2:] == '\r\n': requestline = requestline[:-2] elif requestline[-1:] == '\n': requestline = requestline[:-1] self.requestline = requestline cmd = requestline print 'processing ',cmd [command, path, version] = string.split(cmd) s,n,p,a,q,frag = urlparse.urlparse(path) index = string.find(n,':') req = urlparse.urlunparse(('','',p,a,q,frag)) request = '%s %s %s\r\n' % (command ,req,version) if index > 0: # we have host:port in the network field [host,host_port_str] = string.splitfields(n,':') host_port = string.atoi(host_port_str) else: host = n host_port = 80 if is_external(host): host = 'internet' host_port = 80 request = cmd print host,host_port s = socket(AF_INET, SOCK_STREAM) s.connect((host, host_port)) s.send(request) self.headers = self.MessageClass(self.rfile, 0) if command == 'POST': length = string.atoi (self.headers.getheader('content-length') ) self.content_data = self.rfile.read(length) print 'headers = ', self.headers.headers #s.send(self.raw_requestline) print 'sending ---------------------------------' sys.stdout.write('portmon_client:%s' % request ) for header in self.headers.headers: s.send(header) sys.stdout.write('portmon_client:%s' %header ) s.send('\r\n') sys.stdout.write('portmon_client:\r\n') if command == 'POST': s.send(self.content_data) sys.stdout.write('portmon_client:%s' % self.content_data) print '----------------------------------------------' reply = '' print '------------------portmon_server data begin------------------' while 1: data = s.recv(BUFSIZE) if not data: break self.wfile.write(data) if not is_gif(cmd): sys.stdout.write(data) print '------------------portmon_server data end------------------' #print data #reply = reply + data #s.shutdown(1) def main(): global f if sys.argv[1:]: port = string.atoi(sys.argv[1]) else: port = 9000 server_address = ('',port) echomon = PortServer(server_address,RequestHandler) print 'HTTP PortMon Ready' echomon.serve_forever() main() -----------------http_portmon.py---------------------------- What you need to do is - 1. run http_portmon.py on a port (say 9000) on your Linux box (say linux_host) 2. Now in your browser , select linux_host and port 9000 as your proxy 3. Now invoke your cgi script as you normally would and watch the client and server data on the std output where you ran http_portmon.py Hope that helps, Hiren From guido at eric.cnri.reston.va.us Tue Apr 20 22:57:02 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 20 Apr 1999 22:57:02 -0400 Subject: unpickling an NT object in Solaris? References: Message-ID: <5lzp42smtd.fsf@eric.cnri.reston.va.us> dozier at bellatlantic.net (Bill Dozier) writes: > Problem solved. It seems that the cPickle module is not sufficiently > cross-platform. > > The text mode of pickling is not cross-platform and seems to expect UNIX > linefeeds. :P Nonsense. However you must open the file you're pickling to in binary mode: open(filename,'wb'). -- --Guido van Rossum (home page: http://www.python.org/~guido/) From gherron at aw.sgi.com Thu Apr 22 12:33:17 1999 From: gherron at aw.sgi.com (Gary Herron) Date: Thu, 22 Apr 1999 16:33:17 GMT Subject: NT: Create a link References: <371D9A5D.76541E1E@phoenix-edv.netzservice.de> Message-ID: <371F4F4D.240DA8BE@aw.sgi.com> Holger Jannsen wrote: > > Hi, > > I'd like to know how to create a link to a file with python under WinNT? > Perhaps there is a possibility to get access to 'IShellLink' (Win32Api)? > > Thank you, > Holger > (new under this snake;-)) This is a short python program provided by Mark Hammond (the author of win32com and friends) in response to a similar question some few weeks ago. # MakeShortcut.py # A demo of how to create a shortcut using Python. # This code makes a shortcut to sys.argv[0] in the root directory. from win32com.shell import shell import pythoncom def CreateIt(fileName): # Get the shell interface. sh = pythoncom.CoCreateInstance(shell.CLSID_ShellLink, None, \ pythoncom.CLSCTX_INPROC_SERVER, shell.IID_IShellLink) # Get an IPersist interface persist = sh.QueryInterface(pythoncom.IID_IPersistFile) # Set the data sh.SetPath( fileName ) sh.SetDescription("A test link created with Python") # Save the link itself. persist.Save("\\PythonTest.lnk", 1) if __name__=='__main__': import sys CreateIt(sys.argv[0]) -- Dr. Gary Herron 206-287-5616 Alias | Wavefront 1218 3rd Ave, Suite 800, Seattle WA 98101 From tim_one at email.msn.com Thu Apr 29 03:07:15 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 29 Apr 1999 03:07:15 -0400 Subject: Maximize Benefit when Purchasing Learning Python In-Reply-To: <3727E7B2.616A87F0@polytopic.com> Message-ID: <000d01be920e$e99b0240$199e2299@tim> [Jim Kraii, futilely trying to put all fun aside in hopes of getting a substantive answer that doesn't upset anyone's wife] > ... > Does anybody know what Guido desires most in life? My guess is more time, running a close second to an attractive pair of American glasses. Although one more post about how slow Python is, and I expect he'll most want to be run over by a fast bus . all-kidding-aside-i-accept-checks-too-ly y'rs - tim From bernhard at alpha1.csd.uwm.edu Mon Apr 12 22:31:20 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 13 Apr 1999 02:31:20 GMT Subject: pythonwin COM Update link out of date References: <7em639$fto$1@m2.c2.telstra-mm.net.au> Message-ID: On Sat, 10 Apr 1999 10:30:55 +1000, Mark Hammond wrote: >Bernhard Reiter wrote in message ... >>Hmmmm.... is there a potential danger in installing oadist.exe? >There _shouldnt_ be any danger! I installed oadist.exe. The problem still remains. (I restarted and after that deinstalled and reinstalled the Pythonwin32) Still the three registrations fail and "import win32com.client" fails as described. Any other suggestions? :-( Bernhard From pradeepj at delhi.tcs.co.in Tue Apr 13 03:13:39 1999 From: pradeepj at delhi.tcs.co.in (pradeepj at delhi.tcs.co.in) Date: Tue, 13 Apr 1999 07:13:39 GMT Subject: lexical analyzer Message-ID: <7euqqu$b3l$1@nnrp1.dejanews.com> Question : The lexicographic storage allocation function LOC(A[I,j,k]) = 6I + 2j + k - 368 maps array elements of the array A[22:25, 117:119, 2:3] onto the range of addresses a) 0:23 b) 2:119 c) 22:3 d) none of the above -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From trashcan at david-steuber.com Fri Apr 2 19:40:48 1999 From: trashcan at david-steuber.com (David Steuber) Date: 02 Apr 1999 19:40:48 -0500 Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <37009C12.4C0E6B0B@earth.ox.ac.uk> <19990401114114.A4942@shalott> Message-ID: Marco Mariani writes: -> I'm new to python - new and committed, and not "committed" as in MS speak. -> I've known I'm here to stay since day 1. The only thing about Python I wish -> would be better is Mark's book - I would settle for something easier to -> find things in, I use the index too often. But, sure, I would have -> bought it had it been printed pure ASCII on a dot matrix printer. I recently finished reading the Python tutorial and am now working on the library reference. I am very impressed with the online documentaton that came with the Python that SuSE 6.0 included (1.5.1). It looks to be a very nice, easy language. I am considering using it as an extension/scripting language for a project I am designing. This is after eliminating Perl, ECMAScript, and ANSI Common Lisp. Did this thread start out as a troll? I rather get the impression that Python will be a language that will enjoy a growing user base as more people become aware of it. I'll take it over VBScript any day. Just don't take my Perl away :-). -- David Steuber http://www.david-steuber.com s/trashcan/david/ to reply by mail If you don't, I won't see it. If you live in a country run by committee, be on the committee. -- Graham Summer From tismer at appliedbiometrics.com Fri Apr 23 08:10:57 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 23 Apr 1999 12:10:57 GMT Subject: learning Python (rat book) References: <01f601be8d80$31cbe950$f29b12c2@pythonware.com> Message-ID: <37206351.DB8025EF@appliedbiometrics.com> Fredrik Lundh wrote: > > > The rat has landed! I managed to get my hands a copy at the Stanford > > University Bookstore today. > > just got one on my desk (in Link?ping, Sweden). > > looks great! > > (what else can I say about a book that has > my name in the index? ;-) Unfortunately, names seem to appear just by the chance that material was used. I was astonished to find quite a couple of names, but no Aaron Watters, no Barry Warsaw. Well, the book doesn't try to be complete and doesn't mention everything and everybody. But when mentioning SWIG, it should had better put a reference to Dave Beazley into the index as well. I'm currently working on the Grman translation. it will be ready by end of July. I will try to adjust the index to mention every person who plays a role in the book. (Oops, I wrote this before looking into page 311 - it's me :-) cheers - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 bwarsaw at cnri.reston.va.us Tue Apr 20 13:17:49 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: 20 Apr 1999 13:17:49 -0400 Subject: Tkinter hangs in Emacs in 1.5.2 on Win32 References: <371ca96f.0@nnrp1.news.uk.psi.net> Message-ID: <61n20343eq.fsf@anthem.cnri.reston.va.us> >>>>> "PK" == Pat Knight writes: PK> I often prototype fragments of Tkinter code using the PK> interactive Python mode in NT emacs. Since installing 1.5.2 PK> the interpreter hangs when run interactively inside Emacs. | If I type | from Tkinter import * | r = Tk() | r.title('pat') PK> I never get a >>> prompt from the interpreter after entering PK> the r.title() call. PK> The same sequence of commands works fine in the regular PK> stand-alone interpreter. PK> Does anyone know what's going on before I prepare a bug PK> report? PK> I'm using Python 1.5.2 on Windows 98 and Windows NT with the PK> Tcl/Tk that comes with Python 1.5.2 and NT Emacs 20.3.1 with PK> the python-mode.el that comes with Python 1.5.2. I don't have much time to look into it in detail, but I don't think it's a python-mode problem. I got the same results as you, so I did an edebug on py-comint-output-filter-function which sees every line of text output by the underlying Python interpreter shell, and it is never seeing the `>>>' you'd expect. I'd suspect something's going on in Python because I tested it with a version of NT XEmacs 21 and you tested it with NT Emacs 20.3. I don't know how much of the subproc code the two Emacsen share, so it's possible they both have the same bug. I was using Python 1.5.2b2 on NT. Sorry I can't be of more help. -Barry From neilh at fast.fujitsu.com.au Thu Apr 22 02:15:23 1999 From: neilh at fast.fujitsu.com.au (Neil Hodgson) Date: Thu, 22 Apr 1999 16:15:23 +1000 Subject: PythonWin Debugger comments References: <7fkn0n$37v$1@nnrp1.dejanews.com> Message-ID: <371EBE7B.78B08F4D@fast.fujitsu.com.au> Hi Chuck, [with PythonWin 123] > 1)Syntax highlighting in the debugger needs to go one step > further. While one can change the color of the "current line" > it would be nicer if one could change background color of > the "current line" also. It would make it much more obvious > what the current execution point is. Lots of other debuggers > do this. The look of the editor/debugger has changed a lot in PythonWin 124. There is now a little arrow to show the current line rather than changing colours. If you really like a coloured background for the current line rather than an arrow in the selection margin for build 124, turn the selection margin off by adding self.SendScintilla(SCI_SETMARGINWIDTH, 0, 0) to the OnInitialUpdate method of SyntEditView. This looks better if you change the colour of the current line marker to something bright like yellow: self.SendScintilla(SCI_MARKERSETBACK, MARKER_CURRENT, win32api.RGB(0xff, 0xff, 0)) Neil Hodgson From aa8vb at vislab.epa.gov Wed Apr 28 07:30:22 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Wed, 28 Apr 1999 07:30:22 -0400 Subject: "Compiling" scripts before execution ? In-Reply-To: <000801be912a$0e7ed680$29a02299@tim>; from Tim Peters on Tue, Apr 27, 1999 at 11:49:02PM -0400 References: <19990426104245.A504861@vislab.epa.gov> <000801be912a$0e7ed680$29a02299@tim> Message-ID: <19990428073022.A646406@vislab.epa.gov> Tim Peters: |[Randall Hopper] |> One concern I've been mulling over lately is the potential problem |> maintaining Python scripts over time. For example: |> |> 1) It's easy to never create (or to sever) a link to a |> imported symbol defined in another module, and you may never |> know it until python tries to execute the referencing line of |> script code. |> |> 2) If the signature of an imported method changes, and all |> references to it in all scripts aren't updated, you may never know |> it until Python tries to execute one of these "broken" line of |> script code. |> ... |> What are folks doing to keep this class of errors from being a problem? | |I use a text editor with extremely fast file-based search-and-replace |<0.5 wink>. Short of that, signatures and exported symbols are part of a |module's advertised contract, and a module has no right to change its |contract unilaterally in an incompatible way. During the course of maintenance and enhancement (not to mention prototyping), class or module signatures will change, and possibly change frequently. This is especially true for a multi-developer project. A method, function, or constant may be removed for example, and though the developer making a change shouldn't "get up from his chair" until he impacts all references to it in the software tree, we all make mistakes or get distracted occasionally. So we'd like to know that as soon as reasonably possible that some piece of code isn't quite right and is destined to blow up. I see your point for the case where function warguments change. However, going to the trouble to ensure a past interface works implies a significant penalty for just "changing it" (such as, a past version of your module was released and is being used by other folks). But for prototyping or an application, this isn't (shouldn't be) the case. Just change it; keep it simple, understandable, and cut out the dead wood. One of Python's big strengths is that it lends itself to fast prototyping. If Joe User is prototyping an interface, he shouldn't have to insure that any version of it he tentatively defines is always available. If it doesn't work, get out the eraser, chalk-in something different, and try that. |This isn't as flippant as it sounds (*almost*, but not quite ...). |Python argument lists are exceedingly flexible beasts, and it's almost |always possible to maintain backwards compatibility when changing a |signature. For Python functions this is certainly true. But one area I'm thinking of is interfaces in wrapped C libraries (using SWIG). I'm searching for the best way to implement a "build-time error" (as you'd get with C) when a Python or wrapped C API, which is referenced in a Python script, changes or is removed. If one could just invoke the Python script and have it try to "link" all its symbol references ("python -l"?), reporting failure if it couldn't, that would be a big step toward the goal. Though this doesn't cover type and argument signature changes. I'm toyifng with having copies of C header files checked-in with the Python source, and "diffing" those to generate build errors. But this really is an ugly hack. |> Is there a way to "lint" or compile Python code such that it ... | |Nope, you'll have to deal with it. The best stab at a Python "lint" is |Aaron Watters's kjpylint, available from | | http://www.chordate.com/kwParsing/index.html | |It's not trying to do cross-module analysis, though. Thanks for the tip. I'll check into it. |Python2 may or may not introduce some notion of optional static typing, |which could catch this stuff for those motivated enough to use it. That's a |Types-SIG topic. That sounds promising. Some syntactic sugar where a module could declare assumptions about what it is importing would go a long way. Thanks, Randall From tim_one at email.msn.com Thu Apr 29 20:21:27 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 29 Apr 1999 20:21:27 -0400 Subject: converting perl to python - simple questions. In-Reply-To: Message-ID: <000201be929f$636d10a0$5fa02299@tim> [Tim and Randal Schwartz exchange Perl quotes ] [Randal] > ... > Yes, Perl is heavily context sensitive... and so are human beings. :) [Moshe Zadka] > I wonder if Randal came here (2 messages in this group) to spread the > regular Perl propaganda (summarized by "This language is icky because > programmers are icky").... Na. Randal's occasional visits to c.l.py have always been pleasant. In fact, he should hang out here more often! Here's a topic for civil debate: Resolved: returning different stuff depending on whether an expression is in array or scalar context is no worse than killing those of your classmates wearing shirts with sports insignia . oh-ya?-i'll-see-that-and-raise-you-two-hitlers-ly y'rs - tim From tim_one at email.msn.com Sun Apr 25 14:55:55 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 25 Apr 1999 14:55:55 -0400 Subject: possible bug in 1.5.1 In-Reply-To: <37234712.2E95BC37@stat.ubc.ca> Message-ID: <000101be8f4d$3fd303c0$d39e2299@tim> [Jean Meloche] > ... > The code fails because *sometimes* Infinity takes > value Inf and *sometimes* it takes value 0.0... > I've also added the line > > print 1e1000 > > and it sometimes print Inf and sometimes print 0.0. > > How can I create a Infinite float in python with > certainty? I'm using a RedHat 5.2 system on Intel. You can't with certainty -- Python is not IEEE-754 aware, neither are K&R or ANSI C (in terms of which Python is implemented), and not all HW supports infinities anyway. What you can do is save away the attached as (e.g.) ieee.py, then in your code do from ieee import PINF # positive infinity, if it exists in the modules that need a plus infinity (similarly it exports constants for minus infinity, plus and minus zero, and a generic quiet NaN). The module does about the best that can be done of creating these things in a portable way from within Python, and raises an error if it can't. Note that whether "print ieee.PINF" *prints* "Inf" is entirely up to your platform's libc (or equivlalent); e.g., under Win95 it prints "1.#INF", and ieee.NAN prints "-1.#IND". There's also no guarantee that those strings can be read in and converted back to float correctly by your platform's libc. BTW, due to vagaries in IEEE comparison semantics as implemented by your C, this module may raise a bogus error about NaNs. Let me know if it does, and we'll find some other way to spell it. This can't be out-thought in advance, alas, since IEEE C bindings are not yet standardized, and e.g. MS's C doesn't even generate IEEE-aware comparison code on Pentium platforms (where the HW supports it directly). IOW, this module works under Windows Python by contrived accident. floating-point-is-the-devil's-finest-achievement-ly y'rs - tim From akuchlin at cnri.reston.va.us Wed Apr 28 09:29:53 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Wed, 28 Apr 1999 09:29:53 -0400 (EDT) Subject: Bug or Feature? In-Reply-To: References: <37208E69.4B022E0C@mediaone.net> <7fr3eg$bqr@world1.bellatlantic.net> <7g4jkg$llc@ds2.acs.ucalgary.ca> Message-ID: <14119.2301.611044.266704@amarok.cnri.reston.va.us> Stephan Houben writes: >As you see, the "Numerical" part is by far the biggest, and if you make it >a standard part of Python, you increase the size of the standard distribution >by quite much. So that might be a reason not to do it. I think the idea is to include only the basic NumPy types (multiarray and whatever the rest are). BLAS, LAPACK, or whatever, would still be add-ons. The benefit is that installing numeric code wouldn't require recompiling the Python binary; they'd be simple modules. As a side benefit, other programs could then count on having the multiarray type. -- A.M. Kuchling http://starship.python.net/crew/amk/ I'm sure the reason such young nitwits are produced in our schools is because they have no contact with anything of any use in everyday life. -- Petronius, _The Satyricon_ From noSPAMpvoris at earthlink.net Sun Apr 4 23:29:42 1999 From: noSPAMpvoris at earthlink.net (Phil Voris) Date: Sun, 04 Apr 1999 20:29:42 -0700 Subject: newbie questions (Python vs. Perl) Message-ID: <37082E26.A9445E43@earthlink.net> [I'm sorry -- I'm sure this is a frequently addressed issue on this site....] I've been using Perl for several months and don't find its syntax troublesome. I like its speed considering I don't have to use C constructs (and memory management). I'm considering learning Python for several reasons; but have questions and concerns: 1) I hear it's the best for learning OO. I have heard high praise of Eifel as well, but information on it seems to be scarce at best. (I have C and Perl experience) Will Python take me to the next level in terms of understanding OO? 2) Use in the 'real world.' Are companies really using Python? Articles suggest that Python is preferable to Perl because it's better for prototyping and more suitable for team projects (than Perl). In your opinion(s), has this been a major factor in choosing Python, or is it more enjoyable to program in (than Perl)? 3) Speed. How much slower is Python than comparable Perl? I have read about compiling Python as C or Java and ask myself how this code compares to code written directly in those languages. Your comments are appreciated. My pet Antaresia childreni thanks you as well. From gregory.p.green at boeing.com Thu Apr 29 16:24:07 1999 From: gregory.p.green at boeing.com (Greg Green) Date: Thu, 29 Apr 1999 20:24:07 GMT Subject: Emacs' python-mode buggy? References: <7g8np4$kvf@chronicle.concentric.net> <000901be9203$b4c32e40$199e2299@tim> <14120.31856.181562.574382@anthem.cnri.reston.va.us> Message-ID: Hey, since I just found out via the current thread that py-mode has colorizing, I was wondering why I don't have coloring in mine. Using py-version "3.90" and GNU Emacs 20.2.1 (i386-redhat-linux, X toolkit) of Tue Jun 9 1998 on porky.redhat.com sneaking a look at the message buffer: Loading python-mode (compiled)... Loading python-mode (compiled)...done Local value of py-indent-offset set to 4 Unhighlighting Done unhighlighting highlighting 8: ;.* highlighting 7: hilit-string-find highlighting 6: ^\s *(def\(un\|macro\|advice\|alias\|subst\)[ ] ... \()\|nil\) highlighting 5: ^\s *(defvar\s +\S + highlighting 4: ^\s *(defconst\s +\S + highlighting 3: ^\s *(\(provide\|require\|\(auto\)?load\).*$ highlighting 2: \s *\&\(rest\|optional\)\s * highlighting 1: (\(let\*?\|cond\|if\|or\|and\|map\(car\|concat\)\ |prog[n1*]?\|while\|lambda\|function\|set\([qf]\|car\|cdr\)?\|nconc\ |eval-when-compile\|condition-case\|unwind-protect\|catch\|throw\|error\)[ ] Colors work in the Java and C++ modes. -- Greg Green Boeing IS http://www.seanet.com/~gpgreen/ work e-mail: gregory.p.green at boeing.com From Pokey at lgcy.com Wed Apr 28 10:38:23 1999 From: Pokey at lgcy.com (Jared Long) Date: 28 Apr 99 14:38:23 GMT Subject: Land For Sale. Message-ID: <37271d5f.0@news.lgcy.com> A lot with a view and so much more! For Sale: 5-acre lot with well. The lot is located in Herriman, Utah which is 20 minutes south of Salt Lake City. Herriman is growing fast like the rest of Utah and a purchase of property would be an excellent investment at this state in the game. The lot is rectangle that is 335' wide by 652' deep. The lot sits at a slight slope, which gives you a spectacular view of the vally. If you are interested in purchasing or finding out more information about this lot please feel free to E-mail me at: Pokey at lgcy.com Thanks, Jared From xidicone at iname.com Sun Apr 18 08:42:00 1999 From: xidicone at iname.com (Jussi Jumppanen) Date: Sun, 18 Apr 1999 23:42:00 +1100 Subject: Embedded Late Binding Message-ID: <3719D318.1267@iname.com> I am in the process of embedding python into a Win32 text editor. The plan is to allow the text editor to be control using the python scripting langauge. So far I have managed to build the python source into a DLL and the editor is happily running python scripts and capturing the error and output messages produced. I have also managed to extend the intepreter using the standard approach shown below: static struct PyMethodDef editor_functions[] = { { "get_line_number", MacroPython::get_line_number, 1 }, { "set_line_number", MacroPython::set_line_number, 1 }, { 0, 0, 0 }, }; void MacroPython::initialise() { Py_Initialize(); PyImport_AddModule("editor"); Py_InitModule("editor", editor_functions); } and these functions are also working well. But I now have a question that I have not been able to find the answer. The editor that I am hoping to control has over 400 functions all with and identical interface. For example: FileOpen(); /* open a new file */ FileClose(); /* close the current file */ FileNew(); /* create a new file */ ... etc etc and these are contained within the editor EXE file. I am not sure what is the best way to have the the interpreter recognize these editor functions. I know I could add all 400 functions to the static PyMethodDef structure but I really do not want to do this since this means that the DLL and the EXE are effectively hard coded. What I am looking for is some sort of dynamic runtime linking or some sort of late binding. The reason is, I want a method where if the EXE file changes (ie new functions get add) the new version EXE can still use the old version DLL without any loss of functionality. What I was hoping for was something like: static struct PyMethodDef editor_functions[] = { { "get_line_number", MacroPython::get_line_number, 1 }, { "set_line_number", MacroPython::set_line_number, 1 }, { "FileClose" , MacroPython::edit_func , 1 }, { "FileEdit" , MacroPython::edit_func , 1 }, { "FileNew" , MacroPython::edit_func , 1 }, { ......................... }, { 0, 0, 0 }, }; and then somehow in the C source: PyObject *MacroPython::edit_func(PyObject *self, PyObject *args) { PyObject *pObject = 0; if (PyArg_ParseTuple(args, "")) { /* somehow get the function name???? */ char *function_name = ???? (ie FileNew, FileOpen etc); /* this part is easy enough todo */ call editor passing(function_name); } return pObject; } Can anyone tell me if this possible with Python 1.5.1? Or is there a better way to achieve a similar result? Thanks in advance. Jussi Jumppanen Home Page: http://ourworld.compuserve.com/homepages/jussi/ From Martin.Preishuber at stuco.uni-klu.ac.at Fri Apr 16 11:21:24 1999 From: Martin.Preishuber at stuco.uni-klu.ac.at (Martin Preishuber) Date: Fri, 16 Apr 1999 15:21:24 +0000 Subject: #!/usr/bin/env python -u Message-ID: <37175574.25EBDDBE@stuco.uni-klu.ac.at> Hi all, I'm thinking about a way how to generalize the python start from a script. Usually I took something like #!/usr/local/bin/python -u (I need the -u for unbuffered output) but when creating RPM files the final rpms needs /usr/local/bin/python. So I thought about using #!/usr/bin/env python -u This doesn't work because the Linux kernel takes "python -u" as one argument for env so it doesn't find the command (a couple of friends checked the kernel source which says exactly this). So does anybody know some general way to start python without using some fixed path plus having the -u included ? Thanks, Martin -- Martin Preishuber - Student, ECLiPt Core Member, SysAdmin http://eclipt.uni-klu.ac.at, mailto:Martin.Preishuber at stuco.uni-klu.ac.at A man paints with his brains and not with his hands. From wwrqcg at starmedia.com Sat Apr 3 15:08:50 1999 From: wwrqcg at starmedia.com (wwrqcg at starmedia.com) Date: 3 Apr 99 20:08:50 GMT Subject: DO YOU BELIEVE IN REINCARNATION? 1942 Message-ID: <37067552.2@193.75.226.254> Do you believe in reincarnation? Do you want to know who you were and where you lived in your past life? Click here -> http://orbita.starmedia.com/~luizhenrique/reincarnation.html gbsljtpzdgfkpbjjrjebunfthqothunlsjwtu From ture at lysator.liu.se Thu Apr 8 08:05:07 1999 From: ture at lysator.liu.se (Ture =?iso-8859-1?q?P=E5lsson?=) Date: 08 Apr 1999 14:05:07 +0200 Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> Message-ID: "TM" writes: > P.S. By the way, there is a module called terry that generates renderman > code. Well, sort of. It needs to be linked with a library that implements the RenderMan C API. I wrote terry a couple of years ago when my own RenderMan hack didn't have a RIB parser and I was sick and tired of having to recompile C programs to make test images. I haven't used it very much since I got a RIB parser working, and as far as I know, noone else has used it, either. If someone actually _is_ using it, let me know, and I might get around to release the few bug fixes and improvments that are sitting around in my CVS repository. :-) -- Ture From gutier at intergate.bc.ca Sat Apr 17 17:39:16 1999 From: gutier at intergate.bc.ca (Gerald Gutierrez) Date: Sat, 17 Apr 1999 14:39:16 -0700 Subject: Plugins, or selecting modules to import at runtime References: <924379180.825429211@news.intergate.bc.ca> Message-ID: <924385178.948235039@news.intergate.bc.ca> Never mind. I just found the module "imp". Thanks. On Sat, 17 Apr 1999, Gerald Gutierrez wrote: >Hi all. > >I'd like to write a program in Python in which the user can select one of >several modules to execute through a function that has the same name in all the >modules. I don't believe "import" lets me pass it a string. There is also >reload(), but the module to reload must be previously imported. > >This is very similar to plugins like that used in Netscape, Photoshop and the >GIMP. > >Can someone please give me a hint? > >Thanks. > >Please forward replies to gutier at intergate.bc.ca. From no.email.address.entered at none444.yet Thu Apr 15 22:40:03 1999 From: no.email.address.entered at none444.yet (no.email.address.entered at none444.yet) Date: Thursday, 15 Apr 1999 20:40:03 -0600 Subject: The Fastest way to prepare for a successful IT career! Message-ID: <15049920.4003@none444.yet> For More Information: http://www.cbtnow.com/index.html?ASCID=134 The Fastest way to prepare for a successful IT career! CBT Systems offers the fastest and easiest way to prepare you for a successful career in the ever-expanding Information Technology (IT) industry. Our Self-Study Courses are 100% computer-based training (CBT) available through electronic download or CD-ROM to give you flexibility unmatched by traditional training methods. For More Information: http://www.cbtnow.com/index.html?ASCID=134 From tim_one at email.msn.com Tue Apr 27 11:51:43 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 27 Apr 1999 11:51:43 -0400 Subject: threading/events questions In-Reply-To: <3725a47f.96308574@scout> Message-ID: <000401be90c5$d969cfe0$589e2299@tim> [Chris...] > After experimenting with the modules thread and threading I have > some open questions. I've written the famous ping-pong program > ------------------------------------------------------------------ > from Threading import * > from time import sleep > > Quit = Event() > > def f(t, msg): > print msg > Quit.wait(t) > if Quit.isSet(): > return > f(t, msg) Note that recursion is inappropriate here: Python does not optimize tail calls, and so the thread stack keeps growing and growing. Not what you want for a long-running server . > def run(): > t1 = Thread(target=f, args=(10, 'ping')) > t2 = Thread(target=f, args=(5, '\tpong')) > t1.start() > t2.start() > sleep(60) > Quit.set() > ------------------------------------------------------------------ > With that program, the threads are running for 60 seconds. But, how > can I stop one thread and not both? I don't want to write an > additional function doing exactly the same except dealing with a > different Event. Events are delicate, but if that's *all* you want to do just give f another "early out" argument; e.g., def f(t, msg, earlyout): while 1: print msg Quit.wait(t) if Quit.isSet() or earlyout.isSet(): return def run(): earlyout_t1 = Event() earlyout_t2 = Event() t1 = Thread(target=f, args=(10, 'ping', earlyout_t1)) t2 = Thread(target=f, args=(5, '\tpong', earlyout_t2)) t1.start() t2.start() sleep(30) earlyout_t2.set() sleep(30) Quit.set() That stops t2 after 30 seconds but lets t1 run the full 60. As your program grows fancier, it would also be better to pass "Quit" as an argument rather than rely on an increasingly nasty web of global vrbls. > My second problem is sending an event with a message. > ChangeOutput = Event() > and send the event ChangeOutput('something different than ping-pong') > to one thread. After receiving this message, the thread should change > the recursive call to f(t, 'something different, than ping-pong'). Events can't be directed to a specific thread, nor can they carry information beyond the "clear or set?" distinction. I'm not clear enough on exactly what it is you want to accomplish to suggest an alternative, though. > How can I wait for events (more than one)? Unclear whether you want to wait for at least one, or for all. If all: e1.wait() e2.wait() e3.wait() ... If at least one, you can poll in a busy loop: while not (e1.isSet() or e2.isSet() or ...): pass or use a fancier synchronization mechanism; Events are really pretty feeble, and you shouldn't expect to get fancy stuff done with them; Conditions are more powerful. > In the code above, I am just waiting for one event with a proper timeout. > How can I react on the additional event ChangeOutput? I got lost a few sentences back, so I'll shut up now . the-problem-with-parallelism-is-that-it's-not-serial-ly y'rs - tim From cmedcoff at my-dejanews.com Fri Apr 30 10:41:09 1999 From: cmedcoff at my-dejanews.com (cmedcoff at my-dejanews.com) Date: Fri, 30 Apr 1999 14:41:09 GMT Subject: How to read stdin while debuggingin PythonWin References: <7g9utu$kin$1@nnrp1.dejanews.com> <7garhi$hqi$1@m2.c2.telstra-mm.net.au> Message-ID: <7gcfe5$qin$1@nnrp1.dejanews.com> > > Im not sure why this would be different under the debugger, but when I try > that from the Pythonwin window I get: > >>> sys.stdin.read() > Traceback (innermost last): > File "", line 0, in ? > IOError: [Errno 9] Bad file descriptor > >>> > This is exectly what I observed when aborting the debug process. Any plans to correct this and provide a place for stdin under the debugger. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From thor at localhost.localdomain Sun Apr 4 10:38:07 1999 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 4 Apr 1999 14:38:07 GMT Subject: Songs of monty python Message-ID: I know , this is not python. But monty python, somehow something important in python. so: http://www.weedon.freeserve.co.uk/mp.htm -- From boud at rempt.xs4all.nl Wed Apr 7 03:00:04 1999 From: boud at rempt.xs4all.nl (boud at rempt.xs4all.nl) Date: Wed, 7 Apr 1999 07:00:04 GMT Subject: Python and Qt+KDE References: <36F940DC.44F08BDF@druga.com> <7dbtb8$38j$1@nnrp1.dejanews.com> <7dec78$977$1@Starbase.NeoSoft.COM> <36FB0C5F.E6CE768D@zarlut.utexas.edu> <199903290118.UAA05150@mira.erols.com> <3708D549.12844324@trust.ee> <14090.26424.368839.128874@amarok.cnri.reston.va.us> Message-ID: Andrew M. Kuchling wrote: : boud at rempt.xs4all.nl writes: :>I'm currently working my way through the KDE tutorials, translating from :>c++ (which I don't know much about) to Python (which I am learning :>quickly). : : Might I encourage you to make your translations available, : whether as a tar file or as a revised Qt-Examples howto? : (http://www.python.org/doc/howto/qt-examples/) They'd probably be very : useful to other people trying to learn Qt. : Oh yes, I certainly will. : Also, is there a mailing list where the pyKDE bindings are : discussed? There doesn't seem to be much discussion on kde-devel : about them. : Not that I know about... -- Boudewijn Rempt | www.xs4all.nl/~bsarempt From mal at lemburg.com Fri Apr 30 06:52:15 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 30 Apr 1999 12:52:15 +0200 Subject: Python and CGI (The CGIPython project) References: <37286538.5EAE0173@lemburg.com> <3728DA03.431E34BF@lemburg.com> Message-ID: <37298B5F.1D2A95A7@lemburg.com> I've moved the first set of contributed binaries to the public FTP server on starship.skyport.net (I'll probably move it to starship.python.net next week). The web-page now contains a list of available binaries: http://starship.skyport.net/~lemburg/mxCGIPython.html#Binaries Anybody have access to AIX and HP-UX machines ? -- Marc-Andre Lemburg Y2000: 245 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From spamfranke at bigfoot.de Fri Apr 30 09:50:35 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Fri, 30 Apr 1999 13:50:35 GMT Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> Message-ID: <3729b3f8.6931947@news.omnilink.de> On 28 Apr 1999 04:00:16 -0400, David Steuber wrote: [...] >Python also seems to have that. I would like better python support in >XEmacs. There is a python mode, but I haven't seen anything about >evaluating Python code ineteractivly the way you can with Lisp and >elisp. You can do that by invoking an interactive Python or JPython shell inside Emacs (via C-!). Buffers containing Python code or the currently marked region can be executed inside the shell at any time, which lets you develop your code very quickly and interactively. Stefan From BRUNO_MONNET at Non-HP-France-om1.om.hp.com Fri Apr 9 11:31:29 1999 From: BRUNO_MONNET at Non-HP-France-om1.om.hp.com (Monnet) Date: Fri, 9 Apr 1999 17:31:29 +0200 Subject: formating string like sprintf Message-ID: <370e1d60@isoit370.bbn.hp.com> How can I format a string like using sprintf (mybuffer, "%02x", myhex_value) ? Bruno From zorro at zipzap.ch Tue Apr 13 09:56:58 1999 From: zorro at zipzap.ch (Boris Borcic) Date: Tue, 13 Apr 1999 15:56:58 +0200 Subject: Python as an ODBC *source* on windoze ? Message-ID: <37134D2A.60D62AEE@zipzap.ch> Is there a way to have Python on windows to act as an ODBC source (server) on windoze ? Reason : to use the MS Access report generator component. Thanks for hints, Boris Borcic From MHammond at skippinet.com.au Thu Apr 15 02:01:10 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 15 Apr 1999 16:01:10 +1000 Subject: Freezing an App References: <7f15dj$bq4$1@m2.c2.telstra-mm.net.au> Message-ID: <7f3v96$g88$1@m2.c2.telstra-mm.net.au> Calishar wrote in message ... >okay, basically I am using Python to automate a process at a client site. in >this application, I have about 4 different functions which each get called >by button clicks. One of the routines is supposed to set a registry key >based on an environment variable. The lines follow: > > >the_key=win32api.RegCreateKey(win32con.HKEY_LOCAL_MACHINE,"Software\Stac\Re a >chout\8.0") > win32api.RegSetValueEx(the_key,"Computer Name",0,win32con.REG_SZ,mac_name) > >At the moment, this is the only part of the application I dont have working >on my non-development system, unfortunately it happens to be kind of >important. Are you sure the code is being executed at all? I cant imagine how these could silently do nothing. > This was my first thought, I made sure that I had the .pyd file in the >same directory as the program I am running. It doesnt do it. Why not? I would bet its not on the sys.path. Just before the import, add a "print sys.path". Frozen programs can use .pyd files fine. > Tried doing this, then copying the files needed over to my '95 test system >(not the same OS,but should be close enough for this part) and when I ran >it, it crashed at line 3 of the code (import win32api) Im sure that it is just path fiddling. (OK - I hope it is :-) >generating table of frozen modules >No definition of module _tkinter in any specified map file. >No definition of module win32api in any specified map file. >Warning: unknown modules remain: _tkinter win32api OK - the .ini file may not have an entry for win32api. Im afraid I havent use the latest version of freeze, and cant recall exactly what is in it, but basically you need to have freeze find a [win32api] section in one of the .ini files. Mark. From cgw at fnal.gov Thu Apr 29 19:12:12 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Thu, 29 Apr 1999 23:12:12 GMT Subject: while (a=b()) ... In-Reply-To: <19990430000141.A5867@shalott> References: <19990430000141.A5867@shalott> Message-ID: <14120.59212.758142.722755@buffalo.fnal.gov> Marco Mariani writes: > > Which one is more ugly? Version #1 is exactly 2/3 as ugly as version #2. "$_" is 887 times more ugly; it looks very non-Pythonic to me. > ===== > > c = curs.fetchone() > while c: > print c > c = curs.fetchone() > > ===== > > while 1: > c = curs.fetchone() > if c: > print c > else: > break > > ===== From tim_one at email.msn.com Sun Apr 25 20:45:32 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 26 Apr 1999 00:45:32 GMT Subject: Handling backspace chars in a string... In-Reply-To: <37239c48.594910176@news2.bga.com> References: <37239c48.594910176@news2.bga.com> Message-ID: <000301be8f7e$16b89780$669e2299@tim> [Purple] > I'm in the poistion of having to process strings with arbitrary > numbers of backspace and newline characters in them. Your code doesn't appear to care about newlines one way or t'other. Do you ? > The backspaces actually get put in the string, so I have to handle > removing the characters that are backspaced over. > ... [rather sprawling string + indexing code] ... > This just looked rather messy to me -- I was curious if anyone know a > better way? Assuming "better" means "less messy" here, lists support appending and deleting quite naturally and efficiently; like def stripbs(sin): import string sout = [] for ch in sin: if ch == '\b': del sout[-1:] # a nop if len(sout) == 0 else: sout.append(ch) return string.join(sout, '') This essentially treats the input string as a sequence of opcodes for a stack machine, where "\b" means "pop" and anything else means "push me!". don't-use-any-indices-and-you-can't-screw-'em-up-ly y'rs - tim From claird at Starbase.NeoSoft.COM Sat Apr 24 01:10:03 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 24 Apr 1999 00:10:03 -0500 Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <7fmruj$gtm@cpca3.uea.ac.uk> <37208205.A94D0BC2@istar.ca> Message-ID: <7frjnb$qko$1@Starbase.NeoSoft.COM> In article <37208205.A94D0BC2 at istar.ca>, Eugene Dragoev wrote: >Emulating native components makes the code slower - no doubt about that. >I was not questioning the use of native widgets in Tcl/Tk but just >wondering if all the languages that use Tk (Perl/Python etc.) will have >harder time following the current Tcl/Tk. . . . You also write, in a related article, that "I just thought that porting GUI library that contains native widgets is more difficult." I believe that both of these perceptions are factually incorrect. As much as possible (and more as time goes on?), native com- ponents (in the sense of user interface) are implemented as native components (that is, by invo- cation of low-level OS-specific facilities). In any case, I'm not aware of any particular impact any of this has on the ease of binding "foreign" languages such as Perl and Python to Tk. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From Lance_Ellinghaus at marshall.com Wed Apr 7 18:30:35 1999 From: Lance_Ellinghaus at marshall.com (Lance Ellinghaus) Date: Wed, 7 Apr 1999 22:30:35 GMT Subject: oracledb-0.1.2 and python 1.5.2b2 Message-ID: <8825674C.007BA8E4.00@marshall.com> Has anyone gotten these two things to compile together and run? I am having trouble with the compile. Looks like something changed in the Makefile on Python 1.5.2b2 from previous python make files that makes oracledb-0.1.2 not compile. Can anyone help?? Thanks, Lance From aa8vb at vislab.epa.gov Mon Apr 5 10:44:08 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Mon, 5 Apr 1999 14:44:08 GMT Subject: Subattributes of classes Message-ID: <19990405104408.A807008@vislab.epa.gov> class A: def __init__( self ): self.attr = 123 self.attr.subattr = 456 # <--------- Error! a = A() This generates an error as I would have expected. However, I see the same syntax in: demos/tkinter/matt/canvas-with-scrollbars.py and it works: self.draw = Canvas(self, width="5i", height="5i", background="white", scrollregion=(0, 0, "20i", "20i")) self.draw.scrollX = Scrollbar(self, orient=HORIZONTAL) self.draw.scrollY = Scrollbar(self, orient=VERTICAL) ^^^^^^^^^^^^ Why? Randall From blipf at yahoo.com Wed Apr 7 12:33:19 1999 From: blipf at yahoo.com (Flbill Blipf) Date: Wed, 07 Apr 1999 09:33:19 -0700 Subject: Tkinter and centering Message-ID: <370B88CF.993D8847@yahoo.com> Hi, How do I center a window with Tkinter? If I use this: from Tkinter import * root = Tk() Label(root,text="Cough Cough Cough").pack() root.update() sw = root.winfo_screenwidth() sh = root.winfo_screenheight() w = root.winfo_width() h = root.winfo_height() newGeometry='+%d+%d' % ((sw/2)-(w/2), (sh/2)-(h/2)) root.geometry(newGeometry=newGeometry) root.mainloop() The window appears in a semi-random location and then staggers to the center. If I remove root.update(), winfo_width and winfo_height both return 1. From wc at zyan.com Tue Apr 6 23:53:41 1999 From: wc at zyan.com (John B. Williston) Date: Wed, 07 Apr 1999 03:53:41 GMT Subject: Crappy Software was Re: [OffTopic: Netscape] Re: How should Python be evangelized? References: <7dos4m$usi$1@nnrp1.dejanews.com> <7dqs0h$lcq$1@nnrp1.dejanews.com> <2_6M2.30$Kj1.679@198.235.216.4> <37019F42.EA55CA8@kanga.org> <009d01be7b47$8a9a6020$f29b12c2@pythonware.com> <7dtmso$7u6$1@news.clarkson.edu> <3703ca33.9749737@news.bctel.ca> <37089dcb@fermi.armored.net> Message-ID: <370bd698.137859911@news.dslspeed.com> On Tue, 06 Apr 1999 04:40:22 GMT, wtanksle at dolphin.openprojects.net (William Tanksley) wrote: >The one reason I like Opera (I'm not using it now because I'm a cheapskate): >it fully and nearly correctly supports the keyboard. Oh, it's CSS is better >than anything else, but like you said I don't code for the best, I code for >_everything_. Just FYI, I purchased Opera as a student and paid only $18 for it. And if you *really* want to see IE lose, your best bet is to put your money where your mouth is. Opera has a chance to dethrone IE. John From ben_darnell at hotmail.com Mon Apr 26 20:44:37 1999 From: ben_darnell at hotmail.com (Ben Darnell) Date: Mon, 26 Apr 1999 19:44:37 -0500 Subject: Launching web browser programmatically References: <3724EB92.248E7933@hotmail.com> <7g2rm1$t8i$1@m2.c2.telstra-mm.net.au> Message-ID: <37250874.1F93A13B@hotmail.com> Mark Hammond wrote: > If you have the win32 extensions, you can use win32api.ShellExecute() > > Anything you can use after "start" you can pass to ShellExecute - ie, a URL, > a document file, .exe, etc. > > Thanks. That's just what I'm looking for. Ben From your at email.com Sat Apr 10 04:41:23 1999 From: your at email.com (your at email.com) Date: 10 Apr 1999 08:41:23 GMT Subject: #INCREDIBILE NON CI CREDEVO!!!!! Message-ID: <7en2rj$lej$181@fe2.cs.interbusiness.it> Hi! I posted this using an unregistered copy of Newsgroup AutoPoster 95! You can download your own copy for FREE from: http://www.autoposter.cc or just click this line: http://www.autoposter.cc/files/news200.exe --- NON E' UNA TRUFFA:ESISTE LA POSSIBILITA' DI ARRICCHIRTI CON SEMPLICISSIMO SCAMBIO DI MESSAGGI VIA RETE!! Rasmus Lino ? un ragazzo danese che ha incassato in 5 mesi la bella cifra di 64.700.000.000? !!!!!!!!!! Una notizia del genere non passa inosservata!!!!se vuoi sapere come ha fatto questo simpatico giovanotto ad arricchirsi cosi in fretta eccoti la spiegazione, ma prima di tutto sappi : Non mi interessa stare qui a convincerti sulla bont? o meno di questo metodo. IO APPENA LO PRESO HO DECISO DI PROVARCI !! Questa catena si differenzia dalle altre per la sua potenzialit? di guadagno con un ingresso pari al costo di DIECI CAFFE'. STAMPA SUBITO QUESTO MESSAGGIO :Ti servir? in futuro. Tutto ci? che ti serve sono : -6 banconote da 2.000 lire -6 francobolli per lettera. CHE COSA HAI DA PERDERE ? Telo dico io N-I-E-N-T-E.Sarebbe da stupidi non provarci !! ED ORA ECCO COME PARTECIPARE: 1?PASSO: Prendi 6 fogli di carta separati e scrivi ci? che segue : HO PARTECIPATO ANCH'IO. HO ALLEGATO 2.000 LIRE. BEVI UN CAFFE' ALLA MIA SALUTE. Ora prendi le banconote da 2.000 Lire e mettine una in ognuno dei fogli di carta che hai preparato prima, opportunamente piegati in modo da non rendere visibile la banconota dall' esterno (per evitare accidentali furti). 2? PASSO: Inserisci il foglio con la banconota da 2.000 lire in una busta e chiudila (fai lo stesso con gli altri 5 fogli). Se non lo farai le tue possibilit? di guadagno si ridurrebbero moltissimo. Ci? che stai facendo ? OFFRIRE 6 CAFFE' : PER QUESTO E' ASSOLUTAMENTE LEGALE !!! 3?PASSO: Spedisci le 6 buste ai seguenti indirizzi: #1 R. Biancofiore Via Gaet. Grassi, 8/3 74015 Martina Franca (TA) #2 S. Carpina Via Friuli, 5 56124 Pisa #3 Marta Carletti Via Marcelletta, 13 60027 Osimo (AN) #4 Giulio Debbia Via Tirelli, 41040 Corlo (MO) #5 F.Giovanetti Via Batezzate, 127 41040 Formigine (Mo) #6 G.Smiriglia Via Strada 31, n?7 87010 Terranova da Sibari (Cs) (Italy) 4? PASSO: Ora cancella il nominativo #1 dalla lista che vedi sopra, e sposta in alto gli altri nominativi (il #6 diventa #5 il, #5 diventa #4 ecc.) e aggiungi li tuo nominativo come #6 nella lista. 5? PASSO: Spedisci questo messaggio ricordando di inserire il tuo nome al #6 ad almeno 200 newsgroup(ce ne sono almeno 50.000 !!!!). Te ne bastano 200, e perch? no, invia anche ad amici che hai in chat, ma ricorda pi? mail spedisci pi? ti arrivano soldi!!!! ORA IL DISCORSO SI FA INTERESSANTE Di 200 contatti con diversi newsgroup, ipotizziamo pessimisticamente che tu riceva solo 5 adesioni. Quindi con il tuo nome al #6 posto su ogni messaggio ricevi in tutto 10.000 lire. Ogni persona che ti ha spedito 2.000 lire spedisce anche lei 200 messaggi ad altrettanti newsgroup, ciascuna con il tuo nome al #5 posto, supponendo che anche loro ricevano 5 adesioni,questa fase porta altre 50.000 lire a te. Queste 25 persone fanno almeno 200 messaggi con il tuo nome al #4 posto e nelle medesime sfortunate persone solo 5 persone aderiscono questo ti porta altre 250.000 lire. ora queste 125 persone continuano con la medesima procedura (il tuo nominativo ora ? al #3 posto) ancora solo 5 adesioni ci? porta altre 625 persone e quindi 1.250.000 lire a te!!! ORA ARRIVA LA PARTE PIU' INTERESSANTE : Queste 625 persone spediscono 200 messaggi con il tuo nominativo al 2? posto questo ti porta altre 6.250.000 lire!!!! Infine queste 3125 persone scrivono 200 messaggi con il tu nome al #1 posto e riceverai come prima 5 adesioni questo ti porta 31.250.000 lire !!! tutto con un investimento iniziale di solo 12.000 lire e tutto ci? ipotizzando solo 5 adesioni che ? davvero un numero molto basso di solito sono 20-30 ;ora eccoti una media con 15 adesioni al posto#6 30.000 lire al posto #5 450.000 lire al posto #4 6.750.000 lire al posto #3 101.250.000 lire al posto #2 1.518.750.000 lire al posto #1 22.781.750.000 lire =========================== TOTALE 23.008.480.000 LIRE INCREDIBILE!!!!!!!!!!!!!!! Senza sperare in tanta grazia . perch? non provate a vedere se funziona?? questa catena conviene a me, a te, e a tutti quelli che leggono : in pratica tutti ci arricchiremo con sole 12.000 lire , 6 francobolli, E SENZA RECARE DANNO A NESSUNO . ORA STA A TE DECIDERE !!! (ma credo che tu l'abbia gi? fatto) il meccanismo ? chiaro i ragionamenti sopra riportati sono ineccepibili!!! Che cosa sono poi 12.000 lire ?? Sicuramente ti divertirai e avrai di sicuro molta pi? possibilit? di fare soldi rispetto agli sconvenientissimi giochi statali. poi non serve fortuna perch? ? un gioco puramente statistico Ma ricorda : se vuoi che tutto funzioni devi essere ONESTO (anche perch? ce n'? per tutti !!! cambiare le modalit? porterebbe danno a te e agli altri seguono due lettere per raccontarti di se che hanno provato: ....un giorno navigando leggo questo messaggio provo e dopo 4 settimane non mi ricordavo pi? del gioco fin quando arrivarono le prime buste e manmano le altre.era incredibile posso dire di avere guadagnato sicuramente 60.000.000 lire . adesso possiedo una nuova macchina e quest'estate sono stato in vacanza in Australia wow !!! Sono un ragazzo di 24 anni e 2 mesi fa ero un po' accorto di soldi e essendo un appassionato di comp. mi imbattei in questa lettera che diceva vuoi vincere tanti soldi?? perch? non provare .. .. e adesso ho un computer nuovissimo e mi avanzano ancora tanti soldi. PROVA E VEDRAI COME IL TUO PORTAFOGLIO SI GONFIA From fredrik at pythonware.com Wed Apr 21 08:03:30 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Apr 1999 12:03:30 GMT Subject: Tkinter Q References: <7fkcg3$61o$1@news.rz.uni-karlsruhe.de> Message-ID: <00f701be8bee$f9cf9200$f29b12c2@pythonware.com> Bjoern Giesler wrote: > whenever I try to construct a slightly more complicated Tkinter test at > the Python console, I get a FloatingPointError. The same program written > to a file works flawlessly. Is that a known bug? answer 1: no. answer 2: what console? the plain interpreter command line interface? if so, don't. that interface doesn't keep the Tkinter event loop going, so it's kinda impossible to do any meaningful Tkinter programming from it. (on the other hand, if you're using IDLE or any other Tkinter- based environment which sports a console window, please consider posting some sample code...) From bhowes at cssun3.corp.mot.com Wed Apr 14 13:02:32 1999 From: bhowes at cssun3.corp.mot.com (Brad Howes) Date: 14 Apr 1999 10:02:32 -0700 Subject: simple indexed file module? References: Message-ID: >>>> 'Joe Strout (joe at strout.net)' asked the following: JS> For a CGI script I'm working on, I need to keep a couple of indexed JS> files.[snip] I have good luck with the `anydbm' module. This gives you keyed indexing into a data file. It attempts to import dbhash, gdbm, dbm, or dumbdbm as a backend. On my Windows/NT box, there is dbhash. I've used gdbm on Unix. Not sure what comes with the Macintosh install. Brad -- Brad Howes bhowes at motorola.com Principal Compass Hacker Work: +1 602 446 5219 Motorola Cell: +1 602 768 0735 From tim_one at email.msn.com Sat Apr 17 01:25:43 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 17 Apr 1999 05:25:43 GMT Subject: restore sources from PYC [Q] In-Reply-To: <7f84mq$a7c@chronicle.concentric.net> References: <7f84mq$a7c@chronicle.concentric.net> Message-ID: <000901be8892$bd97d680$ee9e2299@tim> [Christopher Petrilli] > ... in fact many companies put some bizarre constructions in their code > so they can prove in court that someone "stole" the code... When I was in grade school, I noticed that a map of my neighborhood showed a non-existent road going smack thru the middle of a large non-acknowledged pond. Investigation revealed that map makers insert deliberate errors for the same reason: to prove that someone else copied their work. That was the day I decided to become a programmer . all-of-the-intrigue-with-none-of-the-tedious-surveying-ly y'rs - tim From lutz at rmi.net Sun Apr 4 15:42:41 1999 From: lutz at rmi.net (Mark Lutz) Date: Sun, 4 Apr 1999 13:42:41 -0600 Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com><7e30fp$8vf$1@news1.rmi.net> <14085.18282.936883.727575@bitdiddle.cnri.reston.va.us> Message-ID: <7e8f25$ejm$1@news1.rmi.net> Sidebar: you have to be careful with amazon's numbers, because they tend to change too fast to be very useful. I've seen Programming Python go from #500 to #5000 in a day or two; Learning Python changes just as fast (in fact, it was ranked #409 as I wrote this). Their numbers are probably okay as a quick-and-dirty estimate; but for a better picture, you'd have to take an average over a long period of time, and then take into consideration that their numbers are skewed towards online shopper's interests. Publishers get much more useful sales information from the big distributors. OTOH, I wouldn't mind seeing Python in the top 100 ;-). --Mark Lutz (http://rmi.net/~lutz) Jeremy Hylton wrote in message <14085.18282.936883.727575 at bitdiddle.cnri.reston.va.us>... >This is really useless information, but I guess I along with most >other people are fascinated by top ten lists and movie grosses and >... Amazon.com sales ranks. > >Title Amazon.com Sales Rank >Learning Python 1,570 >Programming Python 1,685 >Python : Pocket Reference 3,218 >Internet Programming With Python 8,720 >Mastering Regular Expressions 931 >Programming Perl, 2nd ed. 81 >Perl Cookbook 136 >The C Programming Language 478 >The C++ Programming Language 1,003 >Tcl and the Tk Toolkit 3,362 > >Learning Python seems to be selling well for a book that hasn't been >shipped. :-) From bkhunter at best.com Wed Apr 28 14:07:51 1999 From: bkhunter at best.com (Bill) Date: Wed, 28 Apr 1999 18:07:51 GMT Subject: Designing Large Systems with Python References: <3725CA37.2027327D@lemburg.com> Message-ID: <37274e10.12544588@nntp1.ba.best.com> On Tue, 27 Apr 1999 16:31:19 +0200, "M.-A. Lemburg" wrote: >Projects around 50k are still well manageable using an editor >like Xemacs; larger projects probably need the help of systems >like SNIFF (which offers Python support). Are you talking about SNIFF+ from TakeFive Software? I browsed their site and could only find mention of C++ and Java support. Any pointers? From landrum at foreman.ac.rwth-aachen.de Mon Apr 19 11:26:49 1999 From: landrum at foreman.ac.rwth-aachen.de (Greg Landrum) Date: Mon, 19 Apr 1999 17:26:49 +0200 Subject: Tkinter performance Message-ID: <371B4B39.8B78BC7A@foreman.ac.rwth-aachen.de> While I'm at it, I have a performance question about Tkinter. I am thinking about doing a python/Tkinter port of a program which currently uses C/Xlib (or C/quickdraw on the Mac). I'd love to get this to work because then I would (finally) have a version which could work under Win95/98/NT. But I'm worried about performance issues. The program does 3D graphics (molecular/crystal visualization and orbital plots). I handle all of the perspective/transformation stuff myself, so I don't need any 3D functionality. I do need something which can draw reasonably quickly however. Suppose I need to draw a couple hundred circles and several thousand line segments (these are mostly connected, so I can use things like XDrawLines to cut down function calls) at every update. 1) Can Tkinter on a "typical" PC (say a P200) deliver a "reasonable" update rate (a couple of frames per second would probably cut it)? 2) Is there anyway to do double-buffering to avoid flashing during redraws? I am guessing that the answer to both of these of these questions is "No", but I'd love to hear a contrary opinion. I have considered using something like wxPython, but that cuts the portability of the application down rather than increasing it. At least until there are bindings for the Motif/Lesstif versions of wxWindows. thanks for any help, -greg -- --------------------- Dr. Greg Landrum (landrum.NOSPAM at foreman.ac.rwth-aachen.de) Institute of Inorganic Chemistry Aachen University of Technology From phd at sun.med.ru Wed Apr 28 11:07:44 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Wed, 28 Apr 1999 19:07:44 +0400 (MSD) Subject: 'sourcing' Python scripts? In-Reply-To: <372713AD.6ABA444@cern.ch> Message-ID: Hello! On Wed, 28 Apr 1999, Haimo G. Zobernig wrote: > this might be a unix rather than a Python problem, but I need to set Yes, it is of unix... > environment variables from a Python program *in the parent process* > that is running the Python script ( a la os.environ['BAR'] = 'foo' ). > In other words, I want to achieve the equivalent of 'sourcing' the > Python script. Can this be done? Even better would be a solution that > also works on the various WinAbominations... (well, NT at least) Don't know about NT, sorry. Will talk about unix. Preface. When you run a program (python script, e.g.), shell (that run the program) forks and looses any connection to running program. The program may do anything it wants (change current directory, for example), but all chnages are local to the program's process (and children). Parent shell does not know anything. This is the nature of multitasking environment. For the shell, the only way to set environment (change directory, etc.) is to give commands to that shell. Well, now you want to run a program, and pass the results to a parent shell. Here is how you should do it. First, your program should write the shell commands to stdout. Second, you need to ask the shell to process these commands: (in shell command line) eval `myscript.py` Note "eval" and backticks. Backticks in most (if not all) unix shells mean "run the command and save its stdout". Eval processes saved stdout as shell commnads. Please note. There are two different kinds of shell syntax - Bourne shell and C shell. Usually any program that intended to run under such conditions, can output two different set of commands - for Bourne shell and for C shell. Some programs parse SHELL env var (if it matches /bin/*csh - it is a C-shell variant, else it is Bourne shell), some programs can be controlled with command line switch (-c for c-shell, nothing for bourne shell). Choose your method, but please do not force your users to switch a shell just because your program can only work with one shell but not another. Example: (in python program my_prog.py): if under_cshell: # expect C shell print "setenv MY_VAR1 value1" print "setenv MY_VAR2 value2" else: # expect Bourne shell print "MY_VAR1=value1" print "MY_VAR2=value2" print "export MY_VAR1 MY_VAR2" (in shell): eval `my_prog.py` > Haimo G. Zobernig > Haimo.Zobernig at cern.ch Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From ddb at crystal.uwa.edu.au Tue Apr 27 03:16:10 1999 From: ddb at crystal.uwa.edu.au (Douglas du Boulay) Date: Tue, 27 Apr 1999 15:16:10 +0800 Subject: sharing variables in fortran Message-ID: <3725643A.734B9F06@crystal.uwa.edu.au> I am wondering if it is possible to coerce python to use memory addresses corresponding to a fortran common block (by way of a c extension) for storage of certain variables. I am looking (still) at converting a large fortran program to use python/tkinter/pyOpenGL with an intermediate C-interface to the more numerically intensive fortran OpenGL rendering routines. Currently it looks like there are around 500 variables controlling various aspects of the rendering which need to be set and adjusted in python/tkinter routines, and whose values are needed by the fortran code. If it is possible to avoid using 500 Py_PassTuple() etc. C routines every time the user moves the mouse, it would be very useful to know. I am sure it is possible to get the tkinter widgets to read current state before being invoked and then call another C function to copy it back, but if there was a way to share the fortran/C variable address space so that the tkinter widgets changed them directly .... Thanks in advance for any info. Doug (still a python beginner) P.S. if you are interested to see what a beast the gui really is take a look at part of it here: http://www.crystal.uwa.edu.au/~ddb/panels.py (it doesn't actually do anything constructive yet) From akuchlin at cnri.reston.va.us Wed Apr 21 16:49:09 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Wed, 21 Apr 1999 16:49:09 -0400 (EDT) Subject: Project for newbie In-Reply-To: <70alf7.qc6.ln@loopback> References: <70alf7.qc6.ln@loopback> Message-ID: <14110.12533.232498.655489@amarok.cnri.reston.va.us> Pete Jewell writes: >I've read my way through the tutorial, and am now stuck - where do I go >from here? I want to learn how to use Python, but don't have any >pressing projects at the moment - can anyone suggest a program I should >have a go at writing, to help me learn the language further? Having third parties provide ideas usually doesn't result in anything interesting. I have a list of projects on my Web page, but they're all extremely unlikely to appeal to anyone who isn't me (and even I'm a bit cool on some of them). It's much better to ask what are you interested in. GUIs? You could write a simple game or application with Tkinter, Swing, GTk, or whatever toolkit you want to learn, or join an existing effort like PyRPG. Command-line stuff? Perhaps there's some system administration script you could write; for example, I have a PPP startup script for my own use; maybe there's something you do often that could be automated. -- A.M. Kuchling http://starship.python.net/crew/amk/ When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl. -- Anonymous From alrice at swcp.com Sat Apr 10 01:10:07 1999 From: alrice at swcp.com (Alex Rice) Date: Fri, 09 Apr 1999 23:10:07 -0600 Subject: disenchanted java user mumbles newbie questions References: <3705980A.1C7E9512@swcp.com> <000101be7d9a$e1ae88a0$879e2299@tim> Message-ID: <370EDD2F.21310047@swcp.com> Tim Peters wrote: [tons of excellent pointers] > Why do I suspect you're a Windows programmer ? Thanks for all the suggestions. Python rocks. I really like wxPython too. As far as me being a Windows programmer, well not really. I'm equally at home thrashing around in Windows and Unix. In fact this evening I discovered your python-mode.el. What a great Emacs mode! Thanks again, Alex Rice -- MindLube Software From dozier at bellatlantic.net Tue Apr 20 17:58:49 1999 From: dozier at bellatlantic.net (Bill Dozier) Date: Tue, 20 Apr 1999 17:58:49 -0400 Subject: unpickling an NT object in Solaris? References: Message-ID: Problem solved. It seems that the cPickle module is not sufficiently cross-platform. The text mode of pickling is not cross-platform and seems to expect UNIX linefeeds. :P If I use the binary mode, everything's OK. In article , dozier at bellatlantic.net (Bill Dozier) wrote: >I created an object running python on NT and pickled it. I have no problem >unpickling on NT, but when I ftp'd the file over to Solaris, I get an >ImportError exception ("No module named __main__^M") when I try to >unpickle it. > From arw at ifu.net Mon Apr 5 16:32:00 1999 From: arw at ifu.net (arw) Date: Mon, 5 Apr 1999 20:32:00 GMT Subject: GadFly - MemoryError Message-ID: <199904052036.QAA22515@ifu.ifu.net> Whoops. I didn't notice the python-list was cc'd on the last message oops. Sorry, I didn't see the cc to the python list on the last message. Please also make sure you are using the kjbuckets extension module, as it significantly improves both speed and memory usage. Lemme know... As I say, I've run some pretty large gadfly databases on some pretty mediocre machines... -- Aaron Watters === time flies like an arrow. fruit flies like a banana. From nelson at crynwr.com Sun Apr 25 09:23:35 1999 From: nelson at crynwr.com (Russell Nelson) Date: 25 Apr 1999 09:23:35 -0400 Subject: GUI other than Tkinter References: <3721567f.1748033@news> Message-ID: mrfusion at bigfoot.com writes: > Well, I've just about given up on EVER getting Tkinter to work on my > Win98 machine. Is there any other GUI module that I can get that > doesn't require TCL/TK to be installed on my machine? Isn't there > something called GD? There's pygtk, which uses the gtk toolkit. -- -russ nelson http://crynwr.com/~nelson Crynwr supports Open Source(tm) Software| PGPok | There is good evidence 521 Pleasant Valley Rd. | +1 315 268 1925 voice | that freedom is the Potsdam, NY 13676-3213 | +1 315 268 9201 FAX | cause of world peace. From tim_one at email.msn.com Sat Apr 17 01:20:02 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 17 Apr 1999 05:20:02 GMT Subject: restore sources from PYC [Q] In-Reply-To: <37177D8E.FF43BF65@bigfoot.com> References: <37177D8E.FF43BF65@bigfoot.com> Message-ID: <000801be8891$f238d980$ee9e2299@tim> [Hoon Yoon] > What happens if you do NOT want your pyc codes to be reverse > engineered? You would have to add a layer of encryption to the .pyc files, and decryption to the interpreter. I'm sure the U.S. govt would be delighted to help . > Can you prevent someone from doing this type of rev eng? Nope. You can strive to make it more difficult, but you can't stop it. > Some members in my IT committee always have a problem with this > ability and often used as excuse to kill any new tech adoption. How do they feel about old tech? Like, say, C or C++? It's no great achievement to reverse-engineer algorithms from a binary native machine-code distribution either; in fact, there are a thousand people who can read Intel machine code in their sleep for everyone who can reverse-engineer .pyc files . unless-you-can-hide-your-code-from-the-cpu-a-human-can- watch-it-work-too-ly y'rs - tim From Scott.Kelley at Colorado.edu Fri Apr 23 18:08:52 1999 From: Scott.Kelley at Colorado.edu (KELLEY SCOTT T) Date: Fri, 23 Apr 1999 16:08:52 -0600 Subject: Efficient List Subtraction Message-ID: <3720EF73.CA7DDEFF@Colorado.edu> Does anyone out there have a simple way to compare two lists (some operator perhaps) and return a list of *differences*? By differences, I mean the following: If had two lists like, a = [1, 4, 5, 100] b = [4, 5] the difference between a and b (a-b) would be [1, 100]. I suppose you could write a couple of for loops to go through each list and compare them, but I thought there might be a simple way to do this. I'm also interested in a simple way to returning a list of what is identical between the two lists. In the case of the above lists, a and b, they both contain [4, 5]. If anyone out there has a suggestion (or two) I would very much appreciate it. Cheers! -Scott ------------------------------------------------------------------- Scott Kelley Phone: 303-492-1474 Dept. MCD Biology Fax: 303-492-7744 Campus Box 347 E-mail: Scott.Kelley at Colorado.edu University of Colorado Boulder, CO 80309-0347 From tville at earthlink.net Wed Apr 14 14:43:37 1999 From: tville at earthlink.net (susan e paolini) Date: Wed, 14 Apr 1999 14:43:37 -0400 Subject: Tutorial Python References: <3714BAA0.12F180F3@xs4all.nl> Message-ID: <3714E1D8.AE305670@earthlink.net> Python + KDE Tutorial Perhaps this will help Frank Frank de Bot wrote: > Does somebody knows a good tutorial on the internet especialy for python > - CGI Aplications. Currently I have several websites running on PERL (As > you can see at the bottom of this mail). Currently the searchengine has > 4100 sites and it takes about 0.80 cpu to search. This is now not a > problem, because I rarely get visitors. But I realy like to get > something that's working fast and good. (Ps I've already checked > python.org, but they aren't giving any examples (And I need them hard to > understand the language)) > Thanks in advance... > > Frank de Bot. > > -- > \\\|/// > \\ - - // > ( @ @ ) > /----------------------oOOo-(_)-oOOo--------------------\ > | | > | | > | My Email: debot at xs4all.nl | > | Homepages: http://www.searchy.net/ | > | http://www.debot.nl/ppi/ | > | | > | | > \-------------------------------Oooo--------------------/ > oooO ( ) > ( ) ) / > \ ( (_/ > \_) -------------- next part -------------- An HTML attachment was scrubbed... URL: From trashcan at david-steuber.com Wed Apr 7 23:38:44 1999 From: trashcan at david-steuber.com (David Steuber) Date: 07 Apr 1999 22:38:44 -0500 Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> Message-ID: quinn at cruzeiro.ugcs.caltech.edu (Quinn Dunkan) writes: -> (grumblegripegrunt). It's incomplete, and written when I was first learning -> python, and I haven't worked on it for a while, but I'll send it to anyone -> interested. Perhaps we could collaborate? I'd love too except that I am so new to Python that I haven't written anything in it yet. I was going to have a go at reproducing the functionality of leafnode. -- David Steuber http://www.david-steuber.com s/trashcan/david/ to reply by mail If you don't, I won't see it. As long as the answer is right, who cares if the question is wrong? From bhuzyk at kodak.com Tue Apr 13 09:01:39 1999 From: bhuzyk at kodak.com (Bruce Huzyk) Date: 13 Apr 1999 13:01:39 GMT Subject: Converting a string to a tuple References: <01be8530$65bb7120$52037e81@saints> <14098.28727.245158.616727@buffalo.fnal.gov> <00f501be857f$ff636f40$f29b12c2@pythonware.com> Message-ID: <01be85b5$f7197c90$52037e81@saints> I will now take this opportunity to revise my original post. I wish to convert a string to a tuple. My sample string should have been: s = '(1, "abc\\tef", 2)' instead of: s = '(1, "abc\\def", 2)' The problem is that the \\t part of the string gets expanded to a \011 Only the eval(string.replace(s, '\\', '\\\\')) seems to do the job. Any comments? sample code: >>> s = '(1, "abc\\tef", 2)' >>> eval(s) (1, 'abc\011ef', 2) s = '(1, "abc\\tef", 2)' >>> eval(string.replace(s, '\\', '\\\\')) (1, 'abc\\tef', 2) >>> s = '(1, "abc\\tef", 2)' >>> eval(s, {"__builtins__": {}}) (1, 'abc\011ef', 2) >>> s = '(1, "abc\\tef", 2)' >>> r = rexec.RExec() >>> s = '(1, "abc\\tef", 2)' >>> r = rexec.RExec() >>> r.r_eval(s) (1, 'abc\011ef', 2) Fredrik Lundh wrote in article <00f501be857f$ff636f40$f29b12c2 at pythonware.com>... > Charles G Waldman wrote: > > If you're concerned about safety (the "eval" could be evaluating any > > Python code, possibly a hazard if the string is coming from user > > input) then you don't want to use eval at all. > > try: > > result = eval(string, {"__builtins__": {}}) > > or: > > import rexec > r = rexec.RExec() > result = r.r_eval(string) > > > > From dfan at harmonixmusic.com Fri Apr 30 10:18:14 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 30 Apr 1999 10:18:14 -0400 Subject: while (a=b()) ... References: Message-ID: Nathan Clegg writes: | I have some deep-rooted "hates" in programming and don't even know | where some of them came from. One of them is "while 1" loops. They | seem somehow at the same level as goto statements and should be | used, in my mind, about as rarely. | | The ideal, of course, would be: | | while (c = curs.fetchone()): ... | | That is my only complaint about python, that statements cannot be | expressions. Everyone who is at all interested in loops should read Knuth's article "Structured programming with go to statements", found in his book "Literate Programming". Don't be fooled by the title or the fact that it was written in 1974. It's a comprehensive (70 pages) overview of looping constructs, including convincing proposals for some new ones. Certainly all language designers owe it to themselves to read it. -- Dan Schmidt -> dfan at harmonixmusic.com, dfan at alum.mit.edu Honest Bob & the http://www2.thecia.net/users/dfan/ Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/ Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/ From da at ski.org Thu Apr 22 01:10:28 1999 From: da at ski.org (David Ascher) Date: Wed, 21 Apr 1999 22:10:28 -0700 (Pacific Daylight Time) Subject: Directory of current file Message-ID: Tip: To find out the directory of the currently executing program, use: import sys, os if __name__ == '__main__': _thisDir = '' else: _thisDir = os.path.split(sys.modules[__name__].__file__)[0] (note that this is a relative path). --david From mrfusion at bigfoot.com Wed Apr 21 00:05:56 1999 From: mrfusion at bigfoot.com (mrfusion at bigfoot.com) Date: Wed, 21 Apr 1999 04:05:56 GMT Subject: Tkinter hangs on mainloop References: <371c19bb.60709557@news> <008a01be8b11$e17fb320$f29b12c2@pythonware.com> <371d3ae9.134747887@news> Message-ID: <371d4d4a.435769@news> On Wed, 21 Apr 1999 02:49:43 GMT, mrfusion at bigfoot.com wrote: >>> It hangs. I think I've narrowed it down the the tcl\tk installation. The wish80 program doesn't seem to work correctly. If I double click on the program, nothing happens. I downloaded an earlier version of tcl\tk, installed it and that version of wish worked just fine. I've also noticed that when I try to start my "hello world" python\TK scipt, while it's hanging there it seems to keep spawning wish80 processes. If I kill them in the task switcher, another one (or two or three) keeps showing up. I've tried downloading the latest install (8.0.5) files directly from http://www.scriptics.com but that didn't seem to fix anything. Does this shed any light on the problem??? Thanks, Tom From scrompton at quantisci.co.uk Thu Apr 15 14:51:44 1999 From: scrompton at quantisci.co.uk (Stephen Crompton) Date: Thu, 15 Apr 1999 19:51:44 +0100 Subject: Whoops. (was timezone stuff driving me bonkers) Message-ID: <37163540.6D692E8@quantisci.co.uk> Sorry folks. That was meant to be a personal response to Marc. Apologies. Steve. From S.I.Reynolds at cs.bham.ac.uk Sun Apr 18 14:44:11 1999 From: S.I.Reynolds at cs.bham.ac.uk (Stuart I Reynolds) Date: Sun, 18 Apr 1999 19:44:11 +0100 Subject: Install trouble Message-ID: <371A27FB.5166@cs.bham.ac.uk> Dear all, I'm having trouble installing the latest Python release. I'm also trying to install for multiple platforms (Solaris and DEC OSF1). Here's what happens when I try to do the Solaris installation: % cd ~/tmp/ % tar -xvf py152.tar % cd Python-1.5.2/ % mkdir /bham/ums/solaris/pd/packages/Python-1.5.2/ % cd /bham/ums/solaris/pd/packages/Python-1.5.2/ #This is how the README instructs X-platform installs #These options worked with the 1.5.1 install % /home/pg/sir/tmp/Python-1.5.2/configure --exec-prefix=/bham/ums/solaris/pd/packages/Python-1.5.2 --prefix=/bham/ums/common/pd/packages/Python-1.5.2 --with-gcc --with-thread % make [. . . gcc -c -g -O2 -I/home/pg/sir/tmp/Python-1.5.2/Python/../Include -I.. -DHAVE_CONFIG_H -DPLATFORM='"sunos5"' \ /home/pg/sir/tmp/Python-1.5.2/Python/getplatform.c make: Fatal error: Don't know how to make target `../Include/patchlevel.h' Current working directory /bham/ums/solaris/pd/packages/Python-1.5.2/Python *** Error code 1 make: Fatal error: Command failed for target `Python' . . .] Cheers, Stuart From tismer at appliedbiometrics.com Fri Apr 23 15:15:58 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 23 Apr 1999 19:15:58 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> Message-ID: <3720C6EE.33CA6494@appliedbiometrics.com> Just did a little more cleanup to the code. This it is: def read_write_bulk(input, output, exclude): bufsize = 1 << 16 ; splitter = ">" ignore=exclude.has_key ; split=string.split ; No = None buffer = input.read(bufsize) got = len(buffer) while 1 : pieces = split(buffer, splitter) idx = 0 inner = pieces[1:-1] for piece in inner: idx = idx+1 ; key = split(piece, No, 1)[0] if ignore(key): del inner[idx] ; idx = idx-1 output.write(splitter) output.write(string.join(inner, splitter)) if got==0: break chunk = input.read(bufsize) buffer = splitter+pieces[-1] + chunk got = len(chunk) if got==0: buffer = buffer+splitter # spill last one Also, I think with this I/O layout, buffering of the files doesn't count any more at all. Let me know if it is still much slower than Perl. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 quinn at agora.ugcs.caltech.edu Mon Apr 12 18:08:58 1999 From: quinn at agora.ugcs.caltech.edu (Quinn Dunkan) Date: 12 Apr 1999 22:08:58 GMT Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> <370E4F3E.F9C2CD07@lockstar.com> Message-ID: On Fri, 09 Apr 1999 13:48:46 -0700, Joe Strout wrote: >In article , Quinn Dunkan > wrote: > >> pov.py v0.0: >> http://www.calarts.edu/~elaforge/pov/ >> >> I guess it's released now :) > >Cool! Looks very neat. I'm not quite clear on how you're planning to >handle animations. Will your Python script spit out a different >POV-Ray script for each time point? Or will it spit out a whole series >of them? Some things, like flocking behavior, are really hard to >implement in a clock-independent way. Um, I guess I'm not understanding what you mean... "will it spit out a bunch of pov scripts or will it spit out a bunch of pov scripts?" Er, yes :) (different script for each time point). I see no reason to use pov's animation features (clock, etc) we can do all that from python better. One of my original frustrations with animation under pov was that you couldn't keep a state between frames. While it's an elegant approach in theory, I don't want to do calculus to drop a ball, and huge #case #range etc. to have it bounce :) So I think my approach to clock independence would be to have stateful objects that when you tell them advance time_interval they modify their velocity and advance themselves. Pre-Newtonian physics, I guess, but I'm still a physics idiot :) I'm sure someone more math-minded than myself could come up with some cool ideas / code. >Also, I see matrix transforms are on your to-do list. I suggest you >use the Numeric module. Use dot(m1,m2) or dot(m1,v) to combine >matrices or apply a transformation matrix to a vector, respectively. Hmm... I'd rather not require external packages if it can be avoided. If the matrix stuff is trivial, I'll reinvent it. But it's a good idea to look at NumPy anyway because there's probably some stuff in there that will be useful in other ways too. I've already made my own vectors, but it was a Learning Experience :) BTW, the initial release had some minor code rot that made it non-functional (transforms in the wrong place, etc.) but I replaced it pretty quickly. From mnot at pobox.com Mon Apr 12 17:50:02 1999 From: mnot at pobox.com (Mark Nottingham) Date: Mon, 12 Apr 1999 21:50:02 GMT Subject: ConfigParser module and alternatives (flad, flan) References: <19990331160323.21601.00000471@ng-fi1.aol.com><7du3ab$3ag@chronicle.concentric.net> <371219E9.9EA91839@home.com> Message-ID: <003801be852e$6b8f5d20$0301a8c0@cbd.net.au> Just to jump in here (haven't read the whole thread, I've been away for a while and BOY is my mail piled up), you might have some luck the underdeveloped Conf.py module if ConfigParser doesn't do it for you -- http://www.pobox.com/~mnot/script/python/ ----- Original Message ----- From: Jim Meier Newsgroups: comp.lang.python To: Sent: Tuesday, April 13, 1999 1:59 Subject: Re: ConfigParser module and alternatives (flad, flan) > > > Mike Orr wrote: > > > I'm not sure if I'll use ConfigParser for the next version. I don't > > really need the sections (multiple files work just fine, using the filename > > for the section name), and I haven't found a use for the the %(other_key)s > > substitutions. On the other hand, it doesn't handle multiple values (the > > same key repeated within a record), which I sometimes need. > > > > Attached is a wrapper class for ConfigParser which supports booleans > > and can also return an entire section as a dictionary (or all the sections > > as nested dictionaries). I find these make it a little more convenient. > > > > Why not simply use a file of python expressions? Like this: > > {'section1': { > 'key1':[1,2,3,'value',['useful','nesting','eh?']], > 'key2':'anotherval' > }, > 'section2': { > 'subsection':{ > 'subkey':5 > } > } > } > > I beleive you can even use variable names in such files for application-specified > substitutions, like this: > > (python app defines variable "rootdir") > > {'pathssection': { > 'fontpath': rootdir+'/font/' > } > } > > This introduces some major security problems, and is a little difficult to edit, > but there is very little parsing needed to make it usable. Does anyone know of a > way to limit the damage a user can do to such a file? > > Another idea is to run your config file through a simple macro utility (or do the > macro conversion in python itself) to convert it into python code to eval. > > Jim Meier > > > From mal at lemburg.com Tue Apr 13 11:46:39 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 13 Apr 1999 15:46:39 GMT Subject: rfc822 date header References: <3712D863.2A8148BC@rubic.com> <3712F4C1.52327AF4@lemburg.com> <371318BC.E131EDF0@oratrix.com> Message-ID: <371366DF.DE55B6@lemburg.com> Jack Jansen wrote: > > "M.-A. Lemburg" wrote: > > > > Jeff Bauer wrote: > > > > > > Is there a reasonably bulletproof way to generate an > > > rfc822-compliant date header using the time module? > > > > > > The reason I ask is I recall a number of subtle > > > errors in this regard, reported by Chris Lawrence, > > > among others. > > > > According to the RFC, time.ctime() should do the trick... > > but it's probably locale aware which the RFC doesn't account > > for. > > Which RFC are you referring to? time.ctime() output is definitely *not* > compatible with RFC822. But it should be easy enough to come up with a > time.strftime() format that does the right thing... Ah, sorry, I mixed up HTTP and RFC822. According to RFC 2068 (HTTP 1.1) the result of time.asctime() is a valid date header. Since time.ctime() is short for time.asctime(time.localtime(ticks)) it would not result in the correct value for HTTP either (:-/ second Ooops). You'd have to use time.asctime(time.gmtime(ticks)). Oh well. Anyway, mxDateTime does the right thing (and also allows parsing those beasts). Cheers, -- Marc-Andre Lemburg Y2000: 262 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From aahz at netcom.com Wed Apr 28 14:18:19 1999 From: aahz at netcom.com (Aahz Maruch) Date: Wed, 28 Apr 1999 18:18:19 GMT Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: In article , Florian Weimer wrote: > >(Quotation from the Perl 4 manpage. This version doesn't have an >`exists' function.) Then you've just made a completely irrelevant comment, on the order of referring to Python 1.2. Perl 5 has been out for more than two years, and there are so many improvements that I don't know of *anyone* who's doing new work in Perl 4. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Hi! I'm a beta for SigVirus 2000! Copy me into your .sigfile! From vkolosov at unitedmedia.com Fri Apr 16 17:40:39 1999 From: vkolosov at unitedmedia.com (Kolosov, Victor) Date: Fri, 16 Apr 1999 21:40:39 GMT Subject: smtplib error in 1.5.2 Message-ID: <461182F0B9B7D111B4000008C7282ADC22B04E@nynt04.umny.scripps.com> Hi, Everything has seemed to work in 1.5.1 but after installing 1.5.2 on our Unix box running Solaris 2.5 I get this error when trying to use smtplib >>> import rfc822, string, sys >>> import smtplib >>>msg='Test Message' >>>s = smtplib.SMTP('localhost') >>> s.sendmail('me at my.com',['me at my.com'],msg) Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.5.2/smtplib.py", line 480, in sendmail (code,resp)=self.data(msg) File "/usr/local/lib/python1.5.2/smtplib.py", line 374, in data self.send(quotedata(msg)) File "/usr/local/lib/python1.5.2/smtplib.py", line 134, in quotedata re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)) File "/usr/local/lib/python1.5.2/re.py", line 48, in sub return pattern.sub(repl, string, count) File "/usr/local/lib/python1.5.2/re.py", line 133, in sub return self.subn(repl, string, count)[0] File "/usr/local/lib/python1.5.2/re.py", line 167, in subn regs = match(source, pos, end, 0) TypeError: argument 1: expected read-only character buffer, list found ====== Is there something obvious I do not see? From pkleynjan at my-dejanews.com Sat Apr 24 17:55:00 1999 From: pkleynjan at my-dejanews.com (pkleynjan at my-dejanews.com) Date: Sat, 24 Apr 1999 21:55:00 GMT Subject: Beginner - Tkinter info References: <371c59e9.2723125@news.tin.it> <371B453E.C3F83831@foreman.ac.rwth-aachen.de> <004301be8a99$0faf7920$f29b12c2@pythonware.com> Message-ID: <7ftejj$pb9$1@nnrp1.dejanews.com> Fredrik et al, > there's something called websucker.py down in the Tools > directory in the Python distribution: Call me stupid... I can't find websucker.py in either the Windows or Linux 1.5 distributions... Python.org and starship come up empty as well... Any pointers..? Thanks, -Peter -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From befletch at my-dejanews.com Fri Apr 30 17:07:21 1999 From: befletch at my-dejanews.com (Bruce Fletcher) Date: Fri, 30 Apr 1999 21:07:21 GMT Subject: Trouble with proxies References: <7gasj8$g79$1@nnrp1.dejanews.com> <5lzp3qafkj.fsf@eric.cnri.reston.va.us> <7gd0dh$add$1@nnrp1.dejanews.com> Message-ID: <7gd626$fcf$1@nnrp1.dejanews.com> In article <7gd0dh$add$1 at nnrp1.dejanews.com>, befletch at my-dejanews.com wrote: > In article <5lzp3qafkj.fsf at eric.cnri.reston.va.us>, > Guido van Rossum wrote: > > A quick lookup in errno.errorcode shows that that error is > > WSAECONNRESET, in other words the connection is reset by the server. > > This apparently happens after the proxy has read your headers. Could > > it be that the proxy server requires some kind of magic header? Ask > > the sysadmin who is responsible for the proxy. At least find out what > > the proxy software is, you can probably find the specs on the web.... > > > > If you have a way to snoop network packets, it would be interesting to > > see what traffic happens when your regular browser (IE or netscape) > > connects to the proxy from the same client machine (I'm assuming that > > works!). > > The proxy server is WinProxy Lite, V2.1. It is running on an NT4 server. > Yes, IE and Netscape both work fine through the proxy server, and no, the > sysadmin doesn't know anything more about WinProxy than how to install it > and configure it for normal http/ftp/smtp/pop3 clients. > > Following suggestions from several kind people, I have also tried the > following: [snip] Ok, I have expanded my test and come up with some interesting results. I'm using IDLE now too, if that matters. Slick program. Anyway, consider the following script: import os, urllib #os.environ['http_proxy'] = "http(colon-slash-slash)10.187.200.230:80/" #os.environ['http_proxy'] = "http(colon-slash-slash)1.2.3.4:5/" os.environ['http_proxy'] = "" # (colon-slash-slash) means :// but DejaNews won't post without the # translation. Dunno why not. print os.environ['http_proxy'] #f = urllib.urlopen('http://www.python.org/') #f = urllib.urlopen('http://www.nonexisting.site/') f = urllib.urlopen('http://www.ibm.com/') print f data = f.readline() while len(data)>0: print data data = f.readline() No matter which proxy string I use, or which URL, I get the following: > 403 Forbidden

403 Forbidden

The request was not properly formatted. A possible security risk detected.

Traceback (innermost last): File "C:\PROGRA~1\PYTHON\TOOLS\IDLE\ScriptBinding.py", line 131, in run_module_event execfile(filename, mod.__dict__) File "C:\Users\Bruce\postal codes\idle_experiment.py", line 19, in ? data = f.readline() File "C:\Program Files\Python\Lib\plat-win\socket.py", line 117, in readline new = self._sock.recv(self._rbufsize) error: (10054, 'winsock error') It would appear that the proxy server isn't at issue. Who is generating that HTML output, anyway? Thanks, - Bruce -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From kajiyama at grad.sccs.chukyo-u.ac.jp Mon Apr 12 15:11:16 1999 From: kajiyama at grad.sccs.chukyo-u.ac.jp (Tamito Kajiyama) Date: 12 Apr 1999 19:11:16 GMT Subject: Python 1.5.2c1 -- release candidate for 1.5.2 In-Reply-To: Guido van Rossum's message of Thu, 8 Apr 1999 21:48:12 GMT References: <199904082148.RAA04479@eric.cnri.reston.va.us> Message-ID: Guido van Rossum writes: | | *** Please help making 1.5.2 rock solid by banging on the release | candidate in all possible ways! *** I gave the release candidate a try on a PC running Plamo Linux 1.3 (a Linux distribution based on Slackware 3.5) and a Sparc box running SunOS 4.1.4_JL, both together with two additional packages PIL 1.0b1 and xml 0.5. The installations had no problem and completely succeeded. Congratulations! :-) By the way, the cPickle bug in 1.5.2b1 that I reported in this news group on January 11 (see [1]) has still been alive in 1.5.2c1. The attached is a context diff fixing it. (Excuse me for realizing this so late, but I didn't re-install 1.5.2b2 on the Sparc box...) [1] http://x10.dejanews.com/getdoc.xp?AN=431438253&CONTEXT=923940461.1386086447&hitnum=1 *** cPickle.c.orig Mon Apr 12 23:51:44 1999 --- cPickle.c Mon Apr 12 23:52:13 1999 *************** *** 3295,3301 **** if ((self->num_marks + 1) >= self->marks_size) { s=self->marks_size+20; if (s <= self->num_marks) s=self->num_marks + 1; ! if (self->marks) self->marks=(int *)malloc(s * sizeof(int)); else self->marks=(int *)realloc(self->marks, s * sizeof(int)); --- 3295,3301 ---- if ((self->num_marks + 1) >= self->marks_size) { s=self->marks_size+20; if (s <= self->num_marks) s=self->num_marks + 1; ! if (! self->marks) self->marks=(int *)malloc(s * sizeof(int)); else self->marks=(int *)realloc(self->marks, s * sizeof(int)); -- KAJIYAMA, Tamito From guido at eric.cnri.reston.va.us Fri Apr 30 23:27:35 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 30 Apr 1999 23:27:35 -0400 Subject: How to read stdin while debuggingin PythonWin References: <7g9utu$kin$1@nnrp1.dejanews.com> <7garhi$hqi$1@m2.c2.telstra-mm.net.au> <7gcfe5$qin$1@nnrp1.dejanews.com> Message-ID: <5lr9p1a2qg.fsf@eric.cnri.reston.va.us> cmedcoff at my-dejanews.com writes: > > Im not sure why this would be different under the debugger, but when I try > > that from the Pythonwin window I get: > > >>> sys.stdin.read() > > Traceback (innermost last): > > File "", line 0, in ? > > IOError: [Errno 9] Bad file descriptor > This is exectly what I observed when aborting the debug process. > Any plans to correct this and provide a place for stdin under the > debugger. Mark may not have such plans for PythonWin, but IDLE does fully support sys.stdin, whether or not in the IDLE debugger, in a way very similar to using the command line python.exe. At the moment, IDLE's debugger is not as smooth as Mark's, but it's got your basic step and view locals/globals/source functionality. Breakpoints seem to be broken on Windows (something to do with pathname syntax I'm sure). (IDLE is a new Python program development environment; IDLE 0.4 comes with Python 1.5.2. It requires Tcl/Tk, which (on Windows) also comes with Python 1.5.2.) --Guido van Rossum (home page: http://www.python.org/~guido/) From tismer at appliedbiometrics.com Fri Apr 23 09:16:25 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 23 Apr 1999 13:16:25 GMT Subject: try vs. has_key() References: Message-ID: <372072A9.922CE7A9@appliedbiometrics.com> Aahz Maruch wrote: > > I've seen roughly half the people here doing > > try: > dict[key].append(foo) > except: > dict[key]=[foo] > > with the other half doing > > if dict.has_key(key): > dict[key].append(foo) > else: > dict[key]=[foo] > > Can people explain their preferences? Well, besides the other good answers, there's some more. >From a design point of view, both versions have their place. The has_key version reflects the expectation of many missing keys, and it is not exceptional. The try..except version suggests that you usually will find a key, while a non-existant key is exceptional. I think, the dict.get variant is just a more efficient compromize which is somewhere between. It is also a matter of taste. But on execution speed, there are the measures of Barry's paper, and he is still right, although I would need measures for dict.get as well. Note that a loop running over dict.get calls is still a bit slower than indexing the dict, due to some internal method access overhead. It even applies when the dict.get method is assigned to a local variable. Indexing is the fastest way to access a dict element when you expect no key errors. I have no exact measures yet, but will provide some, soon. To optimize things if you can expect a very small number of key failures, a different approach can help to get the last cycles squeezed out of the code: If it is possible for your algorithm, you can put the try..except clause outside of some loop. This saves a statement and the exception clause setup as well. Your code must be changed quite heavily, since it has to restart the loop where it failed, but there are a number of cases where I need this kind of optimization. Here an example, which doesn't try to look well-designed, but run as fats as possible. I recommend to provide a second, more readable version of the function for documentation. Assuming you have code which runs in a loop and tries to collect new elements as your code does, here a good, "nearly fast" version, one with "get", and a faster, ugly one: def count_many(dict, itemlist): for key, value in itemlist: if dict.has_key(key): dict[key].append(value) else: dict[key] = [value] def count_many_get(dict, itemlist): for key, value in itemlist: lis = dict.get(key) if lis : lis.append(value) else: dict[key] = [value] def count_many_fast(dict, itemlist): while 1: try: k = 1 for key, value in itemlist: dict[key].append(value) ; k = k+1 break except KeyError: dict[key] = [value] itemlist = itemlist[k:] results = """ # given a list of 1000 tuples, and appending # this 1000 times, we measure >>> d={} ; print timing(count_many, (d, list) ,1000)[0] 17.8 >>> d={} ; print timing(count_many_get, (d, list) ,1000)[0] 16.15 >>> d={} ; print timing(count_many_fast, (d, list) ,1000)[0] 13.73 >>> """ ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 aa8vb at vislab.epa.gov Fri Apr 16 06:29:19 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 16 Apr 1999 10:29:19 GMT Subject: 1.5.2 broke IRIX module loading In-Reply-To: <37161C26.C121CA1E@bioreason.com>; from Andrew Dalke on Thu, Apr 15, 1999 at 11:04:38AM -0600 References: <19990414110116.A1374923@vislab.epa.gov> <37161C26.C121CA1E@bioreason.com> Message-ID: <19990416062919.A1501651@vislab.epa.gov> Thanks for the reply. |> "currstep" is the internal FORTRAN routine which has been zeroed-out. | | But I don't know what zeroed-out means in this context. For me |I found which were missing with "nm library.so | grep UNDEFINED" I don't know exactly how they built this library, but somehow they internalized the FORTRAN function names so that they are not exported by the FORTRAN objects (e.g. currstep in currstep.o), while a dangling reference exists to them in the C wrapper object (e.g. currstepc.o): Symbols from currstep.o: [Index] Value Size Class Type Section Name [0] | 0| |File |ref=16 |Text | /tmp_mnt/pub/storage/xcc/work/m3io/currstep.f [1] | 0| |Proc |end=15 unsigned long |Text | currstep_ ->[2] | -8| |Local |unsigned long |Abs | currstep Symbols frstepc [Index] Class Type Section Name [0] | 0| |File |ref=15 |Text | /tmp_mnt/pub/storage/xcc/work/m3io/currstepc.c [1] | 0| |Proc |end=14 int |Text | currstepc [13] | 420| |End |ref=1 |Text | currstepc ->[101] | 0| |Proc | |Undefined| currstep If one links with and calls any of these wrappers (e.g. currstepc()), it works fine. Randall From johngrayson at ome.com Thu Apr 8 19:08:05 1999 From: johngrayson at ome.com (John Grayson) Date: Thu, 08 Apr 1999 23:08:05 GMT Subject: Is Python Dying? Message-ID: <370D36ED.8A270DE9@ome.com> | Now that you mentioned it, I remember hearing that someone was | writeing a Python TKinter book......what the hell ever happened to |that?!?! I don't know about *that* one, but I can say there are two new Python books on the way from Manning Publications. Ken MacDonald's "The Quick Python Book" has been through its reviews and has been revised. Right now it is in final technical review and once complete the Publisher will begin production. I reviewed the ms and can say that it will be a great book for programmers new to Python. The first part illustrates the key features of Python with some good examples. Then, it goes on to demonstrate how to build meaningful applications, including Tkinter GUIs, Windows/COM and interfacing Python and Java. You can get some more details at http://www.manning.com. I'm at various stages of completion of chapters for "Python and Tkinter Programming", which has just completed a review of the partial manuscript. This book is intended for experienced programmers, who probably are getting to know Python pretty well (or have read "Quick Python"!), and have a need to build applications or prototypes in Python and Tkinter. P+TkP starts with some introductions to Python and Tkinter to give context and then documents Tkinter widgets and functions, using some (hopefully) realistic examples. Creating many types of GUI's, front panels and machines, interfacing TCP/IP, ODBC and CORBA, graphic design and many other topics are illustrated with full examples, with detailed explanation of the key points of the code. In fact, the longer-than-usual examples are a key feature of the book; this is intended to provide the reader with some concrete examples that might be useful as templates for their own prototypes and applications. As an appendix, there is a complete Tk to Tkinter mapping, intended to allow Tcl/Tk programmers to make use of Tkinter (!) and to enable Tkinter programmers to make better use of the Tk man pages. Also Pmw widgets feature prominently in the examples. So, Is Python dying? ... not a chance! From nbecker at fred.net Mon Apr 12 14:10:21 1999 From: nbecker at fred.net (nbecker at fred.net) Date: 12 Apr 1999 14:10:21 -0400 Subject: [success] 1.5.2c1 linux Message-ID: python-1.5.2c1 i686-pc-linux-gnu (--with-threads) glibc-2.0.7 egcs-1.1.2 49 tests OK. 12 tests skipped: test_al test_audioop test_bsddb test_cd test_cl test_dl test_gl test_imageop test_imgfile test_nis test_rgbimg test_sunaudiodev From jblake at speakeasy.org Tue Apr 6 01:01:48 1999 From: jblake at speakeasy.org (Jonathon Blake) Date: Tue, 06 Apr 1999 05:01:48 GMT Subject: Python books References: <7dr72m$9p5$1@news1.cableinet.co.uk> <7dso8m$bk5$1@nnrp1.dejanews.com> Message-ID: <923374908.564.89@news.remarQ.com> : just right. i'd be interested in hearing everyone elses' ideas as to what : such a book would/should have in it. i need some encouragment!!! Something like << take your choice here >> _The Pascal Handbook_ _The Basic Handbook_ _The Standard C Library_ Plaugher (?sp) As your source material use _every_ module mentioned in the Snake Book, IPWP, and found in Python v 1.0, 1.1, 1.2 1.3, .4 & 1.5x. State which modules are depreciated, and what the improvements are. FWIW, this is something I've been slowly typing up, on my old XT, whilst waiting for my computers to comeback after they crash. << Something in Python 1.5. doesn't agree the code I write. >> xan jonathon -- From mlh at swl.msd.ray.com Tue Apr 13 13:17:50 1999 From: mlh at swl.msd.ray.com (Milton L. Hankins) Date: Tue, 13 Apr 1999 13:17:50 -0400 Subject: Tools for three way merge of Python source files? Message-ID: Keywords: diff3, merge, three-way, 3-way Are there tools to help with 3-way merges of Python sources and/or indentation conversion? I'm using Python on a Real Project and I need to do a 3-way merge. Certain whitespace characters must be ignored -- specifically, carriage returns. I have a diff tool which ignores blanks but then I run into problems where a block of code has been indented further (inside a new block). I wish I could rely on the parser to catch this sort of thing, but it won't detect all possible follies, such as this one: if foo: if bar: baz() else: frob() if foo: if bar: baz() else: frob() Here, the merge result (using blank ignorance) would not incorporate the changes from . One correct solution seems to be to strip CR from CRLF. But I'm afraid of having too many conflicting sections (false negatives) where the spacing difference is actually benign. Perhaps I should just tell my fellow developers not to change indentation unless they have to. So, it also appears that I need a Python-aware indentation converter -- something that converts a source file to use a minimal number of tabs (or perhaps spaces, as long as it were consistent) for block indents. If anyone has had similar experiences or knows of a solution I'd love to hear about it. Email is preferred. Thanks. (I really hope this doesn't start Yet Another Whitespace War.) -- Milton L. Hankins -=- Software Engineer, Raytheon Systems Company -=- RayComNet 7-225-4728 http://amasts.msd.ray.com/~mlh -=- ><> Isaiah 64:6 ><> From poinot at onera.fr Wed Apr 14 08:02:52 1999 From: poinot at onera.fr (Marc Poinot) Date: Wed, 14 Apr 1999 12:02:52 GMT Subject: Tools for three way merge of Python source files? References: Message-ID: <371483EC.24A9AE3@onera.fr> "Milton L. Hankins" wrote: > > Keywords: diff3, merge, three-way, 3-way > You can use the GNU Emacs merge tool. You will have a color presentation with some nice facilities. Emacs can translate tabs to white-spaces and reverse and back (untabify). http://www.fsf.org You can also use CVS to store your files and ask it to merge them when you have several branches of development. http://www.cyclic.com Marcvs [alias Emacs also have an undo, if to want to get back to the reverse of your translation] From john.michelsen at gte.net Mon Apr 19 20:49:16 1999 From: john.michelsen at gte.net (John Michelsen) Date: Tue, 20 Apr 1999 00:49:16 GMT Subject: accessing calling scripts from called scripts at run time Message-ID: I'm having trouble accessing a calling script from a called script at run time. Here is an example: #first file, will call second from Tkinter import * import tkFileDialog, string root = None def importScript(): filename = tkFileDialog.askopenfilename() if filename != '': list = string.split(filename, '/') filename = list[-1] #dir = string.join(list[:-1], '/') #sys.path.append(dir) exec "import %s" % filename[:-3] if __name__ == "__main__": #? root = Tk() b = Button(root, text="import script", command=importScript) b.pack() root.mainloop() #another file, picked by tkFileDialog at run time by user from importTest import root root.config(bg='green') If I put the "if __name__ == '__main__':" in, the second file can't get at the root properly. If I leave it out, when I import root in the second file, it creates a new root window. How can I get at the root without making a new one? Thanks, John From markus_kohler at hp.com Thu Apr 29 10:05:25 1999 From: markus_kohler at hp.com (Markus Kohler) Date: 29 Apr 1999 16:05:25 +0200 Subject: Dangers of C++ (Way off topic) References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> <372827D8.7A5F@mailserver.hursley.ibm.com> Message-ID: >>>>> "Paul" == Paul Duffin writes: Paul> William Tanksley wrote: >> Let me expand a little on the dangers of C++. >> >> - virtual functions. It shouldn't be my job to tell the >> compiler when virtual lookups are the only thing to do; the >> compiler ought to be able to tell. For performance gurus, a >> way to hint to the compiler that virtual lookups were _not_ >> needed might be useful -- but what if the programmer was wrong? >> Paul> How can the compiler tell ? What William means (I think) is that the default should be that functions are virtual. Since even virtuals functions can be inlined this makes sense. >> - inline functions. Again, a good compiler HAS to make this >> decision for itself, and in a good compiler, whether or not >> this decision was made should be transparent to the programmer. >> Paul> A good compiler will, inline is only a hint to the compiler, Paul> the compiler can choose whether or not to inline that Paul> function, it can also choose to inline other functions which Paul> have not been marked as inline. [agree with all the other points] Markus -- Markus Kohler mailto:markus_kohler at hp.com From markus_kohler at hp.com Fri Apr 30 03:13:53 1999 From: markus_kohler at hp.com (Markus Kohler) Date: 30 Apr 1999 09:13:53 +0200 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> Message-ID: >>>>> "William" == William Tanksley writes: [deletia] >> Agreed. The main problem with todays statically typed languages >> is that they are too restrictive and to complicated. William> I'm not sure that they're _too_ restrictive; they work in William> their domains. The problem is that we don't want to William> loose Python's greatest strength: it's friendly. William> Let me expand a little on the dangers of C++. William> - virtual functions. It shouldn't be my job to tell the William> compiler when virtual lookups are the only thing to do; William> the compiler ought to be able to tell. For performance William> gurus, a way to hint to the compiler that virtual lookups William> were _not_ needed might be useful -- but what if the William> programmer was wrong? >> True, SmallEiffel inlines most of the virtual function calls >> automatically. This is the way to go. William> Inlines virtual functions? I think you got your wires William> crossed ;-). Virtual functions, by definition, can't be William> inlined. Inlining is where you place the routine's William> source code directly into the code of the calling William> routine. No I'm serious. Even most C++ compilers cannot inline virtual functions, that doesn't mean it is not possible ;-) A virtual function call can be inlined if you know all subtypes of a type: Assume you have a class "A" and classes "AA" and "AB" that are subclasses of A. Given A thing; thing = createFromFactory();/* it's not known here at compile whether thing is of type A, AA or AB */ thing.doSomething(); Then the a call A.doSomething() can be inlined ( translated to pseudo-C (tm)). A thing thing = createFromFactory(); if (thing.type)==AA { doSomething__AA(thing); } elseif (thing.type)==AC { doSomething__AB(thing); } elseif (thing.type)==A { doSomething__A(thing); } else { performHashBasedSlowCall(thing, doSomething) } Nobody says that one has to use vtables like C++ does ;-) SmallEiffel does exactly this. They used have a paper about their technique on their web side: http://SmallEiffel.loria.fr/index.html Self a smalltalk successor did the same without static type information years ago : http://self.smli.com/ Sun's new HotSpot Java compiler is based on this technology. Another way to speed up calling polymorphic functions is to use a cache of the latest (or the first) type together with the functions called for this type. This works very well for Smalltalk and should be a good thing in python too. William> - GC -- hard to add after the fact. No worry with William> Python, but what if there are other issues like it? >> I'm not sure if I understand this sentence. Do you mean GC is >> hard to add to python without breaking existing code ? I would >> agree with that. And why do you say "no worry" Do you mean GC >> is not worth the effort ? William> Guido seems to think so. Anyone who disagrees is free to William> contribute and work on porting GC code (I would like to William> see it). William> I think that worrying about the other issues is FAR more William> rewarding -- RC is not only hard to replace with GC, but William> the rewards for doing so are relatively small (in William> comparison to the other things we can think about). I would guess it's a lot of work to replace the RC with a GC, because a good GC needs a way to know if something is a pointer or not and this would require changing object layouts. Also all the reference counting calls would need to be removed. OK it might be possible to replace this code with macros that just do nothing. But the main problem would be that a lot of external (C) code would break with a decent GC because the GC would move objects around at runtime. William> I don't want to stop anyone from trying, though. The William> nice thing about free software is that even if everyone William> disagrees with you or thinks it's not worth it you can William> still get it done. William> So what other issues are worth thinking about? I don't William> know. >> You may have a look at Strongtalk a Smalltalk with static >> (optional) type checking. William> Found it using Google.com (a GOOD search engine for William> technical matters). William> http://java.sun.com/people/gbracha/nwst.html William> I'll be spending some time reading it. My initial William> impression: _very_ good. This would fit well, I think. Nice to hear that ... Markus -- Markus Kohler mailto:markus_kohler at hp.com From wdrake at my-dejanews.com Thu Apr 29 22:12:10 1999 From: wdrake at my-dejanews.com (wdrake at my-dejanews.com) Date: Fri, 30 Apr 1999 02:12:10 GMT Subject: Oracle Call Interface Message-ID: <7gb3hn$lse$1@nnrp1.dejanews.com> If anyone has experience writing applications directly to the Oracle Call Interface (OCI), in Python or JPython please send me examples or references on how to do it. Thanks, -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From cgw at fnal.gov Sun Apr 11 02:58:43 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Sun, 11 Apr 1999 06:58:43 GMT Subject: Python's object model Message-ID: <199904110658.BAA06796@buffalo.fnal.gov> This "Stack" class: class Stack: stack = [] def push(self, value): self.stack.append(value) ... doesn't work as you expected because the way you've declared it, the ".stack" attribute is a class attribute (shared by all instances of the class) rather than an instance attribute. To create instance attriubtes, create them in the initializer, like this: class Stack: def __init__(self): self.stack = () def push(self, value): ... Also note that in the not-quite-yet released Python 1.5.2 the builtin list objects have a pop() method, which is kind of handy. From MHammond at skippinet.com.au Wed Apr 14 00:28:59 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 14 Apr 1999 14:28:59 +1000 Subject: win32net.pyd--NetUserAdd References: <37131b6c.2250115@kelly> Message-ID: <7f15hd$bt0$1@m2.c2.telstra-mm.net.au> As fate would have it, Ive started on this today. I intend using Python dictionaries to exchange the information between the various USER_INFO_* structures.... You can be a beta tester if you like :-) Mark. Holger Fl?rke wrote in message <37131b6c.2250115 at kelly>... >I am interested in adding user accounts on WinNT using python. The >functions "NetUserAdd" and "NetUserSetGroups" in Win32 networking >aren't implemented in then win32net.pyd-module. Does anyone have >mapped these functions? Any other ideas? > >Thanks > >HolgeR From jeff.saenz at jpl.nasa.gov Mon Apr 26 18:09:34 1999 From: jeff.saenz at jpl.nasa.gov (Jeff Saenz) Date: Mon, 26 Apr 1999 15:09:34 -0700 Subject: decompiling python Message-ID: <3724E41E.D3730480@jpl.nasa.gov> Does anyone know of a decompilation tool for python? -jm From tscha00a at oi42.kwu.siemens.de Wed Apr 7 09:51:46 1999 From: tscha00a at oi42.kwu.siemens.de (Dr. Armin Tschammer) Date: Wed, 07 Apr 1999 15:51:46 +0200 Subject: Python and Nutcracker Message-ID: <370B62F2.93D76301@oi42.kwu.siemens.de> Hi, Has anyone experience with Python and Nutcracker ? We are using embedded Python in our application which is developed under HPUX. We are now porting our application to Windows NT with the help of the Nutcracker library. Has anyone already done such stuff ? Armin From jefftc at leland.Stanford.EDU Thu Apr 29 04:10:23 1999 From: jefftc at leland.Stanford.EDU (Jeffrey Chang) Date: Thu, 29 Apr 1999 01:10:23 -0700 Subject: help In-Reply-To: <3725E2FB.F7E46CED@pop.vet.uu.nl> References: <37257B0A.AF4C8E4C@pop.vet.uu.nl> <3725E2FB.F7E46CED@pop.vet.uu.nl> Message-ID: > This is how we push the programmer population slowly up that exponential > curve. :) > > Regards, > > Martijn That's so true! At my last employer, someone managed to convince me and a few other people to look at Python (thanks, Andrew!) Now that I'm back in school, I have a whole new audience to infec^h^h^h^h^h tell. Unfortunately, that other language seems to be quite entrenched in my field (bioinformatics). but-1.1-people-is-all-it-takes-to-achieve-exponential-growth-ly y'rs, (wow, that is fun!) Jeff From lpaterno at fnal.gov Tue Apr 20 12:21:24 1999 From: lpaterno at fnal.gov (Laura Paterno) Date: Tue, 20 Apr 1999 11:21:24 -0500 Subject: Bit Arrays Message-ID: <7fi9i8$n2u$1@info3.fnal.gov> Hello all, I want to write a python program that has 26 Bit Arrays that each contain 1113 bits. Is there a structure in python that one can use to represent a bit array? Laura Paterno From jschiotz at hotmail.com Tue Apr 27 06:15:35 1999 From: jschiotz at hotmail.com (Jakob Schiotz) Date: Tue, 27 Apr 1999 10:15:35 GMT Subject: Cross-references between dynamically loaded modules under AIX Message-ID: <7g42o5$d8u$1@nnrp1.dejanews.com> I am tuning a C program into a python module. The program contains some very large arrays of doubles, that I would like to become NumPy arrays in Python. I wrote a small function to convert a C pointer to a NumPy array (I am using SWIG), the program is appended below. It works fine on an alpha processor running OSF1 V4.0, but it coredumps under AIX version 4.1.5. The coredump occurs when PyArray_FromDims is called. It looks like the dynamical loader under AIX cannot resolve symbols in one module that refers to another module. It is probably related to the primitive way dynamic loading is working under AIX. The modules are created by the ld_so_aix, which is using a text file with the symbols defined in the python executable (created when the python executable was linked). I assume that the linker cannot link the references to symbols in the NumPy modules without similar information. Does anyone have a solution for this problem? Repeating the relevant code from the NumPy source would not be very nice, as it is quite a bit that would have to be repeated. Best regards, Jakob Schiotz Here is the interface file for SWIG. Vector is typedef'ed to double[3] in main.h. ------------------------------------------------------------ /* Emacs: Use -*- C -*- mode for this stuff */ %module fast %title "FAST - a molecular dynamics module",keep %{ #include "main.h" #include "arrayobject.h" %} %include fastcommon.i /* Initialize FAST, reading input files */ CmFile *initfast(char *potfilename, char *infilename, int wantclass, int dynamics, int frame, int hmode); %init %{ setdefaults(); fprintf(stderr, "FAST: %s %s\n", __DATE__, __TIME__); %} /* Access functions for global arrays of Vector */ %{ PyObject *my_Vectors_As_NumPy(PyObject *self, PyObject *args) { char *vectorp; double *cdata; PyArrayObject *numpy; int dims[2]; /* Read the argument, it should be a string encoding a pointer */ if (!PyArg_ParseTuple(args, "s", &vectorp)) return NULL; /* Decode the pointer */ if (SWIG_GetPtr(vectorp, (void **) &cdata, "_Vector_p")) { PyErr_SetString(PyExc_TypeError, "Not a pointer to Vector"); return NULL; } /* Create an empty numpy array of dimension nAtoms * 3 */ dims[0] = nAtoms; dims[1] = 3; numpy = (PyArrayObject *) PyArray_FromDims(2, dims, PyArray_DOUBLE); /* Copy the data to the numpy array */ memcpy(numpy->data, cdata, dims[0]*dims[1]*sizeof(double)); return (PyObject*) numpy; } %} %native(Vectors_As_NumPy) extern PyObject *my_Vectors_As_NumPy(PyObject *self, PyObject *args); -- Jakob Schiotz, CAMP and Department of Physics, Tech. Univ. of Denmark, DK-2800 Lyngby, Denmark. http://www.fysik.dtu.dk/~schiotz/ This email address is used for newsgroups and mailing lists (spam protection). Official email: schiotz @ fysik . dtu . dk -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From paul at prescod.net Fri Apr 30 10:40:19 1999 From: paul at prescod.net (Paul Prescod) Date: Fri, 30 Apr 1999 14:40:19 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <7g9qmo$luf$1@news.udel.edu> <372965CA.2B3FD2FE@appliedbiometrics.com> <19990430080805.B776752@vislab.epa.gov> <3729A9F3.75B2692B@appliedbiometrics.com> <19990430101215.A806665@vislab.epa.gov> Message-ID: <3729C0D3.6D28A592@prescod.net> Randall Hopper wrote: > > Right. I wasn't too clear. By default, I mean I don't want to have to > insert some commands/declarations for every namespace (every class, every > method, every module, etc.) to lock them. I want this to happen > automagically based on a switch. But the "right thing" varies on a class by class basis. Some classes in a module need to be locked and some do not. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Microsoft spokesman Ian Hatton admits that the Linux system would have performed better had it been tuned." "Future press releases on the issue will clearly state that the research was sponsored by Microsoft." http://www.itweb.co.za/sections/enterprise/1999/9904221410.asp From zessin at my-dejanews.com Sun Apr 25 04:15:50 1999 From: zessin at my-dejanews.com (Uwe Zessin) Date: Sun, 25 Apr 1999 08:15:50 GMT Subject: CSV Module References: Message-ID: <7fuivl$n79$1@nnrp1.dejanews.com> In article , Moshe Zadka wrote: > I wonder if there is some standard module out there that can parse > ``CSV'' files. I've downloaded one last year from: http://yi.com/home/TrattLaurence/comp/python/csv/index.html It saved me a lot of time, thanks! Just checked - the URL is still valid. -- Uwe Zessin -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From behrends at cse.msu.edu Thu Apr 29 19:37:24 1999 From: behrends at cse.msu.edu (Reimer Behrends) Date: 29 Apr 1999 23:37:24 GMT Subject: Dylan vrs Python (was; Re: Python IS slow ! [was] Re: Python too slow for real world) References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> <7g89eg$vb0$1@brick.cswv.com> <375533c2.241102625@newshost> Message-ID: Jason Trenouth (jason at harlequin.com) wrote: [...] > with-heavy-troll () > What would you give for interactive development and native compilation and > incremental gc and objects-all-the-way-down and extensible syntax and COM and > CORBA and a great GUI toolkit? > end; A lot--now if I could only get Harlequin Dylan to (1) use a readable font and (2) run on my Linux machine. So I have to settle for Gwydion Dylan right now, which is nice, but not nearly as nice as what you described above. :) (I would still second Jason's comment and suggest that people have a look at the free version of Harlequin Dylan--if I had to develop code under Windows, it would probably be my IDE of choice, with a couple of reservations.) Reimer Behrends From aa8vb at vislab.epa.gov Fri Apr 16 14:19:48 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 16 Apr 1999 18:19:48 GMT Subject: Bug with makesetup on FreeBSD In-Reply-To: <37175E05.4CF3C68@starmedia.net>; from Andrew Csillag on Fri, Apr 16, 1999 at 11:57:57AM -0400 References: <37175E05.4CF3C68@starmedia.net> Message-ID: <19990416141948.B1545732@vislab.epa.gov> Andrew Csillag: |makesetup in Python 1.5.1 and 1.5.2 bombs on lines in the Setup file |that use backslash continuation to break a module spec across lines on |FreeBSD. BTW FWIW, I just built 1.5.2 last night on 3.0-RELEASE using the 1.5.2c1 port. Worked fine. But it may not invoke makesetup under the hood. Randall From JamesL at Lugoj.Com Fri Apr 2 23:45:01 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 02 Apr 1999 20:45:01 -0800 Subject: Dealing with failure Was: Dealing with faults matters References: <7ds2g4$cm8$1@Starbase.NeoSoft.COM> <000901be7b41$cdc84f20$f19e2299@tim> <7dt2pv$1mj$1@Starbase.NeoSoft.COM> <3706f449.12085377@news.cybercity.dk> <7e3efa$j7v$1@Starbase.NeoSoft.COM> Message-ID: <37059CCD.44FA3A91@Lugoj.Com> Cameron Laird wrote: > In fact, a correct computer program often > has over half its lines devoted to accomo- > dating error. Oh sh*t. Yet another quantifiable measurement I suspect my programs wouldn't hold up to. If it comes to 49% I'm SOL. God forbid it should be 48% or even (gasp) 37.5%. I will confess here and now that I wrote programs for over 10 years that included no exception handling (well, an occasional setjmp/longjmp back in the "dark ages"). I am SO ashamed. Will the emotional agony never end? Even worse, I still write the occasional proceedural program, rather than approach it object-oriented. *SOB* They say confession is good for the soul, but I know in my heart I have sinned and will be condemmed to hell where I will be forced to write an X-Windows server using Apple ][ Basic and 6502 assembly for all eternity (cause we all know that is how long it will take to get running right). PRINT D$"OPEN FILE" ....(I think that is right.) From faassen at pop.vet.uu.nl Wed Apr 21 06:32:54 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Wed, 21 Apr 1999 12:32:54 +0200 Subject: New python user seeks comments References: Message-ID: <371DA955.9F13B144@pop.vet.uu.nl> David Steuber wrote: > > Er, uh, hmm. > > I wrote my first Python program today. It took longer than I > expected. Who would have guessed that you couldn't give a file object > the name 'in'? Or at least that was one of the weirder obstacles. It's not that weird as 'in' is a reserved keyword in Python. :) for i in whatever: print "See?" Regards, Martijn From news at dorb.com Thu Apr 8 17:34:52 1999 From: news at dorb.com (Darrell) Date: Thu, 8 Apr 1999 17:34:52 -0400 Subject: Chaning instance methods References: <370C2904.A6F4BD54@inrialpes.fr> Message-ID: > To make a long story short, what you're trying to do is not very cool, > so perhaps you don't get truly cool answers, but still, you can do it > in Python. Fortunately, what you're asking here is not common practice, > I hope! Is this a truly flawed design pattern ? I have done this for a module to replace a function with out changing the module its self. Because I didn't control that module. Also for a class once to allow a runtime XML type script to replace a method. Both of these can be tricky to debug because you tend to forget what's happening. Yet a better solution doesn't come to mind. Possibly the module problem could be solved by creating another module and "from XXX import *" then add my replacement function. Darrell Gallion From herzog at online.de Mon Apr 12 18:02:04 1999 From: herzog at online.de (Bernhard Herzog) Date: 13 Apr 1999 00:02:04 +0200 Subject: extending questions References: <371220AD.6C3B0B5@home.com> Message-ID: "Michael P. Reilly" writes: > Jim Meier wrote: > : Firstly, I'm looking for a quick and easy way for a PyCFunction to > : accept as an argument either an integer or a floating point number, so > : that the function can be called as > > : func(1,1,1) > > : or as > > : func(0.5,0,2/3) > > : because python doesn't seem to let me consider an integer as a float. > : I've tried using some of the conversion functions in the abstract > : numeric suite and the PyFloat_GetDouble (or some similar name), but with > : no luck - it always returned -1 for me. Any ideas? > > My best suggestion would be to use the PyInt_Check and PyFloat_check > functions. > > PyObject *func(PyObject *self, PyObject *args) > { PyObject *arg1, *arg2, *arg3; > double a1, a2, a3; > > if (!PyArg_ParseTuple(args, "OOO", &arg1, &arg2, &arg3)) > return NULL; > /* get the double from the first argument */ > #define py_to_double(a, var) \ > if (PyInt_Check(a)) (var) = (double)PyInt_AS_LONG(a); \ > else if (PyFloat_Check(a)) (var) = PyFloat_AS_DOUBLE(a); \ > else { PyErr_SetString(PyExc_TypeError, "must supply a number"); \ > return NULL; } > > py_to_double(arg1, a1); > py_to_double(arg2, a2); > py_to_double(arg3, a3); > #undef py_to_double Why not just PyObject * func(PyObject *self, PyObject *args) { double a1, a2, a3; if (!PyArg_ParseTuple(args, "ddd", &a1, &a2, &a3)) return NULL; /* ... */ } This should work for Python floats, int and longs. -- Bernhard Herzog | Sketch, a python based drawing program herzog at online.de | http://www.online.de/home/sketch/ From c.evans at clear.net.nz Sun Apr 25 02:14:01 1999 From: c.evans at clear.net.nz (Carey Evans) Date: 25 Apr 1999 18:14:01 +1200 Subject: help with os.popen() References: <7fomaj$oo9$1@nnrp1.dejanews.com> <000301be8e0c$d71ff4a0$f09e2299@tim> Message-ID: <87yajhxm52.fsf@psyche.evansnet> "Tim Peters" writes: [snip - about popen() on Win32] > I'll figure this all out if I ever get a free year <0.7 wink>. Why bother? The Tcl people have done it already, I've had very few problems with pipes there, and it's under a generous license. There's some interesting comments in tclWinPipe.c and stub16.c too, and an amazing number of special cases. I'd be eternally grateful[1] if pipes worked as well in Python as they do in Tcl, although I suppose I could try rewriting tclWinPipe.c using the Win32 extensions. Actually, it would be quite nice if I could just get the return value from os.system() or os.spawnv() like I can from Tcl's "exec". [1] I'd buy the author a drink if I met them, anyway. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "these are not inherent flaws in [NT] -- they don't happen by accident. They are the result of deliberate and well-thought-out efforts." - MS From Jcantrl at ix.netcom.com Sun Apr 25 01:43:00 1999 From: Jcantrl at ix.netcom.com (Jcantrl at ix.netcom.com) Date: Sun, 25 Apr 1999 05:43:00 GMT Subject: Unsubscribe Message-ID: <3722AB63.9DC28BA5@ix.netcom.com> From aaron_watters at my-dejanews.com Tue Apr 27 09:40:27 1999 From: aaron_watters at my-dejanews.com (aaron_watters at my-dejanews.com) Date: Tue, 27 Apr 1999 13:40:27 GMT Subject: Python and "Hand held" computers References: <318D8A1FC77AD211A3110080C83DFC6403139F@comsrv.sowatec.com> <7g1opt$9li$1@nnrp1.dejanews.com> <7g2r14$sia$1@m2.c2.telstra-mm.net.au> Message-ID: <7g4eob$n87$1@nnrp1.dejanews.com> In article <7g2r14$sia$1 at m2.c2.telstra-mm.net.au>, "Mark Hammond" wrote: > >btw: gadfly runs on python-ce (with some mods) :) I think it > >is the most fully featured sql implementation that runs on wince. > >(pocketAccess is braindead.) > > Hey - that is great! Im also glad to hear you have the thing working OK - > are you using my builds? Yes. I also must admit that gadfly runs *slowly* and I don't think it's all my problem (some of it is)... Just in the interest of keeping the signal to noise ratio high :) "imports" of large modules seem to take longer than they should. Gadfly would be much more interesting with a kjbuckets port too. [Dunno what my problem is, just too honest I guess, I can't get into the tradition of "hyperbole" in this industry.] I'm surprised and delighted that it runs as well as it does nonetheless. Thanks Mark, Brian et al for the great work!! -- Aaron Watters === ...doesn't know the difference between "hyperbole" and "mendacity" any more... [Father, I cannot tell a lie: that woman cut down the cherry tree...] -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From MHammond at skippinet.com.au Tue Apr 20 20:30:35 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 21 Apr 1999 10:30:35 +1000 Subject: VB Nothing equivalent in win32com References: <7fiffg$4sb$1@nnrp1.dejanews.com> Message-ID: <7fj65j$6cp$1@m2.c2.telstra-mm.net.au> Python uses None. Pythoncom also uses None in almost all relevant cases. Mark. pecold at my-dejanews.com wrote in message <7fiffg$4sb$1 at nnrp1.dejanews.com>... >Does Python support something like VB Nothing object?? (Universal NULL >pointer.) > >Petr > >-----------== Posted via Deja News, The Discussion Network ==---------- >http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From john.michelsen at gte.net Mon Apr 5 03:23:18 1999 From: john.michelsen at gte.net (John Michelsen) Date: Mon, 5 Apr 1999 00:23:18 -0700 Subject: Tkinter bug in Misc.tkraise, Canvas.tkraise References: <37082E26.A9445E43@earthlink.net> Message-ID: <7e9n6b$7sk$1@news-1.news.gte.net> I found a bug in using Tkinter to raise a canvas widget above later packed (etc.) widgets. It seems Tkinter gets confused between the Misc.tkraise() method and the Canvas.tkraise(item) methods. The following script shows the problem: from Tkinter import * def raiseCanvas(): canvas1.lift() #canvas1.tkraise() #canvas1.widgetlift() root = Tk() canvas1 = Canvas(root, bg='blue') canvas1.place(x=10, y=10, anchor=NW) canvas2 = Canvas(root, bg='red') canvas2.place(x=20, y=20, anchor=NW) raiseButton = Button(root, text='raiseCanvas', command=raiseCanvas) raiseButton.pack() root.geometry("%dx%d" % (100,100)) root.mainloop() which gives the following error: Exception in Tkinter callback Traceback (innermost last): File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 764, in __call__ return apply(self.func, args) File "C:\PROGRA~1\PYTHON\RAISEC~1.PY", line 4, in raiseCanvas canvas1.lift() File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1287, in tkraise self.tk.call((self._w, 'raise') + args) TclError: wrong # args: should be ".8249616 raise tagOrId ?aboveThis?" I made Tkinter do what I want by adding a method to the Misc class and not the Canvas class: class Misc... def tkraise(self, aboveThis=None): self.tk.call('raise', self._w, aboveThis) lift = widgetlift = tkraise so that widgetlift will call the tkraise in Misc and not the tkraise in Canvas. I discovered the error in developing a multiple document interface for Tkinter which can be found on: http://www2.zyvex.com/OpenChem/index.htm Dockable toolbars and a tree widget can also be found there. They probably don't look very good on unix yet. John From marcel.lanz at isoe.ch Sat Apr 10 12:47:58 1999 From: marcel.lanz at isoe.ch (Marcel Lanz) Date: Sat, 10 Apr 1999 18:47:58 +0200 Subject: Problems with InteractiveInterpreter Message-ID: <370F80BE.30B889A9@isoe.ch> Hi, I have a modified python shell and I would use processing python code with the InteractiveInterpreter class. Now, I've got the following error, if I try to run some codelines with this Interpreter: Output: --------------------------------------------- lanzm at frodo:~/data/projects/pylip > python interp.py File "", line 1 print i ^ SyntaxError: invalid syntax --------------------------------------------- interp.py: --------------------------------------------- from code import InteractiveInterpreter lines = open('test2.py', 'r').readlines() ii = InteractiveInterpreter() for line in lines: ii.runsource(line) --------------------------------------------- test2.py: --------------------------------------------- #!/usr/local/bin/python # # test, marcel.lanz at gmx.net # # -------------- # File: $Source$ # -------------- # $Log$ # for i in 'hello': print i ---------------------------------------------- any ideas? marcel From john.david at mankato.msus.edu Wed Apr 21 14:17:42 1999 From: john.david at mankato.msus.edu (john) Date: Wed, 21 Apr 1999 13:17:42 -0500 Subject: Telnetlib error - not References: Message-ID: <371E1632.77566BAE@mankato.msus.edu> Bug in my code - John wrote: > I am running python 1.5.2 (final release downloaded 19Apr1999) on: > Linux version 2.0.34 (gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)) > > Has anyone else run into this problem? > > File "./telnet_test.py", line 86, in ? > initial_data = tn.expect('->') > File "/usr/local/lib/python1.5/telnetlib.py", line 450, in expect > list[i] = re.compile(list[i]) > TypeError: object doesn't support item assignment From Alexia.Marie at wanadoo.fr Thu Apr 29 06:16:22 1999 From: Alexia.Marie at wanadoo.fr (France Télécom) Date: 29 Apr 1999 10:16:22 GMT Subject: Question about Tkinter Message-ID: <01be922b$23801c40$e110fac1@renpostlib> Does Tkinter or any of its extensions allows saving a canvas on a bitmap file? From jmrober1 at ingr.com Thu Apr 8 14:51:52 1999 From: jmrober1 at ingr.com (Joseph Robertson) Date: Thu, 08 Apr 1999 13:51:52 -0500 Subject: Q on Tkinter Scrollbar Message-ID: <370CFAC8.32EB0B29@ingr.com> Hi everyone, I want to manually control the scrollbar in a tkinter app, i.e. I don't want to tie it to another widget as a child. Below is what I have so far. I can't figure how to make the 'thumb' stay at the returned position, or the point where the user drags it. Right now it always pops back to the top. I want it to behave like a Scale, but look like a scrollbar. Think of a virtual window on a dataset, where I don't want to load the contents of the data set into a listbox (not enough memory). Anyone do this before, know of any similar examples, or give me a clue where to look next. I don't want to use extensions or another GUI, it needs to be Tkinter. Thanks in advance, Joe Robertson jmrober1 at ingr.com >----begin code # a manual scrollbar # # Joe Robertson, jmrober1 at ingr.com # from Tkinter import * class Manual(Frame): def __init__(self, master, **kw): apply(Frame.__init__, (self, master), kw) vscrollbar = Scrollbar(self, orient=VERTICAL) self.canvas = Canvas(self) vscrollbar.config(command=self._vscroll) vscrollbar.pack(fill=Y, side=RIGHT) self.canvas.pack(expand=1, fill=BOTH, side=LEFT) def _vscroll(self, type, *arg): print type if type == 'moveto': for each in arg: print each # doit root = Tk() f = Manual(root) f.pack(expand=1, fill=BOTH) root.mainloop() >----end code From kiket at my-dejanews.com Mon Apr 19 04:35:26 1999 From: kiket at my-dejanews.com (kiket at my-dejanews.com) Date: Mon, 19 Apr 1999 08:35:26 GMT Subject: How to add data in a existant file ? Message-ID: <7fepse$pff$1@nnrp1.dejanews.com> Hi, I use python to developp a script and I want to know which is the fonction that permit to add data in a existant file. I know already how to write data in a new file -----> f=open('file.name','w') f.write('data') f.close() But how to merge data in a existant file ? Mail your response to fquiquet at lemel.fr Thank's a lot for your help. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From fuzzy at fuzzys.org Mon Apr 12 08:29:28 1999 From: fuzzy at fuzzys.org (Julien Oster) Date: 12 Apr 1999 14:29:28 +0200 Subject: forking + stdout = confusion References: Message-ID: <7jlnfyowd3.fsf@gandalf.midearth.fuzzys.org> >>>>> "Clarence" == Clarence Gardner writes: Clarence> I have a program running in Python 1.5.1 under FreeBSD 2.1.7. Clarence> It happens to be a nph-type CGI program. Normally, it runs a Clarence> report that can take quite a while, and I'm trying to add an Clarence> option to delay the start. I defined this function: [...] I ran in exactly the same problem. I tried closing all stdxxx-filedescriptors, setting a new session id with setsid, also tried it with setting a new progress groups, and I even tried to reopen stdin, stderr and stdout to /dev/null, but nothing helped. Then I saw that in OpenBSD, there's a function in stdlib.h called "daemon()". You simply call it, and it puts the running program in the background (it forks and exits the parent), redirects the stdxxx-descriptors, sets a new session ID etc... and with this function, it works! Anyway, I was not able to reproduce what daemon does in any way, obviously it does anything else which I did not think of, but I can't find out what. So for now I use a very dirty wrapper which just calls the daemon-function, but since I also realized that at least linux libc5 (I don't know how this is with glibc) doesn't know this handy function, it would be fine to know what I forgot while trying to reproduce daemon()'s actions. I think it must be something with the stdxxx-filedescriptors and/or the terminal, since using daemon() in a cgi lets apache close the connection to the browser, but the simple call of fork, stdxxx.close/reopen/whatever, setsid and setpgrp does not. For know, check if you're system is having the daemon() function (it should reside in the C-Library and its declaration in stdlib.h) and if it has, use it either with a small C wrapper program, with a python module which implements it or even using the dl-module. -- /--/ Julien Oster /---/ www.fuzzys.org <---> www.sysadm.cc /---/ /--/ OpenBSD 2.5 /---/ Greetings from Munich, Germany /---/ /--/ contact me : /---/ talk fuzzy at fuzzys.org or e-Mail me /---/ From hj_ka at my-dejanews.com Sun Apr 18 16:50:45 1999 From: hj_ka at my-dejanews.com (hj_ka at my-dejanews.com) Date: Sun, 18 Apr 1999 20:50:45 GMT Subject: NT: win32api and win32ui import error References: <7fbcpq$2jb$1@nnrp1.dejanews.com> Message-ID: <7fdgj4$nnl$1@nnrp1.dejanews.com> In article , bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) wrote: > > Mark said, that the following dll and their versions might > be relevant: > > ole32.dll > oleaut32.dll > msvcrt.dll No luck. I downloaded some more recent versions of ole32.dll and oleaut32.dll from http://solo.abac.com/dllarchive/, (their msvcrt.dll is older, from VC5 instead of VC6). I also tried those DLLs from my Windows 98 System folder. I tried many combinations. Here is the list of the versions: msvcrt.dll: 5.00.7303 (solo.abac.com) 5.00.7128 (my Windows 98) 6.00.8267.0 (my Windows NT) ole32.dll: 4.71.1120 (solo.abac.com) 4.71.1719 (my Windows 98) 4.00 (my Windows NT) oleaut32.dll: 2.20.4122 (solo.abac.com) 2.20.4122 (my Windows 98) 2.20.4118 (my Windows NT) I tried many combinations of the DLLs inside the C:\Winnt\system32 folder. But they didn't help, and matter of fact, they broke something else and I got more error messages from the operating system. NT has had persistent problem with the Pythonwin extensions. This is not the first time. I have never been able to run Pythonwin or use its extensions modules (e.g: win32api, win32ui) on NT, and we have quite a few NT machines here. The current real status is: PYTHONWIN DOES NOT RUN ON NT. At least not on modern NT versions (our msvcrt.dll is dated 9/23/98, this should be considered fairly recent.) I am willing to track down the problem a bit more. But help is needed from Mark or other people. I am lost at this moment. regards, Hung Jung -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From MHammond at skippinet.com.au Mon Apr 26 18:58:06 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 27 Apr 1999 08:58:06 +1000 Subject: Python and "Hand held" computers References: <318D8A1FC77AD211A3110080C83DFC6403139F@comsrv.sowatec.com> <7g1opt$9li$1@nnrp1.dejanews.com> Message-ID: <7g2r14$sia$1@m2.c2.telstra-mm.net.au> >btw: gadfly runs on python-ce (with some mods) :) I think it >is the most fully featured sql implementation that runs on wince. >(pocketAccess is braindead.) Hey - that is great! Im also glad to hear you have the thing working OK - are you using my builds? Mark. From digitome at iol.ie Sun Apr 4 06:54:30 1999 From: digitome at iol.ie (Sean Mc Grath) Date: Sun, 04 Apr 1999 10:54:30 GMT Subject: Announce: XML Scripting with Python Tutorial Message-ID: <37074410.2385470@news.iol.ie> Some time ago I announced a Python tutorial at the upcoming WWW8 conference (http://www.www8.org). The content of the tutorial has been amended to take account of demand for focused information on the XML scripting with Python. See http://www.www8.org/tutorials.html#python for details. regards, Sean Mc Grath From mal at lemburg.com Fri Apr 16 08:53:32 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 16 Apr 1999 12:53:32 GMT Subject: Simple module installation References: <37170674.F77233A6@prescod.net> Message-ID: <371732CC.201012AF@lemburg.com> Paul Prescod wrote: > > I was just installing Fnorb and it was as painless an installation as a > sane person could ask for but I got to thinking...couldn't this be less > painless? The reason I ask is because I'm thinking of distributing code > that depends on code that depends on code that depends on Fnorb and I need > each installation part to be as simple as possible. So this isn't meant to > pick on Fnorb in particular but to use it as a random sample package with > binary and Python parts. Maybe the distutils package that is being developped by the distutils sig could help. > ... > The PYTHONPATH and PATH would be unneccessary if Fnorb used the Windows > registry. Even so, I think that a Python-managed, portable, text > file-based registry (like JPython's) would be better than depending upon > the over-centralized Windows registry. > ... > If we put my idea for a Python-managed registry together with the "-r" > idea then Fnorb could register itself on Windows or Unix like this: > > python -r register Fnorb /path/to/fnorb You should take the idea even a bit further and have Python use the registry per default for all lookups and only have it revert to PYTHONPATH in case it doesn't find anything appropriate. A while back I wrote a patch called fastpath that made Python use a callback (sys.fastback I think it was named) in the import loader: A little Python function read a marshalled version of a module lookup table the first time it was called and then tried to find the module in that table. If it did find something, the module loader would stop the search and use the returned path to the module, otherwise it would do its normal actions. The nice thing about this callback is that you can modify the module locator's action without having to modify the Python source code (well, apart from the few lines needed to add the callback). BTW, using the above fastpath trick reduces IO overhead on startup quite a bit: from a few 100 stat()s to a few 10s for an average script. The (old) code is still available for anyone to play with: http://starship.skyport.net/~lemburg/fastpath.zip -- Marc-Andre Lemburg Y2000: 259 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From tismer at appliedbiometrics.com Wed Apr 21 07:20:32 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 21 Apr 1999 11:20:32 GMT Subject: Kosovo database; Python speed References: <371DAAC2.D9046550@cs.utwente.nl> Message-ID: <371DB480.32947654@appliedbiometrics.com> Richard van de Stadt wrote: > > Suppose we were going to make a database to help Kosovars locate > their family members. This would probably result in hundreds of > thousands of records (say 1 record (file) per person). > > Would Python be fast enough to manage this data, make queries on > the data, or should compiled programs be used? Dependant of the operating system, I'd suggest to use a database extension. Controlling this database from Python will give you enough speed. If I had to do this, my preferences are mySQL for Linux, with its interface, MS-Access for Windows, with a COM interface. The latter is not since I like it so much, but we have used it before, and the interfaces are there. Since the Kosovars need help quickly, I'd use this combination instead of writing something special. Python alone will not be too easy, since your data will probably not fit into memory. You will also have lots of edits, so I think using a true database is the better choice here. (Not saying that Access is a true database, but it works fine with several 100000 records). But two single columns with a name and a record ID will fit, so your code might extract this info as a whole, map it to a dict and search it in some sophisticated manner. This can be even faster than the database. Do you have more info on the amount of data, fields per record, and what search capabilities are needed? Is it designed as a web based application? Are there on-line updates and such? ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 j_hendry at ix.netcom.com Thu Apr 22 23:37:32 1999 From: j_hendry at ix.netcom.com (Jonathan Hendry) Date: Thu, 22 Apr 1999 21:37:32 -0600 Subject: learning Python (rat book) References: Message-ID: <7fomar$49k@sjx-ixn10.ix.netcom.com> savageb wrote in message ... >The rat has landed! I managed to get my hands a copy at the Stanford >University Bookstore today. Mine arrived from Amazon on Tuesday. From graham at sloth.math.uga.edu Fri Apr 30 11:53:22 1999 From: graham at sloth.math.uga.edu (Graham Matthews) Date: 30 Apr 1999 15:53:22 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: <7gcjli$dn2$2@cronkite.cc.uga.edu> William Tanksley (wtanksle at dolphin.openprojects.net) wrote: : Your data is correct (Python is slow for many things, slower than it needs : to be), but your conclusion is wrong. Python isn't slow because its : bytecode engine is slow; actually, although there's a lot of room for : improvement, its bytecode engine is faster than many of the others out : there. : : The reason it's slow is its runtime model. _Every_ function call requires : a lookup in a hash table, just on the off-chance that the programmer : changed the meaning of the function. I don't buy this. As far as I know every function call in Self and Smalltalk also requires a lookup (just like Python), but both languages are significantly faster than Python it seems. graham -- This ain't no technological breakdown Oh no, this is the road to hell From tismer at appliedbiometrics.com Fri Apr 30 11:34:42 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 30 Apr 1999 15:34:42 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <7g9qmo$luf$1@news.udel.edu> <372965CA.2B3FD2FE@appliedbiometrics.com> <19990430080805.B776752@vislab.epa.gov> <3729A9F3.75B2692B@appliedbiometrics.com> <19990430101215.A806665@vislab.epa.gov> Message-ID: <3729CD92.43477316@appliedbiometrics.com> Randall Hopper wrote: [tismer().chris about locking] > |Well, I wouldn't do that by default. By default, everything could stay as > |it is. First of all, this would not break any existing code. > > Right. I wasn't too clear. By default, I mean I don't want to have to > insert some commands/declarations for every namespace (every class, every > method, every module, etc.) to lock them. I want this to happen > automagically based on a switch. > > A command-line option (-w), or something like Perl's "use strict" > declaration would be a reasonable way to enable this behavior. Now, well, but Perl is quite different here. As I remember, it doesn't have all the dynamic features of Python. In Python, you can reference any identifier in a function or class definition without the need that the object exists. That's the reason why I'm talking of an optional feature, since it has reasonable semantic side effects. > |Then, what would you do with classes which depend on each > |other? You cannot lock them immediately, this would fail. > > Could you give an example? class abstractparser: magic = 42 pass # numerous default and stub methods class parserops: "mixin class" def general_method1(self, *args): self.parser_method(self.scanner, args) def funky_method(self, *args): #some code there return self.magic class someparser(abstractparser, parserops): def parser_method(self, scanner, *args): # do something, and then use the mixin self.funky_method(2, 3, 5) Sorry about my lack of spirit today, this example is bad. But, if you lock class parserops after it is created, it will barf, since parser_method cannot be resolved yet. It will also not resolve self.magic, since it doesn't inherit from abstractparser. But if I lock someparser, it will get all of its methods right though the inheritance mechanism once. > |Depending on how exactly will be implemented, a single line > |at the end of a module should suffice to accomplish this stuff > |for the standard cases. > > This would prevent namespace binding and locking from occuring while the > module is being parsed, wouldn't it? With a lock declaration at the > beginning, Python could do this as it goes. Seems like that would be > easier (Python sees end of function -> module.symbol referenced in the > function was not defined -> flag error and abort parse). Yes, but this would limit Python down to Pascal like name spaces. You would need all kinds of tricks to write recoursions like def two(arg): if arg % 2 == 0: return three(arg-1) return arg def three(arg): if arg % 3 == 0: return two(arg-1) return arg (again not good :) This would need to be locked after both are defined, otherwise we had to invent declarations which is bad. > |As a side effect, locking a module would also find all > |referenced but undefined symbols. > > That's the goal I'm rooting for. ;-) If it is just that, download Aaron Watter's kwParsing module and use its pylint module to see lots of complaints about your source :-) > |Anyway, this is still no cakewalk and quite a lot of code > |is involved. Needs much more thinking... > > Definitely. No doubt Guido and the other language experts have a better > feel for this than I do. But I felt compelled to chime-in on this topic > since it's important to me (and the squeaky wheel gets the grease. :-) Sure that they will also not like my idea, but this cannot stop me from trying :-) ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 cgw at fnal.gov Tue Apr 27 19:13:20 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Tue, 27 Apr 1999 23:13:20 GMT Subject: Long integers getting short shrift? In-Reply-To: <37262F45.2473F5A5@callware.com> References: <14118.9093.292465.438475@buffalo.fnal.gov> <37262F45.2473F5A5@callware.com> Message-ID: <14118.17552.252493.22073@buffalo.fnal.gov> Ivan Van Laningham writes: > ???? I have Python running on my UnixWare system at home, and the long > types are easily accessible. Perhaps I was unclear, I'm not saying that the long type is not available; I'm referring to the level of support for Long objects in the Python/C API, in particular the functions PyArg_ParseTuple and PyObject_CallFunction. Below is the snippet of code in getargs.c that handles the "L" format character... I was wishing for something similar to "L" that would take a plain C int and make a Python Long out of it... I don't know what letter I'd use since l and L are already taken! It's not too important, one can always use the "O" format letter and handle the arg. specially with PyLong_FromLong; it's just a bit ugly to have to do so. #ifdef HAVE_LONG_LONG case 'L': /* LONG_LONG */ { LONG_LONG *p = va_arg( *p_va, LONG_LONG * ); LONG_LONG ival = PyLong_AsLongLong( arg ); if( ival == (LONG_LONG)-1 && PyErr_Occurred() ) { return "long"; } else { *p = ival; } break; } #endif From merlyn at stonehenge.com Thu Apr 29 10:26:22 1999 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: 29 Apr 1999 07:26:22 -0700 Subject: converting perl to python - simple questions. References: <000101be8f62$b66e4700$669e2299@tim> Message-ID: >>>>> "Tim" == Tim Peters writes: Tim> Perl actually has the same problem, but it's *usually* hidden by "regexp Tim> context"; e.g.; Tim> $string =~ /\bthe/ Tim> matches "the" starting at a word boundary, while Tim> $pattern = "\bthe"; Tim> $string =~ /$pattern/ Tim> matches "the" following a backspace character. Oddly enough, these *will* match word boundaries: $pattern = '\bthe'; $pattern = qr/\bthe/; Yes, Perl is heavily context sensitive... and so are human beings. :) -- Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095 Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying Email: Snail: (Call) PGP-Key: (finger merlyn at teleport.com) Web: My Home Page! Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me From mgm at unpkhswm04.bscc.bls.com Wed Apr 28 07:24:37 1999 From: mgm at unpkhswm04.bscc.bls.com (Mitchell Morris) Date: 28 Apr 1999 11:24:37 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: In article , Markus Kohler wrote: [snip] >Python would be appropriate for much more problems if it would only be as fast >as other scripting languages. The bytecode interpreter IS significantly slower >than other byte code interpreted languages. [snip] >You are right that one should choose the right tool for a problem, but >I disagree that Python is optimized for the general case. Squeak a free >Smalltalk implementation (www.squeak.org), is already much faster ( about >3 times actually ) than python and it has even a true Garbage >Collector. [snip] >From profiling python 1.5.2c I found that python's main problem is that >calling functions seems to be very costly. [snip] >Markus >-- >Markus Kohler mailto:markus_kohler at hp.com If it's not too much trouble, could you post your benchmark code and results, either here or on a web page? +Mitchell -- Mitchell Morris Underlying Principle of Socio-Genetics: Superiority is recessive. From brunomadv at ciudad.com.ar Thu Apr 22 01:07:36 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Thu, 22 Apr 1999 05:07:36 GMT Subject: permissions on win32 [Q] In-Reply-To: <7flpkv$6je$1@m2.c2.telstra-mm.net.au> References: <7flpkv$6je$1@m2.c2.telstra-mm.net.au> Message-ID: <001b01be8c7e$093c5770$6eba0ac8@kuarajy.infosys.com.ar> It looks like a solution, but I would have to create those template file by hand ... Since all the permissions are new. I mean it's a migration from one system to another, so there is no previous state, or at least, the previous state is so diferent from the final one, that I cannot use a template file without some serious hand-worked labor.... :-) Thanks a lot Mark. /B Bruno Mattarollo ... proud to be a PSA member > -----Original Message----- > From: python-list-request at cwi.nl [mailto:python-list-request at cwi.nl]On > Behalf Of Mark Hammond > Sent: Wednesday, April 21, 1999 9:15 PM > To: python-list at cwi.nl > Subject: Re: permissions on win32 [Q] > > > Bruno Mattarollo wrote in message > <002401be8c03$4f21d380$6eba0ac8 at kuarajy.infosys.com.ar>... > >Thanks Mark... > > > > All this is supposed to run on sunday and it's Mission Critical, so I > >presume wiill be doing it by hand, but anyway thanks. I am > looking forward > >to be able to do this on NT... :-) > > > > FYI we will be running another mission critical process on Sunday and it > >will be a small Python app that will run on NT ... I love Python ... :-) > > Actually, overnight I thought of a different solution you could > use - use a > "template file". > > Although the help file omits this information, you could use > "win32security.GetFileSecurity()", and name a file that has the > permissions > you wish to "copy". This will give you a SECURITY_DESCRIPTOR > object. Once > you have the object, you can even manipulate the contents - the only thing > missing from 124 was the ability to create a brand-new, empty > SECURITY_DESCRIPTOR - all the functionality to manipulate them is > there.... > > Mark. > > > > From mrfusion at bigfoot.com Tue Apr 20 02:19:21 1999 From: mrfusion at bigfoot.com (mrfusion at bigfoot.com) Date: Tue, 20 Apr 1999 06:19:21 GMT Subject: Tkinter hangs on mainloop Message-ID: <371c19bb.60709557@news> Hi, I've done a complete install of python ver 1.5.2 on my windows98 system and I've run into a problem with Tkinter (no big surprise!) I can import it with the line : from Tkinter import * Everything seems to be fine so far. I add a few more lines: widget = Lable(None, text = 'Hello') widget.pack() Everything great so far..... widget.mainloop() It hangs. If I wait for a while and then hit Ctr-C I get the following error: Traceback (innermost last): File "", line 1, in ? File "k:\python\lib\lib-tk\Tkinter.py", line 492, in mainloop self.tk.mainloop(n) KeyboardInterrupt This happens whenever I try to run a program that uses Tkinter. For some reason I can get the tkFileDialog.py and the tkColorChooser.py to run alright but nothing else......very weird. Can anyone offer insight to this baffling problem?? Thank you so much, Tom From euroibc at solair1.inter.NL.net Wed Apr 21 05:43:43 1999 From: euroibc at solair1.inter.NL.net (Martin van Nijnatten) Date: Wed, 21 Apr 1999 11:43:43 +0200 Subject: opening more than 1 file References: <371CB255.5FCAFBAF@solair1.inter.NL.net> <371CC329.F22B534F@pop.vet.uu.nl> Message-ID: <371D9DCF.9ED0973A@solair1.inter.NL.net> Thanks, this answers my question. I want to read the files, and they have to be open simultaneously because I want to merge the records/lines in the files into 1 file (after I made some changes to certain fields) Martijn Faassen wrote: > martin van nijnatten wrote: > > > > I have a variable, which can have a value in the range from 1 to 20. > > > > If the value is 7, I have to open 7 files. > > > > What could be an elegant way of doing this? > > It's hard to say without more details -- what names do you want these > files to have, for instance? Do you want to read the files, or write to > them? The basic idea could be something like: > > def openfiles(howmany): > opened_files = [] > for i in range(howmany): > opened_files.append(open("prefix%s" % i, "r")) > return opened_files > > This returns a list with file objects. > > Why is it necessary to open so many files simultaneously anyway? Perhaps > I misunderstood. :) > > Regards, > > Martijn From mlh at idt.ntnu.no Tue Apr 6 08:55:53 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 06 Apr 1999 14:55:53 +0200 Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> Message-ID: "TM" writes: > Has anyone created a pov ray module for python? I have been thinking about it, but haven't done it yet... What do you think it should contain? > > Thanks, > Tom -- Magnus Lie Hetland http://arcadia.laiv.org From frank at ned.dem.csiro.au Wed Apr 14 04:47:17 1999 From: frank at ned.dem.csiro.au (frank) Date: Wed, 14 Apr 1999 16:47:17 +0800 Subject: Help! PIL compiled into Tkinter in 1.5.2 (Tricky Bits!) Message-ID: I'm trying to compile PIL (1.0b1) into the _tkinter module in 1.5.2's Modules/Setup config file under Digital Unix 4.0d (from source on all counts). Since it might matter, I'm trying to do this under VPATH control from an architecture-specific directory, where configure was run as: /configure I unpacked the 1.5.2 source into its own directory, separate from /usr/local/lib/python-1.5, where I have the installation proper. The Setup.in file lists the following 2 lines: # *** Uncomment and edit for PIL (TkImaging) extension only: # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ Since the 1.5.2 source is living in its own pristine directory, and in particular *has* no Extensions subdirectory, what is the proper way to configure the above two lines in my architecture-specific Modules/Setup, if I want to have PIL/TkImaging built in? Things I've tried, and failed: * Building PIL in-place, under a hand-built Extensions subdirectory of the pristine 1.5.2 source directory. * Hardwiring the path in Setup to my *old* PIL installation, found under my 1.5.1 Extensions subdirectory. (I never managed to figure this out for 1.5.1 either, and so PIL isn't married to _tkinter in my 1.5.1 installaion either) * Slapping John Cleese on the side of his head with a large dead fish, next to a canal, while dressed in Pith Helmet, Khaki shorts, and Khaki shirt. (Ok, Ok, not really, but then, nobody expects the Spanish Inquisition!) Any help would be much appreciated! Cheers, Frank Horowitz -- Frank Horowitz; frank at ned.dem.csiro.au CSIRO Exploration & Mining/AGCRC; Perth, AUSTRALIA From a.eyre at optichrome.com Tue Apr 6 09:04:38 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Tue, 6 Apr 1999 13:04:38 GMT Subject: Calling __builtins__ from C API In-Reply-To: References: Message-ID: <000a01be802e$0798d4e0$2bcbd9c2@optichrome.com> > However, I can't figure out the proper way to refer to this > instance from the C API. While I can use the PyRun_SimpleString > function to refer the instance, this seems like a hack. Try: #include void main() { Py_Initialize(); PyObject* builtinsMod = PyImport_ImportModule("__builtin__"); PyObject* builtinsDict = PyModule_GetDict(builtinsMod); PyObject* someString = PyString_FromString("someValue"); PyDict_SetItemString(builtinsDict, "someName", someString); Py_DECREF(builtinsMod); Py_DECREF(builtinsDict); Py_DECREF(someString); Py_Finalize(); } > What are the disadvantages of using this over the more cumbersome, > PyObject_GetAttrString(), Py_BuildValue(), PyEval_CallObject(), etc.? > How do you refer to a built-in function or object? AFAIK, the only difference is that with PyRun_String(), it has to run throught the parser first. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From tim_one at email.msn.com Sat Apr 10 00:13:53 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 10 Apr 1999 04:13:53 GMT Subject: WinZip vs 0-length files (was RE: trivial import question) In-Reply-To: <000401be7808$6105e3c0$549e2299@tim> References: <000401be7808$6105e3c0$549e2299@tim> Message-ID: <000201be8308$8b824520$ac9e2299@tim> With tne candidate release of Python 1.5.2 just out, this is quite timely! At various times in March, at least Brad Clements, Lars Marius Garshol and Tres Seaver spread the rumor that WinZip wouldn't extract 0-length files, thus causing Python packages depending on an empty __init__.py to fail in mysterious ways. I tried reproducing that but had no problems with the latest WinZip, so had a good time insulting them all . But they were right! Steve Spicklemire provided the missing clue offline: while WinZip does not have a problem with 0-length files in .zip archives, it does indeed fail to extract them from .tgz archives. Nico Mak (WinZip's source) confirmed this, adding that it's a problem for all of .z, .gz, and .tgz archives (I think .tar belongs in there too), and said it should be fixed in "a future release" (as opposed, I guess, to a past release -- only Guido can pull that one off). Since most Windows distributions get packaged as .zip archives, most times you shouldn't have a problem. If you download the 1.5.2c1 *source* distribution, though, note that there are three files in py152c1.tgz WinZip fails to extract: Python-1.5.2c1\Tools\pynche\__init__.py Python-1.5.2c1\PC\vc15_lib\_.c Python-1.5.2c1\PC\vc15_w31\_.c be-careful-it's-an-empty-jungle-out-there-ly y'rs - tim From tomjenkins at my-dejanews.com Mon Apr 26 16:47:29 1999 From: tomjenkins at my-dejanews.com (tomjenkins at my-dejanews.com) Date: Mon, 26 Apr 1999 20:47:29 GMT Subject: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: <7g2jd0$3r0$1@nnrp1.dejanews.com> In article <613145F79272D211914B0020AFF6401914DAD8 at gandalf.digicool.com>, Brian Lloyd wrote: > There are also some general optimizations that can be used in > places where speed is an issue, such as avoiding repeated > attribute lookups (esp. in loops). This version of your read_write > function uses the same basic algorithm, but forgoes re for more > specific tools (slicing, string.split) and has some examples of > optimizations to mimimize attribute lookups. I haven't timed it > or anything, but I'd be surprised if it wasn't noticeably > faster. Brian, just to followup on your post I profiled his original code and yours: PII 450, 128M, WinNT Original: 5.126 seconds Your Ver: 1.512 seconds Tom -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From fdrake at cnri.reston.va.us Tue Apr 13 09:30:00 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Tue, 13 Apr 1999 13:30:00 GMT Subject: RPC and XDR with python In-Reply-To: <19990413071131.A1293592@vislab.epa.gov> References: <37119B99.B3E2633C@hons.cs.usyd.edu.au> <19990413071131.A1293592@vislab.epa.gov> Message-ID: <14099.18136.253966.903734@weyr.cnri.reston.va.us> Randall Hopper writes: > Well, haven't looked for RPC, but XDR is there. Here's a code snip from > something I wrote recently, brutally cut and simplified to highlight how > xdrlib can be used: The xdrlib module is documented at: http://www.python.org/doc/lib/module-xdrlib.html Using this to support RPC is included in the Demo/rpc/ directory of the source distribution; I don't know how recently this has been tested. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From joe at strout.net Thu Apr 8 18:48:18 1999 From: joe at strout.net (Joseph J. Strout) Date: Thu, 8 Apr 1999 22:48:18 GMT Subject: PIL font questions In-Reply-To: <19990408223742.21605.rocketmail@ web605.yahoomail.com> References: <19990408223742.21605.rocketmail@ web605.yahoomail.com> Message-ID: At 3:37 PM -0700 04/08/99, David Ascher wrote: >There is a bunch of PIL fonts as part of the "FULL" Snow distribution. Feel >free to steal. Thanks! Er, but where do I get that? I just downloaded a fresh copy of Snow 1.26, and I can't seem to find these there. FYI, I'm working on a PIL backend to PIDDLE. I think you already have a PIL backend for Snow, but if my piddlePIL works out nicely, and assuming you're planning to also support PIDDLE, then you may be able to use that rather than maintaining your own PIL-drawing code. Just a thought. Cheers, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' From stephan at pcrm.win.tue.nl Fri Apr 23 10:25:48 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 23 Apr 1999 16:25:48 +0200 Subject: Bug or Feature? References: <37208E69.4B022E0C@mediaone.net> Message-ID: Fuming Wang writes: > Is this a bug or a feature that I don't know about? It is a feature. If you do something like [[]]*10, then you should realize that this gives you a list containing ten times the *same* list. So mutation to one changes them all. Greetings, Stephan From gmcm at hypernet.com Thu Apr 22 17:25:18 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 22 Apr 1999 21:25:18 GMT Subject: What is it ? How can I learn it ? Where should I start ? Wha In-Reply-To: <371F7DB9.E7E48A82@callware.com> References: <371F7DB9.E7E48A82@callware.com> Message-ID: <1287305973-36728049@hypernet.com> Ivan remembers... > ... and most of the real > cannibals have been muzzled (Gordon excepted, so don't put any parts > of you through his cage bars that you want to keep). ... and then forgets that I'm not poikilothermophagic... > PS: And just *where* is this job that (I should be so lucky) > *REQUIRES* you to know Python???????? Why aren't they calling > ME???? Now, Ivan, do you really have to ask? revenge-is-a-dish-best-eaten-raw-ly y'rs - Gordon From chad at vision.arc.nasa.gov Fri Apr 2 20:09:36 1999 From: chad at vision.arc.nasa.gov (Chad Netzer) Date: Fri, 02 Apr 1999 17:09:36 -0800 Subject: string.join() vs % and + operators References: <37054490.E79ADCC9@easystreet.com> Message-ID: <37056A50.E22A3560@vision.arc.nasa.gov> Al Christians wrote: > Whereas Python's strings are immutable, there is potentially a strong > incentive to get them right the first time. In my applications, I > want to create strings that have many fields within them. I assume that > it would be nice to be able to modify the fields without creating a new > string any time its contents get changed, but I don't think that Python > gives any nice way to do this. Look into the array module. (or the NumArray module from LLNL) Depending on the specifics of your applications, it may allow you to do what you want. From larsga at ifi.uio.no Thu Apr 8 05:17:17 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 08 Apr 1999 11:17:17 +0200 Subject: Internet Robot References: <7ehe9m$hbs$1@nnrp1.dejanews.com> Message-ID: * gscot at my-dejanews.com | | I would like to write a Python robot to play an Internet game. I do | not know how to make a POST request. Thanks to anyone in advance | that can point me in the right direction. Use httplib in the standard libraries. If you need information on HTTP you can look here: --Lars M. From news at helen.demon.nl Thu Apr 29 07:18:14 1999 From: news at helen.demon.nl (Ilja Heitlager) Date: Thu, 29 Apr 1999 13:18:14 +0200 Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> <7g99pj$b1$1@news.worldonline.nl> Message-ID: <7g9eln$4eq$1@news.worldonline.nl> David M. Cook wrote in message ... >On Thu, 29 Apr 1999 11:54:58 +0200, Ilja Heitlager wrote: > >>OK, A UNIX guy (that will change ;-) > >Yes, soon you will *all* be Linux guys. I would love too, but Windows doesn't leave any space on my HD ;-( > Resistance is futile. You will be assimilated. Borgs don't mix with snakes. Ilja From bwinton at tor.dhs.org Sun Apr 11 14:35:53 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Sun, 11 Apr 1999 18:35:53 GMT Subject: bug or feature? traceback with python -x off by one line References: <3710DF00.DF5@creo.com> Message-ID: On Sun, 11 Apr 1999 10:42:24 -0700, Dale Nagata wrote: >I package a lot of Python scripts as ready-to-run Windows NT batch >files by prepending the line > @python -x %~f0 %* & goto :EOF Hey, that's pretty cool looking... But I have to wonder, why don't you just type "filename.py"? The associations are set up correctly by default if I remember correctly, so if you have python installed on the machine, you don't need the trick. (Say, does that work on Win95/98 as well? There it could be very handy for some stuff we're doing at work...) >which means "without echoing to the console window, run Python with the This got me started thinking about the "Hello Polyglot" program I saw a while ago, and I wondered just what that line would do if interpreted as a Perl program (because of the @)... The answer is: syntax error at temp2 line 1, near "@python -x " Warning: Use of "-x" without parens is ambiguous at temp2 line 1. Bareword found where operator expected at temp2 line 1, near "%~f0" (Missing operator before f0?) Execution of temp2 aborted due to compilation errors. >Any ideas on the best way to resolve this? How, from within a script, >can I detect that the -x option is in effect? Or do I have to go hack >the interpreter source? I think you'ld have to hack the source, since the traceback line numbers are set in there, no matter what you do. Later, Blake. From markc at chiark.greenend.org.uk Wed Apr 14 07:40:31 1999 From: markc at chiark.greenend.org.uk (Mark Carroll) Date: 14 Apr 1999 12:40:31 +0100 (BST) Subject: Pig Latin? References: <816010E2456BD111A48700805FBBE2EEA63EEF@ex-quebec-u1.baan.com> Message-ID: <-FC*R+rXn@news.chiark.greenend.org.uk> In article <816010E2456BD111A48700805FBBE2EEA63EEF at ex-quebec-u1.baan.com>, Gaetan Corneau wrote: >OK, I'll bite: >Could someone tell me what "pig latin" is? A form of latin spoken by pigs? http://WWW-KSL-SVC.stanford.edu:5915/WEBSTER/ is your friend. According to it, pig latin n, often cap L (1931) :a jargon that is made by systematic alteration of English (as ipskay the ointjay for skip the joint) -- Mark From wlfraed at ix.netcom.com Fri Apr 30 01:37:51 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Fri, 30 Apr 1999 05:37:51 GMT Subject: HTML "sanitizer" in Python References: Message-ID: <37293e7c.2958315@nntp.ix.netcom.com> On Thu, 29 Apr 1999 12:20:27 -0400, "Scott Stirling" declaimed the following in comp.lang.python: > On opening files in Windows--I was hoping there was a way to give python the full file path. Everything I have seen so far just tells me how to open a file if it's in the same directory I am running python from. > > I don't have sed on my MS Windows PC at work. This was part of the initial explanation--I am working for a company where we have DOS, Windows and Office 97. No sed, no Unix. This is a Y2K Project too, so we are on a budget with little leeway for new ideas that weren't included in the original statement of work and project plan. > Did you try? Actually, you might have gotten caught on the \ treatment. > PythonWin 1.5 (#0, Dec 30 1997, 23:24:20) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > Portions copyright 1994-1998 Mark Hammond (MHammond at skippinet.com.au) > >>> fo = open("h:\temp\somefile.txt","w") > Traceback (innermost last): > File "", line 1, in ? > IOError: (2, 'No such file or directory') > >>> fo = open("h:/temp/somefile.txt", "w") > >>> fo.write("This is a line of text\n") > >>> fo.close() > >>> > >>> fo=open("h:\\temp\\somefile.txt","r") > >>> for ln in fo.readlines(): > ... print ln > ... > This is a line of text > > >>> fo.close() > >>> Note the use of reversed / on the first open, and the doubled \\ on the second. -- > ============================================================== < > 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 fredrik at pythonware.com Thu Apr 15 09:31:35 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Apr 1999 13:31:35 GMT Subject: PIL fonts - Where are you? References: <7jbR2.3071$YU1.5576@newsr2.twcny.rr.com> Message-ID: <002c01be8744$4a7af2d0$f29b12c2@pythonware.com> Kevin K. Ehmka wrote: > >> Does anybody have some ready made fonts in PIL format they want to share? we'll post pilfont versions of the fonts in the X11 release within a near future. These fonts are fully redistributable, but the current version of pilfont doesn't copy the copyright text from the source files. That should be fixed first. > I'm using the compiled binaries of PIL (from Starship) and fail to get > pilfont to work on several BDF fonts. I even used a font maker program and I > get different errors. Using 1.0b I get encoder errors. Using 0.3 PIL I get > array bounds errors. pilfont has been tested with all files from the standard distribution, but the version shipped with 1.0b1 fails on fonts generated by some other tools. most notable, it assumes that the FONT field is a full X11 font specifier, e.g: FONT -Adobe-Times-Medium-R-Normal--11-80-100-100-P-54-ISO8859-1 some tools use values like "font1" or "generated" etc. you could try editing the files by hand, changing the value of FONT to some- thing (anything) with an appropriate number of hyphens in it... this will be fixed (together with some other problems) in 1.0 final. From kaz at ashi.FootPrints.net Thu Apr 22 15:17:02 1999 From: kaz at ashi.FootPrints.net (Kaz Kylheku) Date: 22 Apr 1999 19:17:02 GMT Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <371F11C2.3162025@ciril.fr> <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk> Message-ID: <7fnsje$pum$14@newsread.f.de.uu.net> On Thu, 22 Apr 1999 18:01:27 GMT, Barry Margolin wrote: >In article <4fv$ECA+JyH3EwbN at jessikat.demon.co.uk>, >Robin Becker wrote: >>I take this completely differently; least astonishment for me is if >>program X looks and behaves the same way no matter what keyboard, mouse >>and screen I'm using. As a 'user' of the program X it shouldn't matter >>what OS/WM is executing the code. I certainly don't want vi or emacs to >>be different on the mac why should I treat word or excel differently? > >I would be very surprised if Netscape on the Macintosh presented a >Windows-like user interface, rather than adopting the standard Macintosh I'd be very surprised if even 10% of, say, comp.lang.c gave a damn. The pitiful dumbfuck who started this thread made a severe mistake in constructing the Newsgroups: header line, the moment he put in the first comma. I am setting Followup-to: to comp.lang.tcl. From astro at nospam.tne.net.au Fri Apr 30 09:37:45 1999 From: astro at nospam.tne.net.au (Tim Auld) Date: Fri, 30 Apr 1999 23:07:45 +0930 Subject: Using Python for Modular Artificial Intelligence code References: <7g94lp$mdu$1@news.worldonline.nl> Message-ID: >>I've started looking into Python as the AI scripting language for this >>purpose, but I'm having trouble seeing exactly how I could do this. I want >>a message passing architecture - so one object in the game world sends a >>message to another for interpretation (along with a Python tuple for the >>parameters of the message perhaps). This requires a two way interface >>between my C++ code and the Python script loaded for the particular game >>object. >Wouldn't you be better of using a network or distributed architecture. Use >Corba or TCP/IP protocol to let your objects interact. Saves you the trouble >of language-interoperatablility and provides possibilities for multi-user >(You're doing a LARGE game project, not?) > >Where do you use C++ for anyway? GUI's? Build them in Python, forget C++ >until you are done and than use C++ to speed up critical sections > >Ilja This is an interesting idea, using sockets to communicate with the AI modules, which would have to be run in separate threads (but perhaps blocking on socket I/O to save cycles). I was naturally going to use sockets for multiplayer, and having socket connections to AI modules may even generalise (and simplify) the system further. The reason I'm using C++ is mainly because I'm familiar with it, and because of speed. I'm aware that Python is relatively slow, so I would rather use C++ as a base from the start, and save myself the trouble of rewriting it all later. Thanks for your help :) Tim From trashcan at david-steuber.com Wed Apr 28 03:11:57 1999 From: trashcan at david-steuber.com (David Steuber) Date: 28 Apr 1999 03:11:57 -0400 Subject: running application config files written in Python References: Message-ID: Nathan Froyd writes: -> Say I have an application whose configuration language I want to be -> Python. I would like to do the same thing. However, my application will be written in Python and translated to C or C++ as necessary. I just wanted to point out that you will be executing actual code not unlike the VBA macros in Microsoft Word with this technique. The Melissa virus was written in VBA in a Word document. If there is a way to sandbox such code, I would love to hear how because it is very useful to be able to just recycle the Python interpreter for reading configuration information. -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. "Gee, Mudhead, everyone at More Science High has an extracurricular activity except you." "Well, gee, doesn't Louise count?" "Only to ten, Mudhead." -- Firesign Theater From tim_one at email.msn.com Sat Apr 10 22:15:52 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 11 Apr 1999 02:15:52 GMT Subject: WinZip vs 0-length files (was RE: trivial import question) In-Reply-To: <14095.40219.501277.258165@buffalo.fnal.gov> References: <14095.40219.501277.258165@buffalo.fnal.gov> Message-ID: <000301be83c1$39637a20$7fa22299@tim> [Tim, passes on Nico Mak's confirmation that WinZip 7 does not extract 0-length files from .tgz/.gz/.z/.tar archives, but does from .zip archives, and that the former behavior is an acknowledged bug ] [Charles G Waldman] > would it work to make the __init__.py files just have a #comment in > them so that they wouldn't be 0 bytes? Certainly should work, yes. Should also work to leave __init__.py empty but also ship __init__.pyc files (which aren't empty even if __init__.py is). words-to-the-wise-and-the-idle-ly y'rs - tim From faassen at pop.vet.uu.nl Wed Apr 21 15:58:38 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Wed, 21 Apr 1999 21:58:38 +0200 Subject: New python user seeks comments References: <371DA955.9F13B144@pop.vet.uu.nl> Message-ID: <371E2DEE.C2BD5A58@pop.vet.uu.nl> Chad McDaniel wrote: ['in' is a reserved word so can't be used as a variable name] > It seems that Python could have mentioned that to the user. True, though it does say this: File "", line 2 in = open("test.txt", "r") ^ SyntaxError: invalid syntax Could be better, but easily could've been far worse.. From amk1 at erols.com Sun Apr 18 21:14:02 1999 From: amk1 at erols.com (A.M. Kuchling) Date: Sun, 18 Apr 1999 21:14:02 -0400 Subject: How libpython1.5.so Message-ID: <199904190114.VAA03514@207-172-39-16.s16.tnt10.ann.va.dialup.rcn.com> Spam detection software, running on the system "albatross.python.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Nick Belshaw writes: > Whilst trying to get Python plugins to work on Gnumeric-0.23 I bumped up > against the need for libpython1.5.so.0.0.0 Here's a patch to the top-level Makefile.in which adds a "shared" target. Can people please try this and see if it works on your favorite Unix variant? It doesn't verify that you've compiled all the code with -fPIC or whatever's required; I'm not sure how to check or enforce that. (It could do "make clean ; make CCFLAGS=", but is that too extreme?) [...] Content analysis details: (7.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 4.4 HELO_DYNAMIC_IPADDR2 Relay HELO'd using suspicious hostname (IP addr 2) 0.5 FH_HELO_EQ_D_D_D_D Helo is d-d-d-d 1.6 TVD_RCVD_IP TVD_RCVD_IP 2.0 FH_DATE_IS_19XX The date is not 19xx. 0.1 RDNS_DYNAMIC Delivered to trusted network by host with dynamic-looking rDNS -0.7 AWL AWL: From: address is in the auto white-list -------------- next part -------------- An embedded message was scrubbed... From: "A.M. Kuchling" Subject: How libpython1.5.so Date: Sun, 18 Apr 1999 21:14:02 -0400 Size: 2582 URL: From brunomadv at ciudad.com.ar Sun Apr 11 13:33:55 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Sun, 11 Apr 1999 17:33:55 GMT Subject: best way to copy a file [Q] Message-ID: <000201be8441$7965d4d0$6eba0ac8@kuarajy.infosys.com.ar> Hi! I need to copy a file (can be binary or ascii) from one path to another. I have tryied to do: line = fd.readline() while line: fd2.write(line) line = fd.readline() fd.close() fd2.close() It only works for ascii files ... How can I do a 'copy' ...? I need to run this on NT ...:( And I don't want to open a shell to do a copy from there... I also tryied fd.read() ... No success neither. I have looked unsuccesfully throughout the documentation and didn't find a 'filecopy' method. The files can range from 1KB to 600MB+ ... TIA and excuse my english ... :-) /B Bruno Mattarollo ... proud to be a PSA member From arcege at shore.net Wed Apr 28 14:32:06 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 28 Apr 1999 18:32:06 GMT Subject: Python implementation of tar References: <7ftjjl$tim$1@nnrp1.dejanews.com> <372595AE.C27E7E50@phoenix-edv.netzservice.de> <14119.2190.827661.960717@amarok.cnri.reston.va.us> Message-ID: Andrew M. Kuchling wrote: : Holger Jannsen writes: :>frankmcgeough at my-dejanews.com schrieb: :>> Does someone has a tar implementation written in Python? : Try Clement Hintze's tarlib.py: : ftp://ftp.python.org/pub/python/contrib/System/tarlib.py That'll teach me for writing one when I don't know if there is one. ;) -Arcege From jam at newimage.com Sun Apr 25 18:27:15 1999 From: jam at newimage.com (jam) Date: Sun, 25 Apr 1999 18:27:15 -0400 Subject: HELP! NumPy (Graphics) and Linux In-Reply-To: <199904252156.RAA83445@chipotle.physics.uvm.edu>; from Kelvin Chu on Sun, Apr 25, 1999 at 05:56:44PM -0400 References: <7fvpsh$l8e$1@nnrp1.dejanews.com> <199904252156.RAA83445@chipotle.physics.uvm.edu> Message-ID: <19990425182715.A17114@toast.internal> On Sun, Apr 25, 1999 at 05:56:44PM -0400, Kelvin Chu wrote: > > Dear J; > > Thanks for your quick response. I didn't install RPMS, I built the > source. Should I go back and get the RPMs instead? -k > greetings, in general, I install rpms when I can find them from 'trusted' sources (check for latest python rpms).. they have already been compiled, and generally whatever headaches required to fix compilation problems have already been ironed out.. go for it.. it can't hurt.. if it *still* doesn't work, then let me know, and we can work from there... also, before you install the rpms, I would suggest removing old versions of the interpreter that may have been installed in /usr/local/... it "shouldn't" hurt anything to leave them around, but just to be on the safe side, that's what I would do. let me know if that helps. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From dalke at bioreason.com Wed Apr 21 16:31:20 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Wed, 21 Apr 1999 14:31:20 -0600 Subject: Buglet: egcs' name is too long for Python startup message References: Message-ID: <371E3598.1E28EA19@bioreason.com> Gregor Hoffleit suggested a patch: > --- python-1.5.2.orig/Python/getversion.c > +++ python-1.5.2/Python/getversion.c > @@ -39,7 +39,7 @@ > Py_GetVersion() > { > static char version[100]; > - sprintf(version, "%.10s (%.40s) %.40s", PY_VERSION, > + sprintf(version, "%.10s (%.40s) %.80s", PY_VERSION, > Py_GetBuildInfo(), Py_GetCompiler()); > return version; > } And you probably want to use static char version[140]; instead of 100 (since you now allow 80+40+10+5 = 135 characters). Andrew dalke at acm.org From max at rightworks.com Tue Apr 27 21:29:23 1999 From: max at rightworks.com (max at rightworks.com) Date: Wed, 28 Apr 1999 01:29:23 GMT Subject: SMTPLIB accessing MicroSoft SMTP mail server Message-ID: <7g5o9g$ues$1@nnrp1.dejanews.com> I had reported a problem that when sending mail to a MS SMTP server my code was hanging. The fix is in the data() method the msg text is terminated by sending "\n.\n" It appears that MicroSoft requires a full CRLF. By changing the line from self.send("\n.\n") to self.send(CRLF+"."+CRLF) problem is fixed. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From aa8vb at vislab.epa.gov Tue Apr 27 07:33:42 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 27 Apr 1999 07:33:42 -0400 Subject: GUI and printing In-Reply-To: <7fqkcu$7gj$1@mars.worldonline.fr>; from christer fernstrom on Fri, Apr 23, 1999 at 09:18:27PM +0200 References: <7fqkcu$7gj$1@mars.worldonline.fr> Message-ID: <19990427073342.A579158@vislab.epa.gov> christer fernstrom: |Anybody knows if any of the Pythonized GUI kits support printing of window |contents AND cross-platform compatibility? (at least on NT and Mac)? |Thx, | christer Re printing. I don't know the details (since I haven't used this feature), but seems I recall that Tk has some support for PostScript printing. Grepping Tkinter, I see that the Canvas widget has a "postscript" method. Tkinter is one that is widely cross platform since it's built on Tk. IIRC, it runs on both the platforms you mention along with many others. Randall From skip at mojam.com Fri Apr 23 18:41:19 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 23 Apr 1999 22:41:19 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> Message-ID: <3720F783.24F2E94B@mojam.com> Arne Mueller wrote: > However the problem of reading/writing larges files line by > line is the source of slowing down the whole process. > > def rw(input, output): > while 1: > line = input.readline() > if not line: break > output.write(line) > > f = open('very_large_file','r') > rw(f, stdout) > > The file I read in contains 2053927 lines and it takes 382 sec to > read/write it where perl does it in 15 sec. I saw a mention of using readlines with a buffer size to get the benefits of large reads without requiring that you read the entire file into memory at once. Here's a concrete example. I use this idiom (while loop over readlines() and a nested for loop processing each line) all the time for processing large files that I don't need to have in memory all at once. The input file, /tmp/words2, was generated from /usr/dict/words: sed -e 's/\(.*\)/\1 \1 \1 \1 \1/' < /usr/dict/words > /tmp/words cat /tmp/words /tmp/words /tmp/words /tmp/words /tmp/words > /tmp/words2 It's not as big as your input file (10.2MB, 227k lines), but still big enough to measure differences. The script below prints (on the second of two runs to make sure the file is in memory) 68.9596179724 7.96663999557 suggesting about a 8x speedup between your original function and my readlines version. It's still not going to be as fast as Perl, but it's probably close enough that some other bottleneck will probably pop up now... import sys, time def rw(input, output): while 1: line = input.readline() if not line: break output.write(line) f = open('/tmp/words2','r') devnull = open('/dev/null','w') t = time.time() rw(f, devnull) print time.time() - t def rw2(input, output): lines = input.readlines(100000) while lines: output.writelines(lines) lines = input.readlines(100000) f = open('/tmp/words2','r') t = time.time() rw2(f, devnull) print time.time() - t Cheers, -- Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/ skip at mojam.com | Musi-Cal: http://www.musi-cal.com/ 518-372-5583 From jbauer at rubic.com Sun Apr 18 20:32:54 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Mon, 19 Apr 1999 00:32:54 GMT Subject: Sorting tuples References: <7fdkhf$12d$1@sparky.wolfe.net> Message-ID: <371A79B6.F803063E@rubic.com> > I have a list of tuples > [('a','p','q'),('b','r','s'),('c','t','u'),('a','v','w'),('b','x','y')], > and I want to print out > > a : p, q, v, w > b : r, s, x, y > c : t, u Jon, There are lots of cute ways to do this, and I expect to see a bunch of followup posts that will show off arcane Python wizardry, but the simple solution is to use a dictionary. The dictionary approach is quick, easy, and more amenable to modification. ### Jon's list of tuples, shuffled t = [ ('b','y','x'), ('a','v','w'), ('b','r','s'), ('c','u','t'), ('a','p','q'), ] ### build the dict d = {} for x in t: if not d.has_key(x[0]): d[x[0]] = [] for y in x[1:]: d[x[0]].append(y) ### print the dict, sorting the values at the ### last possible moment. keys = d.keys() keys.sort() for k in keys: d[k].sort() print k, ':', d[k] It may not be obvious from the example above, but lists of tuples can also just be sorted in place, e.g. t = [ ('b','x','y'), ... t.sort() Python almost always follows the principle of least surprise in this regard. Best regards, Jeff Bauer Rubicon, Inc. From fredrik at pythonware.com Wed Apr 14 03:12:22 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 14 Apr 1999 07:12:22 GMT Subject: Converting a string to a tuple References: <01be8530$65bb7120$52037e81@saints> <14098.28727.245158.616727@buffalo.fnal.gov> <00f501be857f$ff636f40$f29b12c2@pythonware.com> <01be85b5$f7197c90$52037e81@saints> <008f01be85b8$a5be9580$f29b12c2@pythonware.com> Message-ID: <040801be8646$823310d0$f29b12c2@pythonware.com> > > since \\ is Python's string representation > > for a single backslash (that is, \\ in the > > source code becomes \ in the actual > > string). > > > and \t is an alias for \011 (a tab). > > No it isn't. of course it is. when used in Python's string representation, which was what I was talking about. please read the entire message before following up on pieces of it. > The problem arises because of the second evaluation. Either use > string.replace to double backslashes in the string, prefix the string > with an "r", or don't use eval. argh! if you have the string in source code, just remove the outer quotes. converting strings to tuples has never been easier. but I suspect Bruce was looking for something else, and that he was tricked by Python's string syntax and repr. it has happened to many good programmers before, as can be seen in the c.l.py archives. > I'd avoid eval... why? it's there, it works, and it can be used in a safe way, as shown in earlier posts. and converting strings to tuples is kinda hard without it... From phd at sun.med.ru Wed Apr 7 10:55:30 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Wed, 7 Apr 1999 14:55:30 GMT Subject: GadFly - MemoryError In-Reply-To: <370B5E83.C796BFF3@palladion.com> References: <370B5E83.C796BFF3@palladion.com> Message-ID: Hello! On Wed, 7 Apr 1999, Tres Seaver wrote: > SELECT rec_no, URL FROM bookmarks > WHERE URL IN > (SELECT URL FROM bookmarks GROUP BY URL HAVING COUNT(*) > 1) > > or create a temp table first with the results of the subquery, then join it in a > separate query. It looks nice. I'll try. The problem with it is that I work with Postgres SQl server a little more than a year, and Postgres has many problems with HAVING, so usually I avoid it. I forget to switch my mind when switched to GadFly. Thanks. > -- > ========================================================= > Tres Seaver tseaver at palladion.com 713-523-6582 > Palladion Software http://www.palladion.com > Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From never at mail.matav.hu Sun Apr 11 21:41:57 1999 From: never at mail.matav.hu (Hever Zsolt) Date: Mon, 12 Apr 1999 01:41:57 GMT Subject: ANNOUNCEMENT: Some Python Documentation in Hungarian language Message-ID: Hi there, I am writing my diploma work in Python. I made two enclosures to it and converted them into HTML format. Now I put them out on the Internet with a Python home page together all in Hungarian language. I hope this documentation will help Python to be better known in Hungary. The documentations: ** Python home page in Hungarian language < http://www.cab.u-szeged.hu/~h532851/python.htm > The translation of the foreword: Dear Visitor, by the links on this page you can get into the world of the Python and the Internet Community. ** Python Mini Reference in Hungarian language: < http://www.cab.u-szeged.hu/~h532851/pmr.htm > It was translated from the work "A Python Quick Reference" by Chris Hoffmann and I tried to keep it up-to-date by inserting links. ** Tkinter in Hungarian language: < http://www.cab.u-szeged.hu/~h532851/tkinter.htm > It is based on Tkinter Life Preserver by Matt Conway and has lots of links pointing to the Python Tkinter Resources, An Introduction to Tkinter by Fredrik Lundh . I hope that no copyright is violated by these documentations. I would like to say thank to Arpad Kiss < http://starship.python.net/crew/arpadk/> for his help with making these documentations and my diploma work. Zsolt Hever From achrist at easystreet.com Tue Apr 6 18:05:17 1999 From: achrist at easystreet.com (Al Christians) Date: Tue, 06 Apr 1999 15:05:17 -0700 Subject: How to use os.path.walk method References: <7edt95$krh$1@ash.prod.itd.earthlink.net> Message-ID: <370A851D.F13835CE@easystreet.com> Are you sure that you've got that right? I cut your code and put it into a Python console, then changed the dir from /Windmodem/ to / and it worked for me. Maybe you meant 'Winmodem'? Al Benjamin Derstine wrote: > > Can anyone give me a brief example of how to use this method? The > documentation is somewhat unclear: > > walk (path, visit, arg) > Calls the function visit with arguments (arg, dirname, names) for each > directory in the directory tree rooted at path (including path itself, if it > is a directory). The argument dirname specifies the visited directory, the > argument names lists the files in the directory (gotten from > os.listdir(dirname)). The visit function may modify names to influence the > set of directories visited below dirname, e.g., to avoid visiting certain > parts of the tree. (The object referred to by names must be modified in > place, using del or slice assignment.) > > I understand I need to define a second function for the visit argument but > I'm unclear as to the third argument (arg) in walk() is for. Likewise with > the first argument in visit(). I tried a dummy function just to print the > directories it walks like so: > > import os > > def visit(something, dirname, names): > print dirname > print names > print something > > arg=None > os.path.walk('/Windmodem/',visit,arg) > > where 'Windowmodem' is a directory on my root. > > But this does nothing and quits without returning any errors. > Thanks, > > Ben From kevinsl at yahoo.com Mon Apr 26 00:48:44 1999 From: kevinsl at yahoo.com (Kevin L) Date: Mon, 26 Apr 1999 04:48:44 GMT Subject: timeout on urllib.urlopen? Message-ID: <7g0r7c$gn9$1@nnrp1.dejanews.com> I'm trying to use urllib.urlopen() on a big list of urls, some of which are dead (they don't return a 404, just no response). And the function just waits. Is there any way to specify a timeout period for this function? thanks, Kevin -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From da at ski.org Wed Apr 28 14:50:52 1999 From: da at ski.org (David Ascher) Date: Wed, 28 Apr 1999 11:50:52 -0700 (Pacific Daylight Time) Subject: Maximize Benefit when Purchasing Learning Python In-Reply-To: <00e401be91a6$4d581750$8b7125a6@cpda6686.mcit.com> Message-ID: On Wed, 28 Apr 1999 jkraai at murl.com wrote: > How can I help whom when purchasing Python books? I'll dare to speak for Mark, and say that you should feel free to send either Mark or I (or both) checks for any amount whatsoever. Skip the middleman. Save trees -- don't buy the book, just send us cash. Don't hesitate for a minute. David Ascher From trashcan at david-steuber.com Thu Apr 8 19:21:07 1999 From: trashcan at david-steuber.com (David Steuber) Date: 08 Apr 1999 18:21:07 -0500 Subject: Internet Robot References: <7ehe9m$hbs$1@nnrp1.dejanews.com> Message-ID: gscot at my-dejanews.com writes: -> To All, I would like to write a Python robot to play an Internet -> game. I do not know how to make a POST request. Thanks to anyone in advance -> that can point me in the right direction. Gary There are two ways to post data. I remember one way, but the other is a little trickier. The simple way is to send up a URL encoded string as the body of the request. The other is to send a multi-part mime document. I suggest you go with the former if possible. A post would look something like this: POST /URI HTTP/1.0 Content-Length: octets Content-Type: URL+Encoded+Data+as+name+value+pairs A good thing to do would be to capture the output of an HTTP client posting form data. Also see RFC-1945 and RFC-2068. -- David Steuber http://www.david-steuber.com s/trashcan/david/ to reply by mail If you don't, I won't see it. A LISP programmer knows the value of everything, but the cost of nothing. From ivanlan at callware.com Wed Apr 21 16:12:41 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 21 Apr 1999 20:12:41 GMT Subject: New python user seeks comments References: <371DA955.9F13B144@pop.vet.uu.nl> Message-ID: <371E3139.FDDF65A1@callware.com> Pythonistas-- Chad McDaniel wrote: > > Martijn Faassen writes: > > > David Steuber wrote: > > > > > > Er, uh, hmm. > > > > > > I wrote my first Python program today. It took longer than I > > > expected. Who would have guessed that you couldn't give a file object > > > the name 'in'? Or at least that was one of the weirder obstacles. > > > > It's not that weird as 'in' is a reserved keyword in Python. :) > > > > for i in whatever: > > print "See?" > > > > It seems that Python could have mentioned that to the user. > > -- > -chad http://www.python.org/doc/ref/keywords.html The interpreter also states, in response to an attempt to assign a number to a variable named `in', that such usage is a Syntax Error. It could be changed to ``Fruitless attempt to assign to keyword Error,'' I suppose. -ly y'rs, Ivan =:o ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From aaron_watters at my-dejanews.com Mon Apr 12 08:42:05 1999 From: aaron_watters at my-dejanews.com (aaron_watters at my-dejanews.com) Date: Mon, 12 Apr 1999 12:42:05 GMT Subject: GadFly - MemoryError References: <7eih6b$ck2$1@nnrp1.dejanews.com> Message-ID: <7espms$idh$1@nnrp1.dejanews.com> In article , phd at sun.med.ru wrote: > I started playing with GadFly a few weeks ago, so I downloaded latest > versions of GadFly and kjBuckets. > Yesterday I found a way to use kjSet in my program. > > BTW, what are "kw" in "kwParsing" and "kj" in "kjBuckets"? That's for me to know and you to guess. BTW, I ran the following benchmark on my workstation, emulating your query with artificial data: ===snip fanout = 5 length = 3000 # create a table for self-join test import gadfly g = gadfly.gadfly() g.startup("jtest", "dbtest") # dir ./dbtest should exist c = g.cursor() print "making table" c.execute("create table test (a integer, b integer)") def mapper(i): return (i, i/fanout) data = map(mapper, range(length)) c.execute("insert into test(a,b) values (?,?)", data) # do a self join with fanout from time import time print "doing query" now = time() c.execute("select * from test x, test y where x.b=y.b and x.atestjoin.py making table doing query elapsed 2.39299988747 6000 results generated from initial 3000 This is actually reasonably fast, I think. Adding an index didn't make that much of a difference because the join algorithm actually builds an index on the fly without one for this particular query. The optimized join builds an intermediate table of size 15000 before eliminating most of the intermediate entries with the x.a <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <3709C8BE.4257C9F1@lemburg.com> <14090.16807.950025.496495@bitdiddle.cnri.reston.va.us> Message-ID: <370A78B6.2C18D10F@lockstar.com> Jeremy Hylton wrote: > > >>>>> "MAL" == M -A Lemburg writes: [SNIP] > MAL> Note that I have a project running with the intention to wrap > MAL> OpenSSL in an OO manner called mxCrypto (see the link below). > > Looking forward to seeing it. When do you think you might have an > alpha release ready? > > Jeremy I have a fairly complete SWIGing of OpenSSL/SSleay working. I made it on company time, so I have to get company permission to release it. If there is real interest, I'll push for us to release it. It does all the X.509 stuff, is very OO, and builds on win32 and unices. Interested? Mordy -- o Mordy Ovits o Cryptographic Engineer o LockStar Inc. --------------------------------------------------------------------------- #!/usr/local/bin/python from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!= '-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce( lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1))) From andrew-johnson at home.com Sun Apr 25 17:19:13 1999 From: andrew-johnson at home.com (Andrew Johnson) Date: Sun, 25 Apr 1999 21:19:13 GMT Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: In article , Florian Weimer wrote: ! sweeting at neuronet.com.my writes: ! ! > a) Perl's "defined". ! > [perl] ! > if (defined($x{$token}) ! > ! > [python] ! > if (x.has_key(token) and x[token]!=None) : ! ! Depending on the code, you can omit the comparision to `None'. Perl ! programmers traditionally uses `defined' to test if a key is in a hash, ! so your code is the correct translation if you mimic Perl's undefined ! value with Python's `None', but most of the time, this is not required. Just a point of clarification: Actually, perl programmer's traditionally use 'exists' to test if a key is in a hash ... using 'defined' to test for key existence is a mistake---'defined' will only tell you if that key exists and has a defined value associated with it: Witness the defined test on key2 in the following: #!/usr/bin/perl -w use strict; my %hash = ( key1 => 0, key2 => undef, key3 => 1 ); print "key1 exists\n" if exists $hash{key1}; print "key1 has defined value\n" if defined $hash{key1}; print "key1 has true value\n" if $hash{key1}; print "key2 exists\n" if exists $hash{key2}; print "key2 has defined value\n" if defined $hash{key2}; print "key2 has true value\n" if $hash{key2}; print "key3 exists\n" if exists $hash{key3}; print "key3 has defined value\n" if defined $hash{key3}; print "key3 has true value\n" if $hash{key3}; __END__ which prints: key1 exists key1 has defined value key2 exists key3 exists key3 has defined value key3 has true value regards andrew From guido at eric.cnri.reston.va.us Fri Apr 30 23:40:48 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 30 Apr 1999 23:40:48 -0400 Subject: Trouble with proxies References: <7gasj8$g79$1@nnrp1.dejanews.com> <5lzp3qafkj.fsf@eric.cnri.reston.va.us> <7gd0dh$add$1@nnrp1.dejanews.com> <7gd626$fcf$1@nnrp1.dejanews.com> Message-ID: <5llnf9a24f.fsf@eric.cnri.reston.va.us> Bruce Fletcher writes: > No matter which proxy string I use, or which URL, I get the following: > > > > 403 Forbidden > >

403 Forbidden

> >

The request was not properly formatted. A possible security risk > detected.

> > Traceback (innermost last): > File "C:\PROGRA~1\PYTHON\TOOLS\IDLE\ScriptBinding.py", line 131, in > run_module_event > execfile(filename, mod.__dict__) > File "C:\Users\Bruce\postal codes\idle_experiment.py", line 19, in ? > data = f.readline() > File "C:\Program Files\Python\Lib\plat-win\socket.py", line 117, in readline > new = self._sock.recv(self._rbufsize) > error: (10054, 'winsock error') > > It would appear that the proxy server isn't at issue. Who is > generating that HTML output, anyway? My guess is that your proxy server generates that HTML! Now you have a clue -- look it up in the server's documentation. I'm guessing that it requires some optional HTTP header that modern browsers always send but that poor li'l urllib.py doesn't yet know about. --Guido van Rossum (home page: http://www.python.org/~guido/) From scott at igc.apc.org Sat Apr 3 02:29:50 1999 From: scott at igc.apc.org (Scott Weikart) Date: Sat, 3 Apr 1999 07:29:50 GMT Subject: fix for posix_fsync under SunOS 4.1.x Message-ID: <199904030729.XAA24695@igce.igc.org> Here's a patch to make sure that posix_fsync will compile on all operating systems (specifically needed for SunOS 4.1.x). This unified diff was made against Python 1.5.2 beta 2 . -scott --- Modules/posixmodule.c~ Tue Feb 16 11:38:04 1999 +++ Modules/posixmodule.c Fri Apr 2 22:18:03 1999 @@ -647,6 +647,8 @@ "fsync(fildes) -> None\n\ force write of file with filedescriptor to disk."; +extern int fsync(int); /* Prototype just in case */ + static PyObject * posix_fsync(self, args) PyObject *self; From markus_kohler at hp.com Thu Apr 29 04:13:46 1999 From: markus_kohler at hp.com (Markus Kohler) Date: 29 Apr 1999 10:13:46 +0200 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <37272CA0.3F3F02A2@prescod.net> Message-ID: >>>>> "Paul" == Paul Prescod writes: Paul> Markus Kohler wrote: >> >> >> You are right that one should choose the right tool for a >> problem, but I disagree that Python is optimized for the >> general case. Squeak a free Smalltalk implementation >> (www.squeak.org), is already much faster ( about 3 times >> actually ) than python and it has even a true Garbage >> Collector. Paul> This is a little off-topic but I'm curious whether squeak Paul> has an embedding API. Is there any languge that is as easy Paul> to embed as Python, and also has full garbage collection? No really off-topic, because not using a GC makes embedding much easier, because objects do not move around. Squeak has 'plugins' but these are not yet good enough to allow embedding of arbitrary C code. The main problem is of course that some C code cannot use Squeak allocated objects because the address of the object may change because of garbage collection. Also Squeak currently lacks an easy general mechanism to callback Squeak code from C. In summary one can say that with a decent GC (generational copying + mark and sweep) embedding is more diffcult. Anyway I think a fairly simple embedding API with could be done, it's just more work to do once. Visualworks a commercial Smalltalk implementation shows it's possible to do it. They also have a COM integration for example. I don't know of any other language with a decent garbage that is easy to embed. Maybe SmallEiffel does it. I is a free Eiffel compiler that translates to C has an (optional) GC and allows to call C code. Markus -- Markus Kohler mailto:markus_kohler at hp.com From jeremy at cnri.reston.va.us Tue Apr 13 11:20:58 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 13 Apr 1999 11:20:58 -0400 (EDT) Subject: bug in PyGreSQL module Message-ID: <14099.24295.229214.504295@bitdiddle.cnri.reston.va.us> I found an apparent bug in the Python interface to PostgreSQL. I tried sending a query to the author but haven't heard back, so I'm looking for other users to see if they have run into the problem. I have a table with lots of int fields, some of which of NULL. When I do a Python query, the PyGreSQL module converts the NULL to 0 instead of None, which is the value I expected. Is that a reasonable expectation? The PyGreSQL module doesn't implement the DB API, but I checked there anyway. Alas, it didn't say anything about how to handle NULL. Jeremy From vincem at en.com Mon Apr 19 05:49:32 1999 From: vincem at en.com (Vincent Marchetti) Date: 19 Apr 99 05:49:32 -0400 Subject: How to decode AppleEvent return values Message-ID: I am using the aetools.TalkTo class and methods generated by gensuitemodule.py to send AppleEvents to an app (In this case, CodeWarrior). Some scripting calls to CodeWarrior return a class defined by the application, [e.g. the type 'Segment' from CodeWarrior AppleScript dictionary] which is returned by aepack.unpack as a type 'Unknown'. Is there a way to decode the data attribute of the Unknown class returned by Python or do I need to write my own functions to do this? Thanks, Vincent Marchetti vincem at en.com From aa8vb at vislab.epa.gov Mon Apr 19 10:38:00 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Mon, 19 Apr 1999 14:38:00 GMT Subject: Tkinter - the app that wouldn't quit In-Reply-To: <14107.14469.908426.160852@octopus.chem.uu.nl>; from Rob Hooft on Mon, Apr 19, 1999 at 04:07:01PM +0200 References: <19990416144831.A1548022@vislab.epa.gov> <19990419095013.A62714@vislab.epa.gov> <14107.14469.908426.160852@octopus.chem.uu.nl> Message-ID: <19990419103800.A63906@vislab.epa.gov> Rob Hooft: |>>>>> "RH" == Randall Hopper writes: | | RH> Do I need to add special testing-harness hooks into the dialog | RH> class, or is there a general way to determine when a dialog | RH> destroys/unmaps itself from outside of the dialog code? | |Using Tkinter, you can "wait" for a few specific events. | |"w.wait_window()" will wait for w to be destroyed. But even then, a |destroyed window can not be reused! Ahh, perfect. Just what I was looking for. |I come back to my advertisement: in the *Dialog() classes in the Pmw |framework this has all been programmed (using a wait_variable in that |case); there is no real reason except "the fun of it" to reinvent this |wheel... Well, there's another reason. I'm at the getting-up-to-speed stage with Python and Tkinter, and I want to understand the fundamentals before I go layering other libraries on top. But thanks for the pointer. I'd found Pmw before and do plan to use it in my next project. It looks like it can save me a good bit of time for the off-canvas portions. Randall From ajung at sz-sb.de Sun Apr 18 07:53:06 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Sun, 18 Apr 1999 11:53:06 GMT Subject: re.sub() loops In-Reply-To: ; from Aahz Maruch on Sat, Apr 17, 1999 at 02:35:48PM +0000 References: Message-ID: <19990418135305.A20347@sz-sb.de> On Sat, Apr 17, 1999 at 02:35:48PM +0000, Aahz Maruch wrote: > In article , > Andreas Jung wrote: > > > >I am trying to do some lame HTML processing with some > >HTML. The following lines tries to remove some > >unneccessary code from a HTML file. However python hangs > >in this call: > > > >data = re.sub('','',data) > > Does the ...
contain *all* the strings "es", "da", "en", > "fi", and "sv"? Or are the strings supposed to be "?es" and so on? In > any event, with six ".*" patterns in there, you've got exponential > processing time, even if it's not hanging. The strings are all contained within the TABLE section. I used ".*?" to get the smallest match because there are several TABLE sections in the HTML document. You're right - re did not hang - after about 5 minutes a got a reply :) However meanwhile I got another working solution for the problem. Thanks, Andreas From petrilli at trump.amber.org Wed Apr 21 21:35:25 1999 From: petrilli at trump.amber.org (Christopher Petrilli) Date: 21 Apr 1999 18:35:25 PDT Subject: How many of us are there? References: <371E2648.DED123AE@callware.com> Message-ID: <7fluct$73g@chronicle.concentric.net> Steven D. Majewski wrote: > "How many of us are there?" > Do you mean counting the elevator boy ? > Is he part of your family ? We are four. But of course there's your family. But they're not traveling with me. Where? :-) Chris -- | Christopher Petrilli ``Television is bubble-gum for | petrilli at amber.org the mind.''-Frank Lloyd Wright From phd at sun.med.ru Mon Apr 5 11:43:26 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Mon, 5 Apr 1999 15:43:26 GMT Subject: Subattributes of classes In-Reply-To: <19990405104408.A807008@vislab.epa.gov> References: <19990405104408.A807008@vislab.epa.gov> Message-ID: On Mon, 5 Apr 1999, Randall Hopper wrote: > class A: > def __init__( self ): > self.attr = 123 > self.attr.subattr = 456 # <--------- Error! > > a = A() > > > This generates an error as I would have expected. [skipped] > Why? Try this: class B: pass class A: def __init__( self ): self.attr = B() self.attr.subattr = 456 a = A() > Randall > > > Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From barmar at bbnplanet.com Thu Apr 22 14:51:01 1999 From: barmar at bbnplanet.com (Barry Margolin) Date: 22 Apr 1999 18:51:01 GMT Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <371F11C2.3162025@ciril.fr> <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk> Message-ID: <7fnr2l$mrt$26@newsread.f.de.uu.net> In article <4fv$ECA+JyH3EwbN at jessikat.demon.co.uk>, Robin Becker wrote: >I take this completely differently; least astonishment for me is if >program X looks and behaves the same way no matter what keyboard, mouse >and screen I'm using. As a 'user' of the program X it shouldn't matter >what OS/WM is executing the code. I certainly don't want vi or emacs to >be different on the mac why should I treat word or excel differently? I would be very surprised if Netscape on the Macintosh presented a Windows-like user interface, rather than adopting the standard Macintosh user interface. Most end users don't switch between platforms much, so it's more important that all the programs on their system conform to their expectations, than that a particular program work the same across different platforms. -- Barry Margolin, barmar at bbnplanet.com GTE Internetworking, Powered by BBN, Burlington, MA *** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups. Please DON'T copy followups to me -- I'll assume it wasn't posted to the group. From Haimo.Zobernig at cern.ch Wed Apr 28 09:57:01 1999 From: Haimo.Zobernig at cern.ch (Haimo G. Zobernig) Date: Wed, 28 Apr 1999 15:57:01 +0200 Subject: 'sourcing' Python scripts? Message-ID: <372713AD.6ABA444@cern.ch> Dear Python experts, this might be a unix rather than a Python problem, but I need to set environment variables from a Python program *in the parent process* that is running the Python script ( a la os.environ['BAR'] = 'foo' ). In other words, I want to achieve the equivalent of 'sourcing' the Python script. Can this be done? Even better would be a solution that also works on the various WinAbominations... (well, NT at least) Haimo G. Zobernig Haimo.Zobernig at cern.ch From fredrik at pythonware.com Thu Apr 22 08:13:39 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Apr 1999 12:13:39 GMT Subject: ``if t'' vs ``if t is not None'' References: <7fn1vb$rbo$1@news.glas.net> Message-ID: <00e601be8cb9$92a7ee30$f29b12c2@pythonware.com> wrote: > i faced a VERY strange behaviour of if-test operation! > > ``if t'' != ``if t is not None'' > where ``t'' is None or a class instance > > i was writing a threader for a news reader. > and found occasional hangs of a routine which builds the sequence of message > numbers for "read next" operation. > digging deeper brought me strange results: replacing ``if t'' with > ``if t is not None'' speeded up the things dramatically! "if t" evaluates "t" by calling it's __nonzero__ or __len__ methods (see http://www.python.org/doc/ref/customization.html for details). "if t is not None" compares t's object identity (a pointer) with the object identity for None (another pointer). in other words, using "is" tests are always faster. how much faster depends on how much work you do in your __len__ (or __nonzero__) method... From nospam at morhp.dircon.co.uk Mon Apr 26 17:53:01 1999 From: nospam at morhp.dircon.co.uk (Pete Jewell) Date: Mon, 26 Apr 1999 22:53:01 +0100 Subject: Project for newbie References: <70alf7.qc6.ln@loopback> <14110.12533.232498.655489@amarok.cnri.reston.va.us> Message-ID: In article , glenn at gacela.demon.co.uk (Glenn Rogers) writes: GR> In article <14110.12533.232498.655489 at amarok.cnri.reston.va.us>, GR> Andrew M. Kuchling wrote: >>Pete Jewell writes: >>>I've read my way through the tutorial, and am now stuck - where do I go >>>from here? I want to learn how to use Python, but don't have any >>>pressing projects at the moment - can anyone suggest a program I should >>>have a go at writing, to help me learn the language further? >> >> Having third parties provide ideas usually doesn't result in >>anything interesting. I have a list of projects on my Web page, but >>they're all extremely unlikely to appeal to anyone who isn't me (and >>even I'm a bit cool on some of them). >> GR> For what it's worth, my first project (5ish months ago) was GR> an internet-utility type thing: opening/closing connection, GR> timing the period online, getting a list of mail waiting for me, GR> telling me when I've stopped getting news etc. GR> My second one was for work doing the same sort of thing over a GR> telnet connection. Then several simple text filtering/ GR> processing utilities, and I'm now doing something that started GR> life as an addressbook (storing in a database) but has now GR> got rather more ambitious. GR> GR> What did everyone else do? GR> GR> I'm still at the tiny scripts stage - this is why I like python :-) - #!/usr/local/bin/python # 'sendnntp.py' v0.0.1 # send the contents of stdin to the nntphost localhost from nntplib import * server = NNTP('localhost') messagepipe = open('/dev/stdin','r') server.post(messagepipe) server.quit() I'm using this in combination with procmail/formail to gate posts to a newsgroup via an email address (strictly controlled). Thanks for the suggestions though :-) -- Pete morph at softhome.net ---------------------------------------------------------------- Linux Registered User # 100652 - Uptime 25 hours, and counting... -- If I can't fix it, it's probably a dead norwegian blue. -- From mwh21 at cam.ac.uk Fri Apr 30 11:11:39 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 Apr 1999 16:11:39 +0100 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <7g9qmo$luf$1@news.udel.edu> <372965CA.2B3FD2FE@appliedbiometrics.com> <19990430080805.B776752@vislab.epa.gov> <3729A9F3.75B2692B@appliedbiometrics.com> Message-ID: Christian Tismer writes: > Randall Hopper wrote: > > > > Christian Tismer: > > |Terry Reedy wrote: > > |> A batch-mode optimizer analyzing an entire file (module) should be able to > > |> detect whether or not function names are rebound. > > |> > > |> Perhaps module bindings should be considered immutable from outside the > > |> module unless explicitly declared otherwise. > > | > > |I'm thinking of no new keyword, but a mechanism which allows me to lock a > > |namespace somehow. > > > > I like this idea in concept. Though I would prefer a way to have > > namespaces "lock by default". Examples: After a class definition, the > > class function dictionary is locked. After a module is fully read, all > > references are bound and the module namespace is locked. etc. > > Well, I wouldn't do that by default. By default, everything > could stay as it is. First of all, this would not break any > existing code. Then, many people will want to > fine tune their modules, and they are perhaps not done > after a class definition was ready. > > Then, what would you do with classes which depend on each > other? You cannot lock them immediately, this would fail. > Locking them after they both are defined is fine, since > everything is defined then. With minimum effort and no > language changes, this will be needed. > > Then think of all the more difficult systems which need > more effort to become configured. The xml parsers together > with SAX are an example. If I wanted to lock this, then > this must be done with care. One would also not lock the mixin > classes, but only the final workhorse class, bound with > the correctly selected parser, and so on. > > It might also be necessary to find a way to specify which > attributes may be locked and which not, since there exist > indeed cases where Python's super-flexibility is needed :-) > > Depending on how exactly will be implemented, a single line > at the end of a module should suffice to accomplish this stuff > for the standard cases. Fine adjustment would take a little more. > As a side effect, locking a module would also find all > referenced but undefined symbols. > > Anyway, this is still no cakewalk and quite a lot of code > is involved. Needs much more thinking... I think I can do this. Not to classes yet, but given a function, I can make you another function where all the global lookups are bound to the values found at that moment. It's used like this: >>> def f(x): ... return x+y ... >>> import closure >>> g=closure.bind(f,y=1) >>> f(1) Traceback (innermost last): File "", line 1, in ? File "", line 2, in f NameError: y >>> g(1) 2 It's then easy to write a function that binds all the variables found in the current environment: def bind_now(func): try: raise "" except: import sys frame=sys.exc_traceback.tb_frame.f_back l=apply(bind,(func,),frame.f_locals) g=apply(bind,(l,),frame.f_globals) return g This gets used like so: >>> import closure >>> y=1 >>> def f(x): ... return x+y ... >>> f(0) 1 >>> g=closure.bind_now (f) >>> y=2 >>> f(0) 2 >>> g(0) 1 >>> Is this what you wanted? A word of warning: this code is nasty, *nasty*, NASTY. Possibly the most horrible thing you will see perpetrated in Python this year. It applies regular expressions to strings of bytecode... I made Python core repeatedly when debugging it. However, it works. The returned functions are very fast. I wrote this package because I wanted to avoid both the tackiness of the `default argument hack' and the performance penalty of using classes to fake closures. As to `sealing' classes in this fashion, I guess it could be done. You'd need to look for patterns of LOAD_FAST 0 (the first argument is the zeroth local) followed by LOAD_ATTR. You could then calculate this and insert a LOAD_CONST instead. The thing is, this would replace two argumented bytecode with one, changing the length of the codestring and you'd need to recompute jumps. I haven't had the bloody-mindedness to get this to work yet. Code follows... HTH Michael import new,string,re def copy_code_with_changes(codeobject, argcount=None, nlocals=None, stacksize=None, flags=None, code=None, consts=None, names=None, varnames=None, filename=None, name=None, firstlineno=None, lnotab=None): if argcount is None: argcount = codeobject.co_argcount if nlocals is None: nlocals = codeobject.co_nlocals if stacksize is None: stacksize = codeobject.co_stacksize if flags is None: flags = codeobject.co_flags if code is None: code = codeobject.co_code if consts is None: consts = codeobject.co_consts if names is None: names = codeobject.co_names if varnames is None: varnames = codeobject.co_varnames if filename is None: filename = codeobject.co_filename if name is None: name = codeobject.co_name if firstlineno is None: firstlineno = codeobject.co_firstlineno if lnotab is None: lnotab = codeobject.co_lnotab return new.code(argcount, nlocals, stacksize, flags, code, consts, names, varnames, filename, name, firstlineno, lnotab) def encode_16(n): return '\\%03o\\%03o'%(n%256,n/256) LOAD_CONST=chr(100) LOAD_GLOBAL=chr(116) def munge_code(code,vars): codestring=code.co_code names=list(code.co_names) consts=list(code.co_consts) for var,value in vars.items(): try: index=names.index(var) except ValueError: continue codestring=re.sub(LOAD_GLOBAL+encode_16(index), LOAD_CONST+encode_16(len(consts)), codestring) consts.append(value) return copy_code_with_changes( code, consts=tuple(consts), code=codestring) def bind(func,**vars): newfunc=new.function( munge_code(func.func_code,vars), func.func_globals, func.func_name) newfunc.__doc__=func.__doc__ newfunc.func_defaults=func.func_defaults newfunc.func_doc=func.func_doc return newfunc def bind_locals(func): try: raise "" except: import sys frame=sys.exc_traceback.tb_frame.f_back l=apply(bind,(func,),frame.f_locals) frame=None return l def bind_now(func): try: raise "" except: import sys frame=sys.exc_traceback.tb_frame.f_back l=apply(bind,(func,),frame.f_locals) g=apply(bind,(l,),frame.f_globals) return g ## examples def make_adder(n): def adder(x): return x+n return bind_locals(adder) def make_balance(initial_amount): def withdraw(amount): if current[0] I want to use httplib through a proxy server and I can't seem to get it to work. Someone in this group suggested setting an environment variable, like: SET http_proxy="12.189.130.200:80" This didn't help. Here is a sample session: Python 1.5.1 (#0, Nov 18 1998, 12:17:58) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import httplib >>> h=httplib.HTTP('www.yahoo.com') Traceback (innermost last): File "", line 1, in ? File "C:\PROGRAM FILES\PYTHON\lib\python1.5\httplib.py", line 51, in __init__ if host: self.connect(host, port) File "C:\PROGRAM FILES\PYTHON\lib\python1.5\httplib.py", line 79, in connect self.sock.connect(host, port) File "", line 1, in connect socket.error: host not found >>> For any given test site, I have no problem with a normal web browser, but I can't get past this error with Python. Am I missing something obvious? Thanks, - Bruce -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From news at dorb.com Mon Apr 5 14:12:04 1999 From: news at dorb.com (Darrell) Date: Mon, 5 Apr 1999 14:12:04 -0400 Subject: swig or not to swig ? References: <4p6O2.1348$8m5.2126@newsr1.twcny.rr.com> Message-ID: As is always the case I found the dl module right after making this post. import imp exposes load_dynamic It doesn't look like a general purpose shared lib interface. So now I'm looking at bgen in the tools directory. Here's a doc string from there. """\ Tools for scanning header files in search of function prototypes. Often, the function prototypes in header files contain enough information to automatically generate (or reverse-engineer) interface specifications from them. The conventions used are very vendor specific, but once you've figured out what they are they are often a great help, and it sure beats manually entering the interface specifications. (These are needed to generate the glue used to access the functions from Python.) In order to make this class useful, almost every component can be overridden. The defaults are (currently) tuned to scanning Apple Macintosh header files, although most Mac specific details are contained in header-specific subclasses. """ Darrell wrote in message news:4p6O2.1348$8m5.2126 at newsr1.twcny.rr.com... > Coding a 'C' interface to python seems straight forward. Is swig worth the > trouble ? > > I want to access some shared libs. I tried the dl module which isn't obvious > how it works. import dl fails. > > > > From brunomadv at ciudad.com.ar Wed Apr 21 10:29:05 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Wed, 21 Apr 1999 14:29:05 GMT Subject: permissions on win32 [Q] In-Reply-To: <7fk8r0$7ng$1@m2.c2.telstra-mm.net.au> References: <7fk8r0$7ng$1@m2.c2.telstra-mm.net.au> Message-ID: <002401be8c03$4f21d380$6eba0ac8@kuarajy.infosys.com.ar> Thanks Mark... All this is supposed to run on sunday and it's Mission Critical, so I presume wiill be doing it by hand, but anyway thanks. I am looking forward to be able to do this on NT... :-) FYI we will be running another mission critical process on Sunday and it will be a small Python app that will run on NT ... I love Python ... :-) Cheers, /B Bruno Mattarollo ... proud to be a PSA member > -----Original Message----- > From: python-list-request at cwi.nl [mailto:python-list-request at cwi.nl]On > Behalf Of Mark Hammond > Sent: Wednesday, April 21, 1999 7:22 AM > To: python-list at cwi.nl > Subject: Re: permissions on win32 [Q] > > > NT security is a bit of a black art. Build 124 has > win32security.SetFileSecurity(). > > The next question will be how to create a security descriptor - > here is some > sample code. > > [Oh damn - just realised that pywintypes.SECURITY_DESCRIPTOR() doesnt > actually exist in 124 - it will in 125. sorry - you will > probably get stuck > here... But Ill still post it as reference for build 125 and later] > > Mark. > > def CreateSD(userName): > sd = pywintypes.SECURITY_DESCRIPTOR() > > sidUser = win32security.LookupAccountName(None,userName)[0] > sidCreator = pywintypes.SID() > sidCreator.Initialize(ntsecuritycon.SECURITY_CREATOR_SID_AUTHORITY,1) > sidCreator.SetSubAuthority(0, ntsecuritycon.SECURITY_CREATOR_OWNER_RID) > > acl = pywintypes.ACL() > acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidUser) > acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidCreator) > > sd.SetSecurityDescriptorDacl(1, acl, 0) > return sd > > Bruno Mattarollo wrote in message > <001201be8ba6$f2f706e0$6eba0ac8 at kuarajy.infosys.com.ar>... > >Hi! > > > > I have to do a little script for a customer that will copy files from an > NT > >server to another. I need to change the permissions on those files and > >directories. I mean, I need to give privileges to groups like > >Administrators, the user that owns the files (changes from file to file) > and > >other special groups. Anyone knows how to do this with Python? > We have the > >following env: NT4SP4, Python 1.5.1, Win32All 124 ... the lastest one. I > >have already done the script that copies the files, I just need > to know how > >to set this permissions. > > > > TIA > > > >/B > > > >Bruno Mattarollo > >... proud to be a PSA member > > > > > From fatjim at home.com Mon Apr 12 11:59:05 1999 From: fatjim at home.com (Jim Meier) Date: Mon, 12 Apr 1999 15:59:05 GMT Subject: ConfigParser module and alternatives (flad, flan) References: <19990331160323.21601.00000471@ng-fi1.aol.com> <7du3ab$3ag@chronicle.concentric.net> Message-ID: <371219E9.9EA91839@home.com> Mike Orr wrote: > I'm not sure if I'll use ConfigParser for the next version. I don't > really need the sections (multiple files work just fine, using the filename > for the section name), and I haven't found a use for the the %(other_key)s > substitutions. On the other hand, it doesn't handle multiple values (the > same key repeated within a record), which I sometimes need. > > Attached is a wrapper class for ConfigParser which supports booleans > and can also return an entire section as a dictionary (or all the sections > as nested dictionaries). I find these make it a little more convenient. > Why not simply use a file of python expressions? Like this: {'section1': { 'key1':[1,2,3,'value',['useful','nesting','eh?']], 'key2':'anotherval' }, 'section2': { 'subsection':{ 'subkey':5 } } } I beleive you can even use variable names in such files for application-specified substitutions, like this: (python app defines variable "rootdir") {'pathssection': { 'fontpath': rootdir+'/font/' } } This introduces some major security problems, and is a little difficult to edit, but there is very little parsing needed to make it usable. Does anyone know of a way to limit the damage a user can do to such a file? Another idea is to run your config file through a simple macro utility (or do the macro conversion in python itself) to convert it into python code to eval. Jim Meier From just at letterror.com Fri Apr 16 08:35:10 1999 From: just at letterror.com (Just van Rossum) Date: Fri, 16 Apr 1999 12:35:10 GMT Subject: binary In-Reply-To: <37171BD5.87CFA015@efes.net.tr> References: <37171BD5.87CFA015@efes.net.tr> Message-ID: At 2:15 PM +0300 4/16/99, Murat Yeneroglu wrote: >Hi, >I want to ask that how I can convert a decimal number to binary in >python ? >THNX Take a look at the "struct" module. Just From claird at Starbase.NeoSoft.COM Mon Apr 5 23:06:09 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 5 Apr 1999 22:06:09 -0500 Subject: SNMPy update References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> Message-ID: <7ebtn1$dq$1@Starbase.NeoSoft.COM> In article <14089.11820.416453.80124 at bitdiddle.cnri.reston.va.us>, Jeremy Hylton wrote: . . . >encode/decode and on how to build a backend for SNACC. (A free-ish >ASN.1 compiler; the only one?) Hardly. There are several ASN.1 compilers. MAVROS is another. I know of none that's achieved SNACC's portability. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From kuncej at mail.conservation.state.mo.us Tue Apr 27 11:24:01 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Tue, 27 Apr 1999 15:24:01 GMT Subject: python and SOCKS firewall Message-ID: I just found a way to get python on a Windows machine to talk through a SOCKS firewall. There is a program called SocksCap (http://www.socks.nec.com/sockscap.html) that "socksifies" windows TCP and UDP applications. You launch the tcp app with SocksCap, and SocksCap intercepts tcp and udp calls, and redirects them through the socks server. As far as I can tell, python launched with SocksCap is talking fine through the socks firewall at my location. --Jeff PS SocksCap is free for non-commercial and internal-business use. From wtanksle at dolphin.openprojects.net Thu Apr 29 19:22:51 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 29 Apr 1999 23:22:51 GMT Subject: Errors References: <3728CD26.907ED9A1@geocities.com> Message-ID: On Thu, 29 Apr 1999 21:16:50 GMT, smoothasice at geocities.com wrote: >Ok I have been using python and I have noticed that the errors aren't >truly helpful.. I don't know if I just didn't learn this properly but I >dont' know why this generates an error: The errors could certainly be improved, couldn't they? >for word in All_Words: > z = 0 > while z < len(word): > if z == 0: > tally = tally + alpha.index(word[z]) > else: > tally = tally + (alpha.index(word[z]) * 26) >It gives me this: NameError: tally >and I don't know why...... This one's not too hard -- look at 'tally'. What is its starting value? You're trying to use a variable which has no value. Try setting it to zero somewhere. >Anton -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From neilh at fast.fujitsu.com.au Mon Apr 12 05:11:18 1999 From: neilh at fast.fujitsu.com.au (Neil Hodgson) Date: Mon, 12 Apr 1999 19:11:18 +1000 Subject: OrderedDict.py References: Message-ID: <3711B8B6.9F0D55C7@fast.fujitsu.com.au> evil Japh (or possibly his good twin Jeff Pinyan) wrote: > Is there a need for a module which allows for ordered processing of an > dictionary? I think there is a need for this. There is a bit of code I wrote for PythonWin where some values are displayed in a UI and then read back in after user modification. It did not matter what order the dictionary was displayed in so long as it could be read back in in the same order to match up. Nothing in the documentation specifies that asking for the elements (or keys) of a dictionary returns elements (or keys) in the same order each time, even if no modifications are done to the dictionary between accesses. Therefore, each time the dictionary was used, there was a sequence like: sortedkeys = formats.keys() sortedkeys.sort() for f in sortedkeys: Your module may have made this code easier and also clearer. Neil Hodgson Fujitsu Australia Software Technology From lutz at rmi.net Fri Apr 30 17:15:29 1999 From: lutz at rmi.net (Mark Lutz) Date: Fri, 30 Apr 1999 15:15:29 -0600 (MDT) Subject: Rat sited on Amazon Message-ID: <199904302115.PAA03581@shell.rmi.net> Jeff Bauer wrote (about Learning Python): > Hey everyone.? Check out what's featured on Amazon today > under "Computers and Internet". It gets a little better: the book (and Python) made amazon.com's home page today. It showed up in a paragraph titled "Mighty Python", along with Sarah McLachlan's new CD. Cheers, --Mark Lutz (http://rmi.net/~lutz) From claird at Starbase.NeoSoft.COM Mon Apr 26 05:05:21 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 26 Apr 1999 04:05:21 -0500 Subject: GUI other than Tkinter References: <3721567f.1748033@news> Message-ID: <7g1a8h$fae$1@Starbase.NeoSoft.COM> In article <3721567f.1748033 at news>, wrote: >Well, I've just about given up on EVER getting Tkinter to work on my >Win98 machine. Is there any other GUI module that I can get that >doesn't require TCL/TK to be installed on my machine? Isn't there . . . -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From mal at lemburg.com Wed Apr 7 19:04:46 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 7 Apr 1999 23:04:46 GMT Subject: OpenSSL/X.509 References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <3709C8BE.4257C9F1@lemburg.com> <14090.16807.950025.496495@bitdiddle.cnri.reston.va.us> <370A78B6.2C18D10F@lockstar.com> Message-ID: <370BE48E.2BA9750C@lemburg.com> Mordy Ovits wrote: > > Jeremy Hylton wrote: > > > > >>>>> "MAL" == M -A Lemburg writes: > > [SNIP] > > > MAL> Note that I have a project running with the intention to wrap > > MAL> OpenSSL in an OO manner called mxCrypto (see the link below). > > > > Looking forward to seeing it. When do you think you might have an > > alpha release ready? > > > > Jeremy > > I have a fairly complete SWIGing of OpenSSL/SSleay working. I made it on > company time, so I have to get company permission to release it. If there is > real interest, I'll push for us to release it. It does all the X.509 stuff, is > very OO, and builds on win32 and unices. > Interested? Sure, but if your company is US based, then chances are high you won't be able to share the code outside the US... that's why I started mxCrypto, BTW. -- Marc-Andre Lemburg Y2000: 268 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From jbauer at rubic.com Mon Apr 26 08:44:28 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Mon, 26 Apr 1999 12:44:28 GMT Subject: precompiled MySQL.pyd anyone ? (NT workstation) References: <7fsu50$bss$1@nnrp1.dejanews.com> <372413EE.A2DE88C8@esoc.esa.de> Message-ID: <37245FAC.8A4719C6@rubic.com> Nigel Head wrote: > I too have moved away from MySQL at the moment > so I don't have any newer version than Jeff. In > fact, Jeff probably has the only version as I seem > to have misplaced my copies :-( True confession time. I have MySQL.pyd and libmySQL.dll compiled -- based on Nigel's code -- but I haven't used them much. They appear to work, however. Other people have reported success. I've placed both binaries on the starship: ftp://starship.python.net/pub/crew/jbauer/MySQL.pyd ftp://starship.python.net/pub/crew/jbauer/libmySQL.dll If anyone has problems obtaining these via anon ftp, please contact me or post your queries on this newsgroup. Best regards, Jeff Bauer Rubicon, Inc. From bwizard at bga.com Sun Apr 25 21:15:32 1999 From: bwizard at bga.com (Purple) Date: Mon, 26 Apr 1999 01:15:32 GMT Subject: Handling backspace chars in a string... References: <37239c48.594910176@news2.bga.com> <000301be8f7e$16b89780$669e2299@tim> Message-ID: <3723bd8c.603427371@news2.bga.com> On Mon, 26 Apr 1999 00:45:32 GMT, "Tim Peters" wrote: >[Purple] >> I'm in the poistion of having to process strings with arbitrary >> numbers of backspace and newline characters in them. > >Your code doesn't appear to care about newlines one way or t'other. Do you >? I didn't post the code for that bit as it seems easy enough to take care of processing those with something like map(string.strip,string.split(stringWithNewlines,"\n") Unless there's a better way to do that too? :) >> The backspaces actually get put in the string, so I have to handle >> removing the characters that are backspaced over. >> ... [rather sprawling string + indexing code] ... >> This just looked rather messy to me -- I was curious if anyone know a >> better way? > >Assuming "better" means "less messy" here, lists support appending and >deleting quite naturally and efficiently; like > [code using lists snipped] >This essentially treats the input string as a sequence of opcodes for a >stack machine, where "\b" means "pop" and anything else means "push me!". > >don't-use-any-indices-and-you-can't-screw-'em-up-ly y'rs - tim I may well go that route... Is it any slower or faster to do this using lists rather than counting up the backspaces and slicing around the bits that need to be snipped? From kmiller at castle.cudenver.edu Sun Apr 11 04:38:42 1999 From: kmiller at castle.cudenver.edu (N Yocom) Date: Sun, 11 Apr 1999 01:38:42 -0700 Subject: Graduate Student Research Survey Message-ID: <7eqtkq$qpl$1@news.cudenver.edu> Greetings, We are a small group of graduate students at the University of Colorado at Denver who intend to study specific characteristics of online buying behavior. We have composed a survey to address our questions at http://www.cudenver.edu/~mparthas/survey.htm. This survey should not take more than five minutes of your time. You are assured complete confidentiality. Never will any respondent be identified to any third parties, nor will you ever be contacted by anyone regarding your input. Thank you for your time. If you are interested in the results please mailto: kmiller at castle.cudenver.edu Sincerely, Karl Miller Noelle Yocom Maria Morris Assaro From john.michelsen at gte.net Sat Apr 10 14:39:13 1999 From: john.michelsen at gte.net (John Michelsen) Date: Sat, 10 Apr 1999 11:39:13 -0700 Subject: Multiple Document Interface on Unix, Mac Message-ID: <7eo48q$2r2$1@news-1.news.gte.net> Hi all, I put a Multiple Document Interface script (MDI.py) at http://www2.zyvex.com/OpenChem/Widgets0.1.zip. I was wondering if anyone could send me a gif of what it looks like on Unix or Mac so that I could do some system specific code for the button icons. Thanks, John From news at dorb.com Thu Apr 29 16:02:25 1999 From: news at dorb.com (Darrell) Date: Thu, 29 Apr 1999 16:02:25 -0400 Subject: Read MS Access 97 *.mdb files with python?? References: <37287369.D6E67313@t-online.de> <3728867D.94B5BBF9@appliedbiometrics.com> <3728A903.CF75B41A@pop.vet.uu.nl> <3728B7DF.80E23481@t-online.de> Message-ID: I'm no expert but... Put some data base package on your Linux machine that supports ODBC. I would think that with lots of luck Access running on the Win boxes could connect to it. --Darrell gemodek wrote in message news:3728B7DF.80E23481 at t-online.de... > Martijn Faassen wrote: > > > > Christian Tismer wrote: > > > > > > gemodek wrote: > > > > > > > > Does somebody know some > > > > piece of soft which can this?? > > > > ... > ... > > > > Unfortunately, all this advice may be useless, as I noticed that he's > > the same guy who asked about accessing an Access database on Linux. I > > know Linux can do ODBC, but I doubt there are Access drivers for ODBC on > > linux.. > > > > First: Thanks for the fast response :-) > > But,.. yes I am the guy who asked about accessing Access database on > Linux. > My idea is the following: > At my company we are running 4 Win95 PC's on a network which works > sometimes > and crash sometimes (some days no reboot, some days 5-10 times). > Now I am tired of the whole Win stuff, and I will install an Linux > Server > with Samba. (OK, the clients are still Win95, but at least the server is > linux). > We use also a software which is based on Access. The whole database (mdb > files) will reside on the Linux server. > So far so good. > But now, I want to extract some information out of the access database > to > create html files which everybody in our company is alowed to view. > And for this I need "access to Access". > > Thats the whole story. I'm searching also for a format description > of access, but I did not find anything (up to now!). > > bye > > Stephan From janssen at parc.xerox.com Fri Apr 16 21:28:04 1999 From: janssen at parc.xerox.com (Bill Janssen) Date: Sat, 17 Apr 1999 01:28:04 GMT Subject: #!/usr/bin/env python -u In-Reply-To: <37175574.25EBDDBE@stuco.uni-klu.ac.at> References: <37175574.25EBDDBE@stuco.uni-klu.ac.at> Message-ID: Martin, I'm not a big fan of the /usr/bin/env approach for Python scripts, because at PARC many people run without having Python on their paths. Many, many packages at PARC, including Python and ILU, are installed in their own directory tree under either /project (/project/ILU/) or /import (/import/python-1.5/). People enable or disable various packages depending on what they're up to. So I tend to depend on GNU configure when I'm installing a script. I actually look for Python in the user's environment, then use sed to hard-code that path into the scripts before installing them. Can this be done with RPM? Bill From ppessi at hut.fi Mon Apr 19 10:34:46 1999 From: ppessi at hut.fi (Pekka Pessi) Date: 19 Apr 1999 17:34:46 +0300 Subject: what is reloc error ? References: <371A1E26.846AF8B6@pk.highway.ne.jp> Message-ID: Thooney Millennier writes: >I am now working on building Python interface >to my C++ matrix library. >I have a problem. >After compiling and when trying to import my >module >I get following message. > % gcc -c XXXtype.cc You are compiling position independent code, so use -fPIC flag. > % gcc -c subXXXtype.cc > ....................... > % ld -o XXXtype.so -dy -G -g *.o -lstdc++ What about gcc -o XXXtype.so *.o -shared -g -lstdc++? > % python -c "import XXXtype" > python: can't handle reloc type ><====this!!! >I don't understand why this occurs. >Please help me! >(Platform: python 1.5.2, Linux 2.0.34 with gcc.) The best way to do compile modules is to write a Setup file and let Python to create the Makefile by itself. For details, see Demo/extend in the Python source distribution. Pekka -- Pekka.Pessi at hut.fi From tim_one at email.msn.com Sat Apr 3 00:29:16 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 3 Apr 1999 05:29:16 GMT Subject: string.join() vs % and + operators In-Reply-To: <37054490.E79ADCC9@easystreet.com> References: <37054490.E79ADCC9@easystreet.com> Message-ID: <000001be7d92$ea8da080$879e2299@tim> [Al Christians] > Whereas Python's strings are immutable, there is potentially a strong > incentive to get them right the first time. Not really much more than in a language with mutable strings -- if you overwrite substrings in one of the latter, it's going to be s-l-o-w when the length changes. OTOH, if your fields are 50's-style fixed-width , a Python character array (array.array('c')) makes a fine mutable string. > In my applications, I want to create strings that have many fields > within them. I assume that it would be nice to be able to modify > the fields without creating a new string any time its contents get > changed, but I don't think that Python gives any nice way to do this. Maybe see above? I'm not sure what you mean. Is there any language that *does* give you "a nice way to do this", keeping in mind that you're worried about efficiency too? E.g., use "substr" on the left-hand side of a Perl string assignment, and under the covers it's going to copy the whole thing -- even if the length doesn't change: $a = "gold you so"; $b = $a; substr($a, 0, 1) = "t"; print "$a\n$b\n"; prints told you so gold you so You can do better than this in Python as-is, although you need a little more typing: import array a = array.array('c', "gold you so") b = a a[0] = "t" print a.tostring() print b.tostring() In return for letting you change a[0] in-place, this prints "told you so" twice. > So, I'm stuck with building the string from many little pieces. Think of it instead as an opportunity to excel . > The 'many' part of this gives me some worry about efficiency, which it > is better not to worry about, so I did a brief test to see if there is > ugly downside to this. I ran the following script: [tries a long "%s%s%s..." format, string.join, and repeated catenation; discovers the 2nd is fastest, the first 2nd-fastest, and third much slower ] > ... > Way 3, the way that one would expect to be bad, recreating the string > with each concatenation, was much slower, but only took about 1 minute. > Surprisingly swift as well. It can be very much worse, of course -- it's a quadratic-time approach, and you're helped here in that the final length of your string is only a few hundred characters. > Anybody have anything to add to this? Maybe the array module; maybe not. > Are there any related pitfalls that I may have missed? Not if you stick to string.join -- it's reliably good at this. I'll attach a rewrite of your timing harness that avoids the common Python timing pitfalls, and adds a fourth method showing that array.tostring() blows everything else out of the water. But then doing a length-changing slice assignment to a character array is like doing a length-changing assignment to a Python list: under the covers, everything "to the right" is shifted left or right as needed to keep the array contiguous; mutability can be expensive in under-the-cover ways. pay-now-pay-later-or-pay-all-the-time-ly y'rs - tim import string N = 100 S = [] for i in range(N): S.append(`i`) F = "%s" * N # for method 4 (character array) import array SARRAY = array.array('c') for i in S: SARRAY.fromstring(i) # if time.clock has good enough resolution (it does under Windows), # no point to looping more often than this indices = range(10000) def f1(s=S, f=F): for i in indices: z = f % tuple(s) return z def f2(s=S, join=string.join): for i in indices: z = join(s, '') return z def f3(s=S): for i in indices: z = '' for j in s: z = z + j return z def f4(s=SARRAY): for i in indices: z = s.tostring() return z def timeit(f): from time import clock start = clock() result = f() finish = clock() print f.__name__, round(finish - start, 2) return result z1 = timeit(f1) z2 = timeit(f2) z3 = timeit(f3) z4 = timeit(f4) assert z1 == z2 == z3 == z4 From mwh21 at cam.ac.uk Fri Apr 23 06:03:07 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 23 Apr 1999 11:03:07 +0100 Subject: sort of multiple dictonaries References: <371F28CA.2240BB7B@phoenix-edv.netzservice.de> Message-ID: Holger Jannsen writes: > Hi there, > > perhaps a typical newbie-question: > > I've got a list of dictonaries like that: > > mydics=[{'sortit': 'no412', 'mode': 'nothing'}, > {'sortit': 'no112', 'mode': 'something'}, > {'sortit': 'no02', 'mode': 'something else'}] > > Is there an easy way to get that list sorted like that: > > def sortDictonary(aDictonary, theSortKey="sortit"): > .... > > Result have to be: > > mydics=[{'sortit': 'no02', 'mode': 'something else'}, > {'sortit': 'no112', 'mode': 'something'}, > {'sortit': 'no412', 'mode': 'nothing'}] > > Any hints? Well, it's actually a list you're sorting isn't it? mydics.sort(lambda x,y:cmp(x['sortit'],y['sortit'])) should work, if I understand the problem. HTH Michael > Ciao, > Holger From brunomadv at ciudad.com.ar Thu Apr 15 20:03:22 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Fri, 16 Apr 1999 00:03:22 GMT Subject: restore sources from PYC [Q] Message-ID: <000101be879c$8aed0670$6eba0ac8@kuarajy.infosys.com.ar> Hi! By mistake I am unable to find the PY files (source) from a project I was working on. I only have the PYC files... Is there a way to recover the sources from the PYC? I only need my sources, I don't give a d... for the comments... TIA /B Bruno Mattarollo ... proud to be a PSA member From robin at jessikat.demon.co.uk Thu Apr 22 09:22:06 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 22 Apr 1999 14:22:06 +0100 Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <371F11C2.3162025@ciril.fr> Message-ID: <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk> In article <371F11C2.3162025 at ciril.fr>, Frederic BONNET writes >Hi, > >Eugene Dragoev wrote: >[...] >> But I also found that while older versions of Tk were using lightweight ... >> Is there going to be any Tk implementation that will continue using >> lightweight components? > >By lightweight I guess you mean emulated in some way. I don't think that >cross-platform look&feel consistency is a good thing. As a GUI designer >I'd rather follow the principle of least astonishment: an app running on >Windows should look and feel like a Windows app. The same app running on >MacOS and X should do the same on the respective platforms. Such a >cross-platform application is not supposed to look and feel the same on >all platforms. If users want to use the same app on several platforms, ... I take this completely differently; least astonishment for me is if program X looks and behaves the same way no matter what keyboard, mouse and screen I'm using. As a 'user' of the program X it shouldn't matter what OS/WM is executing the code. I certainly don't want vi or emacs to be different on the mac why should I treat word or excel differently? Another reason for having a Tk look and feel is that it allows widget behaviours different from those allowed by the underlying 'convention'. Of course those with an interest in the survival of rigid wm systems prefer we should adhere to their conventions. The only changes then come from the suppler of such systems and are introduced to make us by new versions etc. Competition between different WM's is currently almost impossible because of the original model ie the 'toplevel' is controlled and decorated by the WM. We don't have to do that with the widgets inside the 'toplevel' so why do we? Let 100 flowers bloom etc. ... >And I don't speak about look differences. > >See you, Fred -- Robin Becker From ajung at sz-sb.de Sat Apr 17 09:59:07 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Sat, 17 Apr 1999 13:59:07 GMT Subject: re.sub() loops Message-ID: I am trying to do some lame HTML processing with some HTML. The following lines tries to remove some unneccessary code from a HTML file. However python hangs in this call: data = re.sub('','',data) Any idea why ? My env: Python 1.5.2 under Solaris 2.5.1 - 7.0. Andreas From spamfranke at bigfoot.de Sat Apr 17 11:30:26 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Sat, 17 Apr 1999 15:30:26 GMT Subject: sys.path.insert - how to make it global? References: <19990416172011.A1551755@vislab.epa.gov> Message-ID: <3718a8aa.4229211@news.omnilink.de> On Fri, 16 Apr 1999 21:20:11 GMT, Randall Hopper wrote: > If I want to augment my Python module search path inside a Python >script (so that it affects itself and imported modules), what's the best >way to do this? > >Randall sys.path *is* already global, though only accessible via the sys module's namespace. Just give it a try. Stefan From quinn at necro.ugcs.caltech.edu Sat Apr 24 02:42:59 1999 From: quinn at necro.ugcs.caltech.edu (Quinn Dunkan) Date: 24 Apr 1999 06:42:59 GMT Subject: package.module != module Message-ID: I have discovered that apparently python's mechanism for discovering if a module has already been imported fails when you import a "fully qualified" package previously imported as a sister. i.e.: client.py ("import package.sister") package/ __init__.py sister.py ("class B: pass") publish.py (""" import sys sys.path.append('..') import sister, client print repr(sister.B), repr(client.package.sister.B) print sys.modules.keys() """) We find that sister.B and client.package.sister.B are different classes. The reason why appears to be sys.modules: we have both 'package.sister' and 'sister' imported as seperate modules. I get this convoluted structure all the time in ZPublisher (Zope), and when I want to talk about a class defined in a package from a module run by that package, nothing works because the package has different versions of the same classes I'm talking about in my modules. You can't catch exceptions defined in the package and thrown from a client module. Feature? Quirk? Workaround? Help! :) thanks! From gmcm at hypernet.com Fri Apr 30 23:05:03 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 1 May 1999 03:05:03 GMT Subject: Read MS Access 97 *.mdb files with python?? In-Reply-To: References: Message-ID: <1286594377-79529701@hypernet.com> Quinn Dunkan wrote: > ... I have databases in > Access. Currently, they are converted to cvs and read into mysql, > which then serves them to python via iODBC + mxODBC. Of course, I > would much rather have Access talk to mysql directly and be just a > front-end for mysql, and the iODBC stuff seems to imply this can be > done... But I still can't figure out how to get Access to do > this... Anyone have a similar setup? It's been years since I did this, but as I recall, you set up a "System DSN" from Control Panel | ODBC for the remote DB. Then, in Access, you use File | External Data | Link Tables and point to the System DSN you just configured. I think this requires a "dummy" Access mdb. There may be other ways to do it, but this is what looks familiar as I poke around in Access's menus. - Gordon From david_ascher at yahoo.com Sat Apr 3 12:00:11 1999 From: david_ascher at yahoo.com (David Ascher) Date: Sat, 3 Apr 1999 17:00:11 GMT Subject: Rat sighting online Message-ID: <19990403170011.21264.rocketmail@web602.mail.yahoo.com> --- Darrell wrote: > I don't knowing much about Java so I tried the > Jpython example and got > stuck. It imports pickle which imports struct. > Jpython doesn't seem to have > struct ? The example was tested with JPython 1.1a3, which I believe has the struct module. I don't have access to JPython right now, but I believe you can get the example to work by creating a struct.py file which just defines empty functions for the functions which pickle imports (I believe, just pack and unpack). Something like: def pack(*args, **kw): pass unpack = pack --david ascher PS: It's surprising that the book came out before the software -- I believe it's mostly because the JPython folks are working out a new license agreement for easier distribution. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From aahz at netcom.com Tue Apr 27 19:17:23 1999 From: aahz at netcom.com (Aahz Maruch) Date: Tue, 27 Apr 1999 23:17:23 GMT Subject: try vs. has_key() References: <7g51q6$1pt$1@vvs.superst.iae.nl> Message-ID: In article <7g51q6$1pt$1 at vvs.superst.iae.nl>, Carel Fellinger wrote: >In article you wrote: >> >> d={} >> for word in words: >> first_two=word[:2] >> d[first_two]=d.get(first_two, []).append(word) > >this is the statement where i get lost. and when i try it with python 1.5.1 >it doesn't work either. As far as i understand the append function it doesn't >return anything as it is just a shorthand for an assignment which to my >knowledge even in python 1.5.2 doesn't return values. or am i missing >something here? nonetheless, it looks great, and i sure hope it works too. It appears that the second parameter for get() (to specify a value different from None when the key is not found) is new to 1.5.2. In 1.5.1 you still have to do the following: d={} for word in words: first_two=word[:2] if d.get(first_two) is None : d[first_two]=[word] else : d[first_two].append(word) (I think, without testing the code) -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Hi! I'm a beta for SigVirus 2000! Copy me into your .sigfile! From brunomadv at ciudad.com.ar Sun Apr 11 15:49:50 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Sun, 11 Apr 1999 19:49:50 GMT Subject: best way to copy a file [ANSWER] In-Reply-To: <199904111935.VAA24485@axil.hvision.nl> References: <199904111935.VAA24485@axil.hvision.nl> Message-ID: <000801be8454$7608f390$6eba0ac8@kuarajy.infosys.com.ar> Thanks Hans. It worked... I didn't used the 'rb' and 'wb' when opening the files... I should stop working on sundays ... :-) Well, I should stop working everyday ;) /B Bruno Mattarollo ... proud to be a PSA member > -----Original Message----- > From: Hans Nowak [mailto:ivnowa at hvision.nl] > Sent: Sunday, April 11, 1999 5:37 PM > To: Bruno Mattarollo; python-list at cwi.nl > Subject: Re: best way to copy a file [Q] > > > On 11 Apr 99, Ce'Nedra took her magical amulet and heard Bruno > Mattarollo say: > > >Hi! > > > > I need to copy a file (can be binary or ascii) from one > path to another. I > >have tryied to do: > > line = fd.readline() > > while line: > > fd2.write(line) > > line = fd.readline() > > fd.close() > > fd2.close() > > > > It only works for ascii files ... How can I do a 'copy' > ...? I need to run > >this on NT ...:( And I don't want to open a shell to do a copy from > >there... I also tryied fd.read() ... No success neither. > > Sure can: > > fin = open("myfile", "rb") # notice the 'rb' > fout = open("target", "wb") # ...and the 'wb' > data = fin.read(1000) # or any amount of bytes you want to read > while data: > fout.write(data) > data = fin.read(1000) > fin.close() > fout.close() > > This should work. For large files, a larger number than 1000 may be > desirable. > > + Hans Nowak (Zephyr Falcon) > + Homepage (under construction): http://www.cuci.nl/~hnowak/ > + You call me a masterless man. You are wrong. I am my own master. > + May a plumber throw eggs at your dead presidents! > From bwarsaw at cnri.reston.va.us Tue Apr 13 13:06:54 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: 13 Apr 1999 13:06:54 -0400 Subject: hey advocates References: <7etg59$6mt$1@nnrp1.dejanews.com> <003f01be852e$a0125b60$0301a8c0@cbd.net.au> Message-ID: <61btgse9g1.fsf@anthem.cnri.reston.va.us> >>>>> "MN" == Mark Nottingham writes: MN> I had a program that I wrote in Perl and had no problem MN> getting into cgi-resources. Then, when I rewrote it in Python MN> and released it (while still making the original available; MN> different uses), he wouldn't create a category for Python, and MN> he wouldn't even put it somewhere else. Grrr... Well, I just sent him a comment requesting addition of a Python category. We'll see. Y'all should make the same request! -Barry From news at dorb.com Mon Apr 5 14:38:40 1999 From: news at dorb.com (Darrell) Date: Mon, 5 Apr 1999 14:38:40 -0400 Subject: swig or not to swig ? References: <4p6O2.1348$8m5.2126@newsr1.twcny.rr.com> Message-ID: Didn't have much luck with bgen. modulator seems handy, Is there a reason to prefer swig ? Darrell wrote in message news:kZ6O2.1351$8m5.2222 at newsr1.twcny.rr.com... > As is always the case I found the dl module right after making this post. > import imp exposes load_dynamic > > It doesn't look like a general purpose shared lib interface. > So now I'm looking at bgen in the tools directory. > > Here's a doc string from there. > """\ > > Tools for scanning header files in search of function prototypes. > > Often, the function prototypes in header files contain enough information > to automatically generate (or reverse-engineer) interface specifications > from them. The conventions used are very vendor specific, but once you've > figured out what they are they are often a great help, and it sure beats > manually entering the interface specifications. (These are needed to > generate > the glue used to access the functions from Python.) > > In order to make this class useful, almost every component can be > overridden. > The defaults are (currently) tuned to scanning Apple Macintosh header files, > although most Mac specific details are contained in header-specific > subclasses. From clarence at silcom.com Wed Apr 14 11:11:15 1999 From: clarence at silcom.com (Clarence Gardner) Date: Wed, 14 Apr 1999 15:11:15 GMT Subject: forking + stdout = confusion References: <87n20caldg.fsf@spock.localnet.de> Message-ID: Roy Smith (roy at popmail.med.nyu.edu) wrote: : Carsten Schabacker wrote: : > No, the child and the parent share the SAME filedescriptors. This is true : > for ALL open files! So if you don't need the descriptors in a child or a : > parent you should close them. : > : > Apache waits for the end of the file, so all processes (parents and : > childs) must close the file! Carsten: Please take this constructively :) I am aware of the fd sharing, and the code I posted clearly closed stdin, stdout, and stderr in both the parent and child processes. Also, in case you're not aware of it, the distinguishing feature of a nph-type CGI program is that its output does not go through the web server. : : When doing a similar thing a while ago, I had similar problems :-) I : eventually found that in addition to doing sys.stdout.close(), I had to do : os.close(1) to make sure the fd really got closed. : : I'm still not sure I understand what was going on. I know that : sys.__stdout__ contains a copy of sys.stdout, so at first I figured that : doing both sys.stdout.close() and sys.__stdout__.close() would do the : trick, but it didn't, but os.close(1) did. That does indeed do the trick, but you probably had to os.close(2) also. (Both stdout and stderr normally are piped into Apache.) However, your first thought also works, with the same caveat about stderr. stdin, stdout, and stderr all have the __xxx__ copy in the sys module (which I was not aware of). So it was a Python issue after all! Removes any tinge of guilt I had about posting it here :) -- -=-=-=-=-=-=-=-= Clarence Gardner AvTel Communications Software Products and Services Division clarence at avtel.com From warlock at eskimo.com Sun Apr 4 13:45:54 1999 From: warlock at eskimo.com (Jim Richardson) Date: 4 Apr 1999 17:45:54 GMT Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <37009C12.4C0E6B0B@earth.ox.ac.uk> <922837384snz@vision25.demon.co.uk> <7dtbu1$rpn$1@nnrp1.dejanews.com> <37025110.1BA742B@appliedbiometrics.com> Message-ID: On Wed, 31 Mar 1999 16:45:04 GMT, Christian Tismer, in the persona of , brought forth the following words...: > > >aaron_watters at my-dejanews.com wrote: >> >> > > K&R is one of the best programming books I have read. A Python equivalent >> > > would be nice. >> >> I think the Python equivalent are Guido's tutorial and reference >> manual. He did such a good job that all other books had to add >> a lot more stuff in order to not be totally redundant. Note that >> there is no K&R equivalent of the library ref unless you consider >> Unix man pages [3]. >> >> Sorry you can't get them in bound form and put them on your shelf. >> -- Aaron Watters > >Well, isn't that an idea? >If somebody (which needn't be Guido himself) just takes >the standard documentation, does some touch-up of the layout, >and turns it into a printable book? > >The "GvR Official Python Library and Reference Book" would appear >with every new release of Python. I could imagine this would >sell good, for Guido and the publisher. >At least I would love to have that on my desk, hard-covered >and bound, not just in electronic form or printed by myself. > >ciao - chris I used mpage to condense them down to 2 pages per 8x11 sheet, and then printed odd/even, cycled the paper throgh the laser printer twice, bound them with those little springy plastic spiral things, and viola, a 5x8, Reference with the tutorial, the api, &etc all at once. Took something a little over 100 pages. I would have printed 4 to a page but I couldn't figure how to make mpage do the registering properly for 2 stage double sided printing. -- Jim Richardson www.eskimo.com/~warlock All hail Eris "Linux, because a cpu is a terrible thing to waste." From ivanlan at callware.com Mon Apr 26 17:47:40 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 26 Apr 1999 21:47:40 GMT Subject: help References: <19990426163014.B20207@toast.internal> <3724D1C3.8BFA2C5B@pop.vet.uu.nl> Message-ID: <3724DEFC.A01E93C2@callware.com> Hi All-- Martijn Faassen wrote: > [snip] > I always sound like that too, don't worry. :) (they're calling me a > Python preacher these days, at work) > > Regards, > > Martijn Oh, they won't even let me talk in meetings around here anymore. I just *look* like I'm going to open my mouth and they all yell, ``Yes, we *know* we should use Python!'' -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From wwells5546 at my-dejanews.com Fri Apr 23 18:06:38 1999 From: wwells5546 at my-dejanews.com (wwells5546 at my-dejanews.com) Date: Fri, 23 Apr 1999 22:06:38 GMT Subject: learning python Message-ID: <7fqqtc$msf$1@nnrp1.dejanews.com> Hi everybody, I know nothing about computer language. I guess I need to start with Python, I've downloaded the progam and installed. I have the Python window and the Ineractive window before me what do I do next????? Any help on tutorials for somebody who doesn't know anything would be helpful. Regards -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From mal at lemburg.com Wed Apr 14 04:32:55 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 14 Apr 1999 10:32:55 +0200 Subject: bug in PyGreSQL module References: <14099.24295.229214.504295@bitdiddle.cnri.reston.va.us> Message-ID: <371452B7.1C5E40EC@lemburg.com> Jeremy Hylton wrote: > > I found an apparent bug in the Python interface to PostgreSQL. I > tried sending a query to the author but haven't heard back, so I'm > looking for other users to see if they have run into the problem. > I have a table with lots of int fields, some of which of NULL. When I > do a Python query, the PyGreSQL module converts the NULL to 0 instead > of None, which is the value I expected. Is that a reasonable > expectation? > > The PyGreSQL module doesn't implement the DB API, but I checked there > anyway. Alas, it didn't say anything about how to handle NULL. Database interface modules should use None as reprensentation of SQL NULL values on the Python side of things; in fact most interfaces already take this intuitive approach. -- Marc-Andre Lemburg Y2000: 261 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From loewis at informatik.hu-berlin.de Wed Apr 21 13:19:21 1999 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Apr 1999 19:19:21 +0200 Subject: HTTP-NG Support? References: <002201be8c08$1969e570$8b7125a6@cpda6686.mcit.com> Message-ID: jkraai at murl.com writes: > Been looking over http-ng ( http://www.w3.org/HTTP-NG/ ) for > the last couple of days. > > Wondering if anything has been done via Python. ILU supports http-ng, and Python (among other protocols and languages). It is available from ftp.parc.xerox.com/pub/ilu. Regards, Martin From fmwang at mediaone.net Fri Apr 23 11:14:49 1999 From: fmwang at mediaone.net (Fuming Wang) Date: Fri, 23 Apr 1999 11:14:49 -0400 Subject: Bug or Feature? Message-ID: <37208E69.4B022E0C@mediaone.net> Hi, I found this little surprise with Python 1.5.1: >list = [[0]*2]*4 >list [[0, 0], [0, 0], [0, 0], [0, 0]] >list[0][1] = 9 >list [[0, 9], [0, 9], [0, 9], [0, 9]] Is this a bug or a feature that I don't know about? Fuming From gustav at morpheus.demon.co.uk Sun Apr 11 17:26:27 1999 From: gustav at morpheus.demon.co.uk (Paul Moore) Date: Sun, 11 Apr 1999 21:26:27 GMT Subject: Does the standard ftplib module support proxies? Message-ID: <37110c85.7753709@news.demon.co.uk> The header says it all... I've looked in the manual, but I can't see anything about proxy (firewall) support, one way or another. Actually, the same question applies to httplib and urllib. Thanks, Paul Moore. From dubois1 at llnl.gov Mon Apr 12 15:20:04 1999 From: dubois1 at llnl.gov (Paul F. Dubois) Date: Mon, 12 Apr 1999 19:20:04 GMT Subject: LLNL Website back on line Message-ID: http://xfiles.llnl.gov is back on line, as is the ftp site ftp://ftp-icf.llnl.gov/pub/python. The latest distributions remain at http://dubois.simplenet.com/python as well. I would appreciate hearing from those far from California if downloading from the latter is better; in principle it should be, I believe. If this is the case I don't mind keeping up the dual locations. From ivanlan at callware.com Thu Apr 22 15:51:21 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 22 Apr 1999 19:51:21 GMT Subject: What is it ? How can I learn it ? Where should I start ? What can you do with it ? References: Message-ID: <371F7DB9.E7E48A82@callware.com> Pythonistas-- "Alexander M. Dietrich" wrote: > > I just heard about it, it's required for a job I will eventually apply to. > I have C programming experience . Is that a plus ? Welcome aboard, Alexander. > What is it? The coolest programming language on the planet. > How can I learn it? Buy _Learning Python_ by Mark Lutz & David Ascher, O'Reilly Press. Bug us. This list is actually civilized. No newbies have been harmed beyond repair in the last year or so, and most of the real cannibals have been muzzled (Gordon excepted, so don't put any parts of you through his cage bars that you want to keep). ... > Where should I start? Here. http://www.python.org (You can order the books from here, too) There's also a Python-tutor mailing list you might want to consider joining. > What can you do with it? Anything. The weirder the better. Check out the previous conference pages at www.python.org; paper topics are, shall we say, all over the map. About the only area where Python doesn't shine is competing with Perl on regular expressions. It can do the same stuff, just not as fast. Python is fun, easy, and entertaining. And, it's educational. -ly y'rs, Ivan PS: And just *where* is this job that (I should be so lucky) *REQUIRES* you to know Python???????? Why aren't they calling ME???? ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From jasonic at nomadicsltd.com Thu Apr 8 09:45:18 1999 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Thu, 8 Apr 1999 14:45:18 +0100 Subject: Q: newbie win95 - python path navigation assignment strategies needed Message-ID: <7eibtm$igb$1@news1.cableinet.co.uk> Hello I am very new to Python, though totally convinced of its genius and utility. Been reading through, and downloading lots of great code, docs, etc. + the 3 books (now waiting for 'Learning Python'). But I seem to be stuck on a _very_ basic issue. Please help, I need some guidance - over-the-shoulder; heads-up on something I am not 'getting' yet... system: Python 1.5.2b2 [MSC 32 bit (Intel)] on win32. 'Idle' by preference :-) I do not understand the relationships between modules, namespace, path and the Python shell. When I am in the python shell at the prompt I can >>> import sys >>> sys.path ['C:\\Program Files\\Python\\Tools\\idle', 'C:\\PROGRA~1\\PYTHON\\TOOLS\\IDLE', 'C:\\Program Files\\Python\\win32', 'C:\\Program Files\\Python\\win32\\lib', 'C:\\Program Files\\Python', 'C:\\Program Files\\Python\\Pythonwin', 'C:\\Program Files\\Python\\LLNLDistribution\\NUMERICAL\\LIB', 'C:\\Program Files\\Python\\LLNLDistribution\\NUMERICAL\\PYDS', 'C:\\Program .....etc etc... and also >>> import os >>> os.getcwd() 'C:\\Program Files\\Python\\Tools\\idle' But how and when do I need to change the working directory? How and when do I need to navigate in the Python shell? Should I be in the python shell or outside it to do this? Do I need to even worry about it? At what point in a session do I need to set the path? Can I explicitly import a module by supplying a path prefix once and let Python take care of the rest? Is there some simple code to automate this? Are these problems any different because I am using Idle? What does Python do if it finds two modules with the same name both on sys.path? And what are the rules/caveats here about upper or lower case? for Win32 Python pathnames I cannot seem to find a setcwd() command or similar.. Am I missing something? If add items to my path for example >>> sys.path.append('c:\\mynewmodulepath') this is good because I can then >>> import mynewmodule But when I save out my stuff, read or write from files, or import other modules which may be located somewhere else, what strategy do you advise I follow for path setting and manipulation? I have tried setting and changing os.environ items. Is this the preferred way? for example: os.environ['MY_DEMOS'] = 'c:\\downloads\\My_Demos' I realize some of my confusion is because I using Win32 and not on a unix box at the moment. I am champing at the Python bit because I keep stumbling over this basic path cwd stuff. Likewise everywhere it in docs and READMEs where it advises running python scripts as executables (Unix) how do you advise I behave on Win95/98/NT? I need to use Win95 at the moment for other purposes and am very keen to use Python as the glue between apps on Win32 and other OSen (Irix, Linux). Thanks in advance for any help. - Jason From brunomadv at ciudad.com.ar Sun Apr 11 12:36:42 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Sun, 11 Apr 1999 16:36:42 GMT Subject: by-passing exception [Q] In-Reply-To: <000501be83ec$64157180$6b9e2299@tim> References: <000501be83ec$64157180$6b9e2299@tim> Message-ID: <000101be8439$7b0c0460$6eba0ac8@kuarajy.infosys.com.ar> Thanks Tim ... Now I am awake and I see it clearly... > just-try-getting-a-dog-to-tell-you-whether-a-file-exists-ly y'rs - tim Do you have a dog that can tell that? I would like one :-) Would be nice, no more programming alone at 2AM ... :-) Cheers, /B Bruno Mattarollo ... proud to be a PSA member From Vladimir.Marangozov at inrialpes.fr Thu Apr 8 10:51:42 1999 From: Vladimir.Marangozov at inrialpes.fr (Vladimir Marangozov) Date: Thu, 08 Apr 1999 16:51:42 +0200 Subject: Chaning instance methods References: <370C2904.A6F4BD54@inrialpes.fr> <000801be8188$b59aa9a0$749e2299@tim> Message-ID: <370CC27E.ED2D0D59@inrialpes.fr> Tim Peters wrote: > > [me, on f being an instance of Foo, becoming an instance of Bar, > the latter being derived directly from Foo] > > ... > > When I signed my exposition of instance-method trickery "subclassing-is- > a-lot-easier-ly y'rs", I had exactly this in mind: > > class Bar(Foo): > def m(self): > print "m2" > > f = Bar() > Careful! We'll eventually see what you had exactly in mind if you change the last line from (1) f = Bar() to (2) f.__class__ = Bar While (1) resets f's internal state and makes a brand new instance, (2) preserves that state (which reflects f's past existence as an instance of Foo) by changing only its interface to that of Bar "on the fly". The difference is quite fundamental. We all knew that you meant (2) in your sig, but making it slightly more explicit does not hurt :-) -- Vladimir MARANGOZOV | Vladimir.Marangozov at inrialpes.fr http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From fastlanete at aol.com Thu Apr 22 10:56:57 1999 From: fastlanete at aol.com (FastLaneTe) Date: 22 Apr 1999 14:56:57 GMT Subject: Tkinter Support Message-ID: <19990422105657.05425.00000129@ng-cg1.aol.com> I am just getting started using Python. Read the programming python book and much of the docs. I am investigating using python for both a univeristy research project and a commercial project. One of the issues is a cross platform GUI (linux,windows, mac) Looks like Tk is the likely candidate. I am impressed with the clean design of the Python language and can see a lot of potential for its use. I run a large research program at the University and I think we could seriously contribute to the Python community. However I need help understanding more about how well the Python open source support works. So far everything we have done is C (Unix Linux Windows VxWorks Qnx) In fact the QNX port for Python makes it something we can use for our autonomous underwater vehicles. Questions: Is there complete documentation for Tkinter someplace? ( I have read the html pages on pkware's web site its good but not complete) I found a lot of detail in a Tk book that is not apparent in the Tkinter docs ("Practical programming in Tcl and Tk). Is all of Tk supported ( I assume so but its not clear how or if Tkinter does some things) How extensive is the group of people supporting Tkinter? Is there a committment to continue to support Tk as the default GUI for Python like it is for TCL and Perl? I see references to several different Python applications that must use a GUI. How prevalent is Tkinter usage? From bbosware at vic.bigpond.net.au Fri Apr 30 08:03:14 1999 From: bbosware at vic.bigpond.net.au (John Leach) Date: Fri, 30 Apr 1999 22:03:14 +1000 Subject: pil vs gd Message-ID: <37299C02.4095E584@vic.bigpond.net.au> Thank you for everyone who sent me gd examples. It's working fine now. gd does what I need; but in order to get some sort of context - does pil provide, or is intended to provide one day, a superset of gd - or are they separate beasts? Can pil for example create gif images from text? And with a choice of fonts? John Leach www.bosware.com.au From fdrake at cnri.reston.va.us Thu Apr 29 17:21:19 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Thu, 29 Apr 1999 21:21:19 GMT Subject: Extension Doc bug In-Reply-To: References: Message-ID: <14120.52559.376120.364972@weyr.cnri.reston.va.us> Michael P. Reilly writes: > I just spent the morning trying to find a very obscure bug related to > the passing keyword arguments to a builtin method/function. Michael, You didn't post your original code that exhibited the bug, so I can't be sure of my conclusions. If you can send source for enough of your extension module that someone can compile it, that would be helpful. My first inclination, however, is that you passed in illegal arguments to PyArg_ParseTupleAndKeywords(). Passing NULL for the keywords dictionary is allowed; I've been looking at the implementation and don't see a way for that to be a problem (but I might have missed something). -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From bruce.adams at rmc-ltd.com Fri Apr 23 05:30:11 1999 From: bruce.adams at rmc-ltd.com (Bruce S. O. Adams) Date: Fri, 23 Apr 1999 10:30:11 +0100 Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <371F11C2.3162025@ciril.fr> <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk> <371F6C8E.6631E8F1@channelpoint.com> Message-ID: <37203DA3.42B86115@rmc-ltd.com> Bryan Oakley wrote: > Barry Margolin wrote: > > > > In article <4fv$ECA+JyH3EwbN at jessikat.demon.co.uk>, > > Robin Becker wrote: > > >I take this completely differently; least astonishment for me is if > > >program X looks and behaves the same way no matter what keyboard, mouse > > >and screen I'm using. As a 'user' of the program X it shouldn't matter > > >what OS/WM is executing the code. I certainly don't want vi or emacs to > > >be different on the mac why should I treat word or excel differently? > > > > I would be very surprised if Netscape on the Macintosh presented a > > Windows-like user interface, rather than adopting the standard Macintosh > > user interface. Most end users don't switch between platforms much, so > > it's more important that all the programs on their system conform to their > > expectations, than that a particular program work the same across different > > platforms. > > I would have to agree with that statement. While there are those who > think retaining the same look and feel across platforms is necessary, I > would wager they are in the distinct minority. That's not to invalidate > their position, but merely to put it in context. _Most_ users of > software want a package to look and feel like the other packages on a > given system. I hate, for example, the artsy (-fartsy) graphic programs > that have some weird UI instead of a more traditional UI. > > On the other hand, to some degree this is application-dependent rather > than user-dependent. For example, if I were to have a requirement to > write a air traffic control program that had to run on BeOS, MacOS, NT > and *nix, I would think there would be significant advantages to keeping > it 100% identical across all platforms. So, to some degree it depends on > the application, or the targeted user base. > > My point being, there's a need in the world for both models. Only, the > model where applications should adhere to native conventions is (I'm > guessing) far and away the most commonly expected model by most users. > Which is why I think using native windows on Tk is a win -- it meets the > needs of the majority (though definitely not all) of the users in the > world. > The two models need not be mutually exclusive. Though I have not had the pleasure of using SWING for JAVA myself, I believe it offers the ability to switch look-and-feel at the touch of a button. A configuration option that would surely please everybody. I would think this kind of configurability is a good design goal. Of course there are trade offs which are worthy of discussion. Would some kind soul with experience in this arena care to shed some light? Regards, Bruce A. From Michael.Scharf at kosmos.rhein-neckar.de Thu Apr 22 21:37:00 1999 From: Michael.Scharf at kosmos.rhein-neckar.de (Michael Scharf) Date: Fri, 23 Apr 1999 03:37:00 +0200 Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> Message-ID: <371FCEBB.96ABCADE@kosmos.rhein-neckar.de> "Steven D. Majewski" wrote: Steven D. Majewski wrote: > > > e.g. cout << "hello python."< However, if you *REALLY* want to have that sort of C++ syntax, > you can get it in Python with something like: ...compare those 15 lines with the zillions of lines of C++ code! Michael -- ''''\ Michael Scharf ` c-@@ TakeFive Software ` > http://www.TakeFive.com \_ V mailto:Michael_Scharf at TakeFive.co.at From linge at embl-heidelberg.de Thu Apr 29 13:19:49 1999 From: linge at embl-heidelberg.de (Jens Linge) Date: Thu, 29 Apr 1999 19:19:49 +0200 Subject: string.atoi('-') Message-ID: <372894B5.78F68430@embl-heidelberg.de> I had the following problem: With python 1.51 running on a SGI: >>> string.atoi('-') Traceback (innermost last): File "", line 1, in ? ValueError: invalid literal for atoi(): - >>> But with python 1.52 running on a SGI: >>> string.atoi('-') 0 >>> Does it depend on the compilation? Does anyone have the same problem? WHAT IS THE RULE? Thank you in advance. Jens From gony at my-dejanews.com Mon Apr 26 01:38:14 1999 From: gony at my-dejanews.com (gony at my-dejanews.com) Date: Mon, 26 Apr 1999 05:38:14 GMT Subject: Cryptography and web storage using PGP,Python and ftp sessions Message-ID: <7g0u46$j1i$1@nnrp1.dejanews.com> This is a 4th year bachelor of technology assignment for a systems programming paper and hence a complete answer to the assignment would be wrong. However there are about 20 of my fellow students who would greatly appreciate any guidance in completing this assignment. the assignment is as follows. Your task is to develop a secure internet-based file repository so mobile users can access files whilst travelling, and enable secure off site backup. Your system must enable a user to save personal files on the archieve-server with the confidence that, even if the files should be inappropriately accessed, they will be of absolutely no use to anyone else. These files are to be encrypted so that they can only be read by the intended recipient this could either be the person publishing the page or another specified person (a single recipient must be specified beforethe file is published). In the latter case the server acts as a secure mailbox. for the encrytion system, use the freely available version of PGP. For communication with the remote system automate an ftp session. The code to tie these together is to be written in Python - a freely available interpreted language. we can develop the system in either a UNIX or a Win95/98 platform. any hints, tips, suggestions, links to relevant sites, advice etc would be greatly appreciated -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From aa8vb at vislab.epa.gov Thu Apr 22 11:35:16 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Thu, 22 Apr 1999 11:35:16 -0400 Subject: Callbacks and "callable" objects Message-ID: <19990422113516.A278137@vislab.epa.gov> A while back I asked how to pass parameterized callbacks to Tkinter. Now I need to explore how best to do partial resolution of callback arguments. For example, define values for arguments 1 and 2 at registration time, but leave argument 3 to be populated by Tkinter. Probably makes no sense. So let me use an example: ------------------------------------------------------------------------------- For simple callbacks you can use a lambda or function wrapper: def SetColor( color ): print color wgt1.configure( command = lambda color="red" : SetColor(color) ) wgt1.configure( command = lambda color="blue": SetColor(color) ) One suggestion Thomas Heller offered before was to use a callable object instead; this gives a much simpler appearance: def SetColor( color ): print color wgt1.configure( command = Call( SetColor, "red" ) ) wgt1.configure( command = Call( SetColor, "blue" ) ) (Call class source attached below in case you're interested). ------------------------------------------------------------------------------- The wrinkle now is what if SetColor is an event callback (i.e. Tkinter provides an event argument): def SetColor( color, event ): print color this breaks the callable object form: wgt1.configure( command = Call( SetColor, "red" ) ) with Tkinter giving: TypeError: too many arguments; expected 1, got 2 So my quetsion is, can the "callable object" be used? Or do I have to fall back to a lambda wrapper? Thanks, Randall ------------------------------------------------------------------------------- class Call: """Instances of this class store a function as well as a list of arguments. When they are called, the function will be called together with the arguments used for creating the instance. Slightly different than lambda, but nicer syntax.""" def __init__ (self, func, *args): self.func = func # save the function (or bound method,or ...) self.args = args # save the arguments to use def __call__ (self): apply (self.func, self.args) # call function, using args as arguments. ------------------------------------------------------------------------------- From jwbaxter at olympus.net Fri Apr 30 01:21:19 1999 From: jwbaxter at olympus.net (John W. Baxter) Date: Thu, 29 Apr 1999 22:21:19 -0700 Subject: string.atoi('-') References: <372894B5.78F68430@embl-heidelberg.de> <372904D7.1A9FC1AB@bioreason.com> Message-ID: In article <372904D7.1A9FC1AB at bioreason.com>, Andrew Dalke wrote: > (cc'ed to Jens Linge , the author of) > > With python 1.51 running on a SGI: > > >>> string.atoi('-') > > Traceback (innermost last): > > File "", line 1, in ? > > ValueError: invalid literal for atoi(): - > > >>> > > > > But with python 1.52 running on a SGI: > > >>> string.atoi('-') > > 0 > > >>> > > > > Does it depend on the compilation? > > Does anyone have the same problem? > > > > WHAT IS THE RULE? The rule is: for the sake of sanity, do not present atoi() with the string '-'. --John -- If nothing is pressing, putter about with this or that. (Fortune cookie) John W. Baxter Port Ludlow, WA USA jwb at olympus.net From aa8vb at vislab.epa.gov Thu Apr 8 07:55:45 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Thu, 8 Apr 1999 11:55:45 GMT Subject: Is Python dying? In-Reply-To: ; from TM on Thu, Apr 08, 1999 at 05:25:30AM +0000 References: <7dos4m$usi$1@nnrp1.dejanews.com> <7e30fp$8vf$1@news1.rmi.net> <14085.18282.936883.727575@bitdiddle.cnri.reston.va.us> <7ectjd$516$1@srv38s4u.cas.org> Message-ID: <19990408075544.B983383@vislab.epa.gov> TM: |> Elsewhere in this thread there have been discussions regarding the fact |>that it's been several years since the last major Python book was |>released. | |Now that you mentioned it, I remember hearing that someone was writeing |a Python TKinter book......what the hell ever happened to that?!?! I believe that was Fredrik Lundh . In shopping for Python books late last month, I happened upon his announced plan to write a Tkinter book. So I slipped him an e-mail query asking how the book was going and if he had an estimated timeframe (in case it was close to market), but I haven't received a response. I assume he's just busy like the rest of us. Draft two of his Intro to Tkinter appeared on his pages in Feb: http://www.pythonware.com/fredrik/tkdraft/ Randall From miller at uinpluxa.npl.uiuc.edu Fri Apr 9 12:23:59 1999 From: miller at uinpluxa.npl.uiuc.edu (M.A.Miller) Date: 09 Apr 1999 11:23:59 -0500 Subject: formating string like sprintf References: <370e1d60@isoit370.bbn.hp.com> Message-ID: <7690c1vk2o.fsf@zero.npl.uiuc.edu> >>>>> "Monnet" == Monnet writes: > How can I format a string like using sprintf (mybuffer, > "%02x", myhex_value) ? Like this: >>> myhex_value = 1223 >>> mybuffer = "%02x" % ( myhex_value ) >>> print mybuffer 4c7 From cfelling at iae.nl Tue Apr 27 15:05:42 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 27 Apr 1999 21:05:42 +0200 Subject: try vs. has_key() References: Message-ID: <7g51q6$1pt$1@vvs.superst.iae.nl> Hai Moshe Zadka, sorry to react so late, but i'm a newbie to python, so it took me some time to realise that i really don't understand what you are doing:) In article you wrote: > Note: > This article is a non-commercial advertisement for the ``get'' method > of dictionary objects. > Brought to you by the object None and the method .append. > d={} > for word in words: > d[word]=d.get(word, 0)+1 > Or, for logging: > d={} > for word in words: > first_two=word[:2] > d[first_two]=d.get(first_two, []).append(word) this is the statement where i get lost. and when i try it with python 1.5.1 it doesn't work either. As far as i understand the append function it doesn't return anything as it is just a shorthand for an assignment which to my knowledge even in python 1.5.2 doesn't return values. or am i missing something here? nonetheless, it looks great, and i sure hope it works too. -- groetjes, carel From wtanksle at dolphin.openprojects.net Thu Apr 29 19:18:25 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 29 Apr 1999 23:18:25 GMT Subject: Dangers of C++ (Way off topic) References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> <372827D8.7A5F@mailserver.hursley.ibm.com> Message-ID: On Thu, 29 Apr 1999 10:35:20 +0100, Paul Duffin wrote: >William Tanksley wrote: >> Let me expand a little on the dangers of C++. >> - virtual functions. It shouldn't be my job to tell the compiler when >> virtual lookups are the only thing to do; the compiler ought to be able to >> tell. For performance gurus, a way to hint to the compiler that virtual >> lookups were _not_ needed might be useful -- but what if the programmer >> was wrong? >How can the compiler tell ? Because there's only one possibility in all of the libraries with which the system is linked. Or perhaps it can tell in some other way -- perhaps the object to which the message is being sent was just declared and couldn't have changed. But let's suppose you have the stupidest compiler in the world (i.e. one that never makes optimizations). What's the _worst_ thing that could happen if functions defaulted to virtual? Your code would be a tiny bit slower. Yawn. But with only a little more cleverness in the compiler, you wind up with the compiler able to make virtual calls when virtual calls are needed, and direct ones otherwise. This means that the same function could be called virtually one moment and directly the next. >> - inline functions. Again, a good compiler HAS to make this decision for >> itself, and in a good compiler, whether or not this decision was made >> should be transparent to the programmer. >A good compiler will, inline is only a hint to the compiler, the compiler >can choose whether or not to inline that function, it can also choose to >inline other functions which have not been marked as inline. Good. So get rid of it. Oh, and even a good C++ compiler can't choose to inline a function which wasn't defined in the header file. And at that, it doesn't have complete information about what the global impact of inlining will be -- only for that one module. >Paul Duffin -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From bwarsaw at cnri.reston.va.us Wed Apr 21 14:58:36 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Wed, 21 Apr 1999 14:58:36 -0400 (EDT) Subject: Python mailing lists are moving! Message-ID: <14110.8156.698067.110820@anthem.cnri.reston.va.us> This message is for folks who are currently receiving the the Python list traffic via python-list at cwi.nl or python-announce-list at cwi.nl, or would like to receive comp.lang.python or comp.lang.python.announce via email instead of Usenet. We are finally moving the mailing lists from cwi.nl to python.org. The lists at python.org will be managed by Mailman and will still be gatewayed to the Usenet newsgroups. We are not going to move people's subscriptions enmasse (yet). For the time being if you want to switch your subscription you should: 1) send an unsubscribe request to python-list-request at cwi.nl 2) Visit http://www.python.org/mailman/listinfo/python-list and fill out a subscription request (same goes for python-announce-list, just substitute `python-announce-list' for `python-list' above). At some point when the majority of people have moved over, and we've had the opportunity to stress the system with real traffic, we will move the remaining subscribers over to python.org, but we'll announce that before we do it. One advantage of moving to python-list at python.org is that you can set your Mailman subscription to deliver the messages in digests (MIME or `plain'). This is a nice middle ground between receiving the messages immediately as they are posted, and reading them via Usenet. Feel free to begin sending messages to the list via python-list at python.org. python-list at cwi.nl will become an alias for this new address. Enjoy, -Barry From bernhard at alpha1.csd.uwm.edu Tue Apr 20 15:44:30 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 20 Apr 1999 19:44:30 GMT Subject: bzip2 module for Python References: Message-ID: On Tue, 20 Apr 1999 09:54:49 +0100, Laurence Tratt wrote: >In message <87zp43gaac.fsf at illusion.tui-net> > Paul Kunysch wrote: > >[me 'announcing' pyBZlib] >>> As I said, I am interested to know if there is a demand for this, so >>> comments are appreciated. >> IMHO it would be nice to have a module like the current "gzip", which >> handles .bz2 .gz .Z and uncompressed files transparently. Hmmm the gzip module could eventually made compatible with the functionality of the "gzip" GNU programm: uncompressing .gz .Z (and pack) compressing .gz A bzip2 module should be able to do, what the "bzip2" program can do. But the two modules should work in the same way. This might be most intuitive for people, I think. >Do you mean you would like to see a module where you give it a file (which >could be .bz2, .gz, .zip etc), and then get an uncompressed version back >without worrying what compression type was used? Would you also want it to >automatically untar files? untaring (or unzipping multiple files) is a totally different matter. Someone could argu leaving that to the filesystem, because that modules would need to act like an filesystem then. Bernhard From cppdan at dansmart.com Sat Apr 24 01:38:50 1999 From: cppdan at dansmart.com (Daniel Smart) Date: Sat, 24 Apr 1999 05:38:50 GMT Subject: Time complexity of dictionary insertions References: <000901be8e11$b4842560$f09e2299@tim> Message-ID: <8DB21A313Me@news.rdc1.ct.home.com> [posted and mailed] Tim Peters wrote in <000901be8e11$b4842560$f09e2299 at tim>: >[someone asks about the time complexity of Python dict insertions] > >[Tim replies] >[one person confuses the issue] >[and another compounds it] >This one-ups-man-ship would be a lot cuter if Python's dict insertion >were in fact amortized constant time <0.9 wink>. It's not, and the >answer I gave doesn't imply that it is. Insertion in STL hashed >associative containers isn't ACT either. > This attempt at one-ups-man-ship would be a lot cuter if the STL had any kind of hashed containers, associative or otherwise, whose performance could be quoted! >reassuringly y'rs - tim Argumentatively y'rs - dan. -- Dan Smart. C++ Programming and Mentoring. cppdan at dansmart.com From nelson at crynwr.com Sun Apr 18 01:06:33 1999 From: nelson at crynwr.com (Russell Nelson) Date: 18 Apr 1999 01:06:33 -0400 Subject: Why no "=" in if? (was Re: Quick fix to add "+=") References: <3717EE20.41343593@mediaone.net> <000701be888f$12fe2920$ee9e2299@tim> Message-ID: aahz at netcom.com (Aahz Maruch) writes: > I'm getting really sick of the way I have to use this stupid construct: > > x = foo() > if x: > ... > > instead of > > if x = foo(): > ... > > Why doesn't Guido get off his duff and fix this?????????! I'm really sick of the way I get to use this stupid construct: if x == foo(): I think we should go back to the days of condition codes: compare(x, foo()) ife: -- -russ nelson http://crynwr.com/~nelson Crynwr supports Open Source(tm) Software| PGPok | There is good evidence 521 Pleasant Valley Rd. | +1 315 268 1925 voice | that freedom is the Potsdam, NY 13676-3213 | +1 315 268 9201 FAX | cause of world peace. From tismer at appliedbiometrics.com Tue Apr 20 16:09:42 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Tue, 20 Apr 1999 20:09:42 GMT Subject: Win32: os.listdir() on a non-existent directory References: <335a0ac6.114790@news.demon.co.uk> Message-ID: <371CDF06.9166182D@appliedbiometrics.com> Responding to a thread which is slightly out of date (exactly 2 years old), but today we stepped into this again, and nobody really seemed to take care about it. Anyway, something must be done, it cannot stay as it is. Paul Moore wrote: > > I'm running Python 1.4 on Windows 95. If I do > > import os > p = os.listdir("C:\\banana") > > I get > > Traceback (innermost last): > File "", line 1, in ? > nt.error: (3, 'No such process') Well, meanwhile this has been changed to os.error, but the same wrong error message is still there. The os returns an error message number 3. This is defined in the Windows Syserr.c file as #ifdef _WIN32 char *_sys_errlist[] = { /* 0 */ "No error", /* 1 EPERM */ "Operation not permitted", /* 2 ENOENT */ "No such file or directory", /* 3 ESRCH */ "No such process", /* 4 EINTR */ "Interrupted function call", But, the meaning is different. What is meant instead is a Unix error message which is mapped to DOS error messages in the Windows Dosmap.c file: static struct errentry errtable[] = { { ERROR_INVALID_FUNCTION, EINVAL }, /* 1 */ { ERROR_FILE_NOT_FOUND, ENOENT }, /* 2 */ { ERROR_PATH_NOT_FOUND, ENOENT }, /* 3 */ { ERROR_TOO_MANY_OPEN_FILES, EMFILE }, /* 4 */ { ERROR_ACCESS_DENIED, EACCES }, /* 5 */ What we really get is a correct Unix System V error number. The error is to take it as-is, without translation to the internal DOS errors. Now, MSDN says in "_doserrno, errno, _sys_errlist, and _sys_nerr": On an error, errno is not necessarily set to the same value as the error code returned by a system call. For I/O operations only, use _doserrno to access the operating-system error-code equivalents of errno codes. For other operations the value of _doserrno is undefined. For me this means we must either output our own posix message or map the error code to a DOS code. I'd like to correct this. What is "the right thing"(tm) ? ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 fellowsd at cs.man.ac.uk Thu Apr 22 06:52:52 1999 From: fellowsd at cs.man.ac.uk (Donal K. Fellows) Date: 22 Apr 1999 10:52:52 GMT Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> Message-ID: <7fmv24$agu$1@m1.cs.man.ac.uk> In article <371E964F.C531C2A at istar.ca>, Eugene Dragoev wrote: > Is there going to be any Tk implementation that will continue using > lightweight components? No current Tk implementation uses lightweight components. All are heavy (which actually merely means that they have their own window each.) One of the things that might come out of the TkGS work at some point may be lightweight components. There are other issues being resolved there first though... On the subject of what you thought lightweight components were: There was a substantial discussion on this matter long ago (at the start of the 8.0 cycle) and the decision was reached that what many people actually wanted was not components that looked the same on all platforms (they had that before and didn't like it) but rather components that fitted in on the platform that they were being run under at the time. Like that, an application that looks like it belongs when running under Solaris/CDE also looks like it belongs when running on Windows or on the Mac. We feel that this is a good thing, and it is the business of making apps look (and eventually feel) like they belong that is one of the major motivations of the TkGS project. Or at least, that's the way *I* see and remember it. YMMV. Donal. -- Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fellowsd at cs.man.ac.uk -- The small advantage of not having California being part of my country would be overweighed by having California as a heavily-armed rabid weasel on our borders. -- David Parsons From lutz at rmi.net Wed Apr 28 20:28:18 1999 From: lutz at rmi.net (Mark Lutz) Date: Wed, 28 Apr 1999 18:28:18 -0600 (MDT) Subject: Maximize Benefit when Purchasing Learning Python Message-ID: <199904290028.SAA20624@shell.rmi.net> David Ascher wrote: > On Wed, 28 Apr 1999 jkraai at murl.com wrote: > > How can I help whom when purchasing Python books? > > I'll dare to speak for Mark, and say that you should feel free to send > either Mark or I (or both) checks for any amount whatsoever. Skip the > middleman. Save trees -- don't buy the book, just send us cash. Don't > hesitate for a minute. What he said. (Though you could save another middleman by making the check out to my wife.) --Mark Lutz (http://rmi.net/~lutz) From steve at estel.uindy.edu Mon Apr 12 06:38:47 1999 From: steve at estel.uindy.edu (Steve Spicklemire) Date: Mon, 12 Apr 1999 10:38:47 GMT Subject: forking + stdout = confusion In-Reply-To: (clarence@silcom.com) References: Message-ID: <199904121038.FAA28479@estel.uindy.edu> Hi Clarence, >>>>> "Clarence" == Clarence Gardner writes: [snip] Clarence> def LateShift(): Clarence> OutputID = `os.getpid()` Clarence> Child = os.fork() Clarence> if Child: Clarence> print 'content-type: text/plain' Clarence> print Clarence> print '''The program is waiting to run later. The output will Clarence> be available with the id number of %s. Clarence> ''' % OutputID Clarence> sys.exit(0) Clarence> sys.stdin.close() Clarence> sys.stdout.close() Clarence> sys.stderr.close() Clarence> sys.stdout = open(os.path.join(SpoolDir, OutputID), 'w') Clarence> sys.stderr = sys.stdout Clarence> time.sleep(15) [snip] Hmm.. the following code works for me: try: serr = sys.stderr sys.stderr = sys.stdout sys.stdout.flush() pid = os.fork() if pid: # # OK...we are the parent process # sys.stdout.close() sys.stdin.close() os.wait() else: sys.stderr = serr sys.stdout.close() sys.stdin.close() ... on to do time consuming task..... Clarence> I thought that maybe sys.stdout was using a dup()'ed Clarence> copy of stdout, but I checked sys.stdout.fileno() and it Clarence> was 1, so that doesn't seem to be the case. Clarence> Can anyone hazard a guess (or see right off the top of Clarence> his head) what's going on here? Thanks for any help. I'm not sure, but I think sys.stdout is always 1. I think you need to close sys.stdxxx in both processes explicitly. At least it works on my systems. good luck! -steve Clarence> -- -=-=-=-=-=-=-=-= Clarence Gardner AvTel Clarence> Communications Software Products and Services Division Clarence> clarence at avtel.com From nascheme at m67.enme.ucalgary.ca Fri Apr 16 16:30:19 1999 From: nascheme at m67.enme.ucalgary.ca (Neil Schemenauer) Date: 16 Apr 1999 20:30:19 GMT Subject: Python.org scheduled down time References: <14103.22251.209537.804890@anthem.cnri.reston.va.us> Message-ID: <7f86kr$bd2@ds2.acs.ucalgary.ca> On Fri, 16 Apr 1999 11:27:39 -0400 (EDT), Barry A. Warsaw wrote: > >Folks, > >parrot.python.org, the machine that hosts web, mail and ftp, will be >taken down today 16-Apr-1999 at 4pm GMT -0500 for approximately 1/2 >hour. We need to install some new hardware. Is ftp.python.org mirrored anywhere? Neil From mal at lemburg.com Tue Apr 27 10:07:32 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 27 Apr 1999 16:07:32 +0200 Subject: ANN: mxODBC Package - Version 1.1.0 Message-ID: <3725C4A4.1C06FB72@lemburg.com> ANNOUNCING: mxODBC Version 1.1.0 A Python Extension Package providing a generic Interface to ODBC 2.0 API compliant Database Drivers or Managers WHAT IT IS: mxODBC is an extension package that provides a Python Database API compliant interface to ODBC 2.0 capable database drivers and managers. In addition to the capabilities provided through the standard API it also provides a rich set of catalog methods that allow you to scan the database for tables, procedures, etc. Furthermore, it uses the mxDateTime package for date/time value interfacing eliminating most of the problems these types normally introduce. mxODBC is known to work with Adabas, MySQL, iODBC Unix ODBC Manager, Solid, Sybase, OpenLink and Intersolv ODBC drivers, Oracle/NT, EasySofts ODBC-ODBC bridge and the Windows ODBC Manager. This covers pretty much the whole range of well known relational database engines and gives you all the connectivity you'll need for doing great database work in Python. WHAT'S NEW ? The 1.1.0 version is the start of moving from DB API 1.0 to DB API 2.0. Not all changes have been implemented yet, but most of the interface was overhauled in order to become DB API 2.0 compatible. Since mxODBC has been using an extended version of the DB API standard for some time already the changes are kept to a minimum. See the documentation for more details. Starting with this version, mxODBC knows about two different ways to bind Python data to SQL statement parameters: The first was in use ever since the first version: SQL type binding. In this mode the database is queried for the data type and the Python parameters are then converted into those types. The new binding mode in this version is Python type binding. Here, the Python programmer has to know which types are to be used for the parameters and the conversion is left to the database. This is of course not as elegant as the first method, but the only way to get some database to work together with mxODBC (since their drivers are missing an important ODBC API). As a result, mxODBC can now also be used to connect to MS Access. In fact, the archive contains a precompiled binary which will let you start working right away. To test your database's capabilities (and the mxODBC connection to it), the package now comes with a generic test script. This provides two features: 1. column type detection and 2. memory leak detection. Note that there are no known leaks in mxODBC; OTOH, several ODBC drivers do leak. WHERE CAN I GET IT ? The full documentation and instructions for downloading and installing can be found at: http://starship.skyport.net/~lemburg/mxODBC.html The mxDateTime package needed for mxODBC can be found at: http://starship.skyport.net/~lemburg/mxDateTime.html WHAT DOES IT COST ? mxODBC comes with a slightly modified Python-style license: Usage is free for non-commercial and commercial internal use. Redistribution of the package in commercial products requires a separate license and will only be free if the product itself is free. Detailed license information is available at: http://starship.skyport.net/~lemburg/mxODBC-License.html WHERE CAN I GET SUPPORT ? I am offering commercial support for this package through Python Professional Services Inc. (http://www.pythonpros.com). Look on their support pages for details or contact me directly. REFERENCE:

<371f956b.70694328@news.bctel.ca> Message-ID: <37207AAE.172D16B6@bigfoot.com> Guppy, Do you know if I can embed & display a COM obj in wxPython? wxPy is good, but needs good graphics package like Graphics Server. I have linked VB with Python via COM. It's a pretty decent solution. I get all the graphics stuff of VB screens and it's much much easier than using MFC. Only problem is it takes about 20 sec to shoot up the first form and passing large array back and forth via COM takes some time. Good MFC reference would really be great. MS still leads everyone on the GUI portion by great margin. Now if we only had IDE like VB where I can just draw controls and hit . to get all attributes and methods. I wish I was good enough to write Visual Pyhon. Hoon, guppy wrote: > > On Wed, 21 Apr 1999 20:53:08 GMT, smoothasice at geocities.com wrote: > > >Ok i've been playing Python for a long time and I am just now wanting > >to expand to learning the visual portion of it.(A.k.a Gui/MFC) but I > >have found that there is a diffinite lack of information on the site and > >I Haven't been able to find a book and I was wondering if there is > >anyone out there that could help me out or perhaps direct me towards > >where I could find info on it. > > Could try wxPython. > -- > MSpeak: in-no-va-tion, n. 1. extending or modifying > existing standards in undocumented ways. 2. creating > new, undocumented standards. --de-com-mod-it-ize, v. -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From fredrik at pythonware.com Tue Apr 13 10:19:18 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 13 Apr 1999 14:19:18 GMT Subject: Converting a string to a tuple References: <01be8530$65bb7120$52037e81@saints> <14098.28727.245158.616727@buffalo.fnal.gov> <00f501be857f$ff636f40$f29b12c2@pythonware.com> <01be85b5$f7197c90$52037e81@saints> Message-ID: <008f01be85b8$a5be9580$f29b12c2@pythonware.com> Bruce Huzyk wrote: > I will now take this opportunity to revise my original post. > I wish to convert a string to a tuple. > My sample string should have been: > s = '(1, "abc\\tef", 2)' > instead of: > s = '(1, "abc\\def", 2)' if that's Python source code, your string actually contains: (1, "abc\tef", 2) since \\ is Python's string representation for a single backslash (that is, \\ in the source code becomes \ in the actual string). and \t is an alias for \011 (a tab). try printing it (using print) to see what I mean. but I doubt that this is the real problem -- if you have these strings in Python source code, you could as well use your editor to remove the quotes, right? so if you get the data from a file or any other external source, the plain eval solutions work as they should. for simple data types like this, v == eval(repr(v)) is always true. From mal at lemburg.com Tue Apr 13 03:48:18 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 13 Apr 1999 07:48:18 GMT Subject: Is comp.lang.python.announce "offline" ? Message-ID: <3712F6C2.50F7BE6A@lemburg.com> There have been no new messages in that newsgroup since 1999-03-30, but I'm pretty sure that I did mail some announcements there. Does anybody know details ? -- Marc-Andre Lemburg Y2000: 262 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From jeremy at cnri.reston.va.us Thu Apr 8 16:50:37 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 8 Apr 1999 16:50:37 -0400 (EDT) Subject: Internet Robot In-Reply-To: References: <7ehe9m$hbs$1@nnrp1.dejanews.com> Message-ID: <14093.5746.99707.193428@bitdiddle.cnri.reston.va.us> Or use urllib in the standard library. Usage is: urllib.urlopen(url, post_data) Jeremy From joe at strout.net Fri Apr 23 14:11:46 1999 From: joe at strout.net (Joe Strout) Date: Fri, 23 Apr 1999 11:11:46 -0700 Subject: Style/efficiency question using 'in' References: <3720B3B9.98BED320@earth.ox.ac.uk> Message-ID: In article <3720B3B9.98BED320 at earth.ox.ac.uk>, Nick Belshaw wrote: > If I do something like :- > > ------------------ > def func1(): > return 1,2,3,4,5,6,7,8 > > for x in func1(): > print x > ------------------ > > it works as expected but is the use of a function in a loop undesirable? > Is the function called once to build the loop or is it called each loop > increment and therefore undesirable if there is much overhead? It's called once to build the loop, as you can prove to yourself by inserting "print 'spam'" into func1(). Cheers, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From alan.gauld at gssec.bt.co.uk Fri Apr 23 08:28:12 1999 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Fri, 23 Apr 1999 13:28:12 +0100 Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> Message-ID: <3720675C.FF7A9E99@gssec.bt.co.uk> > >2. stream class > > e.g. cout << "hello python."< > VERY bad idea. Bad even in C++. Why? Its one of the 'improvements' over C that allows overridding of the << operator so that you can write a class to any stream. Python does similar with the _str_ mechanism but that doesn't allow chaining of types together, which I do like in C++ so why is it a bad idea? Since its off-topic for the group respond by email if you want... > In proper C++, your const will be contained inside a class (probably > static) to keep it out of the global namespace. Hopefully not. It should be contained within a C++ namespace. Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From jam at newimage.com Sun Apr 25 18:32:29 1999 From: jam at newimage.com (jam) Date: Sun, 25 Apr 1999 18:32:29 -0400 Subject: perl v python In-Reply-To: <37238A6A.E245337D@btinternet.com>; from Mark E. Owen on Sun, Apr 25, 1999 at 10:34:34PM +0100 References: <37238A6A.E245337D@btinternet.com> Message-ID: <19990425183229.B17114@toast.internal> On Sun, Apr 25, 1999 at 10:34:34PM +0100, Mark E. Owen wrote: > > I've been using perl quite some time, just starting looking > at Python. > > what's peoples views/comparisons of both languages? > > Cheers > Mark > greetings, though perhaps considered a bit dated, I found the following reference on the python.org site : "Python and Perl come from a similar background (Unix scripting, which both have long outgrown), and sport many similar features, but have a different philosophy. Perl emphasizes support for common application-oriented tasks, e.g. by having built-in regular expressions, file scanning and report generating features. Python emphasizes support for common programming methodologies such as data structure design and object-oriented programming, and encourages programmers to write readable (and thus maintainable) code by providing an elegant but not overly cryptic notation. As a consequence, Python comes close to Perl but rarely beats it in its original application domain; however Python has an applicability well beyond Perl's niche." there have also been numerous posts on c.l.python regarding this very topic.. have a look through dejanews. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From mlh at idt.ntnu.no Sun Apr 25 15:35:08 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 25 Apr 1999 21:35:08 +0200 Subject: Efficient List Subtraction References: <3720EF73.CA7DDEFF@Colorado.edu> Message-ID: KELLEY SCOTT T writes: > Does anyone out there have a simple way to compare two lists (some operator perhaps) and > return > a list of *differences*? By differences, I mean the following: If had two > lists like, > > a = [1, 4, 5, 100] > b = [4, 5] (Check dejanews for similar reply to several similar functions...) You can use dictionaries. def difference(a,b): result = {} for element in a: result[element] = 1 for element in b: if result.has_key(element): del result[element] return result.keys() > > the difference between a and b (a-b) would be [1, 100]. I suppose you could > write a couple of for loops to go through each list and compare them, but I > thought there might be a simple way to do this. At least hashtables makes it more efficient. > I'm also interested in a simple way to returning a list of what is identical between the > two lists. > In the case of the above lists, a and b, they both contain [4, 5]. Same thing, basically... Just do something like: def intersection(a,b): temp = {} result = [] for elt in a: temp[elt] = 1 for elt in b: if temp.has_key(elt): result.append(elt) return result > > If anyone out there has a suggestion (or two) I would very much appreciate it. > > Cheers! -Scott -- > Hi! I'm the signature virus 99! Magnus > Copy me into your signature and join the fun! Lie Hetland http://arcadia.laiv.org From MHammond at skippinet.com.au Thu Apr 8 21:20:32 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 9 Apr 1999 11:20:32 +1000 Subject: COM Event Sinks and Connection Points in Python References: <7eggfh$o0f$1@nnrp1.dejanews.com> <7egnl2$ca5$1@m2.c2.telstra-mm.net.au> <3711134d.17632096@news.freeserve.net> Message-ID: <7ejkjt$67g$1@m2.c2.telstra-mm.net.au> Toby Dickenson wrote in message <3711134d.17632096 at news.freeserve.net>... >"Mark Hammond" wrote: >For controls this is to be expected. They are allowed to be fairly >non-functional until activated, which requires a control site. They might >implement IDispatch, but they can not be used a 'just' an automation server. Actually, in many cases, I can use the functionality of the objects - just not get events. Excel, Word and MSAgent are good examples - can use the IDispatch interfaces fine, but cant get events. However, Im not convinced it isnt something silly I have done, lacking the time to give it serious effort. >If I remove the extra 'return' from testPyComTest.py then I always get a >Fatal Python error: PyThreadState_Get: no current thread >Is this the bug you mean? I think I have some answers.... Yes, and great! >I believe this problem is not caused by a bug in pythoncom, but by several bugs >in PyCOMTest, the C++ server that complements this test harness. > >In PyCOMImpl.cpp, line 49, a new thread is started. That thread uses the Fire >method of the CPyCOMTest object, however this breaks the COM apartment rules. To >pass an object reference across apartments you need to use >CoMarshalInterThreadInterfaceInStream, at least once. ohh. Yes. good point. This means it probably should work if we init Pythoncom as free-threaded. >Secondly, the new thread does not call CoInitializeEx. Oops. > >Hopefully I will have time to dig further next week. Great - let me know if it fixes it! However, the particular thread state error from Python makes me think it wont - the problems you describe would, to me, imply different symptoms. I am sort-of hoping that this is actually finding a threading bug in the COM framework. If so, it will be useful as it is easily reproducible. Ahhh, for more time to play with this stuff... Mark. From euroibc at solair1.inter.NL.net Tue Apr 20 12:59:01 1999 From: euroibc at solair1.inter.NL.net (martin van nijnatten) Date: Tue, 20 Apr 1999 18:59:01 +0200 Subject: opening more than 1 file Message-ID: <371CB255.5FCAFBAF@solair1.inter.NL.net> I have a variable, which can have a value in the range from 1 to 20. If the value is 7, I have to open 7 files. What could be an elegant way of doing this? Martin From arcege at shore.net Thu Apr 8 11:15:36 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 08 Apr 1999 15:15:36 GMT Subject: Tkinter bug in Misc.tkraise, Canvas.tkraise References: <199904062020.QAA05784@python.org> <199904062043.QAA21700@eric.cnri.reston.va.us> Message-ID: Guido van Rossum wrote: :> It is not a bug with either code, it is a naming problem. The :> Canvas.tkraise is calling the correct code, but it should be called :> tag_raise, not tkraise (see the Text widget for naming choice). :> :> Fredrik or Guido, is this something you can change for before 1.5.2 is :> released? (I don't see anything on www.python.org/1.5/ that says when :> 1.5.2 will be done except "mid March", which has gone by.) : You are right that there is a naming conflict. Unfortunately the : default rules for naming Tk subcommands yield this conflict and I : didn't catch it when I (or whoever it was) originally created the : Canvas class. The Canvas.bind() method shows a precedent for naming : it tag_raise() as you propose. Actually, I got the name "tag_raise" from the method in the Text class of the same name. : Unfortunately, I cannot make this change without breaking all existing : code that was using Canvas.tkraise() for raising Canvas items (instead : of raising the Canvas itself). I can add tag_raise() and then in 1.6 : we can delete the tkraise() and lift() names. Good enough for me. : Other issues: : - As someone else suggested, the proper solution is : Misc.tkraise(canvasobject). The proper interim solution only, I think. : - /Fredrik Lundh is responsible for *documenting* Tkinter, but not for : its maintenance (although he contributed a bunch of support modules). : The maintenance of Tkinter is strictly my responsibility. (Not that I : asked for it. :-) Well.. I knew he was in there somewhere. ;) Sorry, Fredrik! : - 1.5.2 will more likely be released around mid-April. I'm awaitin'. :) : --Guido van Rossum (home page: http://www.python.org/~guido/) Thanks, Guido! -Arcege From Marten.Hedman at btk.utu.fi Tue Apr 13 10:05:47 1999 From: Marten.Hedman at btk.utu.fi (=?iso-8859-1?Q?M=E5rten?= Hedman) Date: Tue, 13 Apr 1999 17:05:47 +0300 Subject: Help: Tkinter, bad event type Message-ID: <37134F3B.8C583E0@btk.utu.fi> Hi I'm running Python 1.5.2c1 under Win NT with SP4 and Tcl/Tk 8.05. When I try to run any script that uses Tkinter, even hello.py from the Tkinter Life Preserver, I get two identical error messages: bad event type or keysym "MouseWheel" while executing "bind Listbox ..." invoked from /listbox.tcl ... invoked from /tk.tcl I can work around this by editing listbox.tcl and commenting out the "bind Listbox ..." statement, but I have to do this every time I install a new version of Tcl/Tk, and it's annoying. The same thing happened when I downloaded Python 1.5.2b2, and allowed the installer to install Tcl/Tk. I have tried downloading a fresh copy of Tcl/Tk and reinstalling it, but the problem persists. Tk scripts work fine without the modifying of listbox.tcl, so it seems to be a problem in the interface between Python and Tk. Any help would be appreciated Yours Marten Hedman Centre for Biotechnology Turku, Finland From ivanlan at callware.com Fri Apr 23 15:03:15 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Fri, 23 Apr 1999 19:03:15 GMT Subject: Style/efficiency question using 'in' References: <3720B3B9.98BED320@earth.ox.ac.uk> Message-ID: <3720C3F3.CFF6D739@callware.com> Pythonistas-- Nick Belshaw wrote: > > If someone could spare a mo to clarify - > > If I do something like :- > > ------------------ > def func1(): > return 1,2,3,4,5,6,7,8 > > for x in func1(): > print x > ------------------ > > it works as expected but is the use of a function in a loop undesirable? > Is the function called once to build the loop or is it called each loop > increment and therefore undesirable if there is much overhead? > l = (1,2,3,4,5,6,7,8) for x in l: print x or for x in 1,2,3,4,5,6,7,8: print x And your version, are all the same. In each case, a tuple is created; in the middle case, the tuple is named. There is no ``loop increment''--for just steps through the items in the sequence that it sees in the order that it sees them. That's why handing for a reversed list doesn't produce unexpected behaviour. The only undesirable effects of these three methods are that in (1), you have created a named function that may only be used once; in (2), I created a named variable which may only be used once; and in (3), the tuple has no name and ceases to exist at the end of the for loop. Of course, that means you can't use the tuple again, either;-) -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From ivanlan at callware.com Wed Apr 14 15:18:08 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 14 Apr 1999 19:18:08 GMT Subject: what do you do with Python References: <816010E2456BD111A48700805FBBE2EEA63EFA@ex-quebec-u1.baan.com> Message-ID: <3714E9F0.C3E925FB@callware.com> Hi All-- Gaetan Corneau wrote: > > Susan, > > To see what Python does, take a look at http://www.python.org > Also consider joining the Python Tutorial mailing list, if you are new to programming or to Python. The address can be found on the python.org pages (it has mysteriously vanished from my address book--that will teach me to back up NetScape!), and is a quick way to get beginner's questions answered. Someone will undoubtedly jump into the puddle with both feet and provide the address on this list, if I don't beat them to it, so watch this space;-) > If you want python job ads, take a look at http://www.dice.com > There are many :) > But *NONE* in Utah, dammit. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From cjw at connection.com Mon Apr 19 10:32:25 1999 From: cjw at connection.com (Colin J. Williams) Date: Mon, 19 Apr 1999 10:32:25 -0400 Subject: Problems with PythonWin debugger & tk Message-ID: <371B3E79.C7683E94@connection.com> When attempting to use the debugger with the simplest of tk programs, a couple of problems are observed: 1. An exception is reported when the breakpoint is set. 2. When stepping thro portions of tkinter, the coordination between the source window and the debugger are lost after about line 1000. Below is the source script and the exception report. Are there known limitations when using the debugger with tkinter stuff? This script works fine without the debugger. I would appreciate advise. Colin W. ''' First test script. ''' from Tkinter import * def test(): root = Tk() w = Label(root, text="Hello, world!") w.pack() <<<=== Breakpoint here! root.mainloop() if __name__ == '__main__': test() Traceback (innermost last): File "E:\Program Files\Python\Pythonwin\pywin\framework\scriptutils.py", line 234, in RunScript debugger.run(codeObject, __main__.__dict__) File "E:\Program Files\Python\Pythonwin\pywin\debugger\__init__.py", line 38, in run _GetCurrentDebugger().run(cmd, globals,locals) File "E:\Program Files\Python\Pythonwin\pywin\debugger\debugger.py", line 988, in run debugger_parent.run(self, cmd, globals, locals) File "C:\Python\Lib\bdb.py", line 343, in run exec cmd in globals, locals File "C:\My Files\Python\Tkinter\T1.py", line 15, in ? test() File "C:\My Files\Python\Tkinter\T1.py", line 7, in test root = Tk() File "C:\Python\Lib\lib-tk\Tkinter.py", line 910, in __init__ self.readprofile(baseName, className) File "C:\Python\Lib\lib-tk\Tkinter.py", line 929, in readprofile exec 'from Tkinter import *' in dir File "", line 1, in ? File "C:\Python\Lib\bdb.py", line 41, in trace_dispatch return self.dispatch_call(frame, arg) File "C:\Python\Lib\bdb.py", line 61, in dispatch_call if not (self.stop_here(frame) or self.break_anywhere(frame)): File "E:\Program Files\Python\Pythonwin\pywin\debugger\debugger.py", line 899, in break_anywhere fname = string.lower(win32api.GetFullPathName(frame.f_code.co_filename)) api_error: (161, 'GetFullPathName', 'The specified path is invalid.') From MHammond at skippinet.com.au Fri Apr 30 20:19:18 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 1 May 1999 10:19:18 +1000 Subject: How to read stdin while debuggingin PythonWin References: <7g9utu$kin$1@nnrp1.dejanews.com> <7garhi$hqi$1@m2.c2.telstra-mm.net.au> <7gcfe5$qin$1@nnrp1.dejanews.com> Message-ID: <7gdh9h$8se$1@m2.c2.telstra-mm.net.au> cmedcoff at my-dejanews.com wrote in message <7gcfe5$qin$1 at nnrp1.dejanews.com>... >This is exectly what I observed when aborting the debug process. Any plans to >correct this and provide a place for stdin under the debugger. Not really - I can't think of how it could possibly be useful. Of course, I would be willing to accept patches :-) Mark. From brunomadv at ciudad.com.ar Sun Apr 11 00:54:44 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Sun, 11 Apr 1999 04:54:44 GMT Subject: by-passing exception [Q] Message-ID: <000101be83d7$6a77dc80$6eba0ac8@kuarajy.infosys.com.ar> Hi All Python Gurus ... Perhaps this is a stupid question, but it's saturday and it's almost 2AM, so you may understand my state-of-mind :-) I have a script that has to check a directory for the existence of a file, so I do a os.stat(path-to-file) ... But I want to continue processing even if this file doesn't exist, so I tryed this: try: os.stat(path-to-file) except IOError, msg: blah blah .... But I get an exception ... and it doesn't go into the except statement... Should I be doing a os.listdir(path-to-dir-where-file-resides) and checking there? I am a little bit confused ... Perhaps it's time to go to bed or to stop drinking beer while working ... :-) TIA /B Bruno Mattarollo ... proud to be a PSA member From mark.thomas at gsc.gte.com Wed Apr 7 16:07:38 1999 From: mark.thomas at gsc.gte.com (Justin Development) Date: Wed, 7 Apr 1999 16:07:38 -0400 Subject: Looking 4 C extention examples Message-ID: <7egdv0$2at$1@news.gte.com> I'm looking for some C extention examples and their associated Python modules to help me learn more about Python extending. Thanks!!! From roy at popmail.med.nyu.edu Tue Apr 13 11:55:36 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Tue, 13 Apr 1999 11:55:36 -0400 Subject: forking + stdout = confusion References: <87n20caldg.fsf@spock.localnet.de> Message-ID: Carsten Schabacker wrote: > No, the child and the parent share the SAME filedescriptors. This is true > for ALL open files! So if you don't need the descriptors in a child or a > parent you should close them. > > Apache waits for the end of the file, so all processes (parents and > childs) must close the file! When doing a similar thing a while ago, I had similar problems :-) I eventually found that in addition to doing sys.stdout.close(), I had to do os.close(1) to make sure the fd really got closed. I'm still not sure I understand what was going on. I know that sys.__stdout__ contains a copy of sys.stdout, so at first I figured that doing both sys.stdout.close() and sys.__stdout__.close() would do the trick, but it didn't, but os.close(1) did. -- Roy Smith New York University School of Medicine From robin at jessikat.demon.co.uk Tue Apr 13 13:13:12 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 13 Apr 1999 17:13:12 GMT Subject: site.py & COM startup In-Reply-To: <4D0A23B3F74DD111ACCD00805F31D8100DB90B2B@RED-MSG-50> References: <4D0A23B3F74DD111ACCD00805F31D8100DB90B2B@RED-MSG-50> Message-ID: <8DzenAAos3E3EwyI@jessikat.demon.co.uk> In message <4D0A23B3F74DD111ACCD00805F31D8100DB90B2B at RED-MSG-50>, Bill Tutt writes >I typically do something like: > >k_strModuleName = "swv2Phoenix" > >if __name__ == "__main__": > import win32com.server.register > import sys, regsetup > # The next line is the equivalent of regsvr32 for a Python COM server. > win32com.server.register.UseCommandLine(swMapping) > # Tell the python DLL where to find this .py file > regsetup.FindRegisterModule(k_strModuleName, k_strModuleName + '.py', >sys.path) > >The call into regsetup, alters the Python registry settings to register >where the .py file is located at. > >Bill thanks that's useful -- Robin Becker From gmcm at hypernet.com Tue Apr 13 21:47:48 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 14 Apr 1999 01:47:48 GMT Subject: Windows install has problems. Guido asked that I use this ne In-Reply-To: <924040766.18823.0.nnrp-12.9e982a40@news.demon.co.uk> References: <924040766.18823.0.nnrp-12.9e982a40@news.demon.co.uk> Message-ID: <1288067825-21306272@hypernet.com> Barry Scott writes: [troubles with tcl/tk and installer on NT] > As for the tcl80.dll problems. Either assume that tcl80.dll is > in the standard (english) installation place > %systemdrive%\program files\tcl\bin\tcl80.dll. > > OR release note that users must add the Tcl bin dir to there > PATH. Sounds good to me. > As the python lib does not have a module to access the registry > it makes getting the info from the registry hard. > > Maybe 1.6 needs a windows registry module to solve this and > other problems. Actually, the standard Python on Windows does know about the registry. And Mark Hammond's Win32 extension stuff has a registry module. But what if the user is (for some other purposes) relying on having a different version of tcl/tk around? Not all that uncommon, and very messy. Python is not real flexible about the version of tcl / tk it uses. - Gordon From asehbai at gslink.com Fri Apr 9 01:14:10 1999 From: asehbai at gslink.com (Aamir Sehbai) Date: Fri, 9 Apr 1999 01:14:10 -0400 Subject: Client side cookies in Python Message-ID: To handle cookies sent by the server, the Cookies.py module is not enough. I need to be able to handle client-side cookies in my Python script, (to log in to Yahoo! and get my email). While I searched for this topic in this newsgroup, I found the following hack from Rick Otten to deal with the problem, at http://x8.dejanews.com/[ST_rn=ap]/getdoc.xp?AN=367235052&CONTEXT=923633207.1880162449&hitnum=1 While I will be trying to make his code work with Yahoo, if anyone else has information about something similar, please share. Thanks. From amitp at Xenon.Stanford.EDU Fri Apr 30 13:55:35 1999 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 30 Apr 1999 17:55:35 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <19990430080805.B776752@vislab.epa.gov> <3729A9F3.75B2692B@appliedbiometrics.com> Message-ID: <7gcqqn$p4b$1@nntp.Stanford.EDU> Michael Hudson wrote: | | A word of warning: this code is nasty, *nasty*, NASTY. Possibly the | most horrible thing you will see perpetrated in Python this year. It | applies regular expressions to strings of bytecode... [code removed] | def make_adder(n): | def adder(x): | return x+n | return bind_locals(adder) Yow. I think you are INSANE. :-) I thought bind_locals was impossible to implement in Python, and you go and implement it. Eek! Amit, too afraid to use bind_locals From mal at lemburg.com Thu Apr 29 09:57:12 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 29 Apr 1999 15:57:12 +0200 Subject: Python and CGI Message-ID: <37286538.5EAE0173@lemburg.com> Hi everybody, Yesterday, I mailed an announcement for mxCGIPython, a drop-in setup extension for the Python source distribution that allows compiling a one-file executable containing the standard Python interpreter + the standard library + the default builtin modules. The result is a complete Python installation in one single file -- easy to install and ship around. Although there were a number of hits on the web-page, I'm not sure whether the announcement got the message through... this is intended to be a campaign with the goal of promoting Python as CGI engine. I've further enhanced and simplified the setup, so that producing these binaries really becomes a very simple and highly automated task. Basically all you have to do is unarchive the source distribution, the setup I provide on the web-page below and then type 'make -f Makefile.cgi'. I'll collect the submitted binaries on the starship FTP server for everybody to download at their ISPs (if they don't already support Python). Hope this campaign becomes a success... http://starship.skyport.net/~lemburg/mxCGIPython.html Cheers, -- Marc-Andre Lemburg Y2000: 246 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From Bjoern.Giesler at stud.uni-karlsruhe.de Thu Apr 22 07:24:53 1999 From: Bjoern.Giesler at stud.uni-karlsruhe.de (Bjoern Giesler) Date: 22 Apr 1999 11:24:53 GMT Subject: Pyton setuid program? Message-ID: <7fn0u5$9jm$1@news.rz.uni-karlsruhe.de> Hi, is it possible to have a Python script run setuid? If so, how do I do that? Or could that be a Linux problem? TIA, --Bjoern -- | thank you for your time, worship the antichrist, and have a nice day /\ +---------------------------------------------------------------------/()\ | pgp key available on request /____\ From smoothasice at geocities.com Tue Apr 27 11:51:18 1999 From: smoothasice at geocities.com (smoothasice at geocities.com) Date: Tue, 27 Apr 1999 15:51:18 GMT Subject: Directories Message-ID: <3725DDD2.149DF47F@geocities.com> Hi, i'm curious if there is a python command or set of commaneds that could be used like the dir() command in dos prompt. I am trying to write a program in python that would allow me to list the files of a certain data type in a few directories but I need to know how I would do that ...thanks a bundle. Anton From tavares at connix.com Wed Apr 28 16:54:13 1999 From: tavares at connix.com (tavares at connix.com) Date: Wed, 28 Apr 1999 20:54:13 GMT Subject: HTML "sanitizer" in Python References: Message-ID: <7g7shk$rgd$1@nnrp1.dejanews.com> In article , "Scott Stirling" wrote: > Hi, > > I am new to Python. I have an idea of a work-related project I want to do, > and I was hoping some folks on this list might be able to help me realize it. > I have Mark Lutz' _Programming Python_ book, and that has been a helpful > orientation. I like his basic packer and unpacker scripts, but what I want > to do is something in between that basic program and its later, more complex > manifestations. > > I am on a Y2K project with 14 manufacturing plants, each of which has an > inventory of plant process components that need to be tested and/or > replaced. I want to put each plant's current inventory on the corporate > intranet on a weekly or biweekly basis. All the plant data is in an Access > database. We are querying the data we need and importing into 14 MS Excel 97 > spreadsheets. Then we are saving the Excel sheets as HTML. The HTML files > bloat out with a near 100% increase in file size over the original Excel > files. This is because the HTML converter in Excel adds all kinds of > unnecessary HTML code, such as for every > single cell in the table. Many of these tables have over 1000 cells, and > this code, along with its accompanying closing FONT tag, add up quick. > The other main, unnecessary code is the ALIGN="left" attribute in

PackageName 1.0 - short > description of not more than one sentence. (DD-Mon-YY) > > You may only include *one* link, which should point to a web page > with more info about your package (cf 2. above). The date should > be in parentheses, formatted as shown, e.g. 29-Jul-98. > > 8. Format your posting so that all lines are at most 78 characters > wide. (Exception: Internet resource addresses (cf. 7. above) should > not be line-wrapped, if possible.) > > You can upload your program or module to , > or become a PSA member and create a web page at the "Starship Python" server > (see below). The Python main FTP site is being mirrored at serveral sites > all around the world. Don't forget to send a short e-mail notification to > and upload a corresponding .README > file together with your announcement. > > Mailing list gateways > --------------------- > > * comp.lang.python: > > There is a two-way gateway between the comp.lang.python news group and > the "python-list" mailing list. You can subscribe to this list by sending > an e-mail message to the following address: > > > > with the text "subscribe" in the e-mail body. You can unsubscribe by > sending an e-mail message to the same address with the text "unsubscribe" > in the e-mail body. > > There is a web archive of past comp.lang.python postings at FindMail, > > . > > * comp.lang.python.announce: > > There is also a mailing list gateway for comp.lang.python.announce. > To subscribe or unsubscribe, send an e-mail to > > > > with a body content of "subscribe" or "unsubscribe", respectively. > > Please note that comp.lang.python.announce is moderated; you cannot > just post to this list. Please e-mail any announcements to the > c.l.py.a submission address: > > > > or use your news reader to post to comp.lang.python.announce. > In the latter case, your posting should be forwarded to the > c.l.py.a moderators automatically by the news server software. > > A web archive of c.l.py.a postings is currently being prepared. > Until it becomes available, you can look for c.l.py and c.l.py.a > postings with DejaNews, , or FindMail, > . > > Further Python Resources > ------------------------ > > WWW: - Python Language Home Page > - Python Language FAQ > - Python Quick Help Index Page > - Starship Python: User Pages > > Usenet: - Python Discussion Newsgroup > - Python Announcements Newsgroup > > The PSA > ------- > > About the "Python Software Activity" (PSA), cf. : > > "The continued, free existence of Python is promoted by the contributed > efforts of many people. The Python Software Activity (PSA) supports those > efforts by helping to coordinate them. The PSA operates web, ftp, and > email services, organizes conferences, and engages in other activities > that benefit the Python user community. In order to continue, the PSA > needs the membership of people who value Python." Have a look at the PSA > web pages for further information about the PSA and membership benefits. > > -- > ----------- comp.lang.python.announce (moderated) ---------- > Article Submission Address: python-announce at python.org > Python Language Home Page: http://www.python.org/ > Python Quick Help Index: http://www.python.org/Help.html > ------------------------------------------------------------ sasa From fredrik at pythonware.com Thu Apr 15 10:00:24 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Apr 1999 14:00:24 GMT Subject: Different methods with same name but different signature? References: <3716909C.D8D1B372@fedex.com> Message-ID: <005201be8748$51e0bab0$f29b12c2@pythonware.com> frederic pinel wrote: > While trying to implement the visitor pattern in Python, I ran into the > following problem: > > My class needs to have 2 (or more) different methods, but with the same > name, the difference being the signature (an object in my case), > unfortunately Pyhton interprets this as an overidding, and only > considers the last method defined. well, python doesn't allow you to specify argument types, so there's no way to tell the difference anyway... > - using a single method, but checking isinstance() of the object passed > to switch to the right code, > - using different names for the methods, the second method is preferred -- it's faster, easier to understand, and less error-prone imho, it's also an improvement over the pure visitor pattern, since it allows you to generate "logical events" that doesn't correspond to "physical" data instances in your model. From daye at earthling.net Thu Apr 8 00:51:28 1999 From: daye at earthling.net (Daye) Date: Wed, 7 Apr 1999 23:51:28 -0500 Subject: infoseek? Message-ID: <7ehcn3$elg$1@newssvr01-int.news.prodigy.com> does anyone know if Infoseek.com still use python for their search engine? Thanks. From arcege at shore.net Mon Apr 5 17:59:39 1999 From: arcege at shore.net (Michael P. Reilly) Date: Mon, 05 Apr 1999 21:59:39 GMT Subject: Secure Python for embedding References: <7ebb3c$8jf$1@news.inet.tele.dk> Message-ID: Per Knudsgaard wrote: : Hi all, : I have a situation where I would like to add a scripting language to the : client of a client-server application. The server will, as part of the : communication between client and server, provide the client with scripts to : run. I would like it to be secure so I do not end in a situation where I : expose the client machine to virae, Trojan horses or similar nasty things. : In other words, I would like the scripts to be run in their own little : "sandbox" environment. I have the embedding almost down, but what I have is : a fully functional language within the client. Is there any way, without : modifying the core Python code, that I can implement a secure scripting : language using Python? You will probably want to look at the rexec standard module. Reading the code can help you a lot. -Arcege From invalid.address at do.not.email Wed Apr 7 11:38:50 1999 From: invalid.address at do.not.email (guppy) Date: Wed, 07 Apr 1999 15:38:50 GMT Subject: Crappy Software was Re: [OffTopic: Netscape] Re: How should Python be evangelized? References: <7dos4m$usi$1@nnrp1.dejanews.com> <7dqs0h$lcq$1@nnrp1.dejanews.com> <2_6M2.30$Kj1.679@198.235.216.4> <37019F42.EA55CA8@kanga.org> <009d01be7b47$8a9a6020$f29b12c2@pythonware.com> <7dtmso$7u6$1@news.clarkson.edu> <3703ca33.9749737@news.bctel.ca> <37089dcb@fermi.armored.net> <370bd698.137859911@news.dslspeed.com> Message-ID: <370c7a2d.35857749@news.bctel.ca> And another kick at Netscape: Jamie Z, pretty much the alpha geek programmer at Netscape, has resigned. And in his words: "...I strongly believed that Netscape was no longer capable of shipping products. ... Netscape was shipping garbage, and shipping it late. And daring move or no, this was not going to change: Netscape no longer had the talent, either in engineering or management, to ship quality products. The magic was gone, as the magicians had either moved on to more compelling companies, or were having their voices lost in the din of the crowd, swamped by the mediocrity around them. The Netscape I cared about was dead." The Web Standards Organization has this to say: "We do not plan on reviewing any Netscape browsers.... Netscape does not claim that Communicator 4.0 or 4.5 is CSS compliant. Trying to list the important bugs would be an exercise in writing long documents, one we do not have the patience to do. Running Netscape 4.x through the tests we use... will provide a clear demonstration of Netscape's current shortcomings to anyone who doubts them. Of about 40 test pages in those two reviews, there are only two that don't demonstrate problems in Netscape Communicator (and we weren't even looking for bugs in Netscape Communicator when we wrote those tests)." -- MSpeak: in-no-va-tion, n. 1. extending or modifying existing standards in undocumented ways. 2. creating new, undocumented standards. --de-com-mod-it-ize, v. From john.michelsen at gte.net Mon Apr 5 13:04:34 1999 From: john.michelsen at gte.net (John Michelsen) Date: Mon, 5 Apr 1999 10:04:34 -0700 Subject: Tkinter bug in Misc.tkraise, Canvas.tkraise Message-ID: <7eaoop$leq$1@news-2.news.gte.net> The following got posted in a reply tree by mistake: I found a bug in using Tkinter to raise a canvas widget above later packed (etc.) widgets. It seems Tkinter gets confused between the Misc.tkraise() method and the Canvas.tkraise(item) methods. The following script shows the problem: from Tkinter import * def raiseCanvas(): canvas1.lift() #canvas1.tkraise() #canvas1.widgetlift() root = Tk() canvas1 = Canvas(root, bg='blue') canvas1.place(x=10, y=10, anchor=NW) canvas2 = Canvas(root, bg='red') canvas2.place(x=20, y=20, anchor=NW) raiseButton = Button(root, text='raiseCanvas', command=raiseCanvas) raiseButton.pack() root.geometry("%dx%d" % (100,100)) root.mainloop() which gives the following error: Exception in Tkinter callback Traceback (innermost last): File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 764, in __call__ return apply(self.func, args) File "C:\PROGRA~1\PYTHON\RAISEC~1.PY", line 4, in raiseCanvas canvas1.lift() File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1287, in tkraise self.tk.call((self._w, 'raise') + args) TclError: wrong # args: should be ".8249616 raise tagOrId ?aboveThis?" I made Tkinter do what I want by adding a method to the Misc class and not the Canvas class: class Misc... def tkraise(self, aboveThis=None): self.tk.call('raise', self._w, aboveThis) lift = widgetlift = tkraise so that widgetlift will call the tkraise in Misc and not the tkraise in Canvas. I discovered the error in developing a multiple document interface for Tkinter which can be found on: http://www2.zyvex.com/OpenChem/index.htm Dockable toolbars and a tree widget can also be found there. They probably don't look very good on unix yet. John From ivanlan at callware.com Thu Apr 22 17:58:00 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 22 Apr 1999 21:58:00 GMT Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> Message-ID: <371F9B68.5071C282@callware.com> Hi Thooney and all the other Pythonistas out there-- Thooney Millennier wrote: > > Hello Everyone! > > I usually use C++ ,so I want to make programs like > I do using C++. > I don't figure out how to implement the followings > by Python. > If you know any solutions,Please Help! > > 1. #define statements > e.g. #define __PYTHON_INCLUDED__ > #define PYPROC(ARG) printf("%s",ARG) > __PYTHON_INCLUDED__ = 1 (Although that's probably not what you really mean to do.) def PYPROC(arg): print arg > 2. stream class > e.g. cout << "hello python."< print "hello python" --or-- sys.stdout.write("hello python") > 3. const variables > e.g. const int NOCHAGE=1; > Can't be done. Any sufficiently determined Pythonista can change anything she wants to. But, you can do this to keep your edges inside a specific file-- _NOCHANGE = 1 Any variable beginning with an underscore has module-specific scope. > 4. access to class's members using "::" > e.g. some_class::static_value > e.g. some_class::static_func(x) > print some_class.static_value t = some_class.static_func(x) See, there's no real concept of a ``static'' member, or of ``private'' members in Python classes. All methods and members of all classes are public. That's a good thing. > Thanks for reading. > > Thooney Millennier. You should investigate the tutorial at http://www.python.org It's really very good, and with your C++ experience you will have no trouble at all. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From bryanv at arlut.utexas.edu Mon Apr 19 15:49:47 1999 From: bryanv at arlut.utexas.edu (Bryan VanDeVen) Date: Mon, 19 Apr 1999 14:49:47 -0500 Subject: Tkinter performance References: <371B4B39.8B78BC7A@foreman.ac.rwth-aachen.de> Message-ID: <371B88DB.B71584E4@arlut.utexas.edu> > > I'd suggest using PyOpenGL with the NumPy extension. In combination, it > can be quite fast, by pushing the loops to C extension modules. The only > portability problem is to the mac -- there is no Togl widget for the mac > yet. Another alternative would be the excellent Visualization Toolkit Library, freely available from http://www.kitware.com. It is a large cross-platform C++ class library for building 2D and 3D data visualization apps which has both Python and tcl/tk bindings. -- Bryan Van de Ven Applied Research Labs University of Texas, Austin From thooney at pk.highway.ne.jp Thu Apr 22 17:08:07 1999 From: thooney at pk.highway.ne.jp (Thooney Millennier) Date: Fri, 23 Apr 1999 06:08:07 +0900 Subject: Emulating C++ coding style Message-ID: <371F8FB7.92CE674F@pk.highway.ne.jp> Hello Everyone! I usually use C++ ,so I want to make programs like I do using C++. I don't figure out how to implement the followings by Python. If you know any solutions,Please Help! 1. #define statements e.g. #define __PYTHON_INCLUDED__ #define PYPROC(ARG) printf("%s",ARG) 2. stream class e.g. cout << "hello python."< <7du3ab$3ag@chronicle.concentric.net> <371219E9.9EA91839@home.com> Message-ID: >>>> Thus spake 'Jim Meier (fatjim at home.com)': JM> Mike Orr wrote: >> I'm not sure if I'll use ConfigParser for the next version. I don't >> really need the sections (multiple files work just fine, using the filename >> for the section name), and I haven't found a use for the the %(other_key)s >> substitutions. On the other hand, it doesn't handle multiple values (the >> same key repeated within a record), which I sometimes need. >> >> Attached is a wrapper class for ConfigParser which supports booleans >> and can also return an entire section as a dictionary (or all the sections >> as nested dictionaries). I find these make it a little more convenient. >> JM> Why not simply use a file of python expressions? Like this: Or classes (which is what I've used in several apps): class Section1: key1 = [ 1, 2, 3, 'value', [ 'useful, 'nesting', 'eh?' ] ] key2 = 'anotherval' -- Brad Howes bhowes at motorola.com Principal Compass Hacker Work: +1 602 446 5219 Motorola Cell: +1 602 768 0735 From nascheme at ucalgary.ca Tue Apr 27 11:03:44 1999 From: nascheme at ucalgary.ca (Neil Schemenauer) Date: 27 Apr 1999 15:03:44 GMT Subject: Bug or Feature? References: <37208E69.4B022E0C@mediaone.net> <7fr3eg$bqr@world1.bellatlantic.net> Message-ID: <7g4jkg$llc@ds2.acs.ucalgary.ca> Stephan Houben wrote: [that making multi-dimensional "arrays" is difficult] I think the Numeric array should be added as a standard module. This is on the Python TODO list. I may do it myself it I get time. I don't know how much of Numeric should be added. Any comments? Neil From a.mueller at icrf.icnet.uk Tue Apr 20 08:47:08 1999 From: a.mueller at icrf.icnet.uk (Arne Mueller) Date: Tue, 20 Apr 1999 13:47:08 +0100 Subject: RuntimeError: Maxium recursion ... Message-ID: <371C774C.A3E0001B@icrf.icnet.uk> Hi All, In my program I get the following error message from python: RuntimeError: Maximum recursion depth exceeded And it's true, there're alot of recursions, too many, but this is not a bug in my program, it's only an 'extrem' dataset, and I'll have to think about an iterative solution of my problem ... . However, I'd like to get some results as soon as possible. Is there a may to set the number of maximum allowed recursion depth to a higher value? thanks, Arne -- Arne Mueller Biomolecular Modelling Laboratory Imperial Cancer Research Fund 44 Lincoln's Inn Fields London WC2A 3PX, U.K. phone : +44-(0)171 2693405 | Fax : +44-(0)171 269 3258 email : a.mueller at icrf.icnet.uk | http://www.icnet.uk/bmm/ From markus_kohler at hp.com Wed Apr 28 03:57:18 1999 From: markus_kohler at hp.com (Markus Kohler) Date: 28 Apr 1999 09:57:18 +0200 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: >>>>> "Brian" == Brian Lloyd writes: [deltia] Brian> Arne, Brian> While I'm not going to go near comparing Python to Perl, I Brian> will comment that different languages are just that - Brian> different. As such, the approach you would take in one Brian> language may not be the most appropriate (or comparable in Brian> speed or efficiency) to the approach you would take in Brian> another. Brian> The question here (IMHO) is not Python's appropriateness Brian> for processing large datasets (a fair number of Brian> scientist-types do this all the time), or even the speed of Brian> Python in general, but using the most appropriate Brian> algorithms in the context of the language in use. Python would be appropriate for much more problems if it would only be as fast as other scripting languages. The bytecode interpreter IS significantly slower than other byte code interpreted languages. Since we all know that python is more productive than most other languages, this becomes sooner or later an issue because one would not be able some tasks in python because it is just to slow. Brian> For example, Perl is very regex-centric, so your example Brian> Perl implementation is probably perfectly appropriate for Brian> Perl. Python tends to be more optimized for the general Brian> case, and if it were _me_, I wouldn't bother with using Brian> regular expressions in this case,. Since you have a Brian> predictable file format, there are more specific (and Brian> efficient) Python tools that you could use here. You are right that one should choose the right tool for a problem, but I disagree that Python is optimized for the general case. Squeak a free Smalltalk implementation (www.squeak.org), is already much faster ( about 3 times actually ) than python and it has even a true Garbage Collector. As soon as the first Just in Time Compiler has been finished, it may even come close to Visualworks a commercial Smalltalk implementation with a Just in Time Compiler. At the moment Visualworks is still at least 5 times faster than squeak. I tell you all this just to give you some idea how fast a language that is as flexible as python could be. [deletia] >From profiling python 1.5.2c I found that python's main problem is that calling functions seems to be very costly. Also I have not yet looked at this issue in detail it is obvious that the code to call a python function is pretty complex. I guess this is because python supports default arguments and other 'nice' features for calling functions. It seems to me that without a redesign of at least the bytecode for function calls python's speed will not take off. Markus -- Markus Kohler mailto:markus_kohler at hp.com From tismer at appliedbiometrics.com Sat Apr 24 11:10:48 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sat, 24 Apr 1999 15:10:48 GMT Subject: wrapped around the axle on regexpressions and file searching References: <1287155028-45807148@hypernet.com> Message-ID: <3721DEF8.FBF889D4@appliedbiometrics.com> Gordon McMillan wrote: > > msrisney writes: ... > At any rate, os.path.exists('e:/') is an effective way of finding out > if e: exists. Though specifying 'a:/' will pop up one of those lovely > Abort/Retry/Fail dialogs if nothing is in the drive. Not always. On my Win98 box, the floppy drive brushes teeth for a second, and then I get back *one* from os.path.exists. This is really bad, since I didn't insert a floppy. > in-nearly-20-years-I-still-haven't-figured-out-the-difference-between > -Abort-and-Fail-ly y'rs Some of my early dos tools aborted immediately from the DOS function when I hit abort, while they caught the error and some were able to continue, when I answered with "Fail". So I think the designed intent was to give the user a chance to decide wether the program should shut down, or an internal error handler should get a chance. Anyway no good solution - ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 cgambrell at my-dejanews.com Fri Apr 30 09:41:23 1999 From: cgambrell at my-dejanews.com (Chris Gambrell) Date: Fri, 30 Apr 1999 13:41:23 GMT Subject: Launching web browser programmatically References: <3724EB92.248E7933@hotmail.com> <7g2rm1$t8i$1@m2.c2.telstra-mm.net.au> Message-ID: <7gcbu2$nbc$1@nnrp1.dejanews.com> But how does one specify no scrollbars, no menus, the size of the window, etc. Thanks, Chris In article <7g2rm1$t8i$1 at m2.c2.telstra-mm.net.au>, "Mark Hammond" wrote: > If you have the win32 extensions, you can use win32api.ShellExecute() > > Anything you can use after "start" you can pass to ShellExecute - ie, a URL, > a document file, .exe, etc. > > Mark. > > Ben Darnell wrote in message <3724EB92.248E7933 at hotmail.com>... > >How do I launch the the user's web browser programmatically on Win9x? I > >can use "start http://www.python.org" at the command line, but > > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From jcosby at wolfenet.com Tue Apr 27 13:37:35 1999 From: jcosby at wolfenet.com (Jon Cosby) Date: Tue, 27 Apr 1999 10:37:35 -0700 Subject: CGI post method References: <7g31ah$hk2$1@sparky.wolfe.net> <14117.47102.615236.362798@amarok.cnri.reston.va.us> Message-ID: <7g4slp$e3v$1@sparky.wolfe.net> Tried that. Shows the correct argument, but the script reverts to the default value. Jon Cosby Andrew M. Kuchling wrote in message <14117.47102.615236.362798 at amarok.cnri.reston.va.us>... > It looks reasonable. Try changing the method to "GET" and see >if you wind up with /cgi-bin/fibo.py?value=10. What error are you >seeing? > >-- >A.M. Kuchling http://starship.python.net/crew/amk/ > "Mortal man?" > "Yes?" > "Beware of the dog." > -- Charon warns Orpheus, in SANDMAN: "The Song of Orpheus" > > From tismer at appliedbiometrics.com Thu Apr 29 12:19:09 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 29 Apr 1999 16:19:09 GMT Subject: Read MS Access 97 *.mdb files with python?? References: <37287369.D6E67313@t-online.de> Message-ID: <3728867D.94B5BBF9@appliedbiometrics.com> gemodek wrote: > > Does somebody know some > piece of soft which can this?? Use PythonWin, create an interface for Microsoft DAO (your version) with the makepy utility, and then use COM to access Access. Something like import win32com.client engine=win32com.client.Dispatch("dao.dbengine.35") Then you can use every method of the database engine, as you can find in the VBA help file of your copy of the MS Access distribution. > Or does somebody know if the description of > the format ia avaible (for free of course). That's a long awaited feature which I guess will never be available. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 kernr at mail.ncifcrf.gov Sun Apr 11 19:32:31 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Sun, 11 Apr 1999 19:32:31 -0400 Subject: cygwin32-b20 _tkinter problem References: <371071b0.15953469@news.btx.dtag.de> Message-ID: <3711310F.65CA2C0A@mail.ncifcrf.gov> Monika G?hmann wrote: > > When I try to compile python-1.5.2b2 under WinNT with Cygwin32-B20 it > works very well without Tk-Module. But when I try to include Tk, I get > the following messages: > > gcc python.o \ > ../libpython1.5.a -ltix4180 -ltk80 -ltcl80 -lstdc++ -lm > -lm -o python > ../libpython1.5.a(_tkinter.o): In function `Tkapp_CreateFileHandler': > //c/temp/Python-1.5.2b2/Modules/./_tkinter.c:1459: undefined > reference to `Tcl_CreateFileHandler' > ../libpython1.5.a(_tkinter.o): In function `Tkapp_DeleteFileHandler': > //c/temp/Python-1.5.2b2/Modules/./_tkinter.c:1486: undefined > reference to `Tcl_DeleteFileHandler' > ../libpython1.5.a(_tkinter.o): In function `EventHook': > //c/temp/Python-1.5.2b2/Modules/./_tkinter.c:1913: undefined > reference to `Tcl_CreateFileHandler' > //c/temp/Python-1.5.2b2/Modules/./_tkinter.c:1943: undefined > reference to `Tcl_DeleteFileHandler' > collect2: ld returned 1 exit status > make[1]: *** [link] Error 1 > make: *** [python] Error 2 Add -lexpect526 to the command line. Those symbols are only defined in libexpect526.a of the cygwin B20.1 distribution. Hope that helps. [snip] -- Robert Kern | ----------------------|"In the fields of Hell where the grass grows high This space | Are the graves of dreams allowed to die." intentionally | - Richard Harter left blank. | From my at efes.net.tr Fri Apr 16 07:15:33 1999 From: my at efes.net.tr (Murat Yeneroglu) Date: Fri, 16 Apr 1999 11:15:33 GMT Subject: binary Message-ID: <37171BD5.87CFA015@efes.net.tr> Hi, I want to ask that how I can convert a decimal number to binary in python ? THNX murat. From pduffin at mailserver.hursley.ibm.com Thu Apr 29 05:35:20 1999 From: pduffin at mailserver.hursley.ibm.com (Paul Duffin) Date: Thu, 29 Apr 1999 10:35:20 +0100 Subject: Dangers of C++ (Way off topic) References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> Message-ID: <372827D8.7A5F@mailserver.hursley.ibm.com> William Tanksley wrote: > > Let me expand a little on the dangers of C++. > > - virtual functions. It shouldn't be my job to tell the compiler when > virtual lookups are the only thing to do; the compiler ought to be able to > tell. For performance gurus, a way to hint to the compiler that virtual > lookups were _not_ needed might be useful -- but what if the programmer > was wrong? > How can the compiler tell ? > - inline functions. Again, a good compiler HAS to make this decision for > itself, and in a good compiler, whether or not this decision was made > should be transparent to the programmer. > A good compiler will, inline is only a hint to the compiler, the compiler can choose whether or not to inline that function, it can also choose to inline other functions which have not been marked as inline. > - templates. Generic functions are a very good thing, and with Python > 2's type support we might wind up needing them. In C++, templates are > also a very good thing, but thanks to the C model of seperate compilation, > no two C++ compilers handle templates compatibly. > True enough. > - single-root object hierarchy -- this is a must when the default binding > is virtual. > > - GC -- hard to add after the fact. No worry with Python, but what if > there are other issues like it? > > - covariance/contravariance/"no"variance -- when a subclass redefines a > function, what types of input parameters can the redefinition accept? In > C++, you can't accept a different type without overloading the function. > With covariance (in Sather) you can allow the redefined function to accept > a parent class, which allows the new function to handle more subclasses > (including all the ones the old function handled). With contravariance > you can require the redefinition to be more specific, accepting fewer > classes. Aside from my obvious dislike of novariance, I'm not going to > take sides ;-). > This is something which I would love to be able to do in C++. -- Paul Duffin DT/6000 Development Email: pduffin at hursley.ibm.com IBM UK Laboratories Ltd., Hursley Park nr. Winchester Internal: 7-246880 International: +44 1962-816880 From r.albanese at qut.edu.au Mon Apr 19 22:51:19 1999 From: r.albanese at qut.edu.au (Rico Albanese) Date: Tue, 20 Apr 1999 12:51:19 +1000 Subject: Date/Time conversions Message-ID: <371BEBA7.5DBC1B0F@qut.edu.au> I am writing a web based database application and I am having problems in creating a string that contains an integer in it. I wish to store the login time as an integer so that I may do some time difference calculations based on the stored login time (ie. the integer). The SQL statement string creation fails when I have the integer variable "logtime" in it but not when it is removed. I believe that my problem is caused by trying to insert an integer into a string. The database works fine (ie I can add integers to the column "LogTime"). This is part of the code: . import dbi,odbc #For ODBC stuff import time #For ODBC and time related stuff import rexec #For executing the SQL query import cgi #For processing the form stuff import re #For regular expression and pattern matching #------------------------------------------------------------------------------------------------------- form = cgi.SvFormContentDict() . . . Caller=Ph=Loc=Sch=JbDes=JbPr=None Caller=form['Name'] Ph=form['PhNumb'] Loc=form['Locn'] Sch=form['Schl'] JbDes=form['JobDesc'] JbPr=form['urgency'] . . logtm=time.time() #a floating point logtime=int(logtm) #an integer . . frontpar='(' backpar=')' #Build the SQL statement string thesql="INSERT INTO CSJobs.compjobs (LogTime,Caller,Phone_Extension,Caller_Category,Location,Job_Description,Job_Priority,LogNumb,Log_Date,Finished) VALUES " thesql=thesql + frontpar + logtime + "," The inclusion of this variable ^ (ie logtime) causes this script to fail. When it is removed, it works ok. thesql= thesql + "'" + Caller + "'" + "," thesql=thesql + "'" + Ph + "'" + "," + "'" + Sch + "'" + "," thesql=thesql + "'" + Loc + "'" + "," + "'" + JbDes + "'" thesql=thesql + "," + "'" + JbPr + "'" + "," + "'" + LogN + "'" + "," + "'" + logdate + "'" + "," + "'" + "n" + "'" thesql=thesql + backpar thesql='"""' + thesql + '"""' thesql=frontpar + thesql + backpar thecode='crsr.execute' + thesql . . exec(thecode) Any suggestions as to what I am doing wrong?? Thanks in advance for any assistance. Rico -------------- next part -------------- An HTML attachment was scrubbed... URL: From culliton at clark.net Wed Apr 7 17:38:31 1999 From: culliton at clark.net (Tom Culliton) Date: Wed, 7 Apr 1999 21:38:31 GMT Subject: Cygnus Java Compiler and JPython Message-ID: <199904072138.RAA25670@shell.clark.net> Having just seen the announcement for the "Cygnus GNU Compiler Java(tm) Edition (GCJ)" I immediately wondered if anyone here has tried compiling JPython with it yet? Sounds like an interesting experiment... If it works any thoughts on the speed vs. CPython? A story on the GCJ announement can be seen at: http://www.newsalert.com/bin/story?StoryId=CnWRyqbKbytaXotq From mal at lemburg.com Wed Apr 7 19:01:20 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 7 Apr 1999 23:01:20 GMT Subject: Looking 4 C extention examples References: <7egdv0$2at$1@news.gte.com> Message-ID: <370BE3C0.1ABD6052@lemburg.com> Justin Development wrote: > > I'm looking for some C extention examples and their associated Python > modules to help me learn more about Python extending. Have a look at the C files in the Modules/ subdir of the Python source distribution, esp. the xxmodule.c boiler plate should be of interest. If that's not enough, surf the contrib section on www.python.org. Cheers, -- Marc-Andre Lemburg Y2000: 268 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From tim_one at email.msn.com Tue Apr 27 23:06:22 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 28 Apr 1999 03:06:22 GMT Subject: smtplib hang on send "data " to MS SMTP server In-Reply-To: <7g5euo$m7e$1@nnrp1.dejanews.com> References: <7g5euo$m7e$1@nnrp1.dejanews.com> Message-ID: <000601be9124$1846dce0$29a02299@tim> [max at rightworks.com] > code which works fine with netscape SMTP mail server, fails (hangs) when > attempting to send mail to a MicroSoft SMTP server. In the > module following the call to putcmd("data") the data() calls getreply > and never returns. Does anyone have an idea what is happening here? The > server seems to work with other clients. thanks max Try posting a complete executable failing example? If you're not going to track it down, you need to pass on enough info so someone else can <0.9 wink>. MS SMTP servers in my experience follow the most restrictive possible reading of the protocol specs, and will just sit there if you e.g. so much as include an extraneous blank. Also be clear about which version of Python you're using, and which OS. smtplib.py has changed a *lot* since 1.5.1 (have you tried 1.5.2?). upgrading-is-a-cure-for-many-ills-ly y'rs - tim From bernhard at alpha1.csd.uwm.edu Mon Apr 5 20:23:42 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 6 Apr 1999 00:23:42 GMT Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <3700528A.3F0C047D@Lugoj.Com> <009e01be7a80$b20299b0$f29b12c2@pythonware.com> Message-ID: On 01 Apr 1999 14:56:28 +0200, Lars Marius Garshol wrote: >* Fredrik Lundh >| He's not alone: according to an article I just read, anything that >| is not written in SGML will disappear within 50 years. > >Fredrik, can you read your word processing documents from 1986 today? >I can't. And yet SGML would present no problem today, at least not >after 30 minutes of DSSSL hacking. .dvi and text sources work just fine. Bernhard From john.michelsen at gte.net Wed Apr 7 13:06:36 1999 From: john.michelsen at gte.net (John Michelsen) Date: Wed, 7 Apr 1999 10:06:36 -0700 Subject: askyesnocancel in tkMessageBox References: <199904062020.QAA05784@python.org> <199904062043.QAA21700@eric.cnri.reston.va.us> Message-ID: <7eg1g9$nem$1@news-2.news.gte.net> >- /Fredrik Lundh is responsible for *documenting* Tkinter, but not for >its maintenance (although he contributed a bunch of support modules). >The maintenance of Tkinter is strictly my responsibility. (Not that I >asked for it. :-) Could you put the following function in tkMessageBox then?: def askyesnocancel(title=None, message=None, **options): "Ask a question; return yes, no, or cancel" return apply(_show, (title, message, WARNING, YESNOCANCEL), options) I use it in a standard "closing the document" function so that the user can close with saving, without saving, or cancel the close. Thanks, John From aa8vb at vislab.epa.gov Fri Apr 30 13:40:46 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 30 Apr 1999 17:40:46 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world In-Reply-To: <3729E647.B38DFE72@appliedbiometrics.com>; from Christian Tismer on Fri, Apr 30, 1999 at 07:20:07PM +0200 References: <7g9qmo$luf$1@news.udel.edu> <372965CA.2B3FD2FE@appliedbiometrics.com> <19990430080805.B776752@vislab.epa.gov> <3729A9F3.75B2692B@appliedbiometrics.com> <19990430101215.A806665@vislab.epa.gov> <3729CD92.43477316@appliedbiometrics.com> <19990430130807.A812795@vislab.epa.gov> <3729E647.B38DFE72@appliedbiometrics.com> Message-ID: <19990430134046.A807445@vislab.epa.gov> Christian Tismer: |Randall Hopper wrote: |> |> Base class A calling subclass B's method M without declaring a virtual |> method M itself is very perverse IMO. ... |> Accessing attributes of a sibling base class united by a future subclass? ... |We were not talking style or how to do things, but theory. Existing code |would break. Point taken. No argument there. I was a bit surprised to hear some folks are doing such things, but I suppose if a semantic is possible in a language, there will always be someone who will use it. Randall From andrew at starmedia.net Tue Apr 20 14:06:31 1999 From: andrew at starmedia.net (Andrew Csillag) Date: Tue, 20 Apr 1999 18:06:31 GMT Subject: Problems with mod_pyapache and cPickle Message-ID: <371CC227.5BDF5C5A@starmedia.net> When using mod_pyapache, an interpreter is initialized and finalized for each request. The problem is when using cPickle for serialization, cPickle, upon unpickling, creates a cache of objects that it loads out of modules so that it doesn't have to repeatedly import modules to get at classes it has already de-serialized, which is cool. The problem is that when the second time (in a different interpreter than the first) that cPickle is loaded, it's class cache still references classes from the first interpreter, which when used, causes all sorts of problems since their __builtins__ module has been wrecked and all it's external module references are now wrecked too, making them virtually unusable. I don't believe that this problem is specific to the cPickle module, but is problematic for any C module that contains references to python objects (C objects appear to be immune). For the cPickle module, I've written a patch to make it work correctly, but it requires a python wrapper module to make it "transparent". What I did is this: made a module function that destroys the class cache (called class_map in the code), and creates a new, empty one. Then, I have a wrapper module that imports cPickle and calls the function to clear the cache. -- Added this function to cPickle.c: -- static PyObject* clear_map(PyObject *self, PyObject *args) { PyObject *new_map; PyObject *old_map; /* check arguments */ if (!PyArg_ParseTuple(args, "")) return NULL; /* try to create a new dict */ new_map=PyDict_New(); if (!new_map) return NULL; old_map=class_map; class_map=new_map; Py_DECREF(old_map); Py_INCREF(Py_None); return Py_None; } -- and added this to the cPickle_methods structure in cPickle.c -- {"clear_map", (PyCFunction)clear_cache, 1, "clear_map() -- clear the class map\n" }, -- Then the simple python wrapper module -- import cPickle cPickle.clear_map() -- This alleviates the problem and makes it work. Outside of not finalizing interpreters (which alleviates it somewhat, but makes the code run in restricted mode since __builtins__ of the unpickled objects isn't the same as the "current" __builtins__), I don't know of any other way to fix this. This is likely an issue in other apps that use multiple interpreters and use C extensions which maintain references to python objects also. Might there be a way (although likely not trivial) to fix this for all cases? -- "There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence." - Jeremy S. Anderson From desb at desb.demon.co.uk Sat Apr 24 08:28:29 1999 From: desb at desb.demon.co.uk (Des Barry) Date: Sat, 24 Apr 1999 13:28:29 +0100 Subject: webchecker on Windows Message-ID: Hi, I have just recently downloaded 1.5.2(final) and tried to use webchecker on a local file tree. I am unable to get it to work - as it did in 1.5.2b2 (with a patch applied to urllib) The arguments to webchecker that I use are: -x file:///D|/test1/test2/index.htm this does not find the file! -x file:/D|/test1/test2/index.htm this is able to read the file but not able to process any links contained in the file (all local links are internally created like file:xxx.htm) What am I doing wrong? -- Des Barry From mal at lemburg.com Tue Apr 27 10:31:19 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 27 Apr 1999 16:31:19 +0200 Subject: Designing Large Systems with Python References: Message-ID: <3725CA37.2027327D@lemburg.com> David Steuber wrote: > > Over my programming life, I have used a 'cowboy' programming style. > Once I have a general idea for a solution to a problem, I start > coding, using the text editor as sort of an etch-o-scetch. This works > fine for programs under about 10klocs (thousand lines of code), but it > is rather fragile and doesn't hold up to larger programs or the > requested additions of un-anticipated features. > > I've noticed the acedemic and industry attempts to solve the problem. > OOA/OOD, UML, design patterns, et al are all proposed solutions. > ... > > What I am wondering about is the suitability of Python for specifying, > a large system and building a prototype. I have gotten myself rather > entrenched in the cowboy style and I would love it if Python supported > that for larger systems. Not sure what your "cowboy" style looks like, but Python is just great for designing well-organized OO apps with components using pattern paradigms [...add all your favorite buzzwords here...]. Projects around 50k are still well manageable using an editor like Xemacs; larger projects probably need the help of systems like SNIFF (which offers Python support). -- Marc-Andre Lemburg Y2000: 248 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From geoff at elj.com Mon Apr 5 11:07:20 1999 From: geoff at elj.com (geoff at elj.com) Date: Mon, 05 Apr 1999 15:07:20 GMT Subject: newbie questions (Python vs. Perl) References: <37082E26.A9445E43@earthlink.net> Message-ID: <7eajj2$qe7$1@nnrp1.dejanews.com> In article <37082E26.A9445E43 at earthlink.net>, Phil Voris wrote: [..] > I've been using Perl for several months and don't find its syntax > troublesome. I like its speed considering I don't have to use C > constructs (and memory management). I'm considering learning Python for > several reasons; but have questions and concerns: > > 1) I hear it's the best for learning OO. I have heard high praise of > Eifel as well, but information on it seems to be scarce at best. (I > have C and Perl experience) Starting from http://www.elj.com/ (elj.com - Eiffel Liberty) you can find all kinds of information relating to Eiffel, Perl, Python and open source software. In relation to Eiffel, the following might help with the information scarcity problem (which seems a common perception). -- For Python see: http://www.python.org/ -- For Perl see: http://www.perl.com/ For Eiffel .. Online Books/Papers: -------------------- * Object-Oriented Software Engineering with Eiffel by Jean-Marc Jezequel http://www.irisa.fr/pampa/EPEE/book.html -- (This is my pick ..) -- NB: The first 4 chapters are available here in pdf format: -- http://www.irisa.fr/pampa/EPEE/oosewe.pdf * Object-Oriented Programming in Eiffel by Robert Rist http://www-staff.socs.uts.edu.au/~rist/eiffel/ -- There are two main sections in the Online Eiffel book which -- are The language and Case study. You may read through The -- language part first then look at the Case study for examples -- of each topic covered in The language. * An Invitation to Eiffel by Bertrand Meyer http://www.eiffel.com/doc/manuals/language/intro/ -- on-line introduction to the Eiffel method and language. This -- material was derived from chapter 1, An Invitation to Eiffel, -- of the book Eiffel: The Language, the official reference on -- Eiffel, published by Prentice Hall and available from bookstores -- as well as from ISE. * Eiffel: An Advanced Introduction by Alan A. Snyder and Brian N. Vetter http://www.elj.com/eiffel/intro/ * Into Eiffel by Ian Joyner http://www.elj.com/eiffel/ij/into-eiffel/ij-into-eiffel.pdf * An Eiffel Overview by Richard Paige http://www.elj.com/eiffel/rp/eiffel-overview.pdf -- see also summary of BON: http://www.elj.com/eiffel/rp/bon-intro.pdf * Downloadable Eiffel Papers page: collated by Roger Browne http://www.eiffel.tm/papers.htm * Why Eiffel? by Todd Plessel http://www.elj.com/eiffel/why-eiffel/ Books: ------ * Eiffel, The Language by Bertrand Meyer http://www.eiffel.com/doc/documentation.html#etl * Object Oriented Software Construction 2nd Edition by Bertrand Meyer http://www.eiffel.com/doc/oosc.html * for more books .. http://www.eiffel.com/doc/ Eiffel Langugage: ----------------- Controlled by the Non-Profit International Consortium for Eiffel (NICE): http://www.eiffel-nice.org/ Eiffel Portability Issues: http://www.gobo.demon.co.uk/eiffel/gobo/portability/ Contributed documentation: * Eiffel, The Language by Bertrand Meyer http://www.eiffel.com/doc/documentation.html#etl * Eiffel: The Syntax by Eric Bezault http://www.gobo.demon.co.uk/eiffel/syntax/ * Eiffel Syntax Diagrams ftp://eiffel.com/pub/doc/language/diagrams.ps.gz * Eiffel Kernel Library Standard 1995 http://eiffel.com/doc/manuals/library/elks/ http://www.gobo.demon.co.uk/eiffel/nice/elks95/ * Eiffel Style Guide by Bertrand Meyer (from OOSC) http://eiffel.com/doc/manuals/language/style/ * Eiffel: The Reference http://www.wiwi.uni-karlsruhe.de/info/doc/eiffel_ref/ -- Roger writes .. ``Prepared by Neil Wilson as a -- proposed update to Bertrand Meyer's "Eiffel The Reference" - -- but NICE chose not to pursue it. Neil logged his -- changes, which include some pointers to parts of -- the specification worth reviewing. Some language extensions include: * Precusor [All vendors have implemented this proposal]: http://www.eiffel.com/doc/manuals/technology/language/precursor/ http://www.eiffel.com/doc/manuals/technology/language/precursor/formal.html * [Proposed] Tuples: http://eiffel.com/doc/manuals/language/tuples/page.html * [Proposed] Creating objects of formal generic types http://eiffel.com/doc/manuals/language/generic-creation/page.html * [Proposed] Agents, introspection and iterators: http://eiffel.com/doc/manuals/language/agent/page.html Eiffel Compilers: ----------------- Eiffel Forum has a page titled ``Tools for Eiffel Developers'' here: http://www.eiffel-forum.org/archive/tools.htm There should be a compiler there to fit your needs. Eiffel Libraries: ----------------- The Eiffel Forum Archive: http://www.eiffel-forum.org/archive/category.htm Two libraries that you can learn much from are: * Eric Bezault's GOBO Eiffel Project (includes an Eiffel lex, yacc and data structures libraries): http://www.gobo.demon.co.uk/eiffel/gobo/ * Pylon: a compact foundation library for writing portable Eiffel software and libraries. http://www.altsoft.demon.co.uk/free/pylon.html An excellent description of the Eiffel Conventions used in Pylon is provided here: http://www.altsoft.demon.co.uk/doc/pylonA.html Eiffel Projects: ---------------- http://www.eiffel.com/eiffel/projects/list.html http://www.eiffel.com/eiffel/projects/hp/creel.html http://www.elj.com/eiffel/projects/ Web sites?: ----------- * Eiffel Forum: http://www.eiffel-forum.org/ * elj.com (Eiffel Liberty): http://www.elj.com/ -- to all things Eiffel, plus a bit more .. -- There are dozens of sites to explore from elj.com [Some other sites/papers ..] ---------------------------- * Getting acquainted with Eiffel by Cameron Laird and Kathryn Soraiz (in SunWorld's Nov 98 Issue) http://www.sunworld.com/swol-11-1998/swol-11-regex.html#2 * Eiffel for Native Speakers of C++ by Patrick Doyle (C++ Report Mar 99 Issue) -- [An article to help] demystify some of the major concepts -- of the [Eiffel] language, including Design by Contract, -- Command-Query Separation, and multiple inheritance, by -- casting them in terms that C++ programmers can readily -- embrace. * Eiffel vs C++ (in 1989) by Bertrand Meyer http://www.elj.com/eiffel/bm/eiffelvscpp89/ * Design by Contract by Todd Plessel http://www.elj.com/eiffel/dbc/ * C++?? Critique (Version 3) by Ian Joyner http://www.elj.com/cppcv3/ -- an updated book version is due mid-year from Prentice-Hall * Collective Hypnosis: Avoiding the Second Historic Mistake by Bertrand Meyer http://www.elj.com/eiffel/bm/mistake/ * A critique of Java by Harold Thimbleby http://www.cs.mdx.ac.uk/harold/papers/javaspae.html * Bertrand Meyer (Eiffel's main designer) http://www.elj.com/eiffel/bm/ * Ian Joyner http://www.elj.com/eiffel/ij/ -- particularly - http://www.elj.com/eiffel/ij/correctness/ Finally, for fun: ----------------- * Academic Programmers - A Spotter's Guide by Pete Fenelon http://www.ee.ryerson.ca/~elf/hack/academic.html > Will Python take me to the next level in terms of understanding OO? For sure .. so will Perl (perltoot[1] did it for me [2,3]) and even Eiffel. [1] perltoot: http://www.perl.com/CPAN/doc/manual/html/pod/perltoot.html [2] Realtime (30 min) Weather: http://www.tg.nsw.gov.au/nem/realtime/weather/all/ [3] Realtime ( 5 min) Electricity Prices: http://www.tg.nsw.gov.au/nem/realtime/ppsd/all/ Geoff Eldridge -- ``Eiffel: Do what you want, when you want'' -- email: geoff at elj.com -- elj-daily: http://www.elj.com/new/ -- daily Eiffel news, plus more .. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From tim_one at email.msn.com Wed Apr 28 01:24:23 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 28 Apr 1999 01:24:23 -0400 Subject: FP exception, core dump in Python 1.5.2 (Tim's doing ) In-Reply-To: Message-ID: <000201be9137$5ffb8320$899e2299@tim> [Tim, suggests some code to generate INFs and NANs] > ... [Mark Favas tries it, and...] > On my platform, (DEC Alpha, Digital Unix 4.0D, Python 1.5.2) I > get... a core dump! (exclamation because it's one of the few Python > core dumps I've seen). Excellent! Here's one of your problems: > DEC Alpha and here's the other : > Digital Unix > [code modified to print i, x, x2] > > python ieee.py > 0 2.0 4.0 > 1 4.0 16.0 > 2 16.0 256.0 > 3 256.0 65536.0 > 4 65536.0 4294967296.0 > 5 4294967296.0 1.84467440737e+19 > 6 1.84467440737e+19 3.40282366921e+38 > 7 3.40282366921e+38 1.15792089237e+77 > 8 1.15792089237e+77 1.34078079299e+154 > Floating exception (core dumped) Well, the next step is to square 1.3e154, and that will create an infinity on an IEEE-754 conformant machine (the square is too big to fit in an IEEE double). Your platform apparently triggers an unmasked IEEE (not Python) Overflow exception instead, and your OS decides that's fatal. That means your platform violates the 754 std in two ways, and, as advertised, ieee.py raises an exception to gently inform you of that . Presumably if you scrounge around long enough, you'll find the software incantation you need to make your platform pretend to be 754 conformant. There's not much use in trying to muck with 754 features so long as it's not! Nothing Python can do about it on its own, either, short of simulating 754 arithmetic in software. > ... > 9 PyNumber_Multiply(0x1400b2988, 0x1400b13c0, 0x1400b13c0, > 0x0, 0x3) [0x12006f400] > (dbx) Oh ya. floating-point-is-its-own-reward-ly y'rs - tim From wtanksle at dolphin.openprojects.net Thu Apr 29 19:11:38 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 29 Apr 1999 23:11:38 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> <3727C1CD.83078225@easystreet.com> Message-ID: On Wed, 28 Apr 1999 19:19:57 -0700, Al Christians wrote: >> >Actually, isn't Eiffel's type system famous for being full of holes? >> I'm familiar with the covariance/contravariance argument, but I've never >> before heard anyone say anything about Eiffel being full of holes. What >> problems have you heard of? >I think it's called changing availability by type, or some such. No, CAT is a feature of any object system (never a bug). >It is >possible to delete a feature in a descendant class, leaving a hole in >polymorphic calls through the base class. This would be true, but feature deletion is not used for public interfaces. It's mainly used when you're treating inheritance as though it were 'import' (certainly a major weakness of Eiffel). It's true that you can abuse it by making that feature deletion public, but the type system could just as easily forbid you from doing any such thing (I have no idea whether it does). I think you were talking about Meyer's insistance on covariance. I would call that _one_ hole, albeit a strange one. It's certainly not enough to condemn it as full of holes -- its type system is in other ways quite robust. >Al -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From MGoehmann at t-online.de Mon Apr 12 13:50:56 1999 From: MGoehmann at t-online.de (Monika Göhmann) Date: Mon, 12 Apr 1999 17:50:56 GMT Subject: cygwin32-b20 _tkinter problem References: <371071b0.15953469@news.btx.dtag.de> <3711310F.65CA2C0A@mail.ncifcrf.gov> Message-ID: <37122f43.23780524@news.btx.dtag.de> On Sun, 11 Apr 1999 19:32:31 -0400, Robert Kern wrote: >Add -lexpect526 to the command line. Those symbols are only defined in >libexpect526.a of the cygwin B20.1 distribution. > >Hope that helps. > >[snip] > >-- >Robert Kern | Well yes, I did but got a myriad of error messages. I now do believe, you need to comment out a few lines in _tkinter.c. //#if TKMAJORMINOR < 8000 || !defined(MS_WINDOWS) //#define HAVE_CREATEFILEHANDLER //#endif Cygwin does not define MS_WINDOWS, since it is kind of a "UNIX" system. Nevertheless the two functions which were giving me the error are not included ( other than in the expect526.a which does not work ) With this change _tkinter.c does compile and link fine and IDLE, for example is running. I still do have lot's of problems with PATH settings, but that's another story. Thanks for your help, Monika G?hmann From perk at int.tele.dk Mon Apr 5 17:56:20 1999 From: perk at int.tele.dk (Per Knudsgaard) Date: Mon, 5 Apr 1999 23:56:20 +0200 Subject: Secure Python for embedding Message-ID: <7ebb3c$8jf$1@news.inet.tele.dk> Hi all, I have a situation where I would like to add a scripting language to the client of a client-server application. The server will, as part of the communication between client and server, provide the client with scripts to run. I would like it to be secure so I do not end in a situation where I expose the client machine to virae, Trojan horses or similar nasty things. In other words, I would like the scripts to be run in their own little "sandbox" environment. I have the embedding almost down, but what I have is a fully functional language within the client. Is there any way, without modifying the core Python code, that I can implement a secure scripting language using Python? -- Per. From philh at vision25.demon.co.uk Thu Apr 29 21:30:12 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Fri, 30 Apr 99 01:30:12 GMT Subject: % Message-ID: <925435812snz@vision25.demon.co.uk> Consider the % operator, eg: 'All %(a)s eat %(b)s' % {'a':'cows', 'b':'grass'} If the dictionary doesn't have all the relevant keys, an error occurs. Is it possible for me to change the behaviour of this so that if a key doesn't occur a default value of '' is assumed? -- Phil Hunt....philh at vision25.demon.co.uk From mwh21 at cam.ac.uk Fri Apr 16 08:10:56 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 16 Apr 1999 13:10:56 +0100 Subject: Imperfections in ihooks.py? Message-ID: I apologise for the lousy use of language in this post. It's a subject I find a bit confusing to think about, and I'm clearly not much better a writing about it. Does anybody out there use ihooks? I'm having a couple of problems. What I want to happen is to be able to import a file ending in some random extension (I've chosen '.om') apply some simple preproccessing to it, and then treat that preprocessing as a normal python module. I have a mostly working solution. I can import just fine, but reloading doesn't happen (for any module, not just mine) after I've installed a module importer. I've looked at the code, and this seems inevitable. Should this be changed? I could have a stab at it. On a related note, the import of '.pyc' files takes no notice of the timestamp in the file, so if you import a module that has a stale .pyc file, you get the stale version from the '.pyc' file, not the new version from the '.py' file. This would seem to be harder to fix. I can't see any consideration given to the possibility of rejecting a file once it's been found. These problems would cause no grief once a program is finished, but they make a bit of a mess of development. Turns out the first problem is easy to fix: --- ihooks.py 1999/04/15 08:19:46 1.1.1.1 +++ ihooks.py 1999/04/16 12:08:41 @@ -489,6 +489,7 @@ def reload(self, module): name = module.__name__ if '.' not in name: + self.unload(module) return self.import_it(name, name, None) i = string.rfind(name, '.') pname = name[:i] which does the trick for simple modules. Packages just make my head hurt a bit at the moment. Anybody have any ideas what I could do to improve my situation? If I make some changes to fix them, would there be a chance of getting them into the distribution? Thanks for reading Michael From aahz at netcom.com Thu Apr 22 16:11:00 1999 From: aahz at netcom.com (Aahz Maruch) Date: Thu, 22 Apr 1999 20:11:00 GMT Subject: Jobs and Python (was Re: What is it ? How can I learn it ? Where should I start ? What can you do with it ?) References: <371F7DB9.E7E48A82@callware.com> Message-ID: In article <371F7DB9.E7E48A82 at callware.com>, Ivan Van Laningham wrote: > >PS: And just *where* is this job that (I should be so lucky) *REQUIRES* >you to know Python???????? Why aren't they calling ME???? I advertised such a job a couple of months ago, on the lower peninsula in the SF Bay Area. We still have openings if anyone is interested. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "You often don't really understand the problem until after the first time you implement a solution." - Eric S. Raymond From fredrik at pythonware.com Mon Apr 19 04:14:46 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 19 Apr 1999 08:14:46 GMT Subject: Plugins, or selecting modules to import at runtime References: <924379180.825429211@news.intergate.bc.ca> Message-ID: <017201be8a3e$d327a9f0$f29b12c2@pythonware.com> Gerald Gutierrez wrote: > I'd like to write a program in Python in which the user can select one of > several modules to execute through a function that has the same name in all the > modules. I don't believe "import" lets me pass it a string. There is also > reload(), but the module to reload must be previously imported. > > This is very similar to plugins like that used in Netscape, Photoshop and the > GIMP. > > Can someone please give me a hint? module = __import__("module") also see: http://www.pythonware.com/people/fredrik/fyi/fyi06.htm From MGoehmann at t-online.de Sun Apr 11 06:33:19 1999 From: MGoehmann at t-online.de (Monika Göhmann) Date: Sun, 11 Apr 1999 10:33:19 GMT Subject: cygwin32-b20 _tkinter problem Message-ID: <371071b0.15953469@news.btx.dtag.de> When I try to compile python-1.5.2b2 under WinNT with Cygwin32-B20 it works very well without Tk-Module. But when I try to include Tk, I get the following messages: gcc python.o \ ../libpython1.5.a -ltix4180 -ltk80 -ltcl80 -lstdc++ -lm -lm -o python ../libpython1.5.a(_tkinter.o): In function `Tkapp_CreateFileHandler': //c/temp/Python-1.5.2b2/Modules/./_tkinter.c:1459: undefined reference to `Tcl_CreateFileHandler' ../libpython1.5.a(_tkinter.o): In function `Tkapp_DeleteFileHandler': //c/temp/Python-1.5.2b2/Modules/./_tkinter.c:1486: undefined reference to `Tcl_DeleteFileHandler' ../libpython1.5.a(_tkinter.o): In function `EventHook': //c/temp/Python-1.5.2b2/Modules/./_tkinter.c:1913: undefined reference to `Tcl_CreateFileHandler' //c/temp/Python-1.5.2b2/Modules/./_tkinter.c:1943: undefined reference to `Tcl_DeleteFileHandler' collect2: ld returned 1 exit status make[1]: *** [link] Error 1 make: *** [python] Error 2 My Modules/Setup looks like this # *** Always uncomment this (leave the leading underscore in!): _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ # *** Uncomment and edit to reflect where your Tcl/Tk headers are: # -I/usr/local/include \ # *** Uncomment and edit to reflect where your X11 header files are: # -I/usr/X11R6/include \ # *** Or uncomment this for Solaris: # -I/usr/openwin/include \ # *** Uncomment and edit for Tix extension only: -DWITH_TIX -ltix4180 \ # *** Uncomment and edit for BLT extension only: # -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \ # *** Uncomment and edit for PIL (TkImaging) extension only: # -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \ # *** Uncomment and edit for TOGL extension only: # -DWITH_TOGL togl.c \ # *** Uncomment and edit to reflect where your Tcl/Tk libraries are: # -L/usr/local/lib \ # *** Uncomment and edit to reflect your Tcl/Tk versions: -ltk80 -ltcl80 \ # *** Uncomment and edit to reflect where your X11 libraries are: # -L/usr/X11R6/lib \ # *** Or uncomment this for Solaris: # -L/usr/openwin/lib \ # *** Uncomment these for TOGL extension only: # -lGL -lGLU -lXext -lXmu \ # *** Uncomment for AIX: # -lld \ # *** Always uncomment this; X11 libraries to link with: # -lX11 -lstdc++ Tcl/Tk header and libs are in the Cygwin32-directories and the compiler finds them. Since I have no idea, what is the equivalent of X11 under Cygwin, I used libstdc++. Is this the problem ? From fredrik at pythonware.com Tue Apr 13 03:26:50 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 13 Apr 1999 07:26:50 GMT Subject: Converting a string to a tuple References: <01be8530$65bb7120$52037e81@saints> <14098.28727.245158.616727@buffalo.fnal.gov> Message-ID: <00f501be857f$ff636f40$f29b12c2@pythonware.com> Charles G Waldman wrote: > If you're concerned about safety (the "eval" could be evaluating any > Python code, possibly a hazard if the string is coming from user > input) then you don't want to use eval at all. try: result = eval(string, {"__builtins__": {}}) or: import rexec r = rexec.RExec() result = r.r_eval(string) From bwinton at tor.dhs.org Wed Apr 14 23:45:55 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Thu, 15 Apr 1999 03:45:55 GMT Subject: Novice Question: two lists -> dictionary References: <7f3j1v$f6j$1@nnrp1.dejanews.com> Message-ID: On Thu, 15 Apr, jwtozer at my-dejanews.com wrote: >How do I make the members of one list the key of a dictionary and the members >of a second list the members of list values associated with with those keys? > >Given: >ListA = ['10', '10', '20', '20', '20', '24'] >ListB = ['23', '44', '11', '19', '57', '3'] > >Desired Result: >Dict = {'10': ['23','44'],'20': ['11','19','57'], '24': ['3']} > >Any help will be much appreciated. Just off the top of my head, (after some playing around, cause it's sooo easy to do with Python. :) Dict = {} for i in range(len(ListA)): try: Dict[ListA[i]].append(ListB[i]) except KeyError: Dict[ListA[i]] = [ListB[i]] This gives us Dict = {'24': ['3'], '10': ['23', '44'], '20': ['11', '19', '57']} I think you could write a sort function of some sort if you really needed to get the elements in order, but it would probably just be easier to use: x = Dict.keys() x.sort() for i in x: print i, "=", Dict[i] And I'm sure there's an easier way to do it, as well as a way involving map and or reduce, but it's been a while since I've programmed functionally, so I'm not going to try. # ignore the following code. def myfunc( key, value ): global Dict try: Dict[key].append(value) return "got it" except KeyError: Dict[key] = [value] return "need it" map( myfunc, ListA, ListB ) Hope this helps, Blake. -- I speak for PCDocs http://www.cluetrain.com/ From human at netteens.net Thu Apr 22 12:20:53 1999 From: human at netteens.net (Humans) Date: Fri, 23 Apr 1999 00:20:53 +0800 Subject: Here is which country newsgroup ? Message-ID: <7fku3a$7fu$1@imsp026.netvigator.com> as title From debot at xs4all.nl Wed Apr 14 11:56:17 1999 From: debot at xs4all.nl (Frank de Bot) Date: Wed, 14 Apr 1999 17:56:17 +0200 Subject: Tutorial Python Message-ID: <3714BAA0.12F180F3@xs4all.nl> Does somebody knows a good tutorial on the internet especialy for python - CGI Aplications. Currently I have several websites running on PERL (As you can see at the bottom of this mail). Currently the searchengine has 4100 sites and it takes about 0.80 cpu to search. This is now not a problem, because I rarely get visitors. But I realy like to get something that's working fast and good. (Ps I've already checked python.org, but they aren't giving any examples (And I need them hard to understand the language)) Thanks in advance... Frank de Bot. -- \\\|/// \\ - - // ( @ @ ) /----------------------oOOo-(_)-oOOo--------------------\ | | | | | My Email: debot at xs4all.nl | | Homepages: http://www.searchy.net/ | | http://www.debot.nl/ppi/ | | | | | \-------------------------------Oooo--------------------/ oooO ( ) ( ) ) / \ ( (_/ \_) From tseaver at palladion.com Fri Apr 23 09:05:09 1999 From: tseaver at palladion.com (Tres Seaver) Date: Fri, 23 Apr 1999 08:05:09 -0500 Subject: Time complexity of dictionary insertions References: <371F2125.BEC5F892@fzi.de> <7fo08u$4j2$1@nnrp1.dejanews.com> Message-ID: <37207005.1CC60E1B@palladion.com> tim_one at email.msn.com wrote: > > In article <371F2125.BEC5F892 at fzi.de>, > Oliver Ciupke wrote: > > As I understood from the Python documentation, dictionaries are > > implemented as extensible hash tables. > > Yes. > > > What I didn't find either in the references or in the FAQ is: what is > > the actual time complexity for an insertion into a dictionary? > > Min O(1), Max O(N), Ave O(1). If the hash function is doing a terrible job > (e.g. maps every key to the same hash value), make those all O(N). C++ STL junkies know this as "amortized constant time". ========================================================= Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From arcege at shore.net Thu Apr 22 08:51:56 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 22 Apr 1999 12:51:56 GMT Subject: stdout in a restricted environment References: <7fn3rs$1v9$1@whisper.globalserve.net> Message-ID: Chris AtLee wrote: : I'm trying to make a program that will enable users to connect to a server : running a python interpreter and be able to program in a restricted : environment in that interpreter. The rexec object has methods called s_exec : and s_eval which are supposed to use secure forms of the standard I/O : streams, but I can't redefine them to be something else (specifically, an : object that sends the response back to the client) Any pointers on how to : go about redirecting the standard I/O streams from a restricted environment? I would suggest making a subclass of RExec that redefines the make_delegate_files method. def __init__(self, socket, hooks = None, verbose = 0): RExec.__init__(self, hooks=hooks, verbose=verbose) self._data_socket = socket def make_delegate_files(self): reader = self._data_socket.makefile('r') writer = self._data_socket.makefile('w') s = self.modules['sys'] self.delegate_stdin = FileDelegate(s, 'stdin') self.delegate_stdout = FileDelegate(s, 'stdout') self.delegate_stderr = FileDelegate(s, 'stderr') self.restricted_stdin = FileWrapper(reader) self.restricted_stdout = FileWrapper(writer) self.restricted_stderr = FileWrapper(writer) Granted, I haven't tried this, but it looks correct. :) Good luck. -Arcege From phd at sun.med.ru Tue Apr 27 10:49:38 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Tue, 27 Apr 1999 18:49:38 +0400 (MSD) Subject: PyApache problem (was -- Re: Cross-references between dynamically loaded modules under AIX) In-Reply-To: <19990427081109.C579158@vislab.epa.gov> Message-ID: Hello! Recenly I found a problem trying to use PyApache. I installed it on Sun (sparc-solaris), found it working nicely, and tried to install it on linux. I got an error in httpd error_log: Traceback (innermost last): File "xxx.py", line 3, in ? import cgi File "/usr/local/lib/python1.5/cgi.py", line 422, in ? import urllib File "/usr/local/lib/python1.5/urllib.py", line 25, in ? import socket ImportError: /usr/local/lib/python1.5/lib-dynload/socketmodule.so: undefined symbol: _Py_NoneStruct I recompiled PyApache with different options. Sometimes it works, sometimes it files again with the same error. Anyone understand what is going on and how to make PyApache stable? (on all my systems - sun, redhat 5.1 and debian 2.1 - there is python 1.5.1 and apache 1.3.4; recently I upgraded to python 1.5.2 and apache 1.3.6, but nothing changed - the same problem with dynamic loading) On Tue, 27 Apr 1999, Randall Hopper wrote: > Not knowing NumPy, my assumption is you are failing on a .so-to-.so module > dynamic link. If so... [skipped] > Randall Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From davidh at progmatics.com.au Wed Apr 14 22:19:06 1999 From: davidh at progmatics.com.au (David Hobley) Date: Thu, 15 Apr 1999 12:19:06 +1000 Subject: How libpython1.5.so References: <371320F4.5338600B@earth.ox.ac.uk> <14100.50513.166352.167346@amarok.cnri.reston.va.us> Message-ID: <37154C9A.44DB755B@progmatics.com.au> "Andrew M. Kuchling" wrote: > Nick Belshaw writes: > >Whilst trying to get Python plugins to work on Gnumeric-0.23 I bumped up > >against the need for libpython1.5.so.0.0.0 > > Python doesn't build a .so file, so I think the Gnumeric Is there any reason it doesn't? It is stunningly useful when building arbitrary extensions as you can build them shared and not have to relink python. Or am I misunderstanding something? The last time I built the pykde stuff for FreeBSD I ran into this and ended up hacking together a libpython1.5.so which solved all my linking problems. -- Cheers, david davidh at progmatics.com.au Progmatics Pty Ltd - Architects of IT and Internet Solutions Level 8, 191 Clarence Street Phone +61 2 9262 4933 Sydney NSW Australia Fax +61 2 9262 4045 http://www.progmatics.com.au/ From bwarsaw at cnri.reston.va.us Fri Apr 2 17:06:44 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Fri, 2 Apr 1999 17:06:44 -0500 (EST) Subject: Changes to this list Message-ID: <14085.16244.835438.347220@anthem.cnri.reston.va.us> Folks, Breaking Warsaw's Second Law of Hackputing[*], I am making the following changes to python-list at python.org. This message will only be seen by you poor saps^H^H^H^H^H^H^H^H^Hlucky souls who are subscribed via email; it is not going out to Usenet (I hope ;-). First, I'm pointing the news host for the list to an internal NNTP machine instead of the Alternet feed. This is partially to test our internal server and also because our NNTP machine has a /much/ longer expiry for c.l.py and c.l.py.a so it'll be easier for me to use for debugging. I plan to run the real list off of our internal server when this thing goes live. Second, I've installed what will be Mailman 1.0b11. I believe this fixes the Usenet archiving bug that Wesley reported. On the downside, it's too hard to fix the old archives, so I've essentially just blown them away. Once I turn gating back on, the new archives should be much better. I'd like to let this run for about a week, and then start coordinating with Sjoerd on migration issues. Enjoy, -Barry [*] WSLH: "Never change anything after 3pm on Friday." In totally flaunting this law, I'm am right now heading out for at least 12 hours. I'm going to turn the gateway back on after this message goes out, but I'll show Guido how to shut it off, just in case ;-) From mal at lemburg.com Tue Apr 20 05:00:12 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 20 Apr 1999 09:00:12 GMT Subject: Python on multiple processor machines References: <7dv7t7$h96$1@nnrp1.dejanews.com> Message-ID: <371C421C.7610BAB4@lemburg.com> max at rightworks.com wrote: > > I would like to hear some insights to running Python apps on multi-processor > machines. We are developing an app a good deal of it in Python and there are > those amoungst us who predict that the Python interpreter would be forced to > effectively serialize it's processing in order to be thread safe if running > on a multi-processor machine. We could run multiple interpreters, but this > wouldn't provide the kind of scalability we need, and implies other problems > of dispatching etc. Our application does web based catalog management. I > need facts to keep me from becoming a Java programmer. thanks, max Don't know what platform you use, but on Unix you can easily get away with implementing a multi process model. Communication would be done via shared memory or sockets. The latter even buys you clustering in case IO should become a bottleneck. As for free threading, Greg Stein is working on that idea: http://www.lyra.org/~greg/ (I think it was). -- Marc-Andre Lemburg Y2000: 255 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From bernhard_mulder at ccm.sc.intel.com Fri Apr 16 17:11:12 1999 From: bernhard_mulder at ccm.sc.intel.com (Bernhard Mulder) Date: Fri, 16 Apr 1999 14:11:12 -0700 Subject: Pythonw IDLE Tab setting References: <3715C0A9.D57546B@connection.com> Message-ID: <3717A770.34CCEF8@ccm.sc.intel.com> Here are the changes I made to get an indent of 3: 78c78 < spaceindent = 3*" " --- > spaceindent = 4*" " 110,111c110,111 < if i == n and chars[-3:] == " ": < ndelete = 3 --- > if i == n and chars[-4:] == " ": > ndelete = 4 155c155 < line = line[:i] + " " + line[i:] --- > line = line[:i] + " " + line[i:] 171,173c171,173 < indent = indent[:-1] + " " < elif indent[-3:] == " ": < indent = indent[:-3] --- > indent = indent[:-1] + " " > elif indent[-4:] == " ": > indent = indent[:-4] 176c176 < indent = indent[:-3] --- > indent = indent[:-4] "Colin J. Williams" wrote: > The program AutoIndent.py has: > > prefertabs = 0 > spaceindent = 4*" " > > Should spaceindent be changed to 2 if one wishes the tabs to have > that value? > > Currently I use PythonWin which permits the user to change the Tab > value (incidentally, it also provides for breakpoints). > > Any advice would be appreciated. > > Colin W. From peteb at octave.demon.co.uk Thu Apr 8 07:22:36 1999 From: peteb at octave.demon.co.uk (Pete Becker) Date: Thu, 8 Apr 1999 12:22:36 +0100 Subject: Wanted: man2html, info2html Message-ID: Hi, As the subject says and having searched off http://www.python.org without much success, I'm looking for native Python (not Perl!) packages to convert man and info pages to html. Can be batch-oriented or on-the- fly CGI based. Many thanks for any info ;-) -- Pete Becker From morse at harborcom.net Wed Apr 14 10:27:41 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Wed, 14 Apr 1999 14:27:41 GMT Subject: Documentation for SIP C++ Wrapper Generator? Message-ID: <3714a549.185097135@news.oh.verio.com> Is there any documentation for Phil Thompson's C++ interface generator SIP? Is the module spec. the same as for SWIG? (I'm downloading the Qt bindings to use as an example.) Thanks........ From spamfranke at bigfoot.de Thu Apr 29 14:06:26 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Thu, 29 Apr 1999 18:06:26 GMT Subject: HTML "sanitizer" in Python References: <372a9bd7.21336470@news.omnilink.de> Message-ID: <372b9f60.22241571@news.omnilink.de> Oh, just saw a bug: On Thu, 29 Apr 1999 18:01:54 GMT, spamfranke at bigfoot.de (Stefan Franke) wrote: >source = open("/path/file.txt", "r") >dest = open("/path/file.txt", "w") One should use different filenames here of course. >Stefan From jeremy at cnri.reston.va.us Mon Apr 5 17:45:46 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Mon, 5 Apr 1999 17:45:46 -0400 (EDT) Subject: SNMPy update In-Reply-To: <7ear25$ksf$1@news-sj-3.cisco.com> References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> Message-ID: <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> I'll second your sentiment! I did some work on an X.509 library written entirely in Python. Like you friend's SNMP code, it will probably never be released; I don't have time to finish it nor did I expect that I'd want to release it given the export control hassles. However, it seemed clear to me that an ASN.1 compiler could be written to generate the encode/decode routines. If someone is interested in that, I've got some design notes and rough code on how to do the encode/decode and on how to build a backend for SNACC. (A free-ish ASN.1 compiler; the only one?) Jeremy From gmcm at hypernet.com Fri Apr 16 13:53:20 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 16 Apr 1999 17:53:20 GMT Subject: Imperfections in ihooks.py? In-Reply-To: References: Message-ID: <1287837093-4782027@hypernet.com> [Michael Hudson messes with ihooks and /F points him to Greg's imputil.py at http://www.lyra.org/greg/small/ ]: > Ah! Fantastic! > > Usual case; I start to think about a problem, ask about it and find > someone else has solved the problem already. > > Not perfection yet though - imputil.py contains these lines: > > def _reload_hook(self, module): > raise SystemError, "reload not yet implemented" > > which was one of the things I was moaning about in my post. Greg is being bad. First, that page hasn't been updated with the link to my installer (www.mcmillan-inc.com/install.html), and his imputil.py doesn't have my patch. Said patch doesn't implement reload, but it does at least determine whether the reload request is for a module under the hook's control. If not, it passes the request on. I looked at what it would take to implement reload. It didn't look _that_ bad. However, for my purposes (serving modules from an archive) it just didn't make much sense. I mean, we're talking about an alternative to freeze after all... Nits aside, imputil.py is a truly outstanding piece of code. - Gordon From tseaver at palladion.com Fri Apr 30 09:19:22 1999 From: tseaver at palladion.com (Tres Seaver) Date: Fri, 30 Apr 1999 08:19:22 -0500 Subject: Oracle Call Interface References: <7gb3hn$lse$1@nnrp1.dejanews.com> Message-ID: <3729ADDA.8E51C1D0@palladion.com> Jeffrey Chang wrote: > > > If anyone has experience writing applications directly to the Oracle Call > > Interface (OCI), in Python or JPython please send me examples or references on > > how to do it. > > Yuck! What are you planning to do? Do you really really need to write > directly to the OCI or can you use one of the available Oracle extension > modules? > > About a year ago, I used the oracledb module from Digital Creations with > Oracle7. It's very nice, but not optimized, and thus slow for large > queries. Since then, Digital Creations has made DCOracle > (http://www.digicool.com/DCOracle/; their commercial extension module) > open source, so I guess that will replace oracledb. I haven't looked at > it, but according to the FAQ, it's "much faster." > > I strongly advise you to use an extension module or JDBC if at all > possible. Writing to the OCI is extremely ugly -- all the stuff we try to > avoid by using python! ODBC/JDBC solutions suffer from "least-common-denominator" symptom; one can't easily exploit Oracleisms. I haven't played with DCOracle yet, but wrapping OCI into a nice Pythonic package would be a big win in some situations (passing array parameters to stored procedures is the one I most often want). -- ========================================================= Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From fw at cygnus.stuttgart.netsurf.de Tue Apr 27 15:10:42 1999 From: fw at cygnus.stuttgart.netsurf.de (Florian Weimer) Date: 27 Apr 1999 21:10:42 +0200 Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: andrew-johnson at home.com (Andrew Johnson) writes: > Just a point of clarification: Actually, perl programmer's > traditionally use 'exists' to test if a key is in a hash ... No, unfortunately that's wrong: | defined(EXPR) | | defined EXPR | Returns a boolean value saying whether the lvalue | EXPR has a real value or not. Many operations | return the undefined value under exceptional con- | ditions, such as end of file, uninitialized vari- | able, system error and such. This function allows | you to distinguish between an undefined null | string and a defined null string with operations | that might return a real null string, in particu- | lar referencing elements of an array. You may | also check to see if arrays or subroutines exist. | Use on predefined variables is not guaranteed to | produce intuitive results. Examples: | | print if defined $switch{'D'}; | [...] (Quotation from the Perl 4 manpage. This version doesn't have an `exists' function.) > using > 'defined' to test for key existence is a mistake---'defined' will > only tell you if that key exists and has a defined value associated > with it: Witness the defined test on key2 in the following: Of course you are right. That's the reason why `exists' was introduced -- I guess in Perl 5. From Richard.Jones at fulcrum.com.au Thu Apr 29 20:24:45 1999 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Fri, 30 Apr 1999 00:24:45 GMT Subject: GUI and creating GIF In-Reply-To: Message from Mike Steed of 1999-Apr-29 10:20:38, <372878C6.2CD3858A@natinst.com> References: <372878C6.2CD3858A@natinst.com> Message-ID: <199904300024.KAA14035@icarus.fulcrum.com.au> [Mike Steed] > > John Leach wrote: > > > > I'd also like to use gdmodule but I can't understand the documentation > > (I've emailed to ask Richard Jones for more docs). I'm new to Python. > > Does anyone have any sample programs they can send? > > You might look at Richard's httpd logfile reporting tool (graph.py uses > gdmodule). > > http://starship.python.net/~richard/httpd_log/ > > Also, below is a simple demo that used to be distributed with gdmodule, > although it doesn't appear to be on Richard's site anymore. I don't > have "demoin.gif", so you will have to tweak the code some.... I lost the code, docs and demo scripts about a couple of months ago. I'll put this demo script back up on the web page. "demoin.gif" comes with GD - but you could use any GIF image. graph.py is not something I'd point anyone to as sample code :) ... I'd feel much better pointing them to the PIL version which I wrote much more recently with a better design. Richard From arcege at shore.net Wed Apr 28 15:28:42 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 28 Apr 1999 19:28:42 GMT Subject: running application config files written in Python References: Message-ID: Nathan Froyd wrote: : Say I have an application whose configuration language I want to be : Python. I have all my extra types implemented in C. Now what I'm : wondering is what's the best way to run that file so that the : functions, variables, etc. get imported into the Python interpreter : embedded in my program? : Along the same lines, once I have run the file, what's the easiest way : to find out if a particular function/variable has been defined? For : example, if I always wanted to run the user-defined function : `startup_func', how would I go about doing that? You can do this in two ways easily (and other ways less easily). 1) Store the configuration files as modules, then import them. If you are worried about security, you can import them using rexec. char modulename[] = "app_config"; PyObject *config_module, *config_dict; PyObject *startup_func, *result; Py_Initialize(); if ((config_module = PyImport_ImportModule(modulename)) != NULL && (config_dict = PyModule_GetDict(config_module)) != NULL) { startup_func = PyDict_GetItemString(config_dict, "startup_func"); /* look for startup function, but ignore if not present */ result = NULL; if (startup_func != NULL && PyCallable_Check(startup_func)) result = PyObject_CallFunction(startup_func, ""); if ((startup_func == NULL || result == NULL) && PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_AttributeError)) /* ignore AttributeError exceptions */ PyErr_Print(); PyErr_Clear(); Py_XDECREF(startup_func); Py_XDECREF(result); } else { /* the module could not be loaded */ PyErr_Print(); Py_Exit(1); } All values are stored in the module (accessed thru config_dict). The exception handling is more verbose then the next method. 2) Run the equivalent of execfile(). char filename[] = "app_config.py"; FILE *app_config; Py_Initialize(); app_config = fopen(filename, "r"); if (PyRun_Simplefile(app_config, filename) == -1) { fclose(app_config); /* the traceback has already been written to stderr */ Py_Exit(1); } fclose(app_config); PyRun_SimpleString("try: startup_func()\n\ except NameError: pass\n"); All values are stored in the current namespace (the module __main__, and accessed thru the undocumented function PyEval_GetGlobals() or thru other PyRun_* calls). If there are exceptions raised, PyRun_* calls handle the output; the return value is either -1 for failure, 0 for success. I would suggest using method (1). Good luck. -Arcege From webmaster at python.org Mon Apr 12 14:27:48 1999 From: webmaster at python.org (webmaster at python.org) Date: 12 Apr 1999 14:27:48 -0400 Subject: ANNOUNCEMENT: Some Python Documentation in Hungarian language References: Message-ID: <61k8vhelsr.fsf@anthem.cnri.reston.va.us> >>>>> "HZ" == Hever Zsolt writes: HZ> I am writing my diploma work in Python. I made two enclosures HZ> to it and converted them into HTML format. Now I put them out HZ> on the Internet with a Python home page together all in HZ> Hungarian language. I hope this documentation will help Python HZ> to be better known in Hungary. Cool! I've added links to the Non-English resources page at http://www.python.org/doc/NonEnglish.html -Barry From wtanksle at dolphin.openprojects.net Thu Apr 29 22:59:54 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 30 Apr 1999 02:59:54 GMT Subject: while (a=b()) ... References: Message-ID: On Thu, 29 Apr 1999 16:48:39 -0700 (PDT), Nathan Clegg wrote: >I have some deep-rooted "hates" in programming and don't even know where >some of them came from. One of them is "while 1" loops. They seem >somehow at the same level as goto statements and should be used, in my >mind, about as rarely. I agree. Especially since while(1) loops require the use of a goto inside of them. >The ideal, of course, would be: >while (c = curs.fetchone()): ... I have done my own arguing for an assignment expression, but this I can't countenance. A while statement containing an explicit assignment isn't any kind of an ideal; it's a necessary evil. Thankfully, Python offers some ways around the problem -- making an object is one of them, and it results in the cleanest while statement (although I think it's too messy to stay in Python 2). Hopefully, Python 2 will offer some other ways -- I rather like Sather-K's notion of streams. >That is my only complaint about python, that statements cannot be >expressions. I've got some other complaints, but in spite of my complaints Python still is the easiest language I've worked with. I'm afraid that if they ever implement any of my suggestions the language will get way worse. :) >Nathan Clegg -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From lars.lone at post.tele.dk Wed Apr 7 14:12:27 1999 From: lars.lone at post.tele.dk (Lone H. og Lars G.) Date: Wed, 7 Apr 1999 20:12:27 +0200 Subject: Phyton x-windows GUI example needed Message-ID: <7eg741$5t1$2@news.inet.tele.dk> Hi' To get started with phyton x-windows GUI programming I would appreciate any code examples or references. Thanks. Lars From wware-nospam at world.std.com Sat Apr 10 19:17:29 1999 From: wware-nospam at world.std.com (Will Ware) Date: Sat, 10 Apr 1999 23:17:29 GMT Subject: Python for embedded controllers? References: <370de606.77891472@news.oh.verio.com> Message-ID: Ken McCracken (aa175 at torfree.net) wrote: : Neal Bridges in Toronto, Ont. has been developing an onboard Forth : compliler for the Pilot for a while. People seem pretty well enthused : about it and it is making converts to the Forth language and reattracting : programmers who had given up on Forth. The two things I like about Forth are (1) the interactivity, and (2) the interpreter is incredibly simple to understand; a bonehead like me can code one up. I very much applaud the work Mike Gorlick's group is doing, but it won't be interactive. Well, it won't be interactive out of the box, but interactivity could perhaps be added to it. An obvious approach is to implement a little language in Python, compile the little langugage interpreter, and load it onto the target board. I can imagine another possible approach, but I'm not clever enough to know if it's really feasible. Mike et al. are working on an implementation of the Python virtual machine, to run on a target board. Maybe a Python variant running on a host could have the parser and compiler without the VM, and run all its compiled code on the target's VM. The appeal of interactivity could be circumvented if one were to write Python classes that adequately simulated the target board (and where, necessary, the inputs and outputs from the real world). One could then interact with a simulation on the host, and in a perfect world, the code above the hardware simulation layer should port directly to the target board. Mike's team's effort would apply directly to this appproach. If one went with this development model, it would make sense to maintain the simulation and improve its accuracy as one developed one's application code, and had to find and fix progressively subtler bugs. In the aforementioned perfect world, there would be large open-source simulation libraries for popular microcontrollers' on-chip peripherals. -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Will Ware email: wware[at]world[dot]std[dot]com PGP fp (new key 07/15/97) 67683AE2 173FE781 A0D99636 0EAE6117 From patrick at ablecommerce.com Mon Apr 5 19:24:58 1999 From: patrick at ablecommerce.com (Patrick Curtain) Date: Mon, 05 Apr 1999 23:24:58 +0000 Subject: building python from the tarball on RedHat Message-ID: <3709464A.7C5F02D1@ablecommerce.com> Howdy All! Hopefully that subject will narrow down those looking at this message and save everyone some time. First, a confession. I've got a wierd (i think) linux setup. I'm running the RedHat 5.2 distribution, but I'm using several applications from source; I'm bypassing the RPM mechanism. This may be the cause of my troubles, but.... I want to be able to build from tar balls, so... I need to have my system setup to run apache (1.3.6), php3 (3.05) and MySQL (3.22.20a). Using the default RPM's for each of these didn't get me a working system in which php would talk to mysql. To make that much work, I downloaded the tar balls for each app, ungzip'd and did the usual ./configure; make; make install; process. Now I'm trying to get python working with MySQL from the source tar ball. I downloaded py152b2.tgz and did the same process to build it. When I run the interpreter and say 'import Mysqldb' it says 'ImportError: No module named Mysqldb'. I downloaded MySQLmodule-1.4.tar.gz, read the instructions and tried to build. I'm definitely new to building systems blind, but... irregardless of what I try, the 'make install' step (or 'make test' before that) gives the following: './python: error in loading shared libraries libmysqlclient.so.6: cannot open shared object file: No such file or directory make: *** [libinstall] Error 127' The file 'libmysqlclient.so.6' is in /usr/local/lib/mysql and that directory is named in the Modules/Setup file. Not sure about pasting that section in here, but let me know if that info would help as well. I just pulled the block from the readme. Any ideas? Where can I search from this point? And thanks in advance! --p Patrick Curtain, Husband & Father (i also write software) From jpersson1 at yahoo.com Sat Apr 24 10:20:11 1999 From: jpersson1 at yahoo.com (Jan Persson) Date: Sat, 24 Apr 1999 16:20:11 +0200 Subject: Using Tkinter togther with threads Message-ID: <3721D31A.8650251@yahoo.com> I have not been able to find an answer to this question in the FAQ. Is it possible to use Tkinter together with threads on the plattforms that support both? Regards //Janne Persson From jeremy at cnri.reston.va.us Fri Apr 2 17:49:09 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Fri, 2 Apr 1999 17:49:09 -0500 (EST) Subject: Is Python dying? In-Reply-To: <7e30fp$8vf$1@news1.rmi.net> References: <7dos4m$usi$1@nnrp1.dejanews.com> <7e30fp$8vf$1@news1.rmi.net> Message-ID: <14085.18282.936883.727575@bitdiddle.cnri.reston.va.us> This is really useless information, but I guess I along with most other people are fascinated by top ten lists and movie grosses and ... Amazon.com sales ranks. Title Amazon.com Sales Rank Learning Python 1,570 Programming Python 1,685 Python : Pocket Reference 3,218 Internet Programming With Python 8,720 Mastering Regular Expressions 931 Programming Perl, 2nd ed. 81 Perl Cookbook 136 The C Programming Language 478 The C++ Programming Language 1,003 Tcl and the Tk Toolkit 3,362 Learning Python seems to be selling well for a book that hasn't been shipped. :-) Jeremy From tim_one at email.msn.com Sat Apr 17 00:59:29 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 17 Apr 1999 04:59:29 GMT Subject: Quick fix to add "+=" In-Reply-To: <3717EE20.41343593@mediaone.net> References: <3717EE20.41343593@mediaone.net> Message-ID: <000701be888f$12fe2920$ee9e2299@tim> [Fuming Wang] > I have searched dejanews. They don't like the "+=" characters. Could you > be more specific about how to modify the interpreter? I desperate > here.:) There's a Python ToDo entry open on this; it may (or may not) be introduced in Python2; last time this went around was late last August, in thread "Why no += operator, please?"; modifying the interpreter was an absurd suggestion, although that's what it would take; in the meantime, use an editor with word completion (e.g. Guido's IDLE environment, included with 1.5.2, has this), and/or factor by hand, e.g. not a.b.c.d.e.f.g.h.i.j = a.b.c.d.e.f.g.h.i + 1 but x = a.b.c.d.e.f.g.h.i x.j = x.j + 1 can't-wait-for-a-resumption-of-the-assignment-expression-thread-ly y'rs - tim From guido at eric.cnri.reston.va.us Mon Apr 19 11:13:50 1999 From: guido at eric.cnri.reston.va.us (Guido van Rossum) Date: 19 Apr 1999 11:13:50 -0400 Subject: Python-1.5.2 testing zlib References: Message-ID: <5l7lr8tzgx.fsf@eric.cnri.reston.va.us> piers at cs.su.oz.au (Piers Lauder) writes: > My "make check" fails with a core dump after "test_zlib". mark at chem.uwa.edu.au (Mark C Favas) replies: > Works just fine for me on both DEC Alpha [..] > These are both with zlib-1.1.3. Yes, the new zlib uses features of zlib 1.1.3 that aren't supported by zlib 1.0.4, so you must use 1.1.3 or later. This is documented in the source but easily overseen; unfortunately we didn't think of putting in a version number test. --Guido van Rossum (home page: http://www.python.org/~guido/) From MHammond at skippinet.com.au Sun Apr 25 21:39:50 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Mon, 26 Apr 1999 11:39:50 +1000 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> Message-ID: <7g0g3v$h90$1@m2.c2.telstra-mm.net.au> Moshe Zadka wrote in message ... >Um....two wrong assumptions here: >1. C implementation is /not/ the same as core status: C extension modules >are numerous and wonderful, for example... Why not? I can only think of differences for types, and even these arent significant. I cant see any distinction between core modules and extension modules, other than the fact you need an extra file hanging around. Mark. From faassen at pop.vet.uu.nl Wed Apr 21 07:20:06 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Wed, 21 Apr 1999 13:20:06 +0200 Subject: Kosovo database; Python speed References: <371DAAC2.D9046550@cs.utwente.nl> Message-ID: <371DB466.32097FE5@pop.vet.uu.nl> Richard van de Stadt wrote: > > Suppose we were going to make a database to help Kosovars locate > their family members. This would probably result in hundreds of > thousands of records (say 1 record (file) per person). > > Would Python be fast enough to manage this data, make queries on > the data, or should compiled programs be used? Depends on what queries you make, but if used smartly, Python can probably be fast enough. From what I've heard Gadfly is (a database implemented in Python). Another alternative is to use Python in combination with an external database, and communicate to the database with SQL. This is pretty fast. See for more info: http://www.python.org/topics/database/ Another thing you may want to look at is Zope -- they have an object database implemented in Python. It's web oriented, but perhaps that is what you want: http://www.zope.org Regards, Martijn From cjw at connection.com Thu Apr 15 06:34:17 1999 From: cjw at connection.com (Colin J. Williams) Date: Thu, 15 Apr 1999 06:34:17 -0400 Subject: Pythonw IDLE Tab setting Message-ID: <3715C0A9.D57546B@connection.com> The program AutoIndent.py has: prefertabs = 0 spaceindent = 4*" " Should spaceindent be changed to 2 if one wishes the tabs to have that value? Currently I use PythonWin which permits the user to change the Tab value (incidentally, it also provides for breakpoints). Any advice would be appreciated. Colin W. From mbf2y at my-dejanews.com Mon Apr 19 18:17:10 1999 From: mbf2y at my-dejanews.com (mbf2y at my-dejanews.com) Date: Mon, 19 Apr 1999 22:17:10 GMT Subject: Can PyApache slow things down?! Message-ID: <7fga0t$55l$1@nnrp1.dejanews.com> Short version of question: I have a project where I am using SGMLParser to parse a HTML document I fetch from another site. The machine I'm using is slow - a DEC Alpha with (get this) 20MB of Ram. (Someone must have canibalized the memory to boost another machine at some point. The lack of RAM makes the machine crawl.) I'm also sharing this machine with other people. Bottom line is that my queries take 5-7 sec of wall-clock time for one query, and 3-5 seconds of wall-clock time for the other. In an attempt to speed things up, I downloaded and built apache with PyApache included. Added the "AddHandler" line. I can tell that PyApache is running properly because using "top" I can see that "httpd" is the process doing all the work, whereas previously, "myscript.py" was doing the work. Problem: I noticed a slowdown in wall-clock time. After much pondering, I decided that since my machine is so low on RAM and the httpd binary nearly doubled in size (to just over a meg), maybe I'm doing more context switches. So instead of starting 5 httpd's, I dropped to 2. Still, even when I'm the only user on the webserver, the queries were slower than the "normal" way. I ended up backing out the change, reverted to the old apache binary and kept the number of webservers at 2; this did speed things up a touch (should have thought of that sooner.) Anyway, I'm wondering if this is normal, and if not, what could I be doing wrong? I used Python 1.5.2b2. However, I also tried this exact same solution with Python 1.5.2 on a machine with more RAM (128MB, but slower chip - an old Sparc 5). The scripts ran slower with PyApache than without... this makes no sense to me as at minimum I should be saving time by having fewer context switches... Thanks for any help (and if you have an extra second, could you read the P.S.?) -Fred (I don't ever check dejanews mail... if you want to e-mail me instead of post here, my address is fred-at-cs-dot-umd-dot-edu) P.S. I'm a graduate student working on a project analyzing search engine usage. What my project does is it presents the user with a type-in box just like the "real" search engines. I then take the query and pass it onto the "real" engine that the user chose (either hotbot or altavista). I get the page back from altavista/hotbot and then use a class derived from SGMLParser to parse the page and extract the hits. I then present to the user the hitlist, free from all the advertising junk present on the "real" search engine sites. I also have it set up so that whenever the user clicks on a URL, I write something like "CLICK-ON #47" to a file. My hope is to analyze usage patterns and try to generate some sort of metric which can indicate a user's satisfaction with the hitlist based on the user behavior (what numbered hits they clicked on, etc.) I am trying to collect as many query sessions as I can over the next 2 weeks or so. If you ever use Altavista or Hotbot, could you please travel to http://www.cs.umd.edu/~fred/search/ and bookmark my site? Then the next time (or few times) you have to run a search engine query, could you use the site? If you have privacy concerns or want a more detailed description of the research goals, answers can be found at that site. Thanks, -Fred -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From festus at altavista.netx Wed Apr 28 23:45:38 1999 From: festus at altavista.netx (remove 'x" to send me e-mail) Date: Thu, 29 Apr 1999 03:45:38 GMT Subject: Maximize Benefit when Purchasing Learning Python References: <00e401be91a6$4d581750$8b7125a6@cpda6686.mcit.com> Message-ID: <372bce88.15442009@news.cjnetworks.com> jkraai at murl.com wrote: >How can I help whom when purchasing Python books? > >Haven't seen enough about this on the list lately & thought >it should come up again. > >I see on python.org a link to Amazon. I've seen in the >past that such links can generate a percentage to the >linking page. > >If I buy via this link, will python.org get something from >Amazon? > >If not, who does/can? If python.org can't get it, I'd like to >see that Mark Lutz gets a little more compensation for >his efforts. I'd rather direct it to myself, personally. Mark Lutz, God bless him, isn't starving, so far as I know, so I'll do myself a turn, to keep my own family from starving. I suspect he gets a per-copy fee based on sales -- regardless who sells them. What about python.org? What does their balance sheet look like? Does anybody know or is this just an assumption that they are living on barely-get-along street? Are they being funded by the Chinese military like the US Democrat party? Well, beggars get what they ask for -- pennies from a few folk. Do beggars do better in the Nederlands? (as opposed to the US?) What would a python app looked like that graphed, with tkinter, relative giving among the Dutch, Europeans overall, and Americans? Could Canadians make up any shortfall? Could we invoice the Australian government for a million or so and not have them notice? www.fatbrain.com wants $23.95 for "Learning Python." I don't know who runs this outfit, but they look suspiciously like an adjunct of amazon.com or barnesandnoble.com. I saw an ad for this outfit in the latest PC Magazine, so I thought I'd check them out. Adios, fatbrain.com. www.bookpool.com wants $19.95 for "Learning Python." www.amazon.com wants $17.97 for "Learning Python." www.barnesandnoble.com wants $23.96 for "Learning Python." I was shocked that amazon.com beat bookpool.com on a computer book -- especially since I had ordered copies from bookpool.com and thought my shit didn't stink. Turns out it does. Shockeroo! From clarence at silcom.com Wed Apr 14 10:36:36 1999 From: clarence at silcom.com (Clarence Gardner) Date: Wed, 14 Apr 1999 14:36:36 GMT Subject: hey advocates References: <7etg59$6mt$1@nnrp1.dejanews.com> Message-ID: aaron_watters at my-dejanews.com wrote: : I don't know whether it really matters or not, but aren't there : any CGI or web applications written in Python? : : http://cgi-resources.com/Programs_and_Scripts/ : : [Actually, my experience has been that sites like this one : don't actually accept submissions they have no exterior interest : in, but it might be worth a try. Let's harass the poor bugger, : shall we?] Particularly since two of the languages included on the page have no entries! Python can at least match that :) (Further investigation shows that actually there are but the counts on the home page are wrong. Although the one program provided under "Unix Shell" is not a CGI program.) -- -=-=-=-=-=-=-=-= Clarence Gardner AvTel Communications Software Products and Services Division clarence at avtel.com From mlh at swl.msd.ray.com Mon Apr 5 17:04:21 1999 From: mlh at swl.msd.ray.com (Milton L. Hankins) Date: Mon, 5 Apr 1999 17:04:21 -0400 Subject: win32pipe.popen2 file objects: How to use advanced operations? Message-ID: I'm trying to use win32pipe.popen2(). I'd like to be able to set the buffer size of one or more of the file objects returned by it. How does one do this? Also, how does one perform a non-blocking read or write on such a file object? Is there any documentation on these file objects with these operations mentioned? I checked the Python library reference's material on file objects and PythonWin's help to no avail. Please respond via email. Thank you. -- Milton L. Hankins -=- Software Engineer, Raytheon Systems Company -=- RayComNet 7-225-4728 http://amasts.msd.ray.com/~mlh -=- John 14:12 ><> From cmedcoff at my-dejanews.com Mon Apr 19 17:47:47 1999 From: cmedcoff at my-dejanews.com (cmedcoff at my-dejanews.com) Date: Mon, 19 Apr 1999 21:47:47 GMT Subject: Beginner Help - class problem or string copy semantics? Message-ID: <7fg8a0$3ib$1@nnrp1.dejanews.com> As will soon be apparent I am totally new to Python. In the code fragment below I expect to see the output "foobar", but I do not. Can anyone tell me why? All the bookstores seem to be out of "Learning Python". Are they out of print already or has the initial shipment still not released? class Test: _name = "" def __init__(self, name): _name = name def show(self): print self._name mytest = Test("foobar") mytest.show() Regards, Chuck -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From kranio at nospam.nospam.it Mon Apr 26 18:16:43 1999 From: kranio at nospam.nospam.it (Kranio) Date: Mon, 26 Apr 1999 22:16:43 GMT Subject: examples for beginners Message-ID: <3724e511.441513@news.tin.it> Could you suggest me where to find some script just for studying? Tnx From spamfranke at bigfoot.de Thu Apr 29 14:01:54 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Thu, 29 Apr 1999 18:01:54 GMT Subject: HTML "sanitizer" in Python References: Message-ID: <372a9bd7.21336470@news.omnilink.de> On Thu, 29 Apr 1999 12:20:27 -0400, "Scott Stirling" wrote: >On opening files in Windows--I was hoping there was a way to give python the full file path. >Everything I have seen so far just tells me how to open a file if it's in the same directory I am >running python from. Uuh, f = open ("c:/my_path/my_file.txt", "r") Every in function in the Python library that has a file name argument accepts a full/relative path also (except when dealing with path and name components explicitely)! Note the normal slashes.. with backslashes you had to write f = open ("c:\\my_path\\my_file.txt", "r") or f = open ( r"c:\my_path\my_file.txt", "r") because Python uses the backslash as an escape character inside string literals, which can be suppressed by using "raw" strings with a leading 'r'. Here's a quick outline of some file processing of your kind, which may give you a first impression (typed without testing): source = open("/path/file.txt", "r") dest = open("/path/file.txt", "w") content = source.read() # read the entire file as a string # Do some processing, perhaps import string string.replace (content, "some_substring", "by_another") dest.write (content) source.close() dest.close() Hope that helps, Stefan From morse at harborcom.net Thu Apr 15 10:12:33 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Thu, 15 Apr 1999 14:12:33 GMT Subject: Different methods with same name but different signature? References: <3716909C.D8D1B372@fedex.com> <005201be8748$51e0bab0$f29b12c2@pythonware.com> Message-ID: <3715f36d.74192342@news.oh.verio.com> "Fredrik Lundh" wrote: >> - using different names for the methods, > >the second method is preferred -- it's faster, easier to >understand, and less error-prone > >imho, it's also an improvement over the pure visitor pattern, >since it allows you to generate "logical events" that doesn't >correspond to "physical" data instances in your model. I don't quite follow you. Can you explain this in a more detail? From faassen at pop.vet.uu.nl Mon Apr 26 16:51:15 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Mon, 26 Apr 1999 22:51:15 +0200 Subject: help References: <19990426163014.B20207@toast.internal> Message-ID: <3724D1C3.8BFA2C5B@pop.vet.uu.nl> jam wrote: > > On Mon, Apr 26, 1999 at 07:18:13PM +0000, Stone Cold wrote: > > > > I just got python and I need some help getting started. I have no > > programing knowlodge yet but I want to know all the languges. can someone > > help? > > [snip Python 'commercial'] > > I don't want to sound like a bad commercial, but python is really and truly > very very cool and a lot of fun to work with. I always sound like that too, don't worry. :) (they're calling me a Python preacher these days, at work) Regards, Martijn From tismer at appliedbiometrics.com Mon Apr 5 11:35:26 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Mon, 5 Apr 1999 15:35:26 GMT Subject: Subattributes of classes References: <19990405104408.A807008@vislab.epa.gov> Message-ID: <3708D83E.BBE87D60@appliedbiometrics.com> Randall Hopper wrote: > > class A: > def __init__( self ): > self.attr = 123 > self.attr.subattr = 456 # <--------- Error! > > a = A() > > This generates an error as I would have expected. > > However, I see the same syntax in: > demos/tkinter/matt/canvas-with-scrollbars.py > > and it works: > > self.draw = Canvas(self, width="5i", height="5i", > background="white", > scrollregion=(0, 0, "20i", "20i")) > self.draw.scrollX = Scrollbar(self, orient=HORIZONTAL) > self.draw.scrollY = Scrollbar(self, orient=VERTICAL) > > ^^^^^^^^^^^^ > > Why? This is since the self.draw is assigned a Canvas instance which is itself an object with attributes. Here comes your ticket :-) >>> class attribs: pass >>> class A: ... def __init__(self): ... self.attr = attribs() ... self.attr.subattr = 456 ... >>> x=A() >>> x.attr <__main__.attribs instance at 15f87e0> >>> x.attr.subattr 456 >>> ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 Digulla at SOWATEC.COM Mon Apr 26 03:11:31 1999 From: Digulla at SOWATEC.COM (Aaron Digulla) Date: Mon, 26 Apr 1999 07:11:31 GMT Subject: Python and "Hand held" computers Message-ID: <318D8A1FC77AD211A3110080C83DFC6403139F@comsrv.sowatec.com> What about Palm Pilot ? -----Original Message----- From: Jeff Bauer To: peter.stoehr at weihenstephan.org; Python List Sent: 4/25/99 1:28 AM Subject: Re: Python and "Hand held" computers "Dr. Peter Stoehr" wrote: > I'm a great fan of python and I'm now looking for an > hand held computer (something smaller than a laptop) > that can be programmed with python. This must be PythonCE week. Three requests in 3 days. Brian Lloyd's original PythonCE port: http://www.digicool.com/~brian/PythonCE/ Mark Hammond has extended it: http://starship.python.net/crew/mhammond/ce/ There is also a mailing list: http://www.egroups.com/group/python-ce/ Briefly, you should be able to run Python on any of the CE family. Practically, this means CE devices based on the MIPS or Hitachi processors. The developers working on PythonCE all have MIPS systems, I believe. (At least that's true for Mark Hammond, Brian Lloyd, and myself.) Best regards, Jeff Bauer Rubicon, Inc. From scrompton at quantisci.co.uk Thu Apr 15 14:27:22 1999 From: scrompton at quantisci.co.uk (Stephen Crompton) Date: Thu, 15 Apr 1999 19:27:22 +0100 Subject: timezone stuff driving me bonkers!!! References: <371604B6.C6267011@quantisci.co.uk> <37160A7D.72AD2893@lemburg.com> Message-ID: <37162F8A.B5CF4307@quantisci.co.uk> M.-A. Lemburg wrote: > Try the utc2local() function in mxDateTime (an extension package > which can download from my Python Pages). > > It will convert a DateTime instance using UTC values to a > DateTime instance using local time. The .ticks() method on > that instance will get you the time since epoch value. > > Cheers, > -- > Marc-Andre Lemburg Y2000: 260 days left > --------------------------------------------------------------------- > : Python Pages >>> http://starship.skyport.net/~lemburg/ : > --------------------------------------------------------- Thanks Marc. But why is the logic wrong in the first place ? Cheers, Steve. ------------------------------------------- Business Collaborator : http://www.quantisci.co.uk/bc From neelk at brick.cswv.com Wed Apr 28 20:34:24 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 28 Apr 1999 19:34:24 -0500 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> Message-ID: <7g89eg$vb0$1@brick.cswv.com> In article <372769B0.3CE8C0F3 at prescod.net>, Paul Prescod wrote: >William Tanksley wrote: >> >> And Oberon (SlimBinaries), and Eiffel (typing and general compile-time >> error catching), and ... > >Actually, isn't Eiffel's type system famous for being full of holes? > >Regardless, wouldn't a better source of inspiration on typing be a >language with *optional* compile-time error checking? I've been playing around with Dylan recently, and it seems like what Python would be if you added "end" blocks and mated it with CLOS. Since Dylan is nearly as dynamic as Python, I think it might be a good source of inspiration for Python 2. (And it might even be the case that the Dylan-to-C compiler might be a source of good bits to improve Python's speed. I haven't looked at the source yet, though.) Neel From ivanlan at callware.com Wed Apr 28 16:49:24 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 28 Apr 1999 20:49:24 GMT Subject: Maximize Benefit when Purchasing Learning Python References: <9FJV2.153$pX2.88806@news.shore.net> Message-ID: <37277454.19DE2FDB@callware.com> Hi All-- "Michael P. Reilly" wrote: > > David Ascher wrote: > : On Wed, 28 Apr 1999 jkraai at murl.com wrote: > > :> How can I help whom when purchasing Python books? > > : I'll dare to speak for Mark, and say that you should feel free to send > : either Mark or I (or both) checks for any amount whatsoever. Skip the > : middleman. Save trees -- don't buy the book, just send us cash. Don't > : hesitate for a minute. > > Better yet. Secure web credit-card transfers? Saves the paper from the > envelopes and checks/bills. ;) > > -Arcege People wonder what attracts me to Python. I claim it's the genteel comportment, sophisticated manner, and air of refined ennui projected by the participants in the online discussion. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From aaron_watters at my-dejanews.com Mon Apr 26 09:13:37 1999 From: aaron_watters at my-dejanews.com (aaron_watters at my-dejanews.com) Date: Mon, 26 Apr 1999 13:13:37 GMT Subject: Python and "Hand held" computers References: <318D8A1FC77AD211A3110080C83DFC6403139F@comsrv.sowatec.com> Message-ID: <7g1opt$9li$1@nnrp1.dejanews.com> > What about Palm Pilot ? I think the answer still is "It should be possible, but in practice the Palm Pilot doesn't have enough memory to make it an interesting proposition, unless you upgrade it to non-standard sizes." While it is possible to upgrade the memory (I think) this means that the audience for palm/Python would probably be limited to the developers of palm/Python and certain other hobbiests. For windows CE, by contrast, many machines come with enough memory (32meg ram/24meg rom in mine, with 10 hours of uptime) to make python-ce interesting. Hope I'm wrong, or the Palm folks change the situation. We've seen this situation before in other markets and it doesn't harbor well for the Palm Pilot (cool as it undeniably is). Please correct me!!! btw: gadfly runs on python-ce (with some mods) :) I think it is the most fully featured sql implementation that runs on wince. (pocketAccess is braindead.) -- Aaron Watters http://www.chordate.com === History: read it and weep. -- Kurt Vonnegut -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From fpinel at fedex.com Thu Apr 15 21:21:32 1999 From: fpinel at fedex.com (frederic pinel) Date: Fri, 16 Apr 1999 03:21:32 +0200 Subject: Different methods with same name but different signature? Message-ID: <3716909C.D8D1B372@fedex.com> Hello, While trying to implement the visitor pattern in Python, I ran into the following problem: My class needs to have 2 (or more) different methods, but with the same name, the difference being the signature (an object in my case), unfortunately Pyhton interprets this as an overidding, and only considers the last method defined. C++ being able to switch to the right method, based on the signature, I thought Python would. Being new to Python, is this a limitation or am I missing something? (Python being great I suspect -and hope- it's my ignorance!) Any help would be great! PS: as a workaround, I tried: - using a single method, but checking isinstance() of the object passed to switch to the right code, - using different names for the methods, which both work. regards, frederic From tratt at dcs.kcl.ac.uk Tue Apr 20 08:45:28 1999 From: tratt at dcs.kcl.ac.uk (Laurence Tratt) Date: Tue, 20 Apr 1999 13:45:28 +0100 Subject: bzip2 module for Python References: Message-ID: In message Oleg Broytmann wrote: > On Tue, 20 Apr 1999, Laurence Tratt wrote: >> pyBZlib > What is it? Sounds good! Where is it? pyBZlib is my quick attempt to create a Python interface to the bzip2 compression library after a 'request' on c.l.p yesterday; I must stress that it is experimental, incomplete and definitely not for the feint hearted yet. It also has a temporary home for a few days until the server I normally use is back on line. Until then: http://yi.com/home/TrattLaurence/pybzlib.tar will get you the latest version. Laurie From olipt at mayo.edu Wed Apr 14 18:01:02 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Wed, 14 Apr 1999 17:01:02 -0500 Subject: python interface to c++ class In-Reply-To: <3714E388.CD434E8A@pk.highway.ne.jp> References: <3714E388.CD434E8A@pk.highway.ne.jp> Message-ID: > for example In C++,we can enjoy following > operations. > (f_matrix: matrix class for float, d_matrix: for > double) > > 1. f_matrix x1,x2; float y; x2=y*x1; (operation > between different types) The Numeric module has these types of object defined (but extended to N-D arrays). Operations between different types is supported by sophisticated broadcasting rules. > 2. x1(1,2)=3.4; (substitution for matrix > element) With Numeric one can substitute for array (matrix) elements or array slices (start, stop, step). > 3. d_matrix z; z=x1; > (auto conversion from float matrix to another > type(d_matrix)) > Since Python is not a staticly typed language, typing z = x1 when x1 is a Numeric multiarray object will just bind the name z to the object x1. If x1 is a Float array and you want a double array, you say. z = x1.astype('d') It sounds like you should really check out the Numeric module and see if it doesn't fit your needs. It is quite a useful tool. Best, Travis From vdkoijk at linux01.prc.tno.nl Tue Apr 20 09:41:57 1999 From: vdkoijk at linux01.prc.tno.nl (John van der Koijk) Date: 20 Apr 1999 15:41:57 +0200 Subject: Tkinter canvas scaling does not work for Images?? Message-ID: <87hfqbjtne.fsf@linux01.prc.tno.nl> Hi There, I'm playing around with Pmw and (thus Tkinter). After some experiments, I found out that I can scale lines and such, but Images do not seem to respond to similar requests. The docs don't seem to mention this interesting limitation. Any clues? Regards, -- John van der Koijk. -- TNO Institute of Industrial Technology PO Box 5073, 2600 GB, Delft, The Netherlands Phone +31 15 2608833, Fax +31 15 2608846 From jbauer at rubic.com Thu Apr 22 07:45:22 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Thu, 22 Apr 1999 11:45:22 GMT Subject: Directory of current file References: Message-ID: <371F0BD2.7D40A957@rubic.com> David Ascher wrote: > Tip: To find out the directory of the currently executing program, use: > > import sys, os > if __name__ == '__main__': > _thisDir = '' > else: > _thisDir = os.path.split(sys.modules[__name__].__file__)[0] David, what are the advantages over this? _thisDir = os.path.split(sys.argv[0])[0] Jeff Bauer Rubicon, Inc. From bwinton at tor.dhs.org Sun Apr 4 23:23:02 1999 From: bwinton at tor.dhs.org (Blake Winton) Date: Mon, 05 Apr 1999 03:23:02 GMT Subject: help References: <7e1fr0$6cio$1@titan.xtra.co.nz> Message-ID: On Fri, 2 Apr 1999 15:58:52 +1200, nfbb wrote: >Hi there - I'm running Windows 98 and was wondering what the best program >for writing python Source code is under this operating system? I like vim, but I come from a Unix background, and if you don't already know vim, you'ld probably be better starting off with something else. IDLE (Guido's IDE) is also up on my favourites list. Later, Blake. From charles.choi at computer.org Fri Apr 23 11:19:37 1999 From: charles.choi at computer.org (Charles Y. Choi) Date: Fri, 23 Apr 1999 08:19:37 -0700 Subject: 1.5.2 Build Snag Message-ID: Folks- Found out my problem was with a bad build of gcc2.8.1 here and _not_ the release of Python 1.5.2 - Much thanks to Oleg for his feedback on this - -Charles From fdrake at cnri.reston.va.us Fri Apr 30 16:37:20 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Fri, 30 Apr 1999 20:37:20 GMT Subject: [PSA MEMBERS ANNOUNCE] Python documentation updated! In-Reply-To: <372A1374.6405E48B@callware.com> References: <14122.3325.631762.383828@weyr.cnri.reston.va.us> <372A1374.6405E48B@callware.com> Message-ID: <14122.5248.11057.171391@weyr.cnri.reston.va.us> Ivan Van Laningham writes: > Clicking on the HTML link gets me a 404 Doc not found error. ... Ivan, I can't reproduce this. Is it the http://www.python.org/doc/ URL that's causing this, or something else off of this page? (If the later, you may need to reload the page before following any links from there.) If it's a link within the page, it would really help if I knew exactly what URL is failing. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From quinn at cruzeiro.ugcs.caltech.edu Wed Apr 7 22:45:40 1999 From: quinn at cruzeiro.ugcs.caltech.edu (Quinn Dunkan) Date: 8 Apr 1999 02:45:40 GMT Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> Message-ID: On 06 Apr 1999 15:46:12 -0500, David Steuber wrote: >mlh at idt.ntnu.no (Magnus L. Hetland) writes: > >-> "TM" writes: >-> >-> > Has anyone created a pov ray module for python? >-> >-> I have been thinking about it, but haven't done it yet... What do you >-> think it should contain? > >This is a relatively off the cuff response. But I think such a module >should provide python classes for the POV types. Then, instead of >using the POV scene description language, you would use Python. You >could algorithmicly create a scene or animation sequence. Then you >would pass the data structure (a list or other sequence) to a Python >function that renders it in POV scene description language for POV to >digest and render. > >Another thing I would like to see is a module for generating RIB >files. In fact, a Python RenderMan module would be quite nice, >complete with shading language support. Anything out there like that? Well, I don't have RenderMan, but I did write a pov.py module. It does basically what you described, and eventually I'm going to add animation features and basic physics (the ocaml module I wrote before did that) and stuff like "magic" transforms that align one object with another, spline curves etc. I've designed some scenes in it, and it's wordier than pov, but has all the benefits of a real language. It doesn't do the new halo syntax because the pov people have yet to release an updated unix version (grumblegripegrunt). It's incomplete, and written when I was first learning python, and I haven't worked on it for a while, but I'll send it to anyone interested. Perhaps we could collaborate? From my at efes.net.tr Tue Apr 20 03:19:32 1999 From: my at efes.net.tr (Murat Yeneroglu) Date: Tue, 20 Apr 1999 07:19:32 GMT Subject: unsubscribe Message-ID: <371C2A84.1385D490@efes.net.tr> Pls unsubscribe me. my at efes.net.tr yenerm at efes.net.tr From faassen at pop.vet.uu.nl Wed Apr 7 16:56:24 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Wed, 07 Apr 1999 22:56:24 +0200 Subject: Crappy Software was Re: [OffTopic: Netscape] Re: How should References: <1288614834-78399188@hypernet.com> <370B993C.8DFFB4A4@appliedbiometrics.com> Message-ID: <370BC677.6C6A82D7@pop.vet.uu.nl> Christian Tismer wrote: [netscape plugin maddness] > They should rewrite the whole crap, presumably > build it from the bones of Grail :-)) It is my understanding that they *are* rewriting the whole crap. The new crap looks pretty nice, at least the layout pre-alphas I tried grokked CSS 1 pretty well (though there were some bugs left in stress tests at the time I tried those some months ago). I don't know about the plugin architecture, but I think they're rewriting everything. It being open source would help as well with debugging, and if you don't like their plugin architecture you can try to introduce your own (yeah, that was easily said and not easily done, I know, I know :) Anyway, I'm sorry to hear about the hellish pains you underwent! Perhaps you can give some input to the Mozilla people working on this, though. Regards, Martijn From landrum at foreman.ac.rwth-aachen.de Tue Apr 27 08:44:11 1999 From: landrum at foreman.ac.rwth-aachen.de (Greg Landrum) Date: Tue, 27 Apr 1999 14:44:11 +0200 Subject: sharing variables in fortran References: <3725643A.734B9F06@crystal.uwa.edu.au> Message-ID: <3725B11B.F44244FF@foreman.ac.rwth-aachen.de> Douglas du Boulay wrote: > > I am wondering if it is possible to coerce python to use > memory addresses corresponding to a fortran common block (by way of a c > extension) > for storage of certain variables. I can't speak to the python part of things, but there is a dirty way to allow a C program to access fortran common blocks. I imagine that this would allow you to solve your python problem fairly easily by having your C wrapper muck around with the common blocks. Before I tell you how to do it, I want to emphasize strongly that this may not work with every compiler/OS combination. I figured this out a while ago by playing around with the output of nm, but I've never seen it written down anywhere. I've made this work under AIX, Linux, HPUX, and IRIX, but that's no guarantee that it'll go with everything. Now that I have fired a healthy salvo of disclaimers, here's the unpleasant method of solving the problem. Here's a fragment of fortran code which uses a common block: subroutine test_mod real var1 integer var2 common /testblock/ var1,var2 print *, var1, var2 end You can get at the contents of testblock by defining a global structure in your C program which has exactly the same contents as testblock. So, for example, this C program: #include typedef struct { float var1; int var2; } common1; common1 testblock; void main() { testblock.var1 = 1.034; testblock.var2 = 2; test_mod(); } sets the members of the common block, then calls the fortran subroutine which prints out its members. Of course this repellant bit of magic doesn't work "as is" on every system. Some f77 compilers like to stick one or more underscores after subroutine and common block names. On those, you will have to change the names of the common blocks in order to match. For example, g77 (at least my version) produces a .o file which has these symbols: 00000000 T test_mod__ 00000008 C testblock_ (that's output from nm), so I have to change the call to test_mod in the C part from test_mod() -> test_mod__(). Correspondingly, the name of testblock needs to be changed to testblock_. It just can't be too easy. Anyway, I hope that this type of trickery allows you to solve your problems. ly yours, [1] -greg [1] okay, okay, I haven't been following the group long enough to have earned the right to do that, but I need to do *something* to relieve the tension after thinking about these foul things again. --------------------- Dr. Greg Landrum (landrumSPAM at foreman.ac.rwth-aachen.de) Institute of Inorganic Chemistry Aachen University of Technology Prof.-Pirlet-Str. 1, D-52074 Aachen, Germany From ljz at asfast.com Wed Apr 28 23:01:08 1999 From: ljz at asfast.com (Lloyd Zusman) Date: 28 Apr 1999 23:01:08 -0400 Subject: Pmw, threads, Linux, and 1.5.2 Message-ID: I have a Pmw application that I'm running under version 1.5.2, and I would like to break this application up into a couple threads (Pmw_0_8 and RedHat Linux 5.0). However, Pmw makes use of the `update' and `update_idletasks' Tkinter methods, and according to the documentation, using these methods within threads will cause a deadlock under Unix. I actually see this deadlock behavior, and so I assume that this documentation is correct. But before I give up hope altogether, I'm wondering if anyone has found any way around this restriction? I'd really like to continue using Pmw and to make use of threads, if at all possible. Thanks in advance. -- Lloyd Zusman ljz at asfast.com From jefftc at leland.Stanford.EDU Mon Apr 19 19:07:26 1999 From: jefftc at leland.Stanford.EDU (Jeffrey Chang) Date: Mon, 19 Apr 1999 16:07:26 -0700 Subject: race condition in popen2._test() Message-ID: Hello, I am compiling Python v1.52c1 on a Sun Ultra-4 and am failing the test on popen2.py (this test was not included in earlier distributions): taiyang:~/src/Python-1.5.2c1> ./python Lib/popen2.py testing popen2... testing popen3... Traceback (innermost last): File "Lib/popen2.py", line 99, in ? _test() File "Lib/popen2.py", line 95, in _test assert not _active AssertionError Looking at the code in popen2.py: 92 assert r.read() == teststr 93 assert e.read() == "" 94 _cleanup() 95 assert not _active 96 print "All OK" _active is a list of all the instances of Popen3. The _cleanup function iterates through this list and polls each instance to see if it's done. def _cleanup(): for inst in _active[:]: inst.poll() The poll function does a 'waitpid' on its child, and if it's exit status is available, then it removes itself from the list. def poll(self): if self.sts < 0: try: pid, sts = os.waitpid(self.pid, os.WNOHANG) if pid == self.pid: self.sts = sts _active.remove(self) except os.error: pass return self.sts I believe that the error I am seeing is because the child processes do not have enough time to close before they're polled in _cleanup. If I insert some code so that it pauses before _cleanup: ** import time 92 assert r.read() == teststr 93 assert e.read() == "" ** start = time.time() ** while time.time() < start + 0.1: pass 94 _cleanup() 95 assert not _active 96 print "All OK" the exception goes away and I pass the tests. I would argue against this going inside _cleanup because _cleanup is called every time a new pipe is created. Jeff From jmrober1 at ingr.com Fri Apr 9 10:47:19 1999 From: jmrober1 at ingr.com (Joseph Robertson) Date: Fri, 09 Apr 1999 09:47:19 -0500 Subject: Q on Tkinter Scrollbar References: <370CFAC8.32EB0B29@ingr.com> <370DE495.E98111E3@mindspring.com> Message-ID: <370E12F7.11E9D9E4@ingr.com> No thats a scale. Picture a scrollable canvas spreadsheet table of 58 cols and 90,000+ rows. Now picture tkinter trying to create that grid, if it doesn't bomb from the strain it would still take it literally hours to create it. But since you can't 'see' anything outside the scrollwindow of at most 60 rows, why try to create it? A thermometer or scale looks out of place. A scrollbar is expected. Now let the vertical scrollbar track the 'dataset' and simply show the 60 rows that the scrollbar points to. I've done all this in VB, using Python-Com as the underlying dataset. Now I am trying to ditch the vb gui (and its horrible overhead). Thanks, Joe Robertson jmrober1 at ingr.com Doug Hellmann wrote: > Hi, Joseph, > > I can't give you any useful tips on the scrollbar, but if I was writing > this I think I would probably subclass the canvas to create a "meter" or > "thermometer" widget to do what you need. Create a rectangular canvas > (taller than wide), draw the scale (lines and text), then create an > indicator (a triangle?) to point the current value. > > In fact, if you're not against using Pmw, there is just such a beast in > the demos or contrib directory. Now that I think of it, you might find > some useful examples of the scrollbar elsewhere in the Pmw code. Take a > look http://www.dscpl.com.au/pmw/. > > Doug > > Joseph Robertson wrote: > > > > Hi everyone, > > > > I want to manually control the scrollbar in a tkinter app, i.e. I don't > > want to tie it to another widget as a child. Below is what I have so > > far. I can't figure how to make the 'thumb' stay at the returned > > position, or the point where the user drags it. Right now it always > > pops back to the top. > > > > I want it to behave like a Scale, but look like a scrollbar. Think of a > > virtual window on a dataset, where I don't want to load the contents of > > the data set into a listbox (not enough memory). > > > > Anyone do this before, know of any similar examples, or give me a clue > > where to look next. I don't want to use extensions or another GUI, it > > needs to be Tkinter. > > > > Thanks in advance, > > Joe Robertson > > jmrober1 at ingr.com > > > > >----begin code > > # a manual scrollbar > > # > > # Joe Robertson, jmrober1 at ingr.com > > # > > from Tkinter import * > > > > class Manual(Frame): > > > > def __init__(self, master, **kw): > > apply(Frame.__init__, (self, master), kw) > > vscrollbar = Scrollbar(self, orient=VERTICAL) > > self.canvas = Canvas(self) > > vscrollbar.config(command=self._vscroll) > > vscrollbar.pack(fill=Y, side=RIGHT) > > self.canvas.pack(expand=1, fill=BOTH, side=LEFT) > > > > def _vscroll(self, type, *arg): > > print type > > if type == 'moveto': > > for each in arg: > > print each > > > > # doit > > root = Tk() > > f = Manual(root) > > f.pack(expand=1, fill=BOTH) > > root.mainloop() > > > > >----end code From xzvffz at my-dejanews.com Thu Apr 22 16:39:07 1999 From: xzvffz at my-dejanews.com (xzvffz at my-dejanews.com) Date: Thu, 22 Apr 1999 20:39:07 GMT Subject: Problems compiling 1.5.2 on linux 2.0.27 -- Parser Message-ID: <7fo1db$5ok$1@nnrp1.dejanews.com> I can not compile python 1.5.2 on my linux system (Slackware 2.0.27). It dies while compiling in the Parser directory. First it could not find some .h files but that path was corrected. Upon re - make - ing the distribution I get about two or three pages of warnings and/or errors involving undefined sysmols. Configure runs fine. The previous make steps run fine. Has anyone else had this problem and how was it corrected? -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From quinn at photo.ugcs.caltech.edu Fri Apr 30 23:17:23 1999 From: quinn at photo.ugcs.caltech.edu (Quinn Dunkan) Date: 1 May 1999 03:17:23 GMT Subject: % References: <925435812snz@vision25.demon.co.uk> Message-ID: On Fri, 30 Apr 99 01:30:12 GMT, Phil Hunt wrote: > >Consider the % operator, eg: > > 'All %(a)s eat %(b)s' % {'a':'cows', 'b':'grass'} > >If the dictionary doesn't have all the relevant keys, an error >occurs. Is it possible for me to change the behaviour of this so that >if a key doesn't occur a default value of '' is assumed? Well, my way is to make my own dictionary: import UserDict class DefaultDict(UserDict.UserDict): def __init__(self, dict, default=''): self.default = default self.data = dict def __getitem__(self, key): return self.data.get(key, self.default) 'All %(a)s eat %(b)s' % DefaultDict({'a': 'cows', 'b': 'grass'}) Union dictionaries (search through several dicts) are particularly useful for %. There's even an implementation in C from DC (MultiMapping.so) From bernhard at alpha1.csd.uwm.edu Fri Apr 9 19:08:52 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 9 Apr 1999 23:08:52 GMT Subject: pythonwin COM Update link out of date Message-ID: http://www.python.org/ftp/python/pythonwin/pwindex.html#oadist Gives a bad link to the MS Microsoft Knowledge Base article Q164529. The link is bad and I cannot relocate the article with the search engine on that site and other methods... :( The closest I could get was: http://support.microsoft.com/support/kb/articles/Q139/4/32.asp from http://support.microsoft.com/support/downloads/LNP195.asp Hmmmm.... is there a potential danger in installing oadist.exe? Bernhard From cmedcoff at my-dejanews.com Fri Apr 23 10:05:24 1999 From: cmedcoff at my-dejanews.com (cmedcoff at my-dejanews.com) Date: Fri, 23 Apr 1999 14:05:24 GMT Subject: help with os.popen() References: <7fomaj$oo9$1@nnrp1.dejanews.com> Message-ID: <7fpun1$rmn$1@nnrp1.dejanews.com> Please disregard my post. I blew it. I found the answer in the FAQ. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From cingram at my-dejanews.com Wed Apr 7 16:51:00 1999 From: cingram at my-dejanews.com (cingram at my-dejanews.com) Date: Wed, 07 Apr 1999 20:51:00 GMT Subject: COM Event Sinks and Connection Points in Python Message-ID: <7eggfh$o0f$1@nnrp1.dejanews.com> I am trying to use functionality from a DLL that requires me to create a COM event sink so that it can call back with events. I am trying to write this event sink in Python. However, when I try to create a SimpleConnection object, it gives this exception: "Unable to open the access token of the current thread". In the source code for testPyComTest.py (which is the only thing I could find that uses the SimpleConnection object) that comes with the win32all distribution, the following three lines exist right above code that would test the connection point functionality: # AAARG - why do connection points fail? print "Skipping connection points as we have a threading bug somewhere :-(" return Now, this comment leads me to believe that Mark Hammond, the author of the Python Win32 stuff, has the same problem. Does anyone know how to get around this problem? Below is the sample code I am trying to use. #---- test.py import pythoncom # The GUID was retrieved from the IDL file of an external DLL. # Is there a better way to get these without hard coding? IID_DEMEvents = pythoncom.MakeIID ("{7BAE0700-E7D5-11d0-9C22-0020AFF2B0F5}") class MonitorEvents: """Event Sink for Test.DEM""" _reg_clsid_ = "{554A2C64-EC50-11D2-BD51-006097B6AF50}" _reg_desc_ = "PythonTest.MonitorEvents" _reg_progid_ = "PythonTest.MonitorEvents" _reg_class_spec_ = "test.MonitorEvents" _public_methods_ = ["onSubscribe"] _public_attrs_ = [] _readonly_attrs_ = [] _com_interfaces_ = [IID_DEMEvents] def onSubscribe (self): # Not implemented yet. pass if __name__ == "__main__": import win32com.server.register import win32com.client import win32com.client.connect # Test.DEM is the ProgID of the event source. (This is an # external DLL.) dem = win32com.client.Dispatch ("Test.DEM") # MonitorEvents is the Python class that implements the Event Sink. meobj = MonitorEvents() # The following line causes an exception. s = win32com.client.connect.SimpleConnection (dem, meobj, IID_DEMEvents) # Creating the SimpleConnection object fails with: # #Traceback (innermost last): # File "T:\Playground\Python\Monitor\monitor.py", line 54, in ? # s = win32com.client.connect.SimpleConnection (dem, meobj, IID_DEMEvents) # File "C:\Tools\Python\win32com\client\connect.py", line 10, in __init__ # self.Connect(coInstance , eventInstance, eventCLSID) # File "C:\Tools\Python\win32com\client\connect.py", line 27, in Connect # self.cookie = self.cp.Advise(comEventInstance) #pywintypes.com_error: (-2147220990, 'Unable to open the access token of the current thread', None, None) -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From mlv at pobox.com Mon Apr 26 15:49:35 1999 From: mlv at pobox.com (Michael Vezie) Date: 26 Apr 1999 15:49:35 -0400 Subject: Q on Tkinter Scrollbar References: <370CFAC8.32EB0B29@ingr.com> Message-ID: <7g2g0f$km7$1@mlv.mit.edu> In article <370CFAC8.32EB0B29 at ingr.com>, Joseph Robertson wrote: >Hi everyone, > >I want to manually control the scrollbar in a tkinter app, i.e. I don't >want to tie it to another widget as a child. Below is what I have so >far. I can't figure how to make the 'thumb' stay at the returned >position, or the point where the user drags it. Right now it always >pops back to the top. I think you need to, in _vscroll, set the position of the scrollbar. I did this exact thing in a tcl app once, so I know it's possible. It's a bit of work to figure out where things are supposed to be, but you're going to have to tell it what being halfway down means anyway. Michael From scothrell at austin.rr.com Thu Apr 15 23:26:48 1999 From: scothrell at austin.rr.com (Scott C) Date: Fri, 16 Apr 1999 03:26:48 GMT Subject: Change for compiling 1.5.2 on Windows NT Alpha Message-ID: Guido and fellow pythoneers... There needs to be the following change in file fpectlmodule.c, line 163: Line currently reads: #elif defined(__alpha) line should read: #elif defined(__alpha) && !defined(_MSC_VER) Rationale: The original line correctly identifies the DEC Alpha processor, but not the OS. Consequently, when compiled under NT 4 Alpha using MSVC 5.0, which defines __alpha (apparently), the wrong section is processed. The additional logic prevents the Microsoft compiler from processing the wrong section. Scott Cothrell PS: I have Alpha NT versions compiled for python15.dll and python.exe From mal at lemburg.com Wed Apr 14 17:32:31 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 14 Apr 1999 21:32:31 GMT Subject: python interface to c++ class References: <3714E388.CD434E8A@pk.highway.ne.jp> Message-ID: <3715096F.798B1EBC@lemburg.com> Thooney Millennier wrote: > > Hello, everyone. > I am now working on building Python interface > to my C++ matrix library. Maybe you could use the NumPy extension as basis for this... I guess integrating your lib there should be doable (though they already have an multi-dimensional array). > for example In C++,we can enjoy following > operations. > (f_matrix: matrix class for float, d_matrix: for > double) > > 1. f_matrix x1,x2; float y; x2=y*x1; (operation > between different types) Implementing mixed type numerics is no fun when done in C (there's no real support for it; I have a patch though, that I would like to see in Python1.6 and which I will update now that 1.5.2 is out). In Python it's a piece of cake: just use the __op__ and __rop__ methods. So if you are using SWIG to wrap your C++ classes with shadow classes, you're lucky. To see how the current C implementation can be tweaked to do mixed number operations look at the source code of mxDateTime (available from the link below). > 2. x1(1,2)=3.4; (substitution for matrix > element) You can do this with __set/getitem__: class C: def __getitem__(self,what): print 'get',repr(what),type(what) def __setitem__(self,what,to): print 'set',repr(what),type(what),to o = C() o[1,2] o[1,...,3] o[1,2] = 3 o[1,2,3] = 4 o[1,...,3] = 5 gives: get (1, 2) get (1, Ellipsis, 3) set (1, 2) 3 set (1, 2, 3) 4 set (1, Ellipsis, 3) 5 > 3. d_matrix z; z=x1; > (auto conversion from float matrix to another > type(d_matrix)) Python uses name bindings. z=x1 will only bind the name 'z' to the object referenced as 'x1'. You'll have to use explicit conversion, e.g. z = toDMatrix(x1). -- Marc-Andre Lemburg Y2000: 261 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From S.I.Reynolds at cs.bham.ac.uk Thu Apr 29 10:25:09 1999 From: S.I.Reynolds at cs.bham.ac.uk (Stuart I Reynolds) Date: Thu, 29 Apr 1999 15:25:09 +0100 Subject: GUI and printing References: <7fqkcu$7gj$1@mars.worldonline.fr> <19990427073342.A579158@vislab.epa.gov> Message-ID: <37286BC5.165B@cs.bham.ac.uk> Randall Hopper wrote: > > Re printing. I don't know the details (since I haven't used this feature), > but seems I recall that Tk has some support for PostScript printing. > Grepping Tkinter, I see that the Canvas widget has a "postscript" method. > You can do it like this: mytkwidget.postscript(file = filename) Stuart From aahz at netcom.com Wed Apr 28 14:19:31 1999 From: aahz at netcom.com (Aahz Maruch) Date: Wed, 28 Apr 1999 18:19:31 GMT Subject: HELP - FTP seesions using python???????? References: <7g328l$hga$1@nnrp1.dejanews.com> <7g5ueh$3pt$1@nnrp1.dejanews.com> Message-ID: In article <7g5ueh$3pt$1 at nnrp1.dejanews.com>, wrote: > >another small question in perl the #!/usr/local/bin/perl is not needed when >run on a windows machine, does it matter for Python on a windows machine >whether this line is present or not? No, but if you set Windows up to recognize .py as an executable extension, you can leave that line in there and have a platform--independent program. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Hi! I'm a beta for SigVirus 2000! Copy me into your .sigfile! From hanche at math.ntnu.no Fri Apr 23 17:21:47 1999 From: hanche at math.ntnu.no (Harald Hanche-Olsen) Date: 23 Apr 1999 23:21:47 +0200 Subject: Strange fork() behaviour References: <37203066.6B4A58D9@stuco.uni-klu.ac.at> Message-ID: + Martin Preishuber : | There are some strange things with fork() and python 1.5.2 going | on here. | | I do have some main program which is basically | | while 1: | fork() | | The program forks under certain conditions and works as expected | but somewhen the main process dies even though it is in the | while 1: loop ... there's no error message ... did anyone | see anything similar ? the program worked fine with 1.5.1 | (this is all on a linux box running rh 5.2 and kernel 2.2.6-ac1) This is a joke, right? What I would expect the above program to do is to fork processes until the process table is full or you hit the per-user process limit, at which point fork() will begin to fail, which will then most likely terminate the calling process (unless you trap the error). I'd be curious to know how this could have worked earlier, or how you could expect it to behave differently. or-maybe-basically-really-means-basically-not-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 boud at rempt.xs4all.nl Thu Apr 8 02:39:21 1999 From: boud at rempt.xs4all.nl (boud at rempt.xs4all.nl) Date: Thu, 8 Apr 1999 06:39:21 GMT Subject: Crappy Software was Re: [OffTopic: Netscape] Re: How should References: <370c7a2d.35857749@news.bctel.ca> <1288614834-78399188@hypernet.com> Message-ID: Gordon McMillan wrote: : : There's even a difference between exiting from the file menu and : closing from the title bar. : : When's the last time you closed a GUI from the file menu?? : : Sheesh. : That rings a bell - it also occurred in the last version of Oracle Forms 4.5 I had the misfortune to work with. Worse, closing the app with alt-spacebar (for the system menu) would hang the whole of Windows. -- Boudewijn Rempt | www.xs4all.nl/~bsarempt From akuchlin at cnri.reston.va.us Thu Apr 8 10:29:49 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Thu, 8 Apr 1999 14:29:49 GMT Subject: Lexical analyzers and parsers In-Reply-To: <7jn20jmxsw.fsf@gandalf.midearth.fuzzys.org> References: <7jn20jmxsw.fsf@gandalf.midearth.fuzzys.org> Message-ID: <14092.48400.954787.617539@amarok.cnri.reston.va.us> Julien Oster writes: >What about lexical analyzers and parsers? > >Under C I use bison/yacc and (f)lex. Under python, I can either implement this >stuff using C or try to write my parsers on my own, which is real pain. There are actually a bunch of different systems available; see http://starship.python.net/crew/amk/python/string.html#parsing for a list. (If I've missed any, let me know.) -- A.M. Kuchling http://starship.python.net/crew/amk/ Be wiser than other people if you can; but do not tell them so. -- Lord Chesterfield From jwinkelman at my-dejanews.com Tue Apr 13 15:37:33 1999 From: jwinkelman at my-dejanews.com (jwinkelman at my-dejanews.com) Date: Tue, 13 Apr 1999 19:37:33 GMT Subject: Using SioModule.zip under Win32 Message-ID: <7f06ds$hmb$1@nnrp1.dejanews.com> I have downloaded the SIO-151.ZIP to do some serial IO under Win32. Does anyone know if it can handle port numbers higher than COM9? I tried modifying the dictionary in the serial.py file to add constants for COM10, etc., but when I load the module, I get a NameError for COM10. Being new to python, I'm not sure where to go from here. Any help is appreciated. Thanks. Jeff -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From scothrell at austin.rr.com Fri Apr 9 01:15:48 1999 From: scothrell at austin.rr.com (Scott C) Date: Fri, 09 Apr 1999 05:15:48 GMT Subject: Python on Alpha NT...anyone? Message-ID: <82gP2.685$87.74444@typhoon.austin.rr.com> I'm getting ready to compile Python on my Alpha processor NT box...in fact I've tried it and am "fixing bugs" as I go... Has anyone else done this? and are there "lessons" learned anywhere (re: porting). Scott Cothrell From phd at sun.med.ru Wed Apr 7 04:16:38 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Wed, 7 Apr 1999 08:16:38 GMT Subject: GadFly - MemoryError In-Reply-To: <199904051641.MAA12603@ifu.ifu.net> References: <199904051641.MAA12603@ifu.ifu.net> Message-ID: Hello! On Mon, 5 Apr 1999, arw wrote: > I don't know why you have this problem. > Gadfly should not construct the cross product with > the equality you mention present. > (b1.URL = b2.URL) I freed some memory and the program worked. It ate 30 Megs while running, so I was in need of memory. But it ran 30 minutes (on 3000 rows!) > Please try adding an index on URL on the table > in question. Also, maybe try increasing your virtual > memory (page file size, or whatever). Indices or compiled kjbuckets was not of big help - instead of running 35 minutes the program ran 30. I think, my computer spent more time swapping, not working. > Good luck. fwiw, I've definitely run tables with > 100k rows in Gadfly on a 64Meg machine. > -- Aaron Watters You are in luck. > ps: let me know how it goes. Not so good. I think I would not use gadfly, at least for this project (currently I am using very simple "database", that stored in text files. Of course, I cannot make complex requests, sucj as joins). Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From joe at strout.net Wed Apr 7 13:22:39 1999 From: joe at strout.net (Joe Strout) Date: Wed, 07 Apr 1999 10:22:39 -0700 Subject: Writing lines longer than 80 charc ! References: Message-ID: In article , SunitJoshi wrote: > I'm wondering if someone knew of a way of writing a line of more than 80 > characters to a file in way that it won't split it into two lines. Well, you could type the line in BBEdit Lite, then use the "Save" command... I assume you don't mean writing a line to a file in Python, because it doesn't split it into two lines. Maybe you think it does because of the way you're viewing it? For a more detailed answer, try posting a more detailed question. Cheers, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From flight at mathi.uni-heidelberg.de Wed Apr 21 15:53:57 1999 From: flight at mathi.uni-heidelberg.de (Gregor Hoffleit) Date: 21 Apr 1999 19:53:57 GMT Subject: REPOST:pretty please - Help re libpython1.5.so References: <3714B9F9.30285D74@earth.ox.ac.uk> <87btgpah2x.fsf@padova.cnet.com> Message-ID: In article <87btgpah2x.fsf at padova.cnet.com>, David N. Welton wrote: > >I think it would be really cool if the default distribution had a nice >libpython*.so included, as Tcl does. I'm not quite sure Python will >ever be quite so simple to use as an embedded language as Tcl, given >that it is a bit more complex (and more powerful!), but being able to >do: > >gcc -o foo foo.c -lpython1.5 > >would be a nice step... FYI, this is possible with Debian's new Python 1.5.2 packages: freefly:1> dpkg -S libpython1.5 python-dev: /usr/lib/python1.5/config/libpython1.5.a python-dev: /usr/lib/libpython1.5.so python-base: /usr/lib/libpython1.5.so.0.0 and freefly:2> ldd /usr/bin/python libpython1.5.so.0.0 => /usr/lib/libpython1.5.so.0.0 (0x4001f000) libdl.so.2 => /lib/libdl.so.2 (0x40089000) libpthread.so.0 => /lib/libpthread.so.0 (0x4008c000) libm.so.6 => /lib/libm.so.6 (0x4009d000) libc.so.6 => /lib/libc.so.6 (0x400ba000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) Should work with gnumeric out of the box. The hacks to configure and the Makefiles are not yet really portable and I doubt Guide would like to include them, but if there's no negative feedback from the Debian community, I will try to clean up the diffs and submit it for review (for those really interested, the diffs are available from Debian archives as python_1.5.2-xyz.diff.gz). Gregor From aa175 at torfree.net Fri Apr 9 14:21:15 1999 From: aa175 at torfree.net (Ken McCracken) Date: Fri, 9 Apr 1999 18:21:15 GMT Subject: Python for embedded controllers? References: <370de606.77891472@news.oh.verio.com> Message-ID: Kevin Dahlhausen (morse at harborcom.net) wrote: : I know you already mentioned the mentioning of Python on this mailing list, but : this was really exciting to me and rest of the snake pit might like it too: : SO, maybe when it's available, their microPython source can serve : as the basis for other embedded systems. Neal Bridges in Toronto, Ont. has been developing an onboard Forth compliler for the Pilot for a while. People seem pretty well enthused about it and it is making converts to the Forth language and reattracting programmers who had given up on Forth. http://www.interlog.com/~nbridges for infomation on Quartus http://www.forth.org for general information Ken McCracken From rphillips at celfi.com Tue Apr 6 08:33:18 1999 From: rphillips at celfi.com (rphillips at celfi.com) Date: Tue, 06 Apr 1999 12:33:18 GMT Subject: newbie questions (Python vs. Perl) References: <37082E26.A9445E43@earthlink.net> Message-ID: <7ecuuf$pih$1@nnrp1.dejanews.com> In article , Lars Marius Garshol wrote: > > * Phil Voris > | > | 1) I hear it's the best for learning OO. > > Maybe. Personally, however, I think that when learning OO it doesn't > matter all that much which language you do it in. All you want is > basically that the language stay out of your way and let you get on > with the learning. > > As such, I think maybe Simula would be the best language to learn OO > in. > > | I have heard high praise of Eifel as well, but information on it > | seems to be scarce at best. > > Try this URL: > > > > Here you'll find lots of informationa and links to other useful > pages. You can also find some useful tutorials. > > However, I don't think Eiffel would be a good learning language. I > tried it and found it difficult to get started, and I also think you'd > do best to stay away from this design-by-contract until you understand > OO. I cannot agee with your last statement. Now, I admit that I may be biased, having preferred Eiffel for over 10 years, but I believe that Design by Contract (DbC) is the heart of OO: even if not supported by the language directly, the ability to specify and reason about the *abstract* behaviour of objects is key to OO. And the more formal we can be about specifying that behaviour, the simpler the job of programming becomes. After all, what is a debugger really for? It is for learning what a given method does/has done - how it affects the state of the running system. This is also the intention of DbC, to state clearly what a method will do, with a trusted specification. Current programming practice seems to be based on a 'try it an see' method, but with ever increasing complexity of software systems, more emphasis needs to be put on design, and not just of data structures, but on program behaviour. Would it not be better to teach this earlier rather than later? - Roy -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From aa8vb at vislab.epa.gov Tue Apr 20 06:52:39 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 20 Apr 1999 10:52:39 GMT Subject: Tkinter Canvas & Fast Scrolling/Dragging In-Reply-To: <00b301be8b13$b0e35300$f29b12c2@pythonware.com>; from Fredrik Lundh on Tue, Apr 20, 1999 at 11:53:46AM +0200 References: <19990416174016.A1559856@vislab.epa.gov> <00b301be8b13$b0e35300$f29b12c2@pythonware.com> Message-ID: <19990420065239.A133007@vislab.epa.gov> Fredrik Lundh: |Randall Hopper: |> Basically, what I want to do is turn off filling of canvas objects |> temporarily while the user is scrolling the canvas or they're dragging one |> of the shapes. When the operation is finished (user releases the mouse), |> I'll turn fill back on. ... | scrollbar.bind("", my_canvas.no_detail) | scrollbar.bind("", my_canvas.full_detail) ... |another solution would be to hook into the scrollbar interface; see |http://www.dejanews.com/getdoc.xp?AN=464786051 |for some details. | |but that only allows you to figure out when to switch to less |detail... you could perhaps switch back after a short timeout, |or when the user moves the mouse back into the canvas. Thanks Fredrik. I'll give it a shot. Randall From dnagata at creo.com Sun Apr 11 19:04:02 1999 From: dnagata at creo.com (Dale Nagata) Date: Sun, 11 Apr 1999 16:04:02 -0700 Subject: bug or feature? traceback with python -x off by one line References: <3710DF00.DF5@creo.com> Message-ID: <37112A62.6E56@creo.com> Blake Winton wrote: > > > @python -x %~f0 %* & goto :EOF > > Hey, that's pretty cool looking... But I have to wonder, why don't you > just type "filename.py"? The associations are set up correctly by > default if I remember correctly, so if you have python installed on the > machine, you don't need the trick. (Say, does that work on Win95/98 as > well? There it could be very handy for some stuff we're doing at > work...) > I don't just type filename.py because I can't be certain that the machine the script will run on has Python installed in the normal way with file type associations defined etc, but I can reasonably expect that it will have a native NT CMD.EXE command interpreter that supports the above cool-looking syntax, and a minimalistic Python run time environment. The above trick doesn't work with the 4NT command interpreter, and I am almost certain it won't with Win95/98's either (and it won't work on NT's built-in CMD.EXE if command extensions are disabled). And besides, redirecting I/O is known not to work properly if you try to use filename.py >filename.out instead of python filename.py >filename.out but it does work if the cool syntax is used. -- Dale Nagata | tel : +1 604.451.2700 ext. 2254 (UTC-0800) Software Developer | fax : +1 604.437.9891 Creo Products Inc. | pgr : +1 604.691.8279 Burnaby BC Canada | http://www.creo.com/ From claird at Starbase.NeoSoft.COM Tue Apr 20 20:35:08 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 20 Apr 1999 19:35:08 -0500 Subject: Time Patterns Message-ID: <7fj6fs$qq9$1@Starbase.NeoSoft.COM> Time calculations interest many pythonians. "Time Patterns" is a paper I think you'll want to see. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From gmcm at hypernet.com Mon Apr 5 20:26:52 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 6 Apr 1999 00:26:52 GMT Subject: Freeze for Windows In-Reply-To: <923335978.611.91@news.remarQ.com> References: <923335978.611.91@news.remarQ.com> Message-ID: <1288767480-69433726@hypernet.com> Jon Cosby asks: > Is it possible to configure 'freeze' for the Win32 binary > installation of Python 1.52? If so, what do I need to do? Nope, freeze requires a source install and a compiler. If you're interested in compilerless ways of distributing Python apps, you should check out http://www.mcmillan-inc.com/install.html Someone did some work to extend this to launching Python/Tk apps; one of these days I'll get around to folding that in... - Gordon From timd at macquarie.com.au Thu Apr 29 03:35:02 1999 From: timd at macquarie.com.au (Timothy Docker) Date: 29 Apr 1999 17:35:02 +1000 Subject: Fatal Python error: PyThreadState_Get: no current thread Message-ID: I've seen questions related to this error in dejanews, but no definitive answer. It seems that this error can indicate a variety of misconfigurations. Here's my situation: I have a program written a while ago under python 1.4 that I am trying to run under python 1.5.1. This program uses Tkinter, and makes no reference to Threads. On my Solaris 2.6 machine here I have python1.4 - compiled without threads python1.5.1 - compiled with threads python1.5.2 - compiled with threads After a lot of reduction, I ended up with the 10 or so lines shown below. If I run it each of the installed versions and press the displayed quit button, I see the following | qad16:tools $ /opt/python/python1.4/sunos5/bin/python test.py | qad16:tools $ /opt/python/python1.5.1/bin/python test.py | Fatal Python error: PyThreadState_Get: no current thread | Abort | qad16:tools $ /opt/python/python1.5.2/bin/python test.py | qad16:tools $ So... what's wrong with my 1.5.1 installation? Have I misconfigured the thread stuff, or is a bug that has been fixed in 1.5.2? There is a note in the Misc/NEWS of 1.5.2 that says that PyThreadState_Get has been replaced by a macro that doesn't do error checking. Does this mean that the problem is still lurking in my 1.5.2 installation? Thanks for any pointers! Tim -------------------- test.py -------------------- import sys from Tkinter import * def cancel(): sys.exit(0) def quitFromWM(event): pass mf = Frame() mf.bind("", quitFromWM ) f = Frame(mf).pack(side=BOTTOM,fill=BOTH) Button( f, text = 'Quit', command = cancel ).pack() mf.mainloop() -------------------------------------------------------------- Tim Docker timd at macquarie.com.au Quantative Applications Division Macquarie Bank From Use-Author-Address-Header at [127.1] Fri Apr 9 21:35:00 1999 From: Use-Author-Address-Header at [127.1] (Andy Dustman) Date: Fri, 9 Apr 1999 21:35:00 -0400 (EDT) Subject: Possible problem with timemodule.c [1.5.2c1] In-Reply-To: <199904091446.KAA00671@eric.cnri.reston.va.us> Message-ID: [I decided not to bug Guido directly with this...] My compile is completely clean except for Modules/timemodule.c: ./timemodule.c: In function `time_strptime': ./timemodule.c:429: warning: assignment makes pointer from integer without a cast This is in time_strptime(), naturally. The code immediately before this is: #ifdef HAVE_STRPTIME /* extern char *strptime(); /* Enable this if it's not declared in */ On Linux, strptime() IS declared in . However, I find nothing in timemodule.c that would cause to be included for Linux. configure does find strptime and does cause HAVE_STRPTIME to be defined in config.h. This is unlikely to be a "showstopper", but I thought I would point it out. This may simply be a Linux (RedHat 5.2) problem. The more I look at , the more I lean towards thie conclusion. The prototype for strptime() is not defined unless __USE_XOPEN is defined. The solution, however, is not obvious. -- andy dustman | programmer/analyst | comstar communications corporation telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d From larsga at ifi.uio.no Mon Apr 5 03:26:22 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 05 Apr 1999 09:26:22 +0200 Subject: newbie questions (Python vs. Perl) References: <37082E26.A9445E43@earthlink.net> Message-ID: * Phil Voris | | 1) I hear it's the best for learning OO. Maybe. Personally, however, I think that when learning OO it doesn't matter all that much which language you do it in. All you want is basically that the language stay out of your way and let you get on with the learning. As such, I think maybe Simula would be the best language to learn OO in. | I have heard high praise of Eifel as well, but information on it | seems to be scarce at best. Try this URL: Here you'll find lots of informationa and links to other useful pages. You can also find some useful tutorials. However, I don't think Eiffel would be a good learning language. I tried it and found it difficult to get started, and I also think you'd do best to stay away from this design-by-contract until you understand OO. | (I have C and Perl experience) Will Python take me to the next level | in terms of understanding OO? You might go there with Python, but it won't do this automatically for you. | 2) Use in the 'real world.' Are companies really using Python? Sure. I work at a company which does, and we're very happy with it. You'll find some references at the Python web site as well. | Articles suggest that Python is preferable to Perl because it's | better for prototyping and more suitable for team projects (than | Perl). In your opinion(s), has this been a major factor in choosing | Python, or is it more enjoyable to program in (than Perl)? We chose Python simply because it was a better language. Easier to build large programs with good structure, more predictable syntax, easier to learn, easier to catch bugs in etc etc | 3) Speed. How much slower is Python than comparable Perl? Yes. More or less. Maybe. Not at all. It depends to a very large degree on what you're doing and how you do it. In general I don't think the speed difference is an issue. | I have read about compiling Python as C or Java and ask myself how | this code compares to code written directly in those languages. The Python2C compiler I haven't tried, but JPython is slower than both pure Java code and CPython. Again, the exact amounts will vary. To take one example, I recently heard from a guy who'd written a performance-critical function in Common Lisp that executed in 623 ?s per call. He has a C version that takes 92 ?s per call, but after heavy optimization he now has a pure Common Lisp version that executes in 4.7 ?s per call. His conclusion was that although the first attempt was likely to be faster in C, Common Lisp made it far easier to try out different strategies and algorithms, so that achieving 5 ?s performance required less effort in CL than in C. I think you'll have similar experiences with JPython and CPython. Usually it's fast enough. When it's not you can usually tune it quite a bit. If that doesn't help you usually at least have a very good algorithm, that you can then translate into C/Java. Predicting the performance ratio of this version against C/Java code I find almost impossible, since performance is to some degree a function of expended optimization effort. (It's also usually related to your choice of language implementation.) To take another example, I've written a validating XML parser in Python, which I've spent quite a bit of time optimizing since version 0.50 (which was unoptimized). Version 0.50 chewed through my benchmark suite in 49 seconds when not validating and 599 seconds when validating (one document has a 2K document and a fiendishly complex 79K DTD). The version currently in my CVS tree does the benchmark suite in 21 and 48 seconds respectively, and I still haven't tried rewriting any of it in C. So a fixed comparison ratio between languages is at best useless and probably misleading. --Lars M. From gmcm at hypernet.com Thu Apr 22 18:06:27 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 22 Apr 1999 22:06:27 GMT Subject: thread problem on Linux In-Reply-To: <924813824.1@idas.cz> References: <924813824.1@idas.cz> Message-ID: <1287303501-36876734@hypernet.com> Vaclav/2 writes: > > I have an account on some Linux machine in school, so I thought I > would test Python's portability, one of the reasons why I love it. > I use OS/2, so I only had experience with Python on OS/2, but I > assumed everything should work the same on Linux. > > There was Python 1.5.1 on the Linux machine. My first problem was > that it didn't have the thread module. So I downloaded the most > recent RPM of Oliver Andrich with Python 1.5.2 for Linux, but > because I don't have sufficient rights on the machine to install > the whole RPM, I only extracted the one executable file to my home > directory and tried again. The thread module is there, but doesn't > work! thread.start_new_thread doesn't throw an exception, but the > new thread simply doesn't run. When I accidentally pressed Ctrl+D, > it seemed to run for a while, but then the whole script froze. > > Would somebody please have an idea of what could be wrong? I admit > that my knowledge of Unix is very limited, so perhaps this is an > issue with Linux???? Very much. It all depends on your Linux version / distribution, (threading that works with Python is a fairly recent thing in Linux). With that information, someone can probably tell you what is needed to get Python threading working. But if you don't have the rights to install an RPM, don't get your hopes up... - Gordon From arcege at shore.net Mon Apr 5 11:58:52 1999 From: arcege at shore.net (Michael P. Reilly) Date: Mon, 05 Apr 1999 15:58:52 GMT Subject: nested map() ? References: <19990405085816.A787115@vislab.epa.gov> Message-ID: <055O2.1106$eJ.194719@news.shore.net> Randall Hopper wrote: : To generate all permutations of list elements in Perl, it's sometimes : useful to do this: : @result = map { $a = $_ ; map{ "$a$_" } @B } @A : Is there a relatively short way to do this in Python? : Thanks, : Randall This assumes that you want to take advantage of Perl's flat array limitation (i.e. putting an array as an element of an existing array performs a form of a slice). You can do this with map and reduce, but it's not the simplest, fastest, shortest method. result = reduce( lambda a, b: a + b, map( lambda aitem, b=b: map( lambda bitem, aitem=aitem: "%s%s" % (aitem, bitem), b ), a ) ) This can be done more efficiently with: result = [] for aitem in a: for bitem in b: result.append( "%s%s" % (aitem, bitem) ) Also, you might want to store `(aitem, bitem)' instead of `"%s%s" % (aitem, bitem)'. Unless you _need_ the string concatenation, storing a tuple of the two objects would make them easier to use later. -Arcege From ben_darnell at hotmail.com Mon Apr 26 18:41:22 1999 From: ben_darnell at hotmail.com (Ben Darnell) Date: Mon, 26 Apr 1999 17:41:22 -0500 Subject: Launching web browser programmatically Message-ID: <3724EB92.248E7933@hotmail.com> [I seem to remember a recent thread about this, but I can't find it on DejaNews. I apologize for any redundancy] How do I launch the the user's web browser programmatically on Win9x? I can use "start http://www.python.org" at the command line, but "os.system('start http://www.python.org')" doesn't work properly. The python process seems to hang. When I kill python with the task manager, the web browser does appear. What is going wrong here? Ben Darnell ben_darnell at hotmail.com From dalke at bioreason.com Tue Apr 27 19:36:59 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Tue, 27 Apr 1999 17:36:59 -0600 Subject: help References: Message-ID: <37264A1B.65247D50@bioreason.com> Ivan Van Laningham wrote: > Oh, they won't even let me talk in meetings around here anymore. I just > *look* like I'm going to open my mouth and they all yell, ``Yes, we > *know* we should use Python!'' Moshe Zadka replied: > Don't we all know that feeling? Just to contribute to the ``preaching > python and getting hit for it'' Just to rub people's noses in it; we're a Python shop and I haven't had that feeling for almost a year. :) Andrew dalke at bioreason.com From guido at CNRI.Reston.VA.US Fri Apr 9 11:21:19 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Fri, 09 Apr 1999 11:21:19 -0400 Subject: Python 1.5.2c1 -- What if long long not supported? Message-ID: <199904091521.LAA00858@eric.cnri.reston.va.us> I received a bug report that if the (unnamed) platform doesn't support the "long long" type, the configure script dies. The logic in configure.in looks correct to me and I don't have any such Unix platforms handy myself... Could someone who does investigate whether there is truth in this complaint? (PS, for PSA members who don't follow the newsgroup: Python 1.5.2c1 was released last night, see http://www.python.org/1.5/.) --Guido van Rossum (home page: http://www.python.org/~guido/) From davecook at home.com Wed Apr 7 04:15:36 1999 From: davecook at home.com (David M. Cook) Date: Wed, 07 Apr 1999 08:15:36 GMT Subject: Python and Qt+KDE References: <36F940DC.44F08BDF@druga.com> <7dbtb8$38j$1@nnrp1.dejanews.com> <7dec78$977$1@Starbase.NeoSoft.COM> <36FB0C5F.E6CE768D@zarlut.utexas.edu> <199903290118.UAA05150@mira.erols.com> <3708D549.12844324@trust.ee> Message-ID: On Tue, 6 Apr 1999 07:21:30 GMT, boud at rempt.xs4all.nl wrote: >full-featured. WxWindows was rather nice (and portable), but rather >complicated to install. The documentation is very reasonable. Gtk is in >so rapid a development Actually the stable Gtk 1.2 has been out for a couple months now, and pygtk was pretty much Gtk 1.2 ready when it came out. >that it would be difficult to decide which >version to work with - and I didn't think much of the framework It's not a framework; it's a toolkit. GNOME, on the other hand, does provide a framework. >as presented by the example applications. TkInter looks nice Well, tkinter is not a framework, either. pygtk has more widgets than tkinter and is much faster, but otherwise I find a lot of similarities between them. Some aspects of Gtk are obviously inspired by Tk. >- as can be >seen from Grail or PySol - but is rather underdocumented. Frederick Lundh's intro is pretty good, http://www.pythonware.com/library/tkinter/introduction/ but Tkinter makes a lot more sense to those who know Tcl/Tk already. Dave Cook From bend at realeducation.com Tue Apr 6 17:15:11 1999 From: bend at realeducation.com (Benjamin Derstine) Date: Tue, 6 Apr 1999 15:15:11 -0600 Subject: How to use os.path.walk method Message-ID: <7edt95$krh$1@ash.prod.itd.earthlink.net> Can anyone give me a brief example of how to use this method? The documentation is somewhat unclear: walk (path, visit, arg) Calls the function visit with arguments (arg, dirname, names) for each directory in the directory tree rooted at path (including path itself, if it is a directory). The argument dirname specifies the visited directory, the argument names lists the files in the directory (gotten from os.listdir(dirname)). The visit function may modify names to influence the set of directories visited below dirname, e.g., to avoid visiting certain parts of the tree. (The object referred to by names must be modified in place, using del or slice assignment.) I understand I need to define a second function for the visit argument but I'm unclear as to the third argument (arg) in walk() is for. Likewise with the first argument in visit(). I tried a dummy function just to print the directories it walks like so: import os def visit(something, dirname, names): print dirname print names print something arg=None os.path.walk('/Windmodem/',visit,arg) where 'Windowmodem' is a directory on my root. But this does nothing and quits without returning any errors. Thanks, Ben From sjb at rockford.crosswinds.net Fri Apr 16 19:58:29 1999 From: sjb at rockford.crosswinds.net (Samuel Bridgeland) Date: Fri, 16 Apr 1999 23:58:29 GMT Subject: configuring 1.5.2 Message-ID: I've just compiled Python 1.5.2(linux) but I somehow forgot to conifgure it for tk and such. Is there any way to configure it without having to recompile it? -- Samuel Bridgeland sjb at rockford.crosswinds.net http://www.crosswinds.net/rockford/~sjb/ From mal at lemburg.com Wed Apr 21 04:31:19 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 21 Apr 1999 08:31:19 GMT Subject: Date/Time conversions References: <371BEBA7.5DBC1B0F@qut.edu.au> Message-ID: <371D8CD7.5AF50140@lemburg.com> Rico Albanese wrote: > > I am writing a web based database application and I am having problems > in creating a string that contains an integer in it. I wish to store > the login time as an integer so that I may do some time difference > calculations based on the stored login time (ie. the integer). The > SQL statement string creation fails when I have the integer variable > "logtime" in it but not when it is removed. I believe that my problem > is caused by trying to insert an integer into a string. The database > works fine (ie I can add integers to the column "LogTime"). Note that you should *bind* variables to parameters in the SQL statement rather than insert them literaly into the statement itself, e.g. c.execute('insert into table values (?,?)',(123,'string')) rather than use c.execute('insert into table values (123,"string")') See the database topic guide on www.python.org for more details. -- Marc-Andre Lemburg Y2000: 254 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From mfletch at vrtelecom.com Tue Apr 13 10:41:09 1999 From: mfletch at vrtelecom.com (Mike Fletcher) Date: Tue, 13 Apr 1999 14:41:09 GMT Subject: Lexical analyzers and parsers Message-ID: http://starship.skyport.net/~mcfletch/ Has the VRML processing libraries (based on mcf.pars (i.e. the package is in there)) and the simpleparse package (the one based on mxTextTools. It seems Andrew's page assumed the new starship (to which I still haven't added the updated packages). Suppose I should do that when I get a chance. Mike ____________________________________________________ Mike C. Fletcher -- Virtual Environment Designer mcfletch at vrtelecom.com http://www.vrtelecom.com > -----Original Message----- > From: Michael Hudson [SMTP:mwh21 at cam.ac.uk] > Sent: Tuesday, April 13, 1999 6:00 AM > To: python-list at cwi.nl > Subject: Re: Lexical analyzers and parsers > > "Andrew M. Kuchling" writes: > > Julien Oster writes: > > >What about lexical analyzers and parsers? > > > > > >Under C I use bison/yacc and (f)lex. Under python, I can either > implement this > > >stuff using C or try to write my parsers on my own, which is real pain. > > > > There are actually a bunch of different systems available; see > > http://starship.python.net/crew/amk/python/string.html#parsing > > for a list. (If I've missed any, let me know.) > > A lot of those links are a bit dated: > > kwParsing should probably link www.chordate.com, not the starship > mcf.pars seems to have gone missing; I can't find it at any rate. > "A parser generator based on M.-A. Lemburg's mxTextTools" likewise > The link to PyBison got me a "connection refused"; this may be > temporary (or not) > > These are the first four on the list, which is a little disconcerting! > > All the others work. > > Now I have to find one I can use.. > > HTH > > Michael Hudson From paul at prescod.net Sun Apr 11 23:58:51 1999 From: paul at prescod.net (Paul Prescod) Date: Mon, 12 Apr 1999 03:58:51 GMT Subject: Python without registry entries References: <370fb711.28093946@news.demon.co.uk> <7eol16$1l2$1@m2.c2.telstra-mm.net.au> <37121820.3758204@news.netmeg.net> Message-ID: <37116F7B.3E3088EB@prescod.net> Les Schaffer wrote: > > On Sun, 11 Apr 1999 08:57:49 +1000, "Mark Hammond" wrote: > > >You can. Python does not _need_ the registry for anything. > > said differently, if one doesnt need the registry entries for anything > pythonic, why are there these whole slew of entries made when its > installed? I would prefer if PythonWin did what Netscape does which is put the vast majority of setup information in a text file in the Netscape directory and make a single pointer to that from the registry. I can have Netscape executables on two different operating systems on two different partitions banging on the same configuration files (as long as I only use one at a time) . Yes, this is a reversion to the way things were done before the registry. That just demonstrates that not all change is progress! -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco By lumping computers and televisions together, as if they exerted a single malign influence, pessimists have tried to argue that the electronic revolution spells the end of the sort of literate culture that began with Gutenberg?s press. On several counts, that now seems the reverse of the truth. http://www.economist.com/editorial/freeforall/19-12-98/index_xm0015.html From tim_one at email.msn.com Sat Apr 24 01:40:32 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 24 Apr 1999 01:40:32 -0400 Subject: Suggestion for alternative to map/filter functions In-Reply-To: Message-ID: <000a01be8e14$f8528400$f09e2299@tim> Note that there was a long & highly developed thread about Pythonic list comprehensions last August. Guido didn't hate the idea . high-praise-indeed-ly y'rs - tim From fquiquet at lemel.fr Mon Apr 19 04:43:29 1999 From: fquiquet at lemel.fr (fquiquet at lemel.fr) Date: Mon, 19 Apr 1999 08:43:29 GMT Subject: How to merge data in a existant file Message-ID: <7feqbf$pr6$1@nnrp1.dejanews.com> Hi, I use python to developp script file. I have a problem when I want to write data in a existant file. I know how to write data in a new file : f=open('file.name','w') f.write('data') f.close() I don't know what is the function that permit to add data whithout erase existing data. Thank's for your response to fquiquet at lemel.fr -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From thooney at pk.highway.ne.jp Thu Apr 29 03:44:25 1999 From: thooney at pk.highway.ne.jp (Thooney Millennier) Date: Thu, 29 Apr 1999 16:44:25 +0900 Subject: to make python shell window Message-ID: <37280DD9.A89F30F7@pk.highway.ne.jp> Hello,everyone. I want to make shell window to use python commandline interface. It seems difficult to interact with python by PyRun_InteractiveLoop. I don't figure out how to avoid using standard input and how to convey input string and gui events(such as ctrl-d) to python. Is it possible by using PyRun_InteractiveLoop ? Or I should use another function ? If you know good way to make shell window to use python, please let me know. Thanks for reading. Thooney Millennier too at pk.highway.ne.jp From rparra at abo.fi Mon Apr 26 12:10:49 1999 From: rparra at abo.fi (Raul Parra Bacete FS) Date: Mon, 26 Apr 1999 19:10:49 +0300 Subject: I need test .py files Message-ID: <37249009.AA2B13CA@abo.fi> Hi, I have ported the python interpreter to the sh1 hitachi, and now I would like to get .py programs to test my python interpreter... that programs should not have any import statment or any reference to files, so I need some BASIC .py programs to test my python I wonder if you could give me any addres where I can get some of them or send me some of them by e-mail.... Thanks. Raul Parra Bacete ?bo Akademi rparra at abo.fi From roy at popmail.med.nyu.edu Sat Apr 24 12:57:44 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Sat, 24 Apr 1999 12:57:44 -0400 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <37215EFB.433AFCA6@prescod.net> Message-ID: Paul Prescod wrote: > One benefit would be that the compiler could compile regexps at the same > time everything else is being compiled. It is extremely rare that regex compilation time is a major issue. If you're using a regex inside your inner loop and the amount of data you feed through it is large enough to matter, you should be compiling it yourself outside the loop. It's still done at run-time, but it's only done once so it's almost certainly a trivial amount of time devoted to that. From faassen at pop.vet.uu.nl Tue Apr 20 14:10:49 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Tue, 20 Apr 1999 20:10:49 +0200 Subject: opening more than 1 file References: <371CB255.5FCAFBAF@solair1.inter.NL.net> Message-ID: <371CC329.F22B534F@pop.vet.uu.nl> martin van nijnatten wrote: > > I have a variable, which can have a value in the range from 1 to 20. > > If the value is 7, I have to open 7 files. > > What could be an elegant way of doing this? It's hard to say without more details -- what names do you want these files to have, for instance? Do you want to read the files, or write to them? The basic idea could be something like: def openfiles(howmany): opened_files = [] for i in range(howmany): opened_files.append(open("prefix%s" % i, "r")) return opened_files This returns a list with file objects. Why is it necessary to open so many files simultaneously anyway? Perhaps I misunderstood. :) Regards, Martijn From moshez at math.huji.ac.il Wed Apr 21 15:38:48 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Wed, 21 Apr 1999 22:38:48 +0300 Subject: New python user seeks comments In-Reply-To: References: <371DA955.9F13B144@pop.vet.uu.nl> Message-ID: On 21 Apr 1999, Chad McDaniel wrote: > Martijn Faassen writes: > > David Steuber wrote: > > > expected. Who would have guessed that you couldn't give a file object > > > thename 'in'? Or at least that was one of the weirder obstacles. > > > > It's not that weird as 'in' is a reserved keyword in Python. :) > It seems that Python could have mentioned that to the user. This is a valid criticism: >>> in=1 File "", line 1 in=1 ^ SyntaxError: invalid syntax An error message like 'invalid usage of reserved word' would go a long way to help the programmer. I'm not well aquainted enough with the parser to know whether this is possible or not... -- Moshe Zadka . QOTD: What fun to me! I'm not signing permanent. From ivnowa at hvision.nl Wed Apr 14 18:09:14 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Wed, 14 Apr 1999 22:09:14 GMT Subject: what do you do with Python In-Reply-To: <3714C9EA.86C0A4E@earthlink.net> References: <3714C9EA.86C0A4E@earthlink.net> Message-ID: <199904142107.XAA19293@axil.hvision.nl> On 14 Apr 99, Ce'Nedra took her magical amulet and heard susan e paolini say: >I never see jobs with Python advertised so what is it that Python does? >Thanks for the advice Ask not... what Python can do for you! But what you can do for Python! :^) Hmm, seriously though, it's good for a lot of things. I'm sure that there are lots of people around who can explain it better than I can, but I'll give it a try anyway. Python is a highly flexible and dynamic language, useful for programs ranging from simple scripts to large projects (for instance, the Grail web browser). It's also very readable and thus maintainable. It provides ways for object-oriented, procedural and even functional programming (to some extent). If Python itself doesn't do what you want, you can extend it in C, or possibly another language if your platform allows it. Myself, I'm using it for just about everything now. I wrote a Magic the Gathering database & search engine, a Vedic astrology program, a board game, a signature file generator, a spell checker, a card game, an ftp thingy, etc. etc. and *lots* of little scripts to make life easier. Yadda yadda yadda... I'm sure you get the idea. Check out the Python homepage (http://www.python.org) for more info and advocacy. Veel liefs, + Hans Nowak (Zephyr Falcon) + Homepage (under construction): http://www.cuci.nl/~hnowak/ + You call me a masterless man. You are wrong. I am my own master. + May a stockbroker give unwanted advice about your wig! From tismer at appliedbiometrics.com Fri Apr 23 10:05:20 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 23 Apr 1999 14:05:20 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> Message-ID: <37207E20.21D3CCDD@appliedbiometrics.com> Arne Mueller wrote: > def read_write(i, o, exclude): > name = compile('^>(\S+)') # regex to fetch the identifier > l = i.readline() > while l: > if l[0] == '>': # are we in new dataset? > m = name.search(l) > if m and exclude.has_key(m.group(1)): # excluding current > dataset? > l = i.readline() > while l and l[0] != '>': # skip this dataset > l = i.readline() > pass > o.write(l) > l = i.readline() > > f = open('my_very_big_data_file','r') # datafile with ~300000 records > read_write(f, stdout, {}) # for a simple test I don't exclude anything! > > It took 503.90 sec on a SGI Power Challange (R10000 CPU). An appropiate > perl script does the same job in 32 sec (Same method, same loop > structure)! Without changing the program structure, I could make it run about 3 or 4 times faster by using string.split instead of a regex here. To get more speed, one would have to do more. Summarizing: Stay with the Perl code, if you need it so fast. Perl is made for this real world low-level stuff. Python is for the real world high level stuff. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 ivnowa at hvision.nl Wed Apr 7 02:26:21 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Wed, 7 Apr 1999 06:26:21 GMT Subject: Chaning instance methods In-Reply-To: References: Message-ID: <199904070524.HAA12210@axil.hvision.nl> On 6 Apr 99, Ce'Nedra took her magical amulet and heard Jody Winston say: >I don't understand how to change instance methods. For example: > >class Foo: > def __init__(self): > self.data = 42 > def m(self): > print "Foo.m" > print dir(self) > >def m2(self): > print "m2" > print dir(self) > >f = Foo() >f.m() ># this fails ># f.m = m2 ># f.m() I'm not sure, but I think it works like this... Foo.m and f.m are somehow related to Foo or its instances... they're methods; m2, however, is just a function. When you do something like 'f.m = m2' you attach a plain old function to a class instance. Python apparently does not like this; 'f.m()' won't work anymore, since the language does not do an automatic conversion from function to method (although they look the same!). To call such a function, you could do f.m = m2 f.m(f) # need to provide 'self' explicitly which is probably not what you want. To be honest, I don't really have a good solution to this. Anybody else? >Foo.m = m2 # Changes all instances of Foo.m >f.m() This works because m2 is "injected" though Foo, and thus accepted as a method. Try to print Foo.m; it'll say "unbound method". And printing f.m will show that m2 is accepted as a method in f, too. :^S >f2 = Foo() >f2.m() Veel liefs, + Hans Nowak (Zephyr Falcon) + Homepage (under construction): http://www.cuci.nl/~hnowak/ + You call me a masterless man. You are wrong. I am my own master. + May an orc cheat on your fiance with your life! From m.e.owen at btinternet.com Sun Apr 25 17:34:34 1999 From: m.e.owen at btinternet.com (Mark E. Owen) Date: Sun, 25 Apr 1999 22:34:34 +0100 Subject: perl v python Message-ID: <37238A6A.E245337D@btinternet.com> I've been using perl quite some time, just starting looking at Python. what's peoples views/comparisons of both languages? Cheers Mark From mark at markjreeves.com Sun Apr 11 16:35:32 1999 From: mark at markjreeves.com (Mark J. Reeves) Date: Sun, 11 Apr 1999 16:35:32 -0400 Subject: a few questions... Message-ID: <7er13p$bnl5@ic5.ithaca.edu> We are a group of students who are working with python and we have a few questions. 1. How do we from the command line open a script to run it? 2. (Jpython) We can't get the coordinates demo to run locally using appletDemo.jar. It gives us a name error. All of the other examples run. That's all for now. Please reply by email at mreeves at ic3.ithaca.edu. Thank you. From Gaetan_Corneau at baan.com Fri Apr 9 09:23:12 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Fri, 9 Apr 1999 13:23:12 GMT Subject: import from user input? Message-ID: <816010E2456BD111A48700805FBBE2EEA63EB7@ex-quebec-u1.baan.com> Hello, I want to import modules at runtime, and get the module name from the user. Is that possible? How? Another question: is there a function to copy/move entire directory trees? TIA, ______________________________________________________ Gaetan Corneau Software Developer (System integration Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 654-1454 ext. 252 ______________________________________________________ "Profanity is the one language all programmers know best" From faassen at pop.vet.uu.nl Tue Apr 27 04:53:30 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Tue, 27 Apr 1999 10:53:30 +0200 Subject: help References: <19990426163014.B20207@toast.internal> <3724D1C3.8BFA2C5B@pop.vet.uu.nl> <3724DEFC.A01E93C2@callware.com> Message-ID: <37257B0A.AF4C8E4C@pop.vet.uu.nl> Ivan Van Laningham wrote: > Oh, they won't even let me talk in meetings around here anymore. I just > *look* like I'm going to open my mouth and they all yell, ``Yes, we > *know* we should use Python!'' Yeah, that happened to me for a while - I had to cut down drastically on the use of the word 'Python'. :) So *do* they use Python over there? I mean, now that they all know they should? Regards, Martijn From jschiotz at hotmail.com Thu Apr 29 05:08:37 1999 From: jschiotz at hotmail.com (Jakob Schiotz) Date: Thu, 29 Apr 1999 09:08:37 GMT Subject: WARNING: AIX and dynamic loading. References: <7g4i77$qif$1@nnrp1.dejanews.com> <3726DDD9.19A1@mailserver.hursley.ibm.com> Message-ID: <7g97ik$58$1@nnrp1.dejanews.com> In article , Konrad Hinsen wrote: > On my system (running AIX 4.3.1), it is *impossible* to overwrite > a shared library that has ever been loaded; all you get is an error > message claiming that the file is being used. Even if the directory is NFS mounted? NFS file locking usually doesn't work - and there may be the additional problem of another machine using the module. It sure would be nice if it has been fixed in AIX 4.3 > > > > SOLUTION: > > > You makefile should remove the old module (the .so file) before copying the > > > new version into the installation directory. Then the file gets a new > > This is what I had to do as well, in order to be able to copy a new > version. With that I never had any problems. I guess that is the safest thing to do whenever you are installing an executable or a shared object - somebody might be running it. Happy programming! :-) Jakob -- Jakob Schiotz, CAMP and Department of Physics, Tech. Univ. of Denmark, DK-2800 Lyngby, Denmark. http://www.fysik.dtu.dk/~schiotz/ This email address is used for newsgroups and mailing lists (spam protection). Official email: schiotz @ fysik . dtu . dk -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From kajiyama at grad.sccs.chukyo-u.ac.jp Tue Apr 6 15:51:49 1999 From: kajiyama at grad.sccs.chukyo-u.ac.jp (Tamito Kajiyama) Date: 06 Apr 1999 19:51:49 GMT Subject: Tkinter bug in Misc.tkraise, Canvas.tkraise In-Reply-To: "John Michelsen"'s message of Mon, 5 Apr 1999 10:04:34 -0700 References: <7eaoop$leq$1@news-2.news.gte.net> Message-ID: "John Michelsen" writes: | | I found a bug in using Tkinter to raise a canvas widget above later | packed (etc.) widgets. It seems Tkinter gets confused between the | Misc.tkraise() method and the Canvas.tkraise(item) methods. | The following script shows the problem: | | from Tkinter import * | | def raiseCanvas(): | canvas1.lift() | #canvas1.tkraise() | #canvas1.widgetlift() | | root = Tk() | canvas1 = Canvas(root, bg='blue') | canvas1.place(x=10, y=10, anchor=NW) | canvas2 = Canvas(root, bg='red') | canvas2.place(x=20, y=20, anchor=NW) | raiseButton = Button(root, text='raiseCanvas', command=raiseCanvas) | raiseButton.pack() | root.geometry("%dx%d" % (100,100)) | root.mainloop() You can call Misc.lift (overriden by Canvas.lift) as follows: def raiseCanvas(): Misc.lift(canvas1) In general, you can call a base class method overriden by a subclass method by BaseClassName.methodname(SubClassInstance, arguments). You'll find that the same technique is used in the __init__ methods of the Tkinter widget classes. -- KAJIYAMA, Tamito From hat at se-46.wpa.wtb.tue.nl Fri Apr 23 10:15:00 1999 From: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) Date: 23 Apr 1999 14:15:00 GMT Subject: Suggestion for easier c/c++ interfacing Message-ID: Hello all, I have been experimenting with c++ and Python, and am working on attaching generated c++ module-code to python. In the EXT document, it is explained how to parse arguments from python in c code using PyTuple_ParseArgs(). This is really easy to use. However, the same kind of parsing must occur after a call from c to a python function. The return value from that function is again a Python object, and needs to be decoded before it can be used in c. Unfortunately, the returned value is not a tuple, so PyTuple_ParseArgs() cannot be used. A shortcut would be to wrap the result in a tuple with 1 argument, and then call the decoding function, but I consider that a hack. Wouldn't it be possible to create a PyTuple_ParseArgs()-like function to parse return results from python functions ? Albert --- Look ma, windows without Windows !! From MHammond at skippinet.com.au Mon Apr 26 19:09:15 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 27 Apr 1999 09:09:15 +1000 Subject: Launching web browser programmatically References: <3724EB92.248E7933@hotmail.com> Message-ID: <7g2rm1$t8i$1@m2.c2.telstra-mm.net.au> If you have the win32 extensions, you can use win32api.ShellExecute() Anything you can use after "start" you can pass to ShellExecute - ie, a URL, a document file, .exe, etc. Mark. Ben Darnell wrote in message <3724EB92.248E7933 at hotmail.com>... >How do I launch the the user's web browser programmatically on Win9x? I >can use "start http://www.python.org" at the command line, but From john.michelsen at gte.net Tue Apr 6 16:53:31 1999 From: john.michelsen at gte.net (John Michelsen) Date: Tue, 6 Apr 1999 13:53:31 -0700 Subject: Tkinter bug in Misc.tkraise, Canvas.tkraise References: <7eaoop$leq$1@news-2.news.gte.net> Message-ID: <7edv6p$eh4$1@news-1.news.gte.net> >Until then, I would suggest the following fix: > > from Tkinter import Canvas > Canvas.tag_raise = Canvas.tkraise > del Canvas.tkraise, Canvas.lift > >This should correct the problem. Yep, that works too. Thanks. John From joe at strout.net Fri Apr 23 20:18:21 1999 From: joe at strout.net (Joe Strout) Date: Fri, 23 Apr 1999 17:18:21 -0700 Subject: call for comments on Graphite plotting package Message-ID: I'm part of a small team working on a new package called Graphite. It's an open-source plotting package written entirely in Python, designed primarily for the following requirements: 1. cross-platform and cross-media (i.e., native onscrene graphics for Windows/X-Windows/MacOS, and output to a variety of formats including print-quality PostScript and PDF) 2. fully portable; no reliance on C libraries with limited portability 3. professional-quality graphing power (e.g., similar to Matlab) We're still in the design/prototyping phase, and we'd like to get your input. We know what our needs are, but we may not understand your needs -- we're relying on you to tell us. If you're willing, please go to the Graphite web site: http://www.strout.net/python/graphite/ And check out the Vision Statement and Requirements documents. The others provide additional design details if you're interested. Do the requirements we've outlined meet your needs? Have we omitted any major functionality? Do you forsee problems with the design? In short, does this look like a tool you will use, and if not, why not? Thanks very much for whatever input you're able to give. We'll do our best to reward your investment by producing a great plotting package we all can use. Best regards, -- Joe Strout -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' From frneh at wmdata.com Fri Apr 16 07:20:39 1999 From: frneh at wmdata.com (Fredrik Nehr) Date: Fri, 16 Apr 1999 13:20:39 +0200 Subject: Bug in Python 1.5.1 (with all patches) on Solaris 7? Message-ID: <7f76eh$ijj@news2.newsguy.com> I'm experience different behaivors when running the same instructions as script and interactively, the interactive behaivor is correct. Example: 603 ~ $ cat foo.py import string print string.lower('ABC123???') 604 ~ $ python foo.py abc123??? 605 ~ $ python Python 1.5.1 (#1, Mar 22 1999, 17:07:44) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import string >>> print string.lower('ABC123???') abc123??? >>> Can anyone explain this behaivor? /FN From R.Hooft at EuroMail.com Mon Apr 26 03:08:13 1999 From: R.Hooft at EuroMail.com (Rob Hooft) Date: 26 Apr 1999 09:08:13 +0200 Subject: package.module != module References: Message-ID: >>>>> "QD" == Quinn Dunkan writes: QD> I have discovered that apparently python's mechanism for QD> discovering if a module has already been imported fails when you QD> import a "fully qualified" package previously imported as a QD> sister. i.e.: Feature. If you're running a program "publish" from a directory called "package" that does not make this directory into a package. Hence, importing "sister" just imports it from the "current directory" whereas importing "package.sister" initializes the package and then imports sister from it. Moral is: don't put "programs" into packages, or always import fully qualified module names. I had the same problem before: http://www.dejanews.com/[ST_rn=ap]/getdoc.xp?AN=437913465 Regards, -- ===== R.Hooft at EuroMail.net http://www.xs4all.nl/~hooft/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From fredrik at pythonware.com Fri Apr 23 07:55:31 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 23 Apr 1999 11:55:31 GMT Subject: learning Python (rat book) References: Message-ID: <01f601be8d80$31cbe950$f29b12c2@pythonware.com> > The rat has landed! I managed to get my hands a copy at the Stanford > University Bookstore today. just got one on my desk (in Link?ping, Sweden). looks great! (what else can I say about a book that has my name in the index? ;-) smurf 1.5.2 is out, btw: http://www.smurfalizer.com/smurfalize?url=http://www.python.org/1.5 From faassen at pop.vet.uu.nl Tue Apr 27 07:04:54 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Tue, 27 Apr 1999 13:04:54 +0200 Subject: Designing Large Systems with Python References: Message-ID: <372599D6.C156C996@pop.vet.uu.nl> David Steuber wrote: [snip interesting discussion on prototype building/RAD of large systems with Python] I'm interested in what other people will have to say about this -- don't know anything myself now though. :) > One other thing. Is the documentation that comes with Python > sufficient to gain mastery of the language, or should I consider > buying (yet) another book? If you're already a fairly experienced programmer (with some idea of what object oriente programming is), the Python tutorial is an excellent way to get started. The library reference is very helpful. The language reference is useful when there are tricky bits. Then there's the newsgroup for questions, of course. I haven't had any problem figuring out Python using the standard Python documentation, along with the newsgroup, myself. There *are* still tricky bits (like using a mutable object as a default argument), but in general I haven't found Python hard to learn at all. Regards, Martijn From MHammond at skippinet.com.au Fri Apr 9 20:30:55 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 10 Apr 1999 10:30:55 +1000 Subject: pythonwin COM Update link out of date References: Message-ID: <7em639$fto$1@m2.c2.telstra-mm.net.au> Bernhard Reiter wrote in message ... >http://www.python.org/ftp/python/pythonwin/pwindex.html#oadist > >Gives a bad link to the MS Microsoft Knowledge Base article Q164529. >The link is bad and I cannot relocate the article with the search >engine on that site and other methods... :( > >The closest I could get was: > http://support.microsoft.com/support/kb/articles/Q139/4/32.asp >from > http://support.microsoft.com/support/downloads/LNP195.asp > >Hmmmm.... is there a potential danger in installing oadist.exe? There _shouldnt_ be any danger! These days it is getting quite unnecessary. If you have (I believe) IE4 or Office 97, you are pretty up-to-date, and that includes many PCs these days. You could try installing the Python stuff, and see if it works. Also, see my other post this morning as to why the install may fail - try this out first. Mark. From paul at prescod.net Wed Apr 14 18:29:27 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 14 Apr 1999 22:29:27 GMT Subject: what do you do with Python References: <3714C9EA.86C0A4E@earthlink.net> Message-ID: <371516C7.41A908F2@prescod.net> susan e paolini wrote: > > I never see jobs with Python advertised so what is it that Python does? > Thanks for the advice Python solves hard problems elegantly. Python jobs aren't advertised because usually people take "ordinary" jobs and turn them into Python jobs. For instance if you get a job solving some really complicated sort of math problem, or building a complicated text management system your boss often only cares about the end result, not the language you do it in. So we choose the best language for the job which is often Python. So the question isn't "what Python does" but "what do you need to do?" -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco By lumping computers and televisions together, as if they exerted a single malign influence, pessimists have tried to argue that the electronic revolution spells the end of the sort of literate culture that began with Gutenberg?s press. On several counts, that now seems the reverse of the truth. http://www.economist.com/editorial/freeforall/19-12-98/index_xm0015.html From mal at lemburg.com Thu Apr 29 18:07:46 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 30 Apr 1999 00:07:46 +0200 Subject: Read MS Access 97 *.mdb files with python?? References: <37287369.D6E67313@t-online.de> <3728867D.94B5BBF9@appliedbiometrics.com> <3728A903.CF75B41A@pop.vet.uu.nl> <3728B7DF.80E23481@t-online.de> Message-ID: <3728D832.AA4B72A@lemburg.com> gemodek wrote: > My idea is the following: > At my company we are running 4 Win95 PC's on a network which works > sometimes > and crash sometimes (some days no reboot, some days 5-10 times). > Now I am tired of the whole Win stuff, and I will install an Linux > Server > with Samba. (OK, the clients are still Win95, but at least the server is > linux). > We use also a software which is based on Access. The whole database (mdb > files) will reside on the Linux server. > So far so good. > But now, I want to extract some information out of the access database > to > create html files which everybody in our company is alowed to view. > And for this I need "access to Access". For the file format try: http://www.wotsit.org/ Don't know whether they list it, but if they don't it's likely that it's not published anywhere. An alternative approach is using an Intersolv or OpenLink multi-tier ODBC setup. Or use the EasySoft ODBC-ODBC bridge to fill the gap between Linux and WinXX. Then hook up Python to one of these using mxODBC (follow the link below). PS: I think I already mentioned this some days ago... under a different subject, though. -- Marc-Andre Lemburg Y2000: 246 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From aahz at netcom.com Thu Apr 22 18:48:19 1999 From: aahz at netcom.com (Aahz Maruch) Date: Thu, 22 Apr 1999 22:48:19 GMT Subject: try vs. has_key() Message-ID: I've seen roughly half the people here doing try: dict[key].append(foo) except: dict[key]=[foo] with the other half doing if dict.has_key(key): dict[key].append(foo) else: dict[key]=[foo] Can people explain their preferences? -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het "You often don't really understand the problem until after the first time you implement a solution." - Eric S. Raymond From chad at vision.arc.nasa.gov Thu Apr 8 14:18:09 1999 From: chad at vision.arc.nasa.gov (Chad Netzer) Date: Thu, 08 Apr 1999 11:18:09 -0700 Subject: Crappy Software was References: <1288614834-78399188@hypernet.com> <000a01be8188$b7f56280$749e2299@tim> Message-ID: <370CF2E1.3D2E44E0@vision.arc.nasa.gov> Tim Peters wrote: > Fact is NS dropped the browser ball a couple years ago, then poked holes in > it, then attached industrial-strength vacuum cleaners on the off chance any > air remained. Yeah, they made some poor decisions on where to spend their resources, as well as some bad, abortive attempts to innovate (Javazilla). I think the company just grew too fast, and they weren't able to manage the growth as well as it should have been. And of course, it is hard to invest huge sums of money into your browser (once considered a bread-and-butter product), when Microsoft gives a decent, competing product away for free. As others have said, that really killed the market for browser development. I still see a lot of promise in the future of Mozilla, and I'm willing to wait another six months to see what it will really be able to do. In fact, when it is far enough along, it might be fun to contribute the Python interface (enabling Python applets, ala Grail) to it. Chad Netzer From mark.thomas at gsc.gte.com Wed Apr 7 15:02:08 1999 From: mark.thomas at gsc.gte.com (Justin Development) Date: Wed, 07 Apr 1999 19:02:08 GMT Subject: System Calls Message-ID: <7ega3b$i6v$1@nnrp1.dejanews.com> I need to make a UNIX CDE System Call (DtWsmOccupyAllWorkspaces(XtDisplay (shell)) I'm guessing that I need to create a C file and embed it into my Python module. Is there any other way to do this? If not how do I embed the C call into my Python module? Below is some code that I found which I think is at least heading in the right direction but I'm not sure because I'm new to Dt/Xt coding. Any and ALL help is greatly appreciated! /* Place a window in all workspaces */ #include #include #include

> tags (the default alignment _is_ left). The unnecessary tags are > consistent and easy to identify, and a routine should be writable that > will automate the removal of them. > > I created a Macro in Visual SlickEdit that automatically opens all these > HTML files, finds and deletes all the tags that can be deleted, saves the > changes and closes them. I originally wanted to do this in Python, and I > would still like to know how, but time constraints prevented it at the > time. Now I want to work on how to create a Python program that will do > this. Can anyone help? Has anyone written anything like this in Python > already that they can point me too? I would really appreciate it. > Well, it wouldn't be that hard in Python to parse the HTML files and reformat them in various ways. You can either go the route of straight text substitution using regular expressions, or you could use htmllib to actually parse the HTML files into a data structure, and the write them back out again. However, may I suggest a different method? You've got your original data in Access. There are several different ways to talk to Access from Python. You could pull your data directly from Access using Python and skip Excel all together. And Python's got some great modules for generating HTML. Heck, add CGI or Zope to the mix and you could generate your inventory lists at the web server on the fly! Ok, I'll calm down now. -Chris -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From dfan at harmonixmusic.com Wed Apr 28 16:15:17 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 28 Apr 1999 16:15:17 -0400 Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: aahz at netcom.com (Aahz Maruch) writes: | In article , | Florian Weimer wrote: | > | >(Quotation from the Perl 4 manpage. This version doesn't have an | >`exists' function.) | | Then you've just made a completely irrelevant comment, on the order | of referring to Python 1.2. Perl 5 has been out for more than two | years, and there are so many improvements that I don't know of | *anyone* who's doing new work in Perl 4. Four and a half, actually; Perl 5.000 was released in October 1994, exactly a week after Python 1.1. In fact, Perl 5 has been the current version longer than Perl 4 was (Perl 4 was released in March 1991, so it was the newest version for only three and a half years). (References: perlhist manpage, and Misc/HISTORY in the Python source distribution.) -- Dan Schmidt -> dfan at harmonixmusic.com, dfan at alum.mit.edu Honest Bob & the http://www2.thecia.net/users/dfan/ Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/ Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/ From nathan at islanddata.com Thu Apr 29 19:48:39 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Thu, 29 Apr 1999 16:48:39 -0700 (PDT) Subject: while (a=b()) ... In-Reply-To: <19990430000141.A5867@shalott> Message-ID: I have some deep-rooted "hates" in programming and don't even know where some of them came from. One of them is "while 1" loops. They seem somehow at the same level as goto statements and should be used, in my mind, about as rarely. The ideal, of course, would be: while (c = curs.fetchone()): ... That is my only complaint about python, that statements cannot be expressions. On 30-Apr-99 Marco Mariani wrote: > Hi all language lawyers! > > Which one is more ugly? > > > > ===== > > c = curs.fetchone() > while c: > print c > c = curs.fetchone() > > ===== > > while 1: > c = curs.fetchone() > if c: > print c > else: > break > > ===== > > Is there an elegant way? > > > while curs.fetchone() > print $_ > > >:-))) > > > > -- > "If you're going to kill someone there isn't much reason to get all > worked > up about it and angry. Any discussions beforehand are a waste of time. > We need to smile at Novell while we pull the trigger." > > - Jim Allchin, Microsoft corp. - > > -- > http://www.python.org/mailman/listinfo/python-list ---------------------------------- Nathan Clegg nathan at islanddata.com From mwh21 at cam.ac.uk Wed Apr 14 11:44:27 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 14 Apr 1999 16:44:27 +0100 Subject: REPOST:pretty please - Help re libpython1.5.so References: <3714B9F9.30285D74@earth.ox.ac.uk> Message-ID: Nick Belshaw writes: > I'm gonna start taking this personally soon !!! 1) You've not been very specific wrt platform, hardware. 2) I was getting there! Give us 24 hours! > You bright guys out there..................................... > > If anyone can spare a second - > > Whilst trying to get Python plugins to work on Gnumeric-0.23 I bumped up > > against the need for libpython1.5.so.0.0.0 > > I have 'The Full Python' ( - thats the sequel to 'The Full Monty' !!! ) > > and can build xxxx.a no problem but what do I have to do to get xxxx.so > Can't seem to find anything specific on it in the docs or readme or > Setup and my knowledge is too superficial to allow me to be clever. Are you sure it's exactly libpython1.5.so.0.0.0 it's asking for? I've just compiled this bit of gnumeric (succesfully) and it's created libpython.la, which references libpython.so.0.0.0 and libpython.a, both of which are linked to libpython1.5.a. This is all on a redhat 5.2/i386 with slap bang up to date python and gnumeric from their respective CVS repositories. > Help anyone? I'd try updating your gnumeric, and if that fails, email me more details & what make says as it fails and I'll have a think. > cheers > Nick/Oxford Geochemistry Michael/"the other place" From rasumner at bach.wisdom.weizmann.ac.il Mon Apr 12 17:38:23 1999 From: rasumner at bach.wisdom.weizmann.ac.il (Reuben Sumner) Date: 12 Apr 1999 21:38:23 GMT Subject: role of semilcolon Message-ID: In the python interpreter doing 'a=1;b=2;b=3' does what I would expect, three seperate assignments. However ; doesn't seem to appear in the language reference except in the list of delimeters. Is the above example formally valid python? BTW as you can tell I am a newbie but I am impressed with the ease at which I was able to implement some number theoretic algorithms (gcd, primaility testing, pollard rho factoring, jacobian...) Is there a big practical difference between using long numbers and the mpz package? (is the latter faster) Reuben From Noway at inhell.net Mon Apr 26 15:18:13 1999 From: Noway at inhell.net (Stone Cold) Date: Mon, 26 Apr 1999 19:18:13 GMT Subject: help Message-ID: I just got python and I need some help getting started. I have no programing knowlodge yet but I want to know all the languges. can someone help? P.S I have a web site you can hit a link to earn money and more crazy shit http://members.tripod.com/web_4/index.html -- http://members.tripod.com/web_4/index.html From Jean-Michel.Bruel at univ-pau.fr Wed Apr 14 12:09:51 1999 From: Jean-Michel.Bruel at univ-pau.fr (Jean-Michel BRUEL) Date: Wed, 14 Apr 1999 16:09:51 GMT Subject: [CFP] <>'99 Message-ID: <199904141609.SAA29230@crisv4.univ-pau.fr> [apologies if you receive multiple copies of this announcement] ================================================================= 3rd Call for Papers <>'99 ================================================================= Second International Conference on the Unified Modeling Language October 28-30, 1999, Fort Collins, Colorado, USA (just before OOPSLA) ================================================================= http://www.cs.colostate.edu/UML99 ================================================================= Important dates (deadlines are hard!): Deadline for abstract 05 May 1999 Deadline for submission 15 May 1999 Notification to authors 15 July 1999 Final version of accepted papers 25 August 1999 Submissions: Submit your 10-15 page manuscript electronically in Postscript or pdf using the Springer LNCS style. Details are available at the conference web page. The <>'99 proceedings will be published by Springer-Verlag in the LNCS series. Further Information: Robert B. France E-mail: france at cs.colostate.edu Computer Science Department Tel: 970-491-6356 Colorado State University Fax: 970-491-2466 Fort Collins, CO 80523, USA Bernhard Rumpe E-mail: rumpe at in.tum.de Institut fuer Informatik Tel: 0049-89-289-28129 T. Universitaet Muenchen Fax: 0049-89-289-28183 80290 Muenchen, Germany Sponsored by IEEE Computer Society Technical Committee on Complexity in Computing In Cooperation with ACM SIGSOFT With the Support of OMG From quinn at necro.ugcs.caltech.edu Fri Apr 9 14:40:20 1999 From: quinn at necro.ugcs.caltech.edu (Quinn Dunkan) Date: 9 Apr 1999 18:40:20 GMT Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> <370E4F3E.F9C2CD07@lockstar.com> Message-ID: On 09 Apr 1999 09:07:30 PDT, Mordy Ovits wrote: >Quinn Dunkan wrote: >> Well, I don't have RenderMan, but I did write a pov.py module. It does >> basically what you described, and eventually I'm going to add animation >> features and basic physics (the ocaml module I wrote before did that) and >> stuff like "magic" transforms that align one object with another, spline >> curves etc. I've designed some scenes in it, and it's wordier than pov, but >> has all the benefits of a real language. It doesn't do the new halo syntax >> because the pov people have yet to release an updated unix version >> (grumblegripegrunt). It's incomplete, and written when I was first learning >> python, and I haven't worked on it for a while, but I'll send it to anyone >> interested. Perhaps we could collaborate? > >I'd like a copy of your pov.py module, please. I'm an experienced Python >programmer, and raytracing hobbyist. If I made any additions to it, I'd gladly >send them along to you. >Thanks! >Mordy pov.py v0.0: http://www.calarts.edu/~elaforge/pov/ I guess it's released now :) Also, the pov people just released pov 3.1e for linux, so what I said before is no longer accurate. From cgw at fnal.gov Sat Apr 10 14:48:59 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Sat, 10 Apr 1999 18:48:59 GMT Subject: WinZip vs 0-length files (was RE: trivial import question) In-Reply-To: <000201be8308$8b824520$ac9e2299@tim> References: <000401be7808$6105e3c0$549e2299@tim> <000201be8308$8b824520$ac9e2299@tim> Message-ID: <14095.40219.501277.258165@buffalo.fnal.gov> would it work to make the __init__.py files just have a #comment in them so that they wouldn't be 0 bytes? might save some confusion. From tismer at appliedbiometrics.com Fri Apr 23 15:27:03 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 23 Apr 1999 19:27:03 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> Message-ID: <3720C987.748312F8@appliedbiometrics.com> "Steven D. Majewski" wrote: ... > My guess would be that a difference this big is due to the file > buffering mode. This seems to be true. After removing line I/O at all and doing some optimization, the Python program now runs more than twice as fast than the Perl version on my Linux box. Although unfair, since I would have to optimize the latter as well :-) ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 bernhard at alpha1.csd.uwm.edu Mon Apr 5 20:07:28 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 6 Apr 1999 00:07:28 GMT Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <37009C12.4C0E6B0B@earth.ox.ac.uk> <922837384snz@vision25.demon.co.uk> <7dtbu1$rpn$1@nnrp1.dejanews.com> <37025110.1BA742B@appliedbiometrics.com> Message-ID: On 4 Apr 1999 17:45:54 GMT, Jim Richardson wrote: > I would have printed 4 to a page >but I couldn't figure how to make mpage do the registering properly for >2 stage double sided printing. Tried psnup or psbook? Bernhard From davidtmoore at my-dejanews.com Fri Apr 23 17:17:10 1999 From: davidtmoore at my-dejanews.com (davidtmoore at my-dejanews.com) Date: Fri, 23 Apr 1999 21:17:10 GMT Subject: Style/efficiency question using 'in' References: <3720B3B9.98BED320@earth.ox.ac.uk> Message-ID: <7fqo0i$k85$1@nnrp1.dejanews.com> In article <3720B3B9.98BED320 at earth.ox.ac.uk>, Nick Belshaw wrote: > If someone could spare a mo to clarify - > > If I do something like :- > > ------------------ > def func1(): > return 1,2,3,4,5,6,7,8 > > for x in func1(): > print x > ------------------ This may not be appropriate to the problem that you are really trying to solve, but are you aware of this (range(n) will make your list for you): >>> range(8) [0, 1, 2, 3, 4, 5, 6, 7] >>> for x in range(8): ... print x+1 ... 1 2 3 4 5 6 7 8 >>> ---- David Moore -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From faassen at pop.vet.uu.nl Mon Apr 26 07:44:04 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Mon, 26 Apr 1999 13:44:04 +0200 Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> <371F9D0C.4F1205BB@pop.vet.uu.nl> <7foe7r$15mi$1@nntp6.u.washington.edu> Message-ID: <37245184.3AADF34D@pop.vet.uu.nl> Donn Cave wrote: > > Martijn Faassen writes: > | A static value can be created like this (besides using a global variable > | in a module): > | > | class Foo: > | self.shared = 1 > | > | def __init__(self): > | print self.shared > > Just a nit-pick on this particular item - I tried that already, a > couple of days ago, so I know it won't work! You meant to say, > > class Foo: > shared = 1 Whoops, yes, that makes sense. :) Sorry. > Now a couple of further observations. Per the question, yes, that > variable ("attribute") is accessible in the class scope: > > print Foo.shared > > As well as in the instance scope, as shown in Martijn's example. [snip surprise] > It's not much like C++ here, but it's uncanny how it reeks of Python! > Namespaces, references! Indeed. Not having used that class attribute trick often myself, I wasn't aware of this surprising behavior. I suppose in order to get the C++ behavior it's best to use a module global variable. Regards, Martijn From claird at Starbase.NeoSoft.COM Sat Apr 24 06:32:45 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 24 Apr 1999 05:32:45 -0500 Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <7fmv24$agu$1@m1.cs.man.ac.uk> <3721631D.8642F0AA@istar.ca> Message-ID: <7fs6kd$6ic$1@Starbase.NeoSoft.COM> In article <3721631D.8642F0AA at istar.ca>, Eugene Dragoev wrote: >Where could I find more info about TkGS? . . . -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From aahz at netcom.com Sun Apr 25 11:51:29 1999 From: aahz at netcom.com (Aahz Maruch) Date: Sun, 25 Apr 1999 15:51:29 GMT Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: In article <7fvagp$8lm$1 at nnrp1.dejanews.com>, wrote: > >a) Perl's "defined". > [perl] > if (defined($x{$token}) > > [python] > if (x.has_key(token) and x[token]!=None) : That looks correct. Thankfully Python does have short-circuit evaluation. Note that if you normally expect x[token] to have a value, you might restructure the code a bit to use try/except. >b) RE's. > [perl] > if ($mytext !~ /^\s$/) > > [python] > if not (re.match('^\s$'), mytext) I think you want if not (re.match('^\s$', mytext)) : or if not (re.match('^\s*$', mytext)) : (I think that Perl code has a bug in it by not including '*', but I could be wrong.) -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Hi! I'm a beta for SigVirus 2000! Copy me into your .sigfile! From olipt at mayo.edu Mon Apr 5 23:18:36 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Mon, 5 Apr 1999 22:18:36 -0500 Subject: building python from the tarball on RedHat In-Reply-To: <3709464A.7C5F02D1@ablecommerce.com> References: <3709464A.7C5F02D1@ablecommerce.com> Message-ID: > Howdy All! > > Hopefully that subject will narrow down those looking at this message > and save everyone some time. > > First, a confession. I've got a wierd (i think) linux setup. I'm > running the RedHat 5.2 distribution, but I'm using several applications > from source; I'm bypassing the RPM mechanism. This may be the cause of > my troubles, but.... I want to be able to build from tar balls, so... This shouldn't be a problem --- rpm's are just easier. One thing you might try is downloading a source RPM and building the binary yourself -- it will do the equivalent of a make, but then you'll have a binary package that you can manage and will fit in your system. I've done this several times and could answer questions about this approach. > > I need to have my system setup to run apache (1.3.6), php3 (3.05) and > MySQL (3.22.20a). Using the default RPM's for each of these didn't get > me a working system in which php would talk to mysql. To make that much > work, I downloaded the tar balls for each app, ungzip'd and did the > usual ./configure; make; make install; process. > Are the "default" RPMS the ones that come from RedHat? I get very up-to-date RPMS (or I rebuild new ones using the src.rpm which is also easy) from http://www.andrich.net/python). He has a slew of other extensions, too. > > './python: error in loading shared libraries > libmysqlclient.so.6: cannot open shared object file: No such file or > directory > make: *** [libinstall] Error 127' Is the makefile running python? It looks like the dynamic linker is not finding libmysqlclient.so.6, right? It will only find it if it's internal cache has been updated with ldconfig. This is necessary if shared libraries are installed outside of "standard directories" > > The file 'libmysqlclient.so.6' is in /usr/local/lib/mysql and that > directory is named in the Modules/Setup file. Not sure about pasting > that section in here, but let me know if that info would help as well. > I just pulled the block from the readme. If as you say the libmysqlclient.so.6 file is in /usr/local/lib/mysql then I would try running /sbin/ldconfig /usr/local/lib/mysql and then see if the dynamic linker can load the shared library when python is run. When you install RPMS that included shared libraries this program is often run for you after installation. Good luck. I'm a python user on RedHat 5.2 myself. I love it. --Travis From jwtozer at my-dejanews.com Fri Apr 16 08:12:55 1999 From: jwtozer at my-dejanews.com (jwtozer at my-dejanews.com) Date: Fri, 16 Apr 1999 12:12:55 GMT Subject: Novice Question: two lists -> dictionary References: <7f3j1v$f6j$1@nnrp1.dejanews.com> Message-ID: <7f79g1$kac$1@nnrp1.dejanews.com> Thanks to Blake Winton, Quinn Dunkan, frederic pinel, and Alex for your timely and useful help. What my associates Visual Basic/Access application produced in hours, my little Python script produces in seconds. Jeff In article , Alex wrote: > > You could do something like > > ************************************************** > ListA = ['10', '10', '20', '20', '20', '24'] > ListB = ['23', '44', '11', '19', '57', '3'] > > Dict = {} > for (key, value) in map (None, ListA, ListB): > Dict [key] = Dict.get (key, []) > Dict [key].append (value) > > print Dict > ************************************************** > > The result is > > {'24': ['3'], '10': ['23', '44'], '20': ['11', '19', '57']} > > See you. > Alex. > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From dalke at bioreason.com Thu Apr 22 15:07:50 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Thu, 22 Apr 1999 13:07:50 -0600 Subject: Reversing Long integers References: <371E0C46.E6FA76A9@princeton.edu> Message-ID: <371F7386.92B1BB3C@bioreason.com> Ira H. Fuchs wrote: > Can anyone think of a particularly clever way to [add a [long] > integer to its reverse] Nothing cleverer than import string def add_reverse(n): x = map(None, str(long(n))[:-1]) x.reverse() return n + long(string.join(x,'')) >>> add_reverse(11111111111111L) 22222222222222L >>> add_reverse(11111111111119L) 102222222222230L >>> add_reverse(876437643654354239321L) 1000370097110700973999L The long(n) is to enforce that the L exists as otherwise this won't work for regular integers. > the loop must include moving the L to the end of the reversed string > prior to summing. No need, long("123456789123487") == 123456789123487L . Andrew dalke at acm.org From ppc at redix.com Mon Apr 26 09:40:58 1999 From: ppc at redix.com (Pen Chiang) Date: Mon, 26 Apr 1999 09:40:58 -0400 Subject: freeze problem, please help Message-ID: <7g1qac$f9e@nnrp2.farm.idt.net> I was trying to use the python freeze module, and got the error message: Error: needed directory not found. Even I tried to use the sample "hello.py" in the freeze directory, I still got the same error message. Can someone help? Thanks, P. Chiang From spamfranke at bigfoot.de Sat Apr 17 13:27:52 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Sat, 17 Apr 1999 17:27:52 GMT Subject: sys.path.insert - how to make it global? References: <19990416172011.A1551755@vislab.epa.gov> <3718a8aa.4229211@news.omnilink.de> <19990417113121.A1627033@vislab.epa.gov> Message-ID: <3718c0a3.10366776@news.omnilink.de> In that case the problem seems to be somewhere else. Can you post the traceback, your directory layout and perhaps some isolated code? Your code snippet says : # Augment search path to pull in our C library wrappers Maybe importing C extensions makes your program fail? The following example should resemble your situation (let me know if it doesn't): -------- file a.py in some_directory # First, you can't import c try: import c except ImportError: print "import c failed" # Patch sys.path import sys sys.path.append ("new_directory") # b imports c with the new path import b -------- file b.py in some_directory import sys print sys.path import c -------- file c.py in some_directory/new_directory print "This is c" --------------------------- When I run this from the Python console it prints: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import a import c failed ['', 'D:\\Programme\\Python', 'D:\\Programme\\Pythonwin', 'D:\\Programme\\Python [... long path snipped...] me\\Python\\lib\\plat-win', 'D:\\Programme\\Python\\lib\\lib-tk', 'D:\\Programme \\Python', 'D:\\Programme\\Python\\lib\\site-python', 'new_directory'] This is c Stefan * * * On Sat, 17 Apr 1999 15:31:21 GMT, Randall Hopper wrote: >I'd already tried that. It's effect doesn't appear to be global: > > # Augment search path to pull in our C library wrappers > sys.path.insert( 0, '/home/mylogin/Wrappers' ) > > import MapFile > >This allows Python to find MapFile, but this doesn't allow MapFile to >import other modules in that same Wrappers directory. > >Randall > From cmedcoff at my-dejanews.com Wed Apr 21 10:23:25 1999 From: cmedcoff at my-dejanews.com (cmedcoff at my-dejanews.com) Date: Wed, 21 Apr 1999 14:23:25 GMT Subject: PythonWin Debugger comments Message-ID: <7fkn0n$37v$1@nnrp1.dejanews.com> I am quite new to Python. I've just started tinkering with the PythonWin environment and would like to make the following comments. I'd like to hear some feedback on them. (I'm using build 123.) 1)Syntax highlighting in the debugger needs to go one step further. While one can change the color of the "current line" it would be nicer if one could change background color of the "current line" also. It would make it much more obvious what the current execution point is. Lots of other debuggers do this. 2)I've had problem with both the PythonWin debugger and the IDLE debugger. Both seem to have problems stepping out of a function call. Usually this results in hanging the debugger (Windows NT 4.0 Service Pack 4). Regards, Chuck -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From hew at hons.cs.usyd.edu.au Tue Apr 20 01:13:28 1999 From: hew at hons.cs.usyd.edu.au (Matthew Robert Gallagher) Date: Tue, 20 Apr 1999 15:13:28 +1000 Subject: Can't work this XDR out Message-ID: <371C0CF7.2D1260D7@hons.cs.usyd.edu.au> Whilst trying to pack a list xdr packer asks for (list, pack_item) what is the pack_item can't work this out as there are no examples From petrilli at trump.amber.org Fri Apr 16 14:46:42 1999 From: petrilli at trump.amber.org (Christopher Petrilli) Date: 16 Apr 1999 11:46:42 PDT Subject: restore sources from PYC [Q] References: <000101be879c$8aed0670$6eba0ac8@kuarajy.infosys.com.ar> <37177D8E.FF43BF65@bigfoot.com> Message-ID: <7f80ii$7m0@journal.concentric.net> Hoon Yoon wrote: > What happens if you do NOT want your pyc codes to be reverse engineered? > Can you prevent someone from doing this type of rev eng? You can obscure it, but never more than that... you can reverse out C code too... at some point it must be executable, that's the point. Maybe you won't get the exact code back, but you will get something close. > Some members in my IT committee always have a problem with this ability > and often used as excuse to kill any new tech adoption. Then you better throw out all your compilres :-) Oh, and Java too :-) Seriously, this is a non-event that people use to spread FUD, but it exists in all languages. The simplicity with which it can be done changes, but it's never more than a freshman college project. Chris -- | Christopher Petrilli ``Television is bubble-gum for | petrilli at amber.org the mind.''-Frank Lloyd Wright From gherron at aw.sgi.com Tue Apr 20 14:43:44 1999 From: gherron at aw.sgi.com (Gary Herron) Date: Tue, 20 Apr 1999 18:43:44 GMT Subject: opening more than 1 file References: <371CB255.5FCAFBAF@solair1.inter.NL.net> Message-ID: <371CCAE0.7DE87F8A@aw.sgi.com> martin van nijnatten wrote: > > I have a variable, which can have a value in the range from 1 to 20. > > If the value is 7, I have to open 7 files. > > What could be an elegant way of doing this? > > Martin If your definition of `elegant' includes `short', here is a one-liner to do this. It maps a list [0,1,2,...] to a list of open files: [, , , ...] files = map(lambda i: open("file%02d"%i, 'w'), range(N)) Then, files[i] gives the i'th file. -- Dr. Gary Herron 206-287-5616 Alias | Wavefront 1218 3rd Ave, Suite 800, Seattle WA 98101 From dalke at bioreason.com Thu Apr 22 21:15:19 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Thu, 22 Apr 1999 19:15:19 -0600 Subject: try vs. has_key() References: Message-ID: <371FC9A7.D3C77413@bioreason.com> Aahz Maruch asked: > Can people explain their preferences [for try/except over has_key]? As I recall, has_key is a relatively new addition to Python so older code (and people who learned from older code) will use try/except. I usually use has_key because coming from a shop where most people have C experience, it's easier to explain that than using what it in essense the side effect of exceptions. Also, I believe Barry Warsaw did a benchmark on the tradeoffs of when you do one over the other. The exception case of a try/except has some pretty high overhead, while the has_key call is slightly worse than the non-exception case of the try/except. Barry's results showed that if 5% of the cases or less were "exceptional" then try/except is faster, otherwise, use has_key. Alas, I cannot find the URL for that paper. Andrew dalke at acm.org From dnagata at creo.com Sun Apr 11 18:53:07 1999 From: dnagata at creo.com (Dale Nagata) Date: Sun, 11 Apr 1999 15:53:07 -0700 Subject: Does the standard ftplib module support proxies? References: <37110c85.7753709@news.demon.co.uk> Message-ID: <371127D3.5BD2@creo.com> Paul Moore wrote: > > The header says it all... I've looked in the manual, but I can't see > anything about proxy (firewall) support, one way or another. > > Actually, the same question applies to httplib and urllib. > > Thanks, > Paul Moore. It depends on what kind of proxy. I've found it works fine if the proxy is the nice simple kind that lets you connect to the proxy host on FTP port 21 and specify the remote ftp location using the form user at site. I haven't tried to make it work with any other kind (and there are quite a few). -- Dale Nagata | tel : +1 604.451.2700 ext. 2254 (UTC-0800) Software Developer | fax : +1 604.437.9891 Creo Products Inc. | pgr : +1 604.691.8279 Burnaby BC Canada | http://www.creo.com/ From dptaylor3 at my-dejanews.com Tue Apr 20 14:06:28 1999 From: dptaylor3 at my-dejanews.com (dptaylor3 at my-dejanews.com) Date: Tue, 20 Apr 1999 18:06:28 GMT Subject: smtplib.SMTP.sendmail always fails on Win95 machine. Message-ID: <7fifn1$58d$1@nnrp1.dejanews.com> This is the first time I've used winsock. I had to add/edit the following lines to smtplib.SMTP.sendmail to get it to work on my win95 box. destaddr=self.sock.getpeername()[0] #remote mail server name if not self.helo_resp and not self.ehlo_resp: if self.ehlo(destaddr) >= 400: self.helo(destaddr) I have no idea what this change does to winNT. Perhaps some winsock guru can look this over and put some cleaned up and bulletproofed version of this change into the next win95 release of python? -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From larsga at ifi.uio.no Sat Apr 17 11:13:18 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 17 Apr 1999 17:13:18 +0200 Subject: Why no "=" in if? (was Re: Quick fix to add "+=") References: <3717EE20.41343593@mediaone.net> <000701be888f$12fe2920$ee9e2299@tim> Message-ID: * Aahz Maruch | | x = foo() | if x: | ... | | instead of | | if x = foo(): | ... | | Why doesn't Guido get off his duff and fix this?????????! What's so wrong about it? Personally I seriously dislike assignments that return values (at least in conventional languages). --Lars M. From cs at spock.rhein-neckar.de Thu Apr 15 03:41:30 1999 From: cs at spock.rhein-neckar.de (Carsten Schabacker) Date: 15 Apr 1999 09:41:30 +0200 Subject: forking + stdout = confusion References: <87n20caldg.fsf@spock.localnet.de> Message-ID: <877lrejpp1.fsf@spock.localnet.de> clarence at silcom.com (Clarence Gardner) writes: > Roy Smith (roy at popmail.med.nyu.edu) wrote: > parent and child processes. Also, in case you're not aware of it, the > distinguishing feature of a nph-type CGI program is that its output does > not go through the web server. Could you please explain me what a nph-type CGI is ? I know only regular CGI-Scripts where stdout goes through the webserver. Thanx Carsten. From scrompton at quantisci.co.uk Fri Apr 16 07:28:30 1999 From: scrompton at quantisci.co.uk (Stephen Crompton) Date: Fri, 16 Apr 1999 12:28:30 +0100 Subject: HTML Authentication with Python References: <7f5iru$rlm@news.acns.nwu.edu> <14102.27498.772779.5941@bitdiddle.cnri.reston.va.us> <7f6577$8kp@news.acns.nwu.edu> Message-ID: <37171EDE.9DFD027A@quantisci.co.uk> Matthew T Lineen wrote: > Jeremy Hylton (jeremy at cnri.reston.va.us) wrote: > > If you configure the server properly, users won't be able to run your > > CGI scripts until the server has checked their username and password. > > Actually, I want the script to run because it pulls the "REMOTE_USER" key > and populates a field in a form. If I knew that authentication through the > server would allow me to pull this key, I wouldn't be authenticating through > the script. Maybe the question / issue is that I don't understand the use > of the REMOTE_USER key. I think that is the issue here. The previous poster is correct, but it needs a little explaining. If you set up a web-server with no authentication then environ['REMOTE_USER'] is not set. The 'REMOTE_USER' environment variable is set after client-server authentication has been performed. Basically it works as follows The user ask for a URL ..../name.cgi The server sees that authentication is required and sends back a 401 error. The client receives this a pops up an authentication window. The user enters their details and the request is passed back to the server with the Authorization information in plain text (well base64) in the header. If this information is accurate (userid and password match) then the server sets the environ['REMOTE_USER'] to the userid. This is all that is passed to the cgi script, so all you have to do is set up the web server correctly and then use the value of REMOTE_USER in your script. Any further requests to a URL which is part of the same path (ie. .../name.cgi/0/30/1?dothis) results in the client sending back the Authorization header each time stopping the authentication window repeatedly popping up. Hope this helps. Steve. From fuzz at sys.uea.ac.uk Thu Apr 22 05:54:08 1999 From: fuzz at sys.uea.ac.uk (Farzad Pezeshkpour) Date: Thu, 22 Apr 1999 10:54:08 +0100 Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> Message-ID: <7fmruj$gtm@cpca3.uea.ac.uk> > I don't want to say that this is bad for Tcl users but what about all > the other languages that use Tk? Isn't writting multiplatform GUI harder > using native components. I don't think that implementing all widgets using custom code on all platforms is 'lightweight' at all. The issues about lightweight components for me are performance and cross-platform compatibility. By using native components, Tk has moved closer to this goal. Yes, the differences in look (and to some extent, feel) of components, when usig native widgets, can be every-so-slightly compromised - however, in the case of Tk, I don't find this a major worry, irrespective of the manner by which I access Tk (Tcl, Perl, C etc). > I think Java made big step forward in > abandoning the native components and using lightweight > ones in Swing. I've got a lot good words to say about Swing, but I don't think that it's too smart to emulate the look'n'feel on the same os/toolkit. The results are typically a poor imitation and always slow. It reminds me of the days when I used ParcPlace's Smalltalk - very bad! Fuzz From scott at chronis.pobox.com Thu Apr 29 02:28:45 1999 From: scott at chronis.pobox.com (scott cotton) Date: 29 Apr 1999 06:28:45 GMT Subject: Emacs' python-mode buggy? References: <199904282340.TAA19934@python.org> <3727E329.2E8F3C31@digicool.com> Message-ID: I've often noticed that emacs font locking is weird with TQS's. the strangest thing is that with one TQS, the next line of code can end up in string color, but if you move that line of code around by temporarily adding leading whitespace or moving further down the file, it will change to regular code fonts without me ever changing the TQS above it. while i haven't looked closely at the pymode code, i do think that emac's fontifying stuff works on a certain limited amount of context only (in terms of surrounding characters to the cursor). with such a contstraint, it seems amazing to me that pymode does as well it does fontifying stuff. at any rate, i'll opt for a little sporadic twiddling of source code over using vi(m) or something anyday. scott On 29 Apr 1999 07:48:21 +0300, Markus Stenberg wrote: >Ken Manheimer writes: >> Markus Stenberg wrote: >> I can't speak to the intimacy issue, but the python-mode syntax recognition >> may be due to having a leading '(' open paren in the first column in one of >> your docstrings. If so, emacs' syntax confusion (not to be mistaken for >> poor gender identification) can be remedied by escaping the leading open >> paren with a '\' backslash, like so: > >Ah, what's causing that problem? > >> \(this is what to do with parens in docstrings.) >> >> If it is the problem, well, it's emacs' problem, not pymode. If it's not, >> well, do track it down. >> >> Oh, does that bug constitute the "tons" you mention, or were there others? >> I never was good at estimating the weight of bugs - all that chiton, you >> know. > >Think there is two, as one of my (moderately large) modules has no >docstrings with ('s yet still exhibits that behavior. (ok, I got carried >away, but I was moderately frustrated over the feature :-P) > >> Ken Manheimer >> klm at digicool.com > >-Markus > >-- > Markus Stenberg >Finger fingon at mpoli.fi for PGP key -- PGP key id: 1024/5DAC7D21 > > From tim_one at email.msn.com Wed Apr 7 02:05:12 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 7 Apr 1999 06:05:12 GMT Subject: Chaning instance methods In-Reply-To: <199904070524.HAA12210@axil.hvision.nl> References: <199904070524.HAA12210@axil.hvision.nl> Message-ID: <000401be80bc$999f1820$699e2299@tim> [Jody Winston] > I don't understand how to change instance methods. That's good, because Python doesn't have such a thing . Direct attributes of instances are never methods without extreme trickery. A function becomes a method by virtue of being found in an instance's *class's* dict. Python was designed to allow overriding methods at the class level, but not at the instance level. > For example: > > class Foo: > def __init__(self): > self.data = 42 > def m(self): > print "Foo.m" > print dir(self) > > def m2(self): > print "m2" > print dir(self) > > f = Foo() > f.m() > # this fails > # f.m = m2 > # f.m() Right, a direct attribute of an instance is never a method. Except that this "works": import new f.m = new.instancemethod(m2, f, Foo) f.m() This sets f.m to a *bound* instance method that refers to f, which Python treats as an ordinary function when later referenced via f.m. Without using the "new" module, you can get the same effect via e.g. old_Foo_m = Foo.m Foo.m = m2 f.m = f.m # heh heh Foo.m = old_Foo_m In either case, though, the value of f.m now contains a hidden reference to f, so you've created a piece of immortal cyclic trash. subclassing-is-a-lot-easier-ly y'rs - tim From joe at strout.net Thu Apr 15 15:51:05 1999 From: joe at strout.net (Joe Strout) Date: Thu, 15 Apr 1999 12:51:05 -0700 Subject: PIL fonts - Where are you? References: <7jbR2.3071$YU1.5576@newsr2.twcny.rr.com> <002c01be8744$4a7af2d0$f29b12c2@pythonware.com> Message-ID: In article <002c01be8744$4a7af2d0$f29b12c2 at pythonware.com>, Fredrik Lundh wrote: > pilfont has been tested with all files from the standard distribution, > but the version shipped with 1.0b1 fails on fonts generated by some > other tools. most notable, it assumes that the FONT field is a full > X11 font specifier, e.g: > > FONT -Adobe-Times-Medium-R-Normal--11-80-100-100-P-54-ISO8859-1 I note that in the fonts used with Snow, the above information is the filename. But such filenames are too long for MacOS. Please consider storing this info elsewhere, and using shorter file names. Cheers, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From skip at mojam.com Sat Apr 17 10:24:09 1999 From: skip at mojam.com (Skip Montanaro) Date: Sat, 17 Apr 1999 14:24:09 GMT Subject: Python/XML release 0.5.1 References: Message-ID: <7fa5i3$2q8$1@nnrp1.dejanews.com> AMK wrote: > * Added marshalling into various XML-based formats: a generic > one for Python objects, WDDX, and XML-RPC. The generic marshaller can > be subclassed to implement marshalling into a specific DTD; both the > WDDX and XML-RPC marshallers were implemented in this fashion. Does the XML-RPC marshaller drop into Fredrik Lundh's xmlrpclib module in an obvious way, or is this a complete XML-RPC interface module that would replace xmlrpclib altogether (or is it neither)? (BTW, the "archives" link on the Python/XML page: http://www.python.org/pipermail/xml-sig.html is a broken link.) Thx, -- Skip Montanaro (skip at mojam.com, 518-372-5583) Mojam: "Uniting the World of Music" http://www.mojam.com/ Musi-Cal: http://www.musi-cal.com/ -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From tim_one at email.msn.com Wed Apr 28 19:39:35 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 28 Apr 1999 19:39:35 -0400 Subject: Emacs' python-mode buggy? In-Reply-To: Message-ID: <000401be91d0$5faab280$199e2299@tim> [Markus Stenberg] > At least by my experiences the Emacs mode (at least, two versions I > tried, 3.75 and whatever came with Python 1.5.2) seems to have tons of > bugs; Yes, that would be entirely Barry Warsaw's fault -- pymode had no bugs when I worked on it, and Barry is a known drug addict. Well, all right, I was the drug addict, and I lied about Barry -- but I'm sure it's still all his fault . > to be more precise, it seems to think a lot more of my code than should > be is string (and therefore is green and indentation doesn't work). Offhand, that sounds like one bug. Try posting a minimal failing example? Amorphous griping doesn't help. If you searched DejaNews before posting, you may have noticed that reports of pymode bugs are conspicuous by absence. things-are-fishier-than-you-suspect-ly y'rs - tim From llwo Mon Apr 19 21:42:44 1999 From: llwo (Karl & Mel) Date: Mon, 19 Apr 1999 20:42:44 -0500 Subject: calldll windll instantiation Message-ID: <371bdd70.0@news.dbtech.net> Need some help. I think?(scarry moment)? that I need to create more that one instance of a dll. 1. Can this be done? 2. Is my sample even close? """gm_class quick wrapper of dll functions""" import windll import time class test: def __init__(self): self.gm=windll.module('GM4S32') def load_bde(self, SysDir='c:\\program files\\goldmine', GoldDir='c:\\program files\\goldmine\\gmbase', CommonDir='c:\\program files\\goldmine\\demo', User='PERACLES', Password=''): start=time.time() (SysDir, GoldDir, CommonDir, User, Password)=map(windll.cstring,(SysDir, GoldDir, CommonDir, User, Password)) return (self.gm.GMW_LoadBDE(SysDir, GoldDir, CommonDir, User, Password), "Startup Time: " + str(time.time()-start)) def unload_bde(self): return self.gm.GMW_UnloadBDE() ...other defs... >>> import gm_class >>> a=gm_class.test() >>> b=gm_class.test() >>> a >>> b >>> a.gm >>> b.gm >>> a.load_bde() # This works (1, 'Startup Time: 0.490000009537') >>> a.gm >>> b.gm >>> b.load_bde() # This fails but should work ;-( (0, 'Startup Time: 0.0') >>> a.gm >>> b.gm >>> a.gm==b.gm # Don't know if this is correct 1 >>> a==b 0 >>> >>> gm_class.windll.dump_module_info() -------------------- WINDLL Function Call Stats: --- --- 2 GMW_LoadBDE >>> From achrist at easystreet.com Fri Apr 2 19:50:09 1999 From: achrist at easystreet.com (Al Christians) Date: Fri, 02 Apr 1999 16:50:09 -0800 Subject: string.join() vs % and + operators References: <37054490.E79ADCC9@easystreet.com> Message-ID: <370565C1.7DD4D7D0@easystreet.com> Aahz Maruch wrote: > > Yup. Using '+' for strings really bites when you've got long (or > potentially long) strings. The average size of the string you're > concatenating is about a hundred characters; suppose you're doing CGI > work with redirects, and you're looking at closer to three hundred > characters a pop. > > Try adding a 1K pre-string to the front of each of your Ways and see > what happens to the speed. Time went up from 69 secondes to 115. So it takes only a little bit longer to join the strings than it does to skip over 1k exach time. Al From evan at tokenexchange.com Fri Apr 23 18:01:55 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Fri, 23 Apr 1999 17:01:55 -0500 Subject: Windows install has problems. Guido asked that I use this newsgroup to discus further References: <924039873.18221.0.nnrp-12.9e982a40@news.demon.co.uk> <924040766.18823.0.nnrp-12.9e982a40@news.demon.co.uk> <371FAE0F.43B33158@siosistemi.it> <924903282.24080.0.nnrp-10.9e982a40@news.demon.co.uk> Message-ID: Perhaps I'm missing some context here, but doesn't this thread refer to the Windows Python Install program generated by Wise? If so, Wise *by default* fetches %PROGRAM_FILES% on systems which support it. Barry Scott wrote in message <924903282.24080.0.nnrp-10.9e982a40 at news.demon.co.uk>... Mauro Cicognini wrote in message news:371FAE0F.43B33158 at siosistemi.it... > Mmm, since I'm not an English-language OS user, I'd rather see that as > %programfolder%\tcl\bin\tcl80.dll (I don't remember exactly, but I'm sure there > is a way to refer in a language-independent way to the folder that the US > version calls "Program Files" since we use it in our installations. Its in the registry - but python cannot access the registry. So this hack would not work for none english systems. From Brian at digicool.com Thu Apr 22 16:04:40 1999 From: Brian at digicool.com (Brian Lloyd) Date: Thu, 22 Apr 1999 20:04:40 GMT Subject: Reversing Long integers Message-ID: <613145F79272D211914B0020AFF6401914DAD5@gandalf.digicool.com> > I am attempting to write an efficient Python program which > can add an integer to > its reverse. This is quite easy to do in Lisp and Mathematica > but (mostly out of > curiosity) I wanted to see how one might do this in Python. > Converting an > integer to a string and reversing it and converting back is > quite easy (although > not all of these ops are primitives) but the fact that Long > integers have the > letter L appended means that the loop must include moving the > L to the end of > the reversed string prior to summing. Can anyone think of a > particularly clever > way to do this? Ok, I'll bite :) I don't know if this is particularly clever, but it works and should be pretty fast... import string def addrev(num, join=string.join, atol=string.atol): """Add a long to its reverse""" rev=list(str(num)[:-1]) rev.reverse() return num + atol(join(rev, '')) Brian Lloyd brian at digicool.com Software Engineer 540.371.6909 Digital Creations http://www.digicool.com From Gaetan_Corneau at baan.com Tue Apr 13 10:59:00 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Tue, 13 Apr 1999 14:59:00 GMT Subject: Python as an ODBC *source* on windoze ? Message-ID: <816010E2456BD111A48700805FBBE2EEA63EDE@ex-quebec-u1.baan.com> Boris, > Is there a way to have Python on windows > to act as an ODBC source (server) on windoze ? [GC] I'm not absolutely sure, but I don't think so. You could always create a new ODBC driver to interface the Python interpretor, but that would require much work. > Reason : to use the MS Access report generator > component. [GC] The easy way is just to dump your data to a text file (comma or tab delimited) and read it with MS Access: there is a Text ODBC driver that works well. Hope this helps, ______________________________________________________ Gaetan Corneau Software Developer (System integration Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 654-1454 ext. 252 ______________________________________________________ "Profanity is the one language all programmers know best" From pbrinton at wco.com Wed Apr 7 01:45:16 1999 From: pbrinton at wco.com (pbrinton at wco.com) Date: Tue, 06 Apr 1999 22:45:16 -0700 Subject: DO YOU BELIEVE IN REINCARNATION? 1942 References: <37067552.2@193.75.226.254> Message-ID: well, I didn't believe in reincarnation in any of my past lives, so why should I start now? In article <37067552.2 at 193.75.226.254>, wwrqcg at starmedia.com wrote: >Do you believe in reincarnation? > >Do you want to know who you were and where you lived in your past life? > >Click here -> http://orbita.starmedia.com/~luizhenrique/reincarnation.html >gbsljtpzdgfkpbjjrjebunfthqothunlsjwtu **************************************************************** Patrick Brinton pbrinton at wco.com vox: (707) 874 1898 A Brown Electronic, Inc. **************************************************************** From gmcm at hypernet.com Tue Apr 13 18:10:51 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 13 Apr 1999 22:10:51 GMT Subject: threads In-Reply-To: <80BFA4D02E598C65.76C7CFE2D53BC9F1.ECCA6CF6DE46FB03@library-proxy.airnews.net> References: <80BFA4D02E598C65.76C7CFE2D53BC9F1.ECCA6CF6DE46FB03@library-proxy.airnews.net> Message-ID: <1288080841-20523503@hypernet.com> Eric Lee Green wonders about Python threads: > My question is this: How "atomic" are basic Python variable > operations? This exact question was asked not long ago. My reply, and Guido's clarifications follow: --------------------------------------------------------------------- Gordon McMillan replies: > In general, Python will switch between threads every N (10, unless > you've rebuilt with another constant) byte code instructions. Any > byte-code instruction is therefore atomic. > > > For examples: > > > > Can I safely create/update a global variable from a thread or do I > > risk breaking any dictionary implementation stuff (pointers/hash > > table slots etc)? [Empirical evidence suugests this is OK]. > > Dictionaries are dandy. Updating a single global is fine. > > > Can I append to a list without various pointers getting messed up? > > [Prolly not, huh? Otherwise we wouldn't need the queue module .. > > or is this just a hangover from earlier days?] > > Lists are trickier. Individual operations are atomic, but most of > the time, doing something with a list takes more than one op. You're > normally dealing with the list and an index, so you're better off > protecting the list. That is, you can "safely" append, but even that > may screw up someone else who is iterating. Some examples will clarify also. These are atomic (L, L1, L2 are lists, D, D1, D2 are dicts, x, y are objects, i, j are ints): L.append(x) L1.extend(L2) L1[i:j] = L2 x = y x.field = y D[x] = y D1.update(D2) These aren't: i = i+1 L.append(L[-1]) L[i] = L[j] D[x] = D[x] + 1 Note: operations that replace other objects may invoke those other objects' __del__ method when their reference count reaches zero, and that can affect things. This is especially true for the mass updates to dictionaries and lists. --Guido van Rossum (home page: http://www.python.org/~guido/) - Gordon From fcolaco at wolf.fis.uc.pt Mon Apr 12 10:22:27 1999 From: fcolaco at wolf.fis.uc.pt (Francisco Colaço) Date: Mon, 12 Apr 1999 15:22:27 +0100 Subject: Where is module 'thread'? Message-ID: <371201A3.10E82C4F@wolf.fis.uc.pt> I need to use lightweight threads on a application, and tried to use 'threading'. Unfortunately, it asks for a module 'thread' which I cannot find. I use RedHat 5.2 Linux and python 1.5.1 (RPM release 5). I wish to keep the application able to run on MS Windows (at the least the client side). Where can I find the module or is there another module I could use? Francisco -- Francisco Miguel Pedroso Hon?rio Cola?o fcolaco at wolf.fis.uc.pt From bill_seitz at my-dejanews.com Wed Apr 14 11:47:55 1999 From: bill_seitz at my-dejanews.com (bill_seitz at my-dejanews.com) Date: Wed, 14 Apr 1999 15:47:55 GMT Subject: stupid Win-CGI getting started question References: <7f0f0h$pfb$1@nnrp1.dejanews.com> <8DA86302Bduncanrcpcouk@news.rmplc.co.uk> Message-ID: <7f2db8$dev$1@nnrp1.dejanews.com> In article <8DA86302Bduncanrcpcouk at news.rmplc.co.uk>, Duncan Booth wrote: > seitz at mail.medscape.com wrote in <7f0f0h$pfb$1 at nnrp1.dejanews.com>: > > >...But not clear on > >getting it configured properly to talk CGI with my WinNT Netscape Enterprise > >server. > > > >How should that first #! be changed for Windows users? Could that be it? > > > >Could the fact that all my Python stuff is under > >d:\program files\python\ > >be part of the problem (the long folder name with a space in it)? > > I tried all sorts of configuration changes to get it to run .py files directly, > and eventually gave it up as a bad job (mostly because I didn't want to risk > breaking the server). > > The way I get CGI scripts to run with Netscape Enterprise server on NT is to > put them in .cmd files instead of .py files. For example: > > ---------test.cmd---------------- > @c:\Progra~1\Python\python -x "%~f0" %* & goto :EOF > import os > > print "Content-type: text/html" > print > print "Test" > print "Hello world from python.

" > > for k in os.environ.keys(): > print k, os.environ[k], "
" > print "" > ---------end of test.cmd--------- > You would need to change the path to reflect the location of your copy of > Python, either use the 8.3 filename as above, or put the filename in quotes: > @"c:\Program Files\Python\python" -x "%~f0" %* & goto :EOF > works. I tried your test.cmd (after changing the first line, using your quoted path and making it my path of course). Now I get a response back of internal or external command, operable program or batch file. The server acts shows this as a successful delivery (no error in the logs, status=200). Does that mean the problem is now within Python? -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From mstenber at cc.Helsinki.FI Wed Apr 28 07:16:24 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 28 Apr 1999 14:16:24 +0300 Subject: try vs. has_key() References: <7g51q6$1pt$1@vvs.superst.iae.nl> Message-ID: aahz at netcom.com (Aahz Maruch) writes: > It appears that the second parameter for get() (to specify a value > different from None when the key is not found) is new to 1.5.2. In > 1.5.1 you still have to do the following: Not quite. mstenber at melkki ~>python Python 1.5.1 (#1, Nov 10 1998, 13:21:44) [GCC 2.7.2.3] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> {}.get("foo","bar") 'bar' >>> -Python 1.5-ly yours, Markus -- "Schizophrenia, like the Unicorn, is described in various ways by various people. And its elimination, like the capture of the Unicorn, appears to require some special conditions, not all of which have yet been specified. Finally, whether or not those conditions exist, belief in their existence has had significant consequences." - Schizophrenia, Behavioural Aspects (Salzinger, 1972) From jeremy at cnri.reston.va.us Thu Apr 29 18:57:19 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 29 Apr 1999 18:57:19 -0400 (EDT) Subject: Errors In-Reply-To: <3728CD26.907ED9A1@geocities.com> References: <3728CD26.907ED9A1@geocities.com> Message-ID: <14120.58236.608143.792577@bitdiddle.cnri.reston.va.us> You need to initialize tally first. You're getting a NameError because the first reference to tally is on the right hand side of the first assignment. Python is looking up tally and not finding it, because you haven't assigned to it yet. >>> tally = tally + 1 Traceback (innermost last): File "", line 1, in ? NameError: tally vs. >>> tally = 0 >>> tally = tally + 1 Jeremy From gmcm at hypernet.com Sun Apr 18 22:30:25 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 19 Apr 1999 02:30:25 GMT Subject: NT: win32api and win32ui import error In-Reply-To: <7fdgj4$nnl$1@nnrp1.dejanews.com> References: <7fdgj4$nnl$1@nnrp1.dejanews.com> Message-ID: <1287633267-17041836@hypernet.com> Hung Jung writes: > No luck. I downloaded some more recent versions of ole32.dll > and oleaut32.dll from http://solo.abac.com/dllarchive/, (their > msvcrt.dll is older, from VC5 instead of VC6). I also tried > those DLLs from my Windows 98 System folder. I tried many > combinations. Here is the list of the versions: > > msvcrt.dll: > 5.00.7303 (solo.abac.com) > 5.00.7128 (my Windows 98) > 6.00.8267.0 (my Windows NT) > > ole32.dll: > 4.71.1120 (solo.abac.com) > 4.71.1719 (my Windows 98) > 4.00 (my Windows NT) > > oleaut32.dll: > 2.20.4122 (solo.abac.com) > 2.20.4122 (my Windows 98) > 2.20.4118 (my Windows NT) ... > NT has had persistent problem with the Pythonwin > extensions. This is not the first time. I have > never been able to run Pythonwin or use its > extensions modules (e.g: win32api, win32ui) on NT, > and we have quite a few NT machines here. > > The current real status is: PYTHONWIN DOES NOT > RUN ON NT. At least not on modern NT versions > (our msvcrt.dll is dated 9/23/98, this should be > considered fairly recent.) While I'm still on 1.5b2 and build 123 of Mark's stuff, I've had no problem on NT SP3 and 4. My versions: msvcrt.dll v 5.00.7303 ole32.dll v 4.00 oleaut32.dll v 2.30.4265 I have (some time ago) had problems with the "not registered" messages on install, but they went away when I de-installed the extensions, de-installed Python then reinstalled Python and the extensions. (However, to get IE 4 to install, I had to de-install almost everything network related...) Just to make sure you haven't overlooked anything basic, you do realize that you have to have administrative priveleges to install the extensions? In a direct reply, I'll attach a copy of the HKLM\Software\Python portion of my registry. - Gordon From phd at sun.med.ru Tue Apr 27 05:55:08 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Tue, 27 Apr 1999 13:55:08 +0400 (MSD) Subject: examples of parsing html? In-Reply-To: <764sm3pbfb.fsf@zero.npl.uiuc.edu> Message-ID: On 26 Apr 1999, M.A.Miller wrote: > Can anyone point me to examples of how to parse html files? I > want to extract urls from an index so I can use those urls to get > data files. Look into my "Bookmarks database" programs at http://members.xoom.com/phd2/Software/Python/ http://www.fortunecity.com/skyscraper/unix/797/Software/Python These programs split navigator's bookmarks.html into a databse and restore them back into html. > Mike > > -- > Michael A. Miller miller5 at uiuc.edu > Department of Physics, University of Illinois, Urbana-Champaign Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From smee at iquest.net Fri Apr 16 12:21:05 1999 From: smee at iquest.net (Scott Meyers) Date: Fri, 16 Apr 1999 11:21:05 -0500 Subject: Looking potential Python authors. Message-ID: <37176371.310E0C6C@iquest.net> Hello, I am looking for people who would be interested in writing an in depth tutorial on the Python language. The ideal candidate would have some previous writing experience (or at least some verifiable writing skills), and the ability to clearly explain the python language by guiding the reader through real life programming examples. Anyone with any such interest please contact me directly at smeyers at mcp.com or smee at iquest.net. Thanks, Scott Meyers, Sams Publishing smeyers at mcp.com (317) 817-7276 From wtanksle at dolphin.openprojects.net Fri Apr 30 13:27:35 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 30 Apr 1999 17:27:35 GMT Subject: Using Python for Modular Artificial Intelligence code References: <7g94lp$mdu$1@news.worldonline.nl> Message-ID: On Fri, 30 Apr 1999 23:07:45 +0930, Tim Auld wrote: >>>I've started looking into Python as the AI scripting language for this >>>purpose, but I'm having trouble seeing exactly how I could do this. I >>Where do you use C++ for anyway? GUI's? Build them in Python, forget C++ >>until you are done and than use C++ to speed up critical sections >system further. The reason I'm using C++ is mainly because I'm familiar >with it, and because of speed. I'm aware that Python is relatively slow, so >I would rather use C++ as a base from the start, and save myself the trouble >of rewriting it all later. If you write everything in Python, you will wind up with a program which works far sooner than if you'd written it in C++ (unless you're _REALLY_ good at C++). You can then pull out the parts which need speedup into C or C++. It won't be that much trouble to rewrite -- it seldom is, really. The hard part is getting the design, not writing the program. Python offers the ideal design language, because it's executable. >Tim -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From carol at parkey.com Tue Apr 6 04:23:46 1999 From: carol at parkey.com (Carol Parkey) Date: Tue, 06 Apr 1999 09:23:46 +0100 Subject: Python under ASP/MTS Message-ID: <3709C492.EED3BF03@parkey.com> We have to build something quickly for a client, but we have to fit within their ASP/MTS mandate. I have developed the first cut of a Python COM object which sits under Microsoft Transaction Server, and can be called from an Active Server Page in VBScript/JavaScript (thanks to Mark Hammond and all the FAQ writers). The requirement is perfect for Python, since it has to convert between user requests in XML and mainframe messages in some hideous format, plus some other fiddly bits. I am concerned, though, about whether I will experience performance problems, with the interpreter being loaded and unloaded. Am I worrying needlessly, or is there something I should be doing (like forcing the COM object's reference count to never drop to zero)? All suggestions gratefully received regards jp From KUNCEJ at mail.conservation.state.mo.us Wed Apr 21 10:36:37 1999 From: KUNCEJ at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Wed, 21 Apr 1999 14:36:37 GMT Subject: Bit Arrays Message-ID: Take a look at ./Demo/classes/bitvec.py in the python source distribution. It may be what you want, or at least give you some ideas. --Jeff >>> "Laura Paterno" 04/20/99 11:21am >>> Hello all, I want to write a python program that has 26 Bit Arrays that each contain 1113 bits. Is there a structure in python that one can use to represent a bit array? Laura Paterno From pchristo at ic.sunysb.edu Tue Apr 13 13:46:17 1999 From: pchristo at ic.sunysb.edu (Pavlos Christoforou) Date: Tue, 13 Apr 1999 13:46:17 -0400 Subject: ConfigParser module and alternatives (flad, flan) In-Reply-To: References: <19990331160323.21601.00000471@ng-fi1.aol.com> <7du3ab$3ag@chronicle.concentric.net> Message-ID: On Sat, 10 Apr 1999, Mike Orr wrote: > I use ConfigParser to parse the data files in a Mad Lib CGI program. > See it at http://mso.oz.net/python/madbibs/ > (When I add/change a story, I run a script that parses the files, > creates the HTML, and stores the preprocessed data structures in a > cPickle file for the CGI script.) Sounds like you might benefit from Zope, or at least ZPublisher. > > I'm not sure if I'll use ConfigParser for the next version. I don't > really need the sections (multiple files work just fine, using the filename > for the section name), and I haven't found a use for the the %(other_key)s > substitutions. On the other hand, it doesn't handle multiple values (the > same key repeated within a record), which I sometimes need. Last time I needed to use configuration files I wrote an XML module that maps XML files onto python dictionaries. Changes to either the python dictionary during run-time or to the file are synchronized automatically (not good for huge configuration files that are modified frequently). The standard python distribution comes with a good XML parser so you can do pretty cool things. Mapping onto dictionaries creates the same problem that you mentioned (no multiple values withing the same sectrion (dictionary)). If anyone is interested I can send her/him a copy. Pavlos From bryanv at arlut.utexas.edu Tue Apr 13 16:51:03 1999 From: bryanv at arlut.utexas.edu (Bryan VanDeVen) Date: Tue, 13 Apr 1999 15:51:03 -0500 Subject: real time scheduler Message-ID: <3713AE36.A1EA255B@arlut.utexas.edu> Is there a module for scheduling events in real time? I have events that need to be repeated indefinitely, each at a given time period. The periods are large (at least one minute) and precision requirements are not that great (within a few seconds). Is anyone aware of code to do this? -- Bryan Van de Ven Applied Research Labs University of Texas, Austin From morse at harborcom.net Wed Apr 14 09:51:35 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Wed, 14 Apr 1999 13:51:35 GMT Subject: Python + KDE tutorial References: Message-ID: <37149d49.183049300@news.oh.verio.com> boud at rempt.xs4all.nl wrote: >Since I mentioned my attempts at the translation >of Daniel Marjam?ki's c++ KDE tutorial >(http://www.dormnet.his.se/~a96danma) into Python, >I thought it a good idea to mention that it is now >up at: > >http://www.xs4all.nl/~bsarempt/python/tutorial.html Thanks. It's a nice intro to Qt. From pat at ktgroup.co.uk Tue Apr 20 12:20:57 1999 From: pat at ktgroup.co.uk (Pat Knight) Date: Tue, 20 Apr 1999 16:20:57 GMT Subject: Tkinter hangs in Emacs in 1.5.2 on Win32 Message-ID: <371ca96f.0@nnrp1.news.uk.psi.net> I often prototype fragments of Tkinter code using the interactive Python mode in NT emacs. Since installing 1.5.2 the interpreter hangs when run interactively inside Emacs. If I type from Tkinter import * r = Tk() r.title('pat') I never get a >>> prompt from the interpreter after entering the r.title() call. The same sequence of commands works fine in the regular stand-alone interpreter. Does anyone know what's going on before I prepare a bug report? I'm using Python 1.5.2 on Windows 98 and Windows NT with the Tcl/Tk that comes with Python 1.5.2 and NT Emacs 20.3.1 with the python-mode.el that comes with Python 1.5.2. Pat Knight VCS Development Manager, The Knowledge Group, Bristol, UK +44-117-900-7500 Corporate Web: http://www.ktgroup.co.uk From aahz at netcom.com Sat Apr 17 09:33:47 1999 From: aahz at netcom.com (Aahz Maruch) Date: Sat, 17 Apr 1999 13:33:47 GMT Subject: #!/usr/bin/env python -u References: <37175574.25EBDDBE@stuco.uni-klu.ac.at> Message-ID: In article , Bill Janssen wrote: > >I'm not a big fan of the /usr/bin/env approach for Python scripts, >because at PARC many people run without having Python on their paths. >Many, many packages at PARC, including Python and ILU, are installed in >their own directory tree under either /project (/project/ILU/) or >/import (/import/python-1.5/). People enable or disable various >packages depending on what they're up to. > >So I tend to depend on GNU configure when I'm installing a script. I >actually look for Python in the user's environment, then use sed to >hard-code that path into the scripts before installing them. Can this >be done with RPM? Back when I was working at a software company with a real build environment, we had a system where we used shell scripts to call Perl and make scripts. You can do some pretty sophisticated parsing in a shell script; up to you whether you want to do the perverse option of installing a global python that system calls other python scripts.... I really loathe hard-coded paths unless they're truly global. (Let me know if this isn't clear.) -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Sometimes, you're not just out of left field, you're coming in all the way from outer space. From MHammond at skippinet.com.au Sun Apr 18 19:24:04 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Mon, 19 Apr 1999 09:24:04 +1000 Subject: win32api and win32ui import error References: <7fbcpq$2jb$1@nnrp1.dejanews.com> Message-ID: <7fdpi8$lvg$1@m2.c2.telstra-mm.net.au> hj_ka at my-dejanews.com wrote in message <7fbcpq$2jb$1 at nnrp1.dejanews.com>... >>>> import win32api > >"exceptions.ImportError: DLL load failed: The process cannot access >the file because it is being used by another process." This is a stragne one. Never ever seen anything like this. First step: Does "import pywintypes" work? If not, the problem is related to "pywintypes15.dll", otherwise the problem is related to win32api.pyd. My guess is the former, as win32ui fails in the same way. Only thing I can suggest is removing pywintypes15.dll from the system directory, then re-extracting it using winzip from win32all-124.exe. That is the only thing I can think off. The error message implies some other process has it open for "write" - or it is corrupted in some way? Mark. From thomas at xs4all.nl Thu Apr 8 04:10:17 1999 From: thomas at xs4all.nl (Thomas Wouters) Date: 8 Apr 1999 08:10:17 GMT Subject: DNS module ? Message-ID: I'm looking for a DNS module. Actually, I'm looking for Anthony Baxters' DNS module, from what I've read on dejanews :) However, the URL he gives in the link in those posts, and all others I could find, point to a machine that no longer exists (alumni.dgs.monash.edu.au) and I cannot find a similar module anywhere else (except for the Demo DNS module, which, frankly, wont do :) Am I looking in the wrong places ? Mind you, I started looking into python less than 24 hours ago, but I did check www.python.org, starship python, dejanews and altavista (though the starship python searchengine was showing a lack of voom when I tried it -- I think it was stunned) I would be _very_ grateful for any pointers to the damned module, before I write it myself, out of frustration, burning desire and the sublimal messages... Must... ...write... ...Python... -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From nascheme at ucalgary.ca Wed Apr 28 14:40:24 1999 From: nascheme at ucalgary.ca (Neil Schemenauer) Date: 28 Apr 1999 18:40:24 GMT Subject: Moving Numeric arrays into the core References: <37208E69.4B022E0C@mediaone.net> <7fr3eg$bqr@world1.bellatlantic.net> <7g4jkg$llc@ds2.acs.ucalgary.ca> <14119.2301.611044.266704@amarok.cnri.reston.va.us> Message-ID: <7g7kmo$cm0@ds2.acs.ucalgary.ca> On Wed, 28 Apr 1999 09:29:53 -0400 (EDT), Andrew M. Kuchling wrote: > I think the idea is to include only the basic NumPy types >(multiarray and whatever the rest are). BLAS, LAPACK, or whatever, >would still be add-ons. I've looked into this and it should be pretty easy to split up NumPy. Here is what I got: 332 1075 11818 Include/arrayobject.h 190 585 6704 Include/ufuncobject.h 86 264 3585 Src/_numpymodule.c 2037 6451 53891 Src/arrayobject.c 615 2690 28201 Src/arraytypes.c 2 2 24 Src/multiarray.def 1208 3818 31603 Src/multiarraymodule.c 39 36 639 Src/numpy.def 968 3129 26291 Src/ufuncobject.c 2 2 19 Src/umath.def 2013 10754 95932 Src/umathmodule.c 213 847 7904 Lib/ArrayPrinter.py 29 76 767 Lib/Matrix.py 342 1190 9632 Lib/Numeric.py 80 271 2468 Lib/Precision.py 103 235 2964 Lib/UserArray.py 8259 31425 282442 total On a Intel Linux box I get the following libraries: 163996 _numpymodule.so 69147 multiarraymodule.so 159556 umathmodule.so 392699 total I wonder if this is too large. Maybe umath should be left out. Also, how would the existing array module fix in with this? Neil From fdrake at cnri.reston.va.us Thu Apr 22 10:07:52 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Thu, 22 Apr 1999 14:07:52 GMT Subject: Need someone to try some rarely used bsddb methods In-Reply-To: <371E9326.8472D97@mojam.com> References: <7fa14m$vfm$1@nnrp1.dejanews.com> <371E9326.8472D97@mojam.com> Message-ID: <14111.11576.76622.745554@weyr.cnri.reston.va.us> Skip Montanaro writes: > I wound up writing the section for the library reference as well. I > believe it's in the CVS repository now. It's there, along with modifications I just added to indicate the lack of support for last() and previous() on hashtable databases. Thanks for supporting the Python documentation efforts! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From jbauer at rubic.com Tue Apr 13 01:38:43 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Tue, 13 Apr 1999 05:38:43 GMT Subject: rfc822 date header Message-ID: <3712D863.2A8148BC@rubic.com> Is there a reasonably bulletproof way to generate an rfc822-compliant date header using the time module? The reason I ask is I recall a number of subtle errors in this regard, reported by Chris Lawrence, among others. -Jeff Bauer From phd at sun.med.ru Mon Apr 19 06:29:55 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Mon, 19 Apr 1999 10:29:55 GMT Subject: Database search engine In-Reply-To: <7ferls$qrj$1@nnrp1.dejanews.com> References: <7ferls$qrj$1@nnrp1.dejanews.com> Message-ID: On Mon, 19 Apr 1999 davidcuny at yahoo.fr wrote: > Where can I find an algorithm or, the best, Perl code for that kind of work? > Is Perl the good tool to do that (Perl??,java)?? http://perlfect.com/freescripts/search/ > thanks > > David Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From schliep at octopussy.mi.uni-koeln.de Wed Apr 7 17:44:39 1999 From: schliep at octopussy.mi.uni-koeln.de (Alexander Schliep) Date: 07 Apr 1999 23:44:39 +0200 Subject: Tkinter and centering References: <370B88CF.993D8847@yahoo.com> <370BC217.FFF53A35@vision.arc.nasa.gov> Message-ID: Chad Netzer writes: > Well, I don't know if you can ever get the window width and height without > first mapping it (displaying). One option is to open it completely off the I found a solution in Effective Tcl/Tk. You have to call update_idletasks() which forces geometry calculations first and then you can move the window. Here is some sample code I wrote for a splash screen. Alexander class SplashScreen(Toplevel): """ Subclass and override 'CreateWidgets()' In constructor of main window/application call - S = SplashScreen(main=self) (if caller is Toplevel) - S = SplashScreen(main=self.master) (if caller is Frame) - S.Destroy() after you are done creating your widgets etc. """ def __init__(self, master=None): Toplevel.__init__(self, master, relief=RAISED, borderwidth=5) self.main = master if self.main.master != None: # Why ? self.main.master.withdraw() self.main.withdraw() self.overrideredirect(1) self.CreateWidgets() self.after_idle(self.CenterOnScreen) self.update() def CenterOnScreen(self): self.update_idletasks() xmax = self.winfo_screenwidth() ymax = self.winfo_screenheight() x0 = (xmax - self.winfo_reqwidth()) / 2 y0 = (ymax - self.winfo_reqheight()) / 2 self.geometry("+%d+%d" % (x0, y0)) def CreateWidgets(self): # Need to fill in here def Destroy(self): self.main.update() self.main.deiconify() self.withdraw() -- Alexander Schliep schliep at zpr.uni-koeln.de ZPR/ZAIK Tel: +49-221-470-6011 (w) University of Cologne FAX: +49-221-470-5160 Weyertal 80 http://www.zpr.uni-koeln.de/~schliep 50931 Cologne, Germany Tel: +49-231-143083 (h) From thantos at lucifer.gw.total-web.net Sat Apr 3 21:37:29 1999 From: thantos at lucifer.gw.total-web.net (Alexander Williams) Date: Sun, 04 Apr 1999 02:37:29 GMT Subject: [IRC] Has anyone created a useful IRC module? Message-ID: Has anyone written a module in the spirit of telnetlib that would facilitate writing an IRC bot that connects to the server and can communicate with the core? Such a beast would definitely facilitate writing decent Bots ... such as the one I'd like to put together. -- Alexander Williams (thantos at gw.total-web.net) "Absolute power applied to limited problems. Incidental damage negligable." From fredrik at pythonware.com Wed Apr 21 17:42:00 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Apr 1999 21:42:00 GMT Subject: How do I use proxies with httplib? References: <7fl97e$lnc$1@nnrp1.dejanews.com> Message-ID: <099101be8c3f$cb6206e0$f29b12c2@pythonware.com> wrote: > I want to use httplib through a proxy server and I can't seem to get > it to work. that's probably because it doesn't work: [Lib]$ grep proxy httplib.py [Lib]$ you might be able to use urllib instead: [Lib]$ grep proxy urllib.py proxy = self.proxies[type] type, proxy = splittype(proxy) host, selector = splithost(proxy) #print "proxy via http:", host, selector """Return a dictionary of scheme -> proxy server URL mappings. proxies. An HTTP proxy, for instance, is stored under """Return a dictionary of scheme -> proxy server URL mappings. Scan the environment for variables named _proxy; if value and name[-6:] == '_proxy': [Lib]$ From brunomadv at ciudad.com.ar Tue Apr 20 23:27:56 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Wed, 21 Apr 1999 03:27:56 GMT Subject: permissions on win32 [Q] Message-ID: <001201be8ba6$f2f706e0$6eba0ac8@kuarajy.infosys.com.ar> Hi! I have to do a little script for a customer that will copy files from an NT server to another. I need to change the permissions on those files and directories. I mean, I need to give privileges to groups like Administrators, the user that owns the files (changes from file to file) and other special groups. Anyone knows how to do this with Python? We have the following env: NT4SP4, Python 1.5.1, Win32All 124 ... the lastest one. I have already done the script that copies the files, I just need to know how to set this permissions. TIA /B Bruno Mattarollo ... proud to be a PSA member From kaz at ashi.FootPrints.net Thu Apr 22 16:01:30 1999 From: kaz at ashi.FootPrints.net (Kaz Kylheku) Date: 22 Apr 1999 20:01:30 GMT Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <371F11C2.3162025@ciril.fr> <4fv$ECA+JyH3EwbN@jessikat.demon.co.uk> Message-ID: <7fnv6q$2g5$44@newsread.f.de.uu.net> On Thu, 22 Apr 1999 18:01:27 GMT, Barry Margolin wrote: >In article <4fv$ECA+JyH3EwbN at jessikat.demon.co.uk>, >Robin Becker wrote: >>I take this completely differently; least astonishment for me is if >>program X looks and behaves the same way no matter what keyboard, mouse >>and screen I'm using. As a 'user' of the program X it shouldn't matter >>what OS/WM is executing the code. I certainly don't want vi or emacs to >>be different on the mac why should I treat word or excel differently? > >I would be very surprised if Netscape on the Macintosh presented a >Windows-like user interface, rather than adopting the standard Macintosh I'd be very surprised if even 10% of, say, comp.lang.c gave a damn. The pitiful dumbfuck who started this thread made a severe mistake in constructing the Newsgroups: header line, the moment he put in the first comma. I am setting Followup-to: to comp.lang.tcl. From wwyruygt at jizm.net Tue Apr 27 18:32:18 1999 From: wwyruygt at jizm.net (wwyruygt at jizm.net) Date: Tue, 27 Apr 1999 22:32:18 GMT Subject: Awsome live video sex @ www.xxxsizzle.com! Message-ID: An unregistered copy of Newsgroup AutoPoster 95 was used to post this article! --- This has got to be the best adult website I've seen. www.xxxsizzle.com kicks ass! Don't take my word for it, cum see yourself. From jwbaxter at olympus.net Sat Apr 17 10:18:50 1999 From: jwbaxter at olympus.net (John W. Baxter) Date: Sat, 17 Apr 1999 07:18:50 -0700 Subject: Why no "=" in if? (was Re: Quick fix to add "+=") References: <3717EE20.41343593@mediaone.net> <000701be888f$12fe2920$ee9e2299@tim> Message-ID: In article , aahz at netcom.com (Aahz Maruch) wrote: > I'm getting really sick of the way I have to use this stupid construct: > > x = foo() > if x: > ... > > instead of > > if x = foo(): > ... > > Why doesn't Guido get off his duff and fix this?????????! Because it's not broken. --John -- If nothing is pressing, putter about with this or that. (Fortune cookie) John W. Baxter Port Ludlow, WA USA jwb at olympus.net From jwpolley at collins.rockwell.com Fri Apr 23 11:36:00 1999 From: jwpolley at collins.rockwell.com (Jonathan Polley) Date: Fri, 23 Apr 1999 10:36:00 -0500 Subject: Proposed Change for sys.exitfunc for version 1.6 Message-ID: <37209360.2FB8E145@collins.rockwell.com> I would like to propose adding a function to the module 'sys' that would change (slightly) the behavior of sys.exitfunc. I would like to add a method that performs the same function as UNIX's 'atexit ()' function. The reason is that I have some modules that would like to do some cleanup when python terminates, but I don't want to have to add the code required for them to remember the previous value of sys.exitfunc so they can call that function (if present). A method sys.atexit () would work nicely. It would allow me to add a series of exit functions and be guaranteed that they would all be called at the termination of python (so I can close files, purge queues, close sockets, etc.). Does anyone else think this would be a good idea??? Jonathan Polley jwpolley at collins.rockwell.com From parkw at better.net Mon Apr 26 18:34:28 1999 From: parkw at better.net (William Park) Date: Mon, 26 Apr 1999 18:34:28 -0400 Subject: Launching web browser programmatically In-Reply-To: <3724EB92.248E7933@hotmail.com>; from Ben Darnell on Mon, Apr 26, 1999 at 05:41:22PM -0500 References: <3724EB92.248E7933@hotmail.com> Message-ID: <19990426183428.A770@better.net> On Mon, Apr 26, 1999 at 05:41:22PM -0500, Ben Darnell wrote: > [I seem to remember a recent thread about this, but I can't find it on > DejaNews. I apologize for any redundancy] > > How do I launch the the user's web browser programmatically on Win9x? I > can use "start http://www.python.org" at the command line, but > "os.system('start http://www.python.org')" doesn't work properly. The > python process seems to hang. When I kill python with the task manager, > the web browser does appear. What is going wrong here? > > Ben Darnell > ben_darnell at hotmail.com > > > -- > http://www.python.org/mailman/listinfo/python-list Not knowing too much about Win9x, my guess would be that os.system() is waiting for stdin to close, since the web browser does appear after you kill python. Try Window's equivalent to os.system('start http://www.python.org /dev/null 2>/dev/null &') William Park From morse at harborcom.net Fri Apr 9 07:37:54 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Fri, 09 Apr 1999 11:37:54 GMT Subject: Python for embedded controllers? References: Message-ID: <370de606.77891472@news.oh.verio.com> I know you already mentioned the mentioning of Python on this mailing list, but this was really exciting to me and rest of the snake pit might like it too: SO, maybe when it's available, their microPython source can serve as the basis for other embedded systems. --------------------------------------------------- Date sent: Thu, 8 Apr 1999 11:34:15 -0700 To: ucsimm at uClinux.org From: Michael Gorlick Subject: Re: [uCsimm] Scripting Languages on uCSIMM Send reply to: ucsimm at uClinux.org At 10:03 AM -0700 4/8/99, William Ware wrote: >Python uses a compiled bytecode which is executed by a virtual >machine, like Java. It might be nice to be able to bring up just >the VM on a target board, and download compiled bytecode to it, >rather than running a full interpreter on the board. I would >also think that for a cpu with no floating-point unit (I don't >think the dragonball has one), you'd want a Python build that >avoids any use of floats or doubles. I haven't looked closely >enough at the Python source to see how feasible that would be. >The few times I've tried building a 68K gcc cross-compiler, I've >never been able to get the floating-point library (libgcc1.s?) >to plug in correctly. I don >t have any experience trying to build ecgs as a cross-compiler. Be assured that we are acutely aware of the limitations of the DragonBall processor and have been completely ruthless in stripping it down to the bare minimum (truth in advertising requires that I disclose that in the interest of time a few extraneous bits and pieces have been left in --- these were components that were easier to ignore than remove). We estimate that with more work we can reduce our version of Python down from its current measly 124 kB to about 110 kB. Further reductions may be possible but with correspondingly greater effort. I have also been a little sloppy with terminology. We are not running the full interpreter but just the Python virtual machine and a spare framework around it. For example, the interactive, command-line front end is history along with the builtin compiler. Users will use a "full up" Python interpreter to produce VM bytecode files (*.pyc) which will then be downloaded onto the Palm Pilot. On another note, many interested users have contacted me personally to enquire further or to offer their assistance. Your interest and enthusiasm is greatly appreciated, however, at this point in time no further information is available. We are doing this as quickly as our congested and conflicted schedules permit. We anticipate having an alpha version in house by the end of April. We plan to make the source code and prebuilt binaries publically available, although the exact timing of the distribution is unclear. We will make announcements on this and other mailing lists when the distribution is packaged and ready to go. We recognize the value and potential of Python on platforms like the uCsimm and are anxious to have it in the hands of users such as yourselves. Please be patient with us. __ _/mg\__ ... /o-----o> This message resent by the ucsimm at uclinux.org list server http://ryeham.ee.ryerson.ca/uClinux From wtanksle at dolphin.openprojects.net Sun Apr 4 00:49:07 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Sun, 04 Apr 1999 05:49:07 GMT Subject: Why are they? Re: Module Documentation Strings References: Message-ID: On Sat, 3 Apr 1999 20:38:37 -0500, evil Japh wrote: >Why are there documentation strings? >I mean, granted it would be very bad if the next version of python did not >support them, but why not just use comment lines? Because comment lines are only visible within the source. Docstrings may be accessed from anywhere, without any knowledge of the source. >Jeff Pinyan (jeffp at crusoe.net) -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From markus_kohler at hp.com Fri Apr 30 07:56:31 1999 From: markus_kohler at hp.com (Markus Kohler) Date: 30 Apr 1999 13:56:31 +0200 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: The numbers for tak(18, 12, 6) see my previous post. Python-1.5.2c1 compiled with HP compiler "cc -O" 0.52 seconds Squeak (www.squeak.org) 2.4 running with a 2.3 virtual machine compiled with gcc (egcs 1.02) -O 0.13 seconds. this is compiled with gcc since it uses some gcc extensions that speed up the the case statement for the byte code dispatching. Even the HP compiler produces much better code than gcc, in this case the gcc compiled squeak is usally faster. Of course the comparsion is not really fair because squeak might or might not run a the garbage collector during the test (probably not). But I doubt that this would explain a factor of 4. Markus -- Markus Kohler mailto:markus_kohler at hp.com From jbauer at rubic.com Tue Apr 13 08:42:57 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Tue, 13 Apr 1999 12:42:57 GMT Subject: rfc822 date header References: <3712D863.2A8148BC@rubic.com> <3712F4C1.52327AF4@lemburg.com> Message-ID: <37133BD1.5FF0C763@rubic.com> >>> Is there a reasonably bulletproof way to generate an >>> rfc822-compliant date header using the time module? Chris, Thanks for your response. (Also, thanks to Jack Jansen and M.A. Lemburg for responding too.) I'd like to lobby for a strdate() convenience method to be added to rfc822.py, provided it's sufficiently controversial. -Jeff Bauer From jean at stat.ubc.ca Sun Apr 25 12:47:14 1999 From: jean at stat.ubc.ca (Jean Meloche) Date: Sun, 25 Apr 1999 16:47:14 +0000 Subject: possible bug in 1.5.1 Message-ID: <37234712.2E95BC37@stat.ubc.ca> I am using python to import a SAS database into a relational database and I'm running into some trouble with the real number Infinity. I've had trouble with it before... SAS uses -Infinity to signal exceptional cases. One of my functions tests to a Infinity field: Infinity=1e1000 if rec['HC4']==Infinity: do_something The code fails because *sometimes* Infinity takes value Inf and *sometimes* it takes value 0.0... I've also added the line print 1e1000 and it sometimes print Inf and sometimes print 0.0. How can I create a Infinite float in python with certainty? I'm using a RedHat 5.2 system on Intel. Many thanks and please reply to jean at stat.ubc.ca -- Jean Meloche From akuchlin at cnri.reston.va.us Wed Apr 14 12:47:50 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Wed, 14 Apr 1999 16:47:50 GMT Subject: How libpython1.5.so In-Reply-To: <371320F4.5338600B@earth.ox.ac.uk> References: <371320F4.5338600B@earth.ox.ac.uk> Message-ID: <14100.50513.166352.167346@amarok.cnri.reston.va.us> Nick Belshaw writes: >Whilst trying to get Python plugins to work on Gnumeric-0.23 I bumped up >against the need for libpython1.5.so.0.0.0 Python doesn't build a .so file, so I think the Gnumeric people must have hacked Python to build one; you may want to check with them and see if they have build instructions or an RPM available. Alternatively, you can make a shareable libpython by setting the CFLAGS environment variable to "-fPIC" before running ./configure and compiling Python. Then, turn libpython.a into libpython.so with "gcc -shared -o libpython.so libpython.a" (the exact command may require some tweaking), and copy libpython.so to wherever you like. -- A.M. Kuchling http://starship.python.net/crew/amk/ I think he expected me to agree enthusiastically, but I didn't. Nor did I contradict him; I have had too much experience of life to attempt to tell a really rich person anything. -- Robertson Davies, _The Rebel Angels_ From mlh at idt.ntnu.no Fri Apr 23 17:40:17 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 23 Apr 1999 23:40:17 +0200 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> Message-ID: Christian Tismer writes: > Just did a little more cleanup to the code. > This it is: Hm. This code is nice enough (although not very intuitive...) But isn't it a bit troublesome that this sort of thing (which in many ways is a natural application for Python) is so much simpler to implement (in an efficient enough way) in Perl? Can something be done about it? Perhaps a buffering parameter to fileinput? In that case, a lot of the code could be put in that module, as part of the standard distribution... Even so -- you would somehow have to be able to treat the buffers as blocks... Hm. (And... How about builtin regexes in P2?) > ciao - chris -- > Hi! I'm the signature virus 99! Magnus > Copy me into your signature and join the fun! Lie Hetland http://arcadia.laiv.org From bkc at murkworks.com Wed Apr 7 16:37:03 1999 From: bkc at murkworks.com (Brad Clements) Date: Wed, 7 Apr 1999 16:37:03 -0400 Subject: SNMPy update References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <3709C8BE.4257C9F1@lemburg.com> <14090.16807.950025.496495@bitdiddle.cnri.reston.va.us> <370A78B6.2C18D10F@lockstar.com> Message-ID: <7egflp$843$1@news.clarkson.edu> Mordy Ovits wrote in message <370A78B6.2C18D10F at lockstar.com>... >I have a fairly complete SWIGing of OpenSSL/SSleay working. I made it on >company time, so I have to get company permission to release it. If there is >real interest, I'll push for us to release it. It does all the X.509 stuff, is >very OO, and builds on win32 and unices. >Interested? >Mordy > Definately interested! From tismer at appliedbiometrics.com Sat Apr 24 09:58:57 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sat, 24 Apr 1999 13:58:57 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> Message-ID: <3721CE21.5B881A10@appliedbiometrics.com> "Magnus L. Hetland" wrote: > > Christian Tismer writes: > > > Just did a little more cleanup to the code. > > This it is: > > Hm. This code is nice enough (although not very intuitive...) But > isn't it a bit troublesome that this sort of thing (which in many ways > is a natural application for Python) is so much simpler to implement > (in an efficient enough way) in Perl? Well, Python has its trouble with its generalism, all the object protocols, the stack machine, the name lookups, which all apply even for simplest problems like Arne's. This leads to non-intutive optimization tricks which I showed. Although my buffering techique applies to other languages as well. The brain damaging concept is running over big, partial chunks of memory, trying to process them effectively without much object creation, and making sure that the parts glue together correctly, the last record isn't missing and so on. The real work is hidden somewhere between like a side effect. > Can something be done about it? Perhaps a buffering parameter to > fileinput? In that case, a lot of the code could be put in that > module, as part of the standard distribution... Even so -- you would > somehow have to be able to treat the buffers as blocks... Hm. I think someting can be done. First, I think I can set up a framework for this class of problems, which takes a line oriented algorithm and spits out such a convoluted thing which does the same. Another thing which appears worthwhile is generalizing the realine function. I used that in my own buffered files, but this would be twice as fast if readline/s could do this alone. What I need is a variable line delimiter which can be set as a property for a file object. In this case, I would use ">" as delimiter. For a fast XML scanner (which just works right partitioning of XML pieces, nothing else), I would use "<" as delimiter, read such chunks and break them on ">", with a little repair code for comments, ">" appearing in attributes etc. Conclusion: My readline would be parameterized by a delimiter string. I would *not* leave it attached to a line (like the CR's), instead I would return the delimiter as EOF indicator. > (And... How about builtin regexes in P2?) No. Noo! Please never! :-) I really hate them from design, and they shouldn't imfluence Python in any way. What I likemuch better is Marc Lemburg's tagging engine, which could have been used for this problem. One should think of a nicer interface, which allows it to build readable, efficient tagging engines from Python code, since at the moment, this is a little at the assembly level :-) All in all, I'd like to express little engines in Python, but not these ugly undebuggable unreadable flie dirt strings which they call "regexen". But that's my private opinion which should not be an attack to anybody. I just prefer little machines whcih can interact with Python directly. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 Friedrich.Dominicus at inka.de Thu Apr 15 01:45:11 1999 From: Friedrich.Dominicus at inka.de (Friedrich Dominicus) Date: Thu, 15 Apr 1999 07:45:11 +0200 Subject: for in benchmark interested Message-ID: <37157CE7.EFB470CA@inka.de> Some time ago I have opened a thread about optimization in Python. I have now done a simple benchmark and used Python for that too. If s.o is interested, take a look at: http://edt.vol.cz:81/bench Any comment is very welcome. I got an answer from the ISE-Eiffel guys this morning ;-) You might imagine what they think. If any of you have simular tests, pleas let me know, allow me to put that copy onto that page. I hope we can found some points which speak for one language under certain conditions. It would be really helpful if you would include information about 1) implementation time 2) debug time 3) sort of bug 4) maybe a short estimate how important speed is for that special test I didn't have done that very detailed. And I now regret that. I just can give a rought scetch 1) Perl (stolen from an implementation form Markus Mottl on the OCAML-Mailing-list) 2) OCAML (the same as for Perl) 3) Python first solution < 3 Minutes I guess, If I remember correctly no bug at all (sheer luck, normally I produce at most on typo ;-)) 4) optimizations (<1 minute each, but the last)(typos) 5) fastest solution (point of discussion in this group so this take quite some time but not for implementation but discussion) 6) Eiffel sol. Because I didn't know gelex to that time I need some more time the source was done very fast, but not very Eiffelish. No assertions and the like (but all implemantations take me more than a week). Some parts have to be completely new written (split_string which is of course easy to use in Python) 7) C. This was not difficult to do after all the other stuff, but I didn't have a hash-table implementation at hand. Found one in the conde snippets. But found too bugs in it. So adaption take me quite a while. I can't tell how much time I need for debugging. Either estimate would be much to low (I woul look like a hacker, I'm not) or to high (would look like an idiot, but who cares ;-) And I'm using a debugger just to look into the code that I can see if anything works as inteded even without a direct bug. I don't know if that is good style, but I feel comfortable with that. Regards Friedrich From movits at lockstar.com Fri Apr 9 12:07:30 1999 From: movits at lockstar.com (Mordy Ovits) Date: 09 Apr 1999 09:07:30 PDT Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> Message-ID: <370E4F3E.F9C2CD07@lockstar.com> Quinn Dunkan wrote: > Well, I don't have RenderMan, but I did write a pov.py module. It does > basically what you described, and eventually I'm going to add animation > features and basic physics (the ocaml module I wrote before did that) and > stuff like "magic" transforms that align one object with another, spline > curves etc. I've designed some scenes in it, and it's wordier than pov, but > has all the benefits of a real language. It doesn't do the new halo syntax > because the pov people have yet to release an updated unix version > (grumblegripegrunt). It's incomplete, and written when I was first learning > python, and I haven't worked on it for a while, but I'll send it to anyone > interested. Perhaps we could collaborate? I'd like a copy of your pov.py module, please. I'm an experienced Python programmer, and raytracing hobbyist. If I made any additions to it, I'd gladly send them along to you. Thanks! Mordy -- o Mordy Ovits o Cryptographic Engineer o LockStar Inc. --------------------------------------------------------------------------- #!/usr/local/bin/python from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!= '-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce( lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1))) From Norbert.Klamann at pobox.com Wed Apr 28 01:28:28 1999 From: Norbert.Klamann at pobox.com (Norbert.Klamann at pobox.com) Date: Wed, 28 Apr 1999 05:28:28 GMT Subject: Designing Large Systems with Python References: Message-ID: <7g669p$aer$1@nnrp1.dejanews.com> In article , David Steuber wrote: > Meanwhile, languages like Ansi Common Lisp have had features that > allow you to prototype and build a large system at the same time. > That is, the specification of the system becomes the system. A good principle for this would be 'Design by Contract'. The ideal language for that IMHO would be Eiffel. See http://www.eiffel.com/doc/manuals/language/intro/ for an introduction by the inventor of the language, Bertrand Meyer see also http://www.eiffel-forum.org/ and the links at http://www.elj.com/ > People > have done the same thing with Visual Basic, so I am told. > Very bad idea, as already pointed out > So long ! Norbert -- Norbert Klamann Klamann Software & Beratung Erftstadt Germany Klamann.Software at pobox.com -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From r.hooft at euromail.net Fri Apr 16 08:30:12 1999 From: r.hooft at euromail.net (Rob Hooft) Date: Fri, 16 Apr 1999 12:30:12 GMT Subject: Pmw: Fooling around with the busy window stack. Message-ID: <14103.11604.912185.852847@octopus.chem.uu.nl> I've been trying to fool around a bit with the Pmw busy window stack, but I can't manage without some help.... I have an application of which the main window is a PmwDialog. In the dialog window there are a number of variables that can be edited by the user. All user changes are sent in command form over a pipe to a subprocess (using subproc.py), which is controlled by a CLI. The output of the CLI is shown in a different Toplevel window in a PmwScrolledText widget. My question to you: How can I avoid the ScrolledText widget from being blocked by the blt_busy system during the active phase of the PmwDialog? Is there a way to selectively release the lock on a specified Toplevel? Regards, Rob Hooft. -- ===== R.Hooft at EuroMail.net http://www.xs4all.nl/~hooft/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From olipt at mayo.edu Tue Apr 20 15:01:22 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Tue, 20 Apr 1999 14:01:22 -0500 Subject: Bit Arrays In-Reply-To: <7fi9i8$n2u$1@info3.fnal.gov> References: <7fi9i8$n2u$1@info3.fnal.gov> Message-ID: > Hello all, > > I want to write a python program that has 26 Bit Arrays that each contain > 1113 bits. Is there a structure in python that one can use to represent a > bit array? > > Laura Paterno This could be done in a variety of ways. It depends on what you want to do with the bit arrays. Python has a bitwise OR (|), a bitwise AND (&), and a bitwise XOR (^) operator so you could easily make a Bit Array class that does what you need to do from either a list object, and array object, or the Numeric extenstions (multi)array object. If you use the Numeric extensions I have C-methods called packbits and unpackbits in a module called numpyio as part of the signaltools package at http://oliphant.netpedia.net/ that take 2-D arrays of 1's and 0's and pack them into 8-bit bytes. This may be overkill for you, though. Sincerely, Travis From scrompton at quantisci.co.uk Thu Apr 15 11:24:38 1999 From: scrompton at quantisci.co.uk (Stephen Crompton) Date: Thu, 15 Apr 1999 16:24:38 +0100 Subject: timezone stuff driving me bonkers!!! Message-ID: <371604B6.C6267011@quantisci.co.uk> Pretty obvious from the header I guess. I want to convert from a UTC tuple to the time since the epoch. As far as I can tell this should definitely be timezone, DST, etc. independent. However, there is a notable absence of this functionality in the time module (presumably due to C library absences ?) Anyway, I keep seeing mention that time.mktime(tpl)-time.timezone - (1) should work if the timezone is working correctly, but why isn't it time.mktime(tpl)-time.altzone ? - (2) I merely observe that time.mktime(time.localtime(time.time())) is (near enough) time.time() So, surely in the above example (1), tpl would have to be in localtime for the above to make sense. Writing as somebody who is currently observing DST (UK), this is clearly the case as time.timezone = 0. So, entering a UTC tuple in (1) would not give me the equivalent of time.time() !! (though (2) would) Somebody must be able to point out a flaw in my logic ? Cheers, Steve. From spamfranke at bigfoot.de Tue Apr 13 11:24:21 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Tue, 13 Apr 1999 15:24:21 GMT Subject: ZopeHTTP speed problem. References: <7etton$j4q$1@nnrp1.dejanews.com> Message-ID: <371358fb.4741377@news.omnilink.de> [This is a crossposting from c.l.p to the zope at zope.org mailing list, since it contains a problem report and a proposal/question concerning both] On Mon, 12 Apr 1999 22:57:32 GMT, befletch at my-dejanews.com wrote: [...] > I found I have to use >my machine's numeric IP address, not 'localhost' as the docs indicate. Do you get the long response times even *with* using your localhost's IP address? I once had a similar problem with response times even up to a minute for each HTTP request, and I found out that it was due to the logging mechanism in the standard library's BaseHTTPServer.py: BaseHTTPRequestHandler.log_message calls the address_string function, which does a reverse name lookup of the request's IP address. If neither yout DNS nor the etc/hosts table (it lives in \WINNT\system32\drivers\etc\hosts on a NT machine, don't know about 95/98) are configured correctly, timeouts occur on each request. There are two calls to address_string in Zope, one in BaseHTTPRequestHandler.log_message and one in ZopeHTTPServer.BoboRequestHandler.get_environment Both can be changed to self.client_address[0], so that only IP addresses are used for logging and the REMOTE_HOST environment variable is never set. What I would appreciate is to make this behaviour configurable, but it would require changes to both BaseHTTPRequestHandler and BoboRequestHandler. Any ideas? Stefan From arw at ifu.net Fri Apr 9 14:14:00 1999 From: arw at ifu.net (arw) Date: Fri, 9 Apr 1999 18:14:00 GMT Subject: GadFly - MemoryError Message-ID: <199904091818.OAA01334@ifu.ifu.net> Sorry to reply again, but I replied a bit too quickly last time. Could it be that a large number (say 1000) records have a default URL value of the null string generating 1000000 matching record pairs? this would explain the behavior you see. In this case rewriting the query is in order see below. ----Original Message----- >From: Oleg Broytmann > I freed some memory and the program worked. It ate 30 Megs while running, >so I was in need of memory. But it ran 30 minutes (on 3000 rows!) My feeling is that you are not using gadfly appropriately. For example if what you want is to identify rows with matching urls a join is not the best way to do it by far. Try this method instead. select * from bookmarks order by url, recno This query also should be fairly fast. Take the result of that query and loop through it in a python "for" loop to find the matching urls grouped together in the sequence. This is the way I'd recommend you do it using gadfly, oracle, sybase, mysql, etc... You can also potentially use "group by URL" with max() or min() to good effect, depending on what you want. Sorry for the fuss and Best regards, Aaron Watters === Please come back another day, and another person. -- from a story told by Erdos From Michael.Scharf at kosmos.rhein-neckar.de Thu Apr 22 18:32:54 1999 From: Michael.Scharf at kosmos.rhein-neckar.de (Michael Scharf) Date: Fri, 23 Apr 1999 00:32:54 +0200 Subject: Programming variability experiment [was: Re: Pointers to variables] References: <19990422121403.A279051@vislab.epa.gov> Message-ID: <371FA396.B8194FB0@kosmos.rhein-neckar.de> Randall Hopper wrote: > How can I cause a reference to the variables to be stored in the tuples > instead of their values? Impressive! All four solutions look the same! This reminds me of an experiment I would like to see: - Take a few simple (scripting) problems. - Give it to some (3,5,10,100 the more the better) programmers with different levels of experience. - Let them write little programs and tell them they should find a simple solution (no optimization tricks, no unnecessary generalizations etc.). - Do this for different languages and compare the variability and readability (by letting a control group try to read and understand the code) of the solutions. This would be another quality criterion for languages. It would be also interesting how the solutions of experienced programmers differ from beginners (for one language). Michael -- ''''\ Michael Scharf ` c-@@ TakeFive Software ` > http://www.TakeFive.com \_ V mailto:Michael_Scharf at TakeFive.co.at From bwarsaw at cnri.reston.va.us Thu Apr 29 11:36:16 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 29 Apr 1999 11:36:16 -0400 (EDT) Subject: Emacs' python-mode buggy? References: <7g8np4$kvf@chronicle.concentric.net> <000901be9203$b4c32e40$199e2299@tim> Message-ID: <14120.31856.181562.574382@anthem.cnri.reston.va.us> >>>>> "TP" == Tim Peters writes: | """ | "Hi!" I'm a doc string | """ TP> Emacs "sees" it as a sequence of 4 strings with some crap in TP> the middle: | "" | "\n " | Hi! | " I'm a doc string\n " | "" TP> elisp is too slow to do the character-at-a-time parsing that TP> would be needed to fix cases like this, so-- like all other TP> language modes --pymode settles for what it can get. AFAIK it TP> should *never* screw up in the absence of triple-quoted TP> strings, though, and you can help it make sense of those by TP> pretending you're the Emacs C parsing function, using TP> judicious backslash escapes until you stop confusing yourself TP> . Try something like the following for fun -------------------- snip snip -------------------- '''Hey! I thought I warned you. Don't even think about it! ''' # yikes! Emacs thinks this is a string # add a turd ' # now we're happy again -------------------- snip snip -------------------- -B From arcege at shore.net Mon Apr 12 13:56:33 1999 From: arcege at shore.net (Michael P. Reilly) Date: Mon, 12 Apr 1999 17:56:33 GMT Subject: extending questions References: <371220AD.6C3B0B5@home.com> Message-ID: Jim Meier wrote: : I have two questions, one simple, one a little bit whiny. : Firstly, I'm looking for a quick and easy way for a PyCFunction to : accept as an argument either an integer or a floating point number, so : that the function can be called as : func(1,1,1) : or as : func(0.5,0,2/3) : because python doesn't seem to let me consider an integer as a float. : I've tried using some of the conversion functions in the abstract : numeric suite and the PyFloat_GetDouble (or some similar name), but with : no luck - it always returned -1 for me. Any ideas? My best suggestion would be to use the PyInt_Check and PyFloat_check functions. PyObject *func(PyObject *self, PyObject *args) { PyObject *arg1, *arg2, *arg3; double a1, a2, a3; if (!PyArg_ParseTuple(args, "OOO", &arg1, &arg2, &arg3)) return NULL; /* get the double from the first argument */ #define py_to_double(a, var) \ if (PyInt_Check(a)) (var) = (double)PyInt_AS_LONG(a); \ else if (PyFloat_Check(a)) (var) = PyFloat_AS_DOUBLE(a); \ else { PyErr_SetString(PyExc_TypeError, "must supply a number"); \ return NULL; } py_to_double(arg1, a1); py_to_double(arg2, a2); py_to_double(arg3, a3); #undef py_to_double : Also, ust a suggestion, but would it be possible to add a : PyNumber_GetDouble(PyObject*n) function to the absract numberic : interface? This would be useful for this sort of situation. There already is a PyNumber_Float(PyObject *) function; since the purpose of the PyNumber_* functions is to make abstract numbers (classes, builtins, etc.), you don't want to assume it is a double, but to coerce it into a double. PyObject *temp; double result; if ((temp = PyNumber_Float(number)) != NULL) { result = PyFloat_AS_DOUBLE(temp); Py_DECREF(temp); } else return NULL; This is the same as "result = float(number)" in python, except that you get the C result. -Arcege From loewis at informatik.hu-berlin.de Mon Apr 26 07:08:59 1999 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 26 Apr 1999 13:08:59 +0200 Subject: Beginner Needs Help Compiling/Running Module References: <3723a436.9965940@news.earthlink.net> Message-ID: pfjakub at earthlink.net (Peter Jakubowicz) writes: > When I am in that directory I try to invoke python by typing python > MyModule.py and an command line arguments, as in Java, but > apparently I cannot do this. Alternatively, when I have the python > window console open I cannot get at my module at all, tho I can > invoke the python interpreter. Both methods should work. What are the error messages you see? From martinb at talx.com.no.spam Thu Apr 8 10:19:01 1999 From: martinb at talx.com.no.spam (Martin Bertolino) Date: Thu, 8 Apr 1999 09:19:01 -0500 Subject: COM Event Sinks and Connection Points in Python References: <7eggfh$o0f$1@nnrp1.dejanews.com> <7egnl2$ca5$1@m2.c2.telstra-mm.net.au> Message-ID: <7eie3h$sr$1@newsin-1.starnet.net> Some of COM features (especially when running in a Single Threaded Apartment (STA)) depend on the application having an event loop. I have not looked at the sources for PythonWin, but I have looked at the Python ones, and I did not see any event loop servicing the event queue. This would explain why you don't see the fired events. Martin Mark Hammond wrote in message <7egnl2$ca5$1 at m2.c2.telstra-mm.net.au>... > >cingram at my-dejanews.com wrote in message ><7eggfh$o0f$1 at nnrp1.dejanews.com>... >>I am trying to use functionality from a DLL that requires me to create a >COM >>event sink so that it can call back with events. I am trying to write this > >There appears to be some problem using connection points from Python.exe. > >Events seem a black art. Im happy to help you track this down, but I havent >much time... From fm at synchrologic.com Sat Apr 24 07:28:58 1999 From: fm at synchrologic.com (fm at synchrologic.com) Date: Sat, 24 Apr 1999 11:28:58 GMT Subject: GUI other than Tkinter (wxPython) References: <3721567f.1748033@news> Message-ID: <7fs9to$rlr$1@nnrp1.dejanews.com> I am a real big fan of wxPython. I've gotten everyone at our company hooked on it. We use it for prototyping apps now because it's so much faster than any other tool (that is, VB). It has a full set of controls (tree, list, grid). Actually, wxWindows on which it's based is pretty nice as well (though C++ requires 10-20 times more typing). Check out http://www.alldunn.com/wxPython/ and http://web.ukonline.co.uk/julian.smart/wxwin/. I think you'll be pretty happy with it. Good luck. In article <3721567f.1748033 at news>, mrfusion at bigfoot.com wrote: > Well, I've just about given up on EVER getting Tkinter to work on my > Win98 machine. Is there any other GUI module that I can get that > doesn't require TCL/TK to be installed on my machine? Isn't there > something called GD? -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From annis at biostat.wisc.edu Thu Apr 29 15:53:25 1999 From: annis at biostat.wisc.edu (William Annis) Date: 29 Apr 1999 14:53:25 -0500 Subject: SWIGgy Goodness, or, Where to Install Software Message-ID: I'm currently polishing up a module which is an interface to the Solaris kstat(3k) interface. Those people who get giddy at the idea of computing a machine's load by hand or pondering the minutiae of kernel memory allocation statistics will like this module. However, one of the things I'm trying to make more pleasant is the installation. The module will require the installation of two files: one in Python, and one a .so (dynamic library). Do I put both in the PREFIX../site-packages directory, or should I put the .so with the rest in PREFIX../lib-dynload? Or, is lib-dynload supposed to be reserved for modules bunlded with the core distribution? -- William Annis - System Administrator - Biomedical Computing Group annis at biostat.wisc.edu PGP ID:1024/FBF64031 Mi parolas Esperanton - La Internacia Lingvo www.esperanto.org From garryh at att.com Fri Apr 9 13:45:07 1999 From: garryh at att.com (Garry Hodgson) Date: Fri, 9 Apr 1999 17:45:07 GMT Subject: Is Python Dying? References: <370D36ED.8A270DE9@ome.com> Message-ID: <370E3CA3.951C2DE5@att.com> John Grayson wrote: > I don't know about *that* one, but I can say there are two new Python > books on the way from Manning Publications. > > Ken MacDonald's "The Quick Python Book" has been through its reviews and > has been revised. Right now it is in final technical review and once > complete the Publisher will begin production... ... > I'm at various stages of completion of chapters for "Python and Tkinter > Programming", which has just completed a review of the partial > manuscript... is there a timeline for either of these release yet? -- Garry Hodgson seven times down garry at sage.att.com eight times up Software Innovation Services AT&T Labs - zen proverb From olipt at mayo.edu Sat Apr 10 11:47:43 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Sat, 10 Apr 1999 10:47:43 -0500 Subject: Idiom for Getting Slices of a List In-Reply-To: References: Message-ID: > I want a clean, and relatively efficient method to do the following: > I have an array of length, n*m and I want to make it an array of > length m, where each member is an array of length n. > > Example: n=2, m=3 > [0, 1, 2, 3, 4, 5] ==> [[0, 1], [2, 3], [4, 5]] If you have the Numeric extension: from Numeric import reshape >>> d = [0,1,2,3,4,5] >>> n,m = 2,3 >>> f = reshape(d,(m,n)).tolist() >>> print f [[0, 1], [2, 3], [4, 5]] Best, Travis Oliphant From akuchlin at cnri.reston.va.us Fri Apr 30 10:49:00 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Fri, 30 Apr 1999 10:49:00 -0400 (EDT) Subject: pil vs gd In-Reply-To: <37299C02.4095E584@vic.bigpond.net.au> References: <37299C02.4095E584@vic.bigpond.net.au> Message-ID: <14121.47115.859663.399018@amarok.cnri.reston.va.us> John Leach writes: >gd does what I need; but in order to get some sort of context - does pil >provide, or is intended to provide one day, a superset of gd - or are >they separate beasts? PIL is far more powerful than gd, and is aiming at a more ambitious target; it can handle formats other than GIF, for a start. PIL can also do image-processing things like adjusting image brightness or contrast, blurring or sharpening, and all that sort of thing. >Can pil for example create gif images from text? And with a choice of >fonts? Yes, but the font support isn't very well-documented, at least in 1.0b1, so learning to use it requires poking around in the source code. -- A.M. Kuchling http://starship.python.net/crew/amk/ You shouldn't trust the story-teller; only trust the story -- The grandfather in SANDMAN #38: "The Hunt" From larsga at ifi.uio.no Fri Apr 9 13:04:13 1999 From: larsga at ifi.uio.no (Lars Marius Garshol) Date: 09 Apr 1999 19:04:13 +0200 Subject: Lexical analyzers and parsers References: <7jn20jmxsw.fsf@gandalf.midearth.fuzzys.org> <14092.48400.954787.617539@amarok.cnri.reston.va.us> Message-ID: * Andrew M. Kuchling | | There are actually a bunch of different systems available; see | http://starship.python.net/crew/amk/python/string.html#parsing for a | list. (If I've missed any, let me know.) TRAP was recently announced: --Lars M. From JamesL at Lugoj.Com Mon Apr 26 22:59:34 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 26 Apr 1999 19:59:34 -0700 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <37215EFB.433AFCA6@prescod.net> <3724B2D6.B468687A@prescod.net> Message-ID: <37252816.42634501@Lugoj.Com> Roy Smith wrote: [elided] > I hope this doesn't sound as bad as I fear it might, but part of being a > good programmer (or at least a good computer scientist) is to understand > performance issues like this. [elided] I disagree with the assumption behind that statement. The assumption Roy makes is that only trained programmers or computer scientists will be using a tool like Python. I believe the audience that would benefit most from an easy to use language like Python are "Subject Matter Experts" (SMEs). An SME knows their field (e.g. accountant, biologist, physicist, network manager, etc.) and may find need to automate or compute something whose scope or size does not justify calling in a computer programmer or scientist. This is where a simple to learn language such as Python finds a ready home. When an SME finds the tool too slow, it would be nice if they could post their problem to a group like this without fear of insult, intended or not. From aaron_watters at my-dejanews.com Mon Apr 12 09:52:53 1999 From: aaron_watters at my-dejanews.com (aaron_watters at my-dejanews.com) Date: Mon, 12 Apr 1999 13:52:53 GMT Subject: Help (PLEASE) CGI on 98/NT References: <370E9024.6D256DE8@bullfrog-tech.com> Message-ID: <7estrh$m0f$1@nnrp1.dejanews.com> In article <370E9024.6D256DE8 at bullfrog-tech.com>, manus at python.net wrote: > I had my Win95 Personal Web Server (PWS) up and running > just fine, having merely followed the simple instructions on > Aaron's pws.html page at the starship. > > So they go and give me a 98 machine. Well, it has PWS, so > you'd THINK it'd work if I did the same thing. Nope. > > I get "500 Server Error" and NO other help from Mr. Gates. Generally, whatever works for Perl should work for Python also with few changes. Maybe take a look at this http://www.DynamicNet.net/support/fp/perlwithPWS.htm And lemme know if anything there helps, or search around using dejanews, microsoft.com, lycos etc. for additional help, keywords="perl...". When you fix it propose patches to my page, please (or, I think there was a python-cgi faq somewhere that could be updated too). The problem may have to do with mime type registration... -- Aaron Watters === q: What do you call a drummer who's split with his girlfriend? a: homeless. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From downstairs at home.com Mon Apr 5 02:46:18 1999 From: downstairs at home.com (TM) Date: Mon, 05 Apr 1999 06:46:18 GMT Subject: povray.py Message-ID: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> Has anyone created a pov ray module for python? Thanks, Tom From kajiyama at grad.sccs.chukyo-u.ac.jp Mon Apr 12 15:29:03 1999 From: kajiyama at grad.sccs.chukyo-u.ac.jp (Tamito Kajiyama) Date: 12 Apr 1999 19:29:03 GMT Subject: Python 1.5.2c1 -- What if long long not supported? In-Reply-To: Guido van Rossum's message of Fri, 09 Apr 1999 11:21:19 -0400 References: <199904091521.LAA00858@eric.cnri.reston.va.us> Message-ID: Guido van Rossum writes: | | I received a bug report that if the (unnamed) platform doesn't support | the "long long" type, the configure script dies. The logic in | configure.in looks correct to me and I don't have any such Unix | platforms handy myself... Could someone who does investigate whether | there is truth in this complaint? I was able to reproduce this problem on SunOS 4.1.4_JL. In the configure script, if the C compiler does not support the "long long" type, the variable `ac_cv_sizeof_long_long' is not defined. This variable is referenced later for checking large file support, and the test command fails due to the lack of the expected argument that follows the second -a option. That's why the configure script dies. The attached is a context diff for fixing the problem. (I'm not familiar with autoconf, so please consider the way of fixing ;-) diff -cr Python-1.5.2c1.orig/configure Python-1.5.2c1/configure *** Python-1.5.2c1.orig/configure Tue Apr 13 02:16:45 1999 --- Python-1.5.2c1/configure Tue Apr 13 02:16:08 1999 *************** *** 2034,2039 **** --- 2034,2040 ---- echo $ac_n "checking for long long support""... $ac_c" 1>&6 echo "configure:2036: checking for long long support" >&5 have_long_long=no + ac_cv_sizeof_long_long=undefined cat > conftest.$ac_ext < From alrice at swcp.com Fri Apr 16 15:19:39 1999 From: alrice at swcp.com (Alex Rice) Date: Fri, 16 Apr 1999 13:19:39 -0600 Subject: Zope question Message-ID: <37178D4B.7D933209@swcp.com> Hi, this was a question I posted to the Zope mailing list, but no responses yet. I'm having trouble getting a source installation of Zope running on a Cobalt RaQ. TIA for any suggestions you might have! Date: Mon, 12 Apr 1999 13:31:56 -0600 (MDT) Message-Id: <199904121931.NAA22117 at tora.swcp.com> From: Alex Rice To: zope at zope.org Subject: [Zope] Zope startup problems Hi, after a great experience with the Zope Linux/x86 binaries, I am now trying to get a source installation running for the first time, but seem to have overlooked something. This is on a Cobalt RaQ. This is a MIPS processor with Linux 2.0.34. Basically a RedHat box. I built Python 1.5.1 and Zope-1.10.2-src with no problems. I'm using Apache. When I go to this URL: http://zope.swcp.com/Zope/ I see Zope.cgi process, then I see in my browser after about 15 sec: ! Temporarily Unavailable The resource you requested is temporarily unavailable - please try again later. (102) failure during connect In /usr/share/zope/var, I have only Data.bbb Data.bbb.in (pcgi.* seem to be missing?) Also, I do not see suspicious entries in apache's access and error logs. Below is the relevant section in my Apache config. But the rewrite rule seems to be working since the Zope.cgi process is getting started. Would really appreciate any suggestions. Thanks! ServerName zope.swcp.com ServerAdmin admin DocumentRoot /home/sites/home/web/zope ScriptAlias /zope-bin/ /home/sites/home/web/zope/cgi-bin/ AllowOverride None Options FollowSymLinks ExecCGI # Zope configuration maps everything to the Zope.cgi CGI script RewriteEngine on RewriteCond %{HTTP:Authorization} ^(.*) # this is actually all one line: RewriteRule ^/Zope/(.*) /home/sites/home/web/zope/cgi-bin/Zope.cgi/$1 [e=HTTP_CGI_AUTHORIZATION:%1,t=application/x-httpd-cgi,l] Please cc: alrice at swcp.com on your reply since I'm only in the list digest. TIA Alex Rice | alrice at swcp.com | http://www.swcp.com/~alrice Current Location: N. Rio Grande Bioregion, Southwestern USA From hannu at trust.ee Mon Apr 5 11:22:49 1999 From: hannu at trust.ee (Hannu Krosing) Date: Mon, 05 Apr 1999 18:22:49 +0300 Subject: Python and Qt+KDE References: <36F940DC.44F08BDF@druga.com> <7dbtb8$38j$1@nnrp1.dejanews.com> <7dec78$977$1@Starbase.NeoSoft.COM> <36FB0C5F.E6CE768D@zarlut.utexas.edu> <199903290118.UAA05150@mira.erols.com> Message-ID: <3708D549.12844324@trust.ee> "A.M. Kuchling" wrote: > > (I'm looking into GUI alternatives to Tkinter, having looked > at PyGTK, but haven't yet examined PyKDE to any significant degree; > comments on it would probably be helpful for many people interested in > writing desktop apps in Python.) You should check also wxPython at http://www.alldunn.com/wxPython/ ------------- Hannu From moshez at math.huji.ac.il Thu Apr 29 13:29:45 1999 From: moshez at math.huji.ac.il (Moshe Zadka) Date: Thu, 29 Apr 1999 20:29:45 +0300 Subject: converting perl to python - simple questions. In-Reply-To: References: <000101be8f62$b66e4700$669e2299@tim> Message-ID: On 29 Apr 1999, Randal L. Schwartz wrote: > >>>>> "Tim" == Tim Peters writes: > > Tim> Perl actually has the same problem, but it's *usually* hidden by "regexp > Tim> context"; e.g.; > Yes, Perl is heavily context sensitive... and so are human beings. :) I wonder if Randal came here (2 messages in this group) to spread the regular Perl propaganda (summarized by "This language is icky because programmers are icky").... Randal, while I'm sure you're a good guy, and I liked ``Learning Perl'', most of us at c.l.py heard more about Perl then we'll ever want to -- in fact, I think many of us moved to Python from Perl, and never looked back. (Or we'd turn into salt) (And hey, Randal, when you wake up and start using Python, I'm sure you'll be one of the best c.l.py posters <0.5 wink>) and-one-day-larry-wall-will-help-maintain-python-too-ly y'rs, Z. -- Moshe Zadka . QOTD: My own exit is more likely to be horizontal then perpendicular. From kernr at mail.ncifcrf.gov Sun Apr 4 20:09:15 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Sun, 04 Apr 1999 20:09:15 -0400 Subject: plea for kjbuckets for pywin References: <7e8hds$5i7$1@nnrp1.dejanews.com> Message-ID: <3707FF2B.874E95C9@mail.ncifcrf.gov> bgue at my-dejanews.com wrote: > > Has anybody compiled kjbuckets against Pywin 1.5 or 1.5.1, and if so, could I > trouble you for a copy? I lack a compiler on my Windows partition. http://www.chordate.com/kwParsing/kjbuckets.pyd > Thanks, > > Brian You're welcome. -- Robert Kern | ----------------------|"In the fields of Hell where the grass grows high This space | Are the graves of dreams allowed to die." intentionally | - Richard Harter left blank. | From stadt at cs.utwente.nl Mon Apr 26 08:29:58 1999 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Mon, 26 Apr 1999 14:29:58 +0200 Subject: Kosovo database; Python speed References: <371DAAC2.D9046550@cs.utwente.nl> <371DB480.32947654@appliedbiometrics.com> Message-ID: <37245C46.C13AAB62@cs.utwente.nl> Christian Tismer wrote: > > Richard van de Stadt wrote: > > > > Suppose we were going to make a database to help Kosovars locate > > their family members. This would probably result in hundreds of > > thousands of records (say 1 record (file) per person). > > > > Would Python be fast enough to manage this data, make queries on > > the data, or should compiled programs be used? > > Dependant of the operating system, I'd suggest to use a > database extension. > Controlling this database from Python will give you > enough speed. If I had to do this, my preferences are > > mySQL for Linux, with its interface, > MS-Access for Windows, with a COM interface. > > The latter is not since I like it so much, but we have > used it before, and the interfaces are there. > > Since the Kosovars need help quickly, I'd use this combination > instead of writing something special. I developed a system over the last few years which allows online paper submission and retrieval, which we expect can quite easily be transformed and reused to create a first prototype. On an old system (SS10, 128MB RAM), Python is able to copy a test file about 25000 times per minute, so I expect Python to be fast enough, but wondered if other projects exist which also use several 100.000's of records. > Python alone will not > be too easy, since your data will probably not fit into memory. We were donated a system that is, I think, used for videoconferencing. This probably is a Sun system, running Solaris, with Python 2.5.1 available. I expect at least .5 GB of RAM. > You will also have lots of edits, so I think using a true > database is the better choice here. (Not saying that Access is > a true database, but it works fine with several 100000 records). > > But two single columns with a name and a record ID will fit, > so your code might extract this info as a whole, map it to a dict > and search it in some sophisticated manner. This can be even faster > than the database. > Do you have more info on the amount of data, fields per record, > and what search capabilities are needed? Is it designed as a web > based application? Are there on-line updates and such? We intend to store any data that might be helpful, which includes photos. Online submissions may not always be possible from within the camps, but as refugees are being spread all over Europe, we think that it could be used more often. We'd like to collect existing databases, merge them, and provide all kinds of name matching possibilities. Offline consulting and submission should also be available, so probably there Access might then be used. > ciao - chris > > -- > Christian Tismer :^) [...] Richard. From stephan at pcrm.win.tue.nl Thu Apr 29 09:49:55 1999 From: stephan at pcrm.win.tue.nl (Stephan Houben) Date: 29 Apr 1999 15:49:55 +0200 Subject: HTML "sanitizer" in Python References: Message-ID: "Scott Stirling" writes: > 1) What is the Python syntax for opening a file in MS Windows? I was following Guido's tutorial yesterday, but I could not figure out how to open a file in Windows. ??? I don't think it's different on windows than on linux. Just do: f = open("my_file.html", "rt") (OK, there *is* a difference, I guess; you really need the "t" in "rt". Otherwise the carriage returns show up in your file.) > 2) How do I find a string of text in the open file and delete it iteratively? Check out the "string" module. > 3) How do I save the file in Windows after I have edited it with the Python program? How do I close it? Well you open a second file, for writing this time: f2 = open("output.html", "wt") Then you write to it to your heart's content: f2.write("blahblahblah") Then you close it: f2.close() But all this is in the Python docs, so perhaps you should try to read them. > 4) If someone helps me out, I think I should be able to use this info. and the tutorial and the Lutz book to loop the process and make the program run until all *.htm files in a folder have been handled once. Well, if I understand correctly, the *only* thing you're trying to do is to remove some specific strings from a bunch of files. Now if I were you, I wouldn't even bother to use Python on something that simple; I would just use sed. With sed, you could do: sed 'g/string_to_be_eliminated//g' my_file.html > output.html Presto, that's it. I think that there is a version for GNU sed for Windows somewhere out there; do yourself a favour and get it. Greetings, Stephan From retrev at razor Fri Apr 23 13:29:19 1999 From: retrev at razor (Trevor Clarke) Date: 23 Apr 1999 17:29:19 GMT Subject: Pythonized Shell Message-ID: Here it is....another Pythonized shell....this one is really simple(for now at least). It reads input from stdin and try's to eval() it. If that fails, it try's to exec() it. If that fails, it os.system()'s it. It also has support for simple alias'ing of commands. You can import and cd(1) is part of the shell(so it actually works :) ) I'm working on a faster C version that will look a lot like csh(1) except programming is done in python and all the python interactive interpreter features will be there. Let me know what you think... ftp://ftp.csh.rit.edu/csh/retrev/psh -- Trevor R.H. Clarke Computer Science House Rochester Institute of Technology Scientific Programmer for CIS retrev at csh.rit.edu trcpci at cis.rit.edu http://www.csh.rit.edu/~retrev/ finger retrev at csh.rit.edu for PGP key From SSTirlin at holnam.com Thu Apr 29 12:20:27 1999 From: SSTirlin at holnam.com (Scott Stirling) Date: Thu, 29 Apr 1999 12:20:27 -0400 Subject: HTML "sanitizer" in Python Message-ID: On opening files in Windows--I was hoping there was a way to give python the full file path. Everything I have seen so far just tells me how to open a file if it's in the same directory I am running python from. I don't have sed on my MS Windows PC at work. This was part of the initial explanation--I am working for a company where we have DOS, Windows and Office 97. No sed, no Unix. This is a Y2K Project too, so we are on a budget with little leeway for new ideas that weren't included in the original statement of work and project plan. Scott >>> Stephan Houben 04/29 9:49 AM >>> "Scott Stirling" writes: > 1) What is the Python syntax for opening a file in MS Windows? I was following Guido's tutorial yesterday, but I could not figure out how to open a file in Windows. ??? I don't think it's different on windows than on linux. Just do: f = open("my_file.html", "rt") (OK, there *is* a difference, I guess; you really need the "t" in "rt". Otherwise the carriage returns show up in your file.) > 2) How do I find a string of text in the open file and delete it iteratively? Check out the "string" module. > 3) How do I save the file in Windows after I have edited it with the Python program? How do I close it? Well you open a second file, for writing this time: f2 = open("output.html", "wt") Then you write to it to your heart's content: f2.write("blahblahblah") Then you close it: f2.close() But all this is in the Python docs, so perhaps you should try to read them. > 4) If someone helps me out, I think I should be able to use this info. and the tutorial and the Lutz book to loop the process and make the program run until all *.htm files in a folder have been handled once. Well, if I understand correctly, the *only* thing you're trying to do is to remove some specific strings from a bunch of files. Now if I were you, I wouldn't even bother to use Python on something that simple; I would just use sed. With sed, you could do: sed 'g/string_to_be_eliminated//g' my_file.html > output.html Presto, that's it. I think that there is a version for GNU sed for Windows somewhere out there; do yourself a favour and get it. Greetings, Stephan -- http://www.python.org/mailman/listinfo/python-list ________________________________________________________________ Scott M. Stirling Visit the HOLNAM Year 2000 Web Site: http://web/y2k Keane - Holnam Year 2000 Project Office: 734/529-2411 ext. 2327 fax: 734/529-5066 email: sstirlin at holnam.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From tim_one at email.msn.com Thu Apr 15 23:02:20 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 16 Apr 1999 03:02:20 GMT Subject: forking + stdout = confusion In-Reply-To: References: Message-ID: <001d01be87b5$8b3529a0$ada22299@tim> [Clarence Gardner] >> Mea culpa. The os.close() *is* still necessary. Is there yet another >> copy of these file objects? I tried to find that function that returns >> the reference count, but don't see it in the manual. [Michael Hudson] > It's sys.getrefcount: > > Python 1.5.2 (#2, Apr 14 1999, 13:02:03) [GCC egcs-2.91.66 > 19990314 (egcs-1.1.2 on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import sys > >>> sys.getrefcount (sys.stdout ) > 5 > > Five! I don't know where all of those are... Two are in sys (sys.stdout & sys.__stdout__), two more are in a hidden copy of the initial contents of sys used to keep extension modules sane, and the fifth is-- in effect --a temporary side-effect of passing the object to sys.getrefcount itself (you may have noticed that sys.getrefcount never returns a count less than 2!). It doesn't matter, though, because unlike file objects you create with "open", Python won't close the file descriptor underlying the default binding for sys.stdout (or .stdin or .stderr) even if all references do go away. Those three file objects are initialized specially (in _PySys_Init). 2-plus-2-equals-5-and-0-equals-3-ly y'rs - tim From steve at blighty.com Sat Apr 10 22:42:56 1999 From: steve at blighty.com (Steve Atkins) Date: Sun, 11 Apr 1999 02:42:56 GMT Subject: Internet Robot References: <7ehe9m$hbs$1@nnrp1.dejanews.com> <7emldl$rh9$1@nnrp1.dejanews.com> Message-ID: <37160aeb.268054642@192.168.1.1> On 10 Apr 1999 19:53:18 -0500, David Steuber wrote: >gscot at my-dejanews.com writes: >-> You mentioned that it might be helpful to capture and look at the client's >-> out put. How do I do that. > >This can be tricky. Idealy, when talking to the server, you want an >HTTP client that will show you all the headers. When talking to the >client, you want the server to display all the headers (or send them >back to the client). I've always done this the hardway. You can netcat, 'nc', can be a very handy tool for client debugging. You can easily setup a microserver that'll dump requests from the client to the console. It's a standard networking swiss-army tool - it shouldn't be too hard to find the source code on the 'net (it has versions for *nix and windows). >actually talk to an HTTP server with telnet if you are desperate >enough. I don't recomend it because one typo and you have to do the >request over again. http://samspade.org/t/safe.cgi is a web based http client that shows the whole transaction. Handy for initial debugging of servers, and less painful than telnet. >Other people responding mentioned a url package for python. I would >take a look at that to see just what it can do. It may make the job a >lot easier. Seconded. Cheers, Steve -- -- Steve Atkins -- steve at blighty.com From blipf at yahoo.com Wed Apr 7 21:33:09 1999 From: blipf at yahoo.com (Flbill Blipf) Date: Wed, 07 Apr 1999 18:33:09 -0700 Subject: Tkinter and centering References: <370B88CF.993D8847@yahoo.com> <370BC217.FFF53A35@vision.arc.nasa.gov> <370BDBD0.5657AC26@vision.arc.nasa.gov> Message-ID: <370C0755.940F9AFF@yahoo.com> Thanks guys! From tismer at appliedbiometrics.com Wed Apr 7 13:43:24 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 7 Apr 1999 17:43:24 GMT Subject: Crappy Software was Re: [OffTopic: Netscape] Re: How should References: <1288614834-78399188@hypernet.com> Message-ID: <370B993C.8DFFB4A4@appliedbiometrics.com> Gordon McMillan wrote: > > guppy wrote: > > > And another kick at Netscape: > > > Having recently ported a sophisticated applet using JNI (Sun's new > native interface) to JRI (older Netscape) and RNI (older IE), I too > can kick and scream. Same here. In my recent plugin project, I had to support both Netscape and MSIE. The hard thing was supposed to be MSIE, Netscape was done last year already. But, instead, MSIE had its problems, but porting the plugin from NS4.0 to NS4.5 took me full 10 days and nights! They messed such a lot of things up. Now I can sing a lot of Netscape dll entry points which I became very accustomed to from my debug sessions! Code which needed to sens a JavaScript URL to one frame window caused crashes at random time, and I had to completely circumvent this. They're going nuts. They should rewrite the whole crap, presumably build it from the bones of Grail :-)) > Sheesh. Gosh - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 uffe at data-dealeren.dk Mon Apr 19 08:49:36 1999 From: uffe at data-dealeren.dk (Uffe Koch) Date: Mon, 19 Apr 1999 12:49:36 GMT Subject: How alter maximum recurtion depth Message-ID: <371B2660.ECE4660A@data-dealeren.dk> How do I alter the maximum recursion depth for my Python interpreter? -- /Uffe Overgaard Koch From aa8vb at vislab.epa.gov Mon Apr 19 09:50:13 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Mon, 19 Apr 1999 13:50:13 GMT Subject: Tkinter - the app that wouldn't quit In-Reply-To: ; from Rob Hooft on Mon, Apr 19, 1999 at 08:42:51AM +0200 References: <19990416144831.A1548022@vislab.epa.gov> Message-ID: <19990419095013.A62714@vislab.epa.gov> Rob Hooft: |The problem in your current program appears to be that when your |application window is destroyed, "root" is still an active window, |although it is invisible. | |The WM_DELETE protocol is never called, because you're not |"destroying" the window using the window manager. Ok. That makes sense. |The smallest change would be to make the "Quit" button run "sys.exit" |immediately instead of "self.destroy". The problem here is that this is supposed to be a reusable dialog which doesn't exit the app. In reality, the button says "Dismiss" not "Quit". Hitting it just destroys the dialog (and all the processing guts inside, which I've deleted) and the app continues. Only for the test wrapper do I want to exit the app -- since it's the only window displayed. Do I need to add special testing-harness hooks into the dialog class, or is there a general way to determine when a dialog destroys/unmaps itself from outside of the dialog code? Randall -------------- next part -------------- #!/usr/bin/env python import sys from Tkinter import * from ScrolledText import ScrolledText class CommandWindow(ScrolledText): def __init__(self, master=None, **cnf): apply(ScrolledText.__init__, (self, master), cnf) class CommandWindowDialog(Toplevel): def __init__(self, master=None, **cnf): apply(Toplevel.__init__, (self, master), cnf ) self.title( 'COMMAND OUTPUT' ) win = CommandWindow( self ) win.pack(expand=1, fill=X) btn = Button( self, text="Quit", command=self.destroy ) btn.pack() root = Tk() w = CommandWindowDialog( root ) w.protocol( 'WM_DELETE_WINDOW', sys.exit ) root.wm_withdraw() w.mainloop() From jeremy at cnri.reston.va.us Thu Apr 15 18:39:11 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 15 Apr 1999 22:39:11 GMT Subject: for in benchmark interested In-Reply-To: <14102.20958.460408.832042@buffalo.fnal.gov> References: <37157CE7.EFB470CA@inka.de> <14102.15523.573321.443195@bitdiddle.cnri.reston.va.us> <14102.20958.460408.832042@buffalo.fnal.gov> Message-ID: <14102.20968.308910.844571@bitdiddle.cnri.reston.va.us> Doh! I guess you could read it all at once, which would be fine for a file that's only 6MB or so. If you wanted correctness (how important is that in a benchmark anyway?) and still want to read fixed-size chunks, then you need to see if the buffer that is read ends in the middle of a word or between words. If you add that checking, the code is a bit more complex but still about 20% faster. #!/usr/local/bin/python import sys import string def run(): dict={} dict_get = dict.get read = sys.stdin.read string_split = string.split prev = '' while 1: buf = read(500000) if buf: parts = string_split(buf) # did buffer start with whitespace? if buf[0] == parts[0][0]: parts[0] = prev + parts[0] elif prev: dict[prev] = dict_get(prev, 0) + 1 for key in parts[:-1]: dict[key] = dict_get(key, 0) + 1 # buffer end with whitespace? if buf[-1] != parts[-1][-1]: key = parts[-1] dict[key] = dict_get(key, 0) + 1 prev = '' else: prev = parts[-1] else: return dict dict = run() write = sys.stdout.write for word in dict.keys(): write("%4d\t%s\n" % (dict[word], word)) Jeremy From petrilli at trump.amber.org Thu Apr 15 16:07:00 1999 From: petrilli at trump.amber.org (Christopher Petrilli) Date: 15 Apr 1999 13:07:00 PDT Subject: Fnorb for JPython ? (WAS: Fnorb 1.0 - A Python CORBA ORB) References: <371619a4.1287080@news.cybercity.dk> Message-ID: <7f5gt4$33q@chronicle.concentric.net> Morten Christensen wrote: > I would like to suggest support for JPython (for pure java) !!! Wouldn't it make sense to use a Java based CORBA ORB? This would be MUCH faster and I think there are more than few out there. Chris -- | Christopher Petrilli ``Television is bubble-gum for | petrilli at amber.org the mind.''-Frank Lloyd Wright From quango at watervalley.net Tue Apr 13 05:41:14 1999 From: quango at watervalley.net (Chris Lawrence) Date: 13 Apr 1999 09:41:14 GMT Subject: rfc822 date header References: <3712D863.2A8148BC@rubic.com> <3712F4C1.52327AF4@lemburg.com> Message-ID: On Tue, 13 Apr 1999 07:39:45 GMT, M.-A. Lemburg wrote: >Jeff Bauer wrote: >> >> Is there a reasonably bulletproof way to generate an >> rfc822-compliant date header using the time module? >> >> The reason I ask is I recall a number of subtle >> errors in this regard, reported by Chris Lawrence, >> among others. [Eeek! I'm famous!] >According to the RFC, time.ctime() should do the trick... >but it's probably locale aware which the RFC doesn't account >for. time.ctime() will throw you off (it will generate Unix timestamps, which are decidedly non-RFC-compliant in any number of ways). Try: time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(timeval)) where timeval is a time.time() result. If you already have the tuple form, you may need to coax it into gmt-relative tuple form first (see the tz-aware functions in rfc822). Actually, here you're getting a GMT RFC-compliant header, which is a subset of the universe of allowed headers, but if you're dumping HTTP output this is what you need. Cheap hack for other timezones (untested, ugly, but probably right): ttuple = time.localtime(timeval) x = time.strftime('%a, %d %b %Y %H:%M:%S ', ttuple) if ttuple[8] == 1: x = x + ('%04d' % (-time.altzone)) else: x = x + ('%04d' % (-time.timezone)) Note that locales will screw up the %a (weekday) and make it non-RFC-compliant (though whether anything in the real world will CARE is another question entirely). You may need to bracket this with some locale.setlocale() calls if you're using locale != "C". Incidentally, the locale issue even affects GNU date. Try 'LC_ALL=fr_FR date --rfc --utc' sometime on Linux ;-) I made a patch but dunno if it ever made it upstream... The "subtle errors" were mainly in parsing the damn things, and in Linux's implementation of the time functions in libc6 (which drove me crazy until I finally figured out what was going on a few weeks ago ;-). Chris, exploring the minutae of the topic (as per clp tradition) -- ============================================================================= | Chris Lawrence | Get your Debian 2.1 CD-ROMs | | | http://www.lordsutch.com/ | | | | | Grad Student, Pol. Sci. | Do you want your bank to snoop? | | University of Mississippi | http://www.defendyourprivacy.com/ | ============================================================================= From tim_one at email.msn.com Sun Apr 25 19:47:17 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 25 Apr 1999 19:47:17 -0400 Subject: Time complexity of dictionary insertions In-Reply-To: Message-ID: <000201be8f75$f3e3f0e0$669e2299@tim> [someone asks about the time complexity of Python dict insertions] [Tim] > Min O(1), Max O(N), Ave O(1). If the hash function is doing > a terrible job (e.g. maps every key to the same hash value), make > those all O(N). [Moshe Zadka, gets back to the topic ] > This is interesting. What is the WCS behaviour of Python dicts? "If the hash function is doing a terrible job (e.g. maps every key to the same hash value), make those all O(N)." That implies O(N**2) for a sequence of N inserts. > but-it-doesn't-really-matter-'cause-it-takes-finite-time-anyway-ly y'rs, > Z. Oh, it matters a lot! I'll attach a test case, showing how to consume 4 minutes with about 2000 measily inserts. Python's tuple hash function once did a very poor job on int 2-tuples of the form (i, i+-1), which made marching over diagonals of sparse 2D arrays (represented as dicts) a major exercise in faith . if-it-weren't-for-probability-we'd-all-be-dead-ly y'rs - tim Output from a careless (non-quiet) run, 1.5.2, Win95, P5-166: Timings for horrid = 0 total # dict entries; elapsed time; ratio to last elapsed 1 0.00 2 0.00 1.17 4 0.00 1.23 8 0.00 1.36 16 0.00 2.46 32 0.00 1.29 64 0.01 1.46 128 0.01 1.58 256 0.02 1.76 512 0.03 1.94 1024 0.06 1.91 2048 0.11 1.96 Timings for horrid = 1 total # dict entries; elapsed time; ratio to last elapsed 1 0.00 2 0.00 2.91 4 0.00 3.35 8 0.00 3.81 16 0.02 4.14 32 0.06 3.90 64 0.28 4.76 128 1.20 4.25 256 3.91 3.26 512 14.66 3.75 1024 57.85 3.95 2048 231.16 4.00 Code: import time class Horrid: N = 0 def __init__(self, horrid=1): self.value = Horrid.N Horrid.N = Horrid.N + 1 self.horrid = horrid def __hash__(self): if self.horrid: return 42 else: return hash(self.value) def __cmp__(self, other): return cmp(self.value, other.value) MAX = 2**11 def timeit(horrid): clock = time.clock d = {} elapsed = 0.0 numtoadd = 1 while 1: if numtoadd + len(d) > MAX: break stufftoadd = map(Horrid, [horrid] * numtoadd) start = clock() for thing in stufftoadd: d[thing] = 1 finish = clock() lastelapsed = elapsed elapsed = elapsed + (finish - start) print "%7d %8.2f" % (len(d), elapsed), if lastelapsed: print "%5.2f" % (elapsed / lastelapsed) else: print numtoadd = len(d) for horrid in 0, 1: print "\nTimings for horrid =", horrid print "total # dict entries; elapsed time; ratio to last elapsed" timeit(horrid) From john at mankato.msus.edu Tue Apr 20 11:06:39 1999 From: john at mankato.msus.edu (John) Date: Tue, 20 Apr 1999 10:06:39 -0500 Subject: Telnetlib error Message-ID: I am running python 1.5.2 (final release downloaded 19Apr1999) on: Linux version 2.0.34 (gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)) Has anyone else run into this problem? File "./telnet_test.py", line 86, in ? initial_data = tn.expect('->') File "/usr/local/lib/python1.5/telnetlib.py", line 450, in expect list[i] = re.compile(list[i]) TypeError: object doesn't support item assignment From faassen at pop.vet.uu.nl Mon Apr 12 11:09:07 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Mon, 12 Apr 1999 17:09:07 +0200 Subject: Python Chip References: <3709CFC0.BCB0990A@pop.vet.uu.nl> <000a01be845b$de38b020$2a9e2299@tim> Message-ID: <37120C93.FB587563@pop.vet.uu.nl> Tim Peters wrote: > > [Martijn Faassen] > > For those who are still anxiously itching to get their hands on a Python > > machine, this was of course an April Fool's joke. :) > > Oh, *now* you tell me, just hours before we were to tape out final silicon! > Wonder whether I can get my money back. Sorry. :) Actually it thought it was a nice example of comp.lang.python's flame/spam immune system that this thread immediately mutated into a quite serious discussion on Forth/Java/Pascal/etc chips. > > You can now all come to destroy me now. (any other jokes in this > > newsgroup which I missed?) > > Marc posted a nice amendment to his conference's menu, but all in all c.l.py > was a deadly serious gaggle of humorless geekoids this year. Maybe that's > appropriate, though, since Guido *was* run over by an April 1st bus. I missed this one. :) > thank-god-for-the-fully-automated-python-release-process-ly y'rs - tim yeah-good-thing-Guido's-time-machine-can-travel-forward-in-time-too-ly yours, Martijn From francois.bedard at usa.net Sun Apr 11 21:49:46 1999 From: francois.bedard at usa.net (Francois Bedard) Date: Mon, 12 Apr 1999 01:49:46 GMT Subject: Python's object model References: <37102ED0.933EDDA6@usa.net> Message-ID: <37115155.2B3D6B12@usa.net> Thank you both, Charles and Florent. I'm most familiar with Eiffel's object model and apparently generalized a bit hastily, but your answers did clarify things... Francois Francois Bedard wrote : > > I'm new at Python. In the following program, "stack_1 pops stack_2's > content" (that's actually what it prints), which is obviously not what > I'm after - nor would expect. [...] > > class Stack: > stack = [] > [...] > > class System: > stack_1 = Stack() > stack_2 = Stack() > [...] Charles G Waldman wrote : > > This "Stack" class [...] > doesn't work as you expected because the way you've declared it, the > ".stack" attribute is a class attribute (shared by all instances of > the class) rather than an instance attribute. To create instance > attriubtes, create them in the initializer, like this: > > class Stack: > def __init__(self): > self.stack = () > [...] Florent Heyworth wrote : > > what you're seeing is the difference between a class and an > instance variable. To see the behaviour you want you need to > modify your stack class as follows: > > class Stack: > def __init__(self): > self.stack = [] > [...] > > Otherwise the stack is a class variable which can be referred as > Stack.stack() (this would then act as a class global). > [...] From arcege at shore.net Tue Apr 6 10:50:13 1999 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 06 Apr 1999 14:50:13 GMT Subject: Tkinter bug in Misc.tkraise, Canvas.tkraise References: <7eaoop$leq$1@news-2.news.gte.net> Message-ID: John Michelsen wrote: : The following got posted in a reply tree by mistake: : I found a bug in using Tkinter to raise a canvas widget above later : packed (etc.) widgets. It seems Tkinter gets confused between the : Misc.tkraise() method and the Canvas.tkraise(item) methods. : The following script shows the problem: : from Tkinter import * : def raiseCanvas(): : canvas1.lift() : #canvas1.tkraise() : #canvas1.widgetlift() : root = Tk() : canvas1 = Canvas(root, bg='blue') : canvas1.place(x=10, y=10, anchor=NW) : canvas2 = Canvas(root, bg='red') : canvas2.place(x=20, y=20, anchor=NW) : raiseButton = Button(root, text='raiseCanvas', command=raiseCanvas) : raiseButton.pack() : root.geometry("%dx%d" % (100,100)) : root.mainloop() : which gives the following error: : Exception in Tkinter callback : Traceback (innermost last): : File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 764, in : __call__ : return apply(self.func, args) : File "C:\PROGRA~1\PYTHON\RAISEC~1.PY", line 4, in raiseCanvas : canvas1.lift() : File "C:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 1287, in : tkraise : self.tk.call((self._w, 'raise') + args) : TclError: wrong # args: should be ".8249616 raise tagOrId ?aboveThis?" : I made Tkinter do what I want by adding a method to the Misc : class and not the Canvas class: : class Misc... : def tkraise(self, aboveThis=None): : self.tk.call('raise', self._w, aboveThis) : lift = widgetlift = tkraise : so that widgetlift will call the tkraise in Misc and not the tkraise in : Canvas. : I discovered the error in developing a multiple document interface for : Tkinter : which can be found on: http://www2.zyvex.com/OpenChem/index.htm : Dockable toolbars and a tree widget can also be found there. : They probably don't look very good on unix yet. It is not a bug with either code, it is a naming problem. The Canvas.tkraise is calling the correct code, but it should be called tag_raise, not tkraise (see the Text widget for naming choice). Fredrik or Guido, is this something you can change for before 1.5.2 is released? (I don't see anything on www.python.org/1.5/ that says when 1.5.2 will be done except "mid March", which has gone by.) Until then, I would suggest the following fix: from Tkinter import Canvas Canvas.tag_raise = Canvas.tkraise del Canvas.tkraise, Canvas.lift This should correct the problem. -Arcege From petrilli at trump.amber.org Fri Apr 16 15:57:14 1999 From: petrilli at trump.amber.org (Christopher Petrilli) Date: 16 Apr 1999 12:57:14 PDT Subject: restore sources from PYC [Q] References: <000101be879c$8aed0670$6eba0ac8@kuarajy.infosys.com.ar> <37177D8E.FF43BF65@bigfoot.com> <7f80ii$7m0@journal.concentric.net> <61r9pk1h2t.fsf@anthem.cnri.reston.va.us> Message-ID: <7f84mq$a7c@chronicle.concentric.net> Barry A. Warsaw wrote: >>>>>> "CP" == Christopher Petrilli writes: > CP> Seriously, this is a non-event that people use to spread FUD, > CP> but it exists in all languages. The simplicity with which it > CP> can be done changes, but it's never more than a freshman > CP> college project. > Which is why almost every binary license I've ever stayed awake to > fully read includes text like "you may not decompile, disassemble, > reverse-engineer" blah, blah, blah! :-) Get a life, Barry ;-) Seriously, this is exactly the situation... in fact many companies put some bizarre constructions in their code so they can prove in court that someone "stole" the code... "Judge, no sane person would use a bubble sort!" ;-) Chris -- | Christopher Petrilli ``Television is bubble-gum for | petrilli at amber.org the mind.''-Frank Lloyd Wright From MHammond at skippinet.com.au Fri Apr 23 19:51:18 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 24 Apr 1999 09:51:18 +1000 Subject: PythonWin/ActiveX-Script Question References: <37214562@news1.jps.net> Message-ID: <7fr0vi$539$1@m2.c2.telstra-mm.net.au> This is a bug that must have appeared recently. Sigh. Should be fixed next build... Mark. Zigron wrote in message <37214562 at news1.jps.net>... > I recently installed PythonWin/et al, and went into the >win32comext/axscript/demos/client/ie directory, and found that basically >none of the demos worked at alllllll. > After fiddling with 'foo2.html', I found that all the references to >'MyForm.whatever' or 'Form2.whatever' were resulting in NameErrors..and that >if I put 'window.' onto the front of all the references they then worked. > > I'm just wondering if that's how it's susposed to be? > >--Stephen > > From robin at jessikat.demon.co.uk Thu Apr 22 14:50:51 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: 22 Apr 1999 18:50:51 GMT Subject: The Future of Tk? References: <371E964F.C531C2A@istar.ca> <371F11C2.3162025@ciril.fr> Message-ID: <7fnr2b$mrt$19@newsread.f.de.uu.net> In article <371F11C2.3162025 at ciril.fr>, Frederic BONNET writes >Hi, > >Eugene Dragoev wrote: >[...] >> But I also found that while older versions of Tk were using lightweight ... >> Is there going to be any Tk implementation that will continue using >> lightweight components? > >By lightweight I guess you mean emulated in some way. I don't think that >cross-platform look&feel consistency is a good thing. As a GUI designer >I'd rather follow the principle of least astonishment: an app running on >Windows should look and feel like a Windows app. The same app running on >MacOS and X should do the same on the respective platforms. Such a >cross-platform application is not supposed to look and feel the same on >all platforms. If users want to use the same app on several platforms, ... I take this completely differently; least astonishment for me is if program X looks and behaves the same way no matter what keyboard, mouse and screen I'm using. As a 'user' of the program X it shouldn't matter what OS/WM is executing the code. I certainly don't want vi or emacs to be different on the mac why should I treat word or excel differently? Another reason for having a Tk look and feel is that it allows widget behaviours different from those allowed by the underlying 'convention'. Of course those with an interest in the survival of rigid wm systems prefer we should adhere to their conventions. The only changes then come from the suppler of such systems and are introduced to make us by new versions etc. Competition between different WM's is currently almost impossible because of the original model ie the 'toplevel' is controlled and decorated by the WM. We don't have to do that with the widgets inside the 'toplevel' so why do we? Let 100 flowers bloom etc. ... >And I don't speak about look differences. > >See you, Fred -- Robin Becker From aa8vb at vislab.epa.gov Sat Apr 17 11:31:21 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Sat, 17 Apr 1999 15:31:21 GMT Subject: sys.path.insert - how to make it global? In-Reply-To: <3718a8aa.4229211@news.omnilink.de>; from Stefan Franke on Sat, Apr 17, 1999 at 03:30:26PM +0000 References: <19990416172011.A1551755@vislab.epa.gov> <3718a8aa.4229211@news.omnilink.de> Message-ID: <19990417113121.A1627033@vislab.epa.gov> Stefan Franke: |Randall Hopper: |> If I want to augment my Python module search path inside a Python |>script (so that it affects itself and imported modules), what's the best |>way to do this? | |sys.path *is* already global, though only accessible via the |sys module's namespace. Just give it a try. I'd already tried that. It's effect doesn't appear to be global: # Augment search path to pull in our C library wrappers sys.path.insert( 0, '/home/mylogin/Wrappers' ) import MapFile This allows Python to find MapFile, but this doesn't allow MapFile to import other modules in that same Wrappers directory. Randall From guido at CNRI.Reston.VA.US Sat Apr 3 08:11:40 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Sat, 03 Apr 1999 08:11:40 -0500 Subject: fix for posix_fsync under SunOS 4.1.x In-Reply-To: Your message of "Sat, 03 Apr 1999 07:29:50 GMT." <199904030729.XAA24695@igce.igc.org> References: <199904030729.XAA24695@igce.igc.org> Message-ID: <199904031311.IAA11599@eric.cnri.reston.va.us> > Here's a patch to make sure that posix_fsync will compile on all operating > systems (specifically needed for SunOS 4.1.x). > > This unified diff was made against Python 1.5.2 beta 2 . > > -scott > > --- Modules/posixmodule.c~ Tue Feb 16 11:38:04 1999 > +++ Modules/posixmodule.c Fri Apr 2 22:18:03 1999 > @@ -647,6 +647,8 @@ > "fsync(fildes) -> None\n\ > force write of file with filedescriptor to disk."; > > +extern int fsync(int); /* Prototype just in case */ > + > static PyObject * > posix_fsync(self, args) > PyObject *self; On how many other operating systems have you tried this patch? I have found that almost invariably when you use an extern declaration of a standard function that is defined in the system headers on most modern systems, there's at least one system out there where what they have in the headers causes a conflict with what you declare! It would be better if you put it insude an #ifdef specific for the SunOS 4.x platform. --Guido van Rossum (home page: http://www.python.org/~guido/) From nospam at bitbucket.com Fri Apr 9 02:08:18 1999 From: nospam at bitbucket.com (Phil Mayes) Date: Thu, 8 Apr 1999 23:08:18 -0700 Subject: Pythonwin problem in HookNotify Message-ID: The PythonWin documentation for PyCCmdTarget.HookNotify talks of returning "an integer containing the address of the first byte of the extended information [following the normal struct]." but the code (win32notify.cpp line 284) is: ob2 = PyInt_FromLong((int)pHdr + 1); and should be: ob2 = PyInt_FromLong((int)(pHdr + 1)); So the dread spectre of backwards compatibility arises: if this is fixed, whose code will it break? Note that code that is aware of this problem could check for it by testing bit 0, but that doesn't help code that _isn't_ aware of it. What are the odds of anyone using this rather obscure area? Any opinions on the best way to handle this? Mark? -- Phil Mayes pmayes AT olivebr DOT com Olive Branch Software - home of Arranger - http://www.olivebr.com/ Check out our PalmPilot news page at http://www.olivebr.com/pilot/news.htm From gony at my-dejanews.com Mon Apr 26 21:01:11 1999 From: gony at my-dejanews.com (gony at my-dejanews.com) Date: Tue, 27 Apr 1999 01:01:11 GMT Subject: HELP - FTP seesions using python???????? Message-ID: <7g328l$hga$1@nnrp1.dejanews.com> any links or tips etc on how to tackle automation of FTP sessions using python would be most appreciated. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From mal at lemburg.com Sat Apr 3 03:59:36 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 03 Apr 1999 10:59:36 +0200 Subject: add type predicates to types module? References: <14085.18842.492142.484721@bitdiddle.cnri.reston.va.us> Message-ID: <3705D878.4454DBEB@lemburg.com> Jeremy Hylton wrote: > > This is a really good idea. I know I've got type predicates of many > different flavors in code I've been working on recently. The tough > question, I think, is how to decide which predicates are needed and > how to implement them. > > The folkloric "file-like object" type is a good example. When people > say "file-like object" they mean an object that responds in a > reasonable way to the particular subset of methods on a builtin file > object that they are interested in. > > isSequence might be a better example, since you want to capture > instances that implement the sequence protocol along with tuples, > lists, and strings. I use: > > def isSequence(s): > try: > 0 in s > except TypeError: > return 0 > else: > return 1 I tried this a while back but then concluded that the meaning of "is sequence" can mean different things in different situations, e.g. sometimes I need the object to have a length, at other times I need __getitem__ (this is what "in" uses). Note that the above test fails for dictionary types, but let's dictionary like instances pass. I think a more generic API is needed; one that allows you to define the slots/special methods you really need (we'd have to map the special methods to slots for simplicity). Something like has_interface(obj,('__getitem__','__len__')) > def isCallable(obj): > if type(obj) in (types.BuiltinFunctionType, > types.BuiltinMethodType, types.LambdaType, > types.MethodType): > # XXX could include types.UnboundMethodType > return 1 > if type(obj) == types.InstanceType: > return hasattr(obj, '__call__') > return 0 There already is a builtin function iscallable() that does pretty much what you've coded in Python. > In the particular application I needed, I know I would not want to > include UnboundMethodTypes. In the general case, though, I think it > should be included. ... this is a special case I guess. iscallable(obj) and a type check could be combined to handle it. -- Marc-Andre Lemburg Y2000: 272 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From MHammond at skippinet.com.au Sun Apr 18 19:35:18 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Mon, 19 Apr 1999 09:35:18 +1000 Subject: Embedded Late Binding References: <3719D318.1267@iname.com> Message-ID: <7fdq7b$mpm$1@m2.c2.telstra-mm.net.au> 2 things come to mind here. * Simplest may be to use the pre-processor. something like: #define MAKE_FUNC(FuncName) \ static PyObject *Py##FuncName(PyObject *self, PyObject *args) \ blah blah \ rc = FuncName() \ blah blah\ MAKE_FUNC(OnFileNew); MAKE_FUNC(OnFileSave); You still have 400 methods to expose, but they get a lot smaller :-) Alternatively, this is a bit more complex: * Create a new "editor function" object. This would be a Python object that has a tp_call slot. The module or object getattr() call could create and return one of these objects. Eg: PyObject *getattr(char *attr) { if (IsEditorFuncName(attr)) return PyEditorFunction(attr); } The 3rd of the 2 alternatives :-) * Provide a Python wrapper class. Instead of dealing with Python modules and functions natively, work with classes. This is similar to the above option, but you move the logic into the Python code. Hope this makes some sense, and at least points you to the right path for your project... Mark. Jussi Jumppanen wrote in message <3719D318.1267 at iname.com>... > static struct PyMethodDef editor_functions[] = > { > { "get_line_number", MacroPython::get_line_number, 1 }, > { "set_line_number", MacroPython::set_line_number, 1 }, > { "FileClose" , MacroPython::edit_func , 1 }, > { "FileEdit" , MacroPython::edit_func , 1 }, > { "FileNew" , MacroPython::edit_func , 1 }, > { ......................... }, > { 0, 0, 0 }, > }; > >and then somehow in the C source: > > PyObject *MacroPython::edit_func(PyObject *self, PyObject *args) > { > PyObject *pObject = 0; > > if (PyArg_ParseTuple(args, "")) > { > /* somehow get the function name???? */ > char *function_name = ???? (ie FileNew, FileOpen etc); > > /* this part is easy enough todo */ > call editor passing(function_name); > } > return pObject; > } > > >Can anyone tell me if this possible with Python 1.5.1? > >Or is there a better way to achieve a similar result? > >Thanks in advance. > >Jussi Jumppanen >Home Page: http://ourworld.compuserve.com/homepages/jussi/ From rhww at erols.com Tue Apr 20 00:12:14 1999 From: rhww at erols.com (R Wentworth) Date: Tue, 20 Apr 1999 00:12:14 -0400 Subject: Date/Time conversions References: <371BEBA7.5DBC1B0F@qut.edu.au> Message-ID: <371BFE9E.B0B576EA@erols.com> Rico Albanese wrote: > thesql=thesql + frontpar + logtime + "," > The inclusion of this variable ^ (ie logtime) causes this script to fail. > When it is removed, it works ok. Use backquotes to turn the integer into a string, i.e., thesql=thesql + frontpar + `logtime` + "," From news at dorb.com Fri Apr 2 19:40:26 1999 From: news at dorb.com (Darrell) Date: Fri, 2 Apr 1999 19:40:26 -0500 Subject: string.join() vs % and + operators References: <37054490.E79ADCC9@easystreet.com> Message-ID: We have an application where many thousands of small strings are to be inserted and deleted from a very large buffer. When you have 100k different small strings to replace in 4meg of text the string.join seems to work well. I don't know where the trade off is but you could use re.sub One problem I still don't know how best to avoid is extreme memory consumption. When you have these large objects around they can be referenced from higher level objects and not get destroyed until the program exits. We should have thought about this from the begining of our project. def insertDeleteList(inbuf, l): """ Insert and delete segments in a buffer l is a list of (start, string, end) The input 'l' must be sorted If start and end are equal then string is inserted at that point If end > start then this range is deleted. If end < start then this range is duplicated """ splitBuf=[] last=0 for i in l: b=inbuf[last:i[0]] splitBuf.append(b) splitBuf.append(i[1]) last=i[2] # Advance past some buffer here splitBuf.append(inbuf[last:]) return string.join(splitBuf,'') From mlv at pobox.com Mon Apr 26 15:35:18 1999 From: mlv at pobox.com (Michael Vezie) Date: 26 Apr 1999 15:35:18 -0400 Subject: Pointers to variables References: <19990422121403.A279051@vislab.epa.gov> <371F6124.48EA9794@pop.vet.uu.nl> Message-ID: <7g2f5m$kl6$1@mlv.mit.edu> In article <371F6124.48EA9794 at pop.vet.uu.nl>, Martijn Faassen wrote: >But, if you'd use a mutable list, you still run into trouble. If you say >this: > > mylist = [None] # list with a single element >None > variable_i_want_to_change = "Foo" # a variable I want to >change > mylist[0] = variable_i_want_to_change # okay, mylist[0] points to >same data > mylist[0] = "Bar" # now mylist[0] points to >different data > >then 'variable_i_want_to_change' won't change. You've simply changed >what value mylist[0] points at. This is because a string (and integers >etc) are immutable values in Python. If you use a mutable value such as >a dictionary, you get this: I don't think it has anything to do with mutable or not. mylist[0] simply points (at first) to the same object (string) that variable_i_want_to_change (hereafter called 'var2chg'). Then, at the second assignment, mylist[0] points to something different. If var2chg were an array or dictionary, it would make no difference; mylist[0] would still, after the second assignment, be "Bar". > mylist = [None] > variable_i_want_to_change = {} > mylist[0] = variable_i_want_to_change > mylist[0]["some key"] = "bar" # indeed changes >variable_i_want_to_change! This is different from the other examples. Here, you dereference mylist[0] (which is still pointing to the same object that var2chg points to). So the common object that they both point to changes. Strictly speaking, you aren't changing var2chg, just that which it (and mylist[0]) points to. > # mylist[0] = "Bar" -- doesn't work, makes mylist[0] point elsewhere Well, it works as expected. It changes mylist[0], not what mylist[0] references. >I suspect I'm making things sound horribly complicated when they aren't >really. I can keep all this in my head easily, it's just hard >communicating it. I can understand the confusion with pointers from C, >but note that this is the actual semi-equivalent C code (of the first >fragment, not the dict one, and using ints instead of strings): > >/* Initialize the variables, assume easy allocate functions which do all >the > malloc() calls I don't want to figure out right now */ >int** mylist = allocate_list(); >*mylist[0] = 0; >/* now we have a list with a pointer to an int value, which is 0 */ > >int* variable_i_want_to_change = allocate_int(); >*variable_i_want_to_change = 1; >/* now we have a variable which points to an int value, which is 1 */ > >*mylist[0] = *variable_i_want_to_change; >/* now the data mylist[0] points at becomes 1 too */ > >*mylist[0] = 2; >/* now the data mylist[0] points at becomes 2 */ I wonder if this is how it goes. I've not dived into the python engine code, so I don't know. Are immutable objects stored as objects or just as the data? In the grand scheme of things, it really makes no difference. If there were an "add" method for ints (so you could say: var2chg = 5 var2chg.add(3) and have var2chg have a value of 8), then it would obviously be a concern. But you can't, so it really doesn't matter at the python level whether: a = 5 b = a means that b and a point to the same object, or to separate values of 5. If you could do b.add(3) and suddenly have a with a value of 8, then it would. Michael From sdm7g at virginia.edu Wed Apr 21 15:33:40 1999 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Wed, 21 Apr 1999 19:33:40 GMT Subject: How many of us are there? In-Reply-To: <371E2648.DED123AE@callware.com> References: <371E2648.DED123AE@callware.com> Message-ID: "How many of us are there?" Do you mean counting the elevator boy ? Is he part of your family ? Oh -- sorry, that's not Python. Oops. ---| Steven D. Majewski (804-982-0831) |--- ---| Department of Molecular Physiology and Biological Physics |--- ---| University of Virginia Health Sciences Center |--- ---| P.O. Box 10011 Charlottesville, VA 22906-0011 |--- Caldera Open Linux: "Powerful and easy to use!" -- Microsoft(*) (*) From news at dorb.com Tue Apr 6 12:18:04 1999 From: news at dorb.com (Darrell) Date: Tue, 6 Apr 1999 12:18:04 -0400 Subject: SWIG, Modulator, BGEN, etc. - which? (Re: swig or not to swig ?) References: <4p6O2.1348$8m5.2126@newsr1.twcny.rr.com> <3709f149.2262513@news.oh.verio.com> <19990406103412.A869943@vislab.epa.gov> <002b01be803c$635a54d0$6fc6a8c0@rochester.rr.com> <19990406111950.A870049@vislab.epa.gov> Message-ID: Randall, you are way ahead of me. And it sounds like SWIG is the good solution. Modulator doesn't parse header files and it's not obvious how to get BGEN working. Although BGEN looks promising if I had time. This time I'll use Modulator and hand code the rest. My application isn't very complex at all and the interface should be stable. Thanks for the responses. Darrell From chad at vision.arc.nasa.gov Fri Apr 9 15:03:23 1999 From: chad at vision.arc.nasa.gov (Chad Netzer) Date: Fri, 09 Apr 1999 12:03:23 -0700 Subject: import from user input? What about 'from'? References: <816010E2456BD111A48700805FBBE2EEA63EB9@ex-quebec-u1.baan.com> <370E0F51.E1D33D6@appliedbiometrics.com> Message-ID: <370E4EFB.3D9355BF@vision.arc.nasa.gov> Gaetan Corneau wrote: > I want to import modules at runtime, and get the module name from the user. > Is that possible? How? > > Christian Tismer wrote: > Instead, one should cut off the first name before the first dot > and put that into globals(). > > import string > globals()[string.split(modname, ".")[0]] = __import__(modname) > > seems to do it better. Hmm, what if I want to do something like: exec 'from ' + module_name + ' import ' + class_name Can I use the __import__call, and then just save the specific module name in globals()? ie. (minus exception checking): globals()[class_name] = getattr(__import__(module_name), class_name) Hell, I can just try it... % python Python 1.5.2b2 (#2, Apr 2 1999, 17:30:13) [C] on irix6 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> globals()['strip'] = getattr(__import__('string'), 'strip') >>> globals() {'strip': , '__doc__': None, '__name__': '__main__', '__builtins__': } Looks ok to me... Neat!. Chad Netzer chad at vision.arc.nasa.gov From mal at lemburg.com Fri Apr 16 08:36:40 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 16 Apr 1999 12:36:40 GMT Subject: ANN: mxStack Package - Version 0.3.0 References: <37171CCE.656F3EF6@lemburg.com> Message-ID: <37172ED8.26CC1110@lemburg.com> Oops, just found a bug in the release. I've just updated the package archive on starship: there was a bug in the non-zero testing code. With the updated version, this should now work correctly: s = Stack() while s: obj = s.pop() # do something with obj assert len(s) == 0 -- Marc-Andre Lemburg Y2000: 259 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From dkuhlman at netcom.com Wed Apr 28 11:12:14 1999 From: dkuhlman at netcom.com (G. David Kuhlman) Date: Wed, 28 Apr 1999 15:12:14 GMT Subject: decompiling python References: <3724E41E.D3730480@jpl.nasa.gov> Message-ID: First thing, look at 'dis' in the standard library reference. But, remember, Python is compiled to byte code for the Python virtual machine. 'dis' displays that byte code, *not* machine code for your microprocessor. - Dave Jeff Saenz wrote: > Does anyone know of a decompilation tool for python? > -jm From tbryan at zarlut.utexas.edu Sun Apr 25 19:48:18 1999 From: tbryan at zarlut.utexas.edu (Tom Bryan) Date: Sun, 25 Apr 1999 18:48:18 -0500 Subject: Beginner - Tkinter info References: <371c59e9.2723125@news.tin.it> <371B453E.C3F83831@foreman.ac.rwth-aachen.de> <004301be8a99$0faf7920$f29b12c2@pythonware.com> <7ftejj$pb9$1@nnrp1.dejanews.com> Message-ID: <3723A9C1.1CFEDBC6@zarlut.utexas.edu> pkleynjan at my-dejanews.com wrote: > > > there's something called websucker.py down in the Tools > > directory in the Python distribution: > > Call me stupid... Stupid! Oops...maybe you didn't really mean that. ;-) > I can't find websucker.py in either the > Windows or Linux 1.5 distributions... I don't see it in my Windows version either. If you're talking about a Linux version that came with your distribution, then they might not have saved the Tools directory. To check for certain, you could run find / -name websucker.py If you download the Python source and unpack it, websucker.py should be in Tools/webchecker/ under the Python source directory. still-waiting-for-an-excuse-to-use-websucker-ly yours ---Tom -- tbryan at zarlut.utexas.edu Remove the z from this address to reply. Stop spam! http://spam.abuse.net/spam/ From news at helen.demon.nl Thu Apr 29 03:58:44 1999 From: news at helen.demon.nl (Ilja Heitlager) Date: Thu, 29 Apr 1999 09:58:44 +0200 Subject: Designing Large Systems with Python References: <3725CA37.2027327D@lemburg.com> Message-ID: <7g939e$la5$1@news.worldonline.nl> David Steuber wrote in message ... >Try to imagine object oriented spaghetti. This is what happens when >analysis, design, and coding all happen at the same time. I do not believe that all software can be build in an ADC or waterfallwise manner, but as it seems there is more a problem of lack of management and lack of people. Sounds like a university project ;-) Ilja From faassen at pop.vet.uu.nl Mon Apr 19 09:14:17 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Mon, 19 Apr 1999 15:14:17 +0200 Subject: Why no "=" in if? (was Re: Quick fix to add "+=") References: <3717EE20.41343593@mediaone.net> <000701be888f$12fe2920$ee9e2299@tim> Message-ID: <371B2C29.594AE647@pop.vet.uu.nl> Blake Winton wrote: [assignment in expression rears its head again] > Hitler! Hitler! Hitler! > You're all Hitler! Hey, that doesn't work; intentional calling upon Nazis to end a thread isn't support to work. I read it in a FAQ on this (I forget the name for the 'law') just recently. :) Regards, Martijn From hj_ka at my-dejanews.com Wed Apr 14 22:10:10 1999 From: hj_ka at my-dejanews.com (hj_ka at my-dejanews.com) Date: Thu, 15 Apr 1999 02:10:10 GMT Subject: Tkinter: making a window unresizable (Win 95) Message-ID: <7f3hpt$e64$1@nnrp1.dejanews.com> Hi, Toplevels in Tkinter in Windows-95 come with the resizing button on the upper-right corner, next to the iconify and close buttons. Even if I use resizable(0,0) method of the Tkinter.Toplevel class, the resizing button still persists. And when I click on it, although the window now does not resize, it still flickers and moves around. This is kind of annoying. Is there a way of creating a non-resizable Toplevel in Tkinter more easily? Namely, is there a way to eliminate the resizing button completely? regards, HJ -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From mnot at pobox.com Mon Apr 12 17:51:31 1999 From: mnot at pobox.com (Mark Nottingham) Date: Mon, 12 Apr 1999 21:51:31 GMT Subject: hey advocates References: <7etg59$6mt$1@nnrp1.dejanews.com> Message-ID: <003f01be852e$a0125b60$0301a8c0@cbd.net.au> I had a program that I wrote in Perl and had no problem getting into cgi-resources. Then, when I rewrote it in Python and released it (while still making the original available; different uses), he wouldn't create a category for Python, and he wouldn't even put it somewhere else. Grrr... ----- Original Message ----- From: Newsgroups: comp.lang.python To: Sent: Tuesday, April 13, 1999 5:05 Subject: hey advocates > I don't know whether it really matters or not, but aren't there > any CGI or web applications written in Python? > > http://cgi-resources.com/Programs_and_Scripts/ > > [Actually, my experience has been that sites like this one > don't actually accept submissions they have no exterior interest > in, but it might be worth a try. Let's harass the poor bugger, > shall we?] > > -- Aaron Watters > > ==== > > It's humbling to think that when Mozart was my age > he'd been dead for 3 years. -- Tom Lehrer > > -----------== Posted via Deja News, The Discussion Network ==---------- > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own > > From aa8vb at vislab.epa.gov Fri Apr 23 07:27:10 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 23 Apr 1999 07:27:10 -0400 Subject: Callbacks and "callable" objects In-Reply-To: ; from Michael Hudson on Thu, Apr 22, 1999 at 05:54:03PM +0100 References: <19990422113516.A278137@vislab.epa.gov> Message-ID: <19990423072710.A344288@vislab.epa.gov> Michael Hudson: (wrapper class) (default-arg lambda/function wrapper) Christian Tismer: (functor module) (default-arg lambda/function wrapper) Thanks for the responses. I now have several good ways to approach this. Randall From nagwa at math.ephouse.com Thu Apr 22 16:35:26 1999 From: nagwa at math.ephouse.com (Nagwa Abdel-Mottaleb) Date: 22 Apr 1999 20:35:26 GMT Subject: >>> Down-Translation? <<< Message-ID: <7fo16e$810$1@usenet49.supernews.com> Greetings: I am looking for a suitable language that will enable me to down-translate XML files into something like LaTeX files. Is it easy to use Python for this process? For example, how easy it is to write code segments that enable to translate foo in the xml input file into \begin{tag} foo \end{tag} and things like that in the tex output file? Any pointers and/or sample code will be appreciated. (Please e-mail me if possible.) --Nagwa Abdel-Mottaleb From justin at linus.mitre.org Fri Apr 23 17:40:21 1999 From: justin at linus.mitre.org (Justin Sheehy) Date: 23 Apr 1999 17:40:21 -0400 Subject: Time complexity of dictionary insertions References: <371F2125.BEC5F892@fzi.de> <7fo08u$4j2$1@nnrp1.dejanews.com> <37207005.1CC60E1B@palladion.com> Message-ID: Tres Seaver writes: > > Min O(1), Max O(N), Ave O(1). If the hash function is doing a terrible job > > (e.g. maps every key to the same hash value), make those all O(N). > > C++ STL junkies know this as "amortized constant time". So does anyone who has ever studied much at all about algorithms, data structures, and optimization. It's not a C++ thing. It's a computer science thing. -Justin From gmcm at hypernet.com Sat Apr 24 11:21:03 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 24 Apr 1999 15:21:03 GMT Subject: wrapped around the axle on regexpressions and file searching In-Reply-To: <7frhe0$8g1$1@nnrp1.dejanews.com> References: <7frhe0$8g1$1@nnrp1.dejanews.com> Message-ID: <1287155028-45807148@hypernet.com> msrisney writes: > > I'm attemtping to locate log files on my drive(s), and do some > comparison. here's a simplified snippet where I'm getting > bottlenecked. > > >>>import os,re > >>>regexp = re.compile('.log') > >>>def find_log_files(arg, directory, names): > ...for name in os.listdir(directory): > if regexp.search(name): > print directory + "\\" + name > >>>os.path.walk('D:\\',find_log_files,None) > > > here are my questions: 1. this prints out not only files with the > file extensions ".log" but also any file name that has "log" in it's > name. how would I rewrite to avoid?? In a regex, a "." is a wildcard character. If you want a literal "." you need to escape it: re.compile('\\.log') or re.compile(r'\.log') > 2. is there a better, faster way of doing this??, my end goal is to > open the files and compare time sequences to one another. Any number of ways that would be faster. Since you've already got os imported, you could use os.path.splitext() if os.path.splitext(name)[1] == '.log': > 3. Is ther any way to determine the number of drives on a system, > obviuosly I am hardcoding the top level drive letter "D:\", is there > any way to search the entire system much like win32's find file > search?? Do you know how to search multiple drives with FindxxxFIle()? I've always thought that you either got the current drive or specified the drive to search. At any rate, os.path.exists('e:/') is an effective way of finding out if e: exists. Though specifying 'a:/' will pop up one of those lovely Abort/Retry/Fail dialogs if nothing is in the drive. in-nearly-20-years-I-still-haven't-figured-out-the-difference-between -Abort-and-Fail-ly y'rs - Gordon From tismer at appliedbiometrics.com Wed Apr 21 06:58:32 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 21 Apr 1999 10:58:32 GMT Subject: WINNT/9X patch for errors.c References: <371CF528.532DB5C@appliedbiometrics.com> <199904202239.SAA11014@eric.cnri.reston.va.us> <371DADAC.AF549EC0@appliedbiometrics.com> Message-ID: <371DAF58.70794C81@appliedbiometrics.com> Sorry, I forgot to change this: Instead of _WIN32, one should use MS_WIN32 which has the same meaning, but is the correct convention for Python. Please adjust the 3 places in the diff from > + #ifndef _WIN32 to > + #ifndef MS_WIN32 (it has no other effect, just a matter of style) ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 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 jkraai at murl.com Tue Apr 6 12:27:54 1999 From: jkraai at murl.com (jkraai at murl.com) Date: Tue, 6 Apr 1999 16:27:54 GMT Subject: Rat sighting online Message-ID: <004001be804a$86f8cc60$8b7125a6@cpda6686.mcit.com> Gee, didn't know anyone'd take this as bad. Just thought it deserved a catchy moniker. I really like it, too. When I was young, I used to catch these rodents (well, one anyway :). I like the cover, I like Mark's work, I like Python, I think the Python community's the best of its kind on the planet, I'll be buying two copies of the book as gifts. I'll hide my feelings on Nixon (hint: he was probably less flawed than me). I guess next time I'll sprinkle it with '< 1 spoonful wink>' and the medicine will go down better. ;) --jim -----Original Message----- From: Tom Fenn Newsgroups: comp.lang.python To: python-list at cwi.nl Date: Tuesday, April 06, 1999 11:08 AM Subject: Re: Rat sighting online >I actually like the cover. It has that "There everywhere but you can't >see them" >idea that I associate with Python. > >Mark Lutz wrote: >> >> jkraai at murl.com writes about Learning Python: >> > I can't resist, can we refer to it as: >> > >> > _Nixon_in_a_Nutshell_? >> >> I don't care how you refer to it, as long as you do ;-). >> >> --Mark Lutz (http://rmi.net/~lutz) From akuchlin at cnri.reston.va.us Fri Apr 2 16:59:08 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Fri, 2 Apr 1999 21:59:08 GMT Subject: Python books In-Reply-To: References: <7dtsa4$b6p$1@nnrp1.dejanews.com> <7e0t19$1de$1@nnrp1.dejanews.com> <7e2vol$8c6$1@news1.rmi.net> Message-ID: <14085.14480.691560.774349@amarok.cnri.reston.va.us> evil Japh writes: >Python" is more a book to be read through, rather than a reference; I'm >not saying I expected it to be a reference, but that I would like a book >that was a reference. I think the existing free documentation at http://www.python.org/doc/ is fine for reference purposes, and multiple reference guides aren't needed. Reference docs have the most complete and detailed coverage, and are subject to the most nitpicking flaws, so the division of effort resulting from two different sets of reference docs costs you a lot of accuracy and completeness. We should concentrate on improving them. For an example of why this is bad, look at some of the O'Reilly Java books, such as the Swing book. Some of the material essentially duplicates the Swing API docs, but you can't trust that material because, given the lead time required for book publication, some details may have changed, so you have to look at Sun's docs for definitive information anyway; having another reference-like work doesn't help anything, because it might be wrong. The reference-like material also makes the Swing book painfully dull to read, and probably soul-destroyingly boring to write, too. Focusing on tutorial aspects would have made the book smaller, less likely to get out of date, and more readable. Multiple *tutorials* and other learning documentation, on the other hand, are definitely good, since different people like different presentations. -- A.M. Kuchling http://starship.python.net/crew/amk/ "Where does this one come from? Have you been raiding poor Holinshed again? Or does Plutarch bear the brunt of your depredations?" "Bits of things, here and there, but it's mostly mine, for once." -- Ben Jonson and William Shakespeare, in SANDMAN #75, "The Tempest" From Martin.Preishuber at stuco.uni-klu.ac.at Fri Apr 23 04:33:42 1999 From: Martin.Preishuber at stuco.uni-klu.ac.at (Martin Preishuber) Date: Fri, 23 Apr 1999 08:33:42 +0000 Subject: Strange fork() behaviour Message-ID: <37203066.6B4A58D9@stuco.uni-klu.ac.at> Hi, There are some strange things with fork() and python 1.5.2 going on here. I do have some main program which is basically while 1: fork() The program forks under certain conditions and works as expected but somewhen the main process dies even though it is in the while 1: loop ... there's no error message ... did anyone see anything similar ? the program worked fine with 1.5.1 (this is all on a linux box running rh 5.2 and kernel 2.2.6-ac1) Martin -- Martin Preishuber - Student, ECLiPt Core Member, SysAdmin http://eclipt.uni-klu.ac.at, mailto:Martin.Preishuber at stuco.uni-klu.ac.at Quigley's Law: Whoever has any authority over you, no matter how small, will atttempt to use it. From max at rightworks.com Tue Apr 27 18:50:02 1999 From: max at rightworks.com (max at rightworks.com) Date: Tue, 27 Apr 1999 22:50:02 GMT Subject: smtplib hang on send "data " to MS SMTP server Message-ID: <7g5euo$m7e$1@nnrp1.dejanews.com> code which works fine with netscape SMTP mail server, fails (hangs) when attempting to send mail to a MicroSoft SMTP server. In the module following the call to putcmd("data") the data() calls getreply and never returns. Does anyone have an idea what is happening here? The server seems to work with other clients. thanks max -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From bernhard at alpha1.csd.uwm.edu Mon Apr 5 14:19:02 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 5 Apr 1999 18:19:02 GMT Subject: gzip/zlib module Doc bug (1.5.2b2 Library Reference) Message-ID: I probably encountered a Python Library Reference Documentation bug: The documentation version February 19, 1999 Release 1.5.2 coming with the windows packages in module gzip reads as follows: | 7.11 gzip -- gzip compression and | decompression using files. | | The data compression provided by the zlib module is compatible with | that used by the GNU compression program gzip. Accordingly, the gzip | module provides the GzipFile class to read and write gzip-format | files, automatically compressing or decompressing the data so it | looks like an ordinary file object. This leaves the impression that the gzip module can decompress all the files the gzip program can decompress, which is not true. The gzip program can also deflate data compressed with "compress" and "pack". The python module cannot do this. Another weakness in ether the documentation or the module itself is: | GzipFile ([filename[, mode[, compresslevel[, fileobj]]]]) [..] | The mode argument can be either 'r' or 'w', depending on | whether the file will be read or written. The default is the mode of | fileobj if discernible; otherwise, the default is 'r'. This is not true for Windows, where you need and have to use an additional "b" in the mode argument. At least I needed to do it, because otherwise I got an Error -5: Hit EOF when reading one file. There was probably a binary ^Z in the compressed file that the windows read rountines took for an EOF, because they were used in text mode. Both bugs sucked in some of my time. I hope this helps to improve! ;-> Bernhard From mwh21 at cam.ac.uk Thu Apr 22 12:54:03 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 22 Apr 1999 17:54:03 +0100 Subject: Callbacks and "callable" objects References: <19990422113516.A278137@vislab.epa.gov> Message-ID: Randall Hopper writes: > A while back I asked how to pass parameterized callbacks to Tkinter. > Now I need to explore how best to do partial resolution of callback > arguments. For example, define values for arguments 1 and 2 at > registration time, but leave argument 3 to be populated by Tkinter. > > Probably makes no sense. So let me use an example: I don't think that you've described your problem too well here, but I understand the problem faced in the example well enough. What you want is a callable object with state indpendent of the parameters it's passed by whatever's calling it. In your example below, you want the callback to have a `color' state. The most Pythonic way of doing this is to define a class like this: class ColorCallback: def __init__(self,color): self.color=color def callback(self,event): print self.color wgt1.configure( command = ColourCallback("blue").callback ) This can be a lot of typing for a measly little callback however, leading to the dreaded `default argument hack': def make_color_callback(color): def _(event,color=color): print color return _ This is less typing (& quicker) but it is sneaky. Tim Peters once said: > Not at all, although I agree here too . It's like saying a > fork is broken just because it's not that handy for jacking up a > car. That is, Guido implemented the syntax to support default > arguments, and it works great for that purpose! Using it to fake > closures is a hack, and the "hey, this is cool!" / "hey, this really > sucks!" mixed reaction thus follows, much as pain follows a car > falling on your skull. Stick to stabbing peas, or even teensy > pea-sized closures, and a fork serves very well. which sums it up far better than I ever could. (Pay a visit to http://starship.python.net/crew/amk/quotations/python-quotes.html somtime...) HTH Michael Hudson Jesus College Cambridge CB5 8BL From tim_one at email.msn.com Sun Apr 25 22:26:03 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 25 Apr 1999 22:26:03 -0400 Subject: converting perl to python - simple questions. In-Reply-To: Message-ID: <000101be8f8c$21a1d540$d5a02299@tim> [about Perl "if (defined($x{$token})"] [Tim sez "under the probably-correct theory that the Perl is just asking "does hash 'x' have key 'token'?"] [Aahz Maruch] > Try "definitely wrong theory" ;-). In Perl, exists($x{$token}) is > precisely equivalent to Pyton's x.has_key(token), and you can either use > defined($x{$token}) or $x{$token}!=undef to make sure that a value > exists for that key. Thing is, in Perl you can go straight to checking > the value because a non-existant key is not an error. > > (I won't quite call myself a Perl expert, but I'm pretty close to an > expert on Perl hashes.) But most Perl programmers aren't, and I've suffered thru enormous piles of Perl code that used "defined" where "exists" was appropriate. That's where my "probably" comes from: not talking about what the language does, but what the programmer probably *intended*. In the absence of more information about what the original script does, my guess is still that the author *intended* "exists" == has_key. not-all-perl-code-is-well-written-ly y'rs - tim From dalke at bioreason.com Thu Apr 29 20:26:56 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Thu, 29 Apr 1999 18:26:56 -0600 Subject: while (a=b()) ... References: <19990430000141.A5867@shalott> Message-ID: <3728F8D0.5E91C0F5@bioreason.com> Marco Mariani > Which one is more ugly? > c = curs.fetchone() > while c: > print c > c = curs.fetchone() > while 1: > c = curs.fetchone() > if c: > print c > else: > break The usual answers when this is asked (quick, checking if this is in the FAQ as it is a faq -- nope) are: 1) "The first is uglier as you have needless duplication of code" 2) """I wish Python could do while (c = curs.fetchone()): print c """ To which the response is, it isn't worth the consequences of making hard-to-catch errors like while (c == curs.fetchone()): print c 3) "You quickly get used to it" 4) "Try rewriting your code to use __getitem__" For you specific example you really want to have something like: a) for c in curs: print c b) or maybe for c in curs.fetchall() c) or how about (warning: untested code ahead) class ForwardIterate: def __init__(self, callable): self._callable = callable self._i = 0 def __getitem__(self, n): assert(self._i == n) # probably being overly paranoid... self._i = self._i + 1 return callable() for c in ForwardIterate(curs.fetchone): print c 5) "Oh, and then there's Evan Simpson's PITA" http://www.dejanews.com/getdoc.xp?AN=429491196 6) "This has been discussed many times in the newsgroup before so stop the thread." In other words, searching DejaNews for the thread "Assignment in Conditional" I found 248 articles in it. Andrew Dalke "And hi to you Jeff!" dalke at bioreason.com From joe at strout.net Mon Apr 12 13:08:35 1999 From: joe at strout.net (Joe Strout) Date: Mon, 12 Apr 1999 10:08:35 -0700 Subject: simple indexed file module? Message-ID: For a CGI script I'm working on, I need to keep a couple of indexed files. These will contain variable-length data (descriptions), which may be changed fairly frequently. So I imagine that in addition to the data file, there will be an index file that keeps track of the position and length of each record. New or expanded records will be stuffed in wherever there is free space, or at the end if no sufficient free chunk is available. Is there already a module out there that does this? I know I could use some sort of SQL interface, but I don't want to take up space on my web site host for such a database engine. For this application, a little Python implementation should work fine (and besides, that way I can test it in the comfort of my Mac). Anybody have such a beast? Thanks, -- Joe -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From MHammond at skippinet.com.au Fri Apr 9 20:28:05 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 10 Apr 1999 10:28:05 +1000 Subject: Possible 1.5.2 bug References: <370E1DC7.BC2574B5@freemail.nl> Message-ID: <7em5tv$fkb$1@m2.c2.telstra-mm.net.au> Richard van de Stadt wrote in message <370E1DC7.BC2574B5 at freemail.nl>... >I just stick a picture of a face on my monitor and talk to >it to find bugs. Then my girlfriend would _definately_ leave me :-) Mark. From mlh at idt.ntnu.no Sun Apr 25 15:45:17 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 25 Apr 1999 21:45:17 +0200 Subject: Efficient List Subtraction References: <3720EF73.CA7DDEFF@Colorado.edu> Message-ID: "Steven D. Majewski" writes: > On Fri, 23 Apr 1999, KELLEY SCOTT T wrote: > > > > > Does anyone out there have a simple way to compare two lists (some operator perhaps) and > > return > > a list of *differences*? By differences, I mean the following: If had two > > lists like, [...] > > Well -- it's probably not the most efficient, but the simplest > list intersection is probably: OK... Posted an efficient version earlier -- now for the simple ones... (Assuming that there are no duplicates in the original lists...) > > >>> a = [1,4,5,100] > >>> b = [4,5] > >>> filter( lambda x: x in a, b ) > [4, 5] > >>> filter( lambda x: x in b, a ) # order doesn't matter > [4, 5] # for intersection > > # but it does for set-difference > >>> filter( lambda x: x not in a, b ) # b - a > [] > >>> filter( lambda x: x not in b, a ) # a - b > [1, 100] > > I don't think union or XOR can be done as concisely. Let's do union first: >>> a + filter(lambda x: x not in a, b) Then XOR: >>> filter(lambda x: x not in b, a) + filter(lambda x: x not in a, b) *If* we had an xor operator, we might say: >>> filter(lambda x: x in a xor x in b, a+b) Even though we don't, we might settle for: >>> filter(lambda x: (x in a and not (x in b)) or \ (x in b and not (x in a)), a+b) Or, actually: >>> filter(lambda x: not (x in a and x in b), a+b) Not too bad, is it? -- > Hi! I'm the signature virus 99! Magnus > Copy me into your signature and join the fun! Lie Hetland http://arcadia.laiv.org From zigron at jps.net Sat Apr 24 02:08:09 1999 From: zigron at jps.net (Zigron) Date: Fri, 23 Apr 1999 23:08:09 -0700 Subject: GUI other than Tkinter References: <3721567f.1748033@news> Message-ID: <3721d516@news1.jps.net> If you don't want to learn MFC (which is a headache!), there's wxPython, which i'm looking at now.. its very nice. :) Check the contributed download part of the python website... --Stephen wrote in message news:3721567f.1748033 at news... > Well, I've just about given up on EVER getting Tkinter to work on my > Win98 machine. Is there any other GUI module that I can get that > doesn't require TCL/TK to be installed on my machine? Isn't there > something called GD? > > Thanks, > Frustrated in Frisco..... From MHammond at skippinet.com.au Sat Apr 10 18:57:49 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sun, 11 Apr 1999 08:57:49 +1000 Subject: Python without registry entries References: <370fb711.28093946@news.demon.co.uk> Message-ID: <7eol16$1l2$1@m2.c2.telstra-mm.net.au> Paul Moore wrote in message <370fb711.28093946 at news.demon.co.uk>... >However, it would be nice to be able to run Python, at some level, >without *any* configuration changes (registry entries, environment >variables) at all. (Perl runs fine from a CD binary distribution, with >no registry settings). Can I do this? If so, what (if any) changes are >needed to the basic installed distribution? You can. Python does not _need_ the registry for anything. Python can build a default sys.path when it starts, so assuming your .py files are in a "standard" place (eg, a .\lib directory off you executable) no additional paths are needed. pywintypes and pythoncom do need special treatment without the registry. If you do a dejanews search, I posted some code that can load these 2 modules without the registry. Further, you can change a string in your compiled python15.dll, and you can ensure that it will not conflict with other versions of Python the user may already have... Ive packaged Python like this a number of times. Easiest way to go: Rename your Python registry key, then start Python.exe and print sys.path. Then work from that :-) Mark. From kiffney at my-dejanews.com Fri Apr 23 13:26:10 1999 From: kiffney at my-dejanews.com (Gustin Kiffney) Date: Fri, 23 Apr 1999 17:26:10 GMT Subject: pythonwin/mapi crystal ball needed References: <7fnbks$ga1$1@nnrp1.dejanews.com> <7foapn$iij$1@m2.c2.telstra-mm.net.au> Message-ID: <7fqafc$7b3$1@nnrp1.dejanews.com> Thanks, your answer is in fact very helpful, since I don't know enough about MAPI yet to figure out which way to go (in terms of least effort). Perhaps when I'm done I can help w/ the python extensions - if I ever return alive! BTW, pythonwin is a very neat job. Someday I hope it will make VB go away ... "Mark Hammond" wrote: > Gustin Kiffney wrote in message <7fnbks$ga1$1 at nnrp1.dejanews.com>... > > >Anyway I've long put off learning much about MFC/COM/MAPI because > >it looked too hard, but now have to find a way to implement a MAPI > >service provider (an address book). I've looked at the MAPI stuff > >in the python win32all distribution and it looks pretty complete (anyway, > >it looks like lots of stuff that I don't understand yet is there). > > Unfortunately, Python can not do this. The MAPI support allows us to _use_ > MAPI objects, whereas implementing an Address Book provider requires you to > implement them. > > The only way to go this route is to enhance the MAPI support to be able to > do this. This would not be trivial - I would allow myself 1 week to do > this. However, as writing an Address Book provider is very hard, and lots > of code, I personally would probably still go this route - I think the week > invested would buy me time... > > Sorry I can't be more help, or give better news... > > Mark. > > -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From barry at scottbb.demon.co.uk Sun Apr 11 10:51:02 1999 From: barry at scottbb.demon.co.uk (Barry Scott) Date: Sun, 11 Apr 1999 15:51:02 +0100 Subject: 1.5.2c1 will not compile on Windows NT SP4 with VC++ 6.0 SP1 References: <923765974.19722.0.nnrp-03.9e982a40@news.demon.co.uk> <000001be83b4$65c95d80$7fa22299@tim> Message-ID: <923842373.6258.0.nnrp-10.9e982a40@news.demon.co.uk> Yep I saw and mis understood that redirect to pcbuild. I suggest in mail to Guido that vc40.mak is removed from the kit and that the top level readme point windows builders to the pcbuild dir. BArry From andrew at starmedia.net Fri Apr 16 11:57:57 1999 From: andrew at starmedia.net (Andrew Csillag) Date: Fri, 16 Apr 1999 15:57:57 GMT Subject: Bug with makesetup on FreeBSD Message-ID: <37175E05.4CF3C68@starmedia.net> makesetup in Python 1.5.1 and 1.5.2 bombs on lines in the Setup file that use backslash continuation to break a module spec across lines on FreeBSD. FreeBSD's /bin/sh is the culprit. It's read function doesn't continue reading a line if the last char is a backslash. For example: input being: somemodule somemodule.c \ -lsomelib doing a read line only gets the first line and makesetup barfs on line 154 with invalid word on \ (as opposed to bash (or other sh's) that get "somemodule somemodule.c -lsomelib" back from read). This patch to this works with both FreeBSD's sh and bash. What it does is this: While the last char of $line is a \, read another line and glue it to the original minus the \. *** makesetup Fri Apr 16 11:43:55 1999 --- makesetup Fri Apr 16 11:43:12 1999 *************** *** 104,107 **** --- 104,115 ---- while read line do + #to handle backslashes for sh's that don't automatically + #continue a read when the last char is a backslash + while echo $line | grep '\\$' > /dev/null + do + read extraline + line=`echo $line| sed s/.$//`$extraline + done + # Output DEFS in reverse order so first definition overrides case $line in Cheers, Drew Csillag -- "There are two major products that come out of Berkeley: LSD and UNIX. We don't believe this to be a coincidence." - Jeremy S. Anderson From news at dorb.com Sat Apr 3 15:43:36 1999 From: news at dorb.com (Darrell) Date: Sat, 3 Apr 1999 15:43:36 -0500 Subject: Rat sighting online References: <19990403170011.21264.rocketmail@web602.mail.yahoo.com> Message-ID: I created the struct.py module and got this error. Guess I'll wait for the next version of Jpython. JPython 1.0.3 on java1.1.4 Copyright 1997-1998 Corporation for National Research Initiatives >>> import sys >>> sys.path.append('d:\\python\\lib') >>> import graph Traceback (innermost last): File "", line 1, in ? File "D:\at\sched\.\graph.py", line 202, in ? File "D:\at\sched\.\graph.py", line 116, in __init__ File "D:\at\sched\.\graph.py", line 131, in do_layout TypeError: can't assign to this attribute in java instance: size From satyan at ppllc.com Fri Apr 30 12:53:59 1999 From: satyan at ppllc.com (Sunil Satyan) Date: Fri, 30 Apr 1999 12:53:59 -0400 Subject: CORBA IDL AND SCRIPTS Message-ID: <3729E026.D9D29B1@ppllc.com> Hi All, Hi. I was looking for someone to speak to regarding a few questions that I had about IDL. I would be glad if someone can aswer my question: a) Given that we are moving towards CORBA, we would like to specify all our interfaces ( all of them not necessarily pertaining to client/server) in IDL. i.e., the interfaces we specify must be capable of being used by CORBA (which is OK) AND be available in any scripting language - PERL, PYTHON, TCL etc. I recently evaluated an open system tool called SWIG (Simplfied Wrapper and Interface Generator) that allows one to define classes or C-functions in an interface file (with ANSI C/C++ syntax). After the SWIG generator is run on the interface, it outputs the bindings required for a particular target scripting language - tcl, python, perl, etc. These interface defined classes/functions are then directly available in the target scripting language. For instance, if example.i contained a function "int fact(int);" and example.c contained the implementation for the function, running SWIG on example.i will produce a wrapper file that, when built together with the implementation file, makes the function available in the target scripting language. Thats SWIG in a nutshell and fits well with our needs. Now, with CORBA's IDL in the picture, we are faced with defining client/server interfaces in CORBA specific IDL. But, we'd like to define ALL interfaces - be it scripting languare interfaces, CORBA interfaces - in ONE type of IDL and generate either a) Scriping language bindings or b) CORBA client/server bindings. This allows for consistency in interface definition even for disparate usage of these interfaces. My question is: Is there any support for generating Scripting language bindings from CORBA IDL or a translator (less preferable) that can translate from CORBA IDL to a scripting language IDL ?? I realize that I may have to direct these questions to the appropriate CORBA implementation Vendor. But, I figured I would turn turn here for any suggestions! Thanks a million! Sunil . satyan at ppllc.com From crowland at cisco.com Mon Apr 5 13:17:35 1999 From: crowland at cisco.com (Craig H. Rowland) Date: Mon, 5 Apr 1999 12:17:35 -0500 Subject: SNMPy update References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> Message-ID: <7ear25$ksf$1@news-sj-3.cisco.com> A co-worker has written an SNMP library *entirely* in Python. It works on every platform Python runs under (well, we haven't tried every platform, but it does work under Unix and Windows). Unfortunately it can't be released publicly. I only say this because it *is* possible to write an SNMP client in 100% Python and this is a much better solution IMHO than using a Python wrapper around C based libraries that aren't very portable such as the current SNMPY solution. Conflict of interest issues keep us from releasing the code, but I'm sure anyone interested in taking up the project (which isn't difficult, it is just tedious how SNMP does things) can get questions answered by the author which should make things much easier. If you are interested in doing this let me know and I'll give you his e-mail address. -- Craig > SNMPy interests quite a few people. I've reluctantly > concluded that I can't be much of a leader in its near- > term future; all I can afford for now is to report the > little I know, and give a few personal suggestions on > what we might do next. > > Thanks to the generosity of a correspondent, I can offer > , > from last fall. I'd happily host more documents; what I > think is healthiest for all, though, is that one of us > organize an SNMP SIG, > and immediately put up a few informative pages at > python.org. > From MHammond at skippinet.com.au Mon Apr 5 19:45:04 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Tue, 6 Apr 1999 09:45:04 +1000 Subject: win32pipe.popen2 file objects: How to use advanced operations? References: Message-ID: <7ebhtj$a3l$1@m2.c2.telstra-mm.net.au> Milton L. Hankins wrote in message ... >I'm trying to use win32pipe.popen2(). > >I'd like to be able to set the buffer size of one or more of the file >objects returned by it. How does one do this? Im not sure? >Also, how does one perform a non-blocking read or write on such a file >object? Im pretty sure you can't. To have this level of control, you probably need to emulate win32popen yourself - ie, use win32process.CreateProcess, etc. Then you can use win32file.CreateFile to perform overlapped IO to perform the non-blocking reads. This isnt covered in detail by the win32 extensions help files - all the functions you need to use are covered, but for the specific techniques of how to use overlapped IO you must use the windows documentation. Mark. From aahz at netcom.com Mon Apr 26 17:22:24 1999 From: aahz at netcom.com (Aahz Maruch) Date: Mon, 26 Apr 1999 21:22:24 GMT Subject: converting perl to python - simple questions. References: <7fvagp$8lm$1@nnrp1.dejanews.com> Message-ID: In article , Chad McDaniel wrote: >aahz at netcom.com (Aahz Maruch) writes: >> In article <7fvagp$8lm$1 at nnrp1.dejanews.com>, >> wrote: >>> >>>a) Perl's "defined". >>> [perl] >>> if (defined($x{$token}) >>> >>> [python] >>> if (x.has_key(token) and x[token]!=None) : >> >> That looks correct. Thankfully Python does have short-circuit >> evaluation. Note that if you normally expect x[token] to have a value, >> you might restructure the code a bit to use try/except. > >wouldn't x.get() work more elegantly: >--- >if (x.get(token)) : > [do stuff] Yup. I keep forgetting about that one. Note that (cf recent thread) "if ( not x.get(token) is None ) :" is faster in many cases. -- --- Aahz (@netcom.com) Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Hi! I'm a beta for SigVirus 2000! Copy me into your .sigfile! From phd at sun.med.ru Sun Apr 11 09:41:34 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Sun, 11 Apr 1999 13:41:34 GMT Subject: Processing time In-Reply-To: <37109636.1FF246CB@xs4all.nl> References: <37109636.1FF246CB@xs4all.nl> Message-ID: Hi! On Sun, 11 Apr 1999, Frank de Bot wrote: > How can I get the Processing time of a script? from time import time start_time = time() Do_Processing() end_time = time() print "The program spents", end_time - start_time, "seconds" Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From trashcan at david-steuber.com Fri Apr 30 17:47:18 1999 From: trashcan at david-steuber.com (David Steuber) Date: 30 Apr 1999 17:47:18 -0400 Subject: Designing Large Systems with Python References: <372599D6.C156C996@pop.vet.uu.nl> <7g4a3l$atk$1@news.worldonline.nl> Message-ID: Alex writes: -> Is this the sort of thing you want? -> -> Try C-c ! to create a python shell, C-c C-c to evaluate a buffer in that -> shell, or C-c | to evaluate a marked region. Then you can execute -> commands interactively in that shell. Yes! It looks like I need to pay more attention in Python mode to see what options are made available to me. -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. Ask not for whom the telephone bell tolls ... if thou art in the bathtub, it tolls for thee. From spamfranke at bigfoot.de Mon Apr 19 10:55:52 1999 From: spamfranke at bigfoot.de (Stefan Franke) Date: Mon, 19 Apr 1999 14:55:52 GMT Subject: How to add data in a existant file ? References: <7fepse$pff$1@nnrp1.dejanews.com> Message-ID: <371b4310.32549353@news.omnilink.de> Use the "a" mode for appending. The complete documentation of the open() function can be found in the Library Reference: http://www.python.org/doc/lib/built-in-funcs.html#l2h-213 Regards, Stefan On Mon, 19 Apr 1999 08:35:26 GMT, kiket at my-dejanews.com wrote: >Hi, > >I use python to developp a script and I want to know which is the fonction >that permit to add data in a existant file. I know already how to write data >in a new file -----> f=open('file.name','w') f.write('data') f.close() > >But how to merge data in a existant file ? > >Mail your response to fquiquet at lemel.fr >Thank's a lot for your help. > >-----------== Posted via Deja News, The Discussion Network ==---------- >http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From MHammond at skippinet.com.au Wed Apr 21 06:22:09 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 21 Apr 1999 20:22:09 +1000 Subject: permissions on win32 [Q] References: <001201be8ba6$f2f706e0$6eba0ac8@kuarajy.infosys.com.ar> Message-ID: <7fk8r0$7ng$1@m2.c2.telstra-mm.net.au> NT security is a bit of a black art. Build 124 has win32security.SetFileSecurity(). The next question will be how to create a security descriptor - here is some sample code. [Oh damn - just realised that pywintypes.SECURITY_DESCRIPTOR() doesnt actually exist in 124 - it will in 125. sorry - you will probably get stuck here... But Ill still post it as reference for build 125 and later] Mark. def CreateSD(userName): sd = pywintypes.SECURITY_DESCRIPTOR() sidUser = win32security.LookupAccountName(None,userName)[0] sidCreator = pywintypes.SID() sidCreator.Initialize(ntsecuritycon.SECURITY_CREATOR_SID_AUTHORITY,1) sidCreator.SetSubAuthority(0, ntsecuritycon.SECURITY_CREATOR_OWNER_RID) acl = pywintypes.ACL() acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidUser) acl.AddAccessAllowedAce(win32file.FILE_ALL_ACCESS, sidCreator) sd.SetSecurityDescriptorDacl(1, acl, 0) return sd Bruno Mattarollo wrote in message <001201be8ba6$f2f706e0$6eba0ac8 at kuarajy.infosys.com.ar>... >Hi! > > I have to do a little script for a customer that will copy files from an NT >server to another. I need to change the permissions on those files and >directories. I mean, I need to give privileges to groups like >Administrators, the user that owns the files (changes from file to file) and >other special groups. Anyone knows how to do this with Python? We have the >following env: NT4SP4, Python 1.5.1, Win32All 124 ... the lastest one. I >have already done the script that copies the files, I just need to know how >to set this permissions. > > TIA > >/B > >Bruno Mattarollo >... proud to be a PSA member > From bernhard at alpha1.csd.uwm.edu Fri Apr 30 00:26:34 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 30 Apr 1999 04:26:34 GMT Subject: win32com function<->propterty problem Message-ID: Controlling SPSS for windows with python here, I run into the following problem: My OLE object an instance of ISpssDataCells should have an array as property. From the SPSS documentation: ValueAt Property Returns or sets the value of the current data cell or row/column label. Syntax object.ValueAt (row,column) [=value] Settings row Row index (Long) column Column index (Long) value Variant (String or Binary) Python win32com provides that as a function. And I can perfectly get the values like value=object.ValueAt(1,1) but setting ist a problem: >>> d >>> d.ValueAt >>> d.ValueAt(1,1) >>> d.ValueAt(1,1)=123 Error pulling apart exceptionTraceback (innermost last): File "C:\Python\Pythonwin\pywin\framework\interact.py", line 345, in keyhandler_enter message, (filename, lineno, offset, text) = exc_value ValueError: unpack sequence of wrong size SyntaxError: can't assign to function call The Python Com Browser shows me, that there are two entries in the Registered Spss Pivot Table Type Library, ISpssDataCells as function: ValueAt - Function Dispatch ID=26 Named Params ='row,col' Return Type ='Variant' Argument = 'Integer 4 (Flags=1)' Argument = 'Integer 4(Flags=1)' Function Kind ='Dispatch' Invoke Kind = 'Property Get' Number Optimal Params=0 ValueAt - Function Dispatch ID=26 Named Params ='row,col' Return Type ='Void' Argument = 'Integer 4 (Flags=1)' Argument = 'Integer 4(Flags=1)' Argument = 'Variant (Flags=1)' Function Kind ='Dispatch' Invoke Kind = 'Property Put' Number Optimal Params=0 Okay, python seems to know about both possibilities, but how do I use them? advaTHANKnce Bernhard From planders at mail.utexas.edu Sat Apr 24 13:15:39 1999 From: planders at mail.utexas.edu (Preston Landers) Date: 24 Apr 1999 12:15:39 -0500 Subject: controling a Python daemon with mail References: <84k8v3t4sw.fsf@mail.utexas.edu> Message-ID: <84wvz2szwk.fsf@mail.utexas.edu> "Steven D. Majewski" writes: > Yeah -- mailbox and rfc822 aren't the prettiest modules in the Python > libraries! Here's where the class browser in the Mac Python IDE comes > in handy, along with some interactive snooping. Thank you! Your message was most helpful. Unlike a snotty reply I recieved in email that just said "You didn't read the docs." > Thus you don't have to check the spool periodically -- the program > gets triggered as part of the mail delivery. There are unix programs > like procmail & filter that already do this. ( and procmail has Yeah, I considered this. I actually use fetchmail & procmail for my day to day email. It does have advantages, particularly like you describe ... the script isn't running continuously but is invoked for each message. > Or, you can use procmail to selectively send particular messages to > another script. Right, right. I'd want some kind of validation on who's allowed to send messages to this script. > You might also want to look a Mailman -- which is a mailing list > manager written in Python. It may already have most of the tools > you need for your responder. I only glanced briefly at that package but I may go back and look at it again more carefully. At the time, it seemed like overkill. In fact, since my needs aren't very complicated, and I already know a bit about procmail, I may just go with that. Once again, your message was quite helpful and pointed me in the right direction. Thanks a lot!!!! --Preston From ivanlan at callware.com Tue Apr 27 11:25:30 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 27 Apr 1999 15:25:30 GMT Subject: help References: <19990426163014.B20207@toast.internal> <3724D1C3.8BFA2C5B@pop.vet.uu.nl> <3724DEFC.A01E93C2@callware.com> <37257B0A.AF4C8E4C@pop.vet.uu.nl> Message-ID: <3725D6EA.E2DFB853@callware.com> Pythonistas-- Martijn Faassen wrote: > [snip] > Yeah, that happened to me for a while - I had to cut down drastically on > the use of the word 'Python'. :) So *do* they use Python over there? I > mean, now that they all know they should? > Ha. No. I'm sure that they just think of me as that nut in the corner. ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From barry at scottbb.demon.co.uk Fri Apr 23 17:29:58 1999 From: barry at scottbb.demon.co.uk (Barry Scott) Date: Fri, 23 Apr 1999 22:29:58 +0100 Subject: Windows install has problems. Guido asked that I use this newsgroup to discus further References: <924039873.18221.0.nnrp-12.9e982a40@news.demon.co.uk> <924040766.18823.0.nnrp-12.9e982a40@news.demon.co.uk> <371FAE0F.43B33158@siosistemi.it> Message-ID: <924903282.24080.0.nnrp-10.9e982a40@news.demon.co.uk> Mauro Cicognini wrote in message news:371FAE0F.43B33158 at siosistemi.it... > Mmm, since I'm not an English-language OS user, I'd rather see that as > %programfolder%\tcl\bin\tcl80.dll (I don't remember exactly, but I'm sure there > is a way to refer in a language-independent way to the folder that the US > version calls "Program Files" since we use it in our installations. Its in the registry - but python cannot access the registry. So this hack would not work for none english systems. > We use Mark Hammond's extensions and have no problem at all in fetching things > from the registry. Might just ask him and fold in the registry-access stuff. Mark's nice extensions are not in the base kit so cannot be used to solve problems requiring registry access. I think its important that python without add on's can access the registry under Windows. It is a fundamental requirement on Windows. BArry From mso at oz.net Tue Apr 13 10:26:20 1999 From: mso at oz.net (Mike Orr) Date: 13 Apr 1999 09:26:20 -0500 Subject: README: Python-URL! - the weekly guide to Python resources (Apr 13) Message-ID: <7evk6c$k6d$1@Starbase.NeoSoft.COM> Subject: README: Python-URL! guide to Python resources (Apr 10 1999) Python-URL is still alive and well, although it will be coming out only once or twice a month until we have the resources to return to a weekly schedule. If anyone wishes to be weekly editor for a month, contact Cameron . ** ANY URL STARTING WITH "http://search.dejanews.com/msgid.xp?MID=", ENDS IN "%3e" **, even if it appears split into two lines on your screen. --------------- Python 1.5.2c1 (gamma) released April 8. Guido hopes to have the final 1.5.2 out April 13. http://www.python.org/1.5 --------------- Python Topic Guides are *THE* place to get an overview on alternatives are available re web programming, database connectivity, XML and scientific computing in Python. http://www.python.org/topics/ --------------- Numerical Python documentation and tutorial. http://xfiles.llnl.gov ftp://ftp-icf.llnl.gov/pub/python/README.html --------------- KOffice uses Python as an extension language for creating spreadsheet functions. (requires KDE) http://search.dejanews.com/msgid.xp?MID=%3cmt2.0-4385-922320483%40news.informatik.uni-bonn.de%3e http://www.mieterra.com/article/koffice.html http://koffice.kde.org/ --------------- Cooledit 3.9.0 is a text editor with an embedded Python interpreter. (requires X-windows) http://search.dejanews.com/msgid.xp?MID=%3cmt2.0-3341-922315351%40news.informatik.uni-bonn.de%3e ftp://metalab.unc.edu/pub/Linux/apps/editors/X/ http://www.netins.net/showcase/Comput-IT/cooledit/src/ --------------- Python's source code for the unreleased versions are now available on CVS. http://www.python.org/download/cvs.html --------------- Stathosts 1.5 graphically displays on a webpage the status of your servers. http://www.nerv-un.net/projects/ ftp://ftp.nerv-un.net/pub/source/stathosts-1.5.tar.gz --------------- libretto is a shell script to print the Python documentation (or other Postscript files) while killing the fewest number of trees. (requires a UNIX-like system) http://search.dejanews.com/msgid.xp?MID=%3c370cfb74.23483%40194.247.160.50%3e --------------- Humor re a chip in the Netherlands that runs native Python. NOT. http://search.dejanews.com/msgid.xp?MID=%3c3703C591.FE65E94D%40pop.vet.uu.nl --------------- "Embed this!" Demonstration of a webserver smaller than a matchbox. Anybody want to get Python running on it? http://search.dejanews.com/msgid.xp?MID=%3c3703CF56.60DAFCD7%40yahoo.com%3e http://wearables.stanford.edu/ --------------- Grail 0.6 is a web browser written in Python which runs Python applets. It is now orphaned. It will take a lot of work to bring it up to Netscape 4.5 standards. Does anybody wish to step up and maintain it? http://search.dejanews.com/msgid.xp?MID=%3c14084.3974.729389.832651%40weyr.cnri.reston.va.us%3e http://grail.cnri.reston.va.us/grail/ --------------- SNMPy and other SNMP clients written in Python. Choose the "thread" link to see all the messages. Subject: SNMPy update. http://search.dejanews.com/msgid.xp?MID=%3c7e1hiq%24a71%241%40Starbase.NeoSoft.COM%3e -- ========================================================================= 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 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 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 (once we resume), ask to subscribe. -- The Python-URL! Team-- -Mike Orr, mso at jimpick.com -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From arcege at shore.net Fri Apr 30 16:36:37 1999 From: arcege at shore.net (Michael P. Reilly) Date: Fri, 30 Apr 1999 20:36:37 GMT Subject: Extension Doc bug References: <14120.52559.376120.364972@weyr.cnri.reston.va.us> Message-ID: Michael P. Reilly wrote: : Fred L. Drake wrote: : : Michael P. Reilly writes: : : > I just spent the morning trying to find a very obscure bug related to : : > the passing keyword arguments to a builtin method/function. : : Michael, : : You didn't post your original code that exhibited the bug, so I : : can't be sure of my conclusions. If you can send source for enough of : : your extension module that someone can compile it, that would be : : helpful. : : My first inclination, however, is that you passed in illegal : : arguments to PyArg_ParseTupleAndKeywords(). Passing NULL for the : : keywords dictionary is allowed; I've been looking at the : : implementation and don't see a way for that to be a problem (but I : : might have missed something). Some additional information: the exc_value that I got was 'bad argument to internal function' which is set by PyErr_BadInternalCall(). The only location inside the calling routines for this exception to be raised is inside ceval.c:call_function() (true for 1.5.1 and 1.5.2): if (kw != NULL && !PyDict_Check(kw)) { PyErr_BadInternalCall(); return NULL; } Hopefully, I will be able to recreate and debug this further this weekend. -Arcege From catlee at globalserve.net Fri Apr 23 03:53:05 1999 From: catlee at globalserve.net (Chris AtLee) Date: Fri, 23 Apr 1999 03:53:05 -0400 Subject: stdout in a restricted environment References: <7fn3rs$1v9$1@whisper.globalserve.net> Message-ID: <7fp92n$9fb$1@whisper.globalserve.net> Michael P. Reilly wrote in message news:MXET2.15$7j4.3896 at news.shore.net... ... > I would suggest making a subclass of RExec that redefines the > make_delegate_files method. > > def __init__(self, socket, hooks = None, verbose = 0): > RExec.__init__(self, hooks=hooks, verbose=verbose) > self._data_socket = socket > > def make_delegate_files(self): > reader = self._data_socket.makefile('r') > writer = self._data_socket.makefile('w') > s = self.modules['sys'] > self.delegate_stdin = FileDelegate(s, 'stdin') > self.delegate_stdout = FileDelegate(s, 'stdout') > self.delegate_stderr = FileDelegate(s, 'stderr') > self.restricted_stdin = FileWrapper(reader) > self.restricted_stdout = FileWrapper(writer) > self.restricted_stderr = FileWrapper(writer) > > Granted, I haven't tried this, but it looks correct. :) This works, after I put in some code to flush the writer when something happens...I think I may have had a working solution before but never knew it because my output wasn't getting flushed :) Cheers, Chris From olipt at mayo.edu Tue Apr 27 03:45:58 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Tue, 27 Apr 1999 02:45:58 -0500 Subject: sharing variables in fortran In-Reply-To: <3725643A.734B9F06@crystal.uwa.edu.au> References: <3725643A.734B9F06@crystal.uwa.edu.au> Message-ID: > I am wondering if it is possible to coerce python to use > memory addresses corresponding to a fortran common block (by way of a c > extension) > for storage of certain variables. Yes, but you won't find a ton of information about it. Be prepared to experiment a little. I would suggest using the Numeric module with it's C-API. There is an exported function you can call from C called PyArray_FromDimsAndData that creates a NumPy array from some dimension information and a pointer to already allocated memory. There is some improving documentation on the C-API to Numeric in the documentation recently released for NumPy. See the scientific computing topic section of www.python.org I'm not sure how to access a Fortran common block from C at the moment. Have you heard about the PyOpenGL interface? Good luck. Travis From bill_seitz at my-dejanews.com Thu Apr 15 19:02:18 1999 From: bill_seitz at my-dejanews.com (bill_seitz at my-dejanews.com) Date: Thu, 15 Apr 1999 23:02:18 GMT Subject: stupid Win-CGI getting started question References: <7f0f0h$pfb$1@nnrp1.dejanews.com> Message-ID: <7f5r5l$dh2$1@nnrp1.dejanews.com> I gave up, installed Apache, and got it (and the .py CGI) running in 10 minutes. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From eric at linux-hw.com Tue Apr 13 14:05:08 1999 From: eric at linux-hw.com (Eric Lee Green) Date: 13 Apr 1999 18:05:08 GMT Subject: threads Message-ID: <80BFA4D02E598C65.76C7CFE2D53BC9F1.ECCA6CF6DE46FB03@library-proxy.airnews.net> I am working on a program that has a) a main thread that accepts incoming socket connections, and b) an array of threads, each of which sucks on a Queue to get its socket/address pair and which sets a flag and goes back to sucking when it's finished processing. I.e., a permenant set of threads each sucking on its own queue waiting for incoming connections, rather than the temporary threads supported by the default SocketServer class. (I do superclass the SocketServer class though -- __init__ and handle_request were the only two methods I had to override! Though I added a couple more methods to deal with allocating and starting threads). The only thing that is worrying me is the state of the Python threads implementation under Linux libc6 (GNU libc). I keep having nightmarish thoughts about what happens if the process scheduler kicks a thread out and another one in halfway through Python's internal 'guts' updating an object in the internal object depository, thereby corrupting things badly. So: 1) do I have to set a semaphor on ALL data structures that are altered? For example, a slave thread sets a flag in an array to let the master know that it's available, then goes and starts sucking on the Queue for its next job. When the master sends it a new job on the Queue, the master clears the flag first so that it knows that this thread is no longer available (until the thread sets the flag later signalling otherwise, right?). What happens if the process scheduler kicks in halfway through setting that flag?! Do I get data corruption? (In "C" all that happens is that the master thread doesn't see the flag being set until the next time through, no big deal). My question is this: How "atomic" are basic Python variable operations? I understand about protecting transactions upon variables with semaphors (thus if I want to add 5 to a counter accessible from other threads, I want to semaphor it so that another thread adding 5 to that counter can't "lose" its addition due to a change of context). The question is whether the Python object depository is protected. 2) Any other "gotchas" that I need to be worrying about? Other than the obvious ones that go with any multi-threaded program in any language? I must say that this program is turning out to be a lot easier than I expected, other than my concerns above. The core classes take up barely two pages of printout! I'd still be working on the first class if I'd tried doing it in C++. The most interesting thing is that this looks like it will turn out to be the fastest way of doing this kind of server on Linux. The aio_ (asynchronous I/O) approach doesn't have as great of performance on Linux (since Linux does not yet support the aio_ system calls, the libc6 library spawns off an entire thread for each asynchronous operation -- and spawning threads is a lot more time consuming than sending a message to an already-existing thread). Not to mention that since I'm not serving files with this server, the aio_ approach wouldn't work anyhow. The only real problems are the same ones that face Medusa on Linux -- the fact that Linux, like most Unixes, has a low per-process file handle limit. -- Eric Lee Green eric at linux-hw.com http://www.linux-hw.com/~eric Defend the 2nd Amendment. Fight for the right to arm bears. From R.Hooft at EuroMail.com Mon Apr 26 02:57:10 1999 From: R.Hooft at EuroMail.com (Rob Hooft) Date: 26 Apr 1999 08:57:10 +0200 Subject: wrapped around the axle on regexpressions and file searching References: <7frhe0$8g1$1@nnrp1.dejanews.com> Message-ID: >>>>> "m" == msrisney writes: m> here are my questions: 1. this prints out not only files with the m> file extensions ".log" but also any file name that has "log" in m> it's name. how would I rewrite to avoid?? How about using "fnmatch.fnmatch" instead of a regular expression? -- ===== R.Hooft at EuroMail.net http://www.xs4all.nl/~hooft/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From e9025657 at stud3.tuwien.ac.at Sun Apr 25 14:35:42 1999 From: e9025657 at stud3.tuwien.ac.at (Kaweh Kazemi) Date: Sun, 25 Apr 1999 18:35:42 GMT Subject: GUI other than Tkinter References: <3721567f.1748033@news> Message-ID: <372360df.5406764@news.teleweb.at> >As far as I know, GTk has not been ported to the Win32 platform, yet. thats not correct. have a look at http://user.sgic.fi/~tml/gimp/win32/ kaweh From zorro at zipzap.ch Mon Apr 19 03:34:36 1999 From: zorro at zipzap.ch (Boris Borcic) Date: Mon, 19 Apr 1999 09:34:36 +0200 Subject: IDLE ! Message-ID: <371ADC8C.54C4CDBE@zipzap.ch> I am having my first look at 1.5.2 and IDLE (on Win95). Very nice. Thank you (once again), Guido. Boris Borcic From godzilla at netmeg.net Mon Apr 12 11:43:35 1999 From: godzilla at netmeg.net (Les Schaffer) Date: Mon, 12 Apr 1999 15:43:35 GMT Subject: Python without registry entries References: <370fb711.28093946@news.demon.co.uk> <7eol16$1l2$1@m2.c2.telstra-mm.net.au> Message-ID: <37121820.3758204@news.netmeg.net> On Sun, 11 Apr 1999 08:57:49 +1000, "Mark Hammond" wrote: >You can. Python does not _need_ the registry for anything. a followup question: I just switched over our windows machine to NT from win98, and did a clean install so the registry is fresh spanking new... is there some way to restore the registry settings for python and the win32 extensions without downloading the whole darn thing again? pythonwin doesnt run right now because win32ui.pyd is not found. in lieu of remaking the registry entries are there a handful of env. variables that can be set to keep python humming along? in other words, since i come from linux and know about the env variables there, does ALL one need to do on windows is have the appropriate env. variables set, or is there something more to the slew of registry entries i see were made from the original install logs for python 1.5.2c and win32 extensions. said differently, if one doesnt need the registry entries for anything pythonic, why are there these whole slew of entries made when its installed? thanks les schaffer From hyoon at bigfoot.com Fri Apr 16 14:16:39 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Fri, 16 Apr 1999 14:16:39 -0400 Subject: Python slowness on NT. Message-ID: <37177E87.D9F7179@bigfoot.com> Hi, Post install of 1.5.2 into my computer. The python interpreter seems a lot slow to execute/compile programs. Simple Tkinter._test() takes good 5+ sec get anywhere. I do have to admit that I am running alot of Realtime pricing stuff on my PC. Anyway to make Python gain more attention from CPU? TIA, -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From jkraai at murl.com Wed Apr 21 11:02:52 1999 From: jkraai at murl.com (jkraai at murl.com) Date: Wed, 21 Apr 1999 15:02:52 GMT Subject: HTTP-NG Support? Message-ID: <002201be8c08$1969e570$8b7125a6@cpda6686.mcit.com> Been looking over http-ng ( http://www.w3.org/HTTP-NG/ ) for the last couple of days. Wondering if anything has been done via Python. Of course, this looks like a job for Zope ... Opinions? --jim From basv at sara.nl Mon Apr 26 11:38:33 1999 From: basv at sara.nl (basv at sara.nl) Date: Mon, 26 Apr 1999 15:38:33 GMT Subject: Trouble with httplib and IRIX Message-ID: <7g219p$hvb$1@nnrp1.dejanews.com> Hello, I'm running python 1.5.2 and running it on IRIX 6.5.3 systems. I have the following problem when i'm trying to connect to an non-existing machine the program hangs forever. When i kill ,restart and run it again, it gives an error message that it couldn't find the host. This is the behaviour that i would expect the first time. My question is does somebody else have encounter the same problems on a IRIX machine? -------------------- Python programm ------------------------ #!/usr/local/bin/python import socket import httplib def main(): h = httplib.HTTP() h.set_debuglevel(100) try: h.connect("www.nsrc.nus.sg") except socket.error, detail: print 'Connect failed: %s' %detail main() -- ******************************************************************** * * * Bas van der Vlies e-mail: basv at sara.nl * * SARA - Academic Computing Services phone: +31 20 592 8012 * * Kruislaan 415 fax: +31 20 6683167 * * 1098 SJ Amsterdam * * * ******************************************************************** -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From fpinel at fedex.com Thu Apr 15 23:48:49 1999 From: fpinel at fedex.com (frederic pinel) Date: Fri, 16 Apr 1999 05:48:49 +0200 Subject: Novice Question: two lists -> dictionary References: <7f3j1v$f6j$1@nnrp1.dejanews.com> Message-ID: <3716B321.A0652382@fedex.com> Here is a quick and dirty answer! Sorry... ListA = ['10', '10', '20', '20', '20', '24'] ListB = ['23', '44', '11', '19', '57', '3'] ListT = [] # temporary list Dict = {} for i in range(len(ListA)): ListT = key_values(i, ListA, ListB) if (Dict.has_key(ListT[0]) == 0): Dict[ListT[0]] = ListT[1:] print Dict # print results, for test purposes. def key_values(i, l_key, l_val): " returns a list with the first item being the l_key[i] (ListA), " and the values after for that key (ListB) resultat = [] for j in range(len(l_key)): if (l_key[j] == l_key[i]): result[0] = l_key[i] result.append(l_val[j]) return result regards, frederic jwtozer at my-dejanews.com wrote: > > How do I make the members of one list the key of a dictionary and the members > of a second list the members of list values associated with with those keys? > > Given: > > ListA = ['10', '10', '20', '20', '20', '24'] > ListB = ['23', '44', '11', '19', '57', '3'] > > Desired Result: > > Dict = {'10': ['23','44'],'20': ['11','19','57'], '24': ['3']} > > Any help will be much appreciated. > > -----------== Posted via Deja News, The Discussion Network ==---------- > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From thooney at pk.highway.ne.jp Sun Apr 18 14:02:14 1999 From: thooney at pk.highway.ne.jp (Thooney Millennier) Date: Mon, 19 Apr 1999 03:02:14 +0900 Subject: what is reloc error ? Message-ID: <371A1E26.846AF8B6@pk.highway.ne.jp> Hello, everyone. I am now working on building Python interface to my C++ matrix library. I have a problem. After compiling and when trying to import my module I get following message. % gcc -c XXXtype.cc % gcc -c subXXXtype.cc ....................... % ld -o XXXtype.so -dy -G -g *.o -lstdc++ % python -c "import XXXtype" python: can't handle reloc type <====this!!! I don't understand why this occurs. Please help me! (Platform: python 1.5.2, Linux 2.0.34 with gcc.) Thooney Millennier. From vkolosov at unitedmedia.com Wed Apr 14 09:25:01 1999 From: vkolosov at unitedmedia.com (Kolosov, Victor) Date: Wed, 14 Apr 1999 13:25:01 GMT Subject: Windows install has problems. Guido asked that I use this new sgroup to discus further Message-ID: <461182F0B9B7D111B4000008C7282ADC22B048@nynt04.umny.scripps.com> > -----Original Message----- > From: Barry Scott [SMTP:barry at scottbb.demon.co.uk] > Sent: Tuesday, April 13, 1999 5:42 PM > To: python-list at cwi.nl > Subject: Windows install has problems. Guido asked that I use this > newsgroup to discus further > > THis is Guido's reply to my comments that tcl80.dll is not found > by IDLE on a default installation. > > > > > Running "IDLE (Python GUI)" reports that tcl80.dll is > > > > not in my path then the shell comes up and I can > > > > use Tkinter from the shell. > > I've got NT at home and had the same very message after installation of Tkinter. I know that nobody wants to full around with the registry and in your case you do not need to. Just go to Control Panels it has System control panel, open it. One of the tabs is environment and it has different parameters one of which is Path, click on it and in one of the two single line edits you can edit it, so just stick your - G:\Program Files\Tcl\bin\ - at the end of it, apply you change, log out/in and you'll be set. I hope you can figure the whole thing out, since I'm writing from my memory right now. Victor From liw at iki.fi Sun Apr 25 02:53:11 1999 From: liw at iki.fi (Lars Wirzenius) Date: 25 Apr 1999 06:53:11 GMT Subject: rfc822 date header References: <37136310.62A6BE1A@rubic.com> <7f07n7$7pqv$1@midnight.cs.hut.fi> Message-ID: <7fue4n$ekuj$1@midnight.cs.hut.fi> Lars Wirzenius : > Here's what I wrote for Slime (thhe mailer I'm writing): How embarrassing, the code I posted doesn't work. I'm pretty sure it did work, at some point in time, but either I misremember, or I broke it, or the stuff within rfc822 I use changed. Never mind, here is the new version: def _date_header(self): """Return Date header reflecting current time.""" # XXX this should probably communicate the local time zone # somehow t = time.gmtime(time.time()) return "Date: %s, %02d %s %04d %02d:%02d:%02d GMT\n" % \ (string.capitalize(rfc822._daynames[t[6]]), t[2], string.capitalize(rfc822._monthnames[t[1] - 1]), t[0], t[3], t[4], t[5]) From hniksic at srce.hr Tue Apr 13 06:21:27 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 13 Apr 1999 12:21:27 +0200 Subject: Python 1.5.2c1 -- What if long long not supported? References: <199904091521.LAA00858@eric.cnri.reston.va.us> Message-ID: <87hfqkx1lk.fsf@pc-hrvoje.srce.hr> Guido van Rossum writes: > I received a bug report that if the (unnamed) platform doesn't > support the "long long" type, the configure script dies. The logic > in configure.in looks correct to me and I don't have any such Unix > platforms handy myself... You can "create" such a platform by using `-pedantic-errors'. From tavares at connix.com Mon Apr 26 09:31:16 1999 From: tavares at connix.com (tavares at connix.com) Date: Mon, 26 Apr 1999 13:31:16 GMT Subject: Python and "Hand held" computers References: <318D8A1FC77AD211A3110080C83DFC6403139F@comsrv.sowatec.com> <7g1opt$9li$1@nnrp1.dejanews.com> Message-ID: <7g1pr5$an8$1@nnrp1.dejanews.com> In article <7g1opt$9li$1 at nnrp1.dejanews.com>, aaron_watters at my-dejanews.com wrote: > > > > What about Palm Pilot ? > > I think the answer still is "It should be possible, but in > practice the Palm Pilot doesn't have enough memory to make > it an interesting proposition, unless you upgrade it to non-standard > sizes." "It's worse than that, he's dead Jim!" Even if you do upgrade a pilot to have more RAM (the new Palm IIIx comes with 4 MB, and you can get an 8 MB upgrade), the Pilot OS's memory architecture is also a problem. Palm apps typically get a very small heap - 64k or less, if memory serves me correctly. The rest of RAM is accessed using the "database manager" functions, which chops RAM up into records defined by the app. This is very useful when writing an address book or shopping list program. It is significantly LESS useful when you're trying to implement an interpreter. I'm sure that this can be worked around (heck, someone's implemented Smalltalk on the pilot) but I suspect the amount of changes to the core Python sources would be significant enough to discourage the attempt. [ ...Remainder snipped... ] -Chris -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From kc5tja at bigfoot.com Mon Apr 5 15:15:17 1999 From: kc5tja at bigfoot.com (Samuel A. Falvo II) Date: Mon, 5 Apr 1999 12:15:17 -0700 Subject: Crappy Software was Re: [OffTopic: Netscape] Re: How should Python be evangelized? References: <7dos4m$usi$1@nnrp1.dejanews.com> <7dqs0h$lcq$1@nnrp1.dejanews.com> <2_6M2.30$Kj1.679@198.235.216.4> <37019F42.EA55CA8@kanga.org> <009d01be7b47$8a9a6020$f29b12c2@pythonware.com> <7dtmso$7u6$1@news.clarkson.edu> <3703ca33.9749737@news.bctel.ca> Message-ID: <37089dcb@fermi.armored.net> >Er, that'd be the same Netscape that has such broken CSS that it is >absolutely unuseable? While I understand that Netscape's CSS implementation is not the best, I have to take an opposing view as to it not being usable. Netscape's CSS is more than adequate for the vast majority of the web sites out there. They provide my web sites with a good, professional appearance under both Netscape and MSIE. >Myself, I prefer Opera; at least it meets standards. MSIE runs a close >second these days. Netscape is horrendously buggy. And Mozilla will decimate MSIE. The trick, of course, is them actually releasing it as a finished product. :-) However, when I actually see Opera for Linux, I'll be sure to give it a shot. I've used Opera for Windows, and was only mildly impressed. It was a blazingly fast web browser, but it didn't have the feature set that MSIE had at the time. A lot has changed since then, I know -- which is why I'm willing to give it another shot. As a matter of fact, I'll go an download the latest release right now... :-) (I'll be REALLY happy when they port Opera to AmigaOS 5.) From gmcm at hypernet.com Mon Apr 12 20:34:47 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 13 Apr 1999 00:34:47 GMT Subject: how to use exec In-Reply-To: <7etm5o$bvm$1@nnrp1.dejanews.com> References: <7etm5o$bvm$1@nnrp1.dejanews.com> Message-ID: <1288158605-15845960@hypernet.com> Jaeho Lee asks: > Hi folks, I'm making test tools based on python. I want to test > script includes python script and test tools execute the command > dynamically. "exec" is good for this. But if exec runs assign > statement, it stores the variable in local area. I want to put the > variable in global area. How can I do this? I saw this in python > pocket reference. exec codestring [in globaldict [, localdict]] But > this syntax does not work. Could somebody let me know how to use > exec? Perhaps you are interpreting the "[" and "]" as literals, not as indicators that the enclosed is optional? exec codestring exec codestring in myglobals exec codestring in myglobals, mylocals - Gordon From kevin at cocreator.com Wed Apr 14 21:37:54 1999 From: kevin at cocreator.com (Kevin K. Ehmka) Date: Wed, 14 Apr 1999 21:37:54 -0400 Subject: PIL fonts - Where are you? Message-ID: <7jbR2.3071$YU1.5576@newsr2.twcny.rr.com> Does anybody have some ready made fonts in PIL format they want to share? A web site maybe? I was unsuccessful today creating any. Thanks -- Kevin From trajce at rsc.com.mk Tue Apr 6 23:00:37 1999 From: trajce at rsc.com.mk (Trajce) Date: Wed, 7 Apr 1999 03:00:37 GMT Subject: For list Message-ID: <370ACA53.DC922A74@rsc.com.mk> Please entires list. From rparra at abo.fi Wed Apr 28 09:30:31 1999 From: rparra at abo.fi (Raul Parra Bacete FS) Date: Wed, 28 Apr 1999 16:30:31 +0300 Subject: I need test my .py files again Message-ID: <37270D77.969235F0@abo.fi> Hi, I have ported the python interpreter to the sh1 hitachi, and now I would like to get .py programs to test my python interpreter... that programs should not have any import statment or any reference to files, so I need some BASIC .py programs to test my python interpreter, I know that in the sources of python, there is some test programs but i need a kind of test programs that doesn't use the IMPORT statment, and also complex, long, file, and float objects, so the python test programs doesn't help me. I wonder if you could give me any addres where I can get some of them or send me some of them by e-mail.... Thanks. Raul Parra Bacete ?bo Akademi rparra at abo.fi From bernhard at alpha1.csd.uwm.edu Sun Apr 18 21:45:07 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 19 Apr 1999 01:45:07 GMT Subject: NT: win32api and win32ui import error References: <7fbcpq$2jb$1@nnrp1.dejanews.com> <7fdgj4$nnl$1@nnrp1.dejanews.com> Message-ID: On Sun, 18 Apr 1999 20:50:45 GMT, hj_ka at my-dejanews.com wrote: >In article , > bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) wrote: >> Mark said, that the following dll and their versions might >> be relevant: >No luck. I downloaded some more recent versions of ole32.dll >and oleaut32.dll from http://solo.abac.com/dllarchive/, (their >msvcrt.dll is older, from VC5 instead of VC6). I also tried >those DLLs from my Windows 98 System folder. I tried many >combinations. Sad to hear. As we both got that problem with unregistered services when installing, I think somebody has to find out what that means. I certainly do not know much about this in Windows. Bernhard From dkuhlman at netcom.com Tue Apr 6 20:23:34 1999 From: dkuhlman at netcom.com (G. David Kuhlman) Date: Wed, 7 Apr 1999 00:23:34 GMT Subject: Chaning instance methods References: Message-ID: Is this what you are looking for? --------- # testchangemethod.py: class Test: def m(self): pass def m1(self): print 'I am Test.m1' def m2(self): print 'I am Test.m2' --------- >>> from testchangemethod import Test >>> >>> t = Test() >>> Test.m = Test.m1 >>> t.m() I am Test.m1 >>> Test.m = Test.m2 >>> t.m() I am Test.m2 -------- I don't understand this too well myself. However, note that if you evaluate 'type(Test.m1)' you get something different from what you get if your evaluate 'type(f)' where f is a function (not a method). - Dave Jody Winston wrote: > I don't understand how to change instance methods. For example: > class Foo: > def __init__(self): > self.data = 42 > def m(self): > print "Foo.m" > print dir(self) > def m2(self): > print "m2" > print dir(self) > f = Foo() > f.m() > # this fails > # f.m = m2 > # f.m() > Foo.m = m2 # Changes all instances of Foo.m > f.m() > f2 = Foo() > f2.m() > What am I forgetting? > -- > Jody Winston > Manager SeisRes > Lamont-Doherty Earth Observatory > RT 9W, Palisades, NY 10964 > jody at ldeo.columbia.edu, 914 365 8526, Fax 914 359 1631 > Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email > address may not be added to any commercial mail list with out my > permission. Violation of my privacy with advertising or SPAM will > result in a suit for a MINIMUM of $500 damages/incident, $1500 for > repeats. From tim_one at email.msn.com Sat Apr 24 00:42:21 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 24 Apr 1999 04:42:21 GMT Subject: help with os.popen() In-Reply-To: <7fomaj$oo9$1@nnrp1.dejanews.com> References: <7fomaj$oo9$1@nnrp1.dejanews.com> Message-ID: <000301be8e0c$d71ff4a0$f09e2299@tim> [cmedcoff at my-dejanews.com] > I'm new to python and need a bit of help with os.popen(). What > is wrong with the following? What am I doing wrong? (I'm running > 1.52 on WinNT 4.0) > > >>>import os > >>> p = os.popen("dir", "rt", 1024) > Traceback (innermost last): > File "", line 1, in ? > p = os.popen("dir", "rt", 1024) > OSError: (0, 'Error') > >>> [... and later] > Please disregard my post. I blew it. I found the answer in the FAQ. No you didn't . Seriously, the FAQ talks about PythonWin, but the "pyshell#4" above suggests you're running IDLE. Different beasts! popen is a nightmare under Windows regardless, and I doubt it will ever work without surprises. If you try e.g. f = os.popen("dir") in an interactive DOS-box Python, at least under Win95 it freezes the interpreter solid. Run it under the MS debugger to find out why, and it freezes the debugger solid too. The popen call returns without incident, but stdin and stdout are screwed up beyond recognition. This is related to "dir" being a command.com builtin, btw -- you don't get this problem if you popen a random .exe. OTOH, f = os.popen("dir"); lines = f.readlines() (all on one line) does work OK from a DOS-box Python. But not under IDLE or PythonWin. I'll figure this all out if I ever get a free year <0.7 wink>. pipes-break-windows-in-real-life-too-ly y'rs - tim From tville at earthlink.net Fri Apr 2 21:20:20 1999 From: tville at earthlink.net (G O Economou) Date: Fri, 02 Apr 1999 21:20:20 -0500 Subject: learning... References: Message-ID: <37057AE3.401F4943@earthlink.net> Costas -- www.python.org has most of what you need. They have lots of links & much to download. I have used it exclusively to learn and practice Python. Kali Anastasi Georgia "Constantinos A. Kotsokalis" wrote: > Dear all, > do you believe the python manuals (tutorial, too) are sufficient > for someone trying to learn python, or should I go out looking for > some book on it? In such case, which one do you suggest? > > Thanks, > Costas > > -- > Constantinos A. Kotsokalis || c.kotsokalis at noc.ntua.gr > National Technical University of Athens > Network Management Center > Tel. No: +30 01 7721861 From tim_one at email.msn.com Sun Apr 25 17:29:31 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 25 Apr 1999 17:29:31 -0400 Subject: help with os.popen() In-Reply-To: <87yajhxm52.fsf@psyche.evansnet> Message-ID: <000001be8f62$b5494f00$669e2299@tim> [Tim, wrt popen() on Win32] > I'll figure this all out if I ever get a free year <0.7 wink>. [Carey Evans] > Why bother? The Tcl people have done it already, I've had very few > problems with pipes there, and it's under a generous license. There's > some interesting comments in tclWinPipe.c and stub16.c too, and an > amazing number of special cases. > > I'd be eternally grateful[1] if pipes worked as well in Python as they > do in Tcl, although I suppose I could try rewriting tclWinPipe.c using > the Win32 extensions. Actually, it would be quite nice if I could > just get the return value from os.system() or os.spawnv() like I can > from Tcl's "exec". > > [1] I'd buy the author a drink if I met them, anyway. So, Carey, this particular problem bothers you, and you believe you know how to fix it. How about buying yourself a drink <0.9 wink>? After staring at the ~2,700 lines of Tcl source you referenced, my reaction remains "I'll figure this all out if I ever get a free year". Hip's original Perl-for-Win32 port shipped its own (non-interactive) 32-bit shell, so that Perl popen/backtick/system constructs stood some chance of working. The latest Perl-for-Win32 source appears to have dropped that, though, with scattered vague recommendations that you install your own non-brain-dead PERL5SHELL (4DOS/NT?). about-to-boost-it-to-two-years-ly y'rs - tim From roger.burnham at gte.net Tue Apr 13 16:16:07 1999 From: roger.burnham at gte.net (Roger Burnham) Date: Tue, 13 Apr 1999 20:16:07 GMT Subject: Using SioModule.zip under Win32 References: <7f06ds$hmb$1@nnrp1.dejanews.com> Message-ID: <7f07k6$88l$1@news-1.news.gte.net> On Tue, 13 Apr 1999 19:37:33 GMT, jwinkelman at my-dejanews.com wrote: >I have downloaded the SIO-151.ZIP to do some serial IO under Win32. > >Does anyone know if it can handle port numbers higher than COM9? > >I tried modifying the dictionary in the serial.py file to add constants for >COM10, etc., but when I load the module, I get a NameError for COM10. > >Being new to python, I'm not sure where to go from here. > >Any help is appreciated. > The DLL that Sio wraps, from MarshallSoft Computing, Inc. POB 4543 Huntsville AL 35815. 205-881-4630. Email: mike at marshallsoft.com www.marshallsoft.com only defines constants up to COM9, but they are simple integers. No idea if it will break anything in the WSC32.dll, but you could try: PythonWin 1.5.2b2 (#0, Mar 4 1999, 16:07:53) [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 Serial >>> cfg = Serial.PortDict() >>> cfg._dict['port'] = 9 # should be COM10... >>> fd = Serial.Port(cfg) >>> fd.open() Traceback (innermost last): File "", line 0, in ? File "Serial.py", line 343, in open self._chkSioExec(SioReset, (port, self._bufSize,self.cfg['txBufSize'])) File "Serial.py", line 326, in _chkSioExec raise SioError, '%s: %s' % (func.__name__, SioErrorText(status)) SioError: SioReset: No such port >>> 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 c.evans at clear.net.nz Mon Apr 26 06:05:22 1999 From: c.evans at clear.net.nz (Carey Evans) Date: 26 Apr 1999 22:05:22 +1200 Subject: help with os.popen() References: <000001be8f62$b5494f00$669e2299@tim> Message-ID: <87eml7y9wd.fsf@psyche.evansnet> "Tim Peters" writes: > So, Carey, this particular problem bothers you, and you believe you know how > to fix it. How about buying yourself a drink <0.9 wink>? > > After staring at the ~2,700 lines of Tcl source you referenced, my reaction > remains "I'll figure this all out if I ever get a free year". Umm, OK. I may have to think about it for a while, though. Python's requirements aren't as bad as Tcl's, so it might stand a chance of becoming a reality. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "Try explaining a syn-ack-fin-rst scan to a dialup provider abuse drone. You can almost hear the belt slip off the brain drive shaft." - Strange in asr From arcege at shore.net Fri Apr 23 17:35:05 1999 From: arcege at shore.net (Michael P. Reilly) Date: Fri, 23 Apr 1999 21:35:05 GMT Subject: Proposed Change for sys.exitfunc for version 1.6 References: <37209360.2FB8E145@collins.rockwell.com> Message-ID: Jonathan Polley wrote: : I would like to propose adding a function to the module 'sys' that would : change (slightly) the behavior of sys.exitfunc. I would like to add a : method that performs the same function as UNIX's 'atexit ()' function. : The reason is that I have some modules that would like to do some : cleanup when python terminates, but I don't want to have to add the code : required for them to remember the previous value of sys.exitfunc so they : can call that function (if present). A method sys.atexit () would work : nicely. It would allow me to add a series of exit functions and be : guaranteed that they would all be called at the termination of python : (so I can close files, purge queues, close sockets, etc.). Does anyone : else think this would be a good idea??? Files and sockets will be closed (and flushed), and if you have a queue it is problem an instance of a class and an appropriate __del__ method can be created. import os class LockFile: os_remove = os.remove # do not rely on os still existing def __del__(self): if self.locked: self.os_remove(self.file) Then if the os module is destroyed during exit clean-up, my class (and the instances) still have access to the functions it needs. There is little need in the object-oriented world to have atexit functionality. There used to be some race-condition problems with this as well (I explained one of them above). However, the C API does have the function Py_AtExit() which does this (C modules aren't quite the same as Python modules ;). But if you want to make a atexit callback subsystem: class SysAtExit: def __init__(self): self.callbacks = [] # the instance is callable itself def __call__(self, func): if callable(func): self.callbacks.append(func) else: raise TypeError, "not a callable" def on_exit(self): for func in self.callbacks: func() import sys sys.atexit = SysAtExit() sys.exitfunc = sys.atexit.on_exit del SysAtExit, sys Then in your own code, call: sys.atexit(my_func_to_call_at_exit) There is (almost) always a way. ;) -Arcege From news at dorb.com Thu Apr 22 20:16:51 1999 From: news at dorb.com (Darrell) Date: Thu, 22 Apr 1999 20:16:51 -0400 Subject: try vs. has_key() References: Message-ID: My experience shows that throwing an exception is slower. Aahz Maruch wrote in message news:aahzFAM4oJ.M7M at netcom.com... > I've seen roughly half the people here doing > > try: > dict[key].append(foo) > except: > dict[key]=[foo] > > with the other half doing > > if dict.has_key(key): > dict[key].append(foo) > else: > dict[key]=[foo] > > Can people explain their preferences? > -- > --- Aahz (@netcom.com) > > Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/ > Androgynous poly kinky vanilla queer het > > "You often don't really understand the problem until after the first > time you implement a solution." - Eric S. Raymond From piet at cs.uu.nl Tue Apr 20 11:18:38 1999 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 20 Apr 1999 17:18:38 +0200 Subject: Database search engine References: <7ferls$qrj$1@nnrp1.dejanews.com> Message-ID: >>>>> davidcuny at yahoo.fr (D) writes: D> Hello, D> I'm doing an Intranet Web site with a database (Apache, DB2 and NT). D> I'd like to realize a quite complex search engine on the database : D> - the user enters mutli keywords D> - there exists a table of non significant words D> - there exists a table of words that have meaning: "kind" and "sort" D> Where can I find an algorithm or, the best, Perl code for that kind of work? D> Is Perl the good tool to do that (Perl??,java)?? D> thanks Dr Dobbs had a couple of articles on this subject, I think in Jan and Feb this year. They also have downloadable code in Perl and Java, which you can use as a start. It would be nice if somebody translated it in Python (this last sentence is mainly to make this message on-topic :=) They use a btree (Berkeley DB 1.85) to store the index. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: Piet.van.Oostrum at gironet.nl From news at helen.demon.nl Thu Apr 29 04:21:54 1999 From: news at helen.demon.nl (Ilja Heitlager) Date: Thu, 29 Apr 1999 10:21:54 +0200 Subject: Designing Large Systems with Python References: <7g669p$aer$1@nnrp1.dejanews.com> Message-ID: <7g94b7$m31$1@news.worldonline.nl> >A good principle for this would be 'Design by Contract'. > >The ideal language for that IMHO would be Eiffel. >See http://www.eiffel.com/doc/manuals/language/intro/ >for an introduction by the inventor of the language, Bertrand Meyer >see also >http://www.eiffel-forum.org/ >and the links at http://www.elj.com/ DbC is a good idea anyway, but don't just use Eiffel to use the principle. Python has assertions and and there are some nice assertionpackages for Java (using preprocessors to insert/hide). In other words: assertions can be mimiced in (probably) every language Make your choice based on language constructs like modules or classes (for modularity and abstraction ---> large systems), script or system language (for fast code-debug cycles) and available packages. If speed is a problem most languages offer a C-escape. also check http://www.python.org/workshops/1997-10/proceedings/cunningham.html and guido's http://www.developer.com/journal/techfocus/081798_jpython.html for the Two-language approach (HYPE!) Anyway for large systems use something like OO language (Python and Java?), UML (or something) and a good IDE (love to see a class browser for Python), (re)use existing packages. Ilja From tim_one at email.msn.com Thu Apr 29 20:21:25 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 29 Apr 1999 20:21:25 -0400 Subject: string.atoi('-') In-Reply-To: <372894B5.78F68430@embl-heidelberg.de> Message-ID: <000101be929f$6258e180$5fa02299@tim> [Jens Linge] > With python 1.51 running on a SGI: > >>> string.atoi('-') > Traceback (innermost last): > File "", line 1, in ? > ValueError: invalid literal for atoi(): - > >>> > > But with python 1.52 running on a SGI: > >>> string.atoi('-') > 0 > >>> 1.5.2 on Windows: D:\Python>python Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import string >>> string.atoi('-') Traceback (innermost last): File "", line 1, in ? ValueError: invalid literal for atoi(): - >>> > Does it depend on the compilation? I'd try recompiling Python with optimization disabled and see whether that it makes it go away. If so, you're looking at a compiler bug. > WHAT IS THE RULE? Do unto others as you would have them do unto you? Something like that. but-so-far-as-ints-go-"-"-ain't-one-ly y'rs - tim From tim_one at email.msn.com Sun Apr 18 16:55:45 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 18 Apr 1999 20:55:45 GMT Subject: interfacing to Dragon from a Python app In-Reply-To: References: Message-ID: <000801be89dd$d407a0c0$ed9e2299@tim> FYI, people curious about speech recognition under Windows might want to give Microsoft's implementation a try; see the little-known http://www.microsoft.com/iit/ This is not for the Windows-ignorant, weak-hearted, or slow-modem'ed , but (at least for now) it's all free, and you'll face the same irksome issues with microphones, sound cards and multimedia drivers you'll hit with anyone's offering. pioneers-don't-ask-for-help-because-they're-too-obsessed-to-conceive- of-failing-ly y'rs - tim From dan at control.com Fri Apr 23 10:47:25 1999 From: dan at control.com (Dan L. Pierson) Date: Fri, 23 Apr 1999 14:47:25 GMT Subject: Embedding Python - Win32 - Request for Info/Opinions References: <371f32af.0@news.inet-systems.net> Message-ID: <37218679.236666031@news.randori.com> "Frank McGeough" wrote: > What do I need to install when I put this on a target machine? I start off > with creating a Python directory. If I put my COM dll, atl.dll and the > python15.dll in this directory I can get my wrapper to register...but do I > need to set PythonPath? do I need to install common py files? Where would I > put these? Do I just mirror (in a very small way) what the Python install > does? What is commonly done by people who are using Python commercially? What we do (thanks to Mark Hammond), is change PC/python_nt.rc to create a new registry base for our python: //#define MS_DLL_ID "1.5.1" #define MS_DLL_ID "QuickStep" Then we create path and module subkeys under that, all of which point to our install directory. We then copy all of the (many) needed .pyc files (and the .pyd, etc.) into the install directory. We don't ship the .py files by default, but I do have another kit that adds them. The advantage of this is that our app is independant of whatever version of Python may also be installed on the machine. The disadvantage is that we need our own compile of the main Python dll. Actually, we could probably get by with just editing the official dll's embedded resources, but that makes me queasy just thinking about it... Dan Pierson, Control Technology Corporation dan at control.com From hyoon at bigfoot.com Wed Apr 14 11:47:12 1999 From: hyoon at bigfoot.com (Hoon Yoon) Date: Wed, 14 Apr 1999 11:47:12 -0400 Subject: TCL_LIBRARARY and making it work Message-ID: <3714B880.22F87048@bigfoot.com> Hi, I forgot how to set up my TCL_LIBRARY and TK_LIBRARY env variables on NT to make it work. Directory of C:\Python\Tcl\lib\tcl8.0 02/10/99 07:06p 47,407 init.tcl 1 File(s) 47,407 bytes C:\Python>tcltst.py Traceback (innermost last): File "C:\Python\tcltst.py", line 2, in ? Tkinter._test() File "C:\Python\Lib\lib-tk\Tkinter.py", line 1947, in _test root = Tk() File "C:\Python\Lib\lib-tk\Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable init.tcl in the following directories: {C:\Python\TCL\lib} {} ./lib/tcl8.0 C:/tcl8.0/library C:/library This probably means that Tcl wasn't installed properly. I thought this was right on Control Panel System Properties: TCL_LIBRARY C:\Python\TCL\lib\tcl8.0 Can someone tell me how it's set up again? -- ***************************************************************************** S. Hoon Yoon (Quant) Merrill Lynch Equity Trading, yelled at yahoo.com hoon at bigfoot.com(w) "Miracle is always only few standard deviations away, but so is catastrophe." * Expressed opinions are often my own, but NOT my employer's. "I feel like a fugitive from the law of averages." Mauldin ***************************************************************************** -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 202 bytes Desc: Card for Hoon Yoon URL: From MHammond at skippinet.com.au Sun Apr 18 23:38:11 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Mon, 19 Apr 1999 13:38:11 +1000 Subject: NT: win32api and win32ui import error References: <7fdgj4$nnl$1@nnrp1.dejanews.com> <1287633267-17041836@hypernet.com> Message-ID: <7fe8dq$bdi$1@m2.c2.telstra-mm.net.au> Gordon McMillan wrote in message <1287633267-17041836 at hypernet.com>... > msvcrt.dll v 5.00.7303 > ole32.dll v 4.00 > oleaut32.dll v 2.30.4265 Mine for NT are identical, except msvcrt, where Gordon's is MSVC 5 and mine is MSVC6. Build 124 will install MSVC6 DLLs, and Gordon stated he isnt there yet. For Windows 98, I have: ole32.dll 4.71.26.12 oleaut32.dll 2.30.4261 What I know is: * Anyone who sees during installation something like "The COM object could not be registered" will have some problem once installed. This problem can be boiled down to: - "import pythoncom" fails - COM wont work, but most other things will. - "import pywintypes" fails - almost every other "import win32*" statement will also fail. Almost nothing installed will work correctly. My anecdotal evidence so far is: * Many people who encounter this error do so because old versions of pythoncom15.dll and pywintypes15.dll are still hanging around. I dont understand why the installer is doing this to me :-( * Almost all the rest are solved by installing the OLE update referenced at my pages, or installing IE4. * Bernhard is the only other case. He seemed to have 1 machine where ole32.dll was version 2, and whatever he did, the DLL could not be upgraded, deleted or removed. We both gave up there. No one else has given me any information to believe there is more to it than that. If people have problems that can't be explained by the above, then I really want to hear from them. Ive attempted to put all this into a new "Installation Problems" document, linked from the downloads page. The address is http://starship.python.net/crew/mhammond/bigpond/InstallationProblems.html for any constructuve (or otherwise :-) comments... Mark. From aa8vb at vislab.epa.gov Fri Apr 30 13:08:07 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 30 Apr 1999 17:08:07 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world In-Reply-To: <3729CD92.43477316@appliedbiometrics.com>; from Christian Tismer on Fri, Apr 30, 1999 at 05:34:42PM +0200 References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <7g9qmo$luf$1@news.udel.edu> <372965CA.2B3FD2FE@appliedbiometrics.com> <19990430080805.B776752@vislab.epa.gov> <3729A9F3.75B2692B@appliedbiometrics.com> <19990430101215.A806665@vislab.epa.gov> <3729CD92.43477316@appliedbiometrics.com> Message-ID: <19990430130807.A812795@vislab.epa.gov> Christian Tismer: |[tismer().chris about locking] | |> A command-line option (-w), or something like Perl's "use strict" |> declaration would be a reasonable way to enable this behavior. | |Now, well, but Perl is quite different here. As I remember, |it doesn't have all the dynamic features of Python. My point was not to imply "what" would be done by the switch, only "how" it could be flipped ;-) |> |Then, what would you do with classes which depend on each |> |other? You cannot lock them immediately, this would fail. |> |> Could you give an example? | |class abstractparser: | magic = 42 | pass # numerous default and stub methods | |class parserops: | "mixin class" | def general_method1(self, *args): | self.parser_method(self.scanner, args) | def funky_method(self, *args): | #some code there | return self.magic | |class someparser(abstractparser, parserops): | def parser_method(self, scanner, *args): | # do something, and then use the mixin | self.funky_method(2, 3, 5) | |Sorry about my lack of spirit today, this example is bad. |But, if you lock class parserops after it is created, |it will barf, since parser_method cannot be resolved yet. Well, I personally would call this "broken". :-) Base class A calling subclass B's method M without declaring a virtual method M itself is very perverse IMO. If we have: class parserops: "mixin class" def general_method1(self, *args): self.parser_method(self.scanner, args) def parser_method(self,...) """ Pure virtual method """ pass ... Then there's no problem. self.parse_method will always resolve, possibly to a subclass method but at least to this pure virtual stub. |It will also not resolve self.magic, since it doesn't |inherit from abstractparser. I bet you 5 bucks you know what I'm going to say. :-) Accessing attributes of a sibling base class united by a future subclass? [Cringe!] Sheesh. I wouldn't want to try to follow _that_ code, much less debug it. |Yes, but this would limit Python down to Pascal like name spaces. |You would need all kinds of tricks to write recoursions like | |def two(arg): | if arg % 2 == 0: | return three(arg-1) | return arg | |def three(arg): | if arg % 3 == 0: | return two(arg-1) | return arg Good point for deferring resolution until the end of the module. I'm sold. I'd prefer this to having to use forward declarations. Randall From bbaetz at ug.cs.su.oz.au Thu Apr 29 22:19:09 1999 From: bbaetz at ug.cs.su.oz.au (Baetz; Bradley Michael) Date: Fri, 30 Apr 1999 02:19:09 GMT Subject: Q on Tkinter Scrollbar Message-ID: you can use the "@x,y" index syntax for this; the start of the visible text is "@0,0", the end is "@x,y" where x and y is the window size (or anything larger, like "@10000,10000"). also see the attached example. .... def report_position(): # get (beginning of) first visible line top = text.index("@0,0") # get (end of) last visible line bottom = text.index("@0,%d" % text.winfo_height()) Thanks a lot for your help. The only thing I don't understand is why the above line returns the position of the _end_ of the line. I know it does (I tried it), but wouldn't the "@0,%d" mean that text.index returns the absolute index to the position where x=0 (ie the beginning of the line), not the end? Now looking at your comments :), I would have got the absolute line number, and then used lineno.end as the index. What did I miss? Thanks a lot, Bradley From alhopiteau at aol.com Mon Apr 19 07:34:13 1999 From: alhopiteau at aol.com (Alhopiteau) Date: 19 Apr 1999 11:34:13 GMT Subject: Problem with FNORB Message-ID: <19990419073413.22923.00002720@ng-fz1.aol.com> i have a problem with fnorb, running the example i get a error while the script try to import the Fnorb.cdr module, this module is developped using C, how to manage this? thanks From ntpwme at starmedia.com Sat Apr 10 15:04:55 1999 From: ntpwme at starmedia.com (ntpwme at starmedia.com) Date: 10 Apr 1999 19:04:55 GMT Subject: DO YOU BELIEVE IN REINCARNATION? 1843 Message-ID: <7eo7cn$91u$349@news3.Belgium.EU.net> ************************************************************ DO YOU BELIEVE IN REINCARNATION? ************************************************************ Do you want to know who you were and where you lived in your past life? http://orbita.starmedia.com/~luizhenrique/reincarnation.html ************************************************************ This message was posted with POST AGENT The BEST bulk news poster Download your FREE copy now at: http://postagent.com/default.asp?fromAgentID=1819 kckpihergfqukjjgmfdkvqemocjmbmyoksimyiykuhzwvfqdxszokefntjujqwfqwjnqddueneg From paul at prescod.net Fri Apr 30 10:25:27 1999 From: paul at prescod.net (Paul Prescod) Date: Fri, 30 Apr 1999 14:25:27 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <37272CA0.3F3F02A2@prescod.net> Message-ID: <3729BD57.9F7C1CF3@prescod.net> Reimer Behrends wrote: > > > Is there any languge that is as easy to embed as Python, and also has > > full garbage collection? > > Ruby. (Was discussed here before.) See Maybe you can describe its embedding API. How does it handle the issue of C pointers to objects that are moving around? How does it know if the embedding code has buried a pointer away somewhere? -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco "Microsoft spokesman Ian Hatton admits that the Linux system would have performed better had it been tuned." "Future press releases on the issue will clearly state that the research was sponsored by Microsoft." http://www.itweb.co.za/sections/enterprise/1999/9904221410.asp From aa8vb at vislab.epa.gov Tue Apr 6 11:19:50 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 6 Apr 1999 15:19:50 GMT Subject: SWIG, Modulator, BGEN, etc. - which? (Re: swig or not to swig ?) In-Reply-To: <002b01be803c$635a54d0$6fc6a8c0@rochester.rr.com>; from Darrell on Tue, Apr 06, 1999 at 10:47:26AM -0400 References: <4p6O2.1348$8m5.2126@newsr1.twcny.rr.com> <3709f149.2262513@news.oh.verio.com> <19990406103412.A869943@vislab.epa.gov> <002b01be803c$635a54d0$6fc6a8c0@rochester.rr.com> Message-ID: <19990406111950.A870049@vislab.epa.gov> Darrell: |> I'm also interested in what wrapping options folks like best. |> Roll-your-own, SWIG, Modulator, BGEN? (Do others not listed exist for |UNIX?) | |These are the only options I've found. I just started playing with Modulator |and it will very much simplify a Roll-your-own approach. BGEN is my next |option to try. | |I believe that BGEN is the only one that tries to parse .h files, which |sounds like what you want. |I'll let you know how it goes. Thanks. I'd appreciate that. BTW, SWIG parses header files as well. Of the 3, it is the only one I've used, and I haven't spent a lot of time with it yet. It does a good bit, and it supports generating a Python "shadow class" for structures it encounters which can be convenient. Also, once you get the .i file cooked, ideally you can generate wrappers for Python, Perl, Tcl, and others coming down the pike no more modificiation. Of the 2 small C libraries I've wrapped for Python thus far, I had to augment it's default behavior in a couple ways by customizing the SWIG configuration (.i) file for the libraries: 1) For struct parameters, explicitly define wrapper "constructor" and "destructor" methods for the struct. These are exposed as new functions that are named new_ and delete_. 2) Define access routines in the wrapper for struct members. (These communicate errors to exception wrappers using an ad-hoc wrapper-module-scope variable.) 3) Define a number of exception wrappers to turn C function errors and even wrapper function errors into script language exceptions. (Unfortunately, new functions defined in the wrapper can't throw their own exceptions. They have to communicate these out-of-line to exception wrappers which then trigger the scripting language exceptions.) 4) Define which function parameter names are output parameters. 5) Double wrap functions which return values in arguments and success/failure in the return value, so I can get a tuple in Python. E.g.: %apply float *OUTPUT { float *x, float *y }; int GetPoint( struct S *s, int *x, int *y ) By default this returns a 3-tuple. We don't care about the function return value in Python (it's translated into an exception by the exception wrapper) so we must double-wrap to toss it. It works. However, there is enough non-trivial wrapper code (123 lines for one of these libraries; a maintenance issue) that I thought it'd be worthwhile to survey what other options are out there. Randall From dalke at bioreason.com Thu Apr 15 19:35:51 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Thu, 15 Apr 1999 17:35:51 -0600 Subject: for in benchmark interested References: <37157CE7.EFB470CA@inka.de> Message-ID: <371677D7.EACDA7B7@bioreason.com> Friedrich Dominicus said: > Some time ago I have opened a thread about optimization in Python. I > have now done a simple benchmark and used Python for that too. If > s.o is interested, take a look at: http://edt.vol.cz:81/bench How about a unix command line implementation, like cat file | tr " \t\r" "\n\n\n" | sort | uniq -c | tail +2 It's a bit slower than the C version, but only by a factor of two or so, and a lot easier to write. Another solution might be: echo "" | spellin > myhlist spell -d myhlist < file | sort | uniq -c but that strips punctuation so doesn't give the same results. A third is: deroff -w file | sort | uniq -c which also doesn't give exactly what you want. Still, it is arguable that both these cases are better than the other solutions given different definitions of the word "word." BTW, the C code has some problems: *** add (char *) "count_words.l", line 34: error(3232): a value of type "void *" cannot be used to initialize an entity of type "char *" char* str = malloc(yyleng+1); strcpy(str, yytext); ^ There are a few problems with "inline" that my non-gcc C compiler doesn't like. I'm not sure that inline is a C keyword. I also get a core dump when I run it: bioreason8> ./count_words_c ./count_words.c Bus error (core dumped) bioreason8> dbx ./count_words_c core dbx version 7.1 Dec 3 1996 17:03:19 Core from signal SIGBUS: Bus error (dbx) where > 0 hash(string = 0x100170e9 = "line") ["/home/u05/dalke/tmp/hash.c":104, 0x100037c8] 1 search(table = 0x10017010, key = 0x100170e8 = "#line") ["/home/u05/dalke/tmp/hash.c":181, 0x10003b00] 2 run() ["/home/u05/dalke/tmp/count_words.l":35, 0x100033e0] 3 yylex() ["/home/u05/dalke/tmp/count_words.l":27, 0x1000198c] 4 main(argc = 2, argv = 0x7fff2f24) ["/home/u05/dalke/tmp/count_words.l":59, 0x100034fc] 5 __start() ["/vince/6.2-mar09/work/irix/lib/libc/libc_n32_M3/csu/crt1text.s":166, 0x100015e8] (dbx) list 92 92 /* 93 Hashes a string to produce an unsigned short, which should be 94 sufficient for most purposes. 95 */ 96 97 unsigned hash(char *string) 98 { 99 unsigned int ret_val = 0; 100 int i; 101 (dbx) l 102 while (*string) 103 { * 104 i = *( int *)string; 105 ret_val ^= i; 106 ret_val <<= 1; 107 string ++; 108 } 109 return ret_val; 110 } 111 The conversion on line 104 is really wrong. It should likely be i = (int)(*string) Also, I tried it (with the fix) against a core dump: bioreason8> ls -l /usr/tmp/core -rw-r--r-- 1 root sys 5357568 Apr 8 00:45 /usr/tmp/core bioreason8> ./count_words_c /usr/tmp/core > /dev/null After about 6 minutes I killed the job. Probably doesn't like the embedded NULs. This is an example of "fuzz" testing. See http://www.cs.wisc.edu/Dienst/UI/2.0/Describe/ncstrl.uwmadison/CS-TR-95-1268 Finally, I see the lex code is processed with: count_words.c: count_words.l flex -B -ocount_words.c count_words.l You should add a "-f" to that. That gave me a 15% speedup over just -B, against the code at http://caml.inria.fr/caml-list/0899.html, from whence you based this thread originally. Andrew dalke at acm.org From downstairs at home.com Thu Apr 8 01:21:29 1999 From: downstairs at home.com (TM) Date: Thu, 08 Apr 1999 05:21:29 GMT Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> Message-ID: I would love a copy. I've only written a few (simple) modules, but I'd sure like to try and help you out. Please let me know where I can download it or send it to my other e-mail address: mrfusion at home.com Thanks! Tom P.S. By the way, there is a module called terry that generates renderman code. I think they even list it on python.org. What I'd REALLY rather see is a module that could manipulate pre generated .rib files. God that would make my life easier...... > Well, I don't have RenderMan, but I did write a pov.py module. It does > basically what you described, and eventually I'm going to add animation > features and basic physics (the ocaml module I wrote before did that) and > stuff like "magic" transforms that align one object with another, spline > curves etc. I've designed some scenes in it, and it's wordier than pov, but > has all the benefits of a real language. It doesn't do the new halo syntax > because the pov people have yet to release an updated unix version > (grumblegripegrunt). It's incomplete, and written when I was first learning > python, and I haven't worked on it for a while, but I'll send it to anyone > interested. Perhaps we could collaborate? From aa8vb at vislab.epa.gov Fri Apr 23 08:07:21 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 23 Apr 1999 08:07:21 -0400 Subject: Pointers to variables In-Reply-To: ; from Dan Schmidt on Thu, Apr 22, 1999 at 01:30:53PM -0400 References: <19990422121403.A279051@vislab.epa.gov> Message-ID: <19990423080721.A344578@vislab.epa.gov> Thanks for the replies and suggestions to use setattr to set variables by name. I think I understand the source of my confusion. This construct: for ( var, val ) in [( min, 1 ), ( max, 100 )]: isn't pairwise assignment to all the values of the list. If it were, val would be an alias for the variable min, then an alias for max, etc. This actually builds a completely new list: [( valueof(min), 1 ), ( valueof(max), 100 )] in memory first, which is then iterated over. This is why my original example didn't work. Also, the "valueof()" relation for some types in python (apparently) is a reference rather than a value (lists, objects, etc.) which explains why these examples work: (1) min = [ 0 ] max = [ 0 ] for ( var, val ) in [( min, 1 ), ( max, 100 )]: var[0] = val (2) class Val: def __init__( self, num ): self.num = num min = Val(0) max = Val(0) for ( var, val ) in [( min, 1 ), ( max, 100 )]: var.num = val but this one doesn't: (3) min = 0 max = 0 for ( var, val ) in [( min, 1 ), ( max, 100 )]: var = val So basically this is just a little asymmetry in the language. Putting a variable in a list/tuple (valueof(var)) performs a shallow copy rather than a deep copy. Does this sound about right? Randall From jeremy at cnri.reston.va.us Tue Apr 6 13:24:16 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 6 Apr 1999 13:24:16 -0400 (EDT) Subject: SNMPy update In-Reply-To: <3709C8BE.4257C9F1@lemburg.com> References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> <3709C8BE.4257C9F1@lemburg.com> Message-ID: <14090.16807.950025.496495@bitdiddle.cnri.reston.va.us> >>>>> "MAL" == M -A Lemburg writes: MAL> Jeremy Hylton wrote: >> I'll second your sentiment! I did some work on an X.509 library >> written entirely in Python. Like you friend's SNMP code, it will >> probably never be released; I don't have time to finish it nor >> did I expect that I'd want to release it given the export control >> hassles. MAL> Just want to note that SSLeay/OpenSSL includes a pretty MAL> complete X.509 lib and also routines to do ASN.1 encoding an MAL> decoding. The main argument for using OpenSSL in this context MAL> is, of course, that no export control restrictions apply. Absolutely! There are a number of good reasons for using OpenSSL other than export control as well. OpenSSL buys you all of SSL as well as a lot of X.509 (and more of that every day). A Python application built on a SWIGed OpenSSL, however, has a *lot* of C code underneath it -- with all the problems a large C program has. A pure Python implementation of X.509 could be easier to understand, debug, and maintain. >> However, it seemed clear to me that an ASN.1 compiler could be >> written to generate the encode/decode routines. If someone is >> interested in that, I've got some design notes and rough code on >> how to do the encode/decode and on how to build a backend for >> SNACC. (A free-ish ASN.1 compiler; the only one?) MAL> Not sure what you mean with "ASN.1" compiler. If you want a MAL> compiler that does ASN.1 description -> Python function calling MAL> de/encoding routines kind of thing, then I guess the ASN.1 MAL> stuff in OpenSSL could help you getting started quite fast. It seems awfully hard to separate the ASN.1 specific stuff out of OpenSSL. It uses it owns I/O abstractions and some moderately hair C data structures to manage the results. It's a lot simpler to just write the encode/decode routines in pure Python. MAL> Note that I have a project running with the intention to wrap MAL> OpenSSL in an OO manner called mxCrypto (see the link below). Looking forward to seeing it. When do you think you might have an alpha release ready? Jeremy From clarence at silcom.com Fri Apr 16 11:04:12 1999 From: clarence at silcom.com (Clarence Gardner) Date: Fri, 16 Apr 1999 15:04:12 GMT Subject: forking + stdout = confusion References: <001d01be87b5$8b3529a0$ada22299@tim> Message-ID: Tim Peters (tim_one at email.msn.com), as usual, knew the answer: : It doesn't matter, though, because unlike file objects you create with : "open", Python won't close the file descriptor underlying the default : binding for sys.stdout (or .stdin or .stderr) even if all references do go : away. Those three file objects are initialized specially (in _PySys_Init). I promise this will be my last posting in this thread :) Tim: Thanks! Carsten, et al.: The Apache, CERN and Netscape HTTP servers (at least for Unix) treat any CGI program differently if its name begins with 'nph-'. Normally, stdout in a CGI is a pipe into the web server, which copies the data to the client. Before the data, however, it also includes the HTTP response headers (though it requires you to supply the Content-Type). It may also buffer the entire response so that it can include a Content-Length. Technically, the difference in the NPH environment is that the server does not add any headers, so the entire HTTP response must be provided by the CGI program. (One of the reasons NPH is necessary is if you want to provide an unusual HTTP response code. The server normally takes care of Success and, if you provide a Location: or URI: header, Redirection statuses.) (NPH supposedly means 'non parsed headers'.) In practice, the server also does away with the buffering in the NPH case, and sets the stdout for the CGI program to be the connection to the client. -- -=-=-=-=-=-=-=-= Clarence Gardner AvTel Communications Software Products and Services Division clarence at avtel.com From matt at mondoinfo.com Sat Apr 24 18:27:08 1999 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 24 Apr 1999 17:27:08 -0500 Subject: CSV Module References: Message-ID: In article , Moshe Zadka wrote: > I wonder if there is some standard module out there that can parse > ``CSV'' files. Or, if anyone knows where the documentation of that format > can be had. > > Here is my meek attempt at an answer. It is not certain to work, as I am > not sure about the format -- I was guessing from looking at the file [snip] Moshe, I'm pretty sure that there isn't a standard module since I had a look for one a month or two ago and didn't find one. I ended up doing just what you did -- hacking up something that worked on the file I needed to convert. I have no idea if there's something in the spec that mine doesn't take into account since I've never seen the spec. Mine will handle double-quotes embedded in a field since there were some in the data I had to parse. In case it's of any interest to anyone, I've uploaded mine to my FTP site: ftp://ftp.visi.com/users/mdc/csvsplit.py Regards, Matt From akuchlin at cnri.reston.va.us Tue Apr 6 11:18:21 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Tue, 6 Apr 1999 15:18:21 GMT Subject: SWIG, Modulator, BGEN, etc. - which? (Re: swig or not to swig ?) In-Reply-To: <19990406103412.A869943@vislab.epa.gov> References: <4p6O2.1348$8m5.2126@newsr1.twcny.rr.com> <3709f149.2262513@news.oh.verio.com> <19990406103412.A869943@vislab.epa.gov> Message-ID: <14090.9566.560801.949551@amarok.cnri.reston.va.us> Randall Hopper writes: >I'm also interested in what wrapping options folks like best. >Roll-your-own, SWIG, Modulator, BGEN? (Do others not listed exist for UNIX?) There's also SIP for C++ libraries, written for wrapping the Qt/KDE libraries. http://www.river-bank.demon.co.uk/software/ (It's named "SIP" because it's a small "SWIG".) -- A.M. Kuchling http://starship.python.net/crew/amk/ Blossom for a lady -- Rain in the doorway -- Not her sister -- Want/not want -- The views from the backs of mirrors -- Journal of the plague year -- "The number you have dialled..." -- Title of SANDMAN #41: "Brief Lives:1" From fred at sunrise.com Fri Apr 16 20:47:56 1999 From: fred at sunrise.com (Fred Sells) Date: Fri, 16 Apr 1999 20:47:56 -0400 Subject: Motif GUI Builder References: Message-ID: <3717DA3C.8D91A592@sunrise.com> We have developed a C, C++, Ada GUI builder for Motif 1.2 many years ago. The product is ezX. We had also developed, but never released a Python interface. Is there any interest in a Motif GUI builder that includes a Python interface???. If you are interested, please email to fred at sunrise.com with a few words about how you could use it. To put it in perspective. the C/C++ version sold for $3500 per user. The Python would be freebie or shareware depending on what I need to do to support it and if there is any real interest in a Motif GUI. I need to decide whether to get it out there on the web or deep six it. Fred Sells, Sunrise Software International. From jamz at my-dejanews.com Tue Apr 27 11:52:47 1999 From: jamz at my-dejanews.com (jamz at my-dejanews.com) Date: Tue, 27 Apr 1999 15:52:47 GMT Subject: JPython 64K limit on source-code size? Message-ID: <7g4mgd$uo7$1@nnrp1.dejanews.com> I have a JPython program I'm using as a test suite. It's generated code and around 74K long. When I try to run it with JPython I get this message: Traceback (innermost last): (no code object) at line 0 java.lang.ClassFormatError: org/python/pycode/_pyx0 (Code of a method longer than 65535 bytes) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:382) at org.python.core.BytecodeLoader.loadClass(BytecodeLoader.java:12) at org.python.core.BytecodeLoader.loadBytes(BytecodeLoader.java:23) at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:41) at org.python.core.Py.compile(Py.java:997) at org.python.core.Py.compile(Py.java:1007) at org.python.core.__builtin__.execfile(__builtin__.java:220) at org.python.core.jpython.main(jpython.java:141) If this 64K ceiling is indeed a basic limitation of JPython because of Java, I'm wondering if there is an easy way to split the file into pieces in a chain-like fashion. Any ideas? Thanks, Monty -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From boud at rempt.xs4all.nl Tue Apr 13 17:01:37 1999 From: boud at rempt.xs4all.nl (boud at rempt.xs4all.nl) Date: Tue, 13 Apr 1999 21:01:37 GMT Subject: Python + KDE tutorial Message-ID: Since I mentioned my attempts at the translation of Daniel Marjam?ki's c++ KDE tutorial (http://www.dormnet.his.se/~a96danma) into Python, I thought it a good idea to mention that it is now up at: http://www.xs4all.nl/~bsarempt/python/tutorial.html It offers both of Daniels lessons and some explanatory text. I'm sure I not an experienced Python programmer, but the examples seem to work... Boudewijn Rempt -- Boudewijn Rempt | www.xs4all.nl/~bsarempt From mike.steed at natinst.com Wed Apr 7 13:21:24 1999 From: mike.steed at natinst.com (Mike Steed) Date: Wed, 07 Apr 1999 12:21:24 -0500 Subject: File objects in extension module Message-ID: <370B9414.68053816@natinst.com> Hi, I am trying to use a file object passed from Python to a C extension module (Windows 98). All the C runtime calls crash when I pass them the FILE pointer (fwrite, fflush, etc.) The pointer I get back from PyFile_AsFile seems okay -- the struct members have reasonable values, etc. I have seen the same behavior with MS VC++ (4.2) and egcs/mingw32 (1.1.2), and with Python-1.5.1 and 1.5.2b2. What am I missing? Here is a minimal code snippet, without the error checking code: ----- example.c #include "Python.h" static PyObject * ex_flush(PyObject *self, PyObject *args) { PyObject *file; /* ... code to check arg count and types removed ... */ file = PyTuple_GetItem(args, 0); fflush(PyFile_AsFile(file)); Py_INCREF(Py_None); return Py_None; } static PyMethodDef example_methods[] = { {"flush", ex_flush, 1}, {NULL, NULL} }; void initexample() { Py_InitModule("example", example_methods); } ----- on the Python side: >>> import example >>> f = open('test', 'w') >>> example.flush(f) --> crash! Puzzled, Mike From MHammond at skippinet.com.au Tue Apr 13 19:39:50 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 14 Apr 1999 09:39:50 +1000 Subject: site.py & COM startup References: Message-ID: <7f0kin$ben$1@m2.c2.telstra-mm.net.au> Robin Becker wrote in message ... >using Mark Hammond's win32com for a server I find that the installation path is not >automatically in sys.path so my base .pth files are missed and I get troubles. > >I hacked site.py to fix this using the fact that sys.prefix == '' when running a com >server (I guess inproc). It is indeed when run as an inproc. The problem is that Python uses the current executable to try and deduce the Python home. When Python is being used as a COM server, the host executable could be _anything_, and therefore cant be used to locate the Python home. So, I would like to fix this once and for all in the COM stuff, but I cant work out a reasonable strategy for locating the Python home. Also, FYI: As of build 124 and later of my extensions, when you register a COM object its path is now also automatically saved away, and automatically used as the object is created - thus, no more errors due to your COM object not being on the PythonPath... Mark. From scott at chronis.pobox.com Thu Apr 8 16:27:41 1999 From: scott at chronis.pobox.com (scott cotton) Date: 8 Apr 1999 20:27:41 GMT Subject: another lock module Message-ID: i got tired of worrying about whether or not a system does flock, of thinking that posix fcntl might not work on all systems due to the differences in the struct flock, and certainly not nfs, so i took the file locking locking module from mailman (locks with link() so it _should_ work on NFS, i think), added shared vs exclusive locking, and made the interface something i like. hope someone else finds it handy, and thanx josh for adding the timeouts! file lock.py: ---------------------------------------------------------------------- """ unix portable file locking, reportedly works even on NFS file systems. usage: shared and exclusive locking (read and write locks) import lock shl = lock.shlock() shl.release() exl = lock.exlock() exl.release() try: shl = lock.shlock(, ) except lock.TimeoutError: # SOL, no lock try: exl = lock.exlock(, ) except lock.TimeoutError: # no lock # # By default, all locks will be stored in files in # the /tmp directory. this may not be desirable. # the user can change the lock directory from the # default '/tmp' using the setlockdir() function. # lock.setlockdir("/tmp/lock") # # it is recommended that users of this module # surround code between obtaining and releasing # a lock with a try: ... finally:. This will # help guarantee that an application using this # module will never deadlock. system crashes may # cause deadlock, but that is fairly unlikely. # shl = lock.shlock() try: # do stuff with the lock finally: shl.release() """ # # system mods # import os from stat import ST_NLINK import string import socket import time # # how frequently to retry obtaining locks in seconds # retry_intv = 0.3 # # the default directory in which locks are # housed. # lockdir = "/tmp" class TimeoutError(StandardError): pass def setlockdir(newlockdir): global lockdir lockdir = newlockdir class _lock: def __init__(self, resource, lockdir): self.resource = resource self.lockpath = os.path.join(lockdir, "%s.lock" % (self.resource)) self.tmpfname = os.path.join(lockdir, "%s.lock.%s.%d" % (self.resource, socket.gethostname(), os.getpid())) if not os.path.exists(self.lockpath): open(self.lockpath, "a+").close() self.type = "unknown" def release(self): if not self.locked(): return if self.type == "ex" \ or os.stat(self.lockpath)[ST_NLINK] == 2: open(self.lockpath, "w").close() # remove the info in the lock file os.unlink(self.tmpfname) def __del__(self): self.release() def locked(self): return os.path.exists(self.tmpfname) # # can raise ValueError or IOError, ValueError is handled further up. # def _getlockdata(self): fp = open(self.lockpath, 'r') try: raw = fp.read() ltype, host, pid = string.split(string.strip(raw)) pid = string.atoi(pid) finally: fp.close() return ltype, host, pid def _setlockdata(self): s = "%s %s %d\n" % (self.type, socket.gethostname(), os.getpid()) fp = open(self.lockpath, "w") try: fp.write(s) finally: fp.close() class exlock(_lock): def __init__(self, resource, timeout = 0): _lock.__init__(self, resource, lockdir) self.type = "ex" starttime = time.time() while 1: os.link(self.lockpath, self.tmpfname) if os.stat(self.lockpath)[ST_NLINK] == 2: # we have the exclusive lock self._setlockdata() break os.unlink(self.tmpfname) time.sleep(retry_intv) time_elapsed = time.time() - starttime if (timeout) and (time_elapsed > timeout): raise TimeoutError("Timeout limit of %d seconds" " has been reached" % timeout) class shlock(_lock): # # in order to allow a single process # to acquire multiple shared locks # on a single resource, we must supplant # the pid part of the tmpfname with a counter. # this information in stored in the dict shared_ct # keyed by resource name and valued by counter. # this is not thread safe. shared_ct = {} def __init__(self, resource, timeout = 0): _lock.__init__(self, resource, lockdir) self.type = "sh" if not self.shared_ct.has_key(resource): self.shared_ct[resource] = 1 else: self.shared_ct[resource] = self.shared_ct[resource] + 1 self.tmpfname = self.tmpfname + "-%d" % (self.shared_ct[resource]) starttime = time.time() while 1: os.link(self.lockpath, self.tmpfname) nlink = os.stat(self.lockpath)[ST_NLINK] if nlink == 2: # first shared lock self._setlockdata() break elif nlink > 2: # is it shared or exclusive? # we have to read from the lock file # here, so if a read happens after # another process has truncated the file, # it'll raise ValueError, in which case we just # keep on tryin' try: ltype, host, pid = self._getlockdata() except ValueError: # read after other lock erased lockinfo from file ltype = "unknown" if ltype == "sh": break os.unlink(self.tmpfname) time.sleep(retry_intv) time_elapsed = time.time() - starttime if (timeout) and (time_elapsed > timeout): raise TimeoutError("Timeout limit of %d seconds" "has been reached" % timeout) From roy at popmail.med.nyu.edu Tue Apr 27 08:54:48 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Tue, 27 Apr 1999 08:54:48 -0400 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <37215EFB.433AFCA6@prescod.net> <3724B2D6.B468687A@prescod.net> <37252816.42634501@Lugoj.Com> Message-ID: James Logajan wrote: > When an SME finds the tool too slow, it would be nice if they could post > their problem to a group like this without fear of insult, intended or not. There was no intent to insult. The thread was moving in the direction of "my program using regex is too slow, and I think the solution would be to move regex into the python core to make it faster". I was just pointing out why that is flawed reasoning. -- Roy Smith New York University School of Medicine From ciupke at fzi.de Thu Apr 22 09:16:21 1999 From: ciupke at fzi.de (Oliver Ciupke) Date: Thu, 22 Apr 1999 15:16:21 +0200 Subject: Time complexity of dictionary insertions Message-ID: <371F2125.BEC5F892@fzi.de> As I understood from the Python documentation, dictionaries are implemented as extensible hash tables. What I didn't find either in the references or in the FAQ is: what is the actual time complexity for an insertion into a dictionary? Do the old contents (probably references) have to be copied when extending (doubling?) the dictionary? I guess updates and deletions have constand complexity, right? If the complexity of insertion is something like n*log(n), does anyone know measurements "how linear" the real measured times are? Thanks in advance --Oliver From wtanksle at dolphin.openprojects.net Wed Apr 28 18:54:30 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 28 Apr 1999 22:54:30 GMT Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> Message-ID: On Wed, 28 Apr 1999 20:04:00 GMT, Paul Prescod wrote: >William Tanksley wrote: >> And Oberon (SlimBinaries), and Eiffel (typing and general compile-time >> error catching), and ... >Actually, isn't Eiffel's type system famous for being full of holes? I'm familiar with the covariance/contravariance argument, but I've never before heard anyone say anything about Eiffel being full of holes. What problems have you heard of? >Regardless, wouldn't a better source of inspiration on typing be a >language with *optional* compile-time error checking? Good question. I don't know the answer, but I can point out the dangers of not planning our path. One dangerous side of allowing flexibility is that we could be like C++, where the safe way of doing anything requires more typing and often causes incompatibilities. Examples range from virtual functions; through inline functions, templates, single-root object hierarchy, and garbage collection; to covariance/contravariance. The other dangerous side, of course, is being one of the languages which are so safe you can't use them without a huge manual and pages of UML. Python can NOT wind up like this, regardless of the dangers obvious in the other side. Let me expand a little on the dangers of C++. - virtual functions. It shouldn't be my job to tell the compiler when virtual lookups are the only thing to do; the compiler ought to be able to tell. For performance gurus, a way to hint to the compiler that virtual lookups were _not_ needed might be useful -- but what if the programmer was wrong? - inline functions. Again, a good compiler HAS to make this decision for itself, and in a good compiler, whether or not this decision was made should be transparent to the programmer. - templates. Generic functions are a very good thing, and with Python 2's type support we might wind up needing them. In C++, templates are also a very good thing, but thanks to the C model of seperate compilation, no two C++ compilers handle templates compatibly. - single-root object hierarchy -- this is a must when the default binding is virtual. - GC -- hard to add after the fact. No worry with Python, but what if there are other issues like it? - covariance/contravariance/"no"variance -- when a subclass redefines a function, what types of input parameters can the redefinition accept? In C++, you can't accept a different type without overloading the function. With covariance (in Sather) you can allow the redefined function to accept a parent class, which allows the new function to handle more subclasses (including all the ones the old function handled). With contravariance you can require the redefinition to be more specific, accepting fewer classes. Aside from my obvious dislike of novariance, I'm not going to take sides ;-). > Paul Prescod - ISOGEN Consulting Engineer speaking for only himself -- -William "Billy" Tanksley "But you shall not escape my iambics." -- Gaius Valerius Catullus From duncan at rcp.co.uk Tue Apr 27 06:31:10 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 27 Apr 1999 10:31:10 GMT Subject: Python and "Hand held" computers References: <37222AE6.E6C8F713@weihenstephan.org> <7g2l65$92k$1@minus.oleane.net> Message-ID: <8DB575576duncanrcpcouk@news.rmplc.co.uk> Fred Pacquier wrote in <7g2l65$92k$1 at minus.oleane.net>: >In article <37222AE6.E6C8F713 at weihenstephan.org>, >peter.stoehr at weihenstephan.org wrote: >Python 1.5.1 was ported last year >to the Psion Series 5 by an Englishman, and it works quite well. I can >find the Web site if you're interested... > Scotsman, please. -- Duncan Booth duncan at dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan From fredrik at pythonware.com Fri Apr 23 03:17:32 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 23 Apr 1999 07:17:32 GMT Subject: >>> Down-Translation? <<< References: <7fo16e$810$1@usenet49.supernews.com> Message-ID: <00d601be8d5b$ccf76be0$f29b12c2@pythonware.com> Nagwa Abdel-Mottaleb wrote: > I am looking for a suitable language that will enable me to > down-translate XML files into something like LaTeX files. > Is it easy to use Python for this process? For example, > how easy it is to write code segments that enable to > translate > > foo > > in the xml input file into > > \begin{tag} > foo > \end{tag} > > and things like that in the tex output file? > > Any pointers and/or sample code will be appreciated. > (Please e-mail me if possible.) Python comes with an XML parser: http://www.python.org/doc/lib/module-xmllib.html here's some code to start with: --- import sys, xmllib class myParser(xmllib.XMLParser): _eoln = 1 def __init__(self, out): xmllib.XMLParser.__init__(self) # initiate base class self.write = out.write # for special tags, initiate self.elements here: # self.elements = { # "mytag": (self.start_mytag, self.end_mytag) # } def handle_data(self, data): self.write(data) self._eoln = (data[:-1] == "\n") def unknown_starttag(self, tag, attributes): # default is to map tags to begin/end constructs if not self._eoln: self.write("\n") self.write("begin{%s}\n" % tag) self._eoln = 1 def unknown_endtag(self, tag): if not self._eoln: self.write("\n") self.write("end{%s}\n" % tag) self._eoln = 1 p = myParser(sys.stdout) p.feed("text") p.close() --- From knotwell at my-dejanews.com Fri Apr 16 13:19:21 1999 From: knotwell at my-dejanews.com (knotwell at my-dejanews.com) Date: Fri, 16 Apr 1999 17:19:21 GMT Subject: 1.5.2, threading and sockets Message-ID: <7f7ref$5fg$1@nnrp1.dejanews.com> Hello all-- I'm looking at the 1.5.2 version of python. I've noticed that sockets and threads seem to work together much more slowly than in 1.5.1. I've done a good number of timings using the following snippet of code (or something quite similar to rule out urllib as the problem): import urllib import threading def traffic_gen(url): for i in range(0,10): z = urllib.URLopener() s = z.open(url) s.read() s.close() print 'done' return map(lambda x: x.start(), \ map(lambda x: threading.Thread(target=traffic_gen,kwargs={'url':'http:// www.myurl.here'}),range(0,5))) The problem is that this code was between 2-7 times (1.5.2) slower in my tests (the range appears to depend on the number of threads as well as network latency). The call order was also much more "jerky." It appeared to me that the socket/threading routines (standing alone) were slightly faster in 1.5.2. I can only guess there is some kind of a resource issue for threads using the socket module. I've only tried this on machines running Redhat5.2 (Linux2.0.36 and Linux2.2.5) so I don't know if this a Redhat problem. The only thing I see that looks suspicious is the hocus-pocus with gethostbyname (v. gethostbyname_r) in socketmodule.c. However, I tried compiling with -DHAVE_GETHOSTYBNAME_R_6_ARG and -DUSE_GETHOSTBYNAME_LOCK. Neither option made it any speedier or smoother. Does anyone have any idea what I should do about this? Thanks. --Brad -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From piers at cs.su.oz.au Sat Apr 17 21:03:45 1999 From: piers at cs.su.oz.au (Piers Lauder) Date: Sun, 18 Apr 1999 01:03:45 GMT Subject: Python-1.5.2 testing zlib Message-ID: My "make check" fails with a core dump after "test_zlib". Runng that test by hand shows: : s Python-1.5.2 ; ./python Lib/test/test_zlib.py 0xe5c1a120 0x43b6aa94 0xbd602f7 0xbd602f7 expecting Bad compression level expecting Invalid initialization option expecting Invalid initialization option normal compression/decompression succeeded compress/decompression obj succeeded decompress with init options succeeded decompressobj with init options succeeded Bus error - core dumped Adding a print at the start of the last loop: : s Python-1.5.2 ; ./python Lib/test/test_zlib.py 0xe5c1a120 0x43b6aa94 0xbd602f7 0xbd602f7 expecting Bad compression level expecting Invalid initialization option expecting Invalid initialization option normal compression/decompression succeeded compress/decompression obj succeeded decompress with init options succeeded decompressobj with init options succeeded Decompress: flush mode=0, level=0 Memory fault - core dumped Anyone else seen this? (My system: : s Python-1.5.2 ; uname -a SunOS staff 5.6 Generic_105181-05 sun4u sparc SUNW,Ultra-2 : s Python-1.5.2 ; ./python Python 1.5.2 (#2, Apr 17 1999, 20:08:31) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam ) From jkraai at murl.com Wed Apr 28 15:10:14 1999 From: jkraai at murl.com (jkraai at murl.com) Date: Wed, 28 Apr 1999 14:10:14 -0500 Subject: Maximize Benefit when Purchasing Learning Python Message-ID: <010701be91aa$d1267960$8b7125a6@cpda6686.mcit.com> I'll, eh, need valid street addresses for the both of you. *heh heh* I just really like the whole Python experience. Thanks for making my day! --jim -----Original Message----- From: David Ascher Date: Wednesday, April 28, 1999 1:53 PM >On Wed, 28 Apr 1999 jkraai at murl.com wrote: > >> How can I help whom when purchasing Python books? > >I'll dare to speak for Mark, and say that you should feel free to send >either Mark or I (or both) checks for any amount whatsoever. Skip the >middleman. Save trees -- don't buy the book, just send us cash. Don't >hesitate for a minute. > >David Ascher From doughellmann at mindspring.com Fri Apr 9 07:29:25 1999 From: doughellmann at mindspring.com (Doug Hellmann) Date: Fri, 09 Apr 1999 07:29:25 -0400 Subject: Q on Tkinter Scrollbar References: <370CFAC8.32EB0B29@ingr.com> Message-ID: <370DE495.E98111E3@mindspring.com> Hi, Joseph, I can't give you any useful tips on the scrollbar, but if I was writing this I think I would probably subclass the canvas to create a "meter" or "thermometer" widget to do what you need. Create a rectangular canvas (taller than wide), draw the scale (lines and text), then create an indicator (a triangle?) to point the current value. In fact, if you're not against using Pmw, there is just such a beast in the demos or contrib directory. Now that I think of it, you might find some useful examples of the scrollbar elsewhere in the Pmw code. Take a look http://www.dscpl.com.au/pmw/. Doug Joseph Robertson wrote: > > Hi everyone, > > I want to manually control the scrollbar in a tkinter app, i.e. I don't > want to tie it to another widget as a child. Below is what I have so > far. I can't figure how to make the 'thumb' stay at the returned > position, or the point where the user drags it. Right now it always > pops back to the top. > > I want it to behave like a Scale, but look like a scrollbar. Think of a > virtual window on a dataset, where I don't want to load the contents of > the data set into a listbox (not enough memory). > > Anyone do this before, know of any similar examples, or give me a clue > where to look next. I don't want to use extensions or another GUI, it > needs to be Tkinter. > > Thanks in advance, > Joe Robertson > jmrober1 at ingr.com > > >----begin code > # a manual scrollbar > # > # Joe Robertson, jmrober1 at ingr.com > # > from Tkinter import * > > class Manual(Frame): > > def __init__(self, master, **kw): > apply(Frame.__init__, (self, master), kw) > vscrollbar = Scrollbar(self, orient=VERTICAL) > self.canvas = Canvas(self) > vscrollbar.config(command=self._vscroll) > vscrollbar.pack(fill=Y, side=RIGHT) > self.canvas.pack(expand=1, fill=BOTH, side=LEFT) > > def _vscroll(self, type, *arg): > print type > if type == 'moveto': > for each in arg: > print each > > # doit > root = Tk() > f = Manual(root) > f.pack(expand=1, fill=BOTH) > root.mainloop() > > >----end code From MHammond at skippinet.com.au Thu Apr 8 21:15:02 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Fri, 9 Apr 1999 11:15:02 +1000 Subject: COM Event Sinks and Connection Points in Python References: <7eggfh$o0f$1@nnrp1.dejanews.com> <7egnl2$ca5$1@m2.c2.telstra-mm.net.au> <7eie3h$sr$1@newsin-1.starnet.net> Message-ID: <7ejk9j$5tn$1@m2.c2.telstra-mm.net.au> Martin Bertolino wrote in message <7eie3h$sr$1 at newsin-1.starnet.net>... >Some of COM features (especially when running in a Single Threaded Apartment >(STA)) depend on the application having an event loop. I have not looked at >the sources for PythonWin, but I have looked at the Python ones, and I did >not see any event loop servicing the event queue. This would explain why you >don't see the fired events. I have tried that - although without a window (note pythoncom exposes enough to run a message loop - win32event an even better one :) Also tried running within Pythonwin (so it has a window), but not as a control - still didnt work. Seemed to need some of the control container plumbing to be in place. Dont think I tried all of the threading models tho... Mark. From evan at tokenexchange.com Fri Apr 23 11:18:21 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Fri, 23 Apr 1999 10:18:21 -0500 Subject: Suggestion for alternative to map/filter functions References: Message-ID: Albert Hofkamp wrote: > Hello all, Hi, Albert! > While reading the tutorial, I noticed that Python has map and filter > functions. In our language we also had them, but they were replaced by > another language construct. > Unfortunately, I don't have time and experience enough to put this in > python myself, but if people are interested in it, I can provide details. What language are we speaking of here? I'm sure somebody here would be interested in a description of this mystery construct, if it's sufficiently elegant. Sorry, I find your post amusingly cryptic. It should be mentioned that map and filter (and especially their buddy lambda) are lonely immigrants from the land of functional programming, and are regarded with suspicion by many of the natives. a-construct-proposed-by-Fermat-in-the-margin?-ly y'rs Evan From Webmaster at cybersystems2000.com Tue Apr 27 19:49:49 1999 From: Webmaster at cybersystems2000.com (Webmaster at cybersystems2000.com) Date: Tue, 27 Apr 1999 23:49:49 GMT Subject: Msg for Moderator/Flamers Message-ID: I am a small business owner just trying to make a buck. I have attempted to filter out moderated news groups in an attempt to isolate only newsgroups that may not mind my unobtrusive, and occasional advertisement for http://cybersystems2000.com posted here. I sell a how to help style book. If I have been mis-informed and this is in fact a moderated news group, or you frequent this site and are offended by my request for visitors, PLEASE respond kindly to mailto:unsubscribe at cybersystems2000.com I will in turn immediately remove this news group from any further postings. From hew at hons.cs.usyd.edu.au Fri Apr 16 23:46:53 1999 From: hew at hons.cs.usyd.edu.au (Matthew Robert Gallagher) Date: Sat, 17 Apr 1999 13:46:53 +1000 Subject: Sleeping threads Message-ID: <3718042D.EE5D36A8@hons.cs.usyd.edu.au> I've been looking at threads and time but how do you sleep threads From justin at linus.mitre.org Thu Apr 15 14:54:53 1999 From: justin at linus.mitre.org (Justin Sheehy) Date: 15 Apr 1999 14:54:53 -0400 Subject: Different methods with same name but different signature? References: <3716909C.D8D1B372@fedex.com> Message-ID: frederic pinel writes: > My class needs to have 2 (or more) different methods, but with the same > name, the difference being the signature (an object in my case), Since you don't need to specify argument types in Python function definitions, what you describe is not reasonably possible. Python functions do not have signatures in the way that a C++ programmer means that term. In any case, I'd be willing to bet that you don't really need to have multiple functions with one name. You can simply make one function of that name, and have it branch or otherwise act appropriately based on the argument types. Not only is this nicer than the C++ way, it will probably be easier for someone else to understand when they read your code. I'll take Python's flavor of polymorphism over C++'s any day. No contest. -Justin From faassen at pop.vet.uu.nl Thu Apr 22 16:57:22 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Thu, 22 Apr 1999 22:57:22 +0200 Subject: What is it ? How can I learn it ? Where should I start ? Wha References: <371F7DB9.E7E48A82@callware.com> <1287305973-36728049@hypernet.com> Message-ID: <371F8D32.20535332@pop.vet.uu.nl> Gordon McMillan wrote: > > Ivan remembers... > > > ... and most of the real > > cannibals have been muzzled (Gordon excepted, so don't put any parts > > of you through his cage bars that you want to keep). ... > > and then forgets that I'm not poikilothermophagic... Another problem of Python is that it can be affected by evil alien white space eating nanoviruses. Anyway, the Python newsgroup has the right balance between civilized mature debate and complete whimsical fun. I supply the complete whimsicalness, others supply the maturity and fun. :) Regards, Martijn From nickb at earth.ox.ac.uk Fri Apr 23 13:54:01 1999 From: nickb at earth.ox.ac.uk (Nick Belshaw) Date: Fri, 23 Apr 1999 18:54:01 +0100 Subject: Style/efficiency question using 'in' Message-ID: <3720B3B9.98BED320@earth.ox.ac.uk> If someone could spare a mo to clarify - If I do something like :- ------------------ def func1(): return 1,2,3,4,5,6,7,8 for x in func1(): print x ------------------ it works as expected but is the use of a function in a loop undesirable? Is the function called once to build the loop or is it called each loop increment and therefore undesirable if there is much overhead? greatful for any comments cheers Nick/Oxford From f.geiger at vol.at Sat Apr 24 09:36:23 1999 From: f.geiger at vol.at (Franz GEIGER) Date: Sat, 24 Apr 1999 15:36:23 +0200 Subject: PythonCE Message-ID: <7fshcn$68n$1@pollux.ip-plus.net> Spam detection software, running on the system "albatross.python.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Is there a chance to have Tkinter someday on a CE machine. Or is it too mem consuming and impossible therefore? Regards Franz GEIGER Jeff Bauer wrote in message <3721380C.C545A15 at rubic.com>... >Rich Holm wrote: >> Does anyone know the status of PythonCE? I would like to get >> an updated copy, 1.5.2? Also, where is the source? I wouldn't >> mind recompiling and extending it. > >Brian Lloyd's original PythonCE port: > > http://www.digicool.com/~brian/PythonCE/ > >Mark Hammond has extended it: > > http://starship.python.net/crew/mhammond/ce/ > >PythonCE is stable, even useful for certain tasks, >especially http/ftp communication with your handheld. >The only drawback (IMO) is that a GUI application >will require you to write directly to the Win32/CE >API. Mark provides an excellent example of how >to do this -- he includes a shell written completely >in Python. > >Best regards, > >Jeff Bauer >Rubicon, Inc. [...] Content analysis details: (5.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 FH_DATE_IS_19XX The date is not 19xx. 3.6 TVD_SPACED_SUBJECT_WORD3 TVD_SPACED_SUBJECT_WORD3 -0.0 NO_RELAYS Informational: message was not relayed via SMTP -0.0 NO_RECEIVED Informational: message has no Received headers -------------- next part -------------- An embedded message was scrubbed... From: "Franz GEIGER" Subject: Re: PythonCE Date: Sat, 24 Apr 1999 15:36:23 +0200 Size: 1895 URL: From jeremy at cnri.reston.va.us Tue Apr 13 18:04:41 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Tue, 13 Apr 1999 22:04:41 GMT Subject: bug in PyGreSQL module In-Reply-To: References: <14099.24295.229214.504295@bitdiddle.cnri.reston.va.us> Message-ID: <14099.48588.851795.102448@bitdiddle.cnri.reston.va.us> I'm using PyGreSQL 2.3, Postgres 6.4.2, and Python 1.5.2b2 on RedHat Linux 5.2. (That's a lot of version numbers!) Here's an example of the error. I've extracted the three rows from a table (and gotten ride of the date because it's too wide). As you can see, in the first two rows the min, average, and max fields are empty. source|source_addr|dest|dest_addr|when|size|sent|recv|min|average|max ------+-----------+----+---------+----+----+----+----+---+-------+--- 19| 41| 6| 6|XXXX| 100| 10| 0| | | 19| 41| 6| 6|XXXX|1000| 10| 0| | | 19| 41| 6| 6|XXXX| 100| 10| 4|120| 184|245 If I perform the query in Python and then call the getresult method, I get back the following list: [(19, 41, 6, 6, 'Tue Apr 13 00:46:05 1999 EDT', 100, 10, 0, 0, 0, 0), (19, 41, 6, 6, 'Tue Apr 13 00:45:14 1999 EDT', 1000, 10, 0, 0, 0, 0), (19, 41, 6, 6, 'Tue Apr 13 00:16:05 1999 EDT', 100, 10, 4, 120, 184, 245)] The nulls have been converted to 0. This seems straightforward given the C code in getresult. If the field is an integer, the libpq value is always handed off to PyInt_FromLong. I would think that there should be an explicit check for NULLs in pg_getresult that converts them to None. Jeremy From evan at tokenexchange.com Thu Apr 22 13:52:51 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Thu, 22 Apr 1999 12:52:51 -0500 Subject: Pointers to variables References: <19990422121403.A279051@vislab.epa.gov> Message-ID: <8lJT2.17$eD1.14436@news.corridex.com> Randall Hopper wrote in message <19990422121403.A279051 at vislab.epa.gov>... [snip] > How can I cause a reference to the variables to be stored in the tuples instead of their values? You can't, or at least not directly. What you *can* do, in the case you provided, is something like this: for ( attrname, k ) in [( 'min', 'min_units' ), ( 'max', 'max_units' )]: if cnf.has_key( k ): setattr(self, attrname, cnf[ str ]) del cnf[ str ] Python simply doesn't *have* variables in the sense you're thinking of, with the exception of function-local variables. Instead it has namespaces, such as modules, classes, and instances. These can be usefully be thought of as dictionaries with efficient string-only keys, and can be manipulated as such using getattr, setattr, delattr, etc. Function-local-variables-are-a-whole-nother-alien-world-ly yrs, Evan Simpson From markus_kohler at hp.com Thu Apr 29 04:35:50 1999 From: markus_kohler at hp.com (Markus Kohler) Date: 29 Apr 1999 10:35:50 +0200 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> <372769B0.3CE8C0F3@prescod.net> Message-ID: >>>>> "William" == William Tanksley writes: William> On Wed, 28 Apr 1999 20:04:00 GMT, Paul Prescod wrote: >> William Tanksley wrote: >>> And Oberon (SlimBinaries), and Eiffel (typing and general >>> compile-time error catching), and ... >> Actually, isn't Eiffel's type system famous for being full of >> holes? William> I'm familiar with the covariance/contravariance argument, William> but I've never before heard anyone say anything about William> Eiffel being full of holes. What problems have you heard William> of? As far as I remember Eiffel requires a global system analysis to be type safe at compile time. >> Regardless, wouldn't a better source of inspiration on typing >> be a language with *optional* compile-time error checking? William> Good question. I don't know the answer, but I can point William> out the dangers of not planning our path. William> One dangerous side of allowing flexibility is that we William> could be like C++, where the safe way of doing anything William> requires more typing and often causes incompatibilities. William> Examples range from virtual functions; through inline William> functions, templates, single-root object hierarchy, and William> garbage collection; to covariance/contravariance. William> The other dangerous side, of course, is being one of the William> languages which are so safe you can't use them without a William> huge manual and pages of UML. Python can NOT wind up William> like this, regardless of the dangers obvious in the other William> side. Agreed. The main problem with todays statically typed languages is that they are too restrictive and to complicated. William> Let me expand a little on the dangers of C++. William> - virtual functions. It shouldn't be my job to tell the William> compiler when virtual lookups are the only thing to do; William> the compiler ought to be able to tell. For performance William> gurus, a way to hint to the compiler that virtual lookups William> were _not_ needed might be useful -- but what if the William> programmer was wrong? True, SmallEiffel inlines most of the virtual function calls automatically. This is the way to go. William> - inline functions. Again, a good compiler HAS to make William> this decision for itself, and in a good compiler, whether William> or not this decision was made should be transparent to William> the programmer. Agreed. William> - templates. Generic functions are a very good thing, William> and with Python 2's type support we might wind up needing William> them. In C++, templates are also a very good thing, but William> thanks to the C model of seperate compilation, no two C++ William> compilers handle templates compatibly. The C/C++ compilation model is outdated. Python should *never* adapt that. William> - single-root object hierarchy -- this is a must when the William> default binding is virtual. William> - GC -- hard to add after the fact. No worry with William> Python, but what if there are other issues like it? I'm not sure if I understand this sentence. Do you mean GC is hard to add to python without breaking existing code ? I would agree with that. And why do you say "no worry" Do you mean GC is not worth the effort ? William> - covariance/contravariance/"no"variance -- when a William> subclass redefines a function, what types of input William> parameters can the redefinition accept? In C++, you William> can't accept a different type without overloading the William> function. With covariance (in Sather) you can allow the William> redefined function to accept a parent class, which allows William> the new function to handle more subclasses (including all William> the ones the old function handled). With contravariance William> you can require the redefinition to be more specific, William> accepting fewer classes. Aside from my obvious dislike William> of novariance, I'm not going to take sides ;-). You may have a look at Strongtalk a Smalltalk with static (optional) type checking. Sorry no links, but if a www search does not work I can sent you a document about it. Markus -- Markus Kohler mailto:markus_kohler at hp.com From sandsmark at iname.com Sun Apr 25 20:30:17 1999 From: sandsmark at iname.com (Even) Date: Mon, 26 Apr 1999 00:30:17 GMT Subject: unsubscribe Message-ID: <3723B399.2494EA2E@iname.com> unsubscribe From jmrober1 at ingr.com Fri Apr 23 09:32:53 1999 From: jmrober1 at ingr.com (Joseph Robertson) Date: Fri, 23 Apr 1999 08:32:53 -0500 Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> Message-ID: <37207685.F29BE1AB@ingr.com> Hi, For what you state here, you don't even really need to read the 'data' at all. Just read your descriptors, and store the offsets and len of the data in a dictionary (i.e. index it). readline if first char == > get id get current position using seek method store id, pos in dict #for each id, we now have its byte posisition in the file Then have a filter method which keeps or discards the records by criteria. for each key in dict if key passes filter test store key in filtered dict Then only at the time you really need that data do you go get it. for each in filtered_dict use seek to position read data until next line with > at 0 This way you can create views on your data without actually trying to load it all. The tradeoff of course is memory for fileaccess time, but I found fileaccess to be faster than doing all the work 'up front'. Besides my project reached the point where we ran out of memory often, some datasets are on 8+ cdroms! Hope that was relevant, but maybe I misunderstood the question. Joe Robertson, jmrobert at ro.com Arne Mueller wrote: > Hi All, > > first off all: Sorry for that slightly provoking subject ;-) ... > > I just switched from perl to python because I think python makes live > easyer in bigger software projects. However I found out that perl is > more then 10 times faster then python in solving the following probelm: > > I've got a file (130 MB) with ~ 300000 datasets of the form: > > >px0034 hypothetical protein or whatever description > LSADQISTVQASFDKVKGDPVGILYAVFKADPSIMAKFTQFAGKDLESIKGTAPFETHAN > RIVGFFSKIIGELPNIEADVNTFVASHKPRGVTHDQLNNFRAGFVSYMKAHTDFAGAEAA > WGATLDTFFGMIFSKM > > The word floowing the '>' is an identifier, the uppercase letters in the > lines following the identifier are the data. Now I want to read and > write the contens of that file excluding some entries (given by a > dictionary with identifiers, e.g. 'px0034'). > > The following python code does the job: > > from re import * > from sys import * > > def read_write(i, o, exclude): > name = compile('^>(\S+)') # regex to fetch the identifier > l = i.readline() > while l: > if l[0] == '>': # are we in new dataset? > m = name.search(l) > if m and exclude.has_key(m.group(1)): # excluding current > dataset? > l = i.readline() > while l and l[0] != '>': # skip this dataset > l = i.readline() > pass > o.write(l) > l = i.readline() > > f = open('my_very_big_data_file','r') # datafile with ~300000 records > read_write(f, stdout, {}) # for a simple test I don't exclude anything! > > It took 503.90 sec on a SGI Power Challange (R10000 CPU). An appropiate > perl script does the same job in 32 sec (Same method, same loop > structure)! > > Since I've to call this routine about 1500 times it's a very big > difference in time and not realy accaptable. > > I'd realy like to know why python is so slow (or perl is so fast?) and > what I can do to improove speed of that routine. > > I don't want to switch back to perl - but honestly, is python the right > language to process souch huge amount of data? > > If you want to generate a test set you could use the following lines to > print 10000 datasets to stdout: > > for i in xrange(1, 10001): > print > '>px%05d\nLSADQISTVQASFDKVKGDPVGILYAVFKADPSIMAKFTQFAGKDLESIKGTAPFETHAN\n\ > RIVGFFSKIIGELPNIEADVNTFVASHKPRGVTHDQLNNFRAGFVSYMKAHTDFAGAEAA\n\ > WGATLDTFFGMIFSKM\n' % i > > And if you don't believe me that perl does the job quicker you can try > the perl code below: > > #!/usr/local/bin/perl -w > open(IN,"test.dat"); > my %ex = (); > read_write(%ex); > > sub read_write{ > > $l = ; > OUTER: while( defined $l ){ > if( (($x) = $l =~ /^>(\S+)/) ){ > if( exists $ex{$x} ){ > $l = ; > while( defined $l && !($l =~ /^>(\S+)/) ){ > $l = ; > } > next OUTER; > } > } > print $l; > $l = ; > } > } > > Please do convince me being a python programmer does not mean being slow > ;-) > > Thanks very much for any help, > > Arne From tim_one at email.msn.com Sun Apr 25 15:00:03 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 25 Apr 1999 15:00:03 -0400 Subject: possible bug in 1.5.1 In-Reply-To: <37234712.2E95BC37@stat.ubc.ca> Message-ID: <000401be8f4d$d3ac70e0$d39e2299@tim> [Tim] > ... > What you can do is save away the attached as (e.g.) ieee.py, then > in your code do > > from ieee import PINF # positive infinity, if it exists Oops -- the attachment got lost due to a rounding error . Here: def _make_inf(): x = 2.0 x2 = x * x i = 0 while i < 100 and x != x2: x = x2 x2 = x * x i = i + 1 if x != x2: raise ValueError("This machine's floats go on forever!") return x PINF = _make_inf() MINF = -PINF NAN = PINF - PINF if 1.0 + NAN == 1.0: raise ValueError("This machine doesn't have NaNs, " "'overflows' to a finite number, " "or is 754-conformant but is using " "a goofy rounding mode.") PZERO = 0.0 MZERO = -PZERO From akuchlin at cnri.reston.va.us Mon Apr 26 11:11:14 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Mon, 26 Apr 1999 11:11:14 -0400 (EDT) Subject: Python too slow for real world In-Reply-To: References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> Message-ID: <14116.27076.739392.393714@amarok.cnri.reston.va.us> Moshe Zadka writes: >2. re.py is a (very thin) wrapper around pcre, a C extension module for >Perl Compatible Regular Expressions. > >Which just goes to say that while pcre can certainly be optimized, it >can't be done by simply rewriting it in C. Things like search-and-replace, though, take substantial hits from being implemented in Python code; rewriting re.py in C is one of the top items on my TODO list for the regex code. I also want some sort of code generation interface so that custom syntaxes can be implemented. The problem there is how to do it safely so that it's not possible to crash the interpreter by generating buggy expressions. (We'd want the re module usable by code in a restricted execution environment, after all.) >but-we-can-always-call-Perl-on-the-fly-to-evaluate-regular-expression-ly >y'rs, In one early experiment, there was a version of the regex module that used Perl's pregcomp() and pregexec() functions. It worked fine in some admittedly limited testing, but the compiled module was something like 500K because the regex code pulled in the rest of Perl. I couldn't figure out how to extract the regex code to fix this, so that experiment came to a quick end. Pity, really. -- A.M. Kuchling http://starship.python.net/crew/amk/ You see, you're all wrong. My name isn't Brain Eater. I am the Head. And I don't simply eat brains. It's something deeper than that. Something magical. Something transubstantiational. Excuse me one moment while I ... -- The first villain, in ENIGMA #1: "The Lizard, The Head, The Enigma" From SSTirlin at holnam.com Wed Apr 28 12:49:55 1999 From: SSTirlin at holnam.com (Scott Stirling) Date: Wed, 28 Apr 1999 12:49:55 -0400 Subject: HTML "sanitizer" in Python Message-ID: Hi, I am new to Python. I have an idea of a work-related project I want to do, and I was hoping some folks on this list might be able to help me realize it. I have Mark Lutz' _Programming Python_ book, and that has been a helpful orientation. I like his basic packer and unpacker scripts, but what I want to do is something in between that basic program and its later, more complex manifestations. I am on a Y2K project with 14 manufacturing plants, each of which has an inventory of plant process components that need to be tested and/or replaced. I want to put each plant's current inventory on the corporate intranet on a weekly or biweekly basis. All the plant data is in an Access database. We are querying the data we need and importing into 14 MS Excel 97 spreadsheets. Then we are saving the Excel sheets as HTML. The HTML files bloat out with a near 100% increase in file size over the original Excel files. This is because the HTML converter in Excel adds all kinds of unnecessary HTML code, such as for every single cell in the table. Many of these tables have over 1000 cells, and this code, along with its accompanying closing FONT tag, add up quick. The other main, unnecessary code is the ALIGN="left" attribute in

tags (the default alignment _is_ left). The unnecessary tags are consistent and easy to identify, and a routine should be writable that will automate the removal of them. I created a Macro in Visual SlickEdit that automatically opens all these HTML files, finds and deletes all the tags that can be deleted, saves the changes and closes them. I originally wanted to do this in Python, and I would still like to know how, but time constraints prevented it at the time. Now I want to work on how to create a Python program that will do this. Can anyone help? Has anyone written anything like this in Python already that they can point me too? I would really appreciate it. Again, the main flow of the program is: >> Open 14 HTML files, all in the same folder and all with the .html extension. >> Find certain character strings and delete them from the files. In one case (the tags) it is easier to find the whole tag with attributes and then _replace_ the original tag with a plain . >> Save the files. >> Close the files. >> Exit the program. More advanced options would be the ability for the user to set parameters for the program upon running it, to keep from hard-coding the find and replace parms. OK, thanks to any help you can provide. I partly was turned on to Python by Eric Raymond's article, "How to Become a Hacker" (featured on /.). I use Linux at home, but this program would be for use on a Windows 95 platform at work, if that makes any difference. I do have the latest Python interpreter and editor for Windows here at work. Yours truly, Scott Scott M. Stirling Visit the HOLNAM Year 2000 Web Site: http://web/y2k Keane - Holnam Year 2000 Project Office: 734/529-2411 ext. 2327 fax: 734/529-5066 email: sstirlin at holnam.com From mark at chem.uwa.edu.au Wed Apr 28 00:42:36 1999 From: mark at chem.uwa.edu.au (Mark C Favas) Date: 28 Apr 99 04:42:36 GMT Subject: FP exception, core dump in Python 1.5.2 (Tim's doing ) Message-ID: [Tim Peters suggests some code to generate INFs and NANs] >def _make_inf(): > x = 2.0 > x2 = x * x > i = 0 > while i < 100 and x != x2: > x = x2 > x2 = x * x > i = i + 1 > if x != x2: > raise ValueError("This machine's floats go on forever!") > return x >PINF = _make_inf() >MINF = -PINF >NAN = PINF - PINF >if 1.0 + NAN == 1.0: > raise ValueError("This machine doesn't have NaNs, " > "'overflows' to a finite number, " > "or is 754-conformant but is using " > "a goofy rounding mode.") >PZERO = 0.0 >MZERO = -PZERO [Mark tries it, and...] On my platform, (DEC Alpha, Digital Unix 4.0D, Python 1.5.2) I get... a core dump! (exclamation because it's one of the few Python core dumps I've seen). [code modified to print i, x, x2] python ieee.py 0 2.0 4.0 1 4.0 16.0 2 16.0 256.0 3 256.0 65536.0 4 65536.0 4294967296.0 5 4294967296.0 1.84467440737e+19 6 1.84467440737e+19 3.40282366921e+38 7 3.40282366921e+38 1.15792089237e+77 8 1.15792089237e+77 1.34078079299e+154 Floating exception (core dumped) Python 1.5.2 (#1, Apr 17 1999, 05:27:57) [C] on osf1V4 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> dbx /usr/local/bin/python core dbx version 3.11.10 Type 'help' for help. Core file created by program "python" thread 0x5 signal Floating point exception at >*[nxm_thread_kill, 0x3ff8058a608] ret r31, (r26), 1 (dbx) where > 0 nxm_thread_kill(0x140081940, 0x0, 0x1400b13c0, 0x0, 0x3ff00000000) [0x3ff8058a608] 1 pthread_kill(0x0, 0x0, 0x11fffef20, 0x3ffc018a888, 0x3ff00000000) [0x3ff80577998] 2 (unknown)() [0x3ff8056c234] 3 (unknown)() [0x3ff807b22d8] 4 (unknown)() [0x3ff807b3824] 5 exc_unwind(0x3ff800d4544, 0x11fffdfe0, 0xabadabad00beed00, 0x1400b13c0, 0x3ff807b3af4) [0x3ff807b3864] 6 exc_raise_signal_exception(0x86, 0x0, 0x12005b218, 0x1, 0x8) [0x3ff807b3af0] 7 (unknown)() [0x3ff80578cc8] 8 PyFloat_FromDouble(0x0, 0x0, 0x12006f404, 0x14005c770, 0x1200533cc) [0x12005b214] 9 PyNumber_Multiply(0x1400b2988, 0x1400b13c0, 0x1400b13c0, 0x0, 0x3) [0x12006f400] (dbx) -- Email - mark at chem.uwa.edu.au ,-_|\ Mark C Favas Phone - +61 9 380 3482 / \ Department of Chemistry Fax - +61 9 380 1005 ---> *_,-._/ The University of Western Australia v Nedlands Loc - 31.97 S, 115.81 E Western Australia 6009 From email at domain.com Mon Apr 5 00:39:21 1999 From: email at domain.com (SH) Date: Mon, 05 Apr 1999 04:39:21 GMT Subject: help References: <7e1fr0$6cio$1@titan.xtra.co.nz> Message-ID: In article , bwinton at iname.com wrote: > On Fri, 2 Apr 1999 15:58:52 +1200, nfbb wrote: > >Hi there - I'm running Windows 98 and was wondering what the best program > >for writing python Source code is under this operating system? > > I like vim, but I come from a Unix background, and if you don't already > know vim, you'ld probably be better starting off with something else. > > IDLE (Guido's IDE) is also up on my favourites list. > > Later, > Blake. Where do you find the latest IDLE? Searches on the web are not helpful, and on the Python.org site the search points to the CVS directories? thanks From ivanlan at callware.com Tue Apr 27 17:42:29 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 27 Apr 1999 21:42:29 GMT Subject: Long integers getting short shrift? References: <14118.9093.292465.438475@buffalo.fnal.gov> Message-ID: <37262F45.2473F5A5@callware.com> Hi All-- Charles G Waldman wrote: > > The functions Py_BuildValue and PyArg_ParseTuple don't seem to be > listed in the index of the Python/C API documentation. They are only > described in the Embedding and Extending docs. > > The "L" format code for Long integers is not described anywhere, > AFAICT. I discovered it by reading source. > > It seems that if you are on a system without the "long long" type then > the "L" format char is not available. ???? I have Python running on my UnixWare system at home, and the long types are easily accessible. Python's been running on it since 1.3, and UnixWare has no long long type. Long doubles, but no long long. (By the way, the UnixWare system is going to die on 10 May, when Redhat 6.0 with 2.2 kernel and SMP out of the box appears in the stores.) Now, possibly this is a difference between the running interpreter and the functions available for building extensions, but if so, why the difference? -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From fredrik at pythonware.com Tue Apr 13 11:58:41 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 13 Apr 1999 15:58:41 GMT Subject: Help: Tkinter, bad event type References: <37134F3B.8C583E0@btk.utu.fi> Message-ID: <002b01be85c6$8d62bdf0$f29b12c2@pythonware.com> M?rten Hedman wrote: > I'm running Python 1.5.2c1 under Win NT with SP4 and Tcl/Tk 8.05. When I > try to run any script that uses Tkinter, even hello.py from the Tkinter > Life Preserver, I get two identical error messages: > > bad event type or keysym "MouseWheel" > while executing "bind Listbox ..." invoked from > /listbox.tcl > ... > invoked from /tk.tcl > > I can work around this by editing listbox.tcl and commenting out the > "bind Listbox ..." statement, but I have to do this every > time I install a new version of Tcl/Tk, and it's annoying. looks like you pick up the wrong Tcl/Tk DLL's when running Python. better double-check your installation. From bwarsaw at cnri.reston.va.us Thu Apr 29 18:24:44 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 29 Apr 1999 18:24:44 -0400 (EDT) Subject: Emacs' python-mode buggy? References: <7g8np4$kvf@chronicle.concentric.net> <000901be9203$b4c32e40$199e2299@tim> <14120.31856.181562.574382@anthem.cnri.reston.va.us> Message-ID: <14120.56364.428261.2514@anthem.cnri.reston.va.us> For some reason you're still using hilite to do your syntax coloring. You should trash hilite immediately and start using font-lock, which is standard in Emacs and XEmacs now. Unfortunately I can't help you much with the transition. I don't use Emacs and I never used hilite (XEmacs never had it). Check on comp.emacs or gnu.emacs.help for details. -Barry From markus_kohler at hp.com Fri Apr 30 03:31:51 1999 From: markus_kohler at hp.com (Markus Kohler) Date: 30 Apr 1999 09:31:51 +0200 Subject: Python IS slow ! [was] Re: Python too slow for real world References: <613145F79272D211914B0020AFF6401914DAD8@gandalf.digicool.com> Message-ID: >>>>> "Mitchell" == Mitchell Morris writes: [deletia] Mitchell> If it's not too much trouble, could you post your Mitchell> benchmark code and results, either here or on a web Mitchell> page? Of course I only did useless microbenchmarks ;-) One was : # benchmark in Python # see # Keith Waclena def tak (x, y, z): if not(y < x): return z else: return tak(tak(x-1, y, z), tak(y-1, z, x), tak(z-1, x, y)) this is usally a pretty good tests of function call speed. Since in Smalltalk really everything is object oriented I could not just define a global function that is not a method of some class. Therefore I decided to use class methods and introduce a class TestRec just for that : takx: x y: y z:z "Test function call speed" ^(y Message-ID: On Mon, 26 Apr 1999, Ivan Van Laningham wrote: > > I always sound like that too, don't worry. :) (they're calling me a > > Python preacher these days, at work) > > > > Regards, > > > > Martijn > > Oh, they won't even let me talk in meetings around here anymore. I just > *look* like I'm going to open my mouth and they all yell, ``Yes, we > *know* we should use Python!'' Don't we all know that feeling? Just to contribute to the ``preaching python and getting hit for it'' thread, I wanted to mention that I managed to create a position which will need Python knowledge, and now some people are learning Python, just to make sure they can maintain my code. And they don't even know I'm doing them a favour... -- Moshe Zadka . QOTD: My own exit is more likely to be horizontal then perpendicular. From claird at Starbase.NeoSoft.COM Fri Apr 2 16:56:58 1999 From: claird at Starbase.NeoSoft.COM (Cameron Laird) Date: 2 Apr 1999 15:56:58 -0600 Subject: Dealing with faults matters (was: Is Python dying?) References: <7ds2g4$cm8$1@Starbase.NeoSoft.COM> <000901be7b41$cdc84f20$f19e2299@tim> <7dt2pv$1mj$1@Starbase.NeoSoft.COM> <3706f449.12085377@news.cybercity.dk> Message-ID: <7e3efa$j7v$1@Starbase.NeoSoft.COM> In article <3706f449.12085377 at news.cybercity.dk>, Morten Christensen wrote: >On 31 Mar 1999 06:01:03 -0600, claird at Starbase.NeoSoft.COM (Cameron >Laird) wrote: >>*I* certainly discuss it. Anyone who understands >>that exception-handling is important I invite to >>realize that exception-handling on the sociologi- >>cal-organizational dimension has an even bigger >>multiplier. >> >>This is a plank of my "Visual C considered profes- >>sional malpractice" campaign. > >??? > >...I understand exception handling and regard it as very important, >although the (Visual) C++ implementation is really awful (as everyone >who have experienced "unexplainable" Visual C++ exceptions of unknown >origin and type knows ).... I also know a lot about how exception >handling is actually implemented in modern OO languages such as C++ >(this was the subject I wrote my master thesis on).... > >HOWEVER, I have NO clue about what you mean by exception-handling as a >multiplier on the sociological-organization dimension :-) I would like >to find out. Can you explain? . . . Happily. Excuse my giddiness, please; I see that that last message *did* wander too far into the land of obscurity. Here's what I was saying: exception-handling is important. Programs that intelligently use exception-handling mechanisms are better programs. Exception-handling is even more important to people. People and organizations that deal with exceptions intelligently, and don't pre- tend that everything should be without fault, are better people and organizations. In fact, a correct computer program often has over half its lines devoted to accomo- dating error. A wise person will have good ways to respond to criticism/problems/diffi- culties/...; dealing with success is relatively easier. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From morse at harborcom.net Thu Apr 22 07:28:33 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Thu, 22 Apr 1999 11:28:33 GMT Subject: Controlling Linux serial port w/ Python ... - posixport.py (0/1) References: <924762349.809295488@news.intergate.bc.ca> Message-ID: <371f0721.156454028@news.oh.verio.com> Gerald Gutierrez wrote: >I'd like to do some modem I/O via Python. Mostly, the interactions would be >similar to what "chat" in the ppp package may do; send/recv data, flipping DTR, >setting speed, etc. > >I understand that POSIX termios, for which Python has a binding, may be able to >do this. Can someone point me to an example somewhere? Alternatively, can >someone direct me to where this type of information is available? Here's some code that will get you partially there. It doesn't handle the control lines though. From seitz at mail.medscape.com Tue Apr 13 18:04:06 1999 From: seitz at mail.medscape.com (seitz at mail.medscape.com) Date: Tue, 13 Apr 1999 22:04:06 GMT Subject: stupid Win-CGI getting started question Message-ID: <7f0f0h$pfb$1@nnrp1.dejanews.com> Installed the basic Python stuff. I can run the interpreter. But not clear on getting it configured properly to talk CGI with my WinNT Netscape Enterprise server. I set a CGI folder path properly, but I get a nasty error message. But it's not a file-not-found, so I know it's finding the .py file. So I'm guessing it's not finding the executable. How should that first #! be changed for Windows users? Could that be it? Could the fact that all my Python stuff is under d:\program files\python\ be part of the problem (the long folder name with a space in it)? -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From mss at anguish.transas.com Tue Apr 13 07:59:43 1999 From: mss at anguish.transas.com (Michael Sobolev) Date: 13 Apr 1999 11:59:43 GMT Subject: CVS module Message-ID: <7evbjf$85f$1@anguish.transas.com> My quick attempt to find something that would help me to cope with CVS files failed. Could anybody advise me whether such a module exist? Under "such a module" I mean something that permits to get the complete information about the given file: cvsfile = CVSFile () from pprint import pprint pprint (cvsfile.revisions) or something alike. Thanks, -- Mike From gmcm at hypernet.com Tue Apr 6 21:26:23 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 7 Apr 1999 01:26:23 GMT Subject: Unable to register TclNotifier window class Message-ID: <1288673916-74845510@hypernet.com> OK Tk wizards (hi, /F-bot!) I'm getting "Unable to register TclNotifier window class". What does this mean? Details: Python 1.5.2b2 on NT SP4 I'm doing a tree control / form style window: a big frame another frame, packed 'left' with a Pmw.ScrolledListBox acting as a tree control. Then I have three different frames, each holding a "form" for displaying / editing a particular record type. When a new item in the tree control is selected, I "pack_forget" (if the record type has changed) the right hand frame, then "pack" the appropriate frame and fill the form. Works dandy for 2 of the three forms. Actually, the problem form fills properly, too, it just does a St Vitus dance until I kill the whole app (it appears to be continually re-packing itself). My console window has the mystery error. The problem form is the most complex (has the most widgets), but otherwise they are all clones of each other. - Gordon From joe at strout.net Tue Apr 27 16:06:20 1999 From: joe at strout.net (Joe Strout) Date: Tue, 27 Apr 1999 13:06:20 -0700 Subject: examples for beginners References: <3724e511.441513@news.tin.it> Message-ID: In article <3724e511.441513 at news.tin.it>, Kranio wrote: > Could you suggest me where to find some script just for studying? http://www.strout.net/python/tidbits.html Cheers, -- Joe P.S. I'd send you a private reply, but it looks like your return address is bogus. Please don't munge headers; it's very rude, in violation of Internet standards, and mostly pointless anyway. -- ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' Check out the Mac Web Directory! http://www.strout.net/macweb.cgi From tim_one at email.msn.com Sat Apr 3 02:54:56 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 3 Apr 1999 07:54:56 GMT Subject: Lauch program in the same shell In-Reply-To: <816010E2456BD111A48700805FBBE2EEBBC0AA@ex-quebec-u1.baan.com> References: <816010E2456BD111A48700805FBBE2EEBBC0AA@ex-quebec-u1.baan.com> Message-ID: <000401be7da7$43f20ee0$879e2299@tim> [Martin Tremblay] > Version: 1.51 > Env: Nt > > In a script, I want to lauch an executable in the same shell, > wait that this executable finish and launch another executable. > I've try with execlp but the executable isn't lauch in the same > shell as the script and the script exit when the exec is launch > (so I can't lauch any other executable in this script). > > I'm sure there is an easy way to do what I want... Try os.system("some command"), or if that doesn't work either be very specific by posting executable code that demonstrates your problem. i-thought-execlp-would-be-useful-until-it-was-added-ly y'rs - tim From MHammond at skippinet.com.au Tue Apr 6 19:36:21 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 7 Apr 1999 09:36:21 +1000 Subject: Embedding python question: PyRun_String only returns None not what I calculate References: <923433832.14002.0.nnrp-07.9e982a40@news.demon.co.uk> Message-ID: <7ee5pk$qkm$1@m2.c2.telstra-mm.net.au> Hopefully someone with more time can give a better answer... But the short story is that PyRun_String works with statements, not expressions. You can use it to, eg, import modules, and even call functions, but you cant get the result. To see the difference, try from a Python prompt: >>> cmd = "1+1" >>> exec cmd >>> eval(cmd) You will notice that the functionality you are after is by evaluating objects. Thus, you need to use a different Python API. Mark. Barry Scott wrote in message <923433832.14002.0.nnrp-07.9e982a40 at news.demon.co.uk>... >What I want to do is call python to run python code and return the results >to >my app. But I cannot find anyway to do this. > >It would seem that I should be using PyRun_String to run a piece of python >and return a result object to me. But I can only get a return value of None. >NULL is returned if the code does not run. > >How do I get python to return 2 to me when I ask it what 1+1 is? From jbauer at rubic.com Thu Apr 29 19:54:33 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Thu, 29 Apr 1999 23:54:33 GMT Subject: Python and Perl (was: converting perl to python) References: Message-ID: <3728F139.75BD1D6B@rubic.com> Ben Caradoc-Davies wrote: > Perl is a fertile breeding ground for Pythonistas. I'm sure > many expand into Python from Perl. Count me as one such user. I started using Perl for sysadmin tasks back in the early 90's. From there I expanded to database management, text-mode UI's, code generation, etc. My experience with Perl gave me the courage to "bet the farm" on business projects with Python, starting in 1994. One other debt I must acknowledge. Prior even to Perl, I had many pleasant experiences using Awk. Does anyone remember Jon Bentley's "Confessions of a Coder" books? Marvelous stuff. all-this-and-C++-too-ly yr's Jeff Bauer Rubicon, Inc. From gornauth at dds.nl Fri Apr 23 09:37:20 1999 From: gornauth at dds.nl (Gornauth) Date: Fri, 23 Apr 1999 15:37:20 +0200 Subject: opening more than 1 file References: <371CB255.5FCAFBAF@solair1.inter.NL.net> <371CCAE0.7DE87F8A@aw.sgi.com> Message-ID: <7fpteh$cik$1@news1.xs4all.nl> Gary Herron wrote in message <371CCAE0.7DE87F8A at aw.sgi.com>... >If your definition of `elegant' includes `short', here is a one-liner to >do this. It maps a list [0,1,2,...] to a list of open files: > >[, > , > , > ...] > >files = map(lambda i: open("file%02d"%i, 'w'), range(N)) I'm not completely sure how that one-liner works. To be honest, I have no clue whatsoever. Could someone more python-literate please be so kind as to give a couple of examples on how to use 'map' and 'lamba'? Met vriendelijke groeten, Hans From fredrik at pythonware.com Thu Apr 15 04:52:38 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Apr 1999 08:52:38 GMT Subject: Tkinter: making a window unresizable (Win 95) References: <7f3hpt$e64$1@nnrp1.dejanews.com> Message-ID: <005901be871d$ecf7b290$f29b12c2@pythonware.com> wrote: > Toplevels in Tkinter in Windows-95 come with > the resizing button on the upper-right corner, > next to the iconify and close buttons. > > Even if I use resizable(0,0) method of the > Tkinter.Toplevel class, the resizing button > still persists. And when I click on it, although the > window now does not resize, it still flickers and > moves around. This is kind of annoying. > > Is there a way of creating a non-resizable > Toplevel in Tkinter more easily? Namely, is there > a way to eliminate the resizing button completely? not sure, but I think this has been fixed in a recent version of Tk (8.0.5? 8.1b3?). From kranio at nospam.nospam.it Wed Apr 21 06:36:04 1999 From: kranio at nospam.nospam.it (Kranio) Date: Wed, 21 Apr 1999 10:36:04 GMT Subject: Beginner - Tkinter info References: <371c59e9.2723125@news.tin.it> <371B453E.C3F83831@foreman.ac.rwth-aachen.de> Message-ID: <371da9f4.287834@news.tin.it> On Mon, 19 Apr 1999 17:01:18 +0200, Greg Landrum wrote: tnx for your support Marco From gscot at my-dejanews.com Thu Apr 8 01:19:55 1999 From: gscot at my-dejanews.com (gscot at my-dejanews.com) Date: Thu, 08 Apr 1999 05:19:55 GMT Subject: Internet Robot Message-ID: <7ehe9m$hbs$1@nnrp1.dejanews.com> To All, I would like to write a Python robot to play an Internet game. I do not know how to make a POST request. Thanks to anyone in advance that can point me in the right direction. Gary -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From arw at ifu.net Fri Apr 9 12:20:00 1999 From: arw at ifu.net (arw) Date: Fri, 9 Apr 1999 16:20:00 GMT Subject: GadFly - MemoryError Message-ID: <199904091623.MAA24288@ifu.ifu.net> My guess is that you have a lot of url matches and gadfly is doing what you ask it to do. Could be wrong. Rewriting the query might help, as suggested elsewhere. If you want to discuss this further I don't think we need copy the list. With 3000 entries you have a potential 9M matches. Please try this select url, count(*) from table group by url order by 1 desc And have a look at how many redundancies you have. This query should run faster, I hope. We could take this kind of discussion offline, if you like. :) -- Aaron Watters ----Original Message----- >From: Oleg Broytmann >To: arw >Cc: Python Mailing List >Subject: RE: GadFly - MemoryError >Reply-To: phd at sun.med.ru >Date: Wednesday, April 07, 1999 4:16 AM > >Hello! > >On Mon, 5 Apr 1999, arw wrote: >> I don't know why you have this problem. >> Gadfly should not construct the cross product with >> the equality you mention present. >> (b1.URL = b2.URL) > > I freed some memory and the program worked. It ate 30 Megs while running, >so I was in need of memory. But it ran 30 minutes (on 3000 rows!) > >> Please try adding an index on URL on the table >> in question. Also, maybe try increasing your virtual >> memory (page file size, or whatever). > > Indices or compiled kjbuckets was not of big help - instead of running >35 minutes the program ran 30. I think, my computer spent more time >swapping, not working. > >> Good luck. fwiw, I've definitely run tables with >> 100k rows in Gadfly on a 64Meg machine. >> -- Aaron Watters > > You are in luck. > >> ps: let me know how it goes. > > Not so good. I think I would not use gadfly, at least for this project >(currently I am using very simple "database", that stored in text files. Of >course, I cannot make complex requests, sucj as joins). > >Oleg. >---- > Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ > Programmers don't die, they just GOSUB without RETURN. > > > From ping at lfw.org Tue Apr 13 08:38:40 1999 From: ping at lfw.org (Ka-Ping Yee) Date: 13 Apr 1999 12:38:40 GMT Subject: Python console (please play) Message-ID: <7evdsg$sfh$1@camel29.mindspring.com> Hi, all. I know it's been a long while since i last posted here, but i have been hacking lots of Python all the while. It's just that i mostly don't get to give it away. Well, here's a little late-night hack i whipped up. Thought you might enjoy it, so i'll post it here. It all started with my annoyance at being forced to paste code into the Python interpreter one line at a time because the prompts foul things up. But there is plenty of boasting in the doc string, so i'll not add any more words here. Do let me know how you like it. !ping I never dreamt that i would get to be The creature that i always meant to be But i thought, in spite of dreams, You'd be sitting somewhere here with me. ----------%<----------%<-------Console.py--------%<----------%<---------- """A Tkinter-based console for conversing with the Python interpreter, featuring more tolerant pasting of code from other interactive sessions, better handling of continuations than the standard Python interpreter, highlighting of the most recently-executed code block, the ability to edit and reexecute previously entered code, a history of recently-entered lines, and automatic multi-level completion with pop-up menus. Ka-Ping Yee , 10 April 1999. This software is in the public domain and is provided without express or implied warranty. Permission to use, modify, or distribute the software for any purpose is hereby granted.""" # TODO: autoindent to matching bracket after an unbalanced line (hard) # TODO: outdent after line starting with "break", "raise", "return", etc. # TODO: keep a stack of indent levels for backspace to jump back to # TODO: blink or highlight matching brackets # TODO: delete the prompt when joining lines; allow a way to break lines from Tkinter import * import sys, string, traceback, types REVISION = "$Revision: 1.3 $" VERSION = string.split(REVISION)[1] class OutputPipe: """A substitute file object for redirecting output to a function.""" def __init__(self, writer): self.writer = writer self.closed = 0 def __repr__(self): return "" % repr(self.writer) def read(self, length): return "" def write(self, data): if not self.closed: self.writer(data) def close(self): self.closed = 1 class Console(Frame): def __init__(self, parent=None, dict={}, **options): """Construct from a parent widget, an optional dictionary to use as the namespace for execution, and any configuration options.""" Frame.__init__(self, parent) if not hasattr(sys, "ps1"): sys.ps1 = ">>> " if not hasattr(sys, "ps2"): sys.ps2 = "... " self.prefixes = [sys.ps1, sys.ps2, ">> ", "> "] self.startup = "Python %s\n%s\n" % (sys.version, sys.copyright) + \ "Python Console v%s by Ka-Ping Yee \n" % VERSION self.dict = dict # The text box. self.text = Text(self) self.text.insert("end", self.startup) self.text.insert("end", sys.ps1) self.text.bind("", self.cb_return) self.text.bind("", self.cb_select) self.text.bind("", self.cb_paste) self.text.bind("", self.cb_back) self.text.bind("", self.cb_forward) self.text.bind("", self.cb_hidecompletions) self.text.bind("", self.cb_complete) self.text.bind("", self.cb_backspace) self.text.bind("", self.cb_nothing) # The scroll bar. self.scroll = Scrollbar(self, command=self.text.yview) self.text.config(yscrollcommand=self.scroll.set) self.scroll.pack(side=RIGHT, fill=Y) self.text.pack(fill=BOTH, expand=1) self.text.focus() # Continuation state. self.continuation = 0 self.error = 0 self.intraceback = 0 # The command history. self.history = [] self.historyindex = None self.current = "" # Completion state. self.compmenus = [] self.compindex = None self.compfinish = "" # Redirection. self.stdout = OutputPipe(lambda data, w=self.write: w(data, "stdout")) self.stderr = OutputPipe(lambda data, w=self.write: w(data, "stderr")) # Configurable options. self.options = {"stdoutcolour": "#7020c0", "stderrcolour": "#c03020", "morecolour": "#a0d0f0", "badcolour": "#e0b0b0", "runcolour": "#90d090"} apply(self.config, (), self.options) apply(self.config, (), options) def __getitem__(self, key): return self.options[key] def __setitem__(self, key, value): if not self.options.has_key(key): raise KeyError, 'no such configuration option "%s"' % key self.options[key] = value if key == "stdoutcolour": self.text.tag_configure("stdout", foreground=value) if key == "stderrcolour": self.text.tag_configure("stderr", foreground=value) def config(self, *args, **dict): """Get or set configuration options in a Tkinter-like style.""" if args == () and dict == {}: return self.options if len(args) == 1: return self.options[args[0]] for key, value in dict.items(): self[key] = value # Text box routines. def trim(self, command): """Trim any matching prefix from the given command line, returning the amount trimmed and the trimmed result.""" for prefix in self.prefixes: if command[:len(prefix)] == prefix: return len(prefix), command[len(prefix):] return 0, command def getline(self, line=None, trim=0): """Return the command on the current line.""" if line is None: line, pos = self.cursor() command = self.text.get("%d.0" % line, "%d.end" % line) if trim: trimmed, command = self.trim(command) return command def cursor(self): """Get the current line and position of the cursor.""" cursor = self.text.index("insert") [line, pos] = map(string.atoi, string.split(cursor, ".")) return line, pos def write(self, data, tag=None): """Show output from stdout or stderr in the console.""" if self.intraceback and data[-2:] == "\n ": data = data[:-1] start = self.text.index("insert") self.text.insert("insert", data) end = self.text.index("insert") if tag: self.text.tag_add(tag, start, end) # History mechanism. def cb_back(self, event): """Step back in the history.""" if self.history: if self.historyindex == None: self.current = self.getline(trim=1) self.historyindex = len(self.history) - 1 elif self.historyindex > 0: self.historyindex = self.historyindex - 1 self.recall() return "break" def cb_forward(self, event): """Step forward in the history.""" if self.history and self.historyindex is not None: self.historyindex = self.historyindex + 1 if self.historyindex < len(self.history): self.recall() else: self.historyindex = None self.recall(self.current) return "break" def recall(self, command=None): """Show a command from the history on the current line.""" if command is None: command = self.history[self.historyindex] line, pos = self.cursor() current = self.getline(line) trimmed, trimmedline = self.trim(current) cutpos = "%d.%d" % (line, trimmed) self.text.delete(cutpos, "%d.end" % line) self.text.insert(cutpos, command) self.text.mark_set("insert", "%d.end" % line) # Completion mechanism. def cb_complete(self, event): """Attempt to complete the identifier currently being typed.""" if self.compmenus: if self.cursor() == self.compindex: # Second attempt to complete: add finishing char and continue. self.text.insert("insert", self.compfinish) self.compindex = None self.unpostmenus() return "break" # Scan back for the identifier currently being typed. line, pos = self.cursor() command = self.getline() preceding = command[:pos] startchars = string.letters + "_" identchars = string.letters + string.digits + "_" while pos > 0 and preceding[pos-1] in identchars: pos = pos - 1 preceding, ident = preceding[:pos], preceding[pos:] preceding = string.strip(preceding) if not ident or ident[0] in startchars: # Look for context before the start of the identifier. context = "" while preceding[-1:] == ".": preceding = string.strip(preceding[:-1]) if preceding[-1] in identchars: pos = len(preceding)-1 while pos > 0 and preceding[pos-1] in identchars: pos = pos - 1 if preceding[pos] in startchars: context = preceding[pos:] + "." + context preceding = string.strip(preceding[:pos]) else: break else: break # Get the list of possible choices. if context: object = eval(context[:-1], self.dict) keys = members(object) else: class Lookup: def __init__(self, dicts): self.dicts = dicts def __getattr__(self, key): for dict in self.dicts: if dict.has_key(key): return dict[key] return None object = Lookup([self.dict, __builtins__.__dict__]) keys = self.dict.keys() + dir(__builtins__) keys = matchingkeys(keys, ident) skip = len(ident) # Produce the completion. line, pos = self.cursor() endpos = pos while endpos < len(command) and command[endpos] in identchars: endpos = endpos + 1 cut = "%d.%d" % (line, endpos) if len(keys) == 1: # Complete with the single possible choice. if self.cursor() == self.compindex: # Second attempt to complete: add a dot and continue. self.text.insert("insert", ".") self.compindex = None else: self.text.delete("insert", cut) self.text.insert("insert", keys[0][skip:]) try: # Completed with a valid choice; next try can finish. 1 / len(members(getattr(object, keys[0]))) self.compindex = self.cursor() except: # Object has no members; finish here. self.text.insert("insert", " ") elif len(keys) > 1: # Present a menu. prefix = commonprefix(keys) keys.sort() if len(prefix) > skip: self.text.delete("insert", cut) self.text.insert("insert", keys[0][skip:len(prefix)]) skip = len(prefix) if len(keys[0]) == skip: # Common prefix is a valid choice; next try can finish. self.compindex = self.cursor() self.compfinish = " " try: if members(getattr(object, keys[0])): # Object has members within; continue with a dot. self.compfinish = "." except: pass self.postmenus(keys, skip, cut) return "break" def postmenus(self, keys, skip, cut): """Post a series of menus listing all the given keys, given the length of the existing part so we can position the menus under the cursor, and the index at which to insert the completion.""" width = self.winfo_screenwidth() height = self.winfo_screenheight() bbox = self.text.bbox("insert - %d c" % skip) x = self.text.winfo_rootx() + bbox[0] - 5 y = self.text.winfo_rooty() + bbox[1] + bbox[3] self.compmenus = [] menufont = self.text.cget("font") menu = Menu(font=menufont, bd=1, tearoff=0) self.compmenus.append(menu) while keys: def complete(s=self, k=keys[0][skip:], c=cut): s.text.delete("insert", c) s.text.insert("insert", k + " ") s.unpostmenus() menu.add_command(label=keys[0], command=complete) menu.update() if y + menu.winfo_reqheight() >= height: menu.delete("end") x = x + menu.winfo_reqwidth() y = 0 menu = Menu(font=menufont, bd=1, tearoff=0) self.compmenus.append(menu) else: keys = keys[1:] if x + menu.winfo_reqwidth() > width: menu.destroy() self.compmenus = self.compmenus[:-1] self.compmenus[-1].delete("end") self.compmenus[-1].add_command(label="...") break x = self.text.winfo_rootx() + bbox[0] - 5 y = self.text.winfo_rooty() + bbox[1] + bbox[3] for menu in self.compmenus: maxtop = height - menu.winfo_reqheight() if y > maxtop: y = maxtop menu.post(x, y) x = x + menu.winfo_reqwidth() self.text.focus() self.text.grab_set() def unpostmenus(self): """Unpost the completion menus.""" for menu in self.compmenus: menu.unpost() menu.destroy() self.compmenus = [] self.incompmenu = 0 self.text.grab_release() def cb_hidecompletions(self, event): if self.compmenus: self.unpostmenus() def cb_select(self, event): """Handle a menu selection event. We have to check and invoke the completion menus manually because we are grabbing events to give the text box keyboard focus.""" if self.compmenus: for menu in self.compmenus: x, y = menu.winfo_rootx(), menu.winfo_rooty() w, h = menu.winfo_width(), menu.winfo_height() if x < event.x_root < x + w and \ y < event.y_root < y + h: item = menu.index("@%d" % (event.y_root - y)) menu.invoke(item) break else: self.unpostmenus() return "break" # Entering commands. def cb_backspace(self, event): """Avoid backspacing over the prompt.""" if self.compmenus: self.unpostmenus() line, pos = self.cursor() trimmed, command = self.trim(self.getline()) if pos == trimmed: return "break" # Extremely basic outdenting. Needs more work here. if not string.strip(command[:pos-trimmed]): cut = pos - 4 if cut < trimmed: cut = trimmed self.text.delete("%d.%d" % (line, cut), "%d.%d" % (line, pos)) return "break" def cb_nothing(self, event): return "break" def cb_return(self, event): """Handle a keystroke by running from the current line and generating a new prompt.""" self.text.tag_delete("compiled") self.historyindex = None command = self.getline(trim=1) self.history.append(command) line, pos = self.cursor() self.text.mark_set("insert", "%d.end" % line) self.text.insert("insert", "\n") self.runline(line) line, pos = self.cursor() self.text.mark_set("insert", "%d.end" % line) prompt = self.continuation and sys.ps2 or sys.ps1 if pos > 0: self.text.insert("insert", "\n" + prompt) else: self.text.insert("insert", prompt) # Extremely basic autoindenting. Needs more work here. indent = len(command) - len(string.lstrip(command)) if string.lstrip(command): self.text.insert("insert", command[:indent]) if string.rstrip(command)[-1] == ":": self.text.insert("insert", " ") self.text.see("insert") return "break" def cb_paste(self, event): """Handle a paste event (middle-click) in the text box. Pasted text has any leading Python prompts stripped (at last!!).""" self.text.tag_delete("compiled") self.error = 0 try: lines = string.split(self.selection_get(), "\n") except: return for i in range(len(lines)): trimmed, line = self.trim(lines[i]) line = string.rstrip(line) if not line: continue self.text.insert("end", line) self.text.mark_set("insert", "end") if i < len(lines) - 1: self.cb_return(None) if self.error: break return "break" # Executing commands. def runline(self, line): """Run some source code given the number of the last line in the text box. Scan backwards to get the entire piece of code to run if the line is a continuation of previous lines. Tag the compiled code so that it can be highlighted according to whether it is complete, incomplete, or illegal.""" lastline = line lines = [self.getline(line)] while lines[0][:len(sys.ps2)] == sys.ps2: trimmed, lines[0] = self.trim(lines[0]) self.text.tag_add( "compiled", "%d.%d" % (line, trimmed), "%d.0" % (line+1)) line = line - 1 if line < 0: break lines[:0] = [self.getline(line)] if lines[0][:len(sys.ps1)] == sys.ps1: trimmed, lines[0] = self.trim(lines[0]) self.text.tag_add( "compiled", "%d.%d" % (line, trimmed), "%d.0" % (line+1)) else: self.text.tag_add("compiled", "%d.0" % line, "%d.0" % (line+1)) source = string.join(lines, "\n") if not source: self.continuation = 0 return status, code = self.compile(source) if status == "more": self.text.tag_configure("compiled", background=self["morecolour"]) self.continuation = 1 elif status == "bad": self.text.tag_configure("compiled", background=self["badcolour"]) self.error = 1 self.continuation = 0 self.intraceback = 1 oldout, olderr = sys.stdout, sys.stderr sys.stdout, sys.stderr = self.stdout, self.stderr traceback.print_exception(SyntaxError, code, None) self.stdout, self.stderr = sys.stdout, sys.stderr sys.stdout, sys.stderr = oldout, olderr self.intraceback = 0 elif status == "okay": if self.getline(lastline) == sys.ps2: self.text.tag_remove("compiled", "%d.0" % lastline, "end") self.text.tag_configure("compiled", background=self["runcolour"]) self.continuation = 0 self.run(code) def compile(self, source): """Try to compile a piece of source code, returning a status code and the compiled result. If the status code is "okay" the code is complete and compiled successfully; if it is "more" then the code can be compiled, but an interactive session should wait for more input; if it is "bad" then there is a syntax error in the code and the second returned value is the error message.""" err = err1 = err2 = None code = code1 = code2 = None try: code = compile(source, "", "single") except SyntaxError, err: pass else: return "okay", code try: code1 = compile(source + "\n", "", "single") except SyntaxError, err1: pass else: return "more", code1 try: code2 = compile(source + "\n\n", "", "single") except SyntaxError, err2: pass if err1 != err2: return "more", None try: code3 = compile(source + "\n", "", "exec") except SyntaxError, err3: pass else: return "okay", code3 try: code4 = compile(source + "\n\n", "", "exec") except SyntaxError, err4: pass if err3 != err4: return "more", None else: return "bad", err def run(self, code): """Run a code object within the sandbox for this console. The sandbox redirects stdout and stderr to the console, and executes within the namespace associated with the console.""" oldout, olderr = sys.stdout, sys.stderr sys.stdout, sys.stderr = self.stdout, self.stderr try: exec code in self.dict except: self.error = 1 sys.last_type = sys.exc_type sys.last_value = sys.exc_value sys.last_traceback = sys.exc_traceback.tb_next self.intraceback = 1 traceback.print_exception( sys.last_type, sys.last_value, sys.last_traceback) self.intraceback = 0 self.stdout, self.stderr = sys.stdout, sys.stderr sys.stdout, sys.stderr = oldout, olderr # Helpers for the completion mechanism. def scanclass(klass, result): for key in klass.__dict__.keys(): result[key] = 1 for base in klass.__bases__: scanclass(base, result) def members(object): result = {} try: for key in object.__members__: result[key] = 1 result["__members__"] = 1 except: pass try: for key in object.__methods__: result[key] = 1 result["__methods__"] = 1 except: pass try: for key in object.__dict__.keys(): result[key] = 1 result["__dict__"] = 1 except: pass if type(object) is types.ClassType: scanclass(object, result) result["__name__"] = 1 result["__bases__"] = 1 if type(object) is types.InstanceType: scanclass(object.__class__, result) return result.keys() def matchingkeys(keys, prefix): prefixmatch = lambda key, l=len(prefix), p=prefix: key[:l] == p return filter(prefixmatch, keys) def commonprefix(keys): if not keys: return '' max = len(keys[0]) prefixes = map(lambda i, key=keys[0]: key[:i], range(max+1)) for key in keys: while key[:max] != prefixes[max]: max = max - 1 if max == 0: return '' return prefixes[max] # Main program. if __name__ == "__main__": c = Console(dict={}) c.dict["console"] = c c.pack(fill=BOTH, expand=1) c.master.title("Python Console v%s" % VERSION) mainloop() -- !ping I never dreamt that i would get to be The creature that i always meant to be From MHammond at skippinet.com.au Fri Apr 23 19:44:44 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Sat, 24 Apr 1999 09:44:44 +1000 Subject: Embedding Python - Win32 - Request for Info/Opinions References: <371f32af.0@news.inet-systems.net> <37218679.236666031@news.randori.com> Message-ID: <7fr0j7$4l1$1@m2.c2.telstra-mm.net.au> Dan L. Pierson wrote in message <37218679.236666031 at news.randori.com>... > >What we do (thanks to Mark Hammond), is change PC/python_nt.rc to >create a new registry base for our python: > >//#define MS_DLL_ID "1.5.1" >#define MS_DLL_ID "QuickStep" > Just a minor clarification. If you have MSVC, it is possible to change this value _without_ recompiling Python itself. So it is possible to make this change at the source level (as Dan mentions) and also at the binary level. Mark. From aa8vb at vislab.epa.gov Mon Apr 5 08:58:16 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Mon, 5 Apr 1999 12:58:16 GMT Subject: nested map() ? Message-ID: <19990405085816.A787115@vislab.epa.gov> To generate all permutations of list elements in Perl, it's sometimes useful to do this: @result = map { $a = $_ ; map{ "$a$_" } @B } @A Is there a relatively short way to do this in Python? Thanks, Randall From egibson at connect.com.au Fri Apr 2 21:12:40 1999 From: egibson at connect.com.au (Evan Gibson) Date: Sat, 3 Apr 1999 02:12:40 GMT Subject: Is Python dying? In-Reply-To: ; from Lars Marius Garshol on Thu, Apr 01, 1999 at 02:00:53PM +0200 References: <7dos4m$usi$1@nnrp1.dejanews.com> <37009C12.4C0E6B0B@earth.ox.ac.uk> <922837384snz@vision25.demon.co.uk> <19990331124736.46416@connect.com.au> Message-ID: <19990403121240.18381@connect.com.au> > | I never understood how people can actually read programming books. > | A very basic tutorial can teach the syntax, and after that all you > | need is a library reference and a news group... > > As long as the language is relatively similar to the ones you already > know this approach works fine. But if you only know, say, Algol-like > languages and C, try learning Lisp, Standard ML or BETA from a very > basic tutorial. I would not recommend it. :) Smile. Maybe that's my problem... I know Scheme and Red Code as well... > --Lars M. -- Evan ~ThunderFoot~ Gibson ~ nihil mutatem, omni deletum ~ May the machines watch over you with loving grace. From robin at alldunn.com Mon Apr 26 22:31:50 1999 From: robin at alldunn.com (Robin Dunn) Date: Mon, 26 Apr 1999 19:31:50 -0700 Subject: GUI other than Tkinter (wxPython) References: <3721567f.1748033@news> <7fs9to$rlr$1@nnrp1.dejanews.com> Message-ID: It's always amazing to me that somebody else has already given wxPython a plug before I have a chance to get to it. :-) BTW, Cameron, your page needs it's wxPython link updated. -- Robin Dunn robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! Try http://AllDunn.com/laughworks/ for a good laugh. fm at synchrologic.com wrote in message <7fs9to$rlr$1 at nnrp1.dejanews.com>... >I am a real big fan of wxPython. I've gotten everyone at our company hooked on >it. We use it for prototyping apps now because it's so much faster than any >other tool (that is, VB). It has a full set of controls (tree, list, grid). >Actually, wxWindows on which it's based is pretty nice as well (though C++ >requires 10-20 times more typing). Check out http://www.alldunn.com/wxPython/ >and http://web.ukonline.co.uk/julian.smart/wxwin/. I think you'll be pretty >happy with it. Good luck. > >In article <3721567f.1748033 at news>, > mrfusion at bigfoot.com wrote: >> Well, I've just about given up on EVER getting Tkinter to work on my >> Win98 machine. Is there any other GUI module that I can get that >> doesn't require TCL/TK to be installed on my machine? Isn't there >> something called GD? > >-----------== Posted via Deja News, The Discussion Network ==---------- >http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own And also In article <3721567f.1748033 at news>, wrote: >Well, I've just about given up on EVER getting Tkinter to work on my >Win98 machine. Is there any other GUI module that I can get that >doesn't require TCL/TK to be installed on my machine? Isn't there . . . -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From mspal at sangria.harvard.edu Mon Apr 12 23:47:54 1999 From: mspal at sangria.harvard.edu (Michael Spalinski) Date: 12 Apr 1999 23:47:54 -0400 Subject: simple indexed file module? References: Message-ID: <876771kwph.fsf@schwinger.harvard.edu> I'll suggest the obvious - Aaron Watters' Gadfly. It may be a bit of an overkill, but it is python, and not very big either. M. From akuchlin at cnri.reston.va.us Tue Apr 27 12:07:04 1999 From: akuchlin at cnri.reston.va.us (Andrew M. Kuchling) Date: Tue, 27 Apr 1999 12:07:04 -0400 (EDT) Subject: Directories In-Reply-To: <3725DDD2.149DF47F@geocities.com> References: <3725DDD2.149DF47F@geocities.com> Message-ID: <14117.57115.810107.332251@amarok.cnri.reston.va.us> smoothasice at geocities.com writes: >Hi, i'm curious if there is a python command or set of commaneds that >could be used like the dir() command in dos prompt. I am trying to >write a program in python that would allow me to list the files of a >certain data type in a few directories but I need to know how I would do There are a few ways of doing this. * os.listdir(path) returns a list containing the names of all the files in the directory specified by path. >>> import os >>> os.listdir('.') ['Group.java', 'Group.class', 'User.java', ... ] So you can do os.listdir('C:/whatever/sub/dir/ectory'), and then loop over each filename with a for loop. * The glob module returns a list of filenames matching a wildcard pattern. >>> import glob >>> glob.glob('*.java') ['Group.java', 'User.java', 'GroupWrapper.java', ... ] -- A.M. Kuchling http://starship.python.net/crew/amk/ The chaos of our lives suited me; I don't think I wanted it to end. -- Tom Baker, in his autobiography From bill_seitz at my-dejanews.com Thu Apr 15 10:43:33 1999 From: bill_seitz at my-dejanews.com (bill_seitz at my-dejanews.com) Date: Thu, 15 Apr 1999 14:43:33 GMT Subject: stupid Win-CGI getting started question References: <7f0f0h$pfb$1@nnrp1.dejanews.com> <8DA86302Bduncanrcpcouk@news.rmplc.co.uk> <7f2db8$dev$1@nnrp1.dejanews.com> <8DA96361Fduncanrcpcouk@news.rmplc.co.uk> Message-ID: <7f4tuj$in6$1@nnrp1.dejanews.com> In article <8DA96361Fduncanrcpcouk at news.rmplc.co.uk>, Duncan Booth wrote: > It sounds like you still don't have the right path to python, or it is > protected so you can't access it. I would check the file permissions: you > probably need to give SYSTEM (or whatever user the CGI process is running as) > on the web server full access to the python directory. > > Try creating a CGI cmd file like this: > ----access.cmd--------- Ugh, pardon my sloppiness. Your access.cmd worked fine. Then I went back to the previous file, took off the stuff on your first line after the Python path, and got the same error message followed by the rest of the contents of the file. So that told me that the path was the offending line. I looked more carefully, and realized (d'oh) that the path was not just a folder path to your code files, or the path to the Python executable, but the actual path including the executable filename itself. Once I adjusted my first line to match that, it started working fine. Now, if only I could get .py files to work... -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From chadm at sgi.com Fri Apr 9 13:29:53 1999 From: chadm at sgi.com (Chad McDaniel) Date: 09 Apr 1999 10:29:53 -0700 Subject: POST request References: <7eilen$g9o$1@nnrp1.dejanews.com> Message-ID: gscot at my-dejanews.com writes: > To All: I would like to write a short program that would play a game > found on the Internet. I cannot find any documentation on how to make a POST > request. It is a stock market game. You fill out a form with the symbol and > number of share you want to buy or sell. The form uses the POST method to > send the data. Since I cannot just put this information in the url I am not > sure how to write a program to automate this procese. Is there any way to do > that with Python. Thank you for your help. Gary > If you are asking how you can make a POST request to a HTTP web server using python as the client then yes, you can do this with urllib which should be part of your python installation. urllib.urlopen() normally uses GET, but if you supply a second data argument it will send that data along as the body of a POST. With python 1.5.2 there is also a very hand urllib.urlencode() function to transform a python dictionary into something suitable for the body of a POST request. -- -chad From frneh at wmdata.com Thu Apr 15 06:07:21 1999 From: frneh at wmdata.com (Fredrik Nehr) Date: Thu, 15 Apr 1999 12:07:21 +0200 Subject: 1.5.2 install problems on NT References: <3714D8FF.634655C5@ina.fr> Message-ID: <7f4dor$kt4@news3.newsguy.com> > Registry problems: I have the exact same problems, I removed the previous version (1.5.1) of Python before I installed 1.5.2. /FN From robin at jessikat.demon.co.uk Tue Apr 13 08:32:44 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 13 Apr 1999 13:32:44 +0100 Subject: site.py & COM startup Message-ID: using Mark Hammond's win32com for a server I find that the installation path is not automatically in sys.path so my base .pth files are missed and I get troubles. I hacked site.py to fix this using the fact that sys.prefix == '' when running a com server (I guess inproc). the code I used inside site.py at line 93 looks like if sys.prefix == '': from imp import find_module prefixes = [os.path.normpath(os.path.dirname(find_module('site')[1])+'/..')] else: prefixes = [sys.prefix] but I guess this isn't really how it should be done. Any suggestions? -- Robin Becker From quinn at cruzeiro.ugcs.caltech.edu Wed Apr 7 22:43:02 1999 From: quinn at cruzeiro.ugcs.caltech.edu (Quinn Dunkan) Date: 8 Apr 1999 02:43:02 GMT Subject: povray.py References: <__YN2.30200$FZ5.11443@news.rdc1.sfba.home.com> Message-ID: On 06 Apr 1999 15:46:12 -0500, David Steuber wrote: >mlh at idt.ntnu.no (Magnus L. Hetland) writes: > >-> "TM" writes: >-> >-> > Has anyone created a pov ray module for python? >-> >-> I have been thinking about it, but haven't done it yet... What do you >-> think it should contain? > >This is a relatively off the cuff response. But I think such a module >should provide python classes for the POV types. Then, instead of >using the POV scene description language, you would use Python. You >could algorithmicly create a scene or animation sequence. Then you >would pass the data structure (a list or other sequence) to a Python >function that renders it in POV scene description language for POV to >digest and render. > >Another thing I would like to see is a module for generating RIB >files. In fact, a Python RenderMan module would be quite nice, >complete with shading language support. Anything out there like that? > >-- >David Steuber >http://www.david-steuber.com > >s/trashcan/david/ to reply by mail >If you don't, I won't see it. From phd at sun.med.ru Tue Apr 13 12:27:15 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Tue, 13 Apr 1999 16:27:15 GMT Subject: bug in PyGreSQL module In-Reply-To: <14099.24295.229214.504295@bitdiddle.cnri.reston.va.us> References: <14099.24295.229214.504295@bitdiddle.cnri.reston.va.us> Message-ID: On Tue, 13 Apr 1999, Jeremy Hylton wrote: > I found an apparent bug in the Python interface to PostgreSQL. I > tried sending a query to the author but haven't heard back, so I'm > looking for other users to see if they have run into the problem. > I have a table with lots of int fields, some of which of NULL. When I > do a Python query, the PyGreSQL module converts the NULL to 0 instead > of None, which is the value I expected. Is that a reasonable > expectation? I have not noted such problem, I am using PyGres quite happily. Which version you are using? > The PyGreSQL module doesn't implement the DB API, but I checked there > anyway. Alas, it didn't say anything about how to handle NULL. DB API will be implemented in the upcominh PyGres 3.0. > Jeremy Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From mlh at idt.ntnu.no Thu Apr 8 08:21:01 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 08 Apr 1999 14:21:01 +0200 Subject: Cygnus Java Compiler and JPython References: <199904072138.RAA25670@shell.clark.net> Message-ID: Tom Culliton writes: > A story on the GCJ announement can be seen at: The GCJ assumes that the entire program will be compiled, i.e. no bytecode interpreter... Doesn't JPython use dynamic compilation into bytecode as a part of its Python interpretation? -- Magnus Lie Hetland http://arcadia.laiv.org From tjreedy at udel.edu Mon Apr 5 21:37:36 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 6 Apr 1999 01:37:36 GMT Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <3700528A.3F0C047D@Lugoj.Com> <009e01be7a80$b20299b0$f29b12c2@pythonware.com> <7e1ju7$17k$1@eskinews.eskimo.com> Message-ID: <7eboh0$rec$1@news.udel.edu> Hardly. Until about a year and a half ago, there were no mentions in Dr. Dobb's Journal of Python (that I noticed). Since then, it has appeared in several articles. Some non-obvious examples: 1998 Dec page 101 in article on XLink: references to resources includes several documents, Visual Basic application, Java application, and two! python items - Garshol's XPointer implementation and Meginnson's (spelling correct?) Document Architecture processor. (url given in DD incorrect or obsolete). 1999 Jan page 94 in article on Matlab: reference to three Matlab-like languages - Octave, SciLab, and NumPy. TJR From ljz at asfast.com Fri Apr 30 22:44:26 1999 From: ljz at asfast.com (Lloyd Zusman) Date: 30 Apr 1999 22:44:26 -0400 Subject: Vtk works fine, but not with Python ... ??? Message-ID: I'm using Python 1.5.2 under RedHat Linux 5.0. I have recently downloaded and built vtk, including the Python wrappers. I have followed the instructions given on the vtk web site (summarized below), and the result is a version of vtk which works fine under tcl and as a stand-alone. All example scripts I try to run via vtk work perfectly. However, when I try to run any vtk Python examples, I get the following error no matter what script I try to run: % python earth.py Traceback (innermost last): File "earth.py", line 4, in ? from libVTKGraphicsPython import * ImportError: /usr/local/lib/python1.5/lib-dynload/libVTKGraphicsPython.so: undefined symbol: XtStrings I'm wondering if anyone has seen this problem, or could suggest a way to fix it. Before you tell me that my LD_LIBRARY_PATH is set wrong, or that I didn't run ldconfig, I want to point out that /usr/X11R6/lib is in my LD_LIBRARY_PATH, and this directory contains the libXt.so, libXt.so.6 and libXt.so.6.0 libraries (two are symbolic links pointing to the third one). Furthermore, my /etc/ld.so.conf file does contain /usr/X11R6/lib, and running `ldconfig -v' indeed shows this library. Also, the following vtk libraries have been successfully built and installed in /usr/local/lib. And /usr/local/lib also appears in LD_LIBRARY_PATH and /etc/ld.so.conf, and running `ldconfig -v' shows these libraries: libVTKCommon.so libVTKCommonTcl.so libVTKContrib.so libVTKContribTcl.so libVTKGraphics.so libbVTKGraphicsTcl.so libVTKImaging.so libVTKImagingTcl.so libVTKImagingPython.so libVTKPatented.so libVTKPatentedTcl.so In addition, these libraries have been successfully built and put into this Python subdirectory: /usr/local/lib/python1.5/lib-dynload ... libVTKCommonPython.so libVTKContribPython.so libVTKGraphicsPython.so libVTKPatentedPython.so This directory is also in PYTHONPATH, LD_LIBRARY_PATH, and /etc/ld.so.conf I set up user.make as follows: TCL_INCLUDE=-I/usr/include TCL_LIB=/usr/lib/libtcl.so TK_INCLUDE=-I/usr/local/src/tk8.0.3/generic TK_LIB=/usr/lib/libtk.so MESA_INCLUDE=-I/usr/include/GL MESA_LIB=/usr/lib/libMesaGL.so PYTHON_INCLUDES=-I/usr/local/src/Python-1.5.2/Include USER_CFLAGS = -O2 -D__NO_MATH_INLINES USER_CXXFLAGS = -O2 -D__NO_MATH_INLINES Then, I configured vtk as follows: ./configure --with-mesa --with-shared --with-python --with-tcl \ --with-tkwidget --with-x --with-contrib --with-patented I then did the make, which took quite a while and ran successfully, after which I installed the libraries, ran `ldconfig -v', and then tried the examples. As I mentioned, every example I tried worked fine except for the Python examples, which all give me the error I described above. Note that all other Python modules I have are working perfectly, including Tkinter, Pmw, Gadfly, and many others. Any ideas? Thanks in advance. -- Lloyd Zusman ljz at asfast.com From rholm at mcs.com Fri Apr 23 21:49:08 1999 From: rholm at mcs.com (Rich Holm) Date: 23 Apr 1999 20:49:08 -0500 Subject: PythonCE Message-ID: Spam detection software, running on the system "albatross.python.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hello, Does anyone know the status of PythonCE? I would like to get an updated copy, 1.5.2? Also, where is the source? I wouldn't mind recompiling and extending it. Cheers, Rich [...] Content analysis details: (5.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 FH_DATE_IS_19XX The date is not 19xx. 3.6 TVD_SPACED_SUBJECT_WORD3 TVD_SPACED_SUBJECT_WORD3 -0.0 NO_RELAYS Informational: message was not relayed via SMTP -0.0 NO_RECEIVED Informational: message has no Received headers -------------- next part -------------- An embedded message was scrubbed... From: Rich Holm Subject: PythonCE Date: 23 Apr 1999 20:49:08 -0500 Size: 943 URL: From stadt at freemail.nl Fri Apr 9 11:33:27 1999 From: stadt at freemail.nl (Richard van de Stadt) Date: Fri, 09 Apr 1999 17:33:27 +0200 Subject: Possible 1.5.2 bug References: Message-ID: <370E1DC7.BC2574B5@freemail.nl> Darrell wrote: > > I guess writing this message was all that was required to track down a > common temp file. So why does such clear thinking sometimes require posting > the problem to the world ? That is to make you feel much more silly that you didn't see what you were doing wrong. Usually this clear thinking happens about 5 minutes after posting. So, in fact, you were late :-) But it's a general way to debug: tell someone what right things your program is doing. Chances are that you will see the wrong thing(s) before the other person has said anything... I just stick a picture of a face on my monitor and talk to it to find bugs. Richard. From aa8vb at vislab.epa.gov Tue Apr 6 07:39:17 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 6 Apr 1999 11:39:17 GMT Subject: Possible regex match bug (re module) In-Reply-To: <000001be7fc9$bdb0fec0$65a22299@tim>; from Tim Peters on Mon, Apr 05, 1999 at 09:06:45PM -0400 References: <19990405084819.B802985@vislab.epa.gov> <000001be7fc9$bdb0fec0$65a22299@tim> Message-ID: <19990406073917.B867123@vislab.epa.gov> Tim Peters: |Same as in Perl, you're going to have to write a hairier regexp with only |one interesting group, or give the interesting groups different names and |sort them out after the match (in an alternation involving named groups, at |most one will be non-None after a match). Here's a discouraging |example of the former approach: | |>>> p = re.compile(r"([-=])\1\1(?P((?!\1).)*)\1\1\1").match I didn't parse your reply carefully enough. The "interesting groups different names" approach is the one I took, and you're not advocating the "hairier" form. I guess what threw me with named groups is that they are identified by names (like variables) and not position numbers ($1,$2,...), so context-sensitive assignment seemed to make sense. E.g.: "if a == b { id = b } else { id = c }" I'll use different names in the future, and just be thinking numbers. ;-) Thanks, Randall From tseaver at palladion.com Thu Apr 29 00:21:41 1999 From: tseaver at palladion.com (Tres Seaver) Date: Wed, 28 Apr 1999 23:21:41 -0500 Subject: Emulating C++ coding style References: <371F8FB7.92CE674F@pk.highway.ne.jp> <3720675C.FF7A9E99@gssec.bt.co.uk> Message-ID: <3727DE55.EA5B4BAF@palladion.com> William Tanksley wrote: > > On Fri, 23 Apr 1999 13:28:12 +0100, Alan Gauld wrote: <> > > >> In proper C++, your const will be contained inside a class (probably > >> static) to keep it out of the global namespace. > > >Hopefully not. It should be contained within a C++ namespace. > > Okay, I'll bite. Why "hopefully not" a class? I know namespaces are new > and cool, but classes seem to have done the job very well in the past. > Have they been secretly causing bloat in our code all along ;-)? Classes are semantically "heavier" than namespaces: by design, they exist to classify objects. Classes which exist only to scope other names (typedefs, constants, free functions), while a decent workaround before the ANSI standard, are now less attractive (they can't be reopened, for one thing). -- ========================================================= Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From fredrik at pythonware.com Wed Apr 21 04:26:07 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Apr 1999 08:26:07 GMT Subject: Raw binary string --> long integer? References: <7fjrar$avb$1@nnrp1.dejanews.com> Message-ID: <002901be8bd0$ebef75b0$f29b12c2@pythonware.com> wrote: > I'm looking for a way to do the following in pure Python. > > Given a binary string, e.g., '\003\004\005', convert the string into a long. > So the example should become (3<<8|4)<<8|5 == 110000010000000101 == 197,637. > > The binary strings can be arbitrarily long. (Ok, up to about 256 bytes for an > RSA public key. ;-) here's one way to do it: v = 0L for i in map(ord, "\003\004\005"): v = v<<8 | i print v for short integers, use the struct module instead. From faassen at pop.vet.uu.nl Tue Apr 27 12:14:57 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Tue, 27 Apr 1999 18:14:57 +0200 Subject: help References: <19990426163014.B20207@toast.internal> <3724D1C3.8BFA2C5B@pop.vet.uu.nl> <3724DEFC.A01E93C2@callware.com> <37257B0A.AF4C8E4C@pop.vet.uu.nl> <3725D6EA.E2DFB853@callware.com> Message-ID: <3725E281.A83DBBF@pop.vet.uu.nl> Ivan Van Laningham wrote: > > Pythonistas-- > > Martijn Faassen wrote: > > > [snip] > > Yeah, that happened to me for a while - I had to cut down drastically on > > the use of the word 'Python'. :) So *do* they use Python over there? I > > mean, now that they all know they should? > > > > Ha. No. I'm sure that they just think of me as that nut in the corner. You can take some comfort from the fact that here I've made a few people quite excited about Zope. If Python doesn't work, you could try Zope. At least it's a different word -- when they find out it's written in Python it might already be too late. :) Regards, Martijn From arcege at shore.net Fri Apr 23 12:34:46 1999 From: arcege at shore.net (Michael P. Reilly) Date: Fri, 23 Apr 1999 16:34:46 GMT Subject: Suggestion for easier c/c++ interfacing References: Message-ID: Albert Hofkamp wrote: : Hello all, : I have been experimenting with c++ and Python, and am working on : attaching generated c++ module-code to python. : In the EXT document, it is explained how to parse arguments from python : in c code using PyTuple_ParseArgs(). This is really easy to use. I think you mean PyArg_ParseTuple(). : However, the same kind of parsing must occur after a call from c to a : python function. The return value from that function is again a Python : object, and needs to be decoded before it can be used in c. : Unfortunately, the returned value is not a tuple, so PyTuple_ParseArgs() : cannot be used. A shortcut would be to wrap the result in a tuple with 1 : argument, and then call the decoding function, but I consider that a hack. : Wouldn't it be possible to create a PyTuple_ParseArgs()-like function to : parse return results from python functions ? Gee... that is what happens when you take something out of the doc. There is indeed a function that you describe. It is not used often, but "in the old days" it was used instead of PyArg_ParseTuple(). The function is called PyArg_Parse() and works identically to the function PyArg_ParseTuple(), except that it does not expect a tuple, it expects any Python object. PyObject *function; PyObject *result, *args; char *street, *town, *city; int zipcode; args = Py_BuildValue("ss", "name", "Arcege"); /* returns a list of four elements */ result = PyObject_CallObject(function, args); Py_DECREF(args); if (!PyArg_Parse(result, "[sssi]", &street, &town, &city, &zipcode)) return NULL; Often, it is better to determine the type of the return value in the C code manually - making it more robust and extensible. result = PyObject_CallObject(function, args); if (result == Py_None) { printf("No address found\n"); Py_DECREF(Py_None); } else if (!PyList_Check(result)) { PyErr_SetString(PyExc_TypeError, "expecting a list (or None)") return NULL; } A good idea is to go thru the Python sources and see how PyArg_Parse is still being used. -Arcege From hniksic at srce.hr Tue Apr 13 11:56:38 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 13 Apr 1999 17:56:38 +0200 Subject: Python 1.5.2c1 -- What if long long not supported? References: <199904091521.LAA00858@eric.cnri.reston.va.us> <87hfqkx1lk.fsf@pc-hrvoje.srce.hr> Message-ID: <87g164tsy1.fsf@pc-hrvoje.srce.hr> Hrvoje Niksic writes: > Guido van Rossum writes: > > > I received a bug report that if the (unnamed) platform doesn't > > support the "long long" type, the configure script dies. The logic > > in configure.in looks correct to me and I don't have any such Unix > > platforms handy myself... > > You can "create" such a platform by using `-pedantic-errors'. This was supposed to say "by using `gcc -pedantic-errors' as the compiler." From trashcan at david-steuber.com Thu Apr 22 23:00:24 1999 From: trashcan at david-steuber.com (David Steuber) Date: 22 Apr 1999 23:00:24 -0400 Subject: Built-in Modules gl, GL for SGI IRIX Message-ID: While perusing the documentation that came with Python (1.5.1 on SuSE 6.0 Linux distribution), I noticed pythong modules for interfacing with OpenGL. I am running Linux on an Intel, not IRIX on an SGI MIPS. I was wondering if anyone has patched the modules to work with Mesa, an OpenGL clone. I am still very new to Python, and haven't been through the C linkage referance yet. How difficult is it to set up the gl and GL modules to look on the system for Mesa, GL or Windows OpenGL dlls and use the appropriate shared objects for a Python program? I would like to use Python for a program that will need to display 3D graphics using OpenGL. I would like the program to work on all POSIX compliant systems and possibly Windows as well if the GUI elements (I haven't looked into that yet either) are portable. -- David Steuber http://www.david-steuber.com If you wish to reply by mail, _please_ replace 'trashcan' with 'david' in the e-mail address. The trashcan account really is a trashcan. The big problem with pornography is defining it. You can't just say it's pictures of people naked. For example, you have these primitive African tribes that exist by chasing the wildebeest on foot, and they have to go around largely naked, because, as the old tribal saying goes: "N'wam k'honi soit qui mali," which means, "If you think you can catch a wildebeest in this climate and wear clothes at the same time, then I have some beach front property in the desert region of Northern Mali that you may be interested in." So it's not considered pornographic when National Geographic publishes color photographs of these people hunting the wildebeest naked, or pounding one rock onto another rock for some primitive reason naked, or whatever. But if National Geographic were to publish an article entitled "The Girls of the California Junior College System Hunt the Wildebeest Naked," some people would call it pornography. But others would not. And still others, such as the Spectacularly Rev. Jerry Falwell, would get upset about seeing the wildebeest naked. -- Dave Barry, "Pornography" From fdrake at cnri.reston.va.us Tue Apr 13 09:15:26 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake) Date: Tue, 13 Apr 1999 13:15:26 GMT Subject: ANNOUNCEMENT: Some Python Documentation in Hungarian language In-Reply-To: References: Message-ID: <14099.17262.158344.777419@weyr.cnri.reston.va.us> Hever Zsolt writes: > I am writing my diploma work in Python. I made two enclosures to it and > converted them into HTML format. Now I put them out on the Internet with a > Python home page together all in Hungarian language. I hope this > documentation will help Python to be better known in Hungary. I have added a link to this from: http://www.python.org/doc/NonEnglish.html Thanks for your efforts! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From aa8vb at vislab.epa.gov Mon Apr 19 09:14:38 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Mon, 19 Apr 1999 13:14:38 GMT Subject: sys.path.insert - how to make it global? In-Reply-To: <01E40461E003D21195CC0080296495D80B1309@gates.cdc-group.com>; from Stefan Franke on Sat, Apr 17, 1999 at 06:35:32PM +0200 References: <01E40461E003D21195CC0080296495D80B1309@gates.cdc-group.com> Message-ID: <19990419091438.A59861@vislab.epa.gov> Stefan Franke: |Your code snippet says : | # Augment search path to pull in our C library wrappers | |Maybe importing C extensions makes your program fail? Yes, exactly. |The following example should resemble your situation (let |me know if it doesn't): | |-------- file a.py in some_directory |-------- file b.py in some_directory |-------- file c.py in some_directory/new_directory This works fine here as well. At the time I'd suspected that this was an issue with importing in general, but it's actually shared library importing- specific. Simplifying my situation and drawing parallels to yours, my case was: -------- file A.py in some_directory -------- file B.py in some_directory/new_directory -------- file C.so in some_directory/new_directory -------- file D.so in some_directory/new_directory A imports B which imports C which is linked with D. It failed pulling in D. B are SWIG shadow classes, C.so is the SWIG Python wrappers for a C library, and D.so is the C library itself (several of them actually). Augmenting the RPATH established when C is built to include where D lives resolved my problem not being able to import B from A. So I know now that augmenting sys.path isn't sufficient when some of the Python modules have dependent shared libraries. Thanks for your help, Randall From cgw at fnal.gov Thu Apr 22 22:47:43 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Fri, 23 Apr 1999 02:47:43 GMT Subject: try vs. has_key() Message-ID: <199904230247.VAA10380@buffalo.fnal.gov> Personally I really like the new-ish "get" method of dictionaries, which lets you write dict[key] = dict.get(key,[]) + [foo] I don't know about performance implications but it's a nice terse construct. From martin at dstc.edu.au Tue Apr 13 20:28:23 1999 From: martin at dstc.edu.au (Martin Chilvers) Date: Wed, 14 Apr 1999 00:28:23 GMT Subject: ANNOUNCE - Fnorb 1.0 - A Python CORBA ORB Message-ID: <199904140028.KAA23849@piglet.dstc.edu.au> Announcing the release of version 1.0 of 'Fnorb' a Python CORBA ORB. Thanks to all those people who tried out 1.0b1 and submitted bug reports - here is the detailed list of the changes since the last release as found in the CHANGES file:- Fnorb 1.0 --------- 1) The Windows NT/95 installation has been changed to make the setting of the FNORB_HOME, PATH and PYTHONPATH environment variables up to the user (ie. the installation no longer updates the registry or autoexec.bat). For convenience, an additional batch file ('...\Fnorb\script\fnvars.bat') is created which can be run from a command prompt to set the variables appropriately. To repeat, this is for convenience only - it works on NT with Python 1.5.2c1 - but there are no guarantees beyond that! Win 95 users need to edit the file, remove any spaces in directory names, and wish they had a decent shell ;^) 2) The CORBA type 'unsigned long' is now mapped (as per the draft) to the Python *long* integer type. This has some effect as Python sequences cannot be indexed with these values without an explicit conversion (int(x)). 3) Added support for the CORBA 'long long' and 'unsigned long long' (64-bit integer) types - they are also mapped to Python long integers. 4) The stubs and skeletons generated by 'fnidl' now reference all Fnorb modules explicitly, hence removing possible name clashes with user IDL files. 5) Ugly bug in the parsing/marshalling of recursive types fixed. 6) Locking bug in '_narrow' fixed. 7) Bug in interface repository fixed so that 'fnfeed' now works as expected! 8) A few other minor bug fixes from 1.0b1! Things on the TODO RSN list:- 1) Implement the POA 2) Implement the rest of the CORBA 2.1 datatypes 3) Move documentation to PDF format. Get more details and download Fnorb from:- http://www.dstc.edu.au/Fnorb The Fnorb Development Team c/o Martin _--_|\ Martin Chilvers, Voice: +61-7-3365-4310 / * Research Scientist, Architectures Unit, Fax: +61-7-3365-4311 \_.--._/ DSTC, Level 7, GP South, Staff House Road, Email: martin at dstc.edu.au v The University of Queensland, QLD 4072. ---- From the Fnorb README ---- What is Fnorb? Fnorb is a CORBA 2.0 ORB written in Python (with just the eensiest-teensiest bit of C code for marshalling and parsing ;^). Python is a mature, interpreted, object-oriented programming language with powerful high-level datatypes that make it ideally suited as a scripting language for CORBA. Best of all Python is free so check it out! Like ILU from Xerox PARC, Fnorb gives the Python programmer access to the wonderful world of CORBA. It supports all CORBA 2.0 datatypes (including Any's) and provides a full implementation of IIOP. Unlike ILU, Fnorb is Python and CORBA/IDL specific which makes it simple, light-weight, and easy to install and use. Using Fnorb, you no longer have to use to write CORBA clients and servers - you can now use, yep you guessed it, Python! This makes Fnorb ideal for prototyping complex CORBA architectures, for use as a scripting tool, and for building test harnesses for all your CORBA development projects. The Python language mapping used by Fnorb is based on the 'living' document that is being prepared by members of the DO-SIG. One goal of Fnorb is to allow the Python community to experiment with the mapping before we attempt to set it in stone via the OMG standardisation process. Fnorb is being developed as part of the Hector project at the CRC for Distributed Systems Technology based at the University of Queensland in Brisbane, Australia. From boud at rempt.xs4all.nl Tue Apr 27 11:00:19 1999 From: boud at rempt.xs4all.nl (boud at rempt.xs4all.nl) Date: Tue, 27 Apr 1999 15:00:19 GMT Subject: Designing Large Systems with Python References: Message-ID: David Steuber wrote: : Meanwhile, languages like Ansi Common Lisp have had features that : allow you to prototype and build a large system at the same time. : That is, the specification of the system becomes the system. People : have done the same thing with Visual Basic, so I am told. : Yes, they do. I should know - I'm working on a whopping great big laboratory erp system built in Visual Basic. First there was the prototype and it looked like a Windows program. Then there wasn't enough time to start again and discard the prototype, so the prototype became the specification, and in time, the system. Then the project was delayed by about a year. Then there were performance problems caused by conceptual errors that had to be rectified by hacking around. Then suddenly, the whole blasted !@#$%^&* was more than ten million lines, more than hundred dll's, numerous OCX'es, and countless forms, all built by twenty to thirty novices in the art of programming, of whom fifteen had left the company. It's more than painful or embarrasing... And it's not the first time I've seen that happen. Sorry for the rant - I just had to get it of my chest. I don't think Python really insures you against these mistakes. : : One other thing. Is the documentation that comes with Python : sufficient to gain mastery of the language, or should I consider : buying (yet) another book? : I didn't find the online information quite enough - but the book I got, Internet Programming with Python, isn't much better. It's a bit too fond of telling me how not to do things, instead of how things work. But that's just personal prejudice, and I think I just should have bought Programming Python instead. -- Boudewijn Rempt | www.xs4all.nl/~bsarempt From arcege at shore.net Fri Apr 30 16:17:24 1999 From: arcege at shore.net (Michael P. Reilly) Date: Fri, 30 Apr 1999 20:17:24 GMT Subject: Extension Doc bug References: <14120.52559.376120.364972@weyr.cnri.reston.va.us> Message-ID: Fred L. Drake wrote: : Michael P. Reilly writes: : > I just spent the morning trying to find a very obscure bug related to : > the passing keyword arguments to a builtin method/function. : Michael, : You didn't post your original code that exhibited the bug, so I : can't be sure of my conclusions. If you can send source for enough of : your extension module that someone can compile it, that would be : helpful. : My first inclination, however, is that you passed in illegal : arguments to PyArg_ParseTupleAndKeywords(). Passing NULL for the : keywords dictionary is allowed; I've been looking at the : implementation and don't see a way for that to be a problem (but I : might have missed something). I don't have the code anymore, I took a more rudimentary approach. I wanted something to emulate PyArg_ParseTuple(args, ""); the documentation for PyArg_ParseTupleAndKeywords() states that the format is exactly as documented for PyArg_ParseTuple() ('A format string of zero or more "format units"'), so I wrote something along the lines of: { static char *kwlist[] = { NULL }; if (PyArg_ParseTupleAndKeywords(args, keywds, "", kwlist)) { /* process no arguments */ } else { /* process arguments */ } } My current code is: /* are there arguments? keywds might be NULL */ if (PyTuple_Size(args) > 0 || (keywds != NULL && PyDict_Size(keywds) > 0)) { PyErr_Clear(); if (ExpPy_stty(self->id, args, keywds)) { result = Py_None; Py_INCREF(Py_None); } } else result = ExpPy_unparse_stty_tuple(self->id); return result; And this seems to do me well enough. Still, regardless of there being a source bug (and my original posting suggested that there was no bug), API users should be told that kwdict might be passed NULL. Currently the doc only states (based on the contents of http://www.python.org/doc/ext/parseTupleAndKeywords.html at Fri Apr 30 16:14:26 EDT 1999): The arg and format parameters are identical to those of the PyArg_ParseTuple() function. The kwdict parameter is a dictionary of keywords received as the third parameter from the Python runtime. Nothing is mentioned about the kwdict parameter being NULL, and that is a documentation error (and the jist of my posting). -Arcege From befletch at my-dejanews.com Mon Apr 12 18:57:32 1999 From: befletch at my-dejanews.com (befletch at my-dejanews.com) Date: Mon, 12 Apr 1999 22:57:32 GMT Subject: ZopeHTTP speed problem. Message-ID: <7etton$j4q$1@nnrp1.dejanews.com> I downloaded Zope to kick the tires a bit. It looks very interesting, but I am having a small problem with the ZopeHTTP server being really slow. It is taking about 5 seconds per HTTP request. Does anyone have an idea of what might be wrong here? Here's some details; ZopeHTTP is running on my 300Mhz W95 box. This machine is on a LAN behind an NT proxy-server, but I don't think the server is involved in anyway because even if I disable the server in my (Netscape) browser and disconnect my machine from the LAN, I get the same slow response time. So far, I am just messing with the Zope management pages, unmodified out-of-the-box. I found I have to use my machine's numeric IP address, not 'localhost' as the docs indicate. Hmm. That's all the potentially relevant details I can think of at the moment. Aside from this speed problem, I am encouraged by what I see here. Thanks for any help, - Bruce -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own From guido at CNRI.Reston.VA.US Tue Apr 13 10:00:26 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Tue, 13 Apr 1999 10:00:26 -0400 Subject: Python console (please play) In-Reply-To: Your message of "Tue, 13 Apr 1999 09:25:18 EDT." <199904131325.JAA08848@python.org> References: <199904131325.JAA08848@python.org> Message-ID: <199904131400.KAA13455@eric.cnri.reston.va.us> > I know it's been a long while since i last posted here, > but i have been hacking lots of Python all the while. > It's just that i mostly don't get to give it away. Hello Ka-Ping, glad to hear from you again! > Well, here's a little late-night hack i whipped up. > Thought you might enjoy it, so i'll post it here. > > It all started with my annoyance at being forced to > paste code into the Python interpreter one line at a > time because the prompts foul things up. But there is > plenty of boasting in the doc string, so i'll not add > any more words here. > > Do let me know how you like it. Aww, I can see you've been away for a while! You're trying to recreate the functionality of IDLE, the Interactive DeveLopment Environment for Python that I've been hacking on lately, now that PTUI seems no longer maintained. IDLE sports a colorizing, multiple-undo Python source editor and an interactive shell that acts a lot like yours (except that it subclasses from the source editor code so it also has colorizing and multi-undo). If you want to play with IDLE, get the 1.5.2 distribution. A release candidate is on the website, I'll probably post the final release tonight. Go look in Tools/idle/. Also, the (admittedly painful) code to parse a string of Python source and find out whether it is correct, incorrect or incomplete has been codified in the new library module codeop.py, and the logic of the command line interpreter has been reimplemented in code.py. I did notice that you have one feature that IDLE doesn't have yet; identifier completion based on the contents of the current namespace. (It does have completion based on the current edit buffer, but that's not the same.) Perhaps you could hack that feature into IDLE? Sorry to steal your thunder; I like your code a lot nevertheless! --Guido van Rossum (home page: http://www.python.org/~guido/) From mal at lemburg.com Tue Apr 6 04:41:34 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 06 Apr 1999 10:41:34 +0200 Subject: SNMPy update References: <7e1hiq$a71$1@Starbase.NeoSoft.COM> <7ear25$ksf$1@news-sj-3.cisco.com> <14089.11820.416453.80124@bitdiddle.cnri.reston.va.us> Message-ID: <3709C8BE.4257C9F1@lemburg.com> Jeremy Hylton wrote: > > I'll second your sentiment! I did some work on an X.509 library > written entirely in Python. Like you friend's SNMP code, it will > probably never be released; I don't have time to finish it nor did I > expect that I'd want to release it given the export control hassles. Just want to note that SSLeay/OpenSSL includes a pretty complete X.509 lib and also routines to do ASN.1 encoding an decoding. The main argument for using OpenSSL in this context is, of course, that no export control restrictions apply. > However, it seemed clear to me that an ASN.1 compiler could be written > to generate the encode/decode routines. If someone is interested in > that, I've got some design notes and rough code on how to do the > encode/decode and on how to build a backend for SNACC. (A free-ish > ASN.1 compiler; the only one?) Not sure what you mean with "ASN.1" compiler. If you want a compiler that does ASN.1 description -> Python function calling de/encoding routines kind of thing, then I guess the ASN.1 stuff in OpenSSL could help you getting started quite fast. Note that I have a project running with the intention to wrap OpenSSL in an OO manner called mxCrypto (see the link below). -- Marc-Andre Lemburg Y2000: 269 days left --------------------------------------------------------------------- : Python Pages >>> http://starship.skyport.net/~lemburg/ : --------------------------------------------------------- From bernhard at alpha1.csd.uwm.edu Mon Apr 5 20:25:31 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 6 Apr 1999 00:25:31 GMT Subject: Is Python dying? References: <7dos4m$usi$1@nnrp1.dejanews.com> <3700528A.3F0C047D@Lugoj.Com> <009e01be7a80$b20299b0$f29b12c2@pythonware.com> <7e1ju7$17k$1@eskinews.eskimo.com> Message-ID: On 2 Apr 1999 05:17:59 GMT, Jonathon wrote: > 5: O'Reilly is _not_ the only publisher of computer > books. Find a publisher of either popular > "easy" computer books, or one who likes niche > markets. _An Idiot's Guide To Python_ would > satisfy the first one. You cannot teach idiots programming. I refuse buying any idiot's or for dummies guide, because what can a book be good for that treats you as a dummy or idiot? Justmy 0.02 Euros Bernhard From achrist at easystreet.com Fri Apr 2 17:28:32 1999 From: achrist at easystreet.com (Al Christians) Date: Fri, 02 Apr 1999 14:28:32 -0800 Subject: string.join() vs % and + operators Message-ID: <37054490.E79ADCC9@easystreet.com> Whereas Python's strings are immutable, there is potentially a strong incentive to get them right the first time. In my applications, I want to create strings that have many fields within them. I assume that it would be nice to be able to modify the fields without creating a new string any time its contents get changed, but I don't think that Python gives any nice way to do this. So, I'm stuck with building the string from many little pieces. The 'many' part of this gives me some worry about efficiency, which it is better not to worry about, so I did a brief test to see if there is ugly downside to this. I ran the following script: # Start of Script import string # Create an array of little strings and a format to join them s = [] f = '' for i in range(100): s.append(`i`) f = f + '%s' print "Start of Way 1 -- Create with a big format" for i in range(100000): z = f % tuple(s) print "end of Way 1" print z raw_input() print "Start of Way 2 -- Create with a join" for i in range(100000): z = string.join(s, '') print "End of Way 2" print z raw_input() print "Start of Way 3" for i in range(100000): z = '' for j in s: z = z + j print "End of Way 3" print z # End of Script This ran amazingly fast on my Pentium 200 Mhz -- around 11 seconds for Way 1, and 7 for Way 2. So, either way, Python can put together about 1 million little strings in a second. Way 3, the way that one would expect to be bad, recreating the string with each concatenation, was much slower, but only took about 1 minute. Surprisingly swift as well. Anybody have anything to add to this? Are there any related pitfalls that I may have missed? Al From wware-nospam at world.std.com Wed Apr 28 00:13:23 1999 From: wware-nospam at world.std.com (Will Ware) Date: Wed, 28 Apr 1999 04:13:23 GMT Subject: Python and C References: <37243B44.AE6231AE@serop.abb.se> <7g5bom$g4n$1@Starbase.NeoSoft.COM> Message-ID: In article <37243B44.AE6231AE at serop.abb.se>, thstr wrote: >I would like to add some kind of command interpreter to which you can >type commands like "test functionA(arg1, arg2, ...)"... >For some reasons I'd like this interpreter in Python (like a static >module), linked with C at compile time, is this possible?? Some resources for this: Go to www.python.org and look under "Documentation", somewhere there is a tutorial on embedding and extending the Python interpreter. This describes how to write a C/Python interface. Doing this by hand is a bit daunting, consider Swig (mentioned below). Look for the book "Programming Python" (author Mark Lutz, publisher O'Reilly). This book may appear a little imposing but it has a lot of good information, including writing C interfaces. Go to www.swig.org, which is about a program called Swig which will automatically generate C/Python interface code from a very simple description of your C functions. -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Will Ware email: wware[at]world[dot]std[dot]com PGP fp (new key 07/15/97) 67683AE2 173FE781 A0D99636 0EAE6117 From aa8vb at vislab.epa.gov Tue Apr 20 08:37:59 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Tue, 20 Apr 1999 12:37:59 GMT Subject: Tkinter performance In-Reply-To: <371B4B39.8B78BC7A@foreman.ac.rwth-aachen.de>; from Greg Landrum on Mon, Apr 19, 1999 at 05:26:49PM +0200 References: <371B4B39.8B78BC7A@foreman.ac.rwth-aachen.de> Message-ID: <19990420083759.A133486@vislab.epa.gov> Greg Landrum: |I am thinking about doing a python/Tkinter port of a program ... |The program does 3D graphics (molecular/crystal visualization |and orbital plots). I handle all of the perspective/transformation |stuff myself, so I don't need any 3D functionality. I do need |something which can draw reasonably quickly however. | |Suppose I need to draw a couple hundred circles and several |thousand line segments (these are mostly connected, so I can |use things like XDrawLines to cut down function calls) at |every update. | |1) Can Tkinter on a "typical" PC (say a P200) deliver a |"reasonable" update rate (a couple of frames per second |would probably cut it)? A few folks already mentioned PyOpenGL and VTK. The plus for OpenGL is of course the use of its display lists which makes redraws much faster. Hopefully TkGS will take off in the Tk world and OpenGL-accelerate the canvas by default when OpenGL is available. VTK is a good option, but just to give you a flavor of raw canvas performance, I can give you some samplings from my experiments. The canvas seems to have good internal optimizations. Given variability of usage (not to mention different platforms which is also an issue), this is just to give you a ballpark idea for performance on UNIX. Using Tk8.0 under Tkinter, here are some times for loading and drawing map lines using Tkinter (under SGI IRIX): Load Times (approx): #lines (#vertices) Onyx Indigo2 600 ( 1,200) 0:02 0:18 2,000 ( 15,000) 0:05 0:30 30,000 (180,000) 0:52 6:00 Draw Rates (worst case - approx): #lines (#vertices) Onyx Indigo2 600 ( 1,200) 6-7 fps 6-7 fps 2,000 ( 15,000) 5-6 fps 5-6 fps 30,000 (180,000) 1 fps 0.4 fps Onyx - 195MHz R10000 Indigo2 - 100Mhz R4000 I should mention that the Indigo2 is local. The Onyx X redraws are traversing a 10base ethernet to get here, so frame rates take a hit there. Note that the canvas seems to have respectable optimizations in place so the less that is visible (e.g. the more you're zoomed in, the faster redraws get. Also if only a partial area needs redrawn, it redraws it fairly quickly relative to the full-expose frame rate. It's obvious there's some optimization going on when you load to make drawing faster. I wish there were a "bulk-load" feature so this loading would be faster. Also, operations which can occur in C code are quick. E.g. telling the canvas to scale and translate all 180,000 vertices (used for zooming the canvas) occurs in around 1-2 seconds even on the slower Indigo2. |2) Is there anyway to do double-buffering to avoid flashing |during redraws? It may be completely different on your OS, but here on SGI IRIX, redraws appear all at once. It may be drawing into an off-screen pixmap/image, and blitting to the screen. At any rate, no flashing occurs. YMMV. You might just try loading up some of your data. It really takes very few lines of code to load up the canvas and play with performance. Be sure to set width=0 for your lines. This appears to enable some internal optimizations for drawing lines: canvas.create_line( vertices, width=0, fill="white" ) If the performance you see appears marginal, you might look into using VTK. It's got good coverage of visualization primitives and operations. It will use OpenGL when present (so you get use of your hardware display lists for fast redrawing). It also supports (unlike the canvas) level-of-detail rendering. So if the refresh rate isn't up to a certain threshold, it will render objects using a simpler representation (bounding box, etc). to keep interactivity up during pans, zooms, etc. and then render in full detail when the "render-barrage" quits. I've worked with these same datasets in VTK, registering them as PolyData with LODActors and gotten much better interactive performance. Randall From billtut at microsoft.com Tue Apr 13 12:22:26 1999 From: billtut at microsoft.com (Bill Tutt) Date: Tue, 13 Apr 1999 16:22:26 GMT Subject: site.py & COM startup Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB90B2B@RED-MSG-50> I typically do something like: k_strModuleName = "swv2Phoenix" if __name__ == "__main__": import win32com.server.register import sys, regsetup # The next line is the equivalent of regsvr32 for a Python COM server. win32com.server.register.UseCommandLine(swMapping) # Tell the python DLL where to find this .py file regsetup.FindRegisterModule(k_strModuleName, k_strModuleName + '.py', sys.path) The call into regsetup, alters the Python registry settings to register where the .py file is located at. Bill From dalke at bioreason.com Thu Apr 15 13:04:38 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Thu, 15 Apr 1999 11:04:38 -0600 Subject: 1.5.2 broke IRIX module loading References: <19990414110116.A1374923@vislab.epa.gov> Message-ID: <37161C26.C121CA1E@bioreason.com> Randall Hopper said: > I built and tried 1.5.2 this morning, and it failed to load a module > that worked fine on 1.5.1. We had the same problem on our SGIs. In our case, our vendors accidentally shipped .a files with functions which reference other functions of theirs which they didn't ship. We used SWIG to create a .so files from the .a, and with the removal of RTLD_GLOBAL, this means we can no longer import our module with 1.5.2 . This change was discuessed on the newsgroup some months back (sorry, don't have a DejaNews reference handy) and the outcome was that libraries shipped in this form are broken, and it must be done this way so different shared libraries don't get namespace collisions. For us there were two ways around it: 1) upgrade to our vendor's newest libraries 2) create dummmy C functions which resolve the functions > "currstep" is the internal FORTRAN routine which has been zeroed-out. But I don't know what zeroed-out means in this context. For me I found which were missing with "nm library.so | grep UNDEFINED" I mentioned this problem to Guido when I tested 1.5.2c1 on our SGIs; not that it had to be changed back but that people were going to find this change unexpected. Here are his comments: Guido said: | Unfortunately the conclusion of the debate about this was unanimously | that using RTLD_GLOBAL is evil; even though it solves some real | practical problems in some cases (like yours), it can break other | things for which the only fix is to remove RTLD_GLOBAL. The cases | where it is needed are always caused by bad programming (e.g. your | vendor's). Sorry. | | [....] | | > And, if not, I'll just put "| RTLD_GLOBAL" into my dlopen. | | That would be the easiest solution for you, as long as you don't run | into the other problem (conflicting externals defined in two | libraries). Andrew Dalke dalke at bioreason.com From bernhard at alpha1.csd.uwm.edu Sun Apr 11 00:22:20 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 11 Apr 1999 04:22:20 GMT Subject: pythonwin COM Update link out of date References: <7em639$fto$1@m2.c2.telstra-mm.net.au> Message-ID: On Sat, 10 Apr 1999 10:30:55 +1000, Mark Hammond wrote: >Bernhard Reiter wrote in message ... >>http://www.python.org/ftp/python/pythonwin/pwindex.html#oadist >Hmmmm.... is there a potential danger in installing oadist.exe? >There _shouldnt_ be any danger! Okay, I will try it, after I have mae a full backup in a few days. >These days it is getting quite unnecessary. If you have (I believe) IE4 or >Office 97, you are pretty up-to-date, and that includes many PCs these days. Hmm Excel'97 is on this machine, but not IE4? >You could try installing the Python stuff, and see if it works. Most works, but the win32 stuff doesn't. > Also, see >my other post this morning as to why the install may fail - try this out >first. Both libraries are excactly the ones in the .zip archive. Version 1.5.0.124 Bernhard From news at dorb.com Sat Apr 3 10:45:47 1999 From: news at dorb.com (Darrell) Date: Sat, 3 Apr 1999 10:45:47 -0500 Subject: Rat sighting online References: <199904021940.MAA04204@shell.rmi.net> Message-ID: I don't knowing much about Java so I tried the Jpython example and got stuck. It imports pickle which imports struct. Jpython doesn't seem to have struct ? From aa8vb at vislab.epa.gov Fri Apr 16 06:29:19 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 16 Apr 1999 12:29:19 +0200 Subject: 1.5.2 broke IRIX module loading In-Reply-To: <37161C26.C121CA1E@bioreason.com>; from Andrew Dalke on Thu, Apr 15, 1999 at 11:04:38AM -0600 References: <19990414110116.A1374923@vislab.epa.gov> <37161C26.C121CA1E@bioreason.com> Message-ID: <199904161054.GAA09635@ethyl.rtpnc.epa.gov> Thanks for the reply. |> "currstep" is the internal FORTRAN routine which has been zeroed-out. | | But I don't know what zeroed-out means in this context. For me |I found which were missing with "nm library.so | grep UNDEFINED" I don't know exactly how they built this library, but somehow they internalized the FORTRAN function names so that they are not exported by the FORTRAN objects (e.g. currstep in currstep.o), while a dangling reference exists to them in the C wrapper object (e.g. currstepc.o): Symbols from currstep.o: [Index] Value Size Class Type Section Name [0] | 0| |File |ref=16 |Text | /tmp_mnt/pub/storage/xcc/work/m3io/currstep.f [1] | 0| |Proc |end=15 unsigned long |Text | currstep_ ->[2] | -8| |Local |unsigned long |Abs | currstep Symbols frstepc [Index] Class Type Section Name [0] | 0| |File |ref=15 |Text | /tmp_mnt/pub/storage/xcc/work/m3io/currstepc.c [1] | 0| |Proc |end=14 int |Text | currstepc [13] | 420| |End |ref=1 |Text | currstepc ->[101] | 0| |Proc | |Undefined| currstep If one links with and calls any of these wrappers (e.g. currstepc()), it works fine. Randall From ajung at sz-sb.de Thu Apr 8 01:21:27 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Thu, 8 Apr 1999 05:21:27 GMT Subject: oracledb-0.1.2 and python 1.5.2b2 In-Reply-To: <8825674C.007BA8E4.00@marshall.com>; from Lance Ellinghaus on Wed, Apr 07, 1999 at 03:30:35PM -0700 References: <8825674C.007BA8E4.00@marshall.com> Message-ID: <19990408072127.A6184@sz-sb.de> On Wed, Apr 07, 1999 at 03:30:35PM -0700, Lance Ellinghaus wrote: > > Has anyone gotten these two things to compile together and run? > I am having trouble with the compile. Looks like something changed in the > Makefile on Python 1.5.2b2 from > previous python make files that makes oracledb-0.1.2 not compile. > > Why don?t you use DCOracle available on www.zope.org ? -- _\\|//_ (' O-O ') ------------------------------ooO-(_)-Ooo-------------------------------------- Andreas Jung, Saarbr?cker Zeitung Verlag und Druckerei GmbH Saarbr?cker Daten-Innovations-Center Gutenbergstr. 11-23, D-66103 Saarbr?cken, Germany Phone: +49-(0)681-502-1528, Fax: +49-(0)681-502-1509 Email: ajung at sz-sb.de (PGP key available) ------------------------------------------------------------------------------- From vkolosov at usa.net Mon Apr 12 23:28:55 1999 From: vkolosov at usa.net (VICTOR KOLOSOV) Date: Tue, 13 Apr 1999 03:28:55 GMT Subject: Error loading 'binascii' Message-ID: <19990413032855.10759.qmail@nw179.netaddress.usa.net> Hi all, It seems like I've got this error already on two boxes, one runs FreeBSD and the other one runs Solaris2.6 Could anyone try it on his/her machine and see if it works or may be it is damaged in distributions installed here. Before trying the below 'import binascii' I've tried to encode a file with mimetools.py module and it gave me a core dump write in this 'import binascii' place. % python Python 1.5.1 (#2, Oct 12 1998, 15:11:45) [GCC 2.7.2.1] on freebsd3 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import binascii Traceback (innermost last): File "", line 1, in ? ImportError: /usr/local/lib/python1.5/lib-dynload/binascii.so: Undefined symbol "PyDict_SetItemString" >>> ____________________________________________________________________ Get free e-mail and a permanent address at http://www.netaddress.com/?N=1 From faassen at pop.vet.uu.nl Wed Apr 21 16:00:02 1999 From: faassen at pop.vet.uu.nl (Martijn Faassen) Date: Wed, 21 Apr 1999 22:00:02 +0200 Subject: How many of us are there? References: <371E2648.DED123AE@callware.com> Message-ID: <371E2E42.AF36F73C@pop.vet.uu.nl> Ivan Van Laningham wrote: > > Hello, Pythonistas-- > Does anyone out there have some idea how many people subscribe to the > mailing list, or read the newsgroup? > > -ly y'rs, Okay, I read the newsgroup. I'm here! Count me in! :) Okay-I-guess-that-wasn't-helpful-ly yours, Martijn From tim_one at email.msn.com Sat Apr 17 13:08:41 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 17 Apr 1999 17:08:41 GMT Subject: Why no "=" in if? (was Re: Quick fix to add "+=") In-Reply-To: References: Message-ID: <000401be88f4$f126c440$ee9e2299@tim> > can't-wait-for-a-resumption-of-the-assignment-expression-thread-ly > y'rs - tim [Aahz Maruch] > I'm getting really sick of the way I have to use this stupid construct: > > x = foo() > if x: > ... > > instead of > > if x = foo(): > ... > > Why doesn't Guido get off his duff and fix this?????????! [John Baxter] > Because it's not broken. [Aahz] > Yes, it is. Excellent! We've now summarized in just 3 brief messages just about everything that was said over the course of (literally) hundreds of msgs the last time this came up <0.1 wink>. If anyone wants to continue this now, consider just posting a link to the DejaNews article you would have otherwise rewritten. can't-wait-for-the-resumption-of-the-indexing-thread-ly y'rs - tim From hat at se-46.wpa.wtb.tue.nl Fri Apr 23 10:22:07 1999 From: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) Date: 23 Apr 1999 14:22:07 GMT Subject: Suggestion for alternative to map/filter functions Message-ID: Hello all, While reading the tutorial, I noticed that Python has map and filter functions. In our language we also had them, but they were replaced by another language construct. Unfortunately, I don't have time and experience enough to put this in python myself, but if people are interested in it, I can provide details. Albert --- Look ma, windows without Windows !! From you at you.com Tue Apr 27 05:48:32 1999 From: you at you.com (Gambler) Date: Tue, 27 Apr 1999 09:48:32 GMT Subject: Free US$5 for your gambling Message-ID: <3725B240.52CED5E8@you.com> Hello everybody, Once you sign-up and register for a new user, you will have US$5 for gambling! You ONLY download the setup file and install it. or try to visit these sites: Cyber Thrill Casino Avatar Casino -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: casino.exe Type: application/octet-stream Size: 69155 bytes Desc: not available URL: From invalid.address at do.not.email Thu Apr 8 17:25:44 1999 From: invalid.address at do.not.email (guppy) Date: Thu, 08 Apr 1999 21:25:44 GMT Subject: Crappy Software was Re: [OffTopic: Netscape] Re: How should References: <370c7a2d.35857749@news.bctel.ca> <1288614834-78399188@hypernet.com> Message-ID: <37111e88.2387062@news.bctel.ca> On Thu, 8 Apr 1999 06:39:21 GMT, boud at rempt.xs4all.nl wrote: >Gordon McMillan wrote: >: >: There's even a difference between exiting from the file menu and >: closing from the title bar. >: >: When's the last time you closed a GUI from the file menu?? >: >: Sheesh. >: > >That rings a bell - it also occurred in the last version of Oracle >Forms 4.5 I had the misfortune to work with. Worse, closing the app >with alt-spacebar (for the system menu) would hang the whole of >Windows. Gahd. Yet another way to do it. The guy at Mackido (dunno the URL offhand) documents twenty-odd other ways to close an app. Macintosh has three or four. One can develop quite a significant despisal of Windows when one starts realizing just how lousy an interface it has... -- MSpeak: in-no-va-tion, n. 1. extending or modifying existing standards in undocumented ways. 2. creating new, undocumented standards. --de-com-mod-it-ize, v. From tim_one at email.msn.com Thu Apr 8 02:26:17 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 8 Apr 1999 06:26:17 GMT Subject: Chaning instance methods In-Reply-To: <370C2904.A6F4BD54@inrialpes.fr> References: <370C2904.A6F4BD54@inrialpes.fr> Message-ID: <000801be8188$b59aa9a0$749e2299@tim> [Vladimir Marangozov, with much good advice] > ... > Thus we arrive at the easy & boring solution, which goes along > these lines: > (it's an instance hack too, but a recognized one in metaobject > communities) > > >>> class Foo: > ... def m(self): > ... print "Foo.m" > ... > >>> f = Foo() > >>> f.m() > Foo.m > >>> > >>> def m2(self): > ... print "m2" > ... > >>> class Bar(f.__class__): pass > ... > >>> Bar.m = m2 > >>> > >>> f.__class__ = Bar # f changes its camp > >>> f.m() > m2 When I signed my exposition of instance-method trickery "subclassing-is- a-lot-easier-ly y'rs", I had exactly this in mind: class Bar(Foo): def m(self): print "m2" f = Bar() Over the years, *most* people who have asked questions akin to Jody's really could have done this-- the *wholly* obvious thing! --from the start. Maybe it's a "define a whole new class just to change one method?!" reluctance left over from C++ <0.9 wink>. catering-to-laziness-can-be-counterproductive-ly y'rs - tim From heinkel at embl-heidelberg.de Mon Apr 12 02:50:42 1999 From: heinkel at embl-heidelberg.de (Ralph Heinkel) Date: 12 Apr 1999 06:50:42 GMT Subject: bug report: profiler Message-ID: <7es542$94v$1@beta.EMBL-Heidelberg.DE> Hi, when trying to run the profiler calibration explained in the python documentation, I got the following error: Python 1.5.1 (#8, Dec 18 1998, 09:42:46) [GCC 2.7.2.1] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import profile >>> pr = profile.Profile() >>> print pr.calibrate(100) Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.5/profile.py", line 498, in calibrate self.instrumented() File "/usr/local/lib/python1.5/profile.py", line 515, in instrumented self.profiler_simulation(a, a, a) File "/usr/local/lib/python1.5/profile.py", line 520, in profiler_simulation t = t[0] + t[1] AttributeError: __getitem__ Ralph -- ------------------------------------------------------ Ralph Heinkel European Molecular Biology Laboratory (EMBL) Meyerhofstr. 1 69012 Heidelberg Tel. +49 6221/387 529 eMail: heinkel at dummy.embl-heidelberg.de Please remove the 'dummy' from my email address. From aa8vb at vislab.epa.gov Wed Apr 14 08:10:51 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Wed, 14 Apr 1999 12:10:51 GMT Subject: Python 1.5.2 Build Caveat Message-ID: <19990414081051.A1364941@vislab.epa.gov> Just got it built this morning. If $PYTHONPATH (used to "augment" the Python run-time module search path) is set when building Python v1.5.2, this "overrides" the default search path and prevents Python from finding it's own modules unaided. This wasn't intuitive behavior to me. $PYTHONPATH needs to be set to add run-time search directories. If used by the build process at all, it should be for adding default search directories, not overriding the default. Personally, I'd favor not even using $PYTHONPATH in the build process. That's the function of configure --prefix. Randall From aa8vb at vislab.epa.gov Mon Apr 19 10:24:06 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Mon, 19 Apr 1999 14:24:06 GMT Subject: 'import exceptions' failed In-Reply-To: <371B1201.392B@iname.com>; from Jussi Jumppanen on Mon, Apr 19, 1999 at 10:22:41PM +1100 References: <371B1201.392B@iname.com> Message-ID: <19990419102406.B62714@vislab.epa.gov> Jussi Jumppanen: |I have compiled the python source into a Windows DLL and using ... |the macro runs fine and produces the expected ouput in the |text editor, but I also get the following messages sent to |stderr: | | 'import exceptions' failed; use -v for traceback | defaulting to old style exceptions | 'import site' failed; use -v for traceback I don't know if your case is the same, but when I saw this, I discovered that if $PYTHONPATH (normally used to augment Python's run-time module search path) is defined when Python is built. This completely overrides the default Python search path which it uses to find its own modules. As I recall, "import exceptions" was the first thing it complained about. I think site was the second but I'm not certain. Randall From mfletch at vrtelecom.com Sat Apr 24 18:08:00 1999 From: mfletch at vrtelecom.com (Mike Fletcher) Date: Sat, 24 Apr 1999 22:08:00 GMT Subject: Some win32 registry functions (black, dangerous magic) Message-ID: I often have the desire to create/modify registry entries which are not the "default" entries, and until today I've always considered this stuff very black magic (why two types of every function, why do I need to open a key, yada, yada). The following is a module which provides a few features beyond the regutil.py package distributed with win32all... 1) You specify keys as single paths, not root-key+path 2) You can store non-int/non-string objects (pickled) 3) You can store named values with the same command as default values 4) Has a "register python scripts as executables" function (example, NT only) 5) Has an "add directory to system path" function (example, NT only) I'd appreciate it if the Windows gurus could take a look and point out anything I've done which might scramble someone's registry. This is a blatant rip-off of Mark Hammond's regutil.py . Hereby released for whatever purpose, but at your own risk. No warranties expressed, implied or scandalised. 8<____________________ regutilsex.py _____ import win32api, win32con, string, types def _getDataType( data, coerce = 1 ): ''' Return a tuple of dataType, data for a given object automatically converts non-string-or-tuple-data into strings by calling pickle.dumps ''' if type( data ) is types.StringType: return win32con.REG_SZ, data elif type( data ) is types.IntType: return win32con.REG_DWORD, data # what about attempting to convert Longs, floats, etceteras to ints??? elif coerce: import pickle return win32con.REG_SZ, pickle.dumps( data ) else: raise TypeError, '''Unsupported datatype for registry, use getDataType( data, coerce=1) to store types other than string/int.''' def _getBaseKey( fullPathSpec ): ''' Split a "full path specification" registry key into its root and subpath components ''' key = '' subkey = fullPathSpec # while loop will strip off preceding \\ characters while subkey and not key: key, subkey = string.split( fullPathSpec, '\\', 1 ) try: return getattr( win32con, key ), subkey except AttributeError: raise '''Unknown root key %s in registry path %s'''% (key, fullPathSpec) def RegSetValue( key, valuename='', data='', allowPickling=1 ): ''' Set a registry value by providing a fully-specified registry key (and an optional sub-key/value name), and a data element. If allowPickling is true, the data element can be any picklable element, otherwise data element must be a string or integer. ''' root, subkey = _getBaseKey( key ) dataType, data = _getDataType( data, allowPickling ) try: hKey = win32api.RegOpenKeyEx( root , subkey, 0, win32con.KEY_ALL_ACCESS) # could we use a lesser access model? except: hKey = win32api.RegCreateKey( root, subkey ) try: if not valuename: # the default value win32api.RegSetValue( hKey, valuename, dataType, data ) else: # named sub-value win32api.RegSetValueEx( hKey, valuename, 0, dataType, data ) finally: win32api.RegCloseKey( hKey) def RegQueryValue( key, valuename='', pickling=0 ): ''' Get a registry value by providing a fully-specified registry key (and an optional sub-key/value name) If pickling is true, the data element will be unpickled before being returned. ''' #print 'key', key root, subkey = _getBaseKey( key ) if not valuename: # the default value data, type = win32api.RegQueryValue( root , subkey) else: try: #print root, subkey hKey = win32api.RegOpenKeyEx( root, subkey, 0, win32con.KEY_READ) #print hKey, valuename try: data, type = win32api.RegQueryValueEx( hKey, valuename ) except: # data, type = None, 0 # value is not available... should we raise an error here instead??? pickling = None finally: win32api.RegCloseKey( hKey) if pickling: import pickle data = pickle.loads( data ) return data ################## EXAMPLES FOLLOW def AddPathEntry( newEntry, user = 1, prepend=0 ): ''' Add or remove path entry on NT, use prepend == -1 for removal, use prepend == 0 for append, prepend= 1 for prepending to the current path. ''' if user: user = 'USER' else: user = 'MACHINE' key, valuename = COMMON_KEYS[ (user, 'PATH') ] _PathManager( key, valuename, newEntry, prepend ) def PyExecutables( user = 1, prepend=0 ): ''' Register/Deregister Python files as executables ''' if user: user = 'USER' else: user = 'MACHINE' key, valuename = COMMON_KEYS[ (user, 'PYEXECUTABLES') ] # the default executables + Python scripts... if prepend < 0: # are to eliminate only .py newEntry = '.PY' else: newEntry = '.PY;.COM;.EXE;.BAT;.CMD' _PathManager( key, valuename, newEntry, prepend ) def _PathManager( key, valuename, newEntry, prepend=0, eliminate_duplicates=1 ): ''' Create a new Path entry on NT machines (or kill an old one) user determines whether to alter the USER or the Machine's path prepend 1 -> add newEntry to start 0 -> add newEntry to end -1 -> don't add newEntry eliminate_duplicates determines whether to kill equal paths All values are converted to lower case ''' # get current value... curval = RegQueryValue( key, valuename ) or '' # split into elements curval = string.split( string.lower(curval), ';' ) if type( newEntry ) not in (types.ListType, types.TupleType): newEntry = string.split( string.lower(newEntry), ';' ) # eliminate duplicates of the newEntry curval = map( None, curval) # strip out null entries if eliminate_duplicates: newval = [] for p in curval: if p not in newEntry: newval.append( p ) curval = newval if prepend == 1: curval = list(newEntry) + curval elif prepend == 0: curval = curval + list( newEntry ) elif prepend == -1: # this call is just killing the path entry pass #now do the recombination curval = string.join( curval, ';' ) RegSetValue( key, valuename, curval ) # following constants seem to reflect where path data is stored on NT machines # no idea if it'll work on a 95 machine COMMON_KEYS = { ('USER','PATH') : ('''HKEY_CURRENT_USER\\Environment''', 'path'), ('MACHINE','PATH') : ('''HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment''', 'path'), ('USER','PYEXECUTABLES') : ('''HKEY_CURRENT_USER\\Environment''', 'pathext'), ('MACHINE','PYEXECUTABLES') : ('''HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment''', 'pathext') } ____________________________________________________ Mike C. Fletcher -- Virtual Environment Designer mcfletch at vrtelecom.com http://www.vrtelecom.com From aa8vb at vislab.epa.gov Fri Apr 16 17:40:16 1999 From: aa8vb at vislab.epa.gov (Randall Hopper) Date: Fri, 16 Apr 1999 21:40:16 GMT Subject: Tkinter Canvas & Fast Scrolling/Dragging Message-ID: <19990416174016.A1559856@vislab.epa.gov> Since the Canvas doesn't implement a "level of detail" control, I'd like implement it. Basically, what I want to do is turn off filling of canvas objects temporarily while the user is scrolling the canvas or they're dragging one of the shapes. When the operation is finished (user releases the mouse), I'll turn fill back on. The idea here being that the canvas seems to be pretty responsive for me until it has to draw stipple shapes. Then it's painfully slow. I know how to do this for dragging, but I don't know where to "hook in" for scrolling. Any suggestions? Thanks, Randall From donn at u.washington.edu Mon Apr 12 13:38:45 1999 From: donn at u.washington.edu (Donn Cave) Date: 12 Apr 1999 17:38:45 GMT Subject: forking + stdout = confusion References: <7jlnfyowd3.fsf@gandalf.midearth.fuzzys.org> Message-ID: <7etb35$16v2$1@nntp6.u.washington.edu> Julien Oster writes: ... | I ran in exactly the same problem. I tried closing all stdxxx-filedescriptors, | setting a new session id with setsid, also tried it with setting a new | progress groups, and I even tried to reopen stdin, stderr and stdout to | /dev/null, but nothing helped. Then I saw that in OpenBSD, there's a function | in stdlib.h called "daemon()". You simply call it, and it puts the running | program in the background (it forks and exits the parent), redirects the | stdxxx-descriptors, sets a new session ID etc... and with this function, it | works! I wonder if you could get the effect by iteratively closing all potential file descriptors? This is a pretty common sight in service daemon programs. In Python it's a little more awkward because you have to guess the range of possible descriptors, which a C program could get from getdtablesize(). wereopen = [] for i in range(128): try: os.close(i) wereopen.append(i) except os.error: pass fp = open('log', 'w') fp.write('closed units %s\n' % repr(wereopen)) The other things I've seen daemon() do are basically Berkeley terminal driver issues, to drop the controlling terminal and isolate the program from the job control session that started it -- not relevant there, since the HTTP service daemon didn't start it that way. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From bwizard at bga.com Sun Apr 25 19:01:34 1999 From: bwizard at bga.com (Purple) Date: Sun, 25 Apr 1999 23:01:34 GMT Subject: Handling backspace chars in a string... Message-ID: <37239c48.594910176@news2.bga.com> I'm in the posistion of having to process strings with arbitrary numbers of backspace and newline characters in them. The backspaces actually get put in the string, so I have to handle removing the characters that are backspaced over. Currently I'm doing this something like this (hastily retyped mostly from memory so forgive any small errors and/or typos) : i = len(str) while ktr < i: if string[ktr] == '\b': bBegin = ktr backs = 0 while string[ktr] == '\b': backs = backs + 1 ktr = ktr + 1 if backs > (ktr - backs - 1): # backs > prior chars string = string[bBegin+backs:] ktr = 0 else: string = string[:bBegin-backs] + string[ktr:] ktr = bBegin - backs i = len(str) ktr = ktr + 1 This just looked rather messy to me -- I was curious if anyone know a better way? From ivnowa at hvision.nl Tue Apr 20 18:14:50 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Tue, 20 Apr 1999 22:14:50 GMT Subject: User-defined variables / compilation In-Reply-To: <371C92BA.2C6C883F@igd.fhg.de> References: <371C92BA.2C6C883F@igd.fhg.de> Message-ID: <199904202112.XAA21411@axil.hvision.nl> On 20 Apr 99, Ce'Nedra took her magical amulet and heard Jan Thomczek say: >Hello, > >I?m new to this newsgroup and maybe you?ll say "Wow! What a stupid >question..." I think you?re right- No way... There are no stupid questions... Although that "why no +=" question comes pretty close... ;^) >I used to program in Turbo-Pascal 6. I installed Python on my NT >4.0-machine. > >I wonder how is the procedure to define the varibles by a user like >"readln(x);" I?m sure there is a simple way to do so. I'm not sure what you mean... do you mean, how to write a function that is able to change the value of x? Since that's what ReadLn does... Th answer is: you can't. You can use a function instead; in this case, Python has raw_input for this, and you just call it like this: myname = raw_input("Hi! What's your name? ") which is more or less equivalent to Turbo's Write('What''s your name? '); ReadLn(MyName); >Another question is: How do I *compile* the lines I have written to an >*.exe-file? There are some tools for this... I never used them myself though. Look into DejaNews for 'freeze'. I'm sure others can tell you more about this. + Hans Nowak (Zephyr Falcon) + Homepage (under construction): http://www.cuci.nl/~hnowak/ + You call me a masterless man. You are wrong. I am my own master. + May a pirate chase you for your mashed potatoes! From rhww at erols.com Mon Apr 19 19:21:22 1999 From: rhww at erols.com (R Wentworth) Date: Mon, 19 Apr 1999 19:21:22 -0400 Subject: Using JPython in servlets? Message-ID: <371BBA72.5D24945F@erols.com> I don't know if this newsgroup is intended to deal with issues regarding JPython (implementation of Python that is tightly coupled to Java and runs under the JVM), but if this is an appropriate forum... Can anyone tell me the secret(s) to getting JPython servlets to run, or even allowing JPython classes to successfully be accessed from a Java servlet? (This is under JRun, latest version, and Java 1.1.7, running under Solaris.) I'm running into a seemingly bizarre problem. Here is a simple example of what I'm seeing: -- J.java -- public abstract interface J {} -- X.py -- import J class X(J): pass -- Test.java -- ...working servlet code... new X(); ...working servlet code continued... ---------------- Symptom. Access the servlet GET method via the web, and see a page titled "JRun Servlet Error": Test: Traceback (innermost last): (no code object) at line 0 AttributeError: class 'X' has no attribute 'X' ---------------- I *have* managed to discover one other circumstance that produces this same type of error. Suppose I have a Java application (as opposed to a servlet) which tries to do "new X()". This works just fine if CLASSPATH is set to the value seen by servlets, i.e., a CLASSPATH including "jpython.jar"; however, if I alter the CLASSPATH so that it points to either no jpython libraries, or to an unzipped version of jpython.jar, then I get a "class 'X' has no attribute 'X'" error. So it seems like the error may have something to do with not being able to get at appropriate JPython library code. But the servlet CLASSPATH *does* include "jpython.jar", so this wouldn't seem to explain the problem. Anyone have any clue whatsoever about what might be wrong with the configuration, or how I might go about debugging this?? Thanks in advance, Robert Wentworth rhww at erols.com From nathan.froyd at rose-hulman.edu Sun Apr 25 02:10:54 1999 From: nathan.froyd at rose-hulman.edu (Nathan Froyd) Date: 25 Apr 1999 01:10:54 -0500 Subject: pickling and unpickling on the same file? References: <01c001be8edb$066c5ea0$0301a8c0@cbd.net.au> Message-ID: "Mark Nottingham" writes: > Have you looked at the shelve module? > > Is there any way to implement the above beast? Something like: > > > > p = Pickler(file) > > u = Unpickler(file) > > > > file.seek(random_pos) > > x = u.load() > > > > z = [7, 8, 9] > > p.dump(z) > > > > would be perfect No, I haven't -- I have to implement a weenie database on my own, and I thought that anything that interfaced to an already-written database would not be good. :) But the point is moot, because the above code does work in my example file. It didn't work before. I'm not sure what I changed, but I'm happy that it did! -- Nathan | nathan.froyd at rose-hulman.edu | http://www.rose-hulman.edu/~froydnj/ God went through hell so we don't have to. ICQ:18861764 | AOL:myrlyn007 Avoid the gates of hell. Use Linux. Python:"x='x=%s;x%%`x`';x%`x`" Evolution is a million line computer program falling into place by accident. From francois.bedard at usa.net Sun Apr 11 01:10:09 1999 From: francois.bedard at usa.net (Francois Bedard) Date: Sun, 11 Apr 1999 05:10:09 GMT Subject: Python's object model Message-ID: <37102ED0.933EDDA6@usa.net> Hello, I'm new at Python. In the following program, "stack_1 pops stack_2's content" (that's actually what it prints), which is obviously not what I'm after - nor would expect. Is this how Python's object model really works (kindly explain), is there some arcane rule that I've missed, or is there some obvious mistake I just can't see? Aside from a few such quirks, it's quite an interesting language (I'm using 1.5.1 - on both Linux and NT). Thanks, Francois ------------------------------------- class Stack: stack = [] def push(self, value): self.stack.append(value) def pop(self): result = self.stack[-1] del self.stack[-1] return result class System: stack_1 = Stack() stack_2 = Stack() def __init__(self): self.stack_1.push('stack_1\'s content') self.stack_2.push('stack_2\'s content') print 'stack_1 pops', self.stack_1.pop() # 'main' system = System() From palpa at bogus.bogus.com Fri Apr 16 13:24:44 1999 From: palpa at bogus.bogus.com (Henrique Almeida) Date: Fri, 16 Apr 1999 14:24:44 -0300 Subject: pty, qwsv and Python Message-ID: <3717725B.34F2E34A@bogus.bogus.com> Warning: NO native speaker ahead. Hi. I'm new to Python (only started looking at the docs yesterday). I want to know if it is possible to control a qwsv (quake world linux server) using Python: ie do a "status" command in the qwsv every 5 minutes, process the returned code, watch for some string in the pty... After searching the Python home page it looks like popen2() is the way to go. Is it? Also, is it possible to use "screen" (a program that let me "detach" the server) and "popen2" at the same time? I would like have a interactive session to qwsv to do administration. Thanks. From paul at prescod.net Mon Apr 26 14:39:18 1999 From: paul at prescod.net (Paul Prescod) Date: Mon, 26 Apr 1999 18:39:18 GMT Subject: Python too slow for real world References: <372068E6.16A4A90@icrf.icnet.uk> <3720A21B.9C62DDB9@icrf.icnet.uk> <3720C4DB.7FCF2AE@appliedbiometrics.com> <3720C6EE.33CA6494@appliedbiometrics.com> <37215EFB.433AFCA6@prescod.net> Message-ID: <3724B2D6.B468687A@prescod.net> Roy Smith wrote: > > It is extremely rare that regex compilation time is a major issue. I didn't mean to imply it was. Justin asked about the benefits of "first class regexps" so I pointed out one. > If > you're using a regex inside your inner loop and the amount of data you > feed through it is large enough to matter, you should be compiling it > yourself outside the loop. It's still done at run-time, but it's only > done once so it's almost certainly a trivial amount of time devoted to > that. It is a performance issue if you don't know that regexps are supposed to be compiled. Plus it is a code complexity issue. Having the language handle it for you automatically is in keeping with other aspects of Python's design. Heck, I don't even have to compile Python *programs*. -- Paul Prescod - ISOGEN Consulting Engineer speaking for only himself http://itrc.uwaterloo.ca/~papresco Company spokeswoman Lana Simon stressed that Interactive Yoda is not a Furby. Well, not exactly. "This is an interactive toy that utilizes Furby technology," Simon said. "It will react to its surroundings and will talk." - http://www.wired.com/news/news/culture/story/19222.html From roy at popmail.med.nyu.edu Wed Apr 14 13:04:23 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Wed, 14 Apr 1999 13:04:23 -0400 Subject: forking + stdout = confusion References: <87n20caldg.fsf@spock.localnet.de> Message-ID: > >>> import sys > >>> sys.getrefcount (sys.stdout ) > 5 > > Five! I don't know where all of those are... Yowza! That certainly explains a lot of the problems I had! -- Roy Smith New York University School of Medicine From ajung at sz-sb.de Mon Apr 19 03:25:25 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Mon, 19 Apr 1999 07:25:25 GMT Subject: bzip2 module for Python Message-ID: Is there a module for the bzip2 compression library available or in the making ? Thanks Andreas From olipt at mayo.edu Tue Apr 20 08:54:26 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Tue, 20 Apr 1999 07:54:26 -0500 Subject: what is reloc error ? In-Reply-To: <371A1E26.846AF8B6@pk.highway.ne.jp> References: <371A1E26.846AF8B6@pk.highway.ne.jp> Message-ID: > Hello, everyone. > I am now working on building Python interface > to my C++ matrix library. > > I have a problem. > After compiling and when trying to import my > module > I get following message. > > % gcc -c XXXtype.cc > % gcc -c subXXXtype.cc > ....................... > % ld -o XXXtype.so -dy -G -g *.o -lstdc++ > % python -c "import XXXtype" > python: can't handle reloc type > <====this!!! I'm not entirely sure if this will fix your problem, but I think you need to give a flag to gcc to tell it to make a shared library. Try gcc -fPIC -c *.cc # not sure if this is necessary with gcc and ld -shared -o XXXtype.so *.o Good luck, Travis From fredrik at pythonware.com Fri Apr 30 08:15:47 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 30 Apr 1999 12:15:47 GMT Subject: info References: <37260fc0.3063146@news.tiscalinet.it> Message-ID: <002801be9303$2fb1a9b0$f29b12c2@pythonware.com> > Where I can find any docs about Python' semantics ? http://www.python.org http://www.python.org/doc/ From duncan at rcp.co.uk Thu Apr 15 04:45:36 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 15 Apr 1999 08:45:36 GMT Subject: stupid Win-CGI getting started question References: <7f0f0h$pfb$1@nnrp1.dejanews.com> <8DA86302Bduncanrcpcouk@news.rmplc.co.uk> <7f2db8$dev$1@nnrp1.dejanews.com> Message-ID: <8DA96361Fduncanrcpcouk@news.rmplc.co.uk> bill_seitz at my-dejanews.com wrote in <7f2db8$dev$1 at nnrp1.dejanews.com>: >I tried your test.cmd (after changing the first line, using your quoted path >and making it my path of course). Now I get a response back of internal or >external command, operable program or batch file. The server acts shows this >as a successful delivery (no error in the logs, status=200). Does that mean >the problem is now within Python? Looks like you are getting the second line of the message: The name specified is not recognized as an internal or external command, operable program or batch file. It sounds like you still don't have the right path to python, or it is protected so you can't access it. I would check the file permissions: you probably need to give SYSTEM (or whatever user the CGI process is running as) on the web server full access to the python directory. Try creating a CGI cmd file like this: ----access.cmd--------- @echo Content-type: text/plain @echo "" @echo on dir d:\ dir "d:\program files" dir "d:\program files\python" ----end of access.cmd--------- That should show you the python directory, if not, you need to change the permissions. -- Duncan Booth duncan at dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan From heather at thalamus.wustl.edu Mon Apr 12 17:22:08 1999 From: heather at thalamus.wustl.edu (Heather A. Drury) Date: 12 Apr 1999 16:22:08 -0500 Subject: event loops using tkinter & VTK Message-ID: <7eto60$bgi@thalamus.wustl.edu> Hi, I'm trying to write of a general-purpose volume slice viewer using VTK and python with Tkinter. I've got most of it working (with David Gobbi's vtkImageReslice). I am trying to design the software so that the current slice can be changed using a slider (this works) and the slice image can be zoomed/panned by clicking in the vtkRender window and continuously capturing mouse events (middle mouse = zoom, for example). Currently, I can *either* use the tkinter slider to change the slice *or* remap the buttons in the vtkRenderWindowInteractor function to zoom/pan (although how do I do continuous polling?), but not both simultaneously (as they have independent event loops). Can I create one big event loop that can deal with both continuous cursor reading from the vtkRender window and interactions with the tkinter slider window? I hope this is somewhat clear. I'm also not sure if this should be posted in the python or vtk groups, so I'm posting to both... TIA for any pointers/suggestions, Heather From chadm at sgi.com Thu Apr 22 13:34:05 1999 From: chadm at sgi.com (Chad McDaniel) Date: 22 Apr 1999 10:34:05 -0700 Subject: How do I use proxies with httplib? References: <7fl97e$lnc$1@nnrp1.dejanews.com> <099101be8c3f$cb6206e0$f29b12c2@pythonware.com> <7flr4l$6bc$1@nnrp1.dejanews.com> Message-ID: Proxy configuration with urllib in Python 1.5.1 is broken. If my memory serves correctly it gives just the error you describe. Upgrade to the newly-hatched 1.5.2 and everything should be peachy. You can download it from: http://www.python.org/1.5/ On a completely different note: can anyone out there explain what 1.5.1p1 is? befletch at my-dejanews.com writes: > In article <099101be8c3f$cb6206e0$f29b12c2 at pythonware.com>, > "Fredrik Lundh" wrote: > > wrote: > > > I want to use httplib through a proxy server and I can't seem to get > > > it to work. > [...] > > you might be able to use urllib instead: > [...] > > When I first looked at this I thought it wouldn't do the trick either, > since I wanted to use the HTTP POST protocol. On further inspection > I see that urllib has that covered. So I tried it out, only to run up > against a problem that I want to blame on urllib; it claims to not > recognize the http url type: > > Python 1.5.1 (#0, Nov 18 1998, 12:17:58) [MSC 32 bit (Intel)] on win32 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import urllib > >>> connection=urllib.urlopen('http://www.yahoo.com') > > Traceback (innermost last): File "", line 1, in ? File "C:\PROGRAM > FILES\HOMERUN\lib\python1.5\urllib.py", line 59, in urlopen return > _urlopener.open(url) File "C:\PROGRAM > FILES\HOMERUN\lib\python1.5\urllib.py", line 155, in open return > self.open_unknown(fullurl) File "C:\PROGRAM > FILES\HOMERUN\lib\python1.5\urllib.py", line 169, in open_unk nown raise > IOError, ('url error', 'unknown url type', type) IOError: ('url error', > 'unknown url type', 'http') > > >>> > > As a test, I hacked urllib by forcing it to think all url's are http > url's, like so: > > # name = 'open_' + type > name = 'open_http' > > This gets past the url type only to fail on the urllib line: > > if not host: raise IOError, ('http error', 'no host given') > > Hacking in a host doesn't help much either. Is there something wrong > with my proxy 'set' command? (This is under W95) > > SET http_proxy="100.287.14.130:80" > > Thanks again, > - Bruce > > (emailed & posted) > > -----------== Posted via Deja News, The Discussion Network ==---------- > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own -- -chad From bmcd at es.co.nz Fri Apr 30 19:44:13 1999 From: bmcd at es.co.nz (Ben Caradoc-Davies) Date: 30 Apr 1999 23:44:13 GMT Subject: Python and Perl (was: converting perl to python) References: <3728F139.75BD1D6B@rubic.com> Message-ID: On Thu, 29 Apr 1999 23:54:33 GMT, Jeff Bauer wrote: > One other debt I must acknowledge. Prior even to Perl, I > had many pleasant experiences using Awk. Yes! I came to perl via csh, awk and bash myself. As a scientific programmer with a C / Fortran / Matlab background, with the sacrifice-everything-for-that- last-1%-speedup mentality, scripting was quite an eye-opener. [Doh! Previously mailed to Jeff - let's keep followups in the newsgroup. Thanks.] -- Ben Caradoc-Davies From tim_one at email.msn.com Sun Apr 11 15:45:07 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 11 Apr 1999 19:45:07 GMT Subject: best way to copy a file [Q] In-Reply-To: <000201be8441$7965d4d0$6eba0ac8@kuarajy.infosys.com.ar> References: <000201be8441$7965d4d0$6eba0ac8@kuarajy.infosys.com.ar> Message-ID: <000901be8453$cd7e21a0$2a9e2299@tim> [Bruno Mattarollo] > I need to copy a file (can be binary or ascii) from one > path to another. I have tryied to do: > line = fd.readline() > while line: > fd2.write(line) > line = fd.readline() > fd.close() > fd2.close() > > It only works for ascii file ... How can I do a 'copy' > ...? I need to run this on NT ...:( If it's to run only under Windows systems, will go fastest to build up an xcopy command line and pass it to os.system. > And I don't want to open a shell to do a copy from there... I also tryied > fd.read() ... No success neither. Oh sure -- that works fine. The raw "no success" conveys no information, though, so not enough clues to guess what part you didn't get right. The most common cause for screwing this up is forgetting to open Windows files in binary mode. To see how it's done, look at the source code for shutil.py in your Python's Lib directory. shutil.copyfile is what you're looking for, if you need a cross-platform function. all-obvious-to-everyone-who-already-knows-it-ly y'rs - tim From klm at digicool.com Thu Apr 29 10:24:09 1999 From: klm at digicool.com (Ken Manheimer) Date: Thu, 29 Apr 1999 10:24:09 -0400 Subject: Emacs' python-mode buggy? References: <199904282340.TAA19934@python.org> <3727E329.2E8F3C31@digicool.com> Message-ID: <37286B89.FC61DF02@digicool.com> Markus Stenberg wrote: > Ken Manheimer writes: > > Markus Stenberg wrote: > > I can't speak to the intimacy issue, but the python-mode syntax recognition > > may be due to having a leading '(' open paren in the first column in one of > > your docstrings. If so, emacs' syntax confusion (not to be mistaken for > > poor gender identification) can be remedied by escaping the leading open > > paren with a '\' backslash, like so: > > Ah, what's causing that problem? I can't recall exactly, but what i've retained is that it's inherent in the emacs syntax parsing mechanism, and not surmountable in any apparant way by an application like emacs-mode. > > \(this is what to do with parens in docstrings.) > > > > If it is the problem, well, it's emacs' problem, not pymode. If it's not, > > well, do track it down. > > > > Oh, does that bug constitute the "tons" you mention, or were there others? > > I never was good at estimating the weight of bugs - all that chiton, you > > know. > > Think there is two, as one of my (moderately large) modules has no > docstrings with ('s yet still exhibits that behavior. (ok, I got carried > away, but I was moderately frustrated over the feature :-P) I've been there! After tripping over the problem a few times (and probably being told the fix on a few occasions), the last time i did a binary-style hunt for the culprit by removing and reinserting chunks of text until i found the line that was responsible. It was a bit painful, but once i found a repeatable test for the problem i pinpointed the cause, bopped my forehead and said "that again", and have recognized it since. If the other file is showing the same symptom without the same cause, i suggest that you try a similar hunting expedition, and report back the cause if you turn up anything interesting... Ken Manheimer klm at digicool.com From cgw at fnal.gov Mon Apr 5 12:04:18 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Mon, 5 Apr 1999 16:04:18 GMT Subject: Subattributes of classes In-Reply-To: <19990405104408.A807008@vislab.epa.gov> References: <19990405104408.A807008@vislab.epa.gov> Message-ID: <14088.57090.644687.407420@buffalo.fnal.gov> Randall Hopper wrote: > Why? Because "attr" in class A is just an int, and has no attributes, whereas "draw" in the Tkinter demo is a Canvas object, which has a scrollX and scrollY attribute. Consider this example: class B: def __init__(self): self.subattr = None class A: def __init__(self): self.attr = B() self.attr.subattr = 456 a = A() print a.attr.subattr From alex at somewhere.round.here Thu Apr 15 12:11:04 1999 From: alex at somewhere.round.here (Alex) Date: 15 Apr 1999 12:11:04 -0400 Subject: Novice Question: two lists -> dictionary References: <7f3j1v$f6j$1@nnrp1.dejanews.com> Message-ID: You could do something like ************************************************** ListA = ['10', '10', '20', '20', '20', '24'] ListB = ['23', '44', '11', '19', '57', '3'] Dict = {} for (key, value) in map (None, ListA, ListB): Dict [key] = Dict.get (key, []) Dict [key].append (value) print Dict ************************************************** The result is {'24': ['3'], '10': ['23', '44'], '20': ['11', '19', '57']} See you. Alex. From arw at ifu.net Mon Apr 5 12:37:00 1999 From: arw at ifu.net (arw) Date: Mon, 5 Apr 1999 16:37:00 GMT Subject: GadFly - MemoryError Message-ID: <199904051641.MAA12603@ifu.ifu.net> I don't know why you have this problem. Gadfly should not construct the cross product with the equality you mention present. (b1.URL = b2.URL) Please try adding an index on URL on the table in question. Also, maybe try increasing your virtual memory (page file size, or whatever). Good luck. fwiw, I've definitely run tables with 100k rows in Gadfly on a 64Meg machine. -- Aaron Watters ps: let me know how it goes. ----Original Message----- >From: Oleg Broytmann >To: arw at ifu.net >Cc: Python Mailing List >Subject: GadFly - MemoryError >Reply-To: phd at sun.med.ru >Date: Saturday, April 03, 1999 9:35 AM > >Hello! > > I tried to add yeat another database backend to my project "Bookmarks >database". My database contains now about 3000 URLs, not too much, I think. >I subclass by BookmarksParser to parse bookmarks.html into gadfly database >and got a database of 500 Kbytes - very small database, I hope. > Then I tried to find duplicates (there are duplicates). I ran the query: > >SELECT b1.rec_no, b2.rec_no, b1.URL > FROM bookmarks b1, bookmarks b2 >WHERE b1.URL = b2.URL >AND b1.rec_no < b2.rec_no > > GadFly eats all memory and fails with MemoryError. Is it that gadfly >really constructs multiplication of b1 and b2, thus getting 3000*3000 >pairs? Or I just did something wrong? > I tried to create indicies, but this was not of any help. > > BTW, where are indicies stored? After creating ones I didn't find >additional files - only one file in the database changed. > >Oleg. >---- > Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ > Programmers don't die, they just GOSUB without RETURN. > > > From gmcm at hypernet.com Fri Apr 23 23:26:49 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 24 Apr 1999 03:26:49 GMT Subject: Efficient List Subtraction In-Reply-To: References: Message-ID: <1287197880-43229653@hypernet.com> Jonothan Farr wrote: > I have also longed for built in support for the union and > intersection of two sequences. > > Perhaps: > list.union(list2) > and > list.intersection(list2) While not exactly what you're looking for, I suggest going to chordate.com and looking for kjbuckets. It's got sets and graphs; you can do intersections and closures... - Gordon From victor at idaccr.org Tue Apr 27 14:49:03 1999 From: victor at idaccr.org (Victor S. Miller) Date: 27 Apr 1999 14:49:03 -0400 Subject: Python classes for postscript Message-ID: Are there packages available for formatted output (with nice fonts, etc.)? Presumably one could create individual pages use some sort of GUI like tkinter, but that would be one page at a time. Also, the XML stuff only seems to talk about creating and parsing XML documents -- what about stuff that actually renders them? Where would I look? -- 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 neelk at alum.mit.edu Tue Apr 6 19:12:04 1999 From: neelk at alum.mit.edu (Neelakantan Krishnaswami) Date: Tue, 06 Apr 1999 23:12:04 GMT Subject: Python and the Singleton Pattern References: <37048D53.5D1ED05F@lemburg.com> Message-ID: <7ee4si$sec$2@antiochus.ultra.net> In article , mlh at idt.ntnu.no (Magnus L. Hetland) wrote: > >But isn't the point that people should be able to use the singleton >instantiator without knowing if it already has been instantiated, and >always get the same instance? Isn't it possible to make use of Python's dynamism to turn any class into a singleton class, as needed? For example: class Singletonizer: def __init__(self, base_class): self.base_class = base_class self.obj = None def __call__(self, *args, **kw): if self.obj is None: self.obj = apply(self.base_class, args, kw) return self.obj # Now a test... class Foo: pass Bar = Singletonizer(Foo) x = Foo() y = Foo() a = Bar() b = Bar() if x is not y: print "x and y are different objects" if a is b: print "a and b are the same object" Which yields the right: x and y are different objects a and b are the same object Then you can write your Foo class as usual, and then Singletonize it as needed. If you are paranoid, you can name Foo "_Foo" so that it won't be part of the module's exported interface. Neel From fatjim at home.com Mon Apr 12 12:27:58 1999 From: fatjim at home.com (Jim Meier) Date: Mon, 12 Apr 1999 16:27:58 GMT Subject: extending questions Message-ID: <371220AD.6C3B0B5@home.com> I have two questions, one simple, one a little bit whiny. Firstly, I'm looking for a quick and easy way for a PyCFunction to accept as an argument either an integer or a floating point number, so that the function can be called as func(1,1,1) or as func(0.5,0,2/3) because python doesn't seem to let me consider an integer as a float. I've tried using some of the conversion functions in the abstract numeric suite and the PyFloat_GetDouble (or some similar name), but with no luck - it always returned -1 for me. Any ideas? Also, ust a suggestion, but would it be possible to add a PyNumber_GetDouble(PyObject*n) function to the absract numberic interface? This would be useful for this sort of situation. My second question is, is there any work being done towards updating/completing "Extending and Embedding" and "The Python C API" in the standard documentation? As it is, the C API is just barely useful.Wonderfully written, though. So can anyone offer a guess on when peeking in the source will be mostly outmoded? Anyways, thanks in advance for your help. Jim Meier. From Jack.Jansen at oratrix.com Tue Apr 13 06:13:16 1999 From: Jack.Jansen at oratrix.com (Jack Jansen) Date: Tue, 13 Apr 1999 12:13:16 +0200 Subject: rfc822 date header References: <3712D863.2A8148BC@rubic.com> <3712F4C1.52327AF4@lemburg.com> Message-ID: <371318BC.E131EDF0@oratrix.com> "M.-A. Lemburg" wrote: > > Jeff Bauer wrote: > > > > Is there a reasonably bulletproof way to generate an > > rfc822-compliant date header using the time module? > > > > The reason I ask is I recall a number of subtle > > errors in this regard, reported by Chris Lawrence, > > among others. > > According to the RFC, time.ctime() should do the trick... > but it's probably locale aware which the RFC doesn't account > for. Which RFC are you referring to? time.ctime() output is definitely *not* compatible with RFC822. But it should be easy enough to come up with a time.strftime() format that does the right thing... -- Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++ Jack.Jansen at oratrix.com | ++++ if you agree copy these lines to your sig ++++ www.oratrix.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm From cgw at fnal.gov Mon Apr 12 17:07:04 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Mon, 12 Apr 1999 21:07:04 GMT Subject: Stupid Tkinter question In-Reply-To: <99041222110400.01382@dominion> References: <99041222110400.01382@dominion> Message-ID: <14098.24696.77181.178918@buffalo.fnal.gov> Bjoern Giesler writes: > I'm going crazy. Why does this fragment work (adapted from imageview.py > in Guido's Tkinter demos): > [snip] > .... but this doesn't: > [snip] > > def makeToolbar(aFrame): > toolbar = Frame(aFrame) > markimage = BitmapImage(file = "Mark.xbm") > markbutton = Button(toolbar, > image = markimage, > command = exit) > > markbutton.pack() > return toolbar The "markimage" object goes out of scope when makeToolbar exits, and storage for the image automatically gets cleared up. You need to cause there to be a persistent reference to the image object. Fortunately this is pretty easy to do. Try this: def makeToolbar(aFrame): toolbar = Frame(aFrame) toolbar.markimage = BitmapImage(file = "Mark.xbm") markbutton = Button(toolbar, image = toolbar.markimage, command = exit) markbutton.pack() return toolbar