From fredrik at pythonware.com Fri Oct 15 04:05:36 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 15 Oct 1999 10:05:36 +0200 Subject: initialization of lists in classes References: Message-ID: <001a01bf16e4$10deba90$f29b12c2@secret.pythonware.com> Balint Aradi wrote: > I would like to ask something about initialization of lists in > classes. Given the Python code > > class test: > list = [] > float = 3.2 > > def __init__(self): > print 'list, float (#1):', self.list, self.float > self.list.append(1,2) > self.float = self.float + 2.0 > print 'list, float (#2):', self.list, self.float list is a shared class variable, not an instance variable. until you know exactly how class variables behave, make sure you initialize all your instance variables in the constructor instead: class test: def __init__(self): self.list = [] self.float = 3.2 print 'list, float (#1):', self.list, self.float self.list.append(1,2) self.float = self.float + 2.0 print 'list, float (#2):', self.list, self.float iirc, the FAQ has more info on class variables and other issues related to shared mutable variables. coming soon: http://www.pythonware.com/people/fredrik/librarybook.htm From greg.ewing at compaq.com Mon Oct 18 11:21:55 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 19 Oct 1999 04:21:55 +1300 Subject: IDLE loses menus on Macintosh References: <37FCBD07.432A37B3@compaq.com> <1dzdbpt.1l2uj8zd79z9yN%w_keller@gmx.de> <38043F91.F3F36D5A@compaq.com> <006601bf1582$a22f3dc0$f29b12c2@secret.pythonware.com> Message-ID: <380B3B13.1ACD64B4@compaq.com> Bill Dozier wrote: > > The Mac port is done by Jim Ingham, who does not work for Scriptics. It is > not officially supported All right, so Mac Tkinter goes into my trash can. Now, does anyone know of an existing Python GUI toolkit that really does work across Mac/Unix/Windows? Greg From fredrik at pythonware.com Sun Oct 31 13:15:18 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 31 Oct 1999 19:15:18 +0100 Subject: eff-bot Python book ... revisited References: <7va9hf$ngi$1@marcie.fissiontech.com> <19991029081909.B106968704@vislab.epa.gov> Message-ID: <00fd01bf23cb$e4b6ed30$f29b12c2@secret.pythonware.com> Randall Hopper wrote: > The eMatter pages indicate that you get a Word [uggh] or PDF file as a > download after contacting the server. for now, you get a PDF file, which can only be viewed/printed from a Windows box. support for other platforms should be available soon (see the fatbrain site for more info). > Couldn't this be pulled across to the pre- > ferred OS? yes, but that takes a little creativity, as Scott mentioned. (and is only allowed for personal use, of course). > Or is this really an electronic-only book (proprietary > format or viewing server). Hope not. for now, it works best if you treat it as an electronically distributed paper book. in other words, download and print. (a script archive, errata, and cover art will be posted within a few days). ... and before even more people start whining about me "betraying Python in itself, and especially its Unix roots," note that 1) this book wouldn't exist if it hadn't been for the eMatter initiative, 2) I only wrote the book, not the distribution software, and 3) Python was originally written on a Mac. in other words, future eff-bot guides will be available on Macs only! thanks. I feel better now ;-) ... From mark at chem.uwa.edu.au Thu Oct 21 10:24:48 1999 From: mark at chem.uwa.edu.au (Mark C Favas) Date: 21 Oct 99 14:24:48 GMT Subject: Checking for libc vs. glibc using Python References: <380ED1A6.5AD18ACA@lemburg.com> <14350.57067.605898.954745@gargle.gargle.HOWL> Message-ID: Charles G Waldman writes: >M.-A. Lemburg writes: > > Is it possible to examine a Python interpreter and check whether > > it was compiled against libc5 or glibc2 (libc6) on Linux/*BSD/etc. ? > > > > I'm currently using this hack, but would appreciate a more > > elegant and portable solution: > > def system_nm(progfile): >I would use "ldd" instead of "nm". It's another hack, not much more >elegant, but a little more portable. In particular it doesn't require >that python was compiled -g. The problem is that nm is far more generally available than ldd... so ldd in fcat is less portable.... (I've not seen a *nix (or Tru64!) that doesn't have nm, but very few that have ldd - I thought it was a Sunism...) >I'm not sure how much the ldd output varies on different unices >(haven't tried this on BSD), but I think it should be pretty easy to >find a portable way search for the libc.so.* line in the output and >figure out the libc version. >This will fail if libc is linked statically, as far as I know this is >rarely done. It's still less of a restriction than requiring python >to be built with debugging info. >It's still not exactly elegant but possibly a little more portable than >what you were doing. -- 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 junkster at nospam.rochester.rr.com Mon Oct 4 21:37:02 1999 From: junkster at nospam.rochester.rr.com (Benjamin Schollnick) Date: Tue, 05 Oct 1999 01:37:02 GMT Subject: Puzzled with Time Server conversion problems? References: Here's a follow up. Finished TimeServer code, with "Clients" for port 37 (NTP), and for Port 13 (Datetime). Please note these clients are *NOT* finished, because I don't see anyway to set the date & time inside of PYTHON. Anyone that can point out a way to change the computers clock via python, I'll appreciate it. Also, as far as I can tell, the code is AOK, and returns the same values as RFC 868 via telneting & using the client37.py code. But I've had little luck with verifying this via NT time client daemon. Can anyone assist in trying this server out with *KNOWN* TCP NTP clients? Client13 was written to take advantage of a daemon running under Windows NT on port 13, which broadcasts like this: Mon Oct 4 21:27:45 1999 (In plain text.) Which is nice, but annoying because for some *STRANGE* reason I can't get time.strptime (datetime, '%A, %B, %d, %Y %X') to work. Everytime I try STRPTIME, I get a attribute error. Can anyone point out what I'm goofing up? BTW-> Anyone have suggestions for making the server a little bit "friendlier" either code / execution wise? ----- Server ---- # # Python Time Server, based off of RFC 868. # # Thanks to (no particular order, nor is this complete): # # Jeff [jam .at. quark.emich.edu] # Paul Foley [(setq reply-to (concatenate 'string "Paul Foley " # ""))] # # And other folks in comp.language.python for their assistance with this code. # # This code is free to the public, EXCEPT, I would appreciate any changes to be # emailed to me ("Junkster at rochester.rr.com") # import time import struct # # Leapyear (year): Returns 0 if not leapyear, 1 if leapyear # def leapyear(year): temp = ((year % 4 == 0) and (year % 100 <>0)) or (year % 400 == 0) return temp # # calc_leap_years(year): Returns the # of years between 1900 & year # that are leapyears. (i.e. 5, etc) # def calc_leap_years (year): temp = 0 if year > 1900: for count in range(1900, year): if leapyear(count): temp = temp + 1 return temp def timeserver_calculation(): secs_per_day = 24.0*60*60 # 86400 secs_per_year = 365.0 * secs_per_day leapyear = 1896 # (1880, 1884, 1888, 1892, 1896, 1904, 1908) timetuple = time.gmtime(time.time()) total = secs_per_year * (timetuple[0]-1900) total = total + (calc_leap_years(timetuple[0]) * secs_per_day) total = total + (timetuple[7] - 1) * secs_per_day total = total + timetuple[5] + timetuple[4]*60.0 + timetuple[3]*3600.0 print total return total import sys from socket import * def server(host="", port=37, backlog=5): sock = socket (AF_INET, SOCK_STREAM) sock.bind (host, port) sock.listen (backlog) print "listening on port %s (%s, %s)" % (port, `host`, backlog) while 1: connection = (conn, addr) = sock.accept() print 'connected by %s \nat %s' % connection ft = timeserver_calculation() lt = long(ft) conn.send ( struct.pack("!L", lt)) conn.close() if __name__ == "__main__": server('', 37, 1) ---------- Client37 ------------------- # # Python Time Server client, based off of RFC 868. # # Thanks to the folks in comp.language.python for their assistance with this code. # # This code is free to the public, EXCEPT, I would appreciate any changes to be # emailed to me ("Junkster at rochester.rr.com") # import time import struct import sys from telnetlib import Telnet print "Connecting to : ", sys.argv[1] tn_session = Telnet(sys.argv[1], 37) # Connect to MS Win NT date / time datetime = tn_session.read_all() tn_session.close() print "Server Returned: ",datetime dt = struct.unpack ("!L", datetime) print "Unpacked structure value : ", dt #timevalue = time.strptime (datetime, '%A, %B, %d, %Y %X') #timevalue = time.strptime (datetime) #print timevalue, ' - ', time.asctime(timevalue) print ------------ Client13.py ----------- # # Python Time Server client, based off of RFC 868. # # Thanks to the folks in comp.language.python for their assistance with this code. # # This code is free to the public, EXCEPT, I would appreciate any changes to be # emailed to me ("Junkster at rochester.rr.com") # import time import sys from telnetlib import Telnet print "Connecting to : ", sys.argv[1] tn_session = Telnet(sys.argv[1], 13) # Connect to MS Win NT date / time datetime = tn_session.read_all() tn_session.close() print "Server returned: ",datetime #timevalue = time.strptime (datetime, '%A, %B, %d, %Y %X') #timevalue = time.strptime (datetime) #print timevalue, ' - ', time.asctime(timevalue) print -------------------------------------- ================================ Please feel free to copy any and or all of this sig. A little something for spam bots: root at localhost postmaster at localhost admin at localhost abuse at localhost postmaster at 127.0.0.1 Chairman William Kennard: bkennard at fcc.gov Commissioner Susan Ness: sness at fcc.gov Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov Commissioner Michael Powell: mpowell at fcc.gov Commissioner Gloria Tristani: gtristan at fcc.gov consumerline at ftc.gov fccinfo at fcc.gov ssegal at fcc.gov From tim_one at email.msn.com Thu Oct 14 00:25:51 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 14 Oct 1999 00:25:51 -0400 Subject: Improved struct module In-Reply-To: <0E16861EE7BCD111BE9400805FE6841F0BE36049@c1s5x001.cor.srvfarm.origin-it.com> Message-ID: <000001bf15fc$3397ee00$ba2d153f@tim> [comparing Robin Boerdijk's xstruct C extension module http://www.sis.nl/python/xstruct/xstruct.html with Just van Rossum's sstruct Python module http://starship.python.net/crew/just/code/sstruct.py ] [Robin Boerdijk] > I have done a comparison on how fast sstruct is compared to xstruct > using the Xsdp example that comes with xstruct. The test scripts are > at the end of this post. They both do 10000 iterations of creating > and packing an XsdpMessage. On my computer, the sstruct script takes > 2.4 seconds, the xstruct script takes 0.33 seconds. The ratio on my machine is about the same as you got. You should qualify this with an indication of what it's measuring, though! The inner loops are: [for xstruct] for i in xrange(0, 10000): msg = XsdpMessage() msg.correl_id = 0x01020304 msg.message_type = 1 msg.data = "Hello, World !" [for sstruct] for i in xrange(0, 10000): msg = copy.copy(default_msg) msg['correl_id'] = 0x01020304 msg['message_type'] = 1 msg['data'] = "Hello, World !" sstruct.pack(XsdpMessageFormat, msg) That may (or may not -- beats me) be typical of apps that access each struct member once and are then done with the struct. In an app that accesses (or modifies) struct members multiple times, Just's approach is much faster; e.g., xstruct takes 3+ times longer (on my machine) than sstruct if the inner loops are changed to: [for xstruct] for i in xrange(0, 10000): msg = XsdpMessage() for j in xrange(100): msg.correl_id = 0x01020304 msg.message_type = 1 msg.data = "Hello, World !" [for sstruct] for i in xrange(0, 10000): msg = copy.copy(default_msg) for j in xrange(100): msg['correl_id'] = 0x01020304 msg['message_type'] = 1 msg['data'] = "Hello, World !" sstruct.pack(XsdpMessageFormat, msg) That may (or may not -- beats me ) be typical of apps that access each struct member many times. My guess (with nothing to back it up) is that xstruct would be faster in more apps than sstruct. People making their own guesses must realize there are tradeoffs here, though: almost nothing is a pure win, and this is no exception -- which one runs faster depends on what you're doing. [about the docs] > ... > So far, I have only documented up to the point that I thought that people > who need to interact intimately with C structs from Python (and have been > struggling with struct.pack and struct.unpack to do that) would get > enthousiastic about this new module. Curiously enough, I hardly ever muck with C structs. I too would like to hear from people who do! I only jumped in here because I thought you had written a very interesting module, and your announcement was followed by days of silence. You may not like the approach I've taken here, but it has gotten the module some much-needed publicity . [about the buffer interface] >> It's not ready for prime time (e.g., it's easy to crash the interpreter >> with the little that's already there, staying within pure Python). > Can you give me an example ? Yes, but I won't. You can create your own by thinking about the implementation: a buffer object contains a pointer to a base object and a separate pointer to a chunk of untyped memory. If the base object happens to stop using that memory, there's no way for the buffer object to know that. And if that memory happens to get reused by some other object for something else (or even unmapped by the OS), anything at all can happen -- it's a hole so big even Perl could fit into it . Your new objects are safe because they hold on to their buffer memory until they die (and so long as a buffer object refers to them, they can't die). Some object types aren't so nicely behaved. any-more-hints-and-even-guido-could-create-an-example-ly y'rs - tim From mwh21 at cam.ac.uk Sun Oct 17 15:52:38 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 17 Oct 1999 20:52:38 +0100 Subject: Q: Python 2.0 preliminary features? References: <7tlk6p$4o5$1@nnrp1.deja.com> <3801486F.A7CDEF1D@maxtal.com.au> <3809C575.B8F953FF@maxtal.com.au> Message-ID: skaller writes: [snip tantalizing class/types ideas] > The basic optimisations are functional, that is, > things like making string concatenations go faster in cases like: > > x = x + "hello" > > Here, the deduction starts with the literal "hello" > which > is known to be a string, and, since + accepts a string > RHS only when the LHS is also a string or an int, > and the int case is eliminated since the type of the LHS > of the assignment is also the type of X, and both > operators called + with string RHS return a string, > then x must be a string. Hold it there a second; you are proposing that knowing that x has a certain type in the expression x = x + "hello" has an impact on inference? That's a BIG sea change from CPython. Haven't you ever done this: option = raw_input("enter a parameter> ") try: option = int(option) except: print "get a Clue" OK, contrived example. But the same name can refer to variables of different types at different times, so I don't think you can use that for inference. Regards, Michael PS: Given the bizarre reluctance of my university to give me any work, can I ask if the source to viperi (at least) will be perusable anytime soon? From dnagata at creo.com Sun Oct 31 20:59:28 1999 From: dnagata at creo.com (Dale Nagata) Date: Sun, 31 Oct 1999 17:59:28 -0800 Subject: Comparison between Python and "Ruby" References: <3819BCDA.AC4FD4CA@strs.co.uk> Message-ID: <381CF400.6106@creo.com> Ian Clarke wrote: > * No way to automatically convert between long integer and small > integer. C:\>python Python 1.5.1 (#0, Oct 14 1998, 20:14:21) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> int(1L) 1 >>> long(1) 1L -- 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 mwh21 at cam.ac.uk Thu Oct 21 17:35:21 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 21 Oct 1999 22:35:21 +0100 Subject: Apply a function to each list member? References: <816010E2456BD111A48700805FBBE2EEFDF6F9@ex-quebec-u1.baan.com> Message-ID: Gaetan Corneau writes: > Hi, > > Is there a way to do this (see "ListApply" below) with standard Python > stuff? > > def f(s): > from string import upper > from types import StringType > if type(s) == StringType: > return upper(s) > else: > return s > > > def ListApply(f, l): > for i in range(0, len(l)): > l[i] = f(l[i]) > > > l = ["aaa", "bbb", "ccc", 1, 2, 3, "xxx", "yyy", "zzz"] > print l > > ListApply(f, l) > print l um... map? l=map(f,l) f *could* be defined as a lambda, but it'd be unspeakably hairy, something like f=lambda s,u=string.upper,t=types.StringType: \ (type(s) is t and (u(s),) or (s,))[0] but I'm going to presume you're not that silly. Your ListApply might be a little more space efficient as it works in place, but not much, because you allocate a list of length len(l) anyway in the range(). HTH, Michael PS: Yes, all that hair *is* needed; consider f(0) or f("") before you simplify... From rturpin at my-deja.com Tue Oct 19 18:50:43 1999 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Tue, 19 Oct 1999 22:50:43 GMT Subject: "Calling" PHP pages from Python (and vice versa) Message-ID: <7uisju$2eg$1@nnrp1.deja.com> This may be more a question about Apache than about Python. Given a Python CGI script, is there anyway for it to "redirect" the http request to a PHP page, without incurring the net latency of an actual redirect. This seems like it ought to be easy, but unlike pure HTML, the script cannot just copy the page to standard out, since the actual HTML is generated by the PHP processor. A redirect would work, but it seems silly to go back to the browser for this. (What about the other way around? Is there an efficient way for a PHP page to invoke a Python script through mod-py? Of course, that's a PHP question ..) Thanks! Russell Sent via Deja.com http://www.deja.com/ Before you buy. From ivanlan at callware.com Tue Oct 5 17:54:06 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 5 Oct 1999 21:54:06 GMT Subject: Quick question: recursive touch? References: <7tdden$929$1@nnrp1.deja.com> <7tdgb9$bbv$1@nnrp1.deja.com> <7tdie6$cq1@dfw-ixnews5.ix.netcom.com> <7tdoc8$hno$1@nnrp1.deja.com> Message-ID: <37FA737E.AA989793@callware.com> Hi All-- Preston Landers wrote: > > In article <7tdie6$cq1 at dfw-ixnews5.ix.netcom.com>, > aahz at netcom.com (Aahz Maruch) wrote: > > > I haven't really looked at your code, but I needed to mention that > > 'open(file,"w")' will cause the file to become zero bytes long. > > Isn't that what touch does? > No. If the file exists, it simply updates access and modification times, unless you give it other arguments. Causing a file to become zero bytes long is the job of 'cat /dev/null > zerofile' (at least from the shell). If no file exists, it creates a zero-length file. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.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 mwh21 at cam.ac.uk Sat Oct 30 19:28:01 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 31 Oct 1999 00:28:01 +0100 Subject: Optimization References: <381B479B.6C73707E@c2i.net> Message-ID: Geir Bjarte Terum writes: > Will statements like this be optimized away using the -o program switch? > > if __debug__: > # Dead code in optimized version. Yes. > Is there any way to define similar *variables* for other purposes? Don't think so. > If not, as a workaround, will the following work? > > __myflag__ = __debug__ # Set to 1 if always to be supported. > > if __myflag__: > # Dead code in non-flagged version. Doubt it. There's no real way to enforce constants in Python. One solution is to write if 0: # __myflag__ because `if 0:' does allow code elimination, and then use search and replace if the value needs changing. Not a perfect solution, but it could work. HTH, Michael From toby at puckish.demon.co.uk Sat Oct 16 16:57:34 1999 From: toby at puckish.demon.co.uk (Toby Kelsey) Date: Sat, 16 Oct 1999 21:57:34 +0100 Subject: multi-level break Message-ID: <4HkSiAA+aOC4EwuD@puckish.demon.co.uk> At the moment I am setting and checking flag variables to emulate this, which I find tedious and ugly. Am I missing a better idiom? As much as I dislike feeping creatures, it would be nice to see "break " in version 2.0. IMHO obvious, simple and useful. Cheers, Toby -- Toby Kelsey From Josef.Betancourt at GTECH.COM Tue Oct 26 10:24:31 1999 From: Josef.Betancourt at GTECH.COM (Betancourt, Josef) Date: Tue, 26 Oct 1999 10:24:31 -0400 Subject: Module for generic platform information: platform.py Message-ID: <7780536C9FD5D211801B0008C75D433933CFEB@rimail03> Tried the platform.py but only get win32 on NT 4.0 service pack 5. ver in the shell returns: Windows NT Version 4.0 > -----Original Message----- > From: M.-A. Lemburg [mailto:mal at lemburg.com] > Sent: Tuesday, October 26, 1999 5:45 AM > To: Python List @ Python.org > Subject: Module for generic platform information: platform.py > > > Last week I started to write a small module for more convenient and > portable access to information about the platform on which Python > is running. > > Many people have helped and provided lots of information > about the various Python compatible platforms out there... thanks > everybody :-) > > Some things where I need some more help are: > ? support for Linux distributions other than redhat, suse, > debian, mandrake > ? better support for WindowsCE (Jeff Bauer is working on this one) > ? support for MacOS (not the X Server version; JvR is working on it) > ? support for Amiga, MS DOS and maybe VMS > ? a way to find out the true system names and versions on > MacOS X Server and Solaris (they both use different names > at the OS level, e.g. SunOS 5.5 instead of Solaris 2.5) > > New features: > ? system alias support, e.g. SunOS can be reported as > Solaris > > Here is the latest version of that module: > http://starship.skyport.net/~lemburg/platform.py To see if it works on your platform, simply run the script. Enjoy, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 66 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ -- http://www.python.org/mailman/listinfo/python-list From gherman at darwin.in-berlin.de Tue Oct 5 12:31:36 1999 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Tue, 05 Oct 1999 18:31:36 +0200 Subject: Unix diff algorithm in Python anyone? References: <7td5lp$2oc$1@nnrp1.deja.com> <7td7s2$45ok$1@uvaix7e1.comp.UVic.CA> Message-ID: <37FA27E8.66F62DAA@darwin.in-berlin.de> John Aycock wrote: > > Here's some references to get you started: > > W. Miller & E. W. Myers. A File Comparison Program. _Software > -- Practice and Experience_ 15(11), November 1985, pp. 1025-1040. My previous posting about the (very experimental) alignment module is actually based on a more recent pairwise alignment alorithm of Gene Myers et al., too (1988). Regards, Dinu -- Dinu C. Gherman ................................................................ "An average of more than 15 % of adults in 12 industrialized countries are functionally illiterate; in Ireland, the United Kingdom and the United States, the rates are over 20 %." (The State of the World's Children 1999, UNICEF, http://www.unicef.org/sowc99) From madq968 at djeksta.comNOSPAM Sat Oct 2 17:36:09 1999 From: madq968 at djeksta.comNOSPAM (madQ) Date: 2 Oct 1999 21:36:09 GMT Subject: Download Ia.n.i.!!! It's free! Message-ID: <7t5ts9$6gk$847@nslave1.tin.it> Download Ia.n.i. RemoteControlSystem 1.2 beta. It's free!!! New site: http://jump.to/IaniProject From junkster at nospam.rochester.rr.com Tue Oct 5 04:02:12 1999 From: junkster at nospam.rochester.rr.com (Benjamin Schollnick) Date: Tue, 05 Oct 1999 08:02:12 GMT Subject: Anyone have success w/STRPTIME??? Message-ID: Can anyone point me in the right direction, re: STRPTIME? To my knowledge the strptime function(s) are correct below, yet under both OS/2 & Win NT, I am getting a attribute error. I'm assuming it's my fault, but according to the Docs I think I've got it setup AOK (TMHK). - Benjamin import time import sys from telnetlib import Telnet print "Connecting to : ", sys.argv[1] tn_session = Telnet(sys.argv[1], 13) # Connect to MS Win NT date / time datetime = tn_session.read_all() tn_session.close() print "Server returned: ",datetime #timevalue = time.strptime (datetime, '%A, %B, %d, %Y %X') timestr = time.strptime (datetime) print timevalue, ' - ', time.asctime(timevalue) print Connecting to : 128.173.14.71 Server returned: Tue Oct 5 03:59:56 1999 Traceback (innermost last): File "D:\OS2\PYTHON\WORKING\TIMESERVER\CLIENT13.PY", line 20, in ? timestr = time.strptime (datetime) AttributeError: strptime ================================ Please feel free to copy any and or all of this sig. A little something for spam bots: root at localhost postmaster at localhost admin at localhost abuse at localhost postmaster at 127.0.0.1 Chairman William Kennard: bkennard at fcc.gov Commissioner Susan Ness: sness at fcc.gov Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov Commissioner Michael Powell: mpowell at fcc.gov Commissioner Gloria Tristani: gtristan at fcc.gov consumerline at ftc.gov fccinfo at fcc.gov ssegal at fcc.gov From c.hintze at gmx.net Sun Oct 31 04:46:15 1999 From: c.hintze at gmx.net (Clemens Hintze) Date: Sun, 31 Oct 1999 09:46:15 GMT Subject: Comparison between Python and "Ruby" References: <3819BCDA.AC4FD4CA@strs.co.uk> <7vd1oa$itk$1@newshost.accu.uu.nl> <381A1D8A.6493E814@starmedia.net> Message-ID: >>>>> "Andrew" == Andrew Csillag writes: Andrew> Martijn Faassen wrote: [...] Andrew> In my experience, unless ruby's extension interfaces is Andrew> like tcl's which while simple, isn't terribly powerful, Ahem... I have written extensions in both Python *and* Ruby. Would you please enlight me, why do you think Ruby interface isn't powerful compared with Python's one? I had the opposite impression. :-/ Andrew> Python's is simple enough (I've been known for doing Andrew> simple extension modules in about 3 minutes -- no Andrew> SWIG). But even complicated ones with SWIG aren't hard. Andrew> Actually, even without SWIG it isn't really hard, just Andrew> boring since most of it is boilerplate. All that is also true for Ruby! And you have forgot to compare garbage collection issues which have to be addressed both in Python and Ruby. While Python use a refcount scheme, where you have to address that issue yourself, Ruby use true garbage collection (mark and sweep scheme), so that you have not to deal with it at all. Under some circumstances, you have to provide up to two function in your Ruby extension. One function that mark Ruby objects, stored in your extension, alive (if there are some), one that free the memory of your own occupied memory (normally 'free' is enough). I wish Python would be so easy here! >> > * Function objects are accepted as arguments, but iterators >> are more > elegant. >> >> You can implement iterators in Python, though? Better core >> level iterator support would be nice for Python 2.0, though >> (for instance for loops could use them). Andrew> I argue that simplicity is better than elegance most of Andrew> the time, thus function objects over iterators. Besides Andrew> who wants to make an iterator when you just want to pass a That doesn't score very well, IMHO. My question to your question would be: who likes to write an own function for something that is only used one time and therefor better be stick into an block. Perhaps there is a misunderstanding for iterators. The word was a little bit misleading used in the Ruby documentation, IMHO. But now they have correct the usage. Andrew> function you already have? Reminds me of how you pass Andrew> methods around in Java (make an instance of (usually) an Andrew> inner class that inherits from some interface that just Andrew> calls the outer class's method)... Grr... It reminds me, more of the way how Smalltalk pass methods! Ruby is (except syntax) more like Smalltalk, than like Java! [...] Andrew> From what I saw, it looks like they tried to mix python Andrew> and perl by sticking the python down the camel's throat What?!? Do you really saw it? Can it be that you have only had a glance to the syntax, and therefore decided it's like Perl => crap! Andrew> and got camel puke. You have whitespace for indentation, Okay! Now I am convinced that you never have really looked at Ruby too close. Perhaps only a small blink on it! Ruby *does*not* use whitespaces (unfortunately, cause I like them :-)! Ruby has in common with Python its consistent behavior, its simplicity and its easy extension writing. It shares with Perl the speed and much of the syntax; but not the context dependend behavior, that makes it so diffcult for beginners to learn Perl. There is e.g. a syntax for creating regexps, but these are objects then, like in Python. And it also has many many things in common with Smalltalk (Ruby is totally OOL). Even a '1' is an instance of class Fixnum *unlike* Python & Perl! Andrew> but all the regexy crap and extraneous ?'s and $'s that Andrew> make it ugly. I don't think, that the regexp stuff is crab! If you want, you can also use the Python way: regex = Regexp.new("^(S+)") # Or use: regex = /^(\S+)/ regex =~ "hello world" # Or use "hello world" =~ regex Perl is (whether we like it or not) the most used language for sysadmin and web purposes till today. So there are many programs and modules already available. To ease the port of them, was one of the issues, why matz has decided to introduce these ugly variables. I don't like them, but I can live with them. Hey, there are also things I don't like in Python, but they doesn't necessarily make the language worse for me. Andrew> -lets-make-a-language-named-perl-so-we-can-cast-it-to-swine-ly Andrew> yours, Drew -be-not-so-biased-towards-one-language- -there-is-no-only-one- -all-is-a-matter-of-taste-ly yours Clemens. [...] From samschul at pacbell.net Mon Oct 11 15:55:32 1999 From: samschul at pacbell.net (Sam Schulenburg) Date: Mon, 11 Oct 1999 19:55:32 GMT Subject: lazy function calling? References: <380202B7.ADF0E803@GermanLloyd.org> Message-ID: <7ttfbb$cb2$1@nnrp1.deja.com> In article <380202B7.ADF0E803 at GermanLloyd.org>, Berthold Hoellmann wrote: > Hello, > > I think I can remember a Python extension module, posted or announced > here a while ago, where it was possible to make functions callable lazy. > This means I could call a function spam just writing spam instead of > spam(). Was I just dreaming or is it real. And if it's real, where can I > get it :-)? > > Thanks > > Berthold > -- > email: hoel at GermanLloyd.org > ) > ( > C[_] These opinions might be mine, but never those of my employer. > The previous reply referenced an out of date url, use the following: http://starship.python.net:9673/crew/da/Code/parenless Sent via Deja.com http://www.deja.com/ Before you buy. From junkster at nospam.rochester.rr.com Mon Oct 4 21:40:34 1999 From: junkster at nospam.rochester.rr.com (Benjamin Schollnick) Date: Tue, 05 Oct 1999 01:40:34 GMT Subject: Puzzled with Time Server conversion problems? References: <37F9BC2B.F9FF1AC2@hk.rfa.org> Message-ID: On Tue, 5 Oct 1999 08:51:55, Bill Eldridge wrote: > >>> time.localtime(3155550800.0) > (1901, 12, 14, 4, 22, 28, 5, 348, 0) > >>> time.localtime(315555080.0) > (1980, 1, 1, 14, 11, 20, 1, 1, 0) > > 1970-1976 was about 190 million seconds, so 1976-1980 should > be less than double (380 million seconds), not 3.2 billion seconds. Eh? Bill, I've been staring at this problem on and off for days. I certainly could have made a typo in the comment(s), but either way I worked around it with a manual calculation.... I'm welcome to simplifications.... (See code posted about 2 minutes ago) - Benjamin ================================ Please feel free to copy any and or all of this sig. A little something for spam bots: root at localhost postmaster at localhost admin at localhost abuse at localhost postmaster at 127.0.0.1 Chairman William Kennard: bkennard at fcc.gov Commissioner Susan Ness: sness at fcc.gov Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov Commissioner Michael Powell: mpowell at fcc.gov Commissioner Gloria Tristani: gtristan at fcc.gov consumerline at ftc.gov fccinfo at fcc.gov ssegal at fcc.gov From mlh at idt.ntnu.no Wed Oct 6 09:54:12 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 06 Oct 1999 15:54:12 +0200 Subject: Converting to lists into one dictionary References: <000401bf0ed3$0cd77b80$4da2143f@tim> Message-ID: Alex writes: > > Why? Why not pad with None? I think it would be worse if > > len(seq2)>len(seq1) - because you couldn't pad the keys with Nones... > > But don't you then run the risk of having more than one None? In that > case, don't you lose some of the values as their keys collide? That's what I said in the second sentence (assuming that seq1 is the sequence of keys.) > > Alex. -- Magnus Lie Please forward all spam to Hetland uce at ftc.gov From jfarrell at mincom.com Wed Oct 6 19:58:40 1999 From: jfarrell at mincom.com (John Farrell) Date: Thu, 07 Oct 1999 09:58:40 +1000 Subject: regular expression example generator Message-ID: <37FBE230.6A4113C5@mincom.com> I have a faint recollection of hearing somewhere that someone for some language had written some software which took a regular expression and generated for you the types of things that would match it. For example, '(a(b)?)?c' would give you 'c', 'abc', 'ac' (ab)* would give you '', 'ab', 'abab' IMHO this would be useful for debugging REs when they get complicated. Has anyone heard of such a thing for Python? Thanks, John From jonathan at meanwhile.freeserve.co.uk Sat Oct 30 05:12:55 1999 From: jonathan at meanwhile.freeserve.co.uk (Jonathan) Date: Sat, 30 Oct 1999 10:12:55 +0100 Subject: Learning to program References: <7780536C9FD5D211801B0008C75D433933CFF1@rimail03> Message-ID: <7ved06$nav$1@news7.svr.pol.co.uk> Betancourt, Josef wrote in message news:7780536C9FD5D211801B0008C75D433933CFF1 at rimail03... > The best book I've seen is "Code Complete" by Steve McConnell. Its more of > a reference book and of course doesn't mention Python, but most of its > contents are general enough to be useful in a Python context. > I'd agree that McConnel's book is very good, but it assumes rather a lot and is very thick - it's really a book that teaches people how to program better, rather than how to program. What's really needed is an equivalent of Lalonde's Discovering Smalltalk - something not too long, that explains what a program is, talks about the classic data structures etc. Jonathan From matti at tx.technion.ac.il Tue Oct 19 07:03:51 1999 From: matti at tx.technion.ac.il (Matti Picus) Date: Tue, 19 Oct 1999 13:03:51 +0200 Subject: Matlab -> Python Message-ID: <380C5017.9852E40@tx.technion.ac.il> Anyone translating matlab syntax to python? Any tutorials on the common pitfalls or how to get started From clarkeia at logica.com Tue Oct 5 11:22:33 1999 From: clarkeia at logica.com (Ian Clarke) Date: Tue, 05 Oct 1999 16:22:33 +0100 Subject: Just like in our DNA... References: Message-ID: <37FA17B9.980C2204@logica.com> > Just > > like in our DNA, there are large pieces of software containing unused > > code. Nobody noticed it was no longer needed, so nobody bothered to take > > it out. One of my lecturers at university suggested that the unused DNA code was actually /* commenting */. ;-) Ian. From gmcm at hypernet.com Fri Oct 8 15:57:36 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 8 Oct 1999 15:57:36 -0400 Subject: ANN: Win32 Installer - new beta Message-ID: <1272710597-42056950@hypernet.com> A new beta (03) of the Win32 Installer package is available on starship: http://starship.python.net/crew/gmcm/beta03.html This release incorporates Thomas Heller's changes: executables now act much more like frozen apps in that almost all(*) of the Python modules and scripts are run / imported directly from the exe. (*)exceptions.pyc is the sole exception. In fact, almost the whole package has been rewritten. Among the enhancements: - full support for packages & subpackages - ability to tell the installer to search odd places for your modules - a framework for incorporating extensions with odd packaging / installation requirements - better status reporting - more debugging aids - many more configurations and options available. Read all about it at http://starship.python.net/crew/gmcm/beta03.html. The prior beta (02) is now promoted to release. Background: The Win32 Installer is a sort of compilerless Freeze - a way of distributing Python apps with all the required support built in. It also understands binary resources (.dlls and .pyds) and can package up arbitrary files that your app might require. Python-style license. Contact: gmcm at hypernet.com

Win32 Installer release 02 / beta 03 A compiler-less way of distributing Python apps on Windows. (8-Oct-99) - Gordon From fredrik at pythonware.com Mon Oct 11 14:43:46 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 11 Oct 1999 20:43:46 +0200 Subject: select() interruption by signal References: <01BF141E.81CF8AE0.spooky@dreamfish.freeserve.co.uk> Message-ID: <009901bf1418$8fdefef0$f29b12c2@secret.pythonware.com> Robert Longstaff wrote: > However I've found that this alarm signal, although being caught > successfully by the handler, also interrupts the select() causing the app > to bomb out: > > Traceback (innermost last): > File "./myapp.py", line 169, in ? > inList, outList, specialList = select.select(select_mask, [], []) > select.error: (4, 'Interrupted system call') > > Is this just a timing thing? Is the select() 'catching' the signal at the > same time as the handler or is the signal 'hanging around' longer than it > should? > > Is there an option to get the select() to ignore signals or should I trap > the exception (and throw it away)? I can't find any more information in the > Python manual or man select. I'm using v1.5.1 on Linux. fwiw, the single unix specification says: [EINTR] The select() function was interrupted before any of the selected events occurred and before the timeout interval expired. If SA_RESTART has been set for the interrupting signal, it is implementation-dependent whether select() restarts or returns with [EINTR]. and so does POSIX, I think. I suppose this means that trapping the exception is the right thing to do... coming soon: http://www.pythonware.com/people/fredrik/librarybook.htm From greg.ewing at compaq.com Mon Oct 11 05:07:21 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Mon, 11 Oct 1999 22:07:21 +1300 Subject: Q: Python 2.0 preliminary features? References: <000001bf1272$e8e29b80$0c2d153f@tim> Message-ID: <3801A8C9.37E0FC62@compaq.com> Tim Peters wrote: > > Greg Ewing recently worked up a patch that implements "read only" lexical > closures, that avoids the cycles in many (most, or almost all, for most, or > almost all , common programming styles) cases, albeit with some other > costs (see DejaNews). I'd just like to point out that my closures are only "read only" because I have deferred making a syntactic decision about how to declare variables as "nonlocal" for assignment purposes; there's no inherent reason why my closures couldn't be read-write. Also, to clarify Tim's rather waffly characterisation of when my closures do or don't cause cycles, it's quite simple: they never cause cycles unless you write code which makes them do so. This is no worse than the situation with regard to cycles everywhere else in the language. Caveat-generator-cycloramum, Greg From fredrik at pythonware.com Thu Oct 7 02:39:26 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 7 Oct 1999 06:39:26 GMT Subject: Tkinter: Scrollable buttons References: <7te79t$rja$1@nnrp1.deja.com> Message-ID: <00b201bf1090$dc9cecb0$f29b12c2@secret.pythonware.com> sragsdale at my-deja.com wrote: > I've got a big panel full of buttons and such, and I need to add a > scroll bar so that I can move up and down the list. The following code > will construct something that _looks_ good, but the scrollbar won't > actually do anything. Any idea what's wrong? set the canvas scrollregion. the following example shows you one way to do this (it's setting things up so the canvas will track changes to the frame. if the frame is static, you can set the scrollregion once). # # scrolled frame # # fredrik lundh, april 1998 # # fredrik at pythonware.com # http://www.pythonware.com # from Tkinter import * class ScrolledFrame(Frame): def __init__(self, master, **kw): apply(Frame.__init__, (self, master), kw) # create the widgets scrollbar = Scrollbar(self, orient=VERTICAL) self.canvas = Canvas( self, bd=0, highlightthickness=0, yscrollcommand=scrollbar.set, bg="red" ) scrollbar.config(command=self.canvas.yview) scrollbar.pack(fill=Y, side=RIGHT) self.canvas.pack(expand=1, fill=BOTH, side=LEFT, ) # reset the view # (always do this if you don't use scrollbars) self.canvas.xview("moveto", 0) self.canvas.yview("moveto", 0) # create the inner frame self.inner = Frame(self.canvas, bg="blue") # track changes to its size self.inner.bind('', self.__configure) # place the frame inside the canvas (this also # runs the __configure method) self.canvas.create_window(0, 0, window=self.inner, anchor=NW) def __configure(self, event): # update the scrollbars to match the size of the inner frame size = self.inner.winfo_reqwidth(), self.inner.winfo_reqheight() self.canvas.config(scrollregion="0 0 %s %s" % size) # -------------------------------------------------------------------- # test stuff root = Tk() f = ScrolledFrame( root, bd=2, relief=SUNKEN, highlightthickness=2 ) f.pack(expand=1, fill=BOTH) t = Text( f.inner, bg="gold", height=100, width=40, bd=0, highlightthickness=0 ) t.pack(expand=1, fill=BOTH) for i in range(100): t.insert(END, "line %d\n" % (i+1)) root.mainloop() From wware-nospam at world.std.com Sun Oct 17 14:56:52 1999 From: wware-nospam at world.std.com (Will Ware) Date: Sun, 17 Oct 1999 18:56:52 GMT Subject: A question References: <19991017210106.A1008@io.yok.utu.fi> Message-ID: Kristian Nylund (krnylund at io.yok.utu.fi) wrote: : Could someone tell me an easy way to do : something like "for i in `ls *.txt`..." : in python? Other folks have mentioned glob.glob(), which will work fine for things like "*.txt". If you want something more flexible, for instance all the *.c and *.h files that mention printf, you'd want to iterate on the output of something like find . -name '*.[ch]' -exec grep -l printf {} \; and if you wanted to do something like that in Python, you'd want to know about commands.getoutput(). Specifically, you'd want to write something like this: import commands for file in commands.getoutput( "find . -name '*.[ch]' -exec grep -l printf {} \;"): process(file) So commands.getoutput() is good to know about if you need a little more flexibility than glob.glob(). -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From python at infosys.com.ar Wed Oct 20 22:26:03 1999 From: python at infosys.com.ar (PythonMaster) Date: Wed, 20 Oct 1999 23:26:03 -0300 (ART) Subject: Using CGI with POST In-Reply-To: <380E67CE.E57D8795@progmatics.com.au> Message-ID: Hi! Could you give more information. There should be no difference between the POST and GET methods. What's the HTML for the FORM element? Are you 'posting' other elements than the one called name? /B On Thu, 21 Oct 1999, David Hobley wrote: > Hello, > > I just knocked up a simple cgi script. It works fine if I > use the GET method on the form. However, if I try and POST > it, the script just hangs until it times out. > > Is there any special magic to make this work? > > The script does: > > form = cgi.FieldStorage() > form_ok = 0 > if form.has_key("name"): > if form["name"].value != "": > form_ok = 1 > ... > > but it hangs on the call to cgi.FieldStorage() > > Thanks. > > -- > 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/ > > -- > http://www.python.org/mailman/listinfo/python-list > From fredrik at pythonware.com Mon Oct 11 16:03:38 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 11 Oct 1999 22:03:38 +0200 Subject: Who maintains Tkinter? References: Message-ID: <015301bf1423$b89f1ef0$f29b12c2@secret.pythonware.com> SysProg - Nathan Paul Simons wrote: > A few months ago, i attempted to get some answers to a question > about a bug with tkinter. i received no reply. Therefore, i would like > to know who maintains tkinter so that i could contact them directly. on the other hand, this is already fixed in the code repository: ... forget = grid_forget def grid_remove(self): self.tk.call('grid', 'remove', self._w) ... for more info on how you can access the repository, see: http://www.python.org/download/cvs.html coming soon: http://www.pythonware.com/people/fredrik/librarybook.htm From otso at hybrid.fi Fri Oct 22 03:53:30 1999 From: otso at hybrid.fi (Otso Makinen) Date: 22 Oct 1999 07:53:30 GMT Subject: urgent problems with win32 debug build Message-ID: <7up55q$66i$1@tron.sci.fi> I'm using python as a scripting language wrapped on top of c++ library using the SWIG tool. When using the debug build of the python libraries importing of the .dll modules fails with the following error message: ImportError: no module named xxxx There's no similiar problem with the .py modules and the .dll modules work ok with the release build of the python libraries. I'm using MSVC++ 6.0, pcbuild of python 1.5.2 and SWIG 1.1p5. And yes, I have tried building the both debug/release versions of the wrapper module .dlls. To point out the urgency of this, I'm promising a bottle of finest Finlandia Vodka to be mailed to the first one giving a solution. -- Otso Makinen From pereira at research.att.com Fri Oct 22 23:34:27 1999 From: pereira at research.att.com (Fernando Pereira) Date: Sat, 23 Oct 1999 03:34:27 GMT Subject: [slightly off-topic] programmable speech recognition software References: <000001bf1c51$78160160$352d153f@tim> Message-ID: <221019992334277627%pereira@research.att.com> In article <000001bf1c51$78160160$352d153f at tim>, Tim Peters wrote: > > In the recorded audio stream should be recognized as many words as > > possible - speaker independent and in German! (I can hear you shudder) > > Speaker-independent is hard. From a recording is hard. If people aren't > speaking into a high-quality microphone, it's very hard. If it's not > intentional speech (i.e., if people don't know they're talking to a > computer -- they're just chatting), it's very hard. The good news is that > German is easy (compared to the rest of this). > > > In unclear cases - there will probably be lots of them - the closest > > interpretations would be OK. > > I doubt you can do this yourself and get acceptable results with any > available SR software. It's an extremely difficult problem. Taking > software designed for close-talking microphone, speaker-dependent, "dictate > into word" applications, and trying to apply it to a radically harder task, > is like hoping (say) Perl can be used to get real work done . The > closest Dragon Systems gets is described at: > > http://www.dragonsys.com/products/audiomining/index.html > > Note that there's no product mentioned there -- Dragon has appropriate > technology, and that's what the page talks about. This is so bleeding edge > there are no pre-packaged applications for sale. Dragon would be happy to > build one for you, though, in return for an insignificant percentage of > Germany's gross national product . According to a recently-conducted NIST evaluation, current experimental large-vocabulary recognizers achieve 70-80% word accuracy on unrestricted American radio and TV news broadcasts. That includes studio news announcer speech (often much more accurate on that), phone call-ins, field recordings (often poor, with varied noise in the background), interviews and round-table discussions. This level of accuracy is sufficient for searching news stories by content: with appropriate methods to compensate for recognition errors, search from automatic transcriptions is almost as effective as from manual transcriptions (for those interested, see the paper by Singhal and Pereira in the proceedings of ACM SIGIR 99). Recognition runtime for these results varies between almost real time and three times slower depending on hardware, recognizer and desired accuracy. As far as I know, none of these recognizers is available as a product, although some may be close. In my experience, the critical element is not the actual recognizer code -- although that matters quite a bit for speed, memory usage and flexibility in using different kinds of speech models -- but rather the choice of speech and language modeling techniques for the particular task, selection of training data, and actual model creation recipe. The situation becomes noticeably worse for spontaneous speech over uncontrolled channels. However, even then it is often possible to do topic classification of spoken utterances with fairly high accuracy for a relatively small set of topics by training appropriate classifiers. The point is that for some tasks it's not necessary to recognize each word, but just what the speaker is talking about, which can be identified from several cues in the utterance. The kind of audio data-mining applications that Dragon Systems has announced and Tim mentions above rely on this, I believe. -- F From zessin at my-deja.com Fri Oct 29 07:53:25 1999 From: zessin at my-deja.com (Uwe Zessin) Date: Fri, 29 Oct 1999 11:53:25 GMT Subject: Module for generic platform information: platform.py References: <38188904.BFD13231@lemburg.com> <3819705B.6078E0C9@lemburg.com> Message-ID: <7vc1rk$ip2$1@nnrp1.deja.com> In article <3819705B.6078E0C9 at lemburg.com>, "M.-A. Lemburg" wrote: > FYI, I've uploaded a new version with experimental Java and win32 > support which you may want to test (version 0.5.0): > > http://starship.skyport.net/~lemburg/platform.py > > To see if it works on your platform, simply run the script. > > Things that are still missing: > ? support for MacOS > ? support for Amiga, OS/2, MS-DOS and VMS *** I decided to wait some time to allow the more popular ports to 'shake out' and then try to understand the module. Being a non-Unix person it is not always apparent to me what value is supposed to be returned from the different functions. It also looks like I need to do some enhancements in the OpenVMS port - e.g. it's currently missing uname() support. -- Uwe Zessin Sent via Deja.com http://www.deja.com/ Before you buy. From EarlGoodyer at news.vex.net Fri Oct 29 11:03:07 1999 From: EarlGoodyer at news.vex.net (Earl Goodyer) Date: 29 Oct 1999 15:03:07 GMT Subject: Python for game programming References: <7vca5f$oug$1@nnrp1.deja.com> Message-ID: <7vccvb$ip9$1@hub.org> On Fri, 29 Oct 1999 14:15:16 GMT, Sindh wrote: >Does anyone know if there is a crossplatform library for game >programming with python. Probably not you were looking for (you don't mention what kind of game), but there are a few things listed here that might be of interest (a couple of MUD/MOO systems, and the aging pyRPG project to make a 3D RPG engine): http://www.vex.net/~x/parnassus/apyllo.py/238168060 >A man needs to sleep for 36 hours a day atleast. Ah, so that's my problem. I had always suspected something like this. ... From k_mcdermott at my-deja.com Thu Oct 21 11:46:27 1999 From: k_mcdermott at my-deja.com (k_mcdermott at my-deja.com) Date: Thu, 21 Oct 1999 15:46:27 GMT Subject: PyFloat_Check - help! Message-ID: <7uncgi$6or$1@nnrp1.deja.com> Hi, I have a piece of code like this: if (!PyFloat_Check(poRate)) { PyErr_SetString(DataError, "Rate must be a float"); return NULL; } else Rate = PyFloat_AsDouble(poRate); Where poRate is a PyArg_ParseTuple extracted PyObject. The question I have is: The type checking is too strict (who says Python isn't type checked?) I would prefer the above code to translate Integer objects, where this makes sense. i.e. the rate above could be either 1 or 10 to represent 1% or 10%, but I have to explicitly put in a 1.0 or 10.0 to make it a float. I know this is possible, but how... Kevin Sent via Deja.com http://www.deja.com/ Before you buy. From hniksic at srce.hr Tue Oct 12 14:07:45 1999 From: hniksic at srce.hr (Hrvoje Niksic) Date: 12 Oct 1999 20:07:45 +0200 Subject: P vs P speed (was RE: Newbie question: files..) References: <000001bf1434$82178e60$f1a2143f@tim> Message-ID: <87puykiham.fsf@pc-hrvoje.srce.hr> "Tim Peters" writes: > Python's long ints; Perl's Math::BigInt. I first saw Python when > working for a company trying to design a 64-bit supercomputer, using > software on 32-bit workstations. I had been using Perl, very > painfully and slowly, and the very first Python alpha already ran > circles around Perl (I'm talking factors of 10 - 100 here) for these > tasks. I kept Perl for text-crunching, but dropped it for > everything else. [...] > More, this is *typical* in my experience. All the convolution in > Perl's internals costs time to execute, and Python's much cleaner > implementation translates to faster runtime. Python gets a bad rap > here because of one thing: Guido doesn't put "extraordinary effort" > into optimizing *anything* (it's a personality flaw ), while > Larry et alia did put extraordinary effort into optimizing some > common things (mostly related to text-crunching). Outside of its > areas of special competence, Perl is not fast. I don't really care about the speed where it doesn't matter. I guess my problem was that the only usage where speed really did make a difference was about text-crunching, because textual input files tend to get large (e.g. large log files, or Debian package files, or whatever.) > On my home platform (P5-166, 32Mb RAM, Win95), it takes about 20 > seconds in Perl and about 14 in Python. Which, applying the usual > benchmarking chicanery, means "Python is 43% faster than Perl". FWIW, here it takes 16.5 seconds of CPU time, while Perl takes 12.8. Does that make Perl 37% faster? :-) Benchmarks truly suck. From darcy at vex.net Sat Oct 30 10:40:16 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 30 Oct 1999 14:40:16 GMT Subject: multiline prototyping on command line (oops) References: <87so2ttegm.fsf@slip166-72-251-9.ma.us.prserv.net> Message-ID: <7vf00g$2n7$1@hub.org> Eric Smith wrote: > Greg -- > gerglery at usa.net (greg andruk) posted in comp.lang.python on 30 > Oct 1999 04:55:37 -0400: > > Anyway, Python's not especially amenable to one-liners. Instead, it > > has a really spiffy interactive mode you can leave running in a window > > or spare console session that works like you probably wish `perl -d' > > worked: > Yeah, it is a nice "shell" interface for testing, however one liners are > useful: > 1. I use their history arrows to access them from the unix shell > 2. You can use the unix fc for editing long ones > 3. You can paste them into your scripts. > 4. They are easy to go back to and edit etc. All of which apply to the Python shell with readline installed. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From Bill at nospam.com Sat Oct 16 23:06:07 1999 From: Bill at nospam.com (Bill Rodgers) Date: Sat, 16 Oct 1999 21:06:07 -0600 Subject: Detect file existance before open? Message-ID: I would like to check for the existance of a file before I attempt an open and maybe throw an exception. I don't see a way to do this. I would like to tell the user that the file he specified doesn't exist. Is there a way to do this or do I need to catch the exception and deal with it that way? Thanks, -- Bill Rodgers Enterprise Management Consultant Specialty: BMC/Patrol brodg1 at ix.netcom.com From malcolmt at smart.net.au Mon Oct 4 03:12:29 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Mon, 4 Oct 1999 17:12:29 +1000 Subject: Puzzled with Time Server conversion problems? In-Reply-To: ; from Benjamin Schollnick on Mon, Oct 04, 1999 at 02:44:43AM +0000 References: Message-ID: <19991004171229.A678@Ridcully.home> On Mon, Oct 04, 1999 at 02:44:43AM +0000, Benjamin Schollnick wrote: [...snip...] > I'm using Pythons time module, (specifically) time.time() to > generate the time information. Even though time is specified to : > "return the time > as a floating point number expressed in seconds since the epoch, in > UTC", it doesn't > "match up" with the RFC results even when the 1900 vs 1970 date is > taken into effect. > > The RFC states that "The time is the number of seconds since 00:00 @ > 1900 Jan 1. > > From my experimentation is GMTIME: > > python GMTIME calcs RFC 868 > (Base 1970, Jan 1) (Base Jan 1, 1900) > Jan 1, 1970 - 18,000.0 2,208,988,800 > Jan 1, 1976 - 189,320,400.0 2,398,291,200 > Jan 1, 1980 - 3,155,550,800.0 2,524,421,600 I assume there is a typo here, since the correct value for Jan 1, 1980 should be 2,524,521,600 seconds as far as I can work out (100 000 seconds more than the number written). > I don't see how python's Jan 1, 1980 calcuation can exceed the RFC's > calculation, unless the > calculation is returning *NON-LINEAR* results, which doesn't make > sense if it's the # of secs since > Jan xxxx. I agree. I can't understand your Python numbers at all. There is a problem with your calculation routine (see below), but it shouldnt' give these non-linear results. I don't have access to Python on any sort of Windows box, so I can't verify the results you got there, but certainly nothing like that is happening under Linux for me. > > Also, I can't duplicate the RFC 868 values if I manually perform the > calculations. > > My "big question", is simple: > > Can anyone suggest a way to convert from pythons time.time() to the > RFC date(s)? [... lots'o stuff deleted ...] > import time > # > # Constants > # > #secs_in_year = 31536000 # 365*24*60*60 > secs_in_year = 365.1666666666667 * 24*60*60 ^^^^^^^^^^^^ Huh?? Firstly, since 0.166666... = 1/6, this is saying that leap years occur every six years. On my side of the world at least, we try to have them every four years or so. :-) Secondly, even if you replace this number with 365.25 (I know it's not precisely correct, but it's near enough for my purposes here), it will onyl give the right answer one year out of four. This is because although the time it takes the Earth to do a lap around the Sun is more or less 365.25 days (minus a little bit), the Julian calendar operates on the principle that each year is exactly 365 days, except for every fourth year, which is 366 days (except for every 100th year which is 365 days, except for every 400th year which is 366 days). So to do the correct computations, you need to set secs_in_year to 365*24*3600 and add on the amount 24*3600 for every leap year that has occurred from 1900 until the present day (or from 1968 until the present year, if you are using the Jan 1, 1970 epoch --- I choose 1968, rather than 1970 so that a simple integer division will give the correct answer). To conclude, here is a corrected version of the manual calculation code. I have, in passing, fixed one other error, which is that to work out the number of seconds from the beginning of the year until the current day, you should use (Julian Day - 1), not just Julian Day. This code assumes a 1/1/1970 epoch - just add the appropriate big number is you want to work from 1/1/1900. :-) Cheers, Malcolm Tredinnick import time # # Set test_time to some number of seconds after the epoch # # For example, I use 1 Jan 1980 test_time = 315532800.0 secs_per_day = 24.0 * 60 * 60 secs_per_year = 365.0 * secs_per_day # timetuple is 9 elements: # (yr, mnth, day, hr, min, sec, # D.of.week, Julian day, daylight.savings) timetuple = time.gmtime(test_time) print timetuple # Work out basic number of seconds untils 1 Jan. total = secs_per_year * (timetuple[0] - 1970) # Correct for leap years. The division computes the number of leap # years that have occurred after 1968 and *before* this year # (hence the timetuple[0]-1 bit) total = total + (timetuple[0] - 1 - 1968)/4 * secs_per_day # Add up to current day (the -1 is because 1 Jan has julian day=1 # and we don't want to add anything in that case). total = total + (timetuple[7] - 1) * secs_per_day # Add number of seconds for current time total = total + timetuple[5] + timetuple[4]*60.0 + timetuple[3]*3600.0 # The number of seconds is now be contained in total # (and should, of course, be the same as test_time) print test_time print total From poe at kodak.com Fri Oct 8 13:49:55 1999 From: poe at kodak.com (Warren Poe) Date: Fri, 08 Oct 1999 13:49:55 -0400 Subject: Python and IDL interface Message-ID: <37FE2EC3.253632DD@kodak.com> Where can I find documentation on writing Corba/IDL inferface in python? Has anyone done this before? Thanks in advance From erno at iki.fi Sun Oct 24 12:07:57 1999 From: erno at iki.fi (Erno Kuusela) Date: 24 Oct 1999 16:07:57 GMT Subject: Is httpdapy ready for primetime? References: Message-ID: On Sun, 24 Oct 1999 13:52:13 +0000 (GMT), Oleg Broytmann wrote: >On 24 Oct 1999, Erno Kuusela wrote: >> >> it would probably be quite easy to write something that emulates >> >> cgi's transparently. perhaps httpdapy would become more popular >> >> if something like this was included with it... >> > >> > I don't think so. >> >> it would not be easy or it would not become more popular? :) > > It wouldn't be much more popular, IMHO. a lot of people seem to like mod_perl, and i think many its users like it precisely because of its speed. and the only way to speed is keeping the same interpreter around. maybe there is some other reason for the unpopularity of httpdapy than cgi-incompatibility, as suprisingly few people seem to use it. (or perhaps all its users are just very very quiet :) ) of course there is always zope, but it's like a sledgehammer for lots of stuff, and pretty complex. -- erno -- "The new Intel Linux Gigabit driver is great news for Linux customers who need high speed connectivity to drive their e-business," added Phil Hester, chief technology officer, IBM Personal Systems Group. From olme at ebox.tninet.se Sun Oct 3 05:18:46 1999 From: olme at ebox.tninet.se (Anders olme) Date: 03 Oct 1999 11:18:46 +0200 Subject: newbie question int to string conversion References: <7t4n7n$kdj$1@hub.org> <14325.63797.550594.431553@dolphin.mojam.com> Message-ID: Well actually my strings are comming from a directory listning. I'm trying to implement a autoupgrader for our CAD system at work (tired to ask if a new version has arrived). And the direcotyr contains ordinary names and directories with names like 310,3112 and so on. So it will be 50% numbers and the rest will be strings. -- -- //Anders Olme // //E-mail: olme at ebox.tninet.se From gmcm at hypernet.com Sun Oct 24 10:54:58 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sun, 24 Oct 1999 10:54:58 -0400 Subject: "What is the name of the function/method that called me?" In-Reply-To: <01E317D42527FC5F.A35D548EBCB64C7C.7C5E6B812D216D74@lp.airnews.net> Message-ID: <1271346348-3126980@hypernet.com> [Cameron summarizes my comments on introspection] > Thanks. Our current status is therefore that all > known demands for introspection-goop either > 1. can be satisfied by __*__ references, > which we all recognize as slightly out- > side normal operations, or > 2. are the result of a misdesign for which > we can exhibit a superior alternative, > often involving disciplined polymorphism > or an interface from an explicit class > definition. > This feels slightly alien to me, but I can get over > it. I think it's particularly valuable to write up > explanations of the form, "If you find yourself > wanting to XX, take it as a hint to study your design > in search of a YY, which will yield a better design." You have summarized just a tad more strongly than I would have. I certainly leave open the possibility that today's outre techniques become tomorrow's accepted ones. OTOH, I'm one of the few people who occaisionally writes metaclasses (publicly, at least), which is an area where introspection merges with rape-and-pillage. Now metaclasses were invented (by the infamous Don Beaudry) based on certain abstract ideas about object models. But I have concluded that the only known usage for metaclasses is playing __getattr__ tricks, which can be played (a bit more crudely) without all the theoretical trappings that come with metaclasses. I am thus inclined to try to see behind the arguments about introspection to find out what people are actually trying to do. I'll-pay-for-caller-ID-when-it's-free-ly y'rs - Gordon From jstevens at basho.fc.hp.com Thu Oct 21 14:54:18 1999 From: jstevens at basho.fc.hp.com (John W. Stevens) Date: Thu, 21 Oct 1999 12:54:18 -0600 Subject: do ... while loop References: <000701bf17bf$ee71efe0$3e2d153f@tim> <380BFAF1.116FB21E@mincom.com> Message-ID: <380F615A.36A98BB5@basho.fc.hp.com> Martin Pool wrote: > > while 1: > x = f.readline() > if not x: break > print x > > is the same. So it's really just a matter of whether we want a larger, > more specific syntax, or a smaller syntax that relies a little more on > people using idioms. Which is why, if we were discussing a new language, I would suggest creating ONLY the loop: break continue construct (the condition on both the break and continue is optional). No while. No for. No do. Just loop. After all, it makes a weird kind of sense: loop is the super class of while and for, right? ;-> But we're talking about Python, so the best bet would probably be to just drop this discussion . . . except it is kinda fun! John S. ============ If I spoke for HP --- there probably wouldn't BE an HP! John Stevens john_stevens at fc.hp.com From madq968 at djeksta.comNOSPAM Sat Oct 30 07:13:02 1999 From: madq968 at djeksta.comNOSPAM (madQ) Date: 30 Oct 1999 11:13:02 GMT Subject: Download Ia.n.i.!!! It's free! Message-ID: <7vejru$ccj$4@nslave2.tin.it> Download Ia.n.i. RemoteControlSystem 1.2 beta. It's free!!! New site: http://www.homestead.com/madq/files/index.htm From skip at mojam.com Sat Oct 2 00:27:48 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 1 Oct 1999 23:27:48 -0500 (CDT) Subject: Passing file descriptors in Python? In-Reply-To: <19991001203033.A14484@acs.ucalgary.ca> References: <37f56662.9607568@news.supernews.com> <19991001203033.A14484@acs.ucalgary.ca> Message-ID: <14325.35268.320583.702360@dolphin.mojam.com> Neil> On Sat, Oct 02, 1999 at 02:12:28AM +0000, Dan wrote: >> Has anyone attempted to pass file descriptors from one process to >> another under using Python on Linux? I want to build a little web >> server that accepts connections and hands them off to child processes >> exactly like Apache does. Neil> I don't know too much about how apache works but fork works just Neil> fine with Python: Unfortunately, that's not what Apache does. Apache pre-forks a bunch of children. The parent then (through some clever magic supported on a number of Unix variants which I don't understand) passes the open file descriptor to an already forked process. You can set a limit on the number of requests a child will handle before exiting. Set it high enough and (practically speaking) you won't notice any fork overhead. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/ 847-971-7098 | Python: Programming the way Guido indented... From mirko at picard.inka.de Sat Oct 2 22:20:33 1999 From: mirko at picard.inka.de (Mirko Zeibig) Date: Sun, 3 Oct 1999 04:20:33 +0200 Subject: ping script References: <7t699k$3p1m$1@newssvr04-int.news.prodigy.com> Message-ID: On Sat, 2 Oct 1999 08:40:13 -0400, Sean wrote: > I am a newbie to python. Any ideas on how to create a script to ping a class > c block and maybe resolve the names to DNS. Hello Sean, at least the DNS-resolving is easily done by socket.gethostbyaddr. Regards Mirko -- mailto: mirko.zeibig at gmx.de privat: http://sites.inka.de/picard commerce: http://www.webideal.de qmail, ldap, serialfax, rh-isdn: http://www.webideal.de/#downloads From andy at robanal.demon.co.uk Sat Oct 2 12:09:22 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Sat, 02 Oct 1999 16:09:22 GMT Subject: More Python books coming... References: <5lpuz483p4.fsf@eric.cnri.reston.va.us> Message-ID: <37f92dce.33670976@news.demon.co.uk> Guido van Rossum wrote: >Python Programming on Win 32 > Mark Hammond, Andy Robinson. Published by O'Reilly. Expected > September 1999. Sorry to disappoint you - as an author it pains me even more - but O'Reilly's web site now says December. It just better be out by January 24th! Andy Robinson From poinot at onera.fr Fri Oct 15 09:53:24 1999 From: poinot at onera.fr (Marc POINOT) Date: Fri, 15 Oct 1999 15:53:24 +0200 Subject: Import problem with threads Message-ID: <380731D3.FAE4B45C@onera.fr> I have some problem with my installtion on SGI. We are trying to make a multi-platform installation (n32, 64, and some cross compilers) with threads. Two problems: [ONE] (one could also say [1], or first) During the make install process, the compileall.py phase fails. The previous installation was without threads, and the compileall.py uses the NEW python with threads. The message was something like I force the compilation with the OLD python without threads. It passes, but... [TWO] (see remark above, but changing [1] with [2] and first by second, but NOT one by two) Now, trying to import some modules, I have: elsa at SGI > python Python 1.5.2 (#20, Oct 14 1999, 11:07:33) [GCC 2.95.1 19990816 (release)] on irix646 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import gzip Fatal Python error: unlock_import: not holding the import lock Abort(coredump) elsa at SGI > Any idea, something missing at install time, mess in shell variables, compile option unadequate, other? Marcvs [alias Trying now to feed Python with live rabbits] From blackers at netscape.net Mon Oct 11 00:19:04 1999 From: blackers at netscape.net (Brian Blackwell) Date: Mon, 11 Oct 1999 14:19:04 +1000 Subject: Suppressing console on Windows? Message-ID: <7trona$v8$1@corolla.OntheNet.com.au> My apologies if this is a FAQ, but is there a way to prevent the text console appearing when running a Tkinter-based Python script on Windows? Thanks in advance Brian Blackwell From garabik at melkor.dnp.fmph.uniba.sk.invalid Fri Oct 15 03:21:46 1999 From: garabik at melkor.dnp.fmph.uniba.sk.invalid (Radovan Garabik) Date: 15 Oct 1999 07:21:46 GMT Subject: do ... while loop References: <000201bf1602$9d71f4a0$ba2d153f@tim> <873dveynjm.fsf@pc-hrvoje.srce.hr> <38063FB7.F3BB88AC@anisci.com> Message-ID: <939975615.652258@cdwork.cvt.stuba.sk> Joel Davis wrote: : I totally agree. : I use while 1: (and for(;;) in c) all the time. It seems like a really : good construct, however I always feel a little uneasy, like it is : abusing the language or something.. : I wish there was some kind of "officially sanctioned" version of this, : that implied (or even enforced) that the loop was meant to be exited : with a break, somthing like : loop: : ... : if (): : break : ... : if (): : break I use this in my programs: forever = 1 ... while forever: .... just my 2 cents... -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik/ | | __..--^^^--..__ garabik @ fmph.uniba.sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From malcolmt at smart.net.au Sat Oct 30 04:35:41 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Sat, 30 Oct 1999 18:35:41 +1000 Subject: multiline prototyping on command line In-Reply-To: ; from Eric Smith on Sat, Oct 30, 1999 at 08:13:46AM +0000 References: Message-ID: <19991030183541.A1419@Ridcully.home> On Sat, Oct 30, 1999 at 08:13:46AM +0000, Eric Smith wrote: > I am am a perl programmer looking at Python and would like to know whether > it is possible on the command line to test algorithms like I do in perl > thusly: > > perl -e '$r="de";if ($r eq "whatever" or "de") {print "a match\n"} Yessir! It's the -c option and it has to be the last option on the command line. python --help gives you a list of all the command line options. Cheers, Malcolm Tredinnick From thomas at xs4all.nl Fri Oct 22 10:05:10 1999 From: thomas at xs4all.nl (Thomas Wouters) Date: Fri, 22 Oct 1999 16:05:10 +0200 Subject: Python and HTML hidden input variables In-Reply-To: <7upopa$s50$1@nnrp1.deja.com> References: <7upopa$s50$1@nnrp1.deja.com> Message-ID: <19991022160509.B9043@xs4all.nl> On Fri, Oct 22, 1999 at 01:28:12PM +0000, rainer2207 at my-deja.com wrote: > I was wondering how I could pass a variable using the hidden field. That > is I'd like to do something like this: > test = "Hello" > print "" > but this returns the string test rather than "Hello". Is there anyway > I can get it to pass "Hello"? Am I right in leaving out the double > quotes for the value part? Any help would be appreciated. Thanks. You can do it three ways: >>> print '' (Note that i mixed single and double quotes to avoid the escaping of the originally used quotes... makes for better reading, imho.) But this inserts a space between the quotes and the value of 'test', >>> print '' This doesn't insert a space, but might not work correctly if 'test' is not a string (but, for instance, an object doing something entirely different on '+'.) print ''%test This uses C's 'printf'-style string creation... the '%s' is replaced by the (string-)value of 'test'. If 'test' isn't a string, it's converted into one (or an error is raised, if it refuses.) Note that the ""%... string creation thing can be tricky when you want to include more things. You need to make the argument to % a tuple, like this: print ' Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From Gaetan_Corneau at baan.com Fri Oct 22 10:28:10 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Fri, 22 Oct 1999 10:28:10 -0400 Subject: NT related question (not really Python related) Message-ID: <816010E2456BD111A48700805FBBE2EEFDF702@ex-quebec-u1.baan.com> Adrian, >> Instead of redirecting to a file, why not use os.popen(): Because: 1) I didn't know about popen (sooo many functions, so littletime ;) 2) In a few cases (but not or my kill example), I need the file anyway. >> Have you tried os.popen() on these machines? No, but I will if the problem shows up again :) Thanks! ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From claird at starbase.neosoft.com Wed Oct 13 16:37:53 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 13 Oct 1999 20:37:53 GMT Subject: P vs P speed (was RE: Newbie question: files..) References: <000001bf1434$82178e60$f1a2143f@tim> <87puykiham.fsf@pc-hrvoje.srce.hr> Message-ID: <0FC86360625C0456.AD930DC5F94AE35B.17E6CB0756DD4198@lp.airnews.net> In article <87puykiham.fsf at pc-hrvoje.srce.hr>, Hrvoje Niksic wrote: >"Tim Peters" writes: . . . >> On my home platform (P5-166, 32Mb RAM, Win95), it takes about 20 >> seconds in Perl and about 14 in Python. Which, applying the usual >> benchmarking chicanery, means "Python is 43% faster than Perl". > >FWIW, here it takes 16.5 seconds of CPU time, while Perl takes 12.8. >Does that make Perl 37% faster? :-) > >Benchmarks truly suck. I think benchmarks are truly wonderful. They fill me with wonder. I've seen enough cases where *identical* source produces dramatically different results on apparently randomly chosen machines that I'm ready to begin investigating material causes (holding in reserve the speculation that the boxes know the preferences of their owners). Is there some plausible mechanism for supposing that Tim's tired old silicon (I can write that; I've still got machines from last decade that I prefer to the thought of spending any cash) is relatively more efficient on Python processes, presumably because its DLLs and such are in bet- ter places? -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From parkw at better.net Sat Oct 23 15:18:26 1999 From: parkw at better.net (William Park) Date: Sat, 23 Oct 1999 15:18:26 -0400 Subject: SF Bay: Python Training? In-Reply-To: <7usi9n$2cc$1@nntp1.atl.mindspring.net> References: <7usi9n$2cc$1@nntp1.atl.mindspring.net> Message-ID: <19991023151826.A11892@better.net> On Sat, Oct 23, 1999 at 02:55:51PM +0000, Aahz Maruch wrote: > We just hired a new webmaster who has never done any programming. Does > anyone know of any Python training taking place over the next month or > two in the SF Bay Area? (Yes, I know about the other options; I'm > hoping to possibly piggy-back on some other company's training session.) > -- > --- Aahz (@netcom.com) Let me get this straight... your company hired a programmer who never programmed and, presumably, can't type! Were you pressed to comply with some quota or what? Yours truly, William From greg.ewing at compaq.com Thu Oct 28 04:03:35 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 28 Oct 1999 21:03:35 +1300 Subject: Questions about nested for's vs map References: <38111CA1.D6896911@dicksonstreet.com> <3816BE60.87DC32E7@compaq.com> <381653CE.A463DF1D@dicksonstreet.com> Message-ID: <38180357.87221827@compaq.com> Felix Thibault wrote: > > Is it generally considered better not to generate code? (I don't have any > computer science background, and I'm trying to learn on my own, so I'm a > little paranoid about learning to program the wrong way.) Usually it's both more efficient and easier for others to understand if you can write a procedure which does something directly, rather than generating code which is then compiled and executed to do it. It was fashionable for a while to use techniques like this in languages such as Lisp, where the boundary between code and data was very thin. But nowadays it's generally considered bad style to use it unless there is really no alternative. In the vast majority of cases, there is an alternative, and finding it will make your code run faster and look nicer. > def makedict(*keys): > depth=len(keys) > keyz = tuple(map(repr, keys)) > dict = eval( ('{ %s:'*depth+'None'+'}'*depth) % keyz) > return dict Recursion is your friend in cases like that. Whenever you find yourself wanting to build some sort of hierarchical structure whose depth you don't know in advance, think recursion! Greg From jima at aspectdv.com Thu Oct 14 15:54:14 1999 From: jima at aspectdv.com (Jim Althoff) Date: Thu, 14 Oct 1999 12:54:14 -0700 Subject: JPython? In-Reply-To: References: <199910132322.QAA11710@hermes.aspectdv.com> Message-ID: <199910141949.MAA18769@hermes.aspectdv.com> Hi Hank, I have been using the following methodology and it works pretty well. I start with JBuilder3 from Inprise/Borland. I use its visual developer tool to "draw" a user interface. JBuilder3 is pretty decent because it supports Java2 and Swing and lets you drag & drop the Swing widgets, specify the bean properties in forms, and even use forms to set up the advanced awt layout managers like gridBagLayout -- which I use a lot to make dialogs and user-input forms that resize intelligently on the screen. JBuilder3 will generate and compile the corresponding Java/Swing code. It does a nice job of just generating the basic code without putting in special comments and extra tagging junk. You can make JFrames, JPanels, JPanels with JTrees and JTables inside of JScrollPanes, etc. Basically anything you need. Once I have a "visually drawn" and "auto-generated" user-interface layout class, I then switch to JPython. I write a JPython class that is sort of a "View / Controller". In the JPython class I make an instance of the JBuilder3- generated "layout" class. I then do all of the event handling and application logic inside the JPthon "View / Controller" class, manipulating the Swing elements in the JBuilder3-generated instance as needed. With this methodology, all of the "programming" is done using JPthon and yet the static user interface elements are "drawn" with a visual tool (JBuilder3). As I said, it has been working great for me. Jim At 02:56 PM 10/14/99 -0400, Hank Fay wrote: >Jim, > > is there a visual application development environment, using the Java >API, that will work with JPython? > > tia, > >Hank > >-- >http://www.prosysplus.com >Jim Althoff wrote in message >news:199910132322.QAA11710 at hermes.aspectdv.com... >> As a very active JPython user, here is my take on it. >> >> Yes, you can think of JPython as a mechanism >> that lets you run "Python" in a Web browser that supports >> Java. You can also look at it as a mechanism for >> adding scripting capability to Java applications. >> >> But I think of it in a somewhat different way. >> JPython is a second implementation of Python >> that uses the Java VM instead of the Python >> runtime. Why is this useful? Because of the >> following tradeoffs. In JPython you don't have >> access to Python C-based extension modules. >> Bad, obviously. But you do have access to >> the basic core language structures and to >> any Python modules implemented completely >> in Python. Neutral -- obviously you have this >> in standard Python as well. But, the real kicker >> is this: with JPython you DO have complete >> access to ALL Java APIs. Without having to >> do any work at all. No wrappers, no JNI, no CORBA >> no anything. Instant availability. All in the >> same JVM. >> >> I am in a situation where I need to develop >> huge applications and for various business >> and other reasons I am absolutely committed >> to using Java APIs (Swing for the UI, etc.). >> >> Without JPython, Java is the only real choice >> for programming the applications >> since doing wrappers to make all Java APIs >> available in Python is just not practical. >> >> With JPython, though, I can develop all of my >> applications using the Python language >> (as opposed to the C-Python implementation) >> and still make use of all the Java APIs. >> >> Personally, I believe the Java APIs are >> gaining enormous momentum for applications >> programming. I think the ability to program >> in a high-level, dynamic language like Python >> while having seamless access to all of the Java >> APIs is a killer combination. >> >> Jim >> >> >> >> At 03:00 PM 10/13/99 -0500, Dan Star wrote: >> >Let me see if I am understanding what JPython is. Is it a just-in-time >> >compiler that translates python code to java byte-code so that the >> >python code can run in a WEB browser that supports java? If so, I would >> >assume this places many restricitions on the Python language elements >> >you can use. Or is JPython a seperate implementation of Python with its >> >own language set? >> > >> >--Dan >> > >> >-- >> >http://www.python.org/mailman/listinfo/python-list >> > >> >> > > > >-- >http://www.python.org/mailman/listinfo/python-list > From j.vanderkoijk at ind.tno.nl Wed Oct 27 04:28:48 1999 From: j.vanderkoijk at ind.tno.nl (John van der Koijk) Date: 27 Oct 1999 10:28:48 +0200 Subject: units and uncertainty in python References: <86hfje42xv.fsf@lori.home.nl> Message-ID: <87zox5nr5r.fsf@linux01.prc.tno.nl> I've never written a followup directly to myself... "JvdK" == John van der Koijk writes: JvdK> I'd also like to keep track of units. Is this problem solved i.e., JvdK> are there modules avalable which implement uncertain numbers with JvdK> units? Well, Konrad Hinsen has made public the module Scientific.Physics.PhysicalQuantities which seems to handle units at least. It has Constructor: * PhysicalQuantity(value, unit), where value is a number of arbitrary type and unit is a string containing the unit name. * PhysicalQuantity(string), where string contains both the value and the unit. This form is provided to make interactive use more convenient. I might try to fit that in with an ensemble-uncertainty class. 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 tim_one at email.msn.com Mon Oct 18 03:26:29 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 18 Oct 1999 03:26:29 -0400 Subject: Developing and testing modules live In-Reply-To: <871zatfdbg.fsf@ethereal.dhis.org> Message-ID: <000001bf193a$18e01740$842d153f@tim> [Nolan Darilek] > When I develop modules, I prefer testing them immediately after I > write each specific function. One solution I've tried is to run an > instance of the Python interpreter in a shell buffer alongside my > editting in another. When I import the module, test some > functionality and modify the source file, I've discovered that del'ing > and re-importing the module doesn't include the changes. > ... That's right -- del'ing the module merely removes a local name for the loaded module object, which latter remains intact (it's still living in the sys.modules dict). The builtin reload() function does what you want (see the Library Reference Manual). Notes: + If you're writing nested packages, it can get harder. + Use one of the Python IDEs instead of a shell. Anything from the Emacs python-mode to the Tk-based IDLE will make this easier (e.g., IDLE's "import" menu entry does an import or a reload, depending on whether the module has already been loaded; pymode has similar gimmicks in the Python process buffer). + See doctest.py in python.org's FTP contrib area for a painless way to save those interactive testing sessions as forever-after auto-verified examples. life-is-beautiful-ly y'rs - tim From guido at cnri.reston.va.us Tue Oct 12 22:24:32 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 12 Oct 1999 22:24:32 -0400 Subject: Q: Python 2.0 preliminary features? References: <000001bf1272$e8e29b80$0c2d153f@tim> <3801A8C9.37E0FC62@compaq.com> <14338.4935.540522.984598@bitdiddle.cnri.reston.va.us> <3802F1F7.C6BD5BE2@compaq.com> Message-ID: <5lu2nw576n.fsf@eric.cnri.reston.va.us> (I'm falling into the middle again. But this is interesting. I hope I haven't misunderstood Greg's description.) Greg Ewing writes: > Under my scheme, that piece of code in itself does not create > a cycle. This is because a nested def does not immediately create > a closure; instead it creates a special "local function object" > which simply wraps the function. A closure is created "on > demand" whenever a local function object is fetched out of a > local variable. This is analogous to the way a bound method > object is created whenever a function is fetched out of a > class during an attribute lookup. Hm. I don't find it analogous, and while I agree that it's a clever hack to avoid cycles, I don't like it much. Here's my reason: I dislike defining object types with "magic" properties that are effectuated whenever they are loaded. The magic may easily be triggered at the wrong moment -- e.g. the debugger may be looking at your stack frame, and depending on whether it copies the object it pulls out of your stack frame into a local variable before looking at it or not, it will see either a function or the magic object. (It doesn't have to be the debugger -- it could be any code looking at locals()). This is different from the method lookup -- that is only done in a very specific context (when during attribute lookup on an instance the object is found in the class). Note that this is also one of the reasons why I'm feeling uneasy with the stackless Python patch set (another reason is that it can't be done in JPython so it can't be made a part of the language standard): as far as I recall, it uses a magic object which when returned signals the interpreter to execute some callback that the called function wanted to be executed (this is necessary for apply() I believe). --Guido van Rossum (home page: http://www.python.org/~guido/) From fredrik at pythonware.com Thu Oct 14 15:55:47 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 14 Oct 1999 21:55:47 +0200 Subject: Tkinter Question References: <31658864B59ECF11AA700001FA444D61016B783A@SPFLDNT.lrsinc.LRS.COM> Message-ID: <015c01bf167e$1d58c330$f29b12c2@secret.pythonware.com> Burke, Jason wrote: > I've been pouring over the tutorials for using Tkinter, but I > can't seem to find an answer to what I think should be a > simple question. http://www.pythonware.com/library/tkinter/introduction/entry.htm => methods => "get -- Get the current contents of the entry field." or in other words: e = Entry(...) print "current value =>", e.get() or you can use a StringVar. for radiobuttons and checkbuttons, using a Tkinter variable (StringVar or IntVar) is the best way. see code samples on: http://www.pythonware.com/library/tkinter/introduction/checkbutton.htm http://www.pythonware.com/library/tkinter/introduction/radiobutton.htm btw, a new version of the tkinter introduction is in the works. watch http://www.pythonware.com/people/fredrik/tkintrobook.htm for details. coming soon: http://www.pythonware.com/people/fredrik/librarybook.htm From gmcm at hypernet.com Sun Oct 31 07:54:37 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sun, 31 Oct 1999 07:54:37 -0500 Subject: Changing cursors... In-Reply-To: <7vgqh7$a5v6q$1@titan.xtra.co.nz> Message-ID: <1270748767-19272684@hypernet.com> Xtian Muirhead writes: > > I've been having a play with Tkinter, and I've ported across a > program that I wrote while learning VB, but I've had one problem. > There's one step that has a chunk of processing which takes a few > seconds to complete. In the old program, I changed the cursor to > an hourglass at the start, and reset when the program finished. > Trying to do the same in the new version doesn't seem to work: [snip] No Tk expert, but as I recall, this is a general problem with Tk. Even murkier: I think Tk schedules the cursor-change which means, of course, that it doesn't happen until too late. (Java's AWT had/has? the same problem but even worse - it would get confused and leave the cursor in the wrong state). The work-around that I saw wasn't, to my mind, worth the effort, and I decided to be satisfied with the button remaining depressed. But perhaps the eff-bot has a more elegant solution. - Gordon From greg.ewing at compaq.com Fri Oct 8 03:47:19 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 08 Oct 1999 20:47:19 +1300 Subject: Just like in our DNA... References: <5l670j70fz.fsf@eric.cnri.reston.va.us> <7tiqdc$lau$1@newshost.accu.uu.nl> Message-ID: <37FDA187.8899378F@compaq.com> Martijn Faassen wrote: > > often these junk regions > look very much like genes that are active, but mutated somewhat. God tried out a variation on the procedure, and then commented it out! Greg From neelk at brick.cswv.com Sat Oct 9 17:59:29 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 9 Oct 1999 21:59:29 GMT Subject: Q: Python 2.0 preliminary features? References: <7tlk6p$4o5$1@nnrp1.deja.com> Message-ID: On Fri, 08 Oct 1999 20:29:30 GMT, Preston Landers wrote: > >I'm not really asking about the implementation but the language >itself; any interesting changes ahead? Yes, Python 2.0 will be Perfect(tm). :) Other than that, only Guido knows for sure. Some of the more common requests are: o Elimination of the class/C-type dichotomy. C extension types (like dictionaries and lists) should be real Python classes. o Lexical scoping, a la Scheme. o Optional type anotations, in order to enable more compile-time type checking, and to (possibly) allow faster native Python code. (I'm dubious about the latter working, though.) o A better-designed iteration protocol. There are some other features that are less frequently requested but may happen simply because there are people actually willing to sit down and implement them. (These might even make 1.6, for all I know.) o List comprehension syntax, a la Haskell. In fact, Greg Ewing has already implemented this as a patch. o First-class continuations, a la Scheme. This might make it in just to permit coroutines and exceptions with restarts. Look at Christian Tismer's Stackless Python for the current state. >And just because I like to start flame wars, I'll go ahead and add my >own feature to the wishlist: nested scopes / namespaces. Is this a >pipe dream, or just too hard to implement given the internal structure >of Python (which I'm not really familiar with.) Maybe I'm just going >about it all wrong, but it seems like much of my code would be cleaner >given arbitrarily nested scopes. I've discussed this with people >before on c.l.python but never really got an explanation that made >sense (to me) for the way it is now. The basic reason that Python does not currently support lexical scoping is because Python uses a reference-counting garbage-collection scheme, which can't eliminate cyclic trash, and lexical closures tend to create a lot of it. Since the reference-counting scheme is woven fairly deeply into Python, this is why lexically nested namespaces won't be seen in any Python 1.x, and why people keep pushing garbage-collection is a priority for Python 2.0. If you are desperate for it now, you should look at Neil Schemenauer's patch to get the Python interpreter to use the Boehm garbage collector, and add in Greg Ewing's lexical scoping patch. That should get you 75% of what you want. (The remaining 25% requires some syntactic changes to Python, in order to allow nested local namespaces to shadow properly. Talk to John Max Skaller about Viper to see what his sense of the problem and what the potential solutions are.) Neel From ratman at nmt.edu Mon Oct 18 15:11:11 1999 From: ratman at nmt.edu (Jason Trowbridge) Date: Mon, 18 Oct 1999 13:11:11 -0600 Subject: newbieq: IDLE 0.4 question References: <7ugfd8$c9q$1@nnrp1.deja.com> Message-ID: <380B70CF.C6BEA1FC@nmt.edu> >From what I understand, Python caches the modules once they're imported once. If another module/scope imports that same module, it is given a shallow copy of the loaded module (much faster & less memory than loading a completely different copy). Anyway, to reload the module, you need to call reload(): import mymodule reload(mymodule) sep wrote: > > Hi, how do I tell the Python Shell to reload a module after I edit it? > I do a save in the editor then import module in the shell and the old > one is still in memory. del module seems to delete it but then import > module and the old one is there. I know I'm missing something here. I'm > on NT. > > thanks, > -- > Sepehr (Sep) Kiani > ************************************ > skiani at alum.mit.edu > http://pergatory.mit.edu/skiani > > Sent via Deja.com http://www.deja.com/ > Before you buy. From python-list at teleo.net Fri Oct 29 14:19:56 1999 From: python-list at teleo.net (Patrick Phalen) Date: Fri, 29 Oct 1999 11:19:56 -0700 Subject: advocate needed! get organized you Python gurus :-) In-Reply-To: References: Message-ID: <99102911314704.01843@quadra.teleo.net> [Christopher Petrilli, on Fri, 29 Oct 1999]: :: > This was forwarded to me. Anyone interested in coming face 2 face :: > with Tom and Brent? :-) Don't ask me why I don't go, I'm far from :: > being a Python expert (I'm trying, though). :: :: I think Tim Peters is the correct foil to Tom Christiansen :-0 Of course the entity we call "TIm Peters" is the perfect foil for the Homo Sapien called "Tom Christiansen." The problem enters with the "face 2 face" part. It's becoming increasingly evident that "Tim Peters" is something on the order of an emergent intelligence which arose spontaneously from the primordial soup of the Python list. In its current state of development, "Tim" doesn't appear to have evolved an Avatar mode of operation (in the Snow Crash sense). So how could "he" appear in Seattle? Unless his employer is willing to cooperate. Perhaps he could make an appearance as that Windows paperclip thingy. :) From a.eyre at optichrome.com Tue Oct 26 06:12:44 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Tue, 26 Oct 1999 11:12:44 +0100 Subject: Module for generic platform information: platform.py In-Reply-To: <3815782E.FC516671@lemburg.com> Message-ID: <001001bf1f9a$a51c1950$3acbd9c2@peridot.optichrome.com> > Some things where I need some more help are: > [snip] And Windows NT by the looks of it. All I get from the program is: "win32" -------------------------------------------- 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 vascog at uol.com.br Sun Oct 24 07:44:39 1999 From: vascog at uol.com.br (Joao Neto) Date: Sun, 24 Oct 1999 09:44:39 -0200 Subject: [Q] keeping *args and using it later Message-ID: <7uur88$pm0$1@fu-berlin.de> Hi! If I use a method to receive another method and its arguments, something like: def keepCall( method, *args ) newTuple = (method, args) myQueue.append( newTuple) How can I call that method later? Just typing nextTuple = myQueue[0] myQueue.remove(nextTuple) nextTuple[0](nextTuple[1]) doesn't seem to work... Thanks in advance! Joao From phd at sun.med.ru Sun Oct 17 08:36:24 1999 From: phd at sun.med.ru (Oleg Broytmann) Date: Sun, 17 Oct 1999 16:36:24 +0400 (MSD) Subject: Bidirectional communication through pipes: read/write popen() In-Reply-To: <00a401bf189b$c80d3710$f29b12c2@secret.pythonware.com> Message-ID: On Sun, 17 Oct 1999, Fredrik Lundh wrote: > Oleg Broytmann wrote: > > On 17 Oct 1999, Hrvoje Niksic wrote: > > > def rwpopen(input, command, args=[]): > > ^^^^^^^ > > There was well-know problem with passing mutable object as a default. > > Not sure if it was fixed in recent versions of Python... > > well, that's only a problem if you modify the object > inside the function... Sooner or later you forget about it and modify args and what? :) No, I better will avoid this completely until Python fixes it. > (and no, it hasn't been fixed. I doubt it can be > fixed without breaking stuff). Mmm??? Are there a line of code that *relies* on that misfeature? Oleg. ---- Oleg Broytmann National Research Surgery Centre http://sun.med.ru/~phd/ Programmers don't die, they just GOSUB without RETURN. From loewis at informatik.hu-berlin.de Fri Oct 15 16:28:59 1999 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 15 Oct 1999 22:28:59 +0200 Subject: Im new Help References: <376-38066AB5-93@storefull-255.iap.bryant.webtv.net> Message-ID: DASH14 at webtv.net (Charmeleon) writes: > I just downloaded python and got the book by o'relliy. the only thing i > know how do to do is is make a button does anyone know where I can > download games written in python so I can see the sorce. There are not many games available were you can source code for; please search on www.python.org for "game", or any other appropriate keys. One game I found was http://starship.python.net/crew/amk/python/simple/letters.py.html Hope this helps, Martin From MSteed at altiris.com Fri Oct 15 11:49:12 1999 From: MSteed at altiris.com (Mike Steed) Date: Fri, 15 Oct 1999 09:49:12 -0600 Subject: Nested if's Message-ID: <65118AEEFF5AD3118E8300508B124877073C2F@webmail.altiris.com> > From: geojempty at aol.com [mailto:geojempty at aol.com] > Sent: Friday, October 15, 1999 9:21 AM > To: python-list at python.org > Subject: Nested if's > > > I'm brand new to Python, though I chose it for my CGI > programming because of > it's similarity to the language I use at my day-job: the Progress 4GL > > Enough for intros. I'm having a problem nesting if > statements. I'm defining a > function, and my syntax checks fine, until I try the following: > > if digit > 0: > if digit = 5: > variable = variable + whatever As it stands, the 2nd line will raise a SyntaxError. It's doing an assignment, not a comparison. It's an error because assignment is not an expression in Python. Instead try: if digit == 5: -- M. From glyn at ninz.not.org.nz Fri Oct 22 23:14:35 1999 From: glyn at ninz.not.org.nz (Glyn Webster) Date: Sat, 23 Oct 1999 03:14:35 GMT Subject: Recusive function inside a function can't find itself. Message-ID: <7ur95o$bk8$1@news.wave.co.nz> I've defined a function inside a function. I pass all the variables it needs into it through its argument list, which usually works. But what happens this time is that I get a "NameError: fill_code_list" where the function first calls itself recusively. Am I doing something wrong? (Other than pretending Python is Scheme?) def display_codes(node): """ Pretty-prints the weight and codes for all items in the Huffman tree hanging from `node'. """ def fill_code_list(list, node, code): if len(node.items) == 1: item = node.items[0] list.append((item, node.weight, code)) else: fill_code_list(list, node.lower, code + "0") #SPLAT fill_code_list(list, node.higher, code + "1") list = [] fill_code_list(list, node, "") list.sort(lambda a,b: -cmp(a[1], b[1])) #By descending weight. for (item, weight, code) in list: print " %-6s %4i %s" % (`item`, weight, code) -- (Remove the negation from my address to reply by email.) "ThE oRigiN and SigNificaNce of thIs pRacTicE iS oBscuRe." From neilh at hare.net.au Tue Oct 12 11:08:03 1999 From: neilh at hare.net.au (neilh at hare.net.au) Date: Tue, 12 Oct 1999 15:08:03 GMT Subject: Disk access going mental with Pythonwin? References: <000901bf1488$6a664be0$0801a8c0@bobcat> Message-ID: <7tvis8$s7c$1@nnrp1.deja.com> > Ummm - sheepishly, I admit that would be Pythonwin. Pythonwin has a > feature that automatically detects if the file you are editing has > been modified externally. This check is done in idle time, and each > time you move the > mouse (then stop moving it), Pythonwin enters its idle state. > > I really should add a config option to control this, but currently it > is always turned on... You could have the test done only at application activation time as that is normally the only time a changed file will appear. Or maybe have a choice of (no | activation | idle) detection. The next version of SciTE will have a load on activate option. Neil Sent via Deja.com http://www.deja.com/ Before you buy. From g_will at cyberus.ca Fri Oct 8 07:54:14 1999 From: g_will at cyberus.ca (Gordon Williams) Date: Fri, 08 Oct 1999 11:54:14 GMT Subject: Make Stand Alone W32 Installer Crash with tk Message-ID: <01bf1183$a1637120$0e41c3d1@Cyberus.cyberus.ca> Hi All, I have been trying to get Gordon McMillan's and Thomas Heller's win32 installer to work properly to make a stand alone .exe which uses tk. I have tried Installer_b_02a and _b_02b as well as the non-beta version. They all have the same problem with the tk and tlc libraries not being found. This happens 19 times out of 20, but for some reason it does work sometimes. As a newbie trying to hack something together for my first time, I cant figure out what the problem is. I have tried adding extra paths to just about everything, putting the installer in different directories relative to the Python directory, runing it under command line python and pythonWin, ... etc. The main script is very simple, a hello world kind of thing, where a couple of buttons and a canvas oval are put on the screen. Only Tkinter is imported. During making the stand alone with builder.py the following occurs: Traceback (innermost last): File "E:\Program Files\Python\Pythonwin\pywin\framework\scriptutils.py", line 237, in RunScript exec codeObject in __main__.__dict__ File "E:\Program Files\Python\Installer_b_03b\install\create\Builder.py", line 496, in ? main(opts, args) File "E:\Program Files\Python\Installer_b_03b\install\create\Builder.py", line 479, in main target.build() File "E:\Program Files\Python\Installer_b_03b\install\create\Builder.py", line 302, in build lTOC = self.buildTOC() File "E:\Program Files\Python\Installer_b_03b\install\create\Builder.py", line 267, in buildTOC self.buildTCLTKsupport(lTOC) File "E:\Program Files\Python\Installer_b_03b\install\create\Builder.py", line 105, in buildTCLTKsupport tcllib = os.environ['TCL_LIBRARY'] File "E:\Program Files\Python\Lib\os.py", line 247, in __getitem__ return self.data[string.upper(key)] KeyError: TCL_LIBRARY The Builder.log shows: binary dependencies of hello.py [('win32api.pyd', 'E:\\Program Files\\Python\\win32\\win32api.pyd'), ('_tkinter.pyd', 'E:\\Program Files\\Python\\DLLs\\_tkinter.pyd')] [('_tkinter.pyd', 'E:\\Program Files\\Python\\DLLs\\_tkinter.pyd'), ('win32api.pyd', 'E:\\Program Files\\Python\\win32\\win32api.pyd'), ('zlib.pyd', 'E:\\Program Files\\Python\\DLLs\\zlib.pyd')] analyzing _tkinter.pyd found KERNEL32.dll found tcl80.dll lib not found: tcl80.dll dependency of found tk80.dll lib not found: tk80.dll dependency of found python15.dll lib not found: python15.dll dependency of found MSVCRT.dll analyzing win32api.pyd found KERNEL32.dll found USER32.dll found ADVAPI32.dll found SHELL32.dll found OLEAUT32.dll found PyWinTypes15.dll lib not found: PyWinTypes15.dll dependency of found python15.dll lib not found: python15.dll dependency of found MSVCRT.dll analyzing zlib.pyd found python15.dll lib not found: python15.dll dependency of found MSVCRT.dll found KERNEL32.dll merged/expanded binary dependencies [('_tkinter.pyd', 'E:\\Program Files\\Python\\DLLs\\_tkinter.pyd'), ('win32api.pyd', 'E:\\Program Files\\Python\\win32\\win32api.pyd'), ('zlib.pyd', 'E:\\Program Files\\Python\\DLLs\\zlib.pyd')] lTOC after excludes [('_tkinter.pyd', 'E:\\Program Files\\Python\\DLLs\\_tkinter.pyd'), ('win32api.pyd', 'E:\\Program Files\\Python\\win32\\win32api.pyd'), ('zlib.pyd', 'E:\\Program Files\\Python\\DLLs\\zlib.pyd')] Cannot find TCL/TK libs from either the dll's location or the TCL_LIBRARY & TK_LIBRARY environment variables Shutting down My hello.cfg file is: [MYSINGLEFILE] name= hello.exe type= SINGLEFILE destdir= ./build_hello bindepends=hello.py includeTK= 1 zlib= MYZLIB script= hello.py [MYZLIB] name= hello.pyz dependencies= hello.py excludes= dospath, posixpath, macpath includes= Sorry for adding so much code. Any ideas on what I need to do? Has anyone used it with tk and got it to work? Thanks, Gordon Williams From Kirill.Budkevich Mon Oct 25 04:49:31 1999 From: Kirill.Budkevich (Kirill.Budkevich) Date: Mon, 25 Oct 1999 10:49:31 +0200 Subject: Programming for Web Message-ID: Programming for Web. Belorussian company "Ilmax" Ltd offers you services on web programming. It is possible for us to create in short period a modern web-site, to redo an old site using new technologies, to build in Your site an internet shop and etc. We have highly qualified web programmers (PERL, CGI(SSI,SSL), JAVA). Our specialists speak Your language. The level of our prices will pleasantly surprise You. The prices are formed considering our expenses in OUR country. In case our offer is interesting to You, do not hesitate to contact us. We will be glad to cooperate with You. Contact person: Kirill Budkevich E-mail: budkevich at mail.ru From arcege at shore.net Wed Oct 13 18:10:56 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 13 Oct 1999 22:10:56 GMT Subject: Cisco config? References: <7u2rhe$j3s@dfw-ixnews12.ix.netcom.com> Message-ID: Aahz Maruch wrote: : I've found Gconfig, but my searching hasn't turned up anything for : automated configuration of a Cisco router (a la "expect"). Any : pointers? What about using Expect or ExpectPy? -Arcege From bill at hk.rfa.org Mon Oct 4 04:34:13 1999 From: bill at hk.rfa.org (Bill Eldridge) Date: Mon, 04 Oct 1999 16:34:13 +0800 Subject: HELP again! Changing timezone in Python Message-ID: <37F86685.98B1CE65@hk.rfa.org> Still trying to figure out how to make a machine in Hong Kong do all its Python time calculations as if it were located in Washington. This means I need to take a date like 1999-10-23-0200 and decide if it's EST or EDT, but I can't use my local system time, since that's China time, where DST doesn't exist. Ideas? (yes, I can write a quick script on a Washington machine to figure out time switchovers for the next 50 years, but that's a bit ugly, so I'd rather get the info from a Python module or by parsing the timezone files. Thanks, Bill -- Bill Eldridge Radio Free Asia bill at hk.rfa.org From mikle at amv.tsk.ru Mon Oct 11 05:30:09 1999 From: mikle at amv.tsk.ru (Mikhail Astafiev) Date: Mon, 11 Oct 1999 16:30:09 +0700 Subject: Pythoning of C++ objects In-Reply-To: <7trn39$e86$0@216.39.151.169> References: <7trn39$e86$0@216.39.151.169> Message-ID: <11687.991011@amv.tsk.ru> Hi Donn, you wrote: > When I set out to do this for the BeOS C++ API, I borrowed heavily > from James Ahlstrom's Wpy interface to MFC, as described in > http://www.python.org/workshops/1995-12/papers/ahlstrom1.html > Now as I understand it, this is sort of the inverse of what CXX > does, so whether it's light or heavy, if it's at all suited to > what you're doing, then you should ignore my advice. Thank you! It's looks very interesting. It helped me to make some things clearer. Regards, Mikhail. From wtanksle at hawking.armored.net Sat Oct 23 10:27:26 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 23 Oct 1999 14:27:26 GMT Subject: Musings about Python syntax References: <7ui60u$hg1$1@nnrp1.deja.com> <199910191923.MAA00522@hermes.aspectdv.com> Message-ID: On Wed, 20 Oct 1999 00:05:08 GMT, Jason Stokes wrote: >On Tue, 19 Oct 1999 12:27:59 -0700, Jim Althoff wrote: >>At 07:03 PM 10/19/99 +0200, Fredrik Lundh wrote: >>>steve_allison at my-deja.com wrote: >>>hey, what makes you think len(obj) is less object- >>>oriented than obj.len() ? it's just syntax, you know. >>But it IS less consistent syntax with not much advantage >>("del" is a different story). So it would be very nice if >>I could write aList.len() if I prefer that to len(aList). >Experienced pythoners might correct me, but I believe Python's object model >is younger than its basic design. Not true. Python was designed to be OO from the start. >Plus, Python has to balance the >consideration that many people do not wish to program in the object-oriented >manner. This is true, but has little to do with this. The probelm was that in the original implementation they didn't bother implementing messages in several of the basic types. >Personally I prefer a completely consistent committment to object >orientation, like, say, Smalltalk, but horses for courses and all that. Not really relevant. You could complain about the inconsistent syntax, but in fact that serves a purpose as well. >Jason Stokes: jstok at bluedog.apana.org.au -- -William "Billy" Tanksley From skaller at maxtal.com.au Tue Oct 19 16:07:54 1999 From: skaller at maxtal.com.au (skaller) Date: Wed, 20 Oct 1999 06:07:54 +1000 Subject: Q: Python 2.0 preliminary features? References: <7tlk6p$4o5$1@nnrp1.deja.com> <3801486F.A7CDEF1D@maxtal.com.au> <3809C575.B8F953FF@maxtal.com.au> Message-ID: <380CCF9A.3BD80F74@maxtal.com.au> Michael Hudson wrote: > > skaller writes: > Hold it there a second; you are proposing that knowing that x has a > certain type in the expression > > x = x + "hello" > > has an impact on inference? Yes. Rather, the type of x is _deduced_ from the fact that operator + must be string concatenation in this context, since the second argument is a string, and thus x must be a string. >That's a BIG sea change from CPython. Haven't you ever done this: > > option = raw_input("enter a parameter> ") > try: > option = int(option) > except: > print "get a Clue" > > OK, contrived example. This is a good example! Viper will handle it! It will know that 'option' is _either_ a string or an int. [It _has_ to] In other words, the type inference system WILL work with ordinary Python, allowing a variable to take values of multiple types. There will even be a special handling for the most often used case: try: option = some_function(args) except: option = None that is, 'option is either a string or None'. > But the same name can refer to variables of > different types at different times, so I don't think you can use that > for inference. Sure you can. However, the inference algorithm is not the same as for a statically typed language. > PS: Given the bizarre reluctance of my university to give me any work, > can I ask if the source to viperi (at least) will be perusable anytime > soon? Don't know. Due to the bizarre reluctance of _anyone_ to give me any work, I need to make some money somehow. I would like to do this serving the computing community. I want Viper to be free software (eventually), but I have to eat. So the answer is: probably, I will release it for free evaluation (but not commercial use). But I'm not sure how to best approach this problem. Any ideas? -- John Skaller, mailto:skaller at maxtal.com.au 1/10 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller downloads: http://www.triode.net.au/~skaller From nascheme at enme.ucalgary.ca Tue Oct 19 16:01:28 1999 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Tue, 19 Oct 1999 20:01:28 GMT Subject: fastest string building? References: <7uieee$nsa$1@nnrp1.deja.com> Message-ID: Preston Landers wrote: >Can someone look at my profiling script and see if I made any obvious >errors? Is behavior of strings already well-known? I think you under-estimated the difficulty of benchmarking. :) The speed of each method depends on the situation. Method 1 is really bad if you continuously add characters on the end of a long string: spam = '' for i in range(10000): spam = spam + 'a' This creates and destroys a string object each time around the loop. In this case, method 2 or [c]StringIO is much better: spam = [] for i in range(10000): spam.append('a') spam = string.join(spam, '') I believe this is the primary use of the string.join idiom. I would never write: spam = string.join([a, b, c]) but rather: spam = '%s%s%s%s' % (a, b, c) or even: spam = a + b + c if I am lazy and the strings are not expected to be huge. Neil From claird at starbase.neosoft.com Thu Oct 28 06:35:25 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Oct 1999 10:35:25 GMT Subject: Using python to run scripts References: <7v75hc$1eik$1@rtpnews.raleigh.ibm.com> Message-ID: <610D1AB3CD1FF885.0E74774F2EBDCC32.8274B3096A6770B6@lp.airnews.net> In article <7v75hc$1eik$1 at rtpnews.raleigh.ibm.com>, Arinte wrote: >I want to use python in my app to run test scripts. I am trying to learn it >right now. But, what I wanted to know is when I get ready to distribute the >app (if ever =-(), does the user have to have all of python installed or is >it just a dll or something. This is strictly for windows on the App side >anyway. . . . It is possible--convenient, even--to wrap up all of your application in a single file, so that your users do NOT have to install Python. See for details. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From sparlin at openpro.org Sun Oct 10 12:13:21 1999 From: sparlin at openpro.org (Sonny Parlin) Date: 10 Oct 1999 12:13:21 -0400 Subject: Newbie question: files.. References: <38003892.85E01BC@mindspring.com> <004301bf1326$a3dd0840$f29b12c2@secret.pythonware.com> Message-ID: "Fredrik Lundh" writes: > age, different execution models, different > approach to typing, etc, etc. > > as for reading text files, it's a well-known > fact that Perl is sometimes *faster* than C: > > http://www.deja.com/getdoc.xp?AN=505288860 > WOW, now that's interesting! I never would have guessed something like that. Are you saying that perl code such as: while() { print "$_\n"; } could be faster than low level C code such as: while ((c = read (fd, buf, BUF_SIZE)) > 0) write (1, buf, c); Not sure about that, or do you mean using C file pointers (i.e. stdio, as opposed to lower level methods (i.e. unistd/fcntl which is what my C example shows above))? I just tried those two pieces of code measuring time with /bin/time and the C version was consistently faster than the perl version... But I could see where using C file pointers and higher level functions such as fgets would be slower than Perl, especially if Perl code is implemented using the lower level methods underneath... Please keep in mind that I'm pretty ignorant to how Perl (or python for that matter) is implemented under the hood. And it sounds like you know a bit more about that, so forgive me if I'm pushing the issue here, I'm just trying to learn... > unfortunately, Python's file object is still > layered on top of C's stdio. but that may > of course change some day... > As opposed to unistd or fcntl? > for more info on other speed issues, skip > over to http://www.python.org/search/ > and search for "is perl faster than python" > (and similar phrases) in the newsgroup > archives. > Thanks for all your advice! -Sonny -- Sonny Parlin sparlin at openpro.org http://www.openpro.org fingerprint = 45 FE 56 72 C2 04 CD 76 09 75 52 7A C6 7C 23 D2 From meh9 at cornell.edu Thu Oct 7 11:48:21 1999 From: meh9 at cornell.edu (Matthew Hirsch) Date: Thu, 07 Oct 1999 11:48:21 -0400 Subject: List vs. Tuple Message-ID: <37FCC0C4.DF34352F@cornell.edu> Hi All, Can someone explain to me why if there is only a string in a list/tuple they behave differently when looped through. For example, >>> list=['abcd'] >>> tuple=('abcd') >>> for x in list: ... print x ... abcd >>> for x in tuple: ... print x ... a b c d >>> Shouldn't the second loop also print 'abcd'? Thanks for your help, Matt From nascheme at enme.ucalgary.ca Sun Oct 3 20:59:39 1999 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Mon, 04 Oct 1999 00:59:39 GMT Subject: A Python color syntax file for VIM References: Message-ID: Alan Daniels wrote: ... >I've always noticed that the default syntax highlighting for >Python is sort of Spartan, in that it colors strings and >keywords, and thats about it. This is intentional. >This is just a test of better syntax highlighting... To adapt a quote on threads: Syntax highlighting is like salt. I like salt, you like salt, we all like salt, but we eat more pasta than salt. IMHO, your version highlights too much stuff. I just noticed that the latest version of Vim does not include my latest syntax file for Python. I have included some of your changes and submitted a new version to Bram. Hopefully he will include it in the next version of Vim. If you can't wait you can get it here: http://adler.dynodns.net/~neil/vim/syntax/python.vim One of the major changes in this version is that function and class names are highlighted. This is consistent with emacs and IDLE. There is also support for highlighting numbers but it is disabled by default. I feel this hurts readability rather than helping it. Why are numbers in code so special that we have to make them a different color? Lots of other syntax files do this so I guess some people must like it. I don't want to ram my beliefs down everbody's throat though. Users of python.vim, please vote: a) more highlighting b) less highlighting c) its perfect, don't mess with it If I get enought votes I will post a summary. I guess emacs (and IDLE) users can vote too as they highlight similar to Vim. Neil From greg.ewing at compaq.com Fri Oct 15 09:38:25 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Sat, 16 Oct 1999 02:38:25 +1300 Subject: Improved struct module References: <000001bf15fc$3397ee00$ba2d153f@tim> Message-ID: <38072E51.D212ACBB@compaq.com> Tim Peters wrote: > > a buffer object contains a pointer to a base object and a > separate pointer to a chunk of untyped memory. If the base object happens > to stop using that memory, there's no way for the buffer object to know > that. That sounds like a description of one way to mis-implement the buffer interface of an object, rather than a flaw in the buffer interface concept itself. Are there any existing objects which have this problem? If so, they should be fixed. Greg From aa8vb at yahoo.com Thu Oct 28 15:01:03 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 28 Oct 1999 15:01:03 -0400 Subject: Destroying files In-Reply-To: <7v9h4r$k33$1@sparky.wolfe.net> References: <7v9h4r$k33$1@sparky.wolfe.net> Message-ID: <19991028150103.A106850656@vislab.epa.gov> |Is there a utility out there for finding and destroying deleted files from |my hard drive? I'm not sure if this is a genuine question or flame bait. Could you clarify your request? What platform? What tools do you use to delete? On a hunch, is this MSWindoze? And are the "deleted" files you speak of in that "wastebasket" thing? If so, realize that you can turn the wastebasket off (i.e. really delete files when you say to delete them). -- Randall Hopper aa8vb at yahoo.com From mal at lemburg.com Wed Oct 27 10:05:06 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 27 Oct 1999 16:05:06 +0200 Subject: Module for generic platform information: platform.py References: <001001bf1f9a$a51c1950$3acbd9c2@peridot.optichrome.com> <38157F32.1C0958DA@lemburg.com> <3815C805.D0B4F762@callware.com> <3816155A.67431E95@lemburg.com> <38161667.950EE8A9@callware.com> <3816C56C.C72FF1C1@lemburg.com> <00e601bf206b$c2c7b280$4500a8c0@thomasnotebook> Message-ID: <38170692.D6D438C3@lemburg.com> Thomas Heller wrote: > > > [...] BTW, is there any way (other than using the registry) to find > > out the patch level of WinNT, e.g. something like "Windows NT 4.0 with > > SP4" ? Since this information seems vital on WinNT I think it should > > be included in the version string. > > You can use the command > "winmsd /s /f" > to generate a report containing more than you ever wanted to know about NT. > Flags: /s - summary report (about 13kB here), > or /a - complete system report (about 40kB) > /f - system report will be sent to file, > or /p - system report will be sent to printer > > The first few lines are: > Microsoft Diagnostics Report For \\THOMASNOTEBOOK > ---------------------------------------------------------------------- > > OS Version Report > ---------------------------------------------------------------------- > Microsoft (R) Windows NT (TM) Workstation > Version 4.0 (Build 1381: Service Pack 4) x86 Uniprocessor Free > Registered Owner: Thomas Heller, ION-TOF GmbH > Product Number: <...deleted...> > > Problems I see: > a - the report is written to the file .txt in the current > directory > (hostname.exe will return this name) > b - the report is written in the language corresponding to the NT version > c - you may want to start winmsd with the command line > "start /wait winmsd /s /f" > so that the command returns when winmsd is finished. > d - winmsd displays a progress box (which you may not want to see?) > e - I'm not sure if winmsd is included in every version of NT, > I could only check several NT4.0 boxes here. Sounds interesting, but if it's not installed per default I guess it won't help much. Perhaps there are still other ways to find out the build and service pack information... BTW, what does 'ver /r' output on WinNT ? On Win95 it does provide some more information than the plain 'ver'. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 65 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From tre17 at student.canterbury.ac.nz Fri Oct 29 18:48:13 1999 From: tre17 at student.canterbury.ac.nz (Tim Evans) Date: 30 Oct 1999 11:48:13 +1300 Subject: pipes and commands References: <87d7ty4cyg.fsf@python.kullen.rwth-aachen.de> Message-ID: Gregor Zych writes: > Hi! > How can I get many commands connected with pipes executed. I try > > startexe = 'gs -q -dNOPAUSE -sDEVICE=pbmraw -r600x600 -sOutputFile=- '+pfad+'/'+name+'.eps quit.ps | pnmcut 610 982 4023 5483 | pnmtotiff - > '+pfad+'/'+name+'.tif' > os.system(startexe) > > but the system just waits for ever until I interrupt it, although it > gets the final file written correctly. > os.popen() seems to make my system unusable 'cos it slurps the generated > file und these pictures are HUGE. Any hints are welcome. > Linux 2.2.11 python 1.5.2 > Ciao > Gregor Not a Python solution, but the `convert' program from `imagemagick' is really good at this sort of conversion (ps -> image) and can do all of the above line in a single step IIRC, so you don't need the pipes. It's not really an answer, but it might solve your problem. The home page for imagemagick is: http://www.wizards.dupont.com/cristy/ImageMagick.html -- Tim Evans From ngps at madcap.dyn.ml.org Thu Oct 14 09:03:03 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 14 Oct 99 13:03:03 GMT Subject: HTTP or/and HTTPS server in Python! References: Message-ID: <3805d487.0@news.cyberway.com.sg> According to tommy : > I wounder if someone have wrote a HTTP or even a HTTPS server in Python? HTTP - *HTTPServer in the standard library, Medusa HTTPS - M2Crypto at http://www.post1.com/home/ngps/m2 -- Ng Pheng Siong From junkster at nospam.rochester.rr.com Tue Oct 12 19:13:15 1999 From: junkster at nospam.rochester.rr.com (Benjamin Schollnick) Date: Tue, 12 Oct 1999 23:13:15 GMT Subject: Anyway to *SET* the date & time? References: <19991006021336.B28582@quark.emich.edu> <99100608480103.00964@quadra.teleo.net> Message-ID: On Wed, 6 Oct 1999 15:42:57, Patrick Phalen wrote: > :: It's annoying, but I can work around it for said platforms. *nix, and > :: everything else are out of luck, since I don't know how to set their > :: clock, > :: but........ That's what modifying the source if for. > > Perhaps I missed something at the beginning of this thread... Why don't > you just set up ntp server/client on one *nix box and ntp clients on > the others? Because we are using Windows NT servers.... Not my choice, but I have to work with what is given to me. - Benjamin ================================ Please feel free to copy any and or all of this sig. A little something for spam bots: root at localhost postmaster at localhost admin at localhost abuse at localhost postmaster at 127.0.0.1 Chairman William Kennard: bkennard at fcc.gov Commissioner Susan Ness: sness at fcc.gov Commissioner Harold Furchtgott-Roth: hfurchtg at fcc.gov Commissioner Michael Powell: mpowell at fcc.gov Commissioner Gloria Tristani: gtristan at fcc.gov consumerline at ftc.gov fccinfo at fcc.gov ssegal at fcc.gov From x at x.x Wed Oct 27 21:03:10 1999 From: x at x.x (Eric Jacobs) Date: Wed, 27 Oct 1999 21:03:10 -0400 Subject: 'Dynamic' class instances References: <381629BC.3E47158E@x.x> <38171fe8.14091745@news1.mysolution.com> Message-ID: <3817A0CE.7322D7BC@x.x> Ken Power wrote: > > Hmmm. Thank you for the input. I really appreciate it. If you would > please, in a simple example, how would you, "use a dictionary for the > purpose rather than manipulating any namespaces."? > > The part about namespaces I understand (should the new instance be > global in nature, or localized to a module), using dictionaries in > your implied sense, I do not understand, please expound. I can only speculate about what you need to do here, but taking from your original example: class spam: pass test = raw_input("class name: ") test = spam() What I assume you're trying to do is take whatever that user enters here, create a variable with that name, and put a new instance of the spam class in it. So: class name: happy would result in a variable named happy that contains a new instance of spam. But consider what would happen if they entered: class name: sys or even class name: spam Python wouldn't issue an error in this case; it would simply happily overwrite the variables sys and spam with an instance of spam. The latter case could effectively delete the spam class, replacing it with one of its instances! A dictionary would be better suited: d = {} test = raw_input("class name: ") d[test] = spam() Now if they type "happy", you have a variable that you can access via d["happy"]. If they type "sys", you can use d["sys"], etc, and there's no chance of the user interfering with the execution of your module. Suppose you wanted to do the opposite thing: have the user enter the name of class which is to be instantiated. So: class name: Pickler would create an instance of the class Pickler. A dictionary would also help here: d = {"Pickler": Pickler, "Unpickler": Unpickler} test = raw_input("class name: ") instance = d[test]() By listing out the dictionary items by hand, you can strictly control what the user may and may not access at your prompt. From phd at phd.russ.ru Tue Oct 19 03:50:00 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Tue, 19 Oct 1999 07:50:00 +0000 (GMT) Subject: Bug tracking tool in Python In-Reply-To: <14347.37558.707672.802591@anthem.cnri.reston.va.us> Message-ID: On Mon, 18 Oct 1999, Barry A. Warsaw wrote: > think the Zope folks have an issue tracker written in Python, but I > haven't played with it. It is called Collector, but it is based on their commercial product ZTable, so sources are not available. Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From gary at pgrad.cs.su.oz.au Thu Oct 28 09:57:12 1999 From: gary at pgrad.cs.su.oz.au (Gary Capell) Date: 28 Oct 99 13:57:12 GMT Subject: Learning to program References: <7v82o9$c31$1@news4.svr.pol.co.uk> Message-ID: "Jonathan" writes: > Python seems one of the most >suitable languages to start with. Agreed, but see below. > I think the Lutz et al book is good at >explaining the language to a newcomer, but I'd also like to find an >accessible book that explains program design, clarity, debugging, data >structures, etc in a Python friendly way. Suggestions? ("Programming Pearls" >and "The Practice of Programming" are just too much book for my friend's >needs and experience right now.) Tricky. I don't know of books as good as "PP" or "the P of P" for beginners. SICP doesn't count as I don't think most folks could teach themselves from it. Maybe someone needs to write something like "The Little Schemer", but for Python? From DASH14 at webtv.net Thu Oct 14 19:43:49 1999 From: DASH14 at webtv.net (Charmeleon) Date: Thu, 14 Oct 1999 17:43:49 -0600 (MDT) Subject: Im new Help Message-ID: <376-38066AB5-93@storefull-255.iap.bryant.webtv.net> I just downloaded python and got the book by o'relliy. the only thing i know how do to do is is make a button does anyone know where I can download games written in python so I can see the sorce. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jlp at apti.com Fri Oct 8 15:27:00 1999 From: jlp at apti.com (James L. Preston) Date: Fri, 08 Oct 1999 19:27:00 GMT Subject: fatal relocation error when import shared libs on SOlaris 2.6 Message-ID: <37FE4584.17E9B221@apti.com> I have a new SPARCStation running Solaris 2.6, and I have been installing the latest versions of all my favorites (especially Python). I have gcc-2.95.1, and have installed Python-1.5.2 successfully. My problem is with extension modules, i.e. PIL and Numeric. If I import _imaging or multiarray, for example, I get a message like: ImportError: ld.so.1: python: fatal: relocation error: file ./multiarraymodule.so: symbol PySequence_Length: referenced symbol not found Basically, it appears that the shared object module (multiarray.so, for example) is calling functions from libpython, or somewhere else, but they don't get found. I am using gnu ld and the configuration scripts for the modules generate the link command "ld -G" for generating the .so files. Should I generate a libpython.so in /usr/local/lib? Or is there some other problem? thanks for your help. jlp From bsb at north.de Mon Oct 25 13:03:24 1999 From: bsb at north.de (Siggy Brentrup) Date: 25 Oct 1999 19:03:24 +0200 Subject: Python/Tkinter _and_ COM on win32 platform? Message-ID: <87aep7id9f.fsf@baal.winnegan.north.de> Hello, sorry to bother you with this one, at present I can't search the archives. I have a program written in Python 1.5.2 using sgmllib and the PmwScrolledText widget to most of it's strength which a friend wants to incorporate in her Delphi program on Win95. As expected, porting my program to the win32 platform reduced to ruling out some minor problems with mixed case filenames. Thanks to whoever built the py152 installer. My problem is, I have no clue on COM programming. As far as I understand, my Python program has to register as a COM server providing methods to be called from Delphi. In the standard libs I found no mention of COM while pythonwin doesn't support Tkinter. Maybe /F-bot can point me in the right direction ;-) I hope there is a way without writing an extension module, that might become a major problem without a C compiler for the win32 platform. Thanks Siggy -- Siggy Brentrup - bsb at north.de - http://www.north.de/~bsb/ From darcy at vex.net Fri Oct 8 08:48:11 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 8 Oct 1999 12:48:11 GMT Subject: PyGreSQL difficulties References: <37FDCD98.EF1D5917@seanet.com> Message-ID: <7tkp6b$1p72$1@hub.org> Jim Driese wrote: > I'm new to Python and am trying to get the PyGreSQL module to work. I > am running FreeBSD 3.3-STABLE and installed the Python-1.5.2 package and > PyGreSQL-2.4 port. When I ran basics.py interactively (import basics), > I received the following message: Just so you know, the whole demo area has not received as much attention as it should so don't be too surprised if there are some rough edges here and there. > cnx = basics.DB(...) > and received the following error message: > SyntaxError: invalid syntax > What am I supposed to enter for "..." and what do I need to do to get > the sample program to run? You need to replace the elipsis with whatever args you need to connect to a database. See the README for details on the connect() call which takes the same arguments as the DB class. The init function in DB just calls connect with the args given. For example, if you are opening a database on the local machine with the name matching your login name then you can just use the following. cnx = basics.DB() More commonly you would name the database here. cnx = basics.DB('mytest') and finally, here is a more complicated example. cnx = basics.DB('mytest', 'db.otherdomain.com', user = 'guest', passwd = 'abc') -- D'Arcy J.M. Cain | Democracy is three wolves http://www.druid.net/darcy/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From phil at geog.ubc.ca Sun Oct 10 10:51:47 1999 From: phil at geog.ubc.ca (Phil Austin) Date: 10 Oct 1999 07:51:47 -0700 Subject: Pythoning of C++ objects References: <10715.991010@amv.tsk.ru> Message-ID: Mikhail Astafiev writes: > Hi folks, > > There is a C++ data processing class library. I have to write Python > extension allowing to manipulate C++ objects and call their methods > from Python. I don't want to use CXX - I want to write something more > lightweight. > Take a look at Gordon McMillan's C++ classes: http://starship.python.net/crew/gmcm/scxx.html -- ------------------------------------------------------------ Phil Austin (paustin at eos.ubc.ca) Department of Earth and Ocean Sciences, Tel: (604) 822-2663 University of British Columbia, B.C. Fax: (604) 822-6150 From rob at hooft.net Wed Oct 6 02:43:59 1999 From: rob at hooft.net (Rob W. W. Hooft) Date: 06 Oct 1999 08:43:59 +0200 Subject: converting between PIL and NumPY References: <37F9FFA9.657BDDF6@udel.edu> Message-ID: >>>>> "CB" == Charles Boncelet writes: CB> Could someone send me some quick info on converting between a PIL CB> object and a NumPy array? Some time ago, I posted an example for visualization of 2D NumPy arrays (integer or floating point) using PIL on my starship page as "dis.py". http://starship.python.net/crew/hooft/ Regards, -- ===== rob at hooft.net http://www.xs4all.nl/~hooft/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From the_wrights at onaustralia.com.au Thu Oct 7 08:01:17 1999 From: the_wrights at onaustralia.com.au (the_wrights) Date: Thu, 7 Oct 1999 22:01:17 +1000 Subject: Nice comments about python at www.perl.com Message-ID: There are some nice comments made about python over at www.perl.com http://www.perl.com/pub/1999/09/trips/tripreport.html This is a report on the ORA Open Source conference Just goes to show how nice the perl guys really are. (And I find them so, in fact) No, I haven't cross posted to c.l.p.m.!!! Cheers chris From erno at iki.fi Sun Oct 31 19:19:00 1999 From: erno at iki.fi (Erno Kuusela) Date: 1 Nov 1999 00:19:00 GMT Subject: Destroying files References: <1270962155-6437791@hypernet.com> Message-ID: On Thu, 28 Oct 1999 21:38:09 -0400, Gordon McMillan wrote: >> Yes, I'm on Windows 95. No, deleting files does not remove them >> from your hard drive; They can be recovered by computer forensics >> experts or by nosey hacks. I'm putting my PC up for sale, and the >> thought is troubling. > >How about opening a file, writing '\000'*1024 (and flushing) >until it runs out of disk space, and then deleting it? A wizard >might be able to get filenames out of the FAT, but I don't think >there's be any data left. > writing zeros over the data does not make it unrecoverable. there are numerous companies that specialise in this kind of recovery. you can find lots of discussion about this with dejanews. see for example http://www.deja.com/=dnc/getdoc.xp?AN=375423857 or http://www.deja.com/=dnc/getdoc.xp?AN=457401725 . to make it short, the only sure way to prevent data recovery is to melt the disk and this is what people that are serious about the matter usually do... now, the python file objects seem to be missing a melt() method... perhaps this can be added for python 2.0? or perhaps a more suitable name would be self_destruct(), so it would not be tied to any single method. -- erno From claudius at catlover.com Sat Oct 30 22:54:59 1999 From: claudius at catlover.com (claudius at catlover.com) Date: Sun, 31 Oct 1999 02:54:59 GMT Subject: hasattr(obj, attr) overloading? Message-ID: <7cOS3.4888$Ec1.78104@news1.frmt1.sfba.home.com> Is there a way to overload the hasattr method (by default it calls __getattr__ and checks for an exception. However, my __getattr__ can be a heavy hit that I'd rather avoid for hasattr calls.) If not, perhaps a feature for the next minor revision? From dminor at actcom.co.il Thu Oct 28 11:12:51 1999 From: dminor at actcom.co.il (root) Date: Thu, 28 Oct 1999 17:12:51 +0200 Subject: linux install problem Message-ID: <381867F3.961D690D@actcom.co.il> I'm running Mandrake RH 6.1. I can't find the Modules/Setup file all the docs tell me to use to configure tkinter. (my pen-ultimite goal is to run grail) I rpm installed python 1.5.2 hoping this would solve things, no luck. What can I do, or where can I find installation docs that address this problem??? David Minor dminor at actcom.co.il From duncan at rcp.co.uk Tue Oct 5 12:18:04 1999 From: duncan at rcp.co.uk (Duncan Booth) Date: 5 Oct 1999 16:18:04 GMT Subject: Requiring arguments to be passed as keyword arguments References: Message-ID: <8E56B031Cduncanrcpcouk@news.rmplc.co.uk> mhagger at blizzard.harvard.edu (Michael Haggerty) wrote in : >Sometimes I would like to write functions with arguments that are >REQUIRED to be passed as keyword arguments rather than positional >arguments. For example, for the following function I might want the >second parameter to be passed as a keyword parameter: > > f(1, 2) # Exception > f(1, variation=2) # OK > This is a kludge, but you can avoid accidental positional arguments if you stick in a tuple argument: >>> def f(x, (donotuse,)=(None,), variation=57): ... print "x=%s variation=%s" % (x, variation) ... >>> f(1) x=1 variation=57 >>> f(1,2) Traceback (innermost last): File "", line 1, in ? File "", line 1, in f TypeError: unpack non-sequence >>> f(1, variation=2) x=1 variation=2 This doesn't stop malicious use of positional arguments but it will fix the case you were asking about. Wish list #1: A non-kludge way of doing this. Wish list #2: A way to specify a default argument that cannot be changed when called. From hauser at ifm.uni-kiel.de Thu Oct 21 04:52:11 1999 From: hauser at ifm.uni-kiel.de (Janko Hauser) Date: 21 Oct 1999 10:52:11 +0200 Subject: Linux / Numerical Python compilation problems References: Message-ID: <87vh81w0xw.fsf@ifm.uni-kiel.de> Gerald Gutierrez writes: You need to have the yorick package, do not know, if there is a rpm-package for this. Yorick can also be fetched from llnl site. It's normally easy to install from src as it only needs x11. The error with arrayobject.h is probably that the include directory looks for */include/python1.5/Numeric. Or copy arrayobject.h directly into the source directory of the Graphics package. HTH, __Janko > Hi all. > > I'm trying to compile Numerical Python from LLNL on my Linux-Mandrake > 6.1 / Intel machine. > > I can compile the Numeric module just fine, however when I try to > compile the Graphics module so I can use the plotting facilities, I > get compile errors about missing header files such as arrayobject.h, > hlevel.h and dispas.h. > > It turns out that some of these header files are from the Numeric > module (e.g. arrayobject.h). The Numeric module is already installed > properly but it seems the Graphics module makefile is not include the > actual "numeric" directory where the header files are. I've included > the step of the make process where the error occurs below. > > Other header files like hlevel.h don't exist anywhere on my computer. > > I know NumPy can be compiled on a Linux box; I've seen RPMs for > it. How do I solve these compile problems? > > > Thanks for any help anyone can give. > > Please forward replies to gutier at intergate.bc.ca. > > > > > gcc -fpic -I/usr/local/lib/yorick/1.4/h -g -O2 > -I/z/bin/../opt/python-1.5.2/include/python1.5 > -I/z/bin/../opt/python-1.5.2/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:76: hlevel.h: No such file or directory > ./Gist/Src/gistCmodule.c:78: dispas.h: No such file or directory > ./Gist/Src/gistCmodule.c:88: warning: `PyFPE_END_PROTECT' redefined > /z/bin/../opt/python-1.5.2/include/python1.5/pyfpe.h:169: warning: > this is the location of the previous definition > make: *** [gistCmodule.o] Error 1 > > > > > > > > > > > > > > > > -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From cgw at fnal.gov Thu Oct 7 11:57:54 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Thu, 7 Oct 1999 17:57:54 +0200 (MET DST) Subject: List vs. Tuple In-Reply-To: <37FCC0C4.DF34352F@cornell.edu> References: <37FCC0C4.DF34352F@cornell.edu> Message-ID: <14332.49922.193896.867738@gargle.gargle.HOWL> Matthew Hirsch writes: > Can someone explain to me why if there is only a string in a list/tuple > they behave differently when looped through. For example, > > >>> list=['abcd'] > >>> tuple=('abcd') Despite the name, "tuple" is not a tuple. It's a string. Parentheses are (unfortunately, IMO) overloaded, being both tuple-delimiters and the standard grouping operator, e.g. x=(1+3)*5 If you want to make a one-tuple, you need to use the following slightly strange-looking construction: tuple = ('abcd',) From cors at recercai.com Wed Oct 13 15:44:40 1999 From: cors at recercai.com (Carlos Ors) Date: Wed, 13 Oct 1999 21:44:40 +0200 Subject: Executing a jpython script in another process Message-ID: <38048d23.0@sahara.cablecat.com> I'm working with Jpython 1.1 beta 3 I'm interested in executing a jpython script in a new process so that a System.exit(0) didn't close the main aplication. I have a instance of PythonInterpreter named theInterp. I do: PythonInterpreter theInterp= new PythonInterpreter() theInterp.exec("") I want to call the exec method making a new process and that the main process get the results of the execution. From JamesL at Lugoj.Com Wed Oct 13 23:32:28 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 13 Oct 1999 20:32:28 -0700 Subject: Looping redux. was: do ... while loop References: <7u374b$8lm$1@netnews.upenn.edu> Message-ID: <38054ECC.C0505DA6@Lugoj.Com> Alexander Williams wrote: > Python is designed to minimize the syntactic sugar poured in the > gas-tank of your coding; "do ... while" truly is only a syntactic > abstraction for an initialized while loop [...] > Its not that > much more typing, the test is very clearly marked at the top of the > structure, and we have the benefit of a single, consistant means of > presenting the loop rather than thirteen varying ones. Every control structure is mere syntactical sugar for the elegantly simple "if goto

someList = ["one", "two", "three"] >

if not x in someList: >
    # DO YOUR STUFF >
else: >
    print "ERROR: %s is in list"%x >
  >
  >

mehta at mama.indstate.edu wrote: >

how can I specify not to match strings like >
 donot match "one" | "two" | "three" >

  (one|two|three) could match any string as one or two or three >
but I want them not to matched at that position. >

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

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

> > > --------------852473141D72DB77B0E853C6-- > > Sent via Deja.com http://www.deja.com/ Before you buy. From bwarsaw at cnri.reston.va.us Mon Oct 4 11:36:10 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Mon, 4 Oct 1999 11:36:10 -0400 (EDT) Subject: python mailing list References: <000801c02c30$c13e1ea0$62c21e26@oemcomputer> Message-ID: <14328.51562.199910.890961@anthem.cnri.reston.va.us> >>>>> "CC" == Carol Cameron writes: CC> Can i please be put on the mailing list? You can do it yourself! Please visit http://www.python.org/mailman/listinfo/python-list and follow the directions from there. -Barry From kelley at bioreason.com Thu Oct 28 18:47:31 1999 From: kelley at bioreason.com (Brian Kelley) Date: Thu, 28 Oct 1999 16:47:31 -0600 Subject: Python 1.5.2 list sorting bug References: <3818BF9F.8C6CCDEF@bioreason.com> <3818C0DD.D55CE53@bioreason.com> <3818CC4D.3B3658D7@appliedbiometrics.com> Message-ID: <3818D282.1C506BB8@bioreason.com> Christian Tismer wrote: > Brian Kelley wrote: > > > > actually a much quicker test is: > > > > Python 1.5.2 (#1, Oct 27 1999, 17:21:07) [C] on irix646 > > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > > >>> a = [3,4,5,1,2] > > >>> a.sort(lambda x,y: x>y) > > >>> a > > [3, 4, 5, 1, 2] > > >>> > > Please have a look into the documentation about sorting and > the cmp function. Actually, you need a three valued compare. > > Using > > >>> a.sort(lambda x,y: cmp(x,y)) > > should convince you :-) > I'm convinced. As I mentioned, I don't know where I picked up the idiom of: a.sort(lambda x,y: xx) but I can assure you that now it has become: a.sort(lambda x,y: cmp(y, x) ) and a.sort(lambda x,y: cmp(x,y) ) or better yet forming the appropriate tupes and using a normal sort. > > 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 -- Brian Kelley w 505 995-8188 Bioreason, Inc f 505 995-8186 309 Johnson Av Santa Fe, NM 87501 kelley at bioreason.com From Gaetan_Corneau at baan.com Fri Oct 29 11:15:48 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Fri, 29 Oct 1999 11:15:48 -0400 Subject: Produce .pyc without execution Message-ID: <816010E2456BD111A48700805FBBE2EEFDF739@ex-quebec-u1.baan.com> Hello, Is there a way to compile a module without executing it? Just check syntax and produce the .pyc file? Thanks, ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) BaaN Supply Chain Solutions E-mail: Gaetan_Corneau at baan.com Compuserve: Gaetan_Corneau at compuserve.com ICQ Number: 7395494 Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From skaller at maxtal.com.au Sun Oct 17 08:47:49 1999 From: skaller at maxtal.com.au (skaller) Date: Sun, 17 Oct 1999 22:47:49 +1000 Subject: Q: Python 2.0 preliminary features? References: <7tlk6p$4o5$1@nnrp1.deja.com> <3801486F.A7CDEF1D@maxtal.com.au> Message-ID: <3809C575.B8F953FF@maxtal.com.au> Neel Krishnaswami wrote: > > On Mon, 11 Oct 1999 12:16:15 +1000, skaller wrote: > > > >In the third stage, type inference will attempt to ascribe types to > >the variables, and use some fixed ad hoc speedups to improve > >interpreter speed even further. > > How do you plan to mix type inference and extension-type/Python-class > unification? Already done. Here is what happens: every object has a type. The type in Python is an object of type TypeType. This restriction does not apply in Viper. The type of an object can be ANY object. The second thing to know is: when 'ordinary' object.value lookup fails in Viper, lookup continues for a method in the type object of the object. For the standard Python types, including integers, the type object I'm using is a class. So you can write: (1).abs() right now in Viper, because the type of (1) is PyIntType, for which Types.IntType is a synonym, and PyIntType is a class object with a method 'abs'. That is, the integer type is a class IMPLEMENTED IN PYTHON. [The native function which computes the result is not, it has to be compiled into the interpreter.] The class PyIntType is defined, along with the other types, in a special file py_types.py. Please note that this is DIFFERENT to saying that all objects have class type. This is a BAD idea. I have implemented the exact opposite: in Viper, all objects have a type object, which can be any object. In particular, ONLY class instances have classes, but ALL objects have a type, including classes and including instances. The type of a class instance is PyInstanceType and is NOT the class of the instance. To put all this another way, I have extended the EXISTING python type system to add a new kind of lookup rule, and relaxed the restrictions on the Type object, I have NOT unified the type object with the Class. I have NOT changed the fact that integers are NOT instances of classes. What has this to do with type inference? Easy: the only types I have to deal with are the builtin ones like integers and class instances, there are no extension types in Viper. We don't need them, since the 'type' of all objects is just another object. The only way extension types are visible to the interpreter is if the type is a builtin kind, in which case it is necessary to modify the inference engine .. and the rest of the interpreter. For example, there is a File type in Viper. But the client never sees it, because it is wrapped TWICE with classes! The first wrapper maps the native file manipulation functions, and sees the File type. The second wrapper provides the Python compatible interface. > As I understand it, type inference in OO languages is generally only a > win if you can do enough to infer the actual runtime type of the > object. IOW, it's not enough to know that the object is an instance of > some subclass of the class Number, but that it's a direct instance of > the class Integer. Then you can avoid paying the cost of polymorphic > dispatch, and can take advantage of knowing the actual method called > to do additional optimizations (like inlining). Yes. In particular, the kinds of things that are worth optimising are things like: x = x + 1 where x is not aliased: this can be replaced by x += 1 and avoid an allocation. > But if Python's primitive types are made into real Python classes, > then any type can be potentially be subclassed, which makes inferring > the runtime type a much harder prospect. Indeed. Luckily, subtyping the basic python types is entirely useless, for every single python type except 'file'. That is because python types are in fact naturally algebraic NOT object oriented, again, with the exception of 'file', which is sensibly an object. [Another exception is, exceptions, but they're already class based] > AFAICT, you need to either add something like Java's "final" keyword, > do whole-program analysis (does eval defeat this?), or do dynamic > compilation like Self. Or are there some cool new tricks you can steal > for Viper from the OCaml compiler..? The basic optimisations are functional, that is, things like making string concatenations go faster in cases like: x = x + "hello" Here, the deduction starts with the literal "hello" which is known to be a string, and, since + accepts a string RHS only when the LHS is also a string or an int, and the int case is eliminated since the type of the LHS of the assignment is also the type of X, and both operators called + with string RHS return a string, then x must be a string. Now, if strings can be class instances, we must account for that case too, so there will need to be a run time test, to check if the x is a basic string, or some derived type. Luckily, because I do whole program analysis, i know all the classes, including those that have a + method (__add__). It may be difficult to decide if the x above is one of those type, rather than string. But somewhere, the programmer had to construct the x, and it is possible to trace it back to see what type it is. Sometimes, the result will be it could be one of several types: if t ==0: x = "a string" elif t == 1: x = ClientType("who knows") else: x = None but evern here, the set of possible type is enumerable. So .. you are right, if all types were classes and could be subclassed, then determining which method to call would be harder. However, with my current system, the extra lookup into the type object is done, and that type object is itself compiled, since it is written in Python. So the dispatch should proceed at reasonable speed, especially if name binding is already done. -- John Skaller, mailto:skaller at maxtal.com.au 1/10 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller downloads: http://www.triode.net.au/~skaller From a.eyre at optichrome.com Fri Oct 8 12:21:29 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 8 Oct 1999 17:21:29 +0100 Subject: Beginner's question : Embedding Python - problem with PyRun_SimpleString In-Reply-To: <7tl22s$kn7$1@news.nctech.fr> Message-ID: <000b01bf11a9$2d3386c0$3acbd9c2@peridot.optichrome.com> > #include > Py_Initialize(); > status = PyRun_SimpleString( myCmdLine); > I tried this with : myCmdLine = "a = 5" ; > and got a status equal to -1 !!! Looking at the source code, this means that an exception occurred and got printed to stderr. If you're running under Win32, this information will be lost, unless you redirect stderr to something else. -------------------------------------------- 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 mcfletch at vrtelecom.com Thu Oct 28 02:47:26 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Thu, 28 Oct 1999 02:47:26 -0400 Subject: from (some module) import * In-Reply-To: <38172D03.2CF4CAE5@cfdrc.com> Message-ID: http://www.python.org/doc/current/lib/built-in-funcs.html#built-in-funcs See __import__ at the top of the page. Is available in all "normal" situations. Hope that helps, (incidentally, for some reason my first email to you bounced, hope this gets through), Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Ed Sent: October 27, 1999 12:49 PM To: python-list at python.org Subject: from (some module) import * ... I want to prompt for a module name, then import it. How do I make the module name in the "from" or "import" operators a variable? I was trying ... From srenner at lycosmail.com Sat Oct 30 22:40:30 1999 From: srenner at lycosmail.com (srenner at lycosmail.com) Date: Sun, 31 Oct 1999 02:40:30 GMT Subject: ANN: Unspeakably obscure Just Intonation module, ratio.py References: Message-ID: <7vga6u$fop$1@nnrp1.deja.com> In article , > For people who are into just intonation -- or even know what > it is -- I have written a module to make dealing with JI ratios a > little easier, including methods to handle varous sorts of > katapyknosis as well as the creation of JI chords. There are also > some functions not part the Ratio class which make dealing with scales > and interval lists more fun. People are thirsting for just intonation. You might say that we are partched. Thank you. sr Sent via Deja.com http://www.deja.com/ Before you buy. From andy at robanal.demon.co.uk Sat Oct 2 13:35:29 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Sat, 02 Oct 1999 17:35:29 GMT Subject: Installation problem (or not...) References: Message-ID: <37fd3c4c.37380039@news.demon.co.uk> Mikael Olofsson wrote: >Hi, > >If these are stupid questions, could someone please answer them anyway. > >I have been using python at work for quite a while (under unix), but I >have never tried to install it - until yesterday. I decided to install >python on my Pentium II machine at home (Win95). I downloaded version >1.5.2 and related stuff from python.org, from the "Download Python for >Windows 95/98 and NT" page. So far so good. > >Later, when I installed it I got an error message complaining that some >DLL file assumed WinNT and not Win95. The same thing happened for the >win32all installation. This made me worried. As I have understood things, >the installation is supposed to work in all NT/95/98 environments. I >have not tried any tests yet, but I don't think I would trust my >installation under these circumstances - even if all tests went well. > >Q1: Should I be worried? >Q2: If so: What should I do? AFAIR it is ctld3d or one of its kin. Don't worry, the installer will work and it will not affect your Python installation, but the 3d-look progress bar just looks a bit screwy as it runs. This is beyond Mark Hammond's reasonable control - I suggest leaving it to WISE (who make the installer) and Microsoft to slug it out as to who broke what. Regards, Andy From bfkurd at CYBERDUDE.COM Thu Oct 28 03:23:57 1999 From: bfkurd at CYBERDUDE.COM (bfkurd at CYBERDUDE.COM) Date: 28 Oct 1999 07:23:57 GMT Subject: MAKE HUNDREDS JUST SURFING THE NET Message-ID: <7v8tmd$37j$5186@iceman.tac.net> MAKE HUNDREDS OF DOLLARS A MONTH JUST SURFING THE WEB. OR THOUSANDS BY REFFERING. JOIN AT : http://www.gotoworld.com/getpaid/register/default.asp?rid=1032128546 From pinard at iro.umontreal.ca Tue Oct 5 20:42:25 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 05 Oct 1999 20:42:25 -0400 Subject: 'ipfw' IOCTLS available as python module? In-Reply-To: Bill Anderson's message of "Tue, 05 Oct 1999 18:39:12 +0000" References: <19990930100423.D22550@quark.emich.edu> <19991004104110.C26463@quark.emich.edu> <37FA45D0.6BAB1FE9@boi.hp.com> Message-ID: Bill Anderson ?crit: > it is worth making the comment that ipchains is gone in 2.3.x, and > hence 2.4. Are you serious? If this is true, it is worth telling indeed, before we invest too much Python work in that direction. Could you tell me/us more? What is happening exactly? If you happen to know, _why_ is it happening? -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From prestonlanders at my-deja.com Fri Oct 8 10:37:54 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Fri, 08 Oct 1999 14:37:54 GMT Subject: Beginner asks question about Python on Linux References: <7tkge6$asd$1@nnrp1.deja.com> Message-ID: <7tkvk0$lg5$1@nnrp1.deja.com> Hello Stephen, you might try something like this: import commands import string status, output = commands.getstatusoutput("ps aux|grep someProcess") if status: print "Sorry, grep could not find anything." else: lines_list = string.split(output, "\n") pids_list = [] for line in lines_list: pids_list.append(string.split(line)[1]) Hope this helps, ---Preston In article <7tkge6$asd$1 at nnrp1.deja.com>, stephen.allison at cenes.co.uk wrote: > Hello all, > > I have a, probably fairly trivial, question about using Python on Linux > (and probably Unix too). I'm quite new to both, so apologies if it's a > really stupid question. > > I'm writing some scripts to do some general administation tasks, and > need to get the output of a shell command into Python easily. For > example I have a bit of code like this: > > os.system("ps aux|grep someProcess > pids.temp") > > I then proceed to open the pids.temp file, read the lines and then go > on to do stuff with the processes (readline, splitfields, look through > the list for the PIDs, execute further system commands (usually > 'kill')), and then delete the pids.temp file. What I want to know is > if there is a way of getting the output of the grep straight into > Python, so I won't have to use a temporary file. I have since learned > about killing all processes of a given name, so it's a bit academic, > but I was wondering if anyone could tell me if it's possible to do > this, using either Python cleverness or some shell commands I'm not > aware of. > > Thanks for any help, > > Steve > > -- > Steve Allison > Doesn't read deja news mail > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From robin at jessikat.demon.co.uk Tue Oct 5 07:06:40 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Tue, 5 Oct 1999 12:06:40 +0100 Subject: Three decades of Python! References: <011901bf0f15$1790f910$f29b12c2@secret.pythonware.com> Message-ID: <+pT+tEAAvd+3Ewhs@jessikat.demon.co.uk> In article <011901bf0f15$1790f910$f29b12c2 at secret.pythonware.com>, Fredrik Lundh writes >btw, I hope nobody has missed this: > >http://news.bbc.co.uk/hi/english/special_report/1999/10/99/monty_python/newsid_4 >63000/463024.stm > > > here in the UK we're about to undergo it :) -- Robin Becker From boncelet at udel.edu Tue Oct 5 09:39:53 1999 From: boncelet at udel.edu (Charles Boncelet) Date: Tue, 05 Oct 1999 13:39:53 +0000 Subject: converting between PIL and NumPY Message-ID: <37F9FFA9.657BDDF6@udel.edu> Could someone send me some quick info on converting between a PIL object and a NumPy array? (I seem to recall this being discussed in August, but I can't find it in deja.com. Are there any better places to look? I really hate deja.com.) I want to do some image filtering with my own routines. Has anyone written a wrapper routine that slides a moving window over an image and provides these values to a python list (or numpy array) for a user defined routine to process? If not, I may roll my own. Charlie Boncelet ---- Charles Boncelet (boncelet at udel.edu) From gerrit.holl at pobox.com Fri Oct 22 08:01:27 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 22 Oct 1999 14:01:27 +0200 Subject: Newbie question: files.. In-Reply-To: <7ulc06$pmk$1@nnrp1.deja.com> References: <000601bf12db$2759d640$072d153f@tim> <7ulc06$pmk$1@nnrp1.deja.com> Message-ID: <19991022140127.A6271@optiplex.palga.uucp> Wesley C. wrote: > > > The code I have is here: > > > > > > #!/usr/bin/python > > > > > > file = open('testfile.txt', 'r') > > > for line in file.readlines(): # read file > > > s = line[:-1] # get rid of newline > > > print s #print string > > > file.close() Not good, sometimes the last line doesn't end in a newline. regards, Gerrit Holl. From tim_one at email.msn.com Sun Oct 3 20:04:51 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 3 Oct 1999 20:04:51 -0400 Subject: When Good Regular Expressions Go Bad In-Reply-To: <14324.55883.614652.812873@dolphin.mojam.com> Message-ID: <000001bf0dfc$1553db00$bfa2143f@tim> [Skip Montanaro, continues to defend the indefensible ] > Yes, I should have given example re's (parental guidance suggested): > > First, the real thing: > > r"(?P\s*(?P\d+/\d[-,\d]*/\d+),?" > "(?P[^,]+)," > "(?P[^,]+)," > "(?P[A-Za-z\s]+)," > "(?P