From wware at world.std.com Sun Dec 26 08:24:35 1999 From: wware at world.std.com (Will Ware) Date: Sun, 26 Dec 1999 07:24:35 GMT Subject: midi stuff? References: Message-ID: I (wware at world.std.com) wrote: > Is there any Python code floating around for generating MIDI > files, starting from any sort of human-readable score? The following works on a RedHat 6.1 system. ################################################################## #!/usr/bin/env python import os, sys, string badNoteError = 'bad note error' class Midi: def __init__(self, outf=sys.stdout): self.quarterNoteTime = 256 self.outf = outf def dumpByte(self,b): self.outf.write(chr(b & 0xFF)) def dumpInt16(self,i): self.dumpByte(i >> 8) self.dumpByte(i) def dumpInt(self,i): self.dumpInt16(i >> 16) self.dumpInt16(i) def dumpVariable(self,v): for b in self.variable(v): self.dumpByte(b) def variable(self,i,toobig=0): if i < 0x80: if toobig: return [0x80 + i,] else: return [i,] else: lowSeven = i & 0x7f return (self.variable(i >> 7, 1) + self.variable(i & 0x7f, toobig)) class MidiFile(Midi): tracks = [ ] def register(self,track): self.tracks.append(track) return self.quarterNoteTime, self.outf def dump(self): # dump the header self.outf.write('MThd') self.dumpInt(6) # six bytes follow self.dumpInt16(1) self.dumpInt16(len(self.tracks)) self.dumpInt16(self.quarterNoteTime) for t in self.tracks: t.dump() self.outf.close() class Track(Midi): def __init__(self,channel,owner): self.data = [ ] self.channel = channel - 1 self.quarterNoteTime, self.outf = owner.register(self) self.currentNoteLength = 1. self.currentOctave = 60 self.pendingRest = 0. def dump(self): self.outf.write('MTrk') self.dumpInt(len(self.data)) for b in self.data: self.dumpByte(b) def event(self, time, bytes): self.data = self.data + self.variable(time) + bytes def note(self, pitch, duration): self.event(int(self.pendingRest * self.quarterNoteTime), [0x90 + self.channel, pitch, 127]) self.pendingRest = 0 self.event(int(duration * self.quarterNoteTime), [0x80 + self.channel, pitch, 127]) def parseNote(self, str): pitchOffset = 0 rest = 0 while str: c = str[0] str = str[1:] if c == '+': # octave up self.currentOctave = self.currentOctave + 12 elif c == '-': # octave down self.currentOctave = self.currentOctave - 12 elif c == '#': # sharp pitchOffset = pitchOffset + 1 elif c == '@': # flat pitchOffset = pitchOffset - 1 # numbers are translated to note lengths, measured # in multiples of a quarter note elif (c >= '0' and c <= '9') or c == '.': while (len(str) > 0 and (str[0] == '.' or (str[0] >= '0' and str[0] <= '9'))): c = c + str[0] str = str[1:] # this number is a note length in quarter notes self.currentNoteLength = eval(c) # here are note names (A-G), it would be nice if # the key got picked up automatically here elif c >= 'a' and c <= 'g': pitchOffset = pitchOffset + \ {'c': 0, 'd': 2, 'e': 4, 'f': 5, 'g': 7, 'a': 9, 'b': 11}[c] elif c >= 'A' and c <= 'G': pitchOffset = pitchOffset + \ {'C': 0, 'D': 2, 'E': 4, 'F': 5, 'G': 7, 'A': 9, 'B': 11}[c] # rests elif c == 'r' or c == 'R': rest = 1 else: raise badNoteError if rest: self.pendingRest = self.pendingRest + self.currentNoteLength else: self.note(self.currentOctave + pitchOffset, self.currentNoteLength) def parseVoice(self, str): for s in string.split(str): self.parseNote(s) mf = MidiFile(open('foo.mid', 'w')) t1 = Track(1, mf) t2 = Track(2, mf) # the first few notes of the Crab Canon t1.parseVoice('c2 e@ g a@ b-3 g+1 f#2 f e e at 3 d1 d@ c b- a.5 g c1+ f e at 2 d c') t2.parseVoice(''' c+ e@ g c+ b-.5 c+ d e@ f e@ d c d g- d+ f e@ d c b- a b c+ e@ d c b- ''') mf.dump() # playmidi loses last notes sometimes, xplaymidi doesn't, I dunno why os.system('xplaymidi foo.mid') ############################################################ -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From fdrake at acm.org Fri Dec 3 22:22:49 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 3 Dec 1999 16:22:49 -0500 (EST) Subject: indentation In-Reply-To: <19991203211232.A11045@stopcontact.palga.uucp> References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> <19991203211232.A11045@stopcontact.palga.uucp> Message-ID: <14408.13481.279705.753821@weyr.cnri.reston.va.us> Gerrit Holl writes: > As i said: people who start with Python as a first language like it. There are those of us who started with x86 assembly and BASIC who like it too! (And Pascal, and C, and C++, and... hey, how many places can one person start in, anyway? ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From darrell at dorb.com Thu Dec 30 20:26:48 1999 From: darrell at dorb.com (Darrell) Date: Thu, 30 Dec 1999 14:26:48 -0500 Subject: random number generation: the newbie asks for advice References: <6D8A17398E28D3119F860090274DD7DB4B3D91@pces.cadlab.it> <005001bf529c$75a84100$c02b2bc1@martelli> Message-ID: <003101bf52fb$d14e6cf0$0100a8c0@rochester.rr.com> > > Alex Martelli wrote: > > >Is there a decent, Python-interfaced, C-written, stand-alone random > > >number generator, with persistable/de-persistable state? Or am I > [snip] > > http://www.math.keio.ac.jp/~matumoto/emt.html If your still interested I wrapped this up in a Python extension. Have it built for Windows. Don't want to kill more time here unless someone wants it. --Darrell From mhammond at skippinet.com.au Wed Dec 22 01:21:15 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 22 Dec 1999 00:21:15 GMT Subject: Python and ADSI References: Message-ID: <%PU74.7445$NV6.31305@news-server.bigpond.net.au> "Stephen Milton" wrote in message news:s5vh2ahnrg382 at corp.supernews.com... > Does anyone have any sample code for working with the makepy generated > libraries for ADSI. Specifically I am trying to use the IIS objects to > manage web sites, add, delete, etc. John Nielsen has kindly written some documentation on ADSI and exchange which I have attached below. These docs will be included in the next version of win32all. Also, version 128 of win32all will have a win32com.client.GetObject() - similar to VB's function of the same name. This will make some ADSI stuff easier. Mark. -- ADSI, Exchange, and Python Python's adsi access works really well with Exchange (late or early binding since you can read microsoft's type library). To get started, you will need to download adsi from microsoft: http://www.microsoft.com/windows/server/Technical/directory/adsilinks. asp. Microsoft has documentation for using languages other than python in the sdk. Comments Before doing anything else you need to go through the next two steps: Task Description Create the Global Providers object adsiNameSpaces = win32com.client.Dispatch('ADsNameSpaces') Now get the LDAP Provider object ldapNameSpace = adsiNameSpaces.getobject("","LDAP:") Now you have to decide how you want to access the exchange server. I have chosen to authenticate in which case you need to use opendsobject The login and domain logon_ex='cn=wilma, dc=bedrock' password password='dino' now login myDSObject = ldapNameSpace.OpenDSObject(ex_path,logon_ex,password,0) So what is this ex_path in the login? It is the resource you are trying to access, for example: a specific user ex_path="LDAP://server/cn=fredflintsone,cn=Recipients,ou=rubble,o=bedr o ck" a mailing list ex_path="LDAP://server/cn=bedrock,cn=Recipients,ou=rubble,o=bedrock" all of Recipients ex_path="LDAP://server/cn=Recipients,ou=rubble,o=bedrock" Example Accessing and Modifying a user: ex_path="LDAP://server/cn=fredflint,cn=Recipients,ou=rubble,o=bedrock" myDSObject = ldapNameSpace.OpenDSObjec(ex_path,logon_ex,password,0) myDSObject.Getinfo() # To access a user's data try: attribute = myDSObject.Get('Extension-Attribute-1') print attribute # To modify a user try: myDSObject.Put('Extension-Attribute-1','barney was here') myDSObject.Setinfo() Comments Note -- To make any changes permanent setinfo is required. Example Adding new account to exchange # Adding a new account to exchange is simple except for one thing. # You need to associate an NT account with an exchange account. # To do so at this point requires some c++ to produce some hex SID # and trustee information that adsi can use. # At this point assume we have C++ magic # # Note we are accessing Recipients directly now ex_path="LDAP://server/cn=Recipients,ou=rubble,o=bedrock" logon_ex='cn=wilma,dc=bedrock' password='dino' myDSObject = ldapNameSpace.OpenDSObjec(ex_path,logon_ex,password,0) newobj = myDSObject.create("OrganizationalPerson", "cn=betty") newobj.put('MailPreferenceOption', 0) # etc . . . add whatever else you want. There are a few required fields. # Now the part to get exchange associated with NT # The Magic is here import win32pipe assoc_nt=win32pipe.popen('getsid bedrock\\fredflint') nt_security=win32pipe.popen('gettrustee bedrock\\fredflint') newobj.put('NT-Security-Descriptor',assoc_nt) newobj.put('NT-Security-Descriptor',nt_security) newobj.SetInfo Deleting an account from exchange #Here we connect to Recipients and then #delete a user #This is an example with more generic code: #data is a dictionary that contains info #that may be dynamic like the domain, #admin login, or exchange server #notice I am using a try/except clause here #to catch any exceptions try: #ADSI here # Create the Global Providers object logon_ex='cn='+data['NT_admin']+', dc='+data['NT_domain']+',cn=admin' ex_list_path="LDAP://"+data['EX_site_srv']+"/cn=Recipients,ou="\ +data['ou']+",o="+data['o'] adsi = win32com.client.Dispatch('ADsNameSpaces') # # Now get the LDAP Provider object ldap = adsi.getobject("","LDAP:") dsobj = ldap.OpenDSObject(ex_list_path,logon_ex,data['NT_password'],0); dsobj.Getinfo() dsobj.Delete("OrganizationalPerson", "cn="+login) dsobj.Setinfo() except: print 'Error deleting '+login, sys.exc_type , sys.exc_value Adding to a distribution list # I've added code here to make it a more generic example # I used putex instead of put because it has more options # The '3' value means append. The SDK has specific info on it ex_list_path="LDAP://"+server+"/cn="+list+",cn=Recipients,ou="+ou+",o= "+o dsobj = ldap.OpenDSObject(ex_list_path,logon_ex,password,0); dsobj.Getinfo() list_member='cn='+user+',cn=Recipients,ou='+ou+',o='+o append_list=[list_member] dsobj.putEx(3,'Member',append_list); dsobj.SetInfo() From ionel at psy.uva.nl Sat Dec 4 17:07:23 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Sat, 4 Dec 1999 17:07:23 +0100 Subject: indentation References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> <19991203211232.A11045@stopcontact.palga.uucp> Message-ID: <82beae$rn7@mail.psy.uva.nl> Gerrit Holl wrote in message news:19991203211232.A11045 at stopcontact.palga.uucp... | | no self... Why do I have to type it, if it's not possible to not type it? | When you do not type it, the interpreter should figure out from the context of the call to which object the method applies. In the most usual case [e.g. obj.method()], finding out the object is a snap. However, for complex class hierarchies, things get messy and there would be a lot of work to get the answer. Moreover, making possible a positive answer would impose heavily on the flexibility of the language. However, it's not just about avoiding (un-necessary) complexity. It also offers you more freedom. When object references are passed explicitly, it is easy to design classes whith methods that can be used not just on the instances of the class but on other, unrelated objects as well. Conclusion: it's worth writing 'self', because it gives you more control. ionel From mryan at netaxs.com Mon Dec 20 16:04:34 1999 From: mryan at netaxs.com (Michael W. Ryan) Date: 20 Dec 1999 15:04:34 GMT Subject: shelve References: Message-ID: On Mon, 20 Dec 1999 15:11:34 +0100, Anders M Eriksson wrote: >How do you print out (on screen) all the 'records' in a shelve? The key thing to remember (no pun intended, honest) is that a shelve behaves just like a dictionary. import shelve s = shelve.open('myshelve') recs = s.keys() for r in recs: print s[r] s.close() -- Michael W. Ryan, MCP, MCT | OTAKON 2000 mryan at netaxs.com | Convention of Otaku Generation http://www.netaxs.com/~mryan/ | http://www.otakon.com/ PGP fingerprint: 7B E5 75 7F 24 EE 19 35 A5 DF C3 45 27 B5 DB DF PGP public key available by fingering mryan at unix.netaxs.com (use -l opt) From digitome at iol.ie Mon Dec 13 05:26:51 1999 From: digitome at iol.ie (Sean Mc Grath) Date: Mon, 13 Dec 1999 04:26:51 GMT Subject: Announce: Pyxie - an Open Source XML Processing Library for Python Message-ID: <3854711d.4263700@news.iol.ie> Pyxie is an Open Source XML Processing Library for Python that lives at http://www.pyxie.org. I hope it is of use to some people. The book that hatched the Pyxie library is now in production at Prentice Hall. "XML Processing with Python" should hit the shelves around February, 2000. regards, Sean McGrath From bernhard at alpha1.csd.uwm.edu Mon Dec 13 18:53:02 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 13 Dec 1999 17:53:02 GMT Subject: win32com: subclass a com object? References: <830pi6$n4k$1@nnrp1.deja.com> <831bvt$3f0$1@nnrp1.deja.com> Message-ID: On Sun, 12 Dec 1999 23:43:58 GMT, tiddlerdeja at my-deja.com wrote: >In article , > bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) wrote: >> On Sun, 12 Dec 1999 18:29:31 GMT, tiddlerdeja at my-deja.com > wrote: > >> >I'd like to know how to subclass or derive from a existing COM object. >> Hmm. I haven't done this, but you certainly can derive from the >> class, which wraps the COM object and intercept the method. >I know I'm being pretty lame, but could you give me an example? Even for >say MS Word? As Mark pointed out the other way and I am quite busy right now, please take my appologies for not being more specific. >I know about python inheritance (I should have made this clear in the >original message). >Perhaps my lack of understanding is the COM/python integration. With COM >you use the Dispatch method to create an instance. If you create a >python subclass, e.g.: > Something along these lines: >class myMSWord(MSWord): def __init__... self.realcomobject= Dispatch("...) def __del__... self.realcomobject.Quit() def __getattr__(self, name)... -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From grant at nowhere. Tue Dec 7 22:49:54 1999 From: grant at nowhere. (Grant Edwards) Date: Tue, 07 Dec 1999 21:49:54 GMT Subject: Widget set for curses? Message-ID: Are there any python widget sets that use curses (or slang)? Simple stuff like radio buttons, entry fields, buttons... I was hoping for something like the newt or cdk libraries. Given my choice, I'd use Pmw and X11, but that may not be an option. -- Grant Edwards grante Yow! I'm a fuschia bowling at ball somewhere in Brittany visi.com From amcguire at coastalnet.com Thu Dec 16 21:56:08 1999 From: amcguire at coastalnet.com (Andrew N. McGuire) Date: Thu, 16 Dec 1999 14:56:08 -0600 Subject: Newbie Getopts Question Message-ID: <385951E7.4394EDEC@coastalnet.com> Hey all, I picked up my first python book 5 days ago, so dont laugh at me too hard. I have looked in man page, Learning Python by O &A, and python.org, as well as here, and found nothing __substantial__ on the use of getopts. Here is a code snipet of a program I have written... The programs works fine, and I really like the language, but this seems like a somewhat ineffecient way of handling options. Well, I am probably just ignorant here, so if any of you can help me clean up the mess below, I will be very grateful.. Looking specifically for getopts suggestions, but all suggestions are wanted and welcomed. Thanxx all. Andrew PS. Once again this is my first program, so dont laugh too hard. ;^) #################################################################################### #!/usr/local/bin/python import sys, string, getopt CF = 0 # Define a usage summary function. def usage(): print """ Usage: dbformat -f FS -n NF -i INFILE -o OUTFILE [ -c CF ] Where: FS = Field separator / delimiter, must be single charachter NF = Number of fields to insert \\n after INFILE = Input file name OUTFILE = Output file name CF = Number of fields to cut from beginning of line """ sys.exit(1) # Build an argument/option list. arglist = sys.argv[1:] # Check for extra options or arguments. try: optlist, arglist = getopt.getopt(arglist, 'f:n:i:o:c:') except getopt.error: print 'Unrecognized argument or option!' usage() # Generate a list of all options passed to the program. Arguments # are left out. list = [] for opt in optlist: list.append(opt[0]) # Bounce that list against a list of mandatory options. for opt in ['-f', '-n', '-i', '-o']: if opt not in list: print '%s argument is mandatory!' % opt usage() for opt in optlist: if opt[0] == '-f': FS = opt[1] if (len(FS) > 1): print 'The FS specified must be a single character.' usage() elif opt[0] == '-n': try: NF = string.atoi(opt[1]) except ValueError: usage() if NF <= 0: usage() elif opt[0] == '-i': try: INFILE = open(opt[1], 'r') except IOError: print 'Sorry, cannot open output file: %s' % opt[1] usage() elif opt[0] == '-c': CF = string.atoi(opt[1]) for line in INFILE.readlines(): line = string.split(line, FS)[CF:] COUNT = 0 for word in line: COUNT = COUNT + 1 if word == '\n': OUTFILE.write(word + '\n') else: if COUNT % NF == 0: OUTFILE.write(word + '\n') else: OUTFILE.write(word + FS) INFILE.close() OUTFILE.close() From grant at nowhere. Tue Dec 28 23:17:00 1999 From: grant at nowhere. (Grant Edwards) Date: Tue, 28 Dec 1999 22:17:00 GMT Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> <87ogbcuym5.fsf@den.home.net> <87aemwuowv.fsf@den.home.net> Message-ID: In article <87aemwuowv.fsf at den.home.net>, Frank Sergeant wrote: >mlh at vier.idi.ntnu.no (Magnus L. Hetland) writes: > >> > abbreviation for the noun 'define'. >> >> What is a define? (I assume that it is a word of your own construction?) > >I'm sorry; I screwed it up; the joke is ruined! > >I meant to say 'def' is an abbreviation for the noun 'definition'. > > -- Frank Uh, is that the noun "frank", the verb "frank", or the adjective "frank"? -- Grant Edwards grante Yow! ... I want to perform at cranial activities with visi.com Tuesday Weld!! From newshoes at mail.com Mon Dec 20 22:29:15 1999 From: newshoes at mail.com (NewShoes) Date: 20 Dec 1999 21:29:15 GMT Subject: compiling Message-ID: <83m73b$fj4$1@la-mail4.digilink.net> i thought i read somewhere on the python webpage that python code can be easily compiled into a platform specific executable. i've been looking for a tool to do this, and would also love to find something that could make me a .LIB or .OBJ file to link with my C/C++ code. this would be for win32,x86 thanks... btw, so for python looks great and i'm wondering where to look for some successful python projects out there that have happened (aside from all the regulars you see at python.org) From greybria at direct.ca Sun Dec 26 17:13:39 1999 From: greybria at direct.ca (Colleen & Brian Smith) Date: Sun, 26 Dec 1999 08:13:39 -0800 Subject: Newbie Tkinter Problem References: <87puvut4oz.fsf@baal.winnegan.de> Message-ID: Thanks Siggy. I guess I wasn't clear. The dialog executes, the image loads and then the "QUIT" button does not work. Something in the way I'm calling the dialog allows it to retain control of the event-loop even after the dialog is closed. > Your code works as expected for me. The openfile dialog is modal, > the QUIT button is not expected to work as long as the dialog is open. > > Siggy > > -- > Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ > ****** ceterum censeo javascriptum esse restrictam ******* > From tismer at appliedbiometrics.com Sun Dec 12 13:49:00 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sun, 12 Dec 1999 13:49:00 +0100 Subject: calling Python from C: I can't get this part. References: <82res6$896$1@nnrp1.deja.com> Message-ID: <385399BB.2BC1D709@appliedbiometrics.com> Very Frustrated wrote: ... > typedef struct { > /* much stuff and */ > FN_Ptr EV_fun; /* a pointer to the function to be called */ > /* more stuff */ > } *GA_Info_Ptr > > Before the GA can be run, the EV_fun pointer has to be set by a call to a > configuration function: > > GA_Info_Ptr GA_config((*EV_fun)()) { > GA_Info_Ptr ga_info; > ga_info = CF_alloc(); /* this initializes a GA_Info_Ptr structure */ > > /* the function pointer in the structure is then set to that given*/ > /* in the call to GA_config() */ > > ga_info->EV_fun = EV_fun; > return ga_info; > } > > You would then call it like this in main() somewhere: > > /* define your evaluation function */ > > int obj_fun(Chrom_Ptr chrom) { > /* do some stuff with chrom */ > return; > } > > /* then call the configuration routine */ > GA_config(obj_fun); > > Now, all I want to do is, instead of pointing to a C function that has to > be compiled and included in the library, I want to have ga_info->EV_fun > point to a Python function and have the Python function receive the > (Chrom_Ptr chrom) argument. You still have to provide a C function, but which just calls a Python function. The fastest way is probably to provide a PyObject pointer in your C module and export a function to set this variable from Python. In your module, you call it with PyEval_CallObject, for instance. Untested code follows: PyObject * myfunc = NULL; PyObject * SetPyFunction (self, args) PyObject * self, *args { PyObject * func = NULL; if (!PyArg_ParseTuple("O", &func)) return NULL; if (!PyCallable_Check(func)) { PyErr_SetString(PyExc_TypeError, "argument is not a callable object"); return NULL; } Py_INCREF(func); myfunc = func; } You should export this function in your module's method table. Now, just ignoring the structure of the Chrom_Ptr, your calling stub looks something like this: int obj_fun(Chrom_Ptr chrom) { PyObject * ret, *args; /* do some stuff with chrom */ if (!myfunc) return -1; /* or whatever the error code is */ /* analyse your Chrom_Ptr and build an argument tuple for the Python function. This can be more or less difficult. Then call the function: */ ret = PyEval_CallObject(myfunc, args); /* do some error handling here, evaluate ret, don't forget to DECREF it, and so on... */ return 0; } Now, what about the Chrom_Ptr thing? It depends on what is in it. If it has a simple structure, maybe just a couple of floats or ints with fixed size, the easiest would be to extract the values, build PyObjects for them, stuff them into the args tuple, and done. If that structure is much more complicated, you will need to build a wrapper object for Python, which gives direct access to the object via getattr and setattr methods. Maybe this has been done for you already by SWIG? Anyway good luck - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From skaller at maxtal.com.au Thu Dec 16 19:25:34 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 17 Dec 1999 05:25:34 +1100 Subject: Python complaints References: <3858C226.949FC9C6@udel.edu> <3858FEA3.E593F38C@callware.com> Message-ID: <38592E9E.9F800F5@maxtal.com.au> Ivan Van Laningham wrote: > > However, sin(complex) is a perfectly good mathematical > > operation. It should work. > > > > Use > import cmath > > and > s=cmath.sin(c) Or use Viper, which understands complex numbers. -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From thantos at chancel.org Wed Dec 22 23:54:30 1999 From: thantos at chancel.org (Alexander Williams) Date: Wed, 22 Dec 1999 22:54:30 GMT Subject: List comprehensions References: <38592275.BBA2B61A@maxtal.com.au> <385E045D.9EC36473@compaq.com> Message-ID: On 22 Dec 1999 12:43:33 GMT, Albert Hofkamp wrote: >This is even shorter than the map() call. >Sorry for asking, but is it safe to assume that > > for x,y in zip(xs,ys): > print x,y > >works as expected (and in list comprehensions as well then) ? >(I am still a terribly newbie at Python. > It is a fascinating language, you learn new constructs every day !! >) Well, it /would/ if Python had zip(). :) Instead, it has map(None, lst1, lst2) which does the same thing. >My basic problem with fold was that is is too much hassle, but that is >not the fault of fold, but of our language, because it doesn't allow >writing expressions as a name-less function. Right; once you have lambdas, there is a significant bonus in things like map(), filter(), reduce(),and fold(). Of course, its nearly trivial to create named functions in Python and often The Right Thing to make the temporary tools you use in such constructs names, especially if you find yourself using them more than once or twice. >Sure, just implement lazy evaluation :-) Yeah, like that'll happen in Python. Much as I love Python, I don't expect such things to become part of the language, ever. Even though parsing streams as lazy lists is incredibly cool. :) >Tricks like you explain with zip() are not part of their definition. >I have read the Python tutorial, and saw these two functions, and >assumed that I understood what they meant. Apparently, I missed an >extension (wrt Bird&Wadler) that allows zip()-like functionality. Actually, you only missed a bit of the definition, to wit, what the map/filter does when None is given as the function to use on the lists. Map creates tuples of the elements in parallel, filter returns a list of those elements which evaluate to True. Special cases, but handy because they exist. No extensions at all. -- Alexander Williams (thantos at gw.total-web.net) | In the End, "Join the secret struggle for the soul of the world." | Oblivion Nobilis, a new Kind of RPG | Always http://www.chancel.org | Wins From mlh at vier.idi.ntnu.no Tue Dec 21 20:55:55 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 21 Dec 1999 20:55:55 +0100 Subject: Arg! (Makefile.pre.in) Message-ID: I am trying to compile a simple extension module (at the moment, only the spammodule example of the "Extending and Embedding..." doc.) but nothing seems to work... I tried to do everything as described, and got the error message "bad word", seemingly related to Setup.in. So I tried to fiddle with that, and when it stopped complaining, and I tried to do a make, I got the message "nothing to be done for default". I tried "make spammodule", "make spam" and several others. I tried the version of the first make where I specified the install-dir of my Python. No effect. Is there a more foolproof way of doing this? Is there some way I can find out what is going on? (And - alas - I haven't been able to compile SWIG properly yet, either. . Running solaris, by the way.) -- Magnus Lie Hetland From mlh at vier.idi.ntnu.no Mon Dec 27 20:09:41 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 27 Dec 1999 20:09:41 +0100 Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> <87ogbcuym5.fsf@den.home.net> Message-ID: Frank Sergeant writes: > Paul Prescod writes: > > > Kidding aside, "class" is a noun and "def" is an abbreviation for a > > verb. > > I think you have that backwards. Clearly, 'class' is a verb, as in > "I would class that as ridiculous". Just as clearly, 'def' is an > abbreviation for the noun 'define'. What is a define? (I assume that it is a word of your own construction?) > > However, for "parallel construction", you might consider them both > nouns. > > > -- Frank -- Magnus Lie Hetland From greg.ewing at compaq.com Thu Dec 2 13:58:42 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 03 Dec 1999 01:58:42 +1300 Subject: Python Type-Inference based LINT.. (pylint.py) References: <19991121180043.B3184@teapot.egroups.net> <81e2r7$j14$1@newshost.accu.uu.nl> <383BC3D2.98BCD1FF@compaq.com> <81ktpm$33g$1@newshost.accu.uu.nl> <3843D365.8B530226@maxtal.com.au> Message-ID: <38466D02.BAC4A1F6@compaq.com> skaller wrote: > > It isn't clear what syntax to use to specify > an annotation def frobnicate(x as int, y as [string], z as {(int,int):SomeClass}) as SomeOtherClass: ... Greg From kopecjc at worldnet.att.net Wed Dec 22 06:21:15 1999 From: kopecjc at worldnet.att.net (kopecjc) Date: Wed, 22 Dec 1999 00:21:15 -0500 Subject: SystemError in Learning Python Example References: <385F1132.3DD500EB@worldnet.att.net> <001301bf4ba1$bba0d200$f29b12c2@secret.pythonware.com> Message-ID: <38605FCB.7B53BD8D@worldnet.att.net> You were right -- thanks alot! I had pickled with FeedbackData in a script which, though it was named "feedback.py", was interpreted as the "__main__" module, and attempted to unpickle from a program that imported the "feedback" module -- thus the same file was viewed as having different module name depending on its context. (Note that the file was using the "if __name__ = __main__" trick to allow it to be both used as a main module and to be imported.) I have revised the pickling script to split off class FeedbackData into a "feedback" module and no longer get the SystemError (I subsequently get a "KeyError: #" message, but I do not think that it is necessarily a result of my original problem). I guess what happens is that pickling serializes the class name, as well as the module name, and that unpickling can decode the class/module pair only if the same class, in a module with the same name, is available. It should be noted that "Learning Python" actually addresses this issue in a sidebar on page 285 -- I had skipped over this section because it was an example of interfacing with COM and I am running Linux. Fredrik Lundh wrote: > > kopecjc wrote: > > I am pretty sure that all the required files on the right > > paths. Does anyone know what could be causing the "SystemError" > > message? I would have thought that FeedbackData is from module > > feedback, not __main__. Does anyone have any idea why the pickle module > > would have expected it to be from __main__? > > probably because you created the pickle by running > the program as: > > $ python feedback.py > > this executes the code in feedback.py in a module > called "__main__". if you read the pickle from another > script, it's quite likely are that you don't have the same > class in that script... > > to make pickle work properly with classes, put the class > definitions in a separate module, and import it into your > main script. > > From svoynow at yahoo.com Sun Dec 12 08:38:29 1999 From: svoynow at yahoo.com (Sasha Voynow) Date: Sat, 11 Dec 1999 23:38:29 -0800 Subject: COM and Python threads References: <054f0654.99279019@usw-ex0102-009.remarq.com> <9bF44.5184$Cl3.30257@news-server.bigpond.net.au> Message-ID: <_6I44.796$k95.86588@typhoon-sf.snfc21.pbi.net> > > So call pythoncom.CoInitialize() :-) Yep. Shame on me. I found this in a Deja search that I should have run before posting. Eagerly awaiting the book, BTW. Thanks From kuncej at mail.conservation.state.mo.us Tue Dec 28 00:48:52 1999 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Mon, 27 Dec 1999 17:48:52 -0600 Subject: Python, Com, and Snappy Video Capture Message-ID: Has anyone successfully used python/com to talk to the "Snappy" video capture device? makepy works ok for me, and mySnappy = win32com.client.Dispatch('SNAPPY.SnappyCtrl.1') seems to work OK. But if I try to access any properties or functions of mySnappy, I get something like: com_error: (-2147418113, 'Unexpected failure', None, None) Any ideas? Thanks. --Jeff From nick at src.uchicago.edu Wed Dec 22 19:37:58 1999 From: nick at src.uchicago.edu (Nick Collier) Date: Wed, 22 Dec 1999 12:37:58 -0600 Subject: file time to dos time References: <1266242622-25873811@hypernet.com> Message-ID: <38611A86.B21615FF@src.uchicago.edu> I figured this out. The problem was that dos time begins at 01/01/1980. I found comparable code in the Java java.util.zip.ZipEntry class and used that as a model. For anyone watching at home, the code is as follows: ttuple = time.localtime(os.path.getmtime(path)) year = ttuple[0] if (year < 1980): entry.time = (1 << 21) | (1 << 16) else: year = year - 1980 entry.time = (year << 25 | ttuple[1] << 21 | ttuple[2] << 16 | ttuple[3] << 11 | ttuple[4] << 5 | ttuple[5] >> 1) where entry.time is in dos time format. By the way, I needed to know the dos time as this is the appropriate format when writing a zip archive. Nick Gordon McMillan wrote: > > Nick Collier writes: > > > > I'm trying to convert the results of os.path.getmtime(path) - > > last modification time in seconds since the epoch - to the dos > > time format which I think is a 36 bit number with bit fields for > > the year, month, day, hour, seconds. I'm coming close with some > > guessed at bitwise arthimetic, but can't get the year correct. > > Any suggestions? > > Since what you're doing is platform specific, why not use > DosDateTimeToTime from the Win32 extensions? > > MSVC Help text says (hope the paste comes out looking OK): > wFatDate > Specifies the MS-DOS date. The date is a packed 16-bit value > with the following format: > {PRIVATE}Bits  > Contents  >  > 0-4  > Day of the month (1-31)  >  > 5-8  > Month (1 = January, 2 = February, and so on)  >  > 9-15  > Year offset from 1980 (add 1980 to get actual year)  >  > wFatTime > Specifies the MS-DOS time. The time is a packed 16-bit value with > the following format: > {PRIVATE}Bits  > Contents  >  > 0-4  > Second divided by 2  >  > 5-10  > Minute (0-59)  >  > 11-15  > Hour (0-23 on a 24-hour clock)  >  > > - Gordon -- Nick Collier nick at src.uchicago.edu Social Science Research Computing University of Chicago Chicago, IL 60637 From randy_shaffer at my-deja.com Fri Dec 3 18:13:56 1999 From: randy_shaffer at my-deja.com (randy_shaffer at my-deja.com) Date: Fri, 03 Dec 1999 17:13:56 GMT Subject: newbie: package and import problems Message-ID: <828toe$dog$1@nnrp1.deja.com> Hello. I'm experiencing an ImportError that I do not understand. I'm hoping someone can point out what I'm missing - thanks in advance. I have a package directory structure that looks like this: TestHarness/ __init__.py THDatabase/ __init__.py THUser.py THUniverse.py In THUser.py file, I have various class and function definitions including a top level test() function that excersizes all the code in the file. From the interpreter command line, I can type: >>> from TestHarness.THDatabase.THUser import * >>> test() Everything works just fine here. There is a problem when just executing the file stand-alone. The two lines I have in the file that I understand will enable this are the first: #!/usr/local/bin/python and the last: if __name__ == '__main__': test() The top few lines in the file look like this: import TestHarness import cPickle import os import string from TestHarness.THDatabase.THUniverse import KnownUniverse This last line causes the exception: ImportError: No module named THDatabase.THUniverse Why doesn't python see this file? The top level package name is known to sys.path. I can make this go away by including the lines: from TestHarness import * from THDatabase import * from THUniverse import * But then, in a statement buried in the THUniverse.py file I get an AttributeError for the variable TestHarness.RootDir. This is given a value in __init__.py in the top level package, TestHarness/. What am I doing wrong? Randy Sent via Deja.com http://www.deja.com/ Before you buy. From ajmayo at my-deja.com Tue Dec 7 14:21:39 1999 From: ajmayo at my-deja.com (ajmayo at my-deja.com) Date: Tue, 07 Dec 1999 13:21:39 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <82g4bl$42g$1@nnrp1.deja.com> Message-ID: <82j1l0$6vn$1@nnrp1.deja.com> In article , wtanksle at hawking.armored.net (William Tanksley) wrote: > On Mon, 06 Dec 1999 10:49:25 GMT, ajmayo at my-deja.com wrote: > > ajmayo at my-deja.com wrote: > [snip] > >In fact, I don't necessarily *want* to make that > >client-side code easy to read - code obfuscation is actually a feature > >when you're trying to protect your intellectual property from the > >browser's View Source feature. > > I don't buy this. You're not getting enough value from this trivial bit > of obfusication, and you're losing a LOT. > er, I meant obfuscating the *client-side* code, not the server-side code. But let's not get too excited about that. IE5, for instance, supports client-side code encryption which is probably a better idea than relying on obfuscation. I just meant really that there didn't seem to be any way in Python of abbreviating the code so that (in pseudocode) begin if something then begin more code with more nested blocks... end end if end could be output as a 'one liner' when producing dynamic client-side code from the server. It looks to me like you have to (a) include the line separators (b) use n spaces at the start of each block at level n. This is just plain wasteful of communication line bandwidth, as well as being a bit of a pain when you are writing the code. [snip] > >Secondly, I am afraid I gasped when I read that variables don't require > >declaration. This is a useful feature for tiny 'throw-away' programs > >but please, please tell me there's the equivalent of Visual Basic's > >Option Explicit or perl's Use Strict. > > You're telling us that you use obfusication but don't like the idea of > variables not requiring declaration? > > Anyhow, Perl's use strict mode has essentially the same effect as Python's > normal operation (modulo a few minor behaviors). > As I said, I don't want to obfuscate the *server-side* code. No, I want it to be a marvel of clarity and wit for the generations of programmers who will maintain it. The server-side code doesn't go out to the client, remember. I must admit I kinda feel mandatory variable declaration has proven to be a *good* feature of modern programming languages though I accept Javascript could do with the equivalent of 'use strict' too. So I guess you're telling me that you can't mandate variable declaration in Python. Ah well, as long as I know, I guess. [snip] re Zope - yup, I will certainly be checking it out. Thanks again for all your help. Sent via Deja.com http://www.deja.com/ Before you buy. From gmcm at hypernet.com Wed Dec 1 22:47:13 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 1 Dec 1999 16:47:13 -0500 Subject: use Userdict for class __dict__ In-Reply-To: <38458474@199.186.16.51> Message-ID: <1268037651-41672093@hypernet.com> Gang Li writes: > In order to monitor access of class attributes, I tried to > replace class __dict__ with UserDict. > > class Foo: pass > > class MyUserDict(UserDict.UserDict): > def __getitem__(self, name): > ...... > > Foo.__dict__ = MyUserDict(Foo.__dict__) > > But python bit me with: > TypeError: __dict__ must be a dictionary object > > How can I avoid this kind error. Wrap your object in a proxy: class Proxy: def __init__(self, obj=None): self.__obj__ = obj def __getattr__(self,name): print "getattr called for", name return getattr(self.__obj__, name) def __repr__(self): return "Proxy for "+`self.__obj__` __str__ = __repr__ - Gordon From m.faassen at vet.uu.nl Sun Dec 19 12:22:09 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 19 Dec 1999 11:22:09 GMT Subject: The Official Naughty Or Nice List References: <199912190039.TAA30901@peterjh.goshen.edu> Message-ID: <83if51$760$2@newshost.accu.uu.nl> Robin Becker wrote: > In article <199912190039.TAA30901 at peterjh.goshen.edu>, Santa's Little > Helper writes >> >>Ho, Ho, Ho, python-list at python.org, >> > ... > Satan's little helper is always welcome. Santa in Dutchland is to be > accompanied by Black Pete. Right, several of them, in fact. But the Sint's been past and gone now. > Interestingly my spell checker insists that satan be spelled with a > capital. I got this spam in my mailbox too. I don't think this Santa guy you furrnerrs are all so worked up about can spell, I mean, "you're" password? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From fredrik at pythonware.com Fri Dec 3 12:01:49 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 3 Dec 1999 12:01:49 +0100 Subject: Email address check function References: <19991202163334.A3934@stopcontact.palga.uucp> Message-ID: <028601bf3d7d$cd63a850$f29b12c2@secret.pythonware.com> Gerrit Holl wrote: > I'm writing some CGI scripts and I want the user to fill in their real email > address. Checking this is more difficult than just look if it contains an '@'. > There must be at least one '.' after the '@' but there must be non-'@' chars > before and after every '.', no white space, etc. There must be an RFC for > this, but is there a function in the standard library that checks if it's > OK? http://www.perl.com/pub/doc/manual/html/pod/perlfaq9.html#How_do_I_check_a_valid_mail_addr "How do I check a valid mail address? You can't, at least, not in real time. Bummer, eh?" From mwh21 at cam.ac.uk Sat Dec 4 13:17:45 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 04 Dec 1999 12:17:45 +0000 Subject: Naive Question References: <38484DC9.3FF755EB@murl.com> Message-ID: jim kraai writes: > Greetings, > > If I have: > > class contrived_collection: > def __init__(self): > self.item = [{1,2},{3,4},{5,6}] > > a = contrived_collection() > b = a.item[2] > > How can I ask b what it is a member of? You can't, at least not without basically adding the information yourself. Watch out for cycles! > I need to somehow know later in processing that: > 1. b is a member of a.item > 2. a.item is a member of a Hmm... what are you trying to do? Have you looked at Acquisition: http://www.zope.org/Members/Amos/WhatIsAcquisition (which is zope biased; there may be another more generic intro somewhere but I can't find it just now). It s a very cute method for dealing with some problems a bit like this. Cheers, Michael From fdrake at acm.org Thu Dec 23 15:50:28 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 23 Dec 1999 09:50:28 -0500 (EST) Subject: Super-rexex? In-Reply-To: <19991223151828.A3636@stopcontact.palga.uucp> References: <19991223151828.A3636@stopcontact.palga.uucp> Message-ID: <14434.14004.510906.767308@weyr.cnri.reston.va.us> Gerrit Holl writes: > I'm looking for a super-rexex. In the current rexec, it's possible > to disable all built-in functions and all modules, but I want to > disable all statement also, and non-string assignments. > > Maybe I have to look for another solution. My problem is: > I want to use something like execfile() on a file, but the > file should *only* have string definitions! Gerrit, I presume you want the file to have things like this: FOO = "foo value" BAR = "bar again?" If that's it, there are a couple of ways to do it. The one that probably makes the most sense is to change the systax of the file and use the ConfigParser module to parse an .ini type file: [MyConfiguration] FOO=foo value BAR=bar again? Another, more painful approach, but which allows the specific format you describe, would be to write your own parser for it. You can use the tokenize module to help out with tokenization, but it's up to you to do the actual parse. Chances are good John Aycock's tools would really help out. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From aahz at netcom.com Fri Dec 31 05:19:59 1999 From: aahz at netcom.com (Aahz Maruch) Date: 31 Dec 1999 04:19:59 GMT Subject: Error in inserting blob into ORACLE using ODBC.Windows References: <386c0577.107657473@news.phoenix.com> Message-ID: <84hatf$t93$1@nntp9.atl.mindspring.net> In article <386c0577.107657473 at news.phoenix.com>, TM wrote: > >I have a problem inserting BLOB into ORACLE using ODBC.Windows with either >the Oracle ODBC driver or the Micorsoft ODBC driver for Oracle. I've done similar things using MS SQL Server, so I'm guessing that you've got some kind of configuration problem. What do the Oracle docs say about those errors? -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 2 days and counting! From gerrit.holl at pobox.com Fri Dec 3 21:12:32 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 3 Dec 1999 21:12:32 +0100 Subject: indentation In-Reply-To: <828s7g$d4f$1@mach.vub.ac.be>; from thamelry@vub.ac.be on Fri, Dec 03, 1999 at 04:47:44PM +0000 References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: <19991203211232.A11045@stopcontact.palga.uucp> Thomas Hamelryck wrote: > The use of indentation is IMO indeed a (very) weak point of python. I believe people who use Python as a first language (like me) disagree in that. I dislike all those {'s en }'s in c, and I rather read postscript than P**l. > Many people however who use python like it. As i said: people who start with Python as a first language like it. > I've been using python for one year now and I still deeply dislike it. > However, the language is so nicely crafted that its advantages easily > outweigh the use of indentation. For me, it's the largest reason to use Python over P**l. > Hey, no language is perfect! > You might even start to like as many python users do... I don't know how it is on other languages, but the mistake I make most is: class A: def __init__(): ... no self... Why do I have to type it, if it's not possible to not type it? regards, Gerrit. -- "The world is beating a path to our door" -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates) 9:08pm up 8:42, 16 users, load average: 1.12, 1.21, 1.12 From bsb at winnegan.de Sun Dec 19 15:44:17 1999 From: bsb at winnegan.de (Siggy Brentrup) Date: 19 Dec 1999 15:44:17 +0100 Subject: How do I read multipli bytes from file? In-Reply-To: "Jens Arnfelt"'s message of "Sun, 19 Dec 1999 13:23:35 +0100" References: Message-ID: <87hfhff0se.fsf@baal.winnegan.de> "Jens Arnfelt" writes: > Hi There ! > > I have been working on an python program that reads Call Data Records from a > file! > > Ex. the following values in hex (a telephone number encoded in BCD(Binary > Coded Dicimal) : > > 45 26 10 05 01 1f ff ff ff ff > > The length of the fiels is 10 bytes. > I need to convert this into somthing readable in a single string. The result > should be! > > '45261005011fffffff' > > I've tryed with the string.unpack() but its return a list of bytes, not a > string. > > Any help would apriciated It's not very efficient but it works for getting at the nibbles: string.join(map(lambda b:'%02x' % (b&0xff), LIST_OF_INTS) Further tweaking may be required depending on the exact representation of phone numbers in your input data. HIH Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From mlh at vier.idi.ntnu.no Mon Dec 13 23:19:23 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 13 Dec 1999 23:19:23 +0100 Subject: Dot product? References: <3852B91D.6EE31805@math.okstate.edu> <3854CBFF.85A69AA@compaq.com> <3854F1EE.3CA02CD6@compaq.com> Message-ID: Greg Ewing writes: > "Magnus L. Hetland" wrote: > > > > And something like > > > > for x and y in list1 and list2: > > > > is ruled out because - list1 and list2 may be arbitrary expressions > > resulting in lists or tuples? (Am I right?) > > It's more because "list1 and list2" is already a single > expression which means "apply the 'and' operator to list1 > and list2". That was my point exactly - if list1 and list2 were known to be lists, the "and" would be a safe delimiter, just as it is in its first occurrence. > > And is > > > > for x,y in list1, list2: > > > > ruled out because of anything except aesthetic preference? > > Yes. You're already allowed a comma-separated list of > target variables, in which case unpacking occurs. > > > (In that > > case, I would like to state my preference as being in favour of the > > latter, due to its consitency ;) > > I would have preferred it too, but it's already taken :-( Oh, well... At least its current meaning is quite elegant :) > > Greg -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From rurban at xarch.tu-graz.ac.at Fri Dec 24 20:03:20 1999 From: rurban at xarch.tu-graz.ac.at (Reini Urban) Date: Fri, 24 Dec 1999 19:03:20 GMT Subject: Pythonwin: any plans for COM+? Message-ID: <3863c163.8797109@judy> Reading the MS COM+ specs and Mark's paper and sources regarding improvements when COM+ will be available I have some questions for the knowledable: COM+ will provide dynamic GUID creation, dynamic object registration also. Will this be better than the features we have now? I saw the whole lotta lot of wrappers, in fact one cpp file per interface to support. Isn't that too much work for the new interfaces which will come? Will not the COM+ runtime services provide the same or better functionality? My naive approach would have been without wrappers, just create the needed interfaces at runtime on the heap as with callbacks. Lisps do that this way. (CLISP, Corman Lisp, Allegro Common Lisp) The advantage would be to use the native language and abstraction possibilities with a single (but admitted: complicated) external code-creation facility. Dynamic events: This is one feature which I miss with pythonwin and which will be supported with COM+ Any plans? The new features (interface-based, method-based, and persistent) seems to make life much easier than now. Implementation inheritence: Played with that? MS says that it will complicated at the client-side. Links: http://msdn.microsoft.com/library/techart/compluscouple.htm http://www.microsoft.com/msj/1297/complus2/complus2.htm -- Reini Urban http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html From oli at rz-online.net Fri Dec 31 12:31:21 1999 From: oli at rz-online.net (Oliver Andrich) Date: Fri, 31 Dec 1999 12:31:21 +0100 Subject: Radius module In-Reply-To: <15337897.1989@bellsouthips.com>; from lellinghaus@bellsouthips.com on Thu, Dec 30, 1999 at 03:45:13PM -0500 References: <15337897.1989@bellsouthips.com> Message-ID: <19991231123121.C3236@gothic.andrich.net> Hi, there exists a Zoep Product to do radius auth. This includes a python module that can be used outside of Zope. Search Zope.org for it. Sadly, I don't have a link at hand. Bye, Oliver On Thu, Dec 30, 1999 at 03:45:13PM -0500, Lance Ellinghaus wrote: > Has anyone created a module to talk to a radius server for user validation? > > Thanks! > Lance Ellinghaus > > > -- > Lance Ellinghaus > > -- > http://www.python.org/mailman/listinfo/python-list -- Oliver Andrich, KEVAG Telekom GmbH, Cusanusstrasse 7, D-56068 Koblenz Telefon: 0261-3921027 / Fax: 0261-3921033 / Web: http://rhein-zeitung.de From tismer at appliedbiometrics.com Wed Dec 22 12:51:38 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 22 Dec 1999 12:51:38 +0100 Subject: how does one get aboard the Starship...? References: <6D8A17398E28D3119F860090274DD7DB4B3D71@pces.cadlab.it> Message-ID: <3860BB4A.7176A87B@appliedbiometrics.com> Alex Martelli wrote: > > Right after joining the PSA (and getting confirmation of my being > there, and seeing myself listed as member number 222), I > visited http://starship.python.net/memberform.txt, filled it up, > and mailed it to tismer at appliedbiometrics.com as per > instructions. But then, nothing at all happened -- neither > bounce messages, nor acknowledgments, etc. Some quiet > e-mail failure (so I should just re-send), outdated instructions > (so I should do something else), maintainer busy (so I should > just keep waiting), or...? > > Thanks to anybody who can help, I got many requests last time, and probably failed to acknowledge you, which is hereby done. Due to some restructuring, all pending embarkings will take place in January. Provided that earth will stand the Y2K crash, of course :-) Thanks for your patience - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From python-list at teleo.net Fri Dec 3 22:28:24 1999 From: python-list at teleo.net (Patrick Phalen) Date: Fri, 3 Dec 1999 13:28:24 -0800 Subject: Who "uninvented" brace delimiting? (Was Re: Be gentle with me....) In-Reply-To: References: <828n3e$8kp$1@nnrp1.deja.com> <828qhj$bb1$1@nnrp1.deja.com> Message-ID: <99120313382906.00844@quadra.teleo.net> [Fran?ois Pinard, on Fri, 03 Dec 1999] :: So, of course, when I saw that Guido was pushing *my* idea so far to consider :: the braces themselves as more noisy than informative, while retaining the :: main underlying principle, I liked Python instantly, and I surely found :: that Guido was a very clever guy! :-) Seems like an appropriate time to trot out this chestnut again (courtesy of Andrew Kuchling's Python Quotations Web page): "We will perhaps eventually be writing only small modules which are identified by name as they are used to build larger ones, so that devices like indentation, rather than delimiters, might become feasible for expressing local structure in the source language." Donald E. Knuth, "Structured Programming with goto Statements", Computing Surveys, Vol 6 No 4, Dec. 1974 From python-list at teleo.net Wed Dec 8 17:01:43 1999 From: python-list at teleo.net (Patrick Phalen) Date: Wed, 8 Dec 1999 08:01:43 -0800 Subject: exchanging data btwn Python and lesser languages In-Reply-To: References: <82jau6$e72$1@nnrp1.deja.com> <14413.33938.300484.712295@dolphin.mojam.com> Message-ID: <99120808111500.02667@quadra.teleo.net> [Harry G. George, on Wed, 08 Dec 1999] :: What's the relationship between XML-RPC and Microsoft's SOAP? Userland's Dave Winer worked with several others, including Microsoft to define a Simple Open Access Protocol. It fit Dave's vision of a scriptable Web without boundaries and it fit Microsoft's vision of a Web without Java . Impatient to get it used, and fearing that Microsoft might take a year or more to sign off on an official recommendation, he went ahead and submiitted the XML-RPC spec. Microsoft went on to add some (good) features and released SOAP, with Dave's blessing. So, simply put, SOAP is XML-RPC with addt'l goodies. From s323140 at student.uq.edu.au Thu Dec 23 20:18:41 1999 From: s323140 at student.uq.edu.au (Rob Hodges) Date: 24 Dec 1999 05:18:41 +1000 Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <83lnq7$c9d$1@news1.tele.dk> <86puvz6dbg.fsf@g.local> <86aen2o25s.fsf@g.local> Message-ID: Gareth McCaughan writes: > Rob Hodges wrote: > > Usually it was used in preference to (if a b c) where using the latter > > would have required writing (if a (progn b) c) -- that is, b consists > > of multiple statements. Of course that is a flow control > > construction; I've never seen it used the way you write above, which > > I think could only qualify as intentional obfuscation. > > I don't think I understand. If B consists of more than one > statement, how do you do the AND/OR thing without a PROGN? `and' and `or' will take as many arguments as you like, and keep evaluating them until there's no point continuing: (or (and something-or-other-p non-nil-expr-1 non-nil-expr-2 ...) nil-expr-1 nil-expr-2 ...) The trick is just not to return nil from any of the statements in B. > Er, this is getting a bit off-topic... Yeah, my bad -- sorry for starting this... > Interesting. What makes that construction obscure for me > is mostly the (,,()(((,,),)(,))) stuff, not the "and" and > "or". I don't mean that the parens and commas do more to > stop it being easy to sit down and work out than the > and/or business; I mean that they contribute more to > the fact that the idiom isn't one the eye just glides > happily past, even when you know what it does. To that extent I agree. But the construct often doesn't need the tuplification and indexing. For example when assembling a command line for a process you're going to spawn, something like use_r_option and "-r" or "" is fine without that garbage. And reasonably elegant, provided the reader is familiar with it. > "Idiot" comes from the Greek "idiotes" meaning "layman". I'm not > sure why "idiotes" means that; perhaps the idea is the contrast > between the individual layman and the person who's a member of > whatever institution is in question. "Layman" has at least the potential for harbouring perjorative overtones; really it means someone who knows little or nothing -- usually about a particular field of endeavour, but if you've got someone who knows nothing about anything, I guess that's an idiot. The message I got off-list said that the Greek root relates to ownership, and given that, you would expect that "idiot" ought to mean something like "private person". Which ties in reasonably well. Anyway, I think it's time I shut up and desist from diverting the eyeballs away from the many greater minds here. -Rob From pinard at IRO.UMontreal.CA Fri Dec 10 01:57:12 1999 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 09 Dec 1999 19:57:12 -0500 Subject: FORTRAN (was Re: indentation) In-Reply-To: "William B. Clodius"'s message of "Thu, 09 Dec 1999 16:47:37 -0700" References: <65118AEEFF5AD3118E8300508B124877073CC6@webmail.altiris.com> <384EF139.91ACD637@bioreason.com> <38500A94.FB6EF7DE@be-research.ucsd.edu> <3850368B.F104F1D9@appliedbiometrics.com> <38503F7E.66E9D5BD@lanl.gov> Message-ID: "William B. Clodius" writes: > [...] I believe that all Fortran's up to Fortran 90 could be implemented > with static allocation. It had no recursion and, in most respects, no > dynamic allocation. The one tricky point in static allocation involves > some usages of CHARACTER variables which result in expressions whose > size can vary at runtime. CHARACTER variables?! :-) They appeared rather late in FORTRAN. In earlier FORTRAN, one was using Hollerith constants within integers, for initialising something vaguely resembling character strings. All this was highly dependent on the word size, of course, and hardly portable. There was a function LOCF(VAR) returning the address of VAR. The usual idiom was to initialize some: COMMON // IZ(1) IZ = 1 - LOCF(IZ) and then use: IZ(IZ+K) to read or assign the K'th word in memory. If you knew rather well how the system was using its memory, you could do "sophisticated" things. :-) > As a side point, dynamic languages can also be implemented statically I vaguely remember that it is the young Alain Colmerauer, the later father of the Prolog family, who made us laugh quite a bit when he asserted that recursive algorithms may be implemented non-recursively, if using a stack. It was at a time we were using FORTRAN and assembler on the first floor to make real programs, while linguists on the fifth floor and other computer science people were using Algol-60 to write algorithms like mathematic theorems. The despise was mutual... Testing theoretical algorithms with a real computer was, at the time, considered a dirtying, impure activity, only done secretely if possible; so we were calling them "Algoolic Anonymous" (does the pun translate?). Things changed immensely since then. Nowadays, computer science people often lead, and even for practical matters! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From badzen at yifan.net Sat Dec 18 06:21:55 1999 From: badzen at yifan.net (dj trombley) Date: Sat, 18 Dec 1999 05:21:55 GMT Subject: Stack overflow References: <83em51$krl$1@nnrp1.deja.com> Message-ID: <385B195B.E9B32A3@yifan.net> homunq at my-deja.com wrote: > > I recently had a subtle __getattr__ bug that led to infinite recursion > and thus stack overflow. This causes PythonWin to crash, rather than > just raising an exception. Ugly. > > I heard something about a patch that would fix this. Does anyone know > where I would find this? > > If there isn't a patch, or if the patch isn't a planned component of the > next python version, I'd like to vote (as a PSA member) that this is > important. Yes, of course I know in retrospect that if I were a Real > Programmer this would have been the first thing I thought of when I got > my crashing behavior. But it's still ugly behaviour, and especially in > light of CP4E it shouldn't be how things work. > > Sent via Deja.com http://www.deja.com/ > Before you buy. The patch is really merely a convienence so you don't have to recompile. It is available at http://www.deja.com/[LBURL=_LBHT,LBT,ST_rn=ap]/threadmsg_ct.xp?AN=484809938 as Thomas Heller pointed out in a seperate thread. The binary it was created against was presumably produced by changing the value of MAX_RECURSION_DEPTH in the python source (python/ceval.c:336) to a smaller value than the default 10,000 so that a windows machine will not run out of stack space before fenceposting. Also, there is an implementation of Python which does not use the C stack available at http://www.pns.cc/stackless/stackless.htm. I've not tried this personally, but it should theoretically behave better under such conditions. -dj Dave Trombley From malcolmt at smart.net.au Wed Dec 22 11:27:08 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Wed, 22 Dec 1999 21:27:08 +1100 Subject: strptime on Unix systems In-Reply-To: ; from Oleg Broytmann on Wed, Dec 22, 1999 at 09:41:04AM +0000 References: <19991222110107.A972@Ridcully.home> Message-ID: <19991222212708.A1526@Ridcully.home> On Wed, Dec 22, 1999 at 09:41:04AM +0000, Oleg Broytmann wrote: > On Wed, 22 Dec 1999, Malcolm Tredinnick wrote: > > The following does *not* work under Linux (at least): > > > > import time > > format = '%a %b %d %H:%M:%S %Z %Y' > > t = time.localtime(time.time()) > > timestring = time.strftime(format, tt) # Works OK > > timetuple = time.strptime(tt, format) # Throws ValueError > > > I've tested your program (replaced "t =" with "tt =") on pentium linux, > freebsd and sprac solaris. All the same ValueError... Urgh! Stupid typing error ... sorry :( OK .. so we have three pretty common unix variants all exhibiting the same problem. Should something be added to the docs (under strptime) about this in the future? (I was going to mention I was running glibc 2.0, rather than the latest 2.1 version, but that seems irrelevant if *BSD and Solaris are behaving similarly.) Malcolm Tredinnick From wtanksle at hawking.armored.net Wed Dec 1 07:42:27 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 1 Dec 1999 06:42:27 GMT Subject: Exposing COM via XML-RPC or Something Else References: <38435919.D88B4EC0@home.com> Message-ID: On Tue, 30 Nov 1999 04:57:00 GMT, Edward Muller wrote: >I'm playing around with a way to expose Windows COM object via >XML-RPC (or something else). I love how well Python works with XML-RPC. It's just amazing. Anyhow, what you want is SOAP, which was a byproduct of XML-RPC. Microsoft helped develop XML-RPC, but at one point the committee was moving too slowly, so MS decided to make an end-run. They finished SOAP at about the same time, plus or minus, the committee did, but I suspect that they put a lot more into it. At any rate, SOAP provides a Simple Object Access Protocol. Just what you need. And it's essentially XML-RPC, and it's made to grok COM. Highly satisfactory. Now all we need is a truly open COM implementation. -- -William "Billy" Tanksley, in hoc signo hack From pinard at iro.umontreal.ca Mon Dec 13 01:56:58 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 12 Dec 1999 19:56:58 -0500 Subject: recode In-Reply-To: Pawel Krawczyk's message of "Wed, 22 Sep 1999 17:20:34 +0200" References: <19990921194833.I13743@ceti.pl> <19990922172034.D28017@ceti.pl> Message-ID: Pawel Krawczyk ?crit: > Problem is that actually I'm improving some third party program using > third party library. In this particular case the program_name is unique > for recode, but if tin also used this symbol for some other purposes? It is unlikely that it does for other purposes. `program_name' is widely used in GNU programs. > Instead of having the program_name symbol in the librecode, I'd rather > make another library, say librecode_simple, which would contain procedures > for simple programs using auto-abort feature you mention. I'm not fully sure I understand your suggestion, yet I wonder if the matter is worth the trouble. As I wrote to you in a separate message, the purpose and usage of this variable is now documented, and if the surprise does not exist, it will probably not be a problem in practice. Not documenting it in the first place was a mere oversight from me, as this variable exists in almost every C program I wrote, for a lot of years now :-). -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From herzog at online.de Wed Dec 15 22:14:17 1999 From: herzog at online.de (Bernhard Herzog) Date: 15 Dec 1999 22:14:17 +0100 Subject: Error confusing a newbie References: <19991210100320.B18389@dmcom.net> <19991211161917.C27756@dmcom.net> Message-ID: Wayne Topa writes: > Quoting Bernhard Herzog(herzog at online.de): > >| Did you notice that the line numbers are off by one? The open is on line > >| 6 and not seven. Perhaps your file starts with a newline? > >| > > Give that man a Big Box of cigars. Thanks, but I don't smoke. :-) [snip] > Tschuess Tsch?? Bernhard From python-list at teleo.net Sun Dec 19 19:26:14 1999 From: python-list at teleo.net (Patrick Phalen) Date: Sun, 19 Dec 1999 10:26:14 -0800 Subject: python apache module? In-Reply-To: References: <3823D45F.CF78E6E7@mindspring.com> Message-ID: <99121911004600.02583@quadra.teleo.net> [Cameron Laird, on Sun, 19 Dec 1999] :: In article , :: Erno Kuusela wrote: :: >On Sat, 06 Nov 1999 02:10:23 -0500, Rob Nikander :: > wrote: :: >>I am just beginning to learn python and so far I think it is awesome. I :: >>was wondering if there is an Apache module analogous to mod_perl for :: >>python? I don't see anything on the Apache page. If not, is someone :: >>working on one? :: > :: >there are 2. :: > :: >PyApache is CGI-compatible out of the box, but is not noticeably :: >faster than using straight CGI because it creates and shuts down :: >a python interpreter for each individual http request. :: > :: >httpdapy is not cgi-compatible, but it is pretty easy to use :: >and it is much faster then cgi/pyapache since it keeps :: >the python interpreter around. it is in this sense more :: >equivalent to mod_perl functionality. :: . . :: . :: I welcome help with , :: whose aim is to catalogue such information and comparisons. Keeping Cameron's repository of information up to date is important. Having some information on apache.org would also be valuable. If I go to http://www.apache.org/perl/, I see a whole lively section of development. If I go to http://www.apache.org/python/, I get a 403 Not Found error. Could something be done about this disparity? From thomas at bibsyst.no Tue Dec 28 11:05:19 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Tue, 28 Dec 1999 11:05:19 +0100 Subject: Portable or not?! Message-ID: <38688B5F.AC2C4683@bibsyst.no> Hi, I`ve written a python script that uses dbhash. When run under Windows, it crashes and says something about bsddb/dbhash-error, "(22, invalid argument)". I run the script without problems under Red Hat 6.1 Linux, but it crashes under Windows98, with the latest Python dist. for windows. Does the linux version use a different version of the dbhash-module, or how can I find out? I don`t feel very x-mas merry right now. :-< Please help, anyone. Thomas From szhao at my-deja.com Mon Dec 6 20:14:25 1999 From: szhao at my-deja.com (szhao at my-deja.com) Date: Mon, 06 Dec 1999 19:14:25 GMT Subject: Looking for a Unix alike tar tool written in Python Message-ID: <82h1ts$pus$1@nnrp1.deja.com> Hello, everyone: I noticed that there is a gzip module in python 1.5.2, is there a tar module written in python? Thanks. Sent via Deja.com http://www.deja.com/ Before you buy. From ahopkins at ahopkins.dynacare.com Mon Dec 20 17:29:03 1999 From: ahopkins at ahopkins.dynacare.com (Albert Hopkins) Date: 20 Dec 1999 11:29:03 EST Subject: FAQ References: <385e6375.0@news1.cluster1.telinco.net> Message-ID: On Mon, 20 Dec 1999 16:11:54 -0000, Torture wrote: >Where can i get an FAQ for this NG? I don't know if this newsgroup has a FAQ per se, but the Whole Python FAQ is available at http://www.python.org/doc/FAQ.html -- Albert Hopkins Sr. Systems Specialist Dynacare, Inc ahopkins at dynacare.com From abrahams at mediaone.net Fri Dec 31 01:23:09 1999 From: abrahams at mediaone.net (Dave Abrahams) Date: Thu, 30 Dec 1999 19:23:09 -0500 Subject: The Don Beaudry/Jim Fulton hack References: <1265560092-4227862@hypernet.com> Message-ID: In article <1265560092-4227862 at hypernet.com> , "Gordon McMillan" wrote: > Dave Abrahams wrote: >> >> I've recently been crawling through the source code (trying to >> understand what all those fields in PyTypeObject really do), and >> stumbled across an explanation for what I had read about being >> able to subclass a type extension in Python: there's special code >> to make this possible! > > Not really. That special code allows you to take over the > building of a new instance from Python. Subclassing a type > takes a whole lot of C code. Yes, really. Even with a whole lot of 'C' code, you couldn't subclass a type extension without that bit of special code. That bit of special code is what makes it possible. >> I think: it would be cool to experiment with this before writing >> any C code, just to make sure I understand it. So I fire up >> Python. Since the special code is never entered if the base is a >> real class (not shown), I figure it has to be an instance: >> otherwise, how could it have an attribute called "__class__"? > > Correct. > >> >>> class Empty: pass >> ... >> >>> base = Empty() >> >>> base.__class__ = stupid_class >> Traceback (innermost last): >> File "", line 1, in ? >> TypeError: __class__ must be set to a class >> >>> > > Nope. The above magic is invoked when the "class" statement > is run. So the key is > > class MyClass(magicinstance): > > That is, you "derive" from an instance. The magicinstance has > nothing to do with the result. It's the magicinstance's class > that provides the magic. I understood all that. I just forgot that attributes of the class object are reflected in its instances. It would have been more helpful to nudge me in this direction, instead: class Empty: __class__ = stupid_class > IOW, this was an easy way to test > out an experimental feature, not an axiom of the object model. Yes; I was intending to explore it experimentally before I started writing C++ code. > Look at Demo/metaclasses. > > >> Finally, another point. It is now possible to make extension >> classes which walk, talk, and smell just like built-in classes > > Not at all. In what sense "not at all"? > Making a type subclassable means bridging the two > different "method" mechanisms. Types have slots, classes / > instances have magic dictionaries. Certainly I can make an extension types which have magic dictionaries, just like classes and instances do (not that I would waste the effort on something so uninteresting). > Take a look at > ExtensionClass from Digital Creations (comes with Zope). > Notice that it reimplements 99% of everything, and only types > of the ExtensionClass type are subclassable (so you still can't > subclass lists or dictionaries). I didn't claim to be able to subclass the built-in types. All I said was that I could make a system of class and instance extension types which are arbitrarily similar to built-in classes and instances, up to the point where somebody calls is_instance() or uses type(). Then the whole system is exposed. I don't think there's any way around the latter, but I'd prefer it if the former could be made to work. -Dave From ivanlan at callware.com Fri Dec 10 04:31:43 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 09 Dec 1999 20:31:43 -0700 Subject: some random reflections of a "Python newbie": (2) language issues References: <001e01bf42bd$4da0cfe0$60a2143f@tim> Message-ID: <3850741F.F1EEE23B@callware.com> Hi All-- Tim Peters wrote: > > [Alex Martelli] > > ... > > [snip] > > The way I envision this -- if X chooses to > > implement a method __contains__, ... > > Yup -- that's The Plan. > > postcognitively y'rs - tim > Hmmm. So--Alex has a Time Machine too! It's no longer a Guido Monopoly! -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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From peter.stoehr at sdm.de Wed Dec 15 15:11:00 1999 From: peter.stoehr at sdm.de (Peter Stoehr) Date: Wed, 15 Dec 1999 15:11:00 +0100 Subject: Timing in MacPython? References: Message-ID: <3857A174.9277CBF9@sdm.de> Hi Michael, maybe you can take one or two ideas from my WebTime-Program. It's attached to this article. Greetings from munich Peter ventrego at yahoo.com schrieb: > > I'm trying to create a simple timer application - something like a > kitchen timer, just computerized. However, I'm running into several > problems: > > First,can I force TKinter update the window? I've set up a label and a > button with TKinter textvariables, but the changes don't happen until > after my program returns to idle - in this case, after the time interval > has elapsed. I'd like to have changes updated while the timer's waiting, > so that the user knows everything's working correctly. > > Second, is there an easy way to sound the system alert sound? I'm > referring the one that people can choose in the Sound/Monitors & Sound > control panel. It's possible to create a waveform and play it a la' the > morse.py demo program, but this seems excessively inelegant. > > Finally, is there a non-blocking time-delay command? I'm using > time.sleep(1), which is working well, but it stops all other processes > from executing. Ideally, I'd like this timer to run in the background! > If I was on a UNIX system, I'd use signals, which would be VERY easy, > but I'm a Mac addict at heart. :) > > Thanks for any help - > Michael -- Dr. Peter Stoehr mailto:peter.stoehr at sdm.de sd&m AG http://www.sdm.de software design & management Thomas-Dehler-Strasse 27, D-81737 Muenchen, Germany Tel ++49 89 63812-783, Fax -444 -------------- next part -------------- # # Internet-Time for Python/tk # ============================= # # Author: Peter Stoehr # Teisenbergweg 6 # 85435 Erding # Germany # # peter at peter-stoehr.de # import tkFont import Tkinter from time import * oldBeat = 0 class InternetStandardTime: def __init__(self): self.msec_per_day = 24 * 60 * 60 * 1000 self.msec_per_beat = self.msec_per_day / 1000 def getBeat(self): msec = self._getSecond() * 1000 the_beat = msec / self.msec_per_beat return int(the_beat) def msecToNextBeat(self): msec = self._getSecond() * 1000 retValue = msec % int(self.msec_per_beat) return (int(self.msec_per_beat - retValue)) def _getSecond(self): (year, month, day, hour, minute, second, day, jday, swz) = localtime(time()) return(second + 60 * (minute + 60 * (hour - swz))) def my_after(): global window global ist global oldBeat theBeat = ist.getBeat() if (theBeat == oldBeat): window.after(25, my_after) else : oldBeat = theBeat beat_string = "Beat-Time: @ %3d" % (theBeat) window.configure(text=beat_string) window.update_idletasks() window.after(ist.msecToNextBeat(), my_after) # # Create the TK-interface # ist = InternetStandardTime() root = Tkinter.Tk() root.wm_transient() window = Tkinter.Label(root,text="Hello World") window.pack() window.after(1000, my_after) Tkinter.mainloop() From stigb at tihlde.org Wed Dec 22 21:52:31 1999 From: stigb at tihlde.org (Stig Bjorlykke) Date: 22 Dec 1999 21:52:31 +0100 Subject: How to read lines from end of a file? Message-ID: <4rhfhazoj4.fsf@colargol.tihlde.hist.no> Hi all. I wonder how to read lines from end of a file, like this perl code: open FILE, "/tmp/file"; foreach (reverse ) { ... } I am using it to get the latest entries in a log file. -- Stig Bj?rlykke Linux user From tholap at compuserve.com Mon Dec 13 22:54:14 1999 From: tholap at compuserve.com (Olaf Appelt) Date: Mon, 13 Dec 1999 22:54:14 +0100 Subject: Suitability of Python for a Big Application? References: <830vic$r2t$1@nnrp1.deja.com> <83181a$n90$1@ssauraab-i-1.production.compuserve.com> <832fn5$iio$2@newshost.accu.uu.nl> Message-ID: <8355b0$j3p$1@ssauraaa-i-1.production.compuserve.com> > > I like Python, but I don't think it's well suited for large projectes. Also > > it lacks in the speed department. > > Also, I believe that it's lack of type safety and access restrictions, which > > is a bonus for small projects beccomes a liability in large, > > multi-programmer projects. > > This may be true, but is debatable, and.. Well, everything can be drebated. ;-) > While smalltalk implementations may be faster than Python, Smalltalk is > just as dynamically typed as Python, isn't it? Right. > And I didn't think it had > much of access restrictions as well. So unless you're recommending Smalltalk > for speed reasons, I don't see why it'd do better than Python in the large, > multi-programmer project domain? Tools, libraries, consistency. There's more literature, skills and general support around for Smalltalk than for Python. I don't want to make Python look bad. I like it. It's a good language. But given the requirements (and my interpretation of the gaps), I don't believe that Python would be the right choice. I might be wrong. It's IMHO of course. > It's probably true there's more experience with Smalltalk in large multi > programmer projects. I vaguely recall anecdotal evidence that it can be > quite successful at this. If that's the case, your objections against > Python as regards to lack of type safety and large scale programming support > may be less strong, though. > > To use Python in a large project you need programming (and design) discipline. > But such discipline is need with Java and C++ projects as well (*definitely* > with C++!); One of the reasons I recommended Java over C++. > static type checking doesn't magically make large scale engineering > problems go away, though it can help, of course. My thoughts exactly. It's not a silver bullet, but it helps keeping things under control, especially when there's a group of programmers. IMHO. Olaf From drek at MonsterByMistake.Com Tue Dec 14 16:59:47 1999 From: drek at MonsterByMistake.Com (Agent Drek) Date: Tue, 14 Dec 1999 10:59:47 -0500 (EST) Subject: building string for __import__() In-Reply-To: <003b01bf461c$8d05a810$3acbd9c2@peridot.optichrome.com> Message-ID: On Tue, 14 Dec 1999, Adrian Eyre wrote: |Date: Tue, 14 Dec 1999 10:18:22 -0000 |From: Adrian Eyre |To: Agent Drek , python-list at python.org |Subject: RE: building string for __import__() | |> ImportError: No module named /mnt/somewhere0/foo1/flub2/TARGET | |Assuming PYTHONPATH contains /mnt | |import and __import__ take the format: somewhere0.foo1.flub2.TARGET | |Although if you want to execute a script, you can use: | |execfile("/mnt/somewhere0/foo1/flub2/TARGET") | |-------------------------------------------- |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 |-------------------------------------------- Hmmm... my problem was that the variable that I built up with: dirdata = { 'somewhere': '0', 'foo': '1', 'flub': '2' } FILE = "/mnt/somewhere" + dirdata['somewhere'] + \ "/foo" + dirdata['foo'] \ "/flub" + dirdata['flub'] \ "/TARGET" would give me the import error but just typing it manually into the interpreter would work fine. I'll try the . notation. >>> c = import__("/typing/in/the/path/by/hand/did/it/TARGET") execfile(FILE) works well enough however. __import__ just didn't like my Object FILE. I'm happy enough with execfile and was just curious about what I was doing wrong with __import__ thanks, =derek Monster By Mistake Inc > 'digital plumber' http://www.interlog.com/~drek From dworkin at ccs.neu.edu Thu Dec 23 17:08:16 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 23 Dec 1999 11:08:16 -0500 Subject: When to use input()? References: <19991222210125.A1195@stopcontact.palga.uucp> Message-ID: Gerrit Holl writes: > Can someone tell me a situation to use input()? > Is it possible to run it in a rexec environment? If not, input() isn't > only useless, but also unsafe. > I think input() is bad because you pass the users input to eval() directly, > so the user can do __import__('os').system('sh'). That can't be what > you want. Unless, of course, it is what you want. There are plently of situations where this isn't dangerous at all. In the case of a user manually executing a non-suid script, for instance, they can't do anything as a result of input() that they couldn't do on their own anyway. There are many problem domains where input() is not appropriate. Most networked or distributed applications are examples of such, as you probably don't want users of your app to execute arbitrary code on your server. suid scripts or programs that manage to have some authorization to do things that their user cannot do on his own should probably not use input() either. However, there are plenty of situations where input() is convenient, useful and safe. -Justin From abrahams at mediaone.net Thu Dec 30 12:50:29 1999 From: abrahams at mediaone.net (Dave Abrahams) Date: Thu, 30 Dec 1999 06:50:29 -0500 Subject: The Don Beaudry/Jim Fulton hack Message-ID: <9GHa4.1682$wG6.149869@ndnws01.ne.mediaone.net> Hi, I've recently been crawling through the source code (trying to understand what all those fields in PyTypeObject really do), and stumbled across an explanation for what I had read about being able to subclass a type extension in Python: there's special code to make this possible! Looking at the comment and code which follows... /* Call the base's *type*, if it is callable. This code is a hook for Donald Beaudry's and Jim Fulton's type extensions. In unexended Python it will never be triggered since its types are not callable. Ditto: call the bases's *class*, if it has one. This makes the same thing possible without writing C code. A true meta-object protocol! */ PyObject *basetype = (PyObject *)base->ob_type; PyObject *callable = NULL; if (PyCallable_Check(basetype)) callable = basetype; else callable = PyObject_GetAttrString( base, "__class__"); if (callable) { PyObject *args; PyObject *newclass = NULL; args = Py_BuildValue( "(OOO)", name, bases, methods); if (args != NULL) { newclass = PyEval_CallObject( callable, args); I think: it would be cool to experiment with this before writing any C code, just to make sure I understand it. So I fire up Python. Since the special code is never entered if the base is a real class (not shown), I figure it has to be an instance: otherwise, how could it have an attribute called "__class__"? >>> class Empty: pass ... >>> base = Empty() >>> base.__class__ = stupid_class Traceback (innermost last): File "", line 1, in ? TypeError: __class__ must be set to a class >>> But as you can see, you can't set the __class__ attribute of an instance to anything other than a class. So what have I missed? How am I supposed to get this to work "without writing C code"? Finally, another point. It is now possible to make extension classes which walk, talk, and smell just like built-in classes except for one important detail: as far as I can tell, there's no way to make is_instance work so that it returns TRUE for base classes. In other words, if I have an extension type "A" which is a "subclass" of another extension type "B", and an instance of "A", "a", is_instance(a, B) should be true. I don't think ther's any way to do that without a change to the Python source. -Dave From robin at jessikat.demon.co.uk Sun Dec 19 20:41:20 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sun, 19 Dec 1999 19:41:20 +0000 Subject: Tcl/Tk 8.2 References: <385D0C6D.D92B2F12@omnitechconsulting.com> Message-ID: In article <385D0C6D.D92B2F12 at omnitechconsulting.com>, Steve Simonet (Omni) writes >Python 1.5.2 on Windows does not appear to work out of the box with >Tcl/Tk 8.2, even after modifying TkFix.py to look for 82 rather than >80. Can this be overcome? > >-- Steve > there are some patches to _tkinter that need to be done to get 8.2 to work. Someone told me to look in the archive. -- Robin Becker From mgushee at havenrock.com Sat Dec 18 08:44:21 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 18 Dec 1999 02:44:21 -0500 Subject: Python locks up X References: <83dvvn$4d7$1@nnrp1.deja.com> Message-ID: sragsdale at my-deja.com writes: > For some reason, forking a child process and using Dialog.Dialog boxes > to call Frame.quit results in X locking up in both Irix and Linux > (Redhat 6.0). Anyone have a clue why this is happening? Is this sloppy > programming on my part or a bug in Tkinter? ... or a bug in X or your window manager? I don't have a clue *why* it's happening, but I don't get the same results. I have Red Hat 5.2. I tried your code in 4 different ways: 1) By doing 'execute-buffer' in XEmacs' python-mode. 2) By saving, 'chmod 755'-ing, and executing ./junk.py from an xterm/rxvt 3) By doing 'python junk.py' in an rxvt 4) By doing './junk.py &' in an rxvt In case 1, the OK button destroys the dialog immediately, while the main window remains for a short time before exiting with Xlib: unexpected async reply (sequence 0x1db)! In cases 2 & 3 (foreground execution), both Tkinter windows become zombies (? not sure of the correct term) and the shell prompt returns immediately. In case 2, the dead windows disappear after a few moments, while in case 3, they linger until I kill the Python process. In case 4, the 'click to lock X' button does nothing. In no case did X lock up, though things did get a little jerky with several cat processes running. Hope this helps a bit. -- Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ From stuarty at excite.co.uk Thu Dec 2 13:17:19 1999 From: stuarty at excite.co.uk (stuarty at excite.co.uk) Date: 2 Dec 1999 12:17:19 GMT Subject: breakout Message-ID: <825o0f$250$1@news.qub.ac.uk> Has anyone wrote a breakout(fairly manditory to have breakout) script in python yet ? From badzen at yifan.net Fri Dec 17 08:23:32 1999 From: badzen at yifan.net (dj trombley) Date: Fri, 17 Dec 1999 07:23:32 GMT Subject: problem with an infinite loop References: <8381in$de3@mail.psy.uva.nl> Message-ID: <3859E477.A639411@yifan.net> Ionel Simionescu wrote: > > Hi, > > The code below represents an erroneous snippet that crashes Python > (1.5.2/WinNT) in a very reproductible manner. > > Maybe this kind of error can be intercepted by the interpreter and raise an > exception. > > ionel > > --- > > # I know this code is bad. > > class node: > def __init__(self, name=''): > self.name = name > > def __setattr__(self, name, value): > if name=='name': self.name = value > > f = node() The answer here is to not assign to an attribute in the usual fashion, ie. ., but to directly access the object's dictionary. For example: if name == 'name': self.__dict__[name] = value -dj Dave Trombley From darrell at dorb.com Mon Dec 27 20:06:00 1999 From: darrell at dorb.com (Darrell) Date: Mon, 27 Dec 1999 14:06:00 -0500 Subject: Python suitability References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> <113901bf470c$cb236f60$0100a8c0@rochester.rr.com> <38654F5C.378F8338@maxtal.com.au> <005801bf4f7a$059ddf20$bf2b2bc1@martelli> <38664525.1D26C3D4@maxtal.com.au> Message-ID: <1e9c01bf509d$6a76a070$0100a8c0@rochester.rr.com> John Skaller wrote: > > I think Python scores well when it comes to making > small utilities, but it begins to fall apart for larger systems. > > Let me predict, for example, that Zope will become > almost unworkable soon: Python just cannot hack such a large > beast. C++ on the other hand, makes getting started > much harder, but it then scales better. The large scale idioms for C++ are well known. I'd love to read "Large Scale Python Software Design", when someone writes it. Component interfaces like COM or CORBA make big stuff work and Zope offers some such. Although I wonder if they have too many good ideas in one place. Even with the interpreter lock and no types, how much more scalable is C++ anyway ? Especially if someone would wrote the book for Python :) --Darrell From scherbi at bam.com Fri Dec 17 12:59:59 1999 From: scherbi at bam.com (Bill Scherer) Date: Fri, 17 Dec 1999 06:59:59 -0500 Subject: Python port on Open Edition References: <8E9EBCE5Etheistoperamailcom@207.69.128.201> Message-ID: <385A25BF.C718E4FA@bam.com> http://www2.s390.ibm.com/products/oe/python.html Theist wrote: > I was unable to find the Python binaries for IBM OS390 Open > Edition (a Unix variant running on IBM mainframes). Does > anyone know if there is such a thing? > > Thanks, > Raj > -- > http://www.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff Bell Atlantic Mobile -------------- next part -------------- A non-text attachment was scrubbed... Name: scherbi.vcf Type: text/x-vcard Size: 226 bytes Desc: Card for Bill Scherer URL: From efc1966 at hotmail.com Tue Dec 7 11:31:25 1999 From: efc1966 at hotmail.com (Dodgemasta) Date: Tue, 07 Dec 1999 02:31:25 -0800 Subject: look at this!! Message-ID: <384CE1FD.3B29163E@hotmail.com> LOTS OF CASH, FAST AND COMPLETELY LEGAL, THIS REALLY WORKS!! THIS REALLY CAN MAKE YOU EASY MONEY!!IT WORKS!!BUT YOU HAVE TO FOLLOW THIS LETTER FOR IT TO WORK!!!! A little while back, I was browsing through news groups, just like you are now,and came across an article similar to this that said you could make thousands of dollars within weeks with only an initial investment of 6.00!So I thought,"Yeah ,right,this must be a scam", but like most of us, I was curious, so I kept reading. Anyway,it said that you send $1.00to each of the 6 names and address stated in the article. You then place your own name and address in the bottom of the list at #6, and post the article in at least 200 news groups.(There are thousands) No catch,that was it.So after thinking it over, and talking to a few people first,I thought about trying it. I figured what have I got to loose except 6 stamps and $6.00, right?Like most of us I was a little skeptical and worried about the legal aspects of it all.So I checked it out with the U.S. Post Office (1-800-725-2161) and they confirmed it was indeed legal! Then I invested the measly $6.00. Well GUESS WHAT!!...within 7 days,I started getting money in the mail ! I was shocked! I figured it would end soon,but the money just kept coming in. In my first, week I made about $25.00. By the end of the second week I had made a total of over $1,000.00! In the third week I had over $10,000.00 and it's still growing.This is now my fourth week and I have made a total of just over $42,000.00 and it is still coming in rapidly.It's certainly worth $6.00 and 6 stamps.Let me tell you how this works and most importantly, why it works...also make sure you print a copy of this article NOW,so you can get information off of it as you need it. Believe me, it does work!! STEP 1: Get 6 separate pieces of paper and write the following on each piece of paper"PLEASE PUT ME ON YOUR MAILING LIST".Now get 6 US $1.00 bills and place ONE inside each pieces of paper so the bill will not be seen through the envelope to prevent thievery. Next, place one paper in each of the 6 envelopes and seal them.Now,you should have 6 sealed envelopes, each with a piece of paper stating the above phrase,your name and address,and a $1.00 bill. what you are doing is creating a service by this. THIS IS ABSOLUTELY LEGAL! Mail the 6 envelopes to the following addresses: #1) Justin 3707 Crenna Ave.Concord, CA 94519 #2) Chicollla 2 Oxford Mews, Poquoson VA 23662 #3) EZ Ads, P.O. Box 1274, Moses Lake, WA 98837 #4) Derek 1353 RR Street Grafton, WV 26354 #5)Valerie 21320 Parthenia St. #204, Canoga Park, CA 91304 #6) John, P.O Box 341 Alexandria ,NSW, Australia, 1435 (Be sure to use the correct postage when mailing to the the states or out of the states) STEP 2 : Now take the #1 name off the list that you see above,move the other names up (6 becomes five ,5 becomes 4 etc...) and add YOUR name as number 6 on the list. STEP 3 : Change anything you need to, but try to keep this article as close to original as possible.Now, post your amended article to at least 200 news groups. (I think there are close to 24,000 groups.) All you need is 200, but remember , the more you post the more money you make!---DIRECTIONS---HOW TO POST TO NEWS GROUPS--- STEP 1) You don't need to re-type this entire letter to do your own posting. Simply put your cursor at the beginning of this letter and drag your cursor to the bottom of this document,and select 'copy' from the edit menu. This will copy the entire letter into the computers memory. STEP 2) Open a blank "notepad" file under accessories in windows and place your cursor at the top of the blank page.From the 'edit' menu select 'paste'.This will paste a copy of the letter into notepad so that you can add your name to the list. STEP 3) Save your new notepad file as a .txt file.If you want to do your in different sittings, you will always have this file to go back to. STEP 4)Use Netscape or Internet explorer and try searching for various newsgroups (on-line forums, message boards, chat sites, discussions.) STEP 5) Visit message boards and post this article as a new message by highlighting the text of this letter and selecting paste from the edit menu. Fill in the Subject,this will be the header everyone sees as then scroll through the list of postings in a particular group!**REMEMBER,THE MORE NEWSGROUPS YOU POST IN,THE MORE MONEY YOU WILL MAKE!! BUT YOU HAVE TO POST A MINIMUM OF 200** That's it ! You will begin receiving money from around the world within days. You may eventually want to rent a P.O. Box due to the large amount of mail you will receive.If you wish to stay anonymous,you can invent a name to use, as long as the postman will deliver it. **JUST MAKE SURE ALL THE ADDRESSES ARE CORRECT.** Now the WHY part: Out of the 200 postings say I only receive 5 replies (a very low example). So then I made $5.00 with my name at #6 Now,each of the 5 persons who just sent me $1.00 make the MINIMUM 200 postings,each with my name at #5 and only 5 persons to each of the original 5, that is another $25.00 for me,now those 25 each make 200 MINIMUM posts with my name at #4 and only 5 replies each,I will bring in an additional $125.00! Now, those125 persons turn around and post the MINIMUM 200 with my name as #3 and I only receive 5 replies each,I will make an additional $625.00! OK,now here is the fun part,each one of those 625 persons post a MINIMUM of 200 letters with my name at #2 and they only receive 5 replies,that just made me $3,125.00!!! Those 3,125 persons will deliver this message to 200 news groups with my name at #1 and if still 5 persons per 200 news groups react I will receive $15,625.00! With the original investment of only $6.00! AMAZING! When your name is no longer on the list, you just take the latest posting in the news groups and send out another $6.00 to names on the list, putting your name at number 6 again. And start posting again.The thing to remember is, do you realize that thousands of people all over the world are joining the internet and reading these articles, everday,JUST LIKE YOU ARE NOW!! So can you afford $6.00 and see if it really works?? I think so ... People have said,"What if the plan is played out and no one sends you the money? So what! What are the chances of that happening when there are tons of new honest users and new honest users who are joining the internet and newsgroups every day and are willing to give it a try? Estimates are at 20,000 to 50,000 new users,every day ,with thousands of those joining the actual internet. Remember,play FAIRLY and HONESTLY and this will work. From n8grayCUTHERE at earthlink.net Fri Dec 10 18:52:44 1999 From: n8grayCUTHERE at earthlink.net (Nathaniel Gray) Date: Fri, 10 Dec 1999 09:52:44 -0800 Subject: Help setting up NumTut Message-ID: <38513DEC.47004307@earthlink.net> Hi everybody, I'm using Python 1.5.2 on WinNT. I'm trying to run the Numeric Python Tutorial (NumTut) but whenever I try to import it I get this: >>> from NumTut import * Traceback (innermost last): File "", line 1, in ? from NumTut import * File "C:\Program Files\Python\Lib\NumTut\__init__.py", line 14, in ? greece = pickle.load(open(os.path.join(_dir, 'greece.pik'), 'rb')) / 256.0 File "C:\Program Files\Python\Lib\pickle.py", line 826, in load return Unpickler(file).load() File "C:\Program Files\Python\Lib\pickle.py", line 495, in load dispatch[key](self) File "C:\Program Files\Python\Lib\pickle.py", line 659, in load_global klass = self.find_class(module, name) File "C:\Program Files\Python\Lib\pickle.py", line 669, in find_class raise SystemError, \ SystemError: Failed to import class array_constructor from module Numeric I have the Numerical Library installed at: C:\Program Files\Python\LLNLDistribution\Numerical and I have no trouble with the command 'from Numeric import *' Does anybody have any suggestions? Another curiosity -- I tried moving the NumTut subdirectory from Python\Lib to Python\LLNLDistribution\Numerical\Lib and when I tried the command again it failed with _exactly_ the same message, including the line: File "C:\Program Files\Python\Lib\NumTut\__init__.py", line 14, in ? This seems crazy, since NumTut wasn't even in that directory. If you can help please mail me, but remove the capital letters from my username before you hit send. Thanks a lot! -- Nathaniel A. Gray -- "But the sun is going down!" "No, no, you're all confused. The horizon is moving up." -The Firesign Theatre -- PGP Key: http://certserver.pgp.com:11371/pks/lookup?op=get&search=0x95345747 For PGP: http://www.pgpi.com/ From themantis at trojanslair.zzn.com Sun Dec 12 08:24:54 1999 From: themantis at trojanslair.zzn.com (Black Mantis) Date: Sat, 11 Dec 1999 23:24:54 -0800 Subject: cursors for Tk Message-ID: <38534DC5.82CEB43A@trojanslair.zzn.com> hello in Tkinter, you can set what type of cursor is displayed when the mouse is moved over an object eg. b=Button(root, text="hello world", cursor='cursor type') can someone tell me a list of all the cursor types available for a windows 95 machine? From paul at prescod.net Thu Dec 30 10:44:23 1999 From: paul at prescod.net (Paul Prescod) Date: Thu, 30 Dec 1999 04:44:23 -0500 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <386A1037.C6D458B3@prescod.net> <386a43e3.48679477@news.isomedia.com> Message-ID: <386B2977.467D8976@prescod.net> Eugene Goodrich wrote: > > .... > > Begging your pardon, but is it possible to make a class that looks > tuplish to users trying to access it by index but also exposes its > values via .properties? What incompatibilities with functions > expecting tuples would this code provide: (sorry for any bad wrapping) It is very close to possible to implement a Tuple type that allows both indexed and name based access. The only problem is that Python does not return keyword arguments to you in the order that they were specified. Paul Prescod From estama at ithaca.dbnet.ece.ntua.gr Thu Dec 16 19:51:05 1999 From: estama at ithaca.dbnet.ece.ntua.gr (Elefterios Stamatogiannakis) Date: Thu, 16 Dec 1999 20:51:05 +0200 Subject: Byte to integer conversion Message-ID: <38593499.5BD58BD1@ithaca.dbnet.ece.ntua.gr> How can i convert two, three, four bytes into an integer? I know a way with pickle, using loads() but i wonder is there a more elegant way of doing it. I don't care about big, little endian problems Elefterios Stamatogiannakis. From mhammond at skippinet.com.au Wed Dec 15 23:32:04 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 15 Dec 1999 22:32:04 GMT Subject: trying again: CgiHttpServer workalike for Win/NT and Win/98? References: <837o38$b65$1@serv1.iunet.it> Message-ID: Alex Martelli wrote in message <837o38$b65$1 at serv1.iunet.it>... >I thought I had posted this request (mailed it to the list, to >be precise), but it doesn't seem to have 'taken', so, I'm >trying again, via the NG this time -- sorry if it's a repeat. My guess is simply that noone has hacked this code to work on NT. >To test some CGI scripts with minimal hassle, I would like to >be able to run CgiHttpServer.py, or something similar to it, >on some Windows/NT and Windows/98 PCs. Unfortunately >for this purpose, it seems that CgiHttpServer.py itself is oriented >to Unix (e.g., it wants to fork to run the script). Which means your only solution may be to try and hack it. It should not be too hard to change CgiHttpServer.py to work on Windows if you make a few assumptions. But it looks like you are the first... Mark. From skaller at maxtal.com.au Mon Dec 13 22:36:35 1999 From: skaller at maxtal.com.au (skaller) Date: Tue, 14 Dec 1999 08:36:35 +1100 Subject: Python complaints References: <000201bf3bd4$2bda5e20$542d153f@tim> <38553B8B.822488D3@callware.com> Message-ID: <385566E3.69992E33@maxtal.com.au> Ivan Van Laningham wrote: > OK, I can understand the desire to eliminate lambda. Well, what is it? >But there are a > couple of points I'm not clear on. To illustrate, I offer an example. > 1) In the 'tm.add_command(...)' line, how would list comprehensions > replace the 'command=lambda m=elements[ne]:setimage(m)' ? How would > they work? Please explain for bears of very small mind;-) I think you misread a previous post. List comprehensions don't replace lambda, they replace map: assert map(f,seq) == [f(x) for x in seq] [I'll try adding that to Viper .. even better, if a lazy version can be done ..] Lambda can be replaced by using ordinary named functions. That is, it is entirely unnecessary already. It's just convenient, it saves cluttering up code. > 2) In the Pythonian world of today (or is this the "Postpythonian > world?"), how would one avoid the use of lambda and still use only one > callback to handle every constructed entry in the menus? you just define the function using 'def': replace for j in range(lim): ne = (10 * i) + j tm.add_command(label=elements[ne], command=lambda m=elements[ne]:setimage(m)) by for j in range(lim): ne = (10 * i) + j def cmd(m=elements[ne]): return setimage(m) tm.add_command(label=elements[ne], command=cmd) In fact, for syntactic reasons, lambdas (in C and J Python) are restricted compared to def -- they can only contain expressions, whereas def allows statements. -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From paulb at infercor.no Mon Dec 13 15:40:53 1999 From: paulb at infercor.no (Paul Boddie) Date: Mon, 13 Dec 1999 15:40:53 +0100 Subject: sites offering free webspace & Python scripting...? References: <82j8cc$qju$1@serv1.iunet.it> <82p1ak$fuu$1@nnrp1.deja.com> <38511FA3.D945E11F@infercor.no> Message-ID: <38550575.45A49DE8@infercor.no> William Burrow wrote: > > On Fri, 10 Dec 1999 16:43:31 +0100, > Paul Boddie wrote: > >> One of those (I forget which) doesn't even force you to show > >> their ads, although they do _ask_ it as a favour. > > > >That's http://www.prohosting.com, I think. > > What, you can get an account on prohosting nowadays? Try http://free.prohosting.com - that address coming from an e-mail they sent me two days ago. It took me a while to actually access my account when I originally attempted to acquire one, but they did become more responsive later on. Paul From fredrik at pythonware.com Tue Dec 7 09:41:30 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 7 Dec 1999 09:41:30 +0100 Subject: Video analysis with numpy... References: <007601bf3fe5$6f11c740$f29b12c2@secret.pythonware.com> Message-ID: <00ab01bf408e$dcd1bd90$f29b12c2@secret.pythonware.com> Les Schaffer wrote: > > it would be *very* nice if the multiarray module was added to the > > python core... (any volunteers?) > > i am confused by this question. i was under the distinct impression > that it is a top down decision (guido on down) on whether to integrate > multiarray into python. no? > or am i confusing a call for volunteers with a command level decision > to give go ahead to such project? does the latter already exist? http://www.foretec.com/python/workshops/1998-11/proceedings/guido/sld010.htm (he lists it under 2.0, but given that 1.6 is still not out there, I see no reason to wait that long. after all, adding this to the standard distribution doesn't really affect the interpreter that much...) From bernhard at alpha1.csd.uwm.edu Wed Dec 1 21:42:32 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 1 Dec 1999 20:42:32 GMT Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD81@gandalf.digicool.com> Message-ID: On 1 Dec 1999 18:27:33 GMT, William Tanksley wrote: .On Wed, 1 Dec 1999 09:41:21 -0500 , Brian Lloyd wrote: . .>> At any rate, SOAP provides a Simple Object Access Protocol. .>> Just what you .>> need. And it's essentially XML-RPC, and it's made to grok COM. . .>> Highly satisfactory. Now all we need is a truly open COM .>> implementation. . .>Maybe not - IMHO SOAP is a good step forward, since you will .>now be able to just implement SOAP-aware Python objects instead .>of mucking around with COM. You can still interoperate with .>existing COM objects - hey, you could even declare them to be .>"legacy" code :^) . .Yes, but you can only write COM objects on a COM-supporting platform. I'm .not aware of any freely available ones (although WINE might have .something, its docs don't mention it). . .I'm helping a friend implement COM for his OS, so I'm a bit grumpy ;-). .It's a cool system. I just read through a huge bunch of literature regarding the comparison of COM and CORBA. CORBA still seems to be more mature. The only reason to use COM is, if you want to interoperate with the Microsoftproduct world. The big part of the microsoft COM platform is the MTS (microsoft transaction server) if you want to do to distributed objects. Why not stick with CORBA and SOAP, where needed? :) Just my 0.02 Euro. Bernhard -- Research Assistant, Geog Dept UM-Milwaukee, USA. (www.uwm.edu/~bernhard) Free Software Projects and Consulting (intevation.net) Association for a Free Informational Infrastructure (ffii.org) From thor at localhost.localdomain Wed Dec 29 20:31:46 1999 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 29 Dec 1999 19:31:46 GMT Subject: Super Tuples [or why python is so good] References: <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <386A1037.C6D458B3@prescod.net> Message-ID: On Wed, 29 Dec 1999 08:44:23 -0500, Paul Prescod wrote: > > * why does Python need an immutable list type but not an immutable >dictionary? Because a tuple is the simplest way of saying: there are three things a,b,c and they're ordered thus: (a,b,c) There is no simpler way to say it. An inmutable dictionary... perhaps subclassing and removing __set__ ?? :) >has a special "meaning." The time library is a perfect example of this: > >"The time tuple as returned by gmtime(), localtime(), and strptime(), >and accepted by asctime(), mktime() and strftime(), is a tuple of 9 >integers: year (e.g. 1993), month (1-12), day (1-31), hour (0-23), >minute (0-59), second (0-59), weekday (0-6, monday is 0), Julian day >(1-366) and daylight savings flag (-1, 0 or 1)." > >The primary weakness with the time library is that you have to index >daylight savings flag by (for example) [9] instead of .daylight . This is a perfect example of what to do in those cases: index_year = 0 index_month = 1 index_day = 2 ... index_daylight = 9 time.asctime()[time.index_daylight] And this example is probably the only one that would justify such a thing. Being OO means that everything should be considered and object, so the more objects we use and in a clearer way ( defining them as objects ) the better for the purity of the language and uniformity of the code. Imagine that python would have a big set of iterators (loop's, while, selectors...) and a whole bunch of tuple,list or dicts functions ( think in Ruby list for examples ), then python would have lost most of its personality: a simple syntax. And instead of inter-object relationships we'd have simple algebraic relationships very nice for Haskell or any mathematic rubish but a disaster for those (like me) that like utter simplicity in the relationships: - *Many* objects linked by very simple constructs ( inheritance and has-to) - Each object simple enough to handle not too many relationships - Each object is linked to "a real world " idea or it's a clearly "defined" part of a "big" idea. I don't like those python codes that hold dozens of lines of code inside a function ( or hundreds of lines inside a class). Any change of syntax towards "algebraization"(haskellation/ mathematicalization) : many operators, many "abstractions", *long* formulae and so on, would be **really** nasty. Java is a cast oriented language, perl is a criptic oriented language, python is a simplicity oriented language, a complex python would not be python anymore. Having little but powerful enough constructs helps to the orthogonality of the code. A tuple behaving almost an object doesn't sound orthogonal. And it could turn into a nightmare. Imagine this: Step 1 ) We have tuples this way : o = (time= 23, name= "alfa", g = 1) Step 2) We allow keywords for those tuples t = (time = 23, name="alfa", g= 1).keys() would return time, alfa, g and constructs like t['time' ] = 28 Step 3) We allow procedures for those tuples def print_time(t): print t.time t = (t, print_time) # this means that print_time is associated with the tuple itself Well you see, after some steps we have tuples that behave like dicts, tuples or objects. Very different programming styles would arise and a poorer readibility of python code. -- Manolo From janssen at parc.xerox.com Wed Dec 1 04:31:47 1999 From: janssen at parc.xerox.com (Bill Janssen) Date: Tue, 30 Nov 1999 19:31:47 PST Subject: '==' vs. 'is' behavior In-Reply-To: Your message of "Mon, 29 Nov 1999 21:13:40 PST." Message-ID: <99Nov30.193151pst."3757"@watson.parc.xerox.com> Actually, the presence of "is" and "==" in Python is one of the nicer features. "is" is the Lisp "eq", while "==" is the Lisp "equal". These are really the two comparisons from Lisp that make the most sense. Java, on the other hand, only gives you "eql"! Ugh! Bletcherous! Bill From guido at CNRI.Reston.VA.US Wed Dec 22 21:00:19 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Wed, 22 Dec 1999 15:00:19 -0500 Subject: Two weeks Till Python Conference Early Bird Registration Deadline! Message-ID: <199912222000.PAA17264@eric.cnri.reston.va.us> We know that the Python conference isn't until the next millennium. You have exactly two weeks left to register and qualify for the early bird registration. Since most of that time most people are taking off for the holidays, it's really NOW OR NEVER! If you haven't registered and paid by January 5, you will paying full price... So, be smart and register NOW. Also don't forget to book your hotel room by January 3. Some highlights from the conference program: - 8 tutorials on topics ranging from JPython to Fnorb; - a keynote by Open Source evangelist Eric Raymond; - another by Randy Pausch, father of the Alice Virtual Reality project; - a separate track for Zope developers and users; - live demonstrations of important Python applications; - refereed papers, and short talks on current topics; - a developers' day where the feature set of Python 2.0 is worked out. Our motto, due to Bruce Eckel, is: "Life's better without braces." Come and join us at the Key Bridge Marriott in Rosslyn (across the bridge from Georgetown), January 24-27 in 2000. Make the Python conference the first conference you attend in the new millennium! The early bird registration deadline is January 5. More info: http://www.python.org/workshops/2000-01/ The program is now complete with the titles of all presentations. There is still space in the demo session and in the short talks session. --Guido van Rossum (home page: http://www.python.org/~guido/) From trosen at activmedia.com Mon Dec 20 23:01:53 1999 From: trosen at activmedia.com (trosen) Date: Mon, 20 Dec 1999 22:01:53 GMT Subject: creating dragable objects Message-ID: <83m90e$ipt$1@nnrp1.deja.com> Hello all, I'm trying to make a program, using wxPython, that will allow me to specify the size of an object in a window. The program makes the object. (just enter the upper right, lower left or something similar) That part is easy. Let's say the object I make is a rectangle. I want to be able to click on one of the sides of the rectangle, and drag the rectangle do a different size. Does anybody know how I would go about accomplishing this using wxPython? Is it possible? are there any example programs that accomplish this? Any help would be greatly appreciated! Thanks in advance -- Michael Trosen ActivMedia Robotics www.activrobots.com trosen at activmedia.com Sent via Deja.com http://www.deja.com/ Before you buy. From malcolmt at smart.net.au Wed Dec 22 01:01:07 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Wed, 22 Dec 1999 11:01:07 +1100 Subject: strptime on Unix systems Message-ID: <19991222110107.A972@Ridcully.home> On a Linux technical support mailing list I am on, somebody recently posted a question about Python and although I was able to answer it, the logic behind the answer has me stumped: The following does *not* work under Linux (at least): import time format = '%a %b %d %H:%M:%S %Z %Y' t = time.localtime(time.time()) timestring = time.strftime(format, tt) # Works OK timetuple = time.strptime(tt, format) # Throws ValueError The reason for this problem is that strftime and strptime are based on their C-library counterparts and according the man pages, while strftime does take a %Z modifier in the format string, strptime does NOT understand this modifier. (so you can remove the %Z from format and the above snippet is fine.) Two questions: (1) What is the story on other Unix systems? Is this a general problem (I hope not)? (2) Is there any logic hidden behind the fact that one direction takes %Z and the other does not? Cheers, Malcolm Tredinnick -- Telepath required. You know where to apply... From kahn at cena.dgac.fr Fri Dec 3 17:44:12 1999 From: kahn at cena.dgac.fr (Julien Kahn) Date: Fri, 3 Dec 1999 17:44:12 +0100 Subject: Using open() under Window 97 Message-ID: <828s0t$ad6$1@ilana.cenaath.cena.dgac.fr> This program run under UNIX import string tab_line=[] # ouverture du fichier f=open('sol.txt','r') # parcours du fichier line=f.readline() while line : tab_line.append(string.split(line,';')) print tab_line[-1] line=f.readline() f.close() but under Window, even if the file is in current directory I've got the fallowing message: Traceback (innermost last): File "C:\PROGRA~1\PYTHON\TOOLS\IDLE\ScriptBinding.py", line 131, in run_module_event execfile(filename, mod.__dict__) File "C:\Utilisateurs\Julien\CENA\trafic\convertisseur.py", line 8, in ? f=open('sol.txt','r') IOError: [Errno 2] No such file or directory: 'sol.txt' Thanks Julien From torppa at polykoira.megabaud.fi Thu Dec 30 23:04:05 1999 From: torppa at polykoira.megabaud.fi (Jarkko Torppa) Date: 30 Dec 1999 22:04:05 GMT Subject: Compiling python with threads References: <386B5F2D.989A0C13@concreteillusions.fi> Message-ID: <84gksl$4um$3@news.kolumbus.fi> In article <386B5F2D.989A0C13 at concreteillusions.fi>, Joonas Rapila wrote: >Hi. > >If someone knows what I could be doing wrong, please let me know. >The problem is that I don't manage to compile Python on NetBSD with >Thread support. I'v both tried by doing it trough the package management >tool (pkg_add) (there it instals, but with pkg_add >I don't know how to give it options, i.e, getting it to compile w/ >thread support) and the source code. I'v got Pth (The Gnu Portable >threads), so it should (or should it.. :) compile ok. Well anyways, I'd >be grateful for any tips, even if anyone knows a good place to start >searching futher.. thnx. I did this a while ago, but because of the way pth is written I dont think it will do any good without modifying python source. This is sadly more of a NetBSD question that python one, thread support in NetBSD is in quite sorry state. And I were unable to get python to work with two other userthread libraries I tried (ptl2 and mit-pthreads). -- Jarkko Torppa torppa at staff.megabaud.fi Megabaud Internet-palvelut From ivanlan at callware.com Mon Dec 20 21:25:15 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 20 Dec 1999 13:25:15 -0700 Subject: Is there a debugger tutorial? Message-ID: <385E90AB.B1296AA8@callware.com> Hi All-- Has anyone written a tutorial for pdb, the Python debugger? I'm not volunteering to write one, I just want to see if there _is_ one out there that I can reference. Take care, 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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From simon at george.maths.unsw.edu.au Wed Dec 1 02:07:49 1999 From: simon at george.maths.unsw.edu.au (Simon Evans) Date: 1 Dec 1999 01:07:49 GMT Subject: Plotting a single pixel (possible newbie question) Message-ID: <821sd5$7h0$1@mirv.unsw.edu.au> I'm relatively new to Python, which I use for several small numerically-oriented projects that are refreshingly different from my workday giant Fortran simulations. I've installed and used both Tkinter and DISLIN (a scientific graphing extension), but what I'm really missing is the ability to do the simplest graphics task of all: lighting up a single pixel. You'd think it wouldn't be too much to ask... Does anyone know of a graphics extension that offers this simple facility, or a method of doing it in the ones I have? I'd like to do it by some other method than drawing a line with a length of one pixel! ================================================================= Simon Evans (simon at maths.unsw.edu.au) Physical Oceanography Group School of Mathematics, University of New South Wales, Australia. ================================================================= From m.faassen at vet.uu.nl Thu Dec 2 19:39:16 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 Dec 1999 18:39:16 GMT Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> <38467727.BC269134@callware.com> Message-ID: <826eck$bre$2@newshost.accu.uu.nl> Ivan Van Laningham wrote: [snip] > However, if you're an astronomer, a calendar freak, or a logician, you > might find yourself working in what has lately become known as the > Common Era calendar, simply because the math is far easier when there's > a year 0, and you don't have to "special case the snot out of > everything." The timeline then becomes: > BCE--------0---------CE > BCE = Before the Common Era; years negative, i.e., -1 on back > CE = Common Era; years positive, 1 forward > Thus, years 0-99 form the "first century CE"; year 0 through -99 form > the "first century BCE"; and so on. 0-999 is the first millennium, > 1000-1999 the second, 2000-2999 the third. Cool, these astronomers, calendar freaks and logicians must have read my previous post, as this is just the proposal I've sent off to the W3C! (though I add an XML implementation of course :) > This of course begs the question "where the hell is century zero"? ;-) > I think the argument will go on for at least another millennium. ... After that the programmers will win! Muahaha! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From alex at magenta.com Thu Dec 9 11:40:20 1999 From: alex at magenta.com (Alex Martelli) Date: Thu, 9 Dec 1999 11:40:20 +0100 Subject: some random reflections of a "Python newbie": (1) books, and free sites Message-ID: <82o0to$6eq$1@serv1.iunet.it> I've started playing with Python (starting with a strong background in C++, Perl, and sundry other matters), and I would like to share a few reflections, in the hope that I'll receive help on some of them, perhaps stimulate useful action with others, and maybe (through either my reflections, or, more likely, ensuing debate) be of some help to other newbies, too. (Btw, my newsfeed's flaky -- if it were possible to cc me on any reply posts, I'd be grateful -- TIA!) Please consider "IMHO"'s to be liberally inserted in what follows, of course!-). In this post, I cover 2 things (executive summary:-): 1. what put me off Python for so long? Short answer: the book "Programming Python" did. 2. there appear to be no providers of free webspace that will let one put Python scripts behind the pages, while, if one wants to use Perl instead, some can be found -- and I find this to be a real pity. Other issues, more about language and less about environment, I'll pursue in a separate post later. OK, here come my ramblings...: 1. why just now? Why didn't I start playing with Python much earlier? After some introspection, I think I can answer: the book "Programming Python", which I read quite a while ago, _put me off_. I've tried re-reading it now, with a better grasp of Python, and still find it chaotic and offputting. The contrast with "Programming Perl", which I find a very, very well written book, could not be stronger. A language as _clean_ as Python deserves a better, _cleaner_ book. And it's got it, too -- "Learning Python" is _MUCH_ better. "Internet Programming with Python", while burdened under a _truly_ silly title (whose idea was it...?), is also the kind of book that really makes one itch to go and try out the powerful, beautiful things it's explaining -- I'm happy I overcame the strong reluctance to try it, that the title initially gave me. It's no doubt a matter of taste -- I do _not_ like books, which purport to be introductions to a language, which try to teach by presenting "true" and/or "significant" applications prematurely; my taste runs strongly towards _simplified_ examples, "toy" ones if you will, that show the language's features more starkly, without mixing them up with application-domain-dependent issue. It's also why, e.g. in the realm of C++ books, I love Lippmann & Lajoie's Primer, Eckel's "Thinking in C++" 2nd ed, and Meyer's "Effective C++" (CD), _vastly_ more than Stroustrup's "C++ Programming Language". There is, of course, a time and place for "significant" examples -- but it's not "right off the bat". IMHO, as usual, and I know people whose tastes run strongly towards the other extreme. Books matter -- a lot. I just got the "Top 10 of 1999" list of computer books from amazon.com: out of the 10, 3 are about Perl, 3 about Java, 1 about C++, 2 about object-oriented design, 1 about relational databases. Mostly a reflection on the popularity of the subjects, I guess, but, to some extent, of the books' quality too -- and such lists will tend to make even more people read those books (an example of what economists call a "network effect" -- a term which predates the Internet, and describes products that become more valuable to each user when they have more users, in a "positive feedback" kind of loop). I'll do what I can (not much) by posting my reviews to amazon &c, with cross-pointers to the books I liked from those I didn't, and by recommending to those who ask. Maybe the www.perl.org site should host book reviews too, helping newbies choose the book that might be most appropriate for them, else the natural tendency might be to go for "Programming Python" and away from one, hard to get hold of by now and sounding by its titlte as if it's only about one specific application area, such as "Internet Programming with Python". 2. apparently, no free webspace providers support Python scripting I asked about it here the other day, got zero answers, and meanwhile diligently combed the net looking for one. No such luck. If one wants to write _Perl_ scripts, fine -- it takes some looking, but one can find half a dozen providers that will let you do it, some even without imposing their ads on your pages. I've asked each and every one of them if they would consider adding Python too -- apparently, none is interested. I find this to be a real pity. I would like to make freely available, to the interested segment of the public, certain computations, and being able to place them as scripts behind a free webpage would be a splendid way to serve them up. And I want to redo them in Python from the rather chaotic Perl version (and the reduced-functionality C++ version) I have now, too. But I do not know how to do both things... it's either keep them in Perl, or give up the idea of having them as scripts behind a free webpage. More details... the realm of these computations is analysis of probability values in the game of contract bridge. I have some classic computations wrapped up in a VC++ application that can be freely downloaded from my webpage; I have a much more advanced/innovative set of ideas, packaged as a somewhat chaotic ramble of Perl scripts and ad-hoc C thingies (not very well integrated with each other), which allowed me to get some results that are being published in the prestigious "The Bridge World" (Jan 2000 issue), where the editor described them as "taking a giant step" towards the resolution of certain age-old issues in the game's theory. But I really cannot distribute that mess of fragile code -- I _have_ to re-do it "properly". Python would be a natural for this. Among other things, having long-integers available would enable a very simple approach to the combinatorial computations I need -- with longs, computing, say, the factorial of 52, if and when needed, is no problem at all... what a wonderful thing! However, packaging things up for distribution as Python scripts would mean any interested users would have to install Python -- and, with Python 1.5.2, on Windows98, I keep getting strange crashes and blocks (with any of IDLE, python.exe, and PythonWin) -- I cannot really recommend it to people not very knowledgeable about computers to start with (on Win/NT, no such problems, but /98 is what most people will have) -- the release notes of PythonWin's current version even mention that, although those of the other environments don't. Perl is more widely installed, and more solid on /98 right now, but only a partial solution; to reach a wider audience of bridge analysist and theoreticians interested in trying out my ideas, I really need to distribute a more "stand-alone" packaging... OR, and that would, I think, be just the ticket, I could place some programs as CGI scripts (or other, more efficient ways of allowing remote execution on the web). But, apparently, this latter option does not exist now, unless I'm willing to write my stuff in Perl, or, I guess, to spend money to purchase some "professional" web-serving (which apparently does not come cheap). This is a real pity from my POV. Such a deployment would be, not a "killer" app for Python, for sure, but, maybe, some sort of "jaywalker" app, which might let Python gain a foothold in some niche (you'd be surprised at how many bridge players, particularly within that subset interested in analysis, theoretical questions, etc, are in the computer field:-). I wonder if the Python community, or some individuals within it, are interested in this issue, of "showcasing" Python's abilities in this way. Or maybe I'm the only skinflint who balks at spending money for web pages (programmable in Python) which I could get for free (if I would program them in Perl instead)...? Alex From neelk at brick.cswv.com Wed Dec 8 01:33:41 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 8 Dec 1999 00:33:41 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: Samuel A. Falvo II wrote: >In article , Neel Krishnaswami wrote: >>parenthesized s-exps is why Lisp has a macro system that does not >>suck -- Lisp macros are essentially transformations of the abstract >>syntax. And that macro system is why even novel ideas can always be >>expressed cleanly in Lisp. > >Forth has much the same capabilities without the use of parentheses. In >fact, it uses zero punctuation at all. :-) Does every Forth word have a fixed number of arguments? That seems like the only way it could work. I have to admit to being a weakling in this regard though: I have trouble reading pre/post-fix linearizations of syntax trees and usually end up manually adding parens so I can figure out the structure. My brother claims that Forth is a language that basically did the opposite of Lisp at every design point (eg, no garbage collection, postfix syntax, close-to-the-metal rather than highly abstract, etc) and therefore proves by example that Lisp is not the sole right way to design a language. He goes on to say that he's a bit worried by the fact that it's the *only* counterexample he has found.... :) Neel From alex at magenta.com Wed Dec 29 22:39:36 1999 From: alex at magenta.com (Alex Martelli) Date: Wed, 29 Dec 1999 22:39:36 +0100 Subject: newbie question... References: <3869229B.C06B94E5@earthlink.net> <3869298b.8634305@news.isomedia.com> <00a901bf51f3$499c8340$f29b12c2@secret.pythonware.com> <386a5461.52901207@news.isomedia.com> Message-ID: <016e01bf5245$e103b1c0$db2b2bc1@martelli> Eugene Goodrich writes: > I don't know why I tend to shy away from the while (1): in what I > consider "simple" cases. I use it plenty in larger loops. I do know why _I_ try hard to avoid it -- it's *ugly*!=) Yep, I _am_ used to having to trot out the C/C++ equivalent: for(;;) ... or while(1) ... (I prefer the former, btw) -- oh btw, you don't need those parentheses in Python: while 1: will do just as well -- but often in C++ I can have while(!finished(nextitem = stepperfunc())) { // ... rather than the more spread-out while(1) { nextitem = stepperfunc(); if(finished(nextitem)) break; // ... and, since Python is mostly higher-level that C++, it rankles to have to resort more often to a lower level, more roundabout expression of the concept. I'm more and more happy with the wrapped version: for nextitem in enum(stepperfunc, finished): with the enum wrapper I posted recently -- now my mission in life is to make this a _common_ Python idiom so people will start recognizing it!-) > My inclusion of unnecessary parameters in some places comes from not > always knowing the defaults and a desire to help out some of the less > clueless readers of my code - like me 60 days after I write it :) ...and who says it's a bad practice...? Unnecessary _parentheses_ otoh mark the newbie out (me just as well as you, of course:-). > Thanks for the clue to use while (1) on the file reading. Jeez, I > can't believe I've been using that lame prep code for so long. Gotta > lay off the crack. The repeated-stepping idiom you used: nextitem = stepper() while nextitem: process(nextitem) nextitem = stepper() is actually best-practice in languages wich refuse to have a 'break' statement (as well as assigning-expressions), such as standard Pascal. And, to me: while 1: nextitem = stepper if not nextitem: break process(nextitem) is no big improvement -- one line longer (and Pythonistas do seem to frown on the one-line form of if/break) and less direct to boot. for nextitem in enum(stepper): process(nextitem) now THAT is progress -- and, for this simple case, class enum: def __init__(self,stepper): self.stepper=stepper def __getitem__(self,key): nextitem=self.stepper() if not nextitem: raise IndexError return nextitem is all the wrapper you need... buy now, while supplies last!-) Alex From nobody at nowhere.nohow Tue Dec 7 17:19:54 1999 From: nobody at nowhere.nohow (Grant Edwards) Date: Tue, 07 Dec 1999 16:19:54 GMT Subject: Need python mode for Jed Message-ID: Could somebody point me to a copy of pymode.sl v1.3? It was posted a month ago, but trying to get it from deja.com always screws up the file somehow. I couldn't find it on the jed home page either. Thanks -- Grant Edwards grante Yow! That's a decision at that can only be made visi.com between you & SY SPERLING!! From bwarsaw at cnri.reston.va.us Wed Dec 8 06:13:38 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Wed, 8 Dec 1999 00:13:38 -0500 (EST) Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: <14413.59650.177134.276091@anthem.cnri.reston.va.us> >>>>> "SAF" == Samuel A Falvo, II writes: SAF> Yet, combined with colon definitions, immediate words, and SAF> the EVALUATE word, Forth's execution model can rival, and in SAF> some cases, exceed, Lisp's own macro subsystem. I haven't written any Forth in nearly 15 years, but before I started hacking Python I don't think I had as much fun with any other language (well, Lisp ironically comes close as does Objective-C). I worked with some great Forth hackers at the time, and it was truly amazing what could be accomplished with what today would be a laughingly tiny memory footprint. -Barry From junkster at nospam.rochester.rr.com Wed Dec 15 23:27:27 1999 From: junkster at nospam.rochester.rr.com (Benjamin Schollnick) Date: Wed, 15 Dec 1999 22:27:27 GMT Subject: Help?? Struct packing of Date time not has stopped working??!?! References: <835mvi$62t$1@nnrp1.deja.com> <38579924@194.120.211.23> Message-ID: On Wed, 15 Dec 1999 13:30:14, "Klaus Baldermann" wrote: > One of my first Python exercises was a (rdate) client. > It had the problem that the read_all() sometimes > returned less than 4 characters. > This happened only intermittently, so I simply > put a loop around the thing: The problem is that this does not appear to be happening intermittently. Both !L, & !d (Long, and Double), were not unpacking correctly. Which seemed strange, but I just tried again today, and it appears to be working okay.... > Of course, this is most inelegant solution (might even take looong), > and I still don't know what the reason was/is. I thought about nulls '\0', > but now I think it might have to do with newlines. What will telnetlib's > read_all() > return if the data is containing newlines? Will it return a string with > embedded \n's > or a list of strings, like a file's readlines() method? I'm starting to favor your comment here.....As a possible point of attack. Is there someway to have telnetlib return BINARY data directly? Or hex encoded, etc? That way the return/linefeed's are not corrupting data? I'll have to examine the telnet library, and see if there is some provision for that.... - Benjamin From ava at dde974.equipement.gouv.fr Wed Dec 22 14:13:51 1999 From: ava at dde974.equipement.gouv.fr (Ava) Date: Wed, 22 Dec 1999 17:13:51 +0400 Subject: how to use win32wnet.WNetAddConnection2 ? Message-ID: Hello, Under Windows 98 and Python 1.5.2, I'm trying to use win32wnet.WNetAddConnection2: server is a windows NT server 4.0 SP3, member of a domain where I am logged as user/pass. >> import win32wnet >> win32wnet.WNetAddConnection2(1, 'e:', '\\\\server\share$', None, 'user', 'pass') Traceback (innermost last): File "", line 1, in ? win32wnet.WNetAddConnection2(1, 'e:', '\\\\server\share$', None, 'user', 'pass') TypeError: argument 4: expected string, None found this is different from the doc (in Python/Win32/demos/win32wnet/netresource.htm), which says that Provider can be None. Anyway: >> win32wnet.WNetAddConnection2(1, 'e:', '\\\\server\share$', '', 'user', 'pass') Traceback (innermost last): File "", line 1, in ? win32wnet.WNetAddConnection2(1, 'e:', '\\\\babouck\data$', '', 'Ava', 'ava') api_error: (87, 'WNetAddConnection2', 'Param\350tre incorrect.') Can someone tell me what I am doing wrong? Thanks in advance, Jephte CLAIN minf7 at educ.univ-reunion PS: please CC: to me, I am not on the list From hiro at dagram.tdh.qntm.com Mon Dec 20 22:02:58 1999 From: hiro at dagram.tdh.qntm.com (Hirofumi Furusawa) Date: 20 Dec 1999 21:02:58 GMT Subject: Why can pyhton deal with a big project? References: <83lutn$sfn$1@news3.dti.ne.jp> <19991220142820.A25651@quark.emich.edu> Message-ID: <83m5i2$3qk$1@news3.dti.ne.jp> > >check out http://www.python.org/.. it has an online copy of the available >documentation, links to other sites, and contributed modules. you may also >want to look at the archives of comp.lang.python on dejanews or your >favorite usenet archive. > >hope that helps. > Before the previous post I read through the FAQ file but I cannot find my answer. But this time I found there is search page. I found the page titled "Comparing Python to Other Language". That says in the section of comparing to Tcl: Tcl also lacks features needed for writing large programs, such as modular namespaces. Now I understand Tcl lacks namespace management. To tell the truth, I don't know about Tcl or Perl. This time I want to learning the 3rd language followed C, shell-sed-awk and puzzling among popular scripting languages. Also I don't know very much about Perl for larger project. Can you say perl lacks namespace ability same as Tcl? If so, I can easily decide my way to go :) thank you. -- _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ _/ Hirofumi Furusawa _/ _/ Home - fsawa at remus.dti.ne.jp _/ _/ School - y8a1198 at students.chiba-u.ac.jp _/ _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ From jae at ilk.de Thu Dec 9 19:25:38 1999 From: jae at ilk.de (Juergen A. Erhard) Date: Thu, 09 Dec 1999 19:25:38 +0100 Subject: getopt patch Message-ID: <09121999.2@sanctum.jae> Hi, Getopt as in python 1.5.2 is incomplete (compared even to getopt/getopt_long in glibc2). I've looked at some of the alternative getopts, but found that they deviate too much from getopt's simple interface. So, I decided to hack getopt.py itself. Here's a list of the changes: + correctly (I hope) handles options following arguments. That's prog arg1 arg2 --option The old getopt treated the --differently as an argument. + handles long options with conditional arguments. Instead of a "=", you append ":" for those. So, getopt.getopt(sys.argv[1:], "", ["verbose:"]) would accept both `--verbose=extreme' and `--verbose'. (Sorry, short options not handled... I tend not to use them anyway) Those were the things I *wanted* real bad. Now for the fun stuff (while I was hacking it...) + setting getopt.return_dictionary makes getopt return the options as a dictionary instead of a list. Multiple occurences of the same option are collected in a list. So, for prog --long --long we'd get ({'--long': ['', '']}, []) + setting getopt.return_dictionary_all_lists is similar to return_dictionary, but the values in the dict are all guaranteed to be lists (even single strings). Might be more handy than return_dictionary alone... + setting getopt.return_in_order makes getopt return one list with all the arguments and options in the order in which they appear on the command line. And now, without further ado, here's the diff (and remember, corrections and further patches are always welcome...) 8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8< --- getopt.py 1999/12/09 16:54:47 1.1 +++ getopt.py 1999/12/09 18:16:47 @@ -17,6 +17,15 @@ import string error = 'getopt.error' +version = "19991209" + +# Return options as a dictionary +return_dictionary = 0 +# All entries in the dict are lists (even if there's only one element +return_dictionary_all_lists = 0 +# Return only one list, with opts and pure args in order +return_in_order = 0 + def getopt(args, shortopts, longopts = []): """getopt(args, options[, long_options]) -> opts, args @@ -50,16 +59,47 @@ def getopt(args, shortopts, longopts = [ else: longopts = list(longopts) longopts.sort() - while args and args[0][:1] == '-' and args[0] != '-': + if not return_in_order: + newargs = [] + while args: + # -- terminates option processing if args[0] == '--': - args = args[1:] + if return_in_order: + opts = opts + args[1:] + else: + newargs = newargs + args[1:] break if args[0][:2] == '--': opts, args = do_longs(opts, args[0][2:], longopts, args[1:]) - else: + elif args[0][:1] == '-': opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:]) + else: + if return_in_order: + opts.append(args[0]) + else: + newargs.append(args[0]) + del args[0] - return opts, args + # Create result dictionary + if (return_dictionary or return_dictionary_all_lists) and not return_in_order: + optdict = {} + for opt, arg in opts: + if return_dictionary_all_lists: + optdict[opt] = optdict.get(opt, []) + optdict[opt].append(arg) + else: + if optdict.has_key(opt): + if type(optdict[opt]) == type(""): + optdict[opt] = [optdict[opt], arg] + else: + optdict[opt].append(arg) + else: + optdict[opt] = arg + return optdict, newargs + elif return_in_order: + return opts + else: + return opts, newargs def do_longs(opts, opt, longopts, args): try: @@ -71,6 +111,7 @@ def do_longs(opts, opt, longopts, args): has_arg, opt = long_has_args(opt, longopts) if has_arg: if optarg is None: + if has_arg == "required": if not args: raise error, 'option --%s requires argument' % opt optarg, args = args[0], args[1:] @@ -91,8 +132,10 @@ def long_has_args(opt, longopts): if y != '' and y != '=' and i+1 < len(longopts): if opt == longopts[i+1][:optlen]: raise error, 'option --%s not a unique prefix' % opt - if longopts[i][-1:] in ('=', ): - return 1, longopts[i][:-1] + if longopts[i][-1] == "=": + return "required", longopts[i][:-1] + elif longopts[i][-1] == ":": + return "optional", longopts[i][:-1] return 0, longopts[i] raise error, 'option --' + opt + ' not recognized' 8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8<--8< -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 MARS: http://Juergen_Erhard.tripod.com/mars_index.html "Ever wonder why the SAME PEOPLE make up ALL the conspiracy theories?" -- Michael K. Johnson From e.e.sutton at cummins.com Wed Dec 8 18:25:21 1999 From: e.e.sutton at cummins.com (e.e.sutton at cummins.com) Date: Wed, 08 Dec 1999 17:25:21 GMT Subject: Where can I find info on IDispatchEx() References: <1267780385-12582932@hypernet.com> Message-ID: <82m49p$fa5$1@nnrp1.deja.com> > Also look at IDispatchEx() - targetted more for "dynamic" objects. Where can I find info on IDispatchEx()? I am not having much luck on MSDN. I want to write a COM object that can dynamically create interface methods which appear as "properties" to a VB script user. This is apparently being done in PerlCOM. In an article titled "Examing PerlCOM, Perl meets Microsoft's COM" by Mike McMillian Dr. Dobb's Journal, January 2000, page 84 A variable named "greet" is added to the PerlCOM object and then it is accessed from VB as a property. See example below: Dim objPerl As Object Set objPerl = CreateObject("PerlCOM.Script") objPerl.EvalScript '$greet = 'Hello, world.\n';" 'Display greeting in a message box. *** It is used like a property! *** MsgBox objPerl.greet 'Change greeting. *** Again it is used like a property! *** objPerl.Greet = "Welcome." Any tips or suggestions on how to research this (I'm using C++) is much appreciated. Thanks in advance, Ed Sutton e.e.sutton at cummins.com Sent via Deja.com http://www.deja.com/ Before you buy. From grant at nowhere. Thu Dec 23 22:09:10 1999 From: grant at nowhere. (Grant Edwards) Date: Thu, 23 Dec 1999 21:09:10 GMT Subject: __init__ keyword param for sub-class? References: <14434.30055.405044.204758@weyr.cnri.reston.va.us> <14434.32576.62080.865071@weyr.cnri.reston.va.us> Message-ID: Fred L. Drake, Jr. wrote: >the only way to resolve it is to use the same search pattern as normal >method lookup in C.__bases__. But it's not clear that its a good >idea. I guess it depends on how often multiple inheritence is used. I come from a single-inheritence background (Smalltalk and Modula-3), and haven't looked at enough Python code to have a feel for that question. Worst case is you have to explicitly specify the super-class if you want to guarantee which one of multiple possiblities is chosen. Users of MI are then no worse off than they are now -- and it would benefit the rest of us that do things the "right" way. ;) [I'll admit, I can see that MI could be useful.] > There's also an issue of introducing new keywords or some way to >name the thing called "super" in my example. I don't know of any >languages that let you name it within; they all seem to use a >keyword. And introducing new keywords is *hard*; Yup, adding a keyword to a language is going to break programs, and pretending otherwise is delusional. So, I don't see that it would be a good idea unless it is part of a major change that's going to break programs anyway. -- Grant Edwards grante Yow! I wish I was on a at Cincinnati street corner visi.com holding a clean dog! From darrell at dorb.com Wed Dec 15 15:58:05 1999 From: darrell at dorb.com (Darrell) Date: Wed, 15 Dec 1999 09:58:05 -0500 Subject: Python suitability References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> Message-ID: <113901bf470c$cb236f60$0100a8c0@rochester.rr.com> Python is easy to learn and very nice for at least the largish project I just finished. We had a max of four Python developers at one point and the first release took about eight months. This doesn't sound large from a C++ prospective, I know. But the same project in C++ would have been a much larger undertaking. Not just in the amount of code but the number of developers and associated problems. The quality of our code for the second release was vastly better than the first. Learning to write good Python took a while. Some things I noticed that effect most everything. 1. Deciding on a directory structure and whether or not to use packages was a big debate. Importing the wrong module of the same name is a problem. Someone installs the latest cool Python thingie and your application stops working. 2. Memory management is easy, but test for memory leaks. Or just massive memory usage. It's easy to eat huge amounts of memory or for some module to tuck away references that can't be freed. 3. Slicing and dicing huge strings is a performance problem. When we first started everyone was slicing and pasting with a+b+c. Don't do that. We came up with a Python solution though it required a lot of code rework. It wasn't until integration that we noticed the problem ! 4. Exceptions, error messages and debug control were vastly improved in the second release. My first attempt was just way too complicated. Python lends it's self to simple solutions, that aren't always obvious to a the reformed C++ developer. 5. We have only one C++ extension module even though I wanted to write more. Seems that what we have is fast enough, at least for what they want to pay. 6. Many of the things you do in C++ are to over come it's own limitations. Such as the Visitor pattern that gets written up in the C++ report every other issue. For the most part it solves a problem of C++. How to stop thinking in C++ and start doing things the Pythonic way takes a while. Find an experienced Pythonist who can review code and designs. Go for it, but remember there are no silver bullets, software is hard. --Darrell From mjackson at wc.eso.mc.xerox.com Fri Dec 3 22:45:24 1999 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 3 Dec 1999 21:45:24 GMT Subject: indentation References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> Message-ID: <829dlk$12p$1@news.wrc.xerox.com> "Fred L. Drake, Jr." writes: > Gerrit Holl writes: > > As i said: people who start with Python as a first language like it. > > There are those of us who started with x86 assembly and BASIC who > like it too! (And Pascal, and C, and C++, and... hey, how many places > can one person start in, anyway? ;) And Fortran. Don't forget Fortran. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson It doesn't matter that I'm a crab! I'm an Internet visionary! - Hawthorne (Jim Toomey) From ajung at sz-sb.de Tue Dec 28 09:37:36 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Tue, 28 Dec 1999 09:37:36 +0100 (MET) Subject: Problem getting output of subprocesses with commands.getstatusoutput() Message-ID: I am trying to get the output of a python script and its children (the childrens are fork()ed from the main python script) via commands.getstatusoutput(). There is the following misbehaviour of the commands module: - when I call commands.getstatusoutput() from python script that is startet from a shell I get the complete output of the called script and its children - when the same script is started from cron I get only the output from the parent process but not the output from the children Bug or feature ? Thanks, Andreas From fredrik at pythonware.com Wed Dec 1 10:20:28 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 1 Dec 1999 10:20:28 +0100 Subject: [Zope-dev] Re: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF64019276318@gandalf.digicool.com> <38449F86.D6538558@home.com> Message-ID: <00f701bf3bdd$52aaf510$f29b12c2@secret.pythonware.com> Edward Muller wrote: > I took a look at the SOAP specs at work, and it is basically XML-RPC with > some differences.... so you didn't notice that SOAP addresses most of the limitations in XML-RPC (including support for None, better type support, support for cyclic data structures, etc)? or in other words, SOAP makes it possible to handle any Python data structure that can be Pickled. XML-RPC doesn't. definitely an improvement, also for those who'll only use it for Python-to-Python connections. > It looks like MS is at it again....designing YAAPI > (Yet Another API) to confuse the world.... not this time. From bsb at winnegan.de Sun Dec 26 10:34:20 1999 From: bsb at winnegan.de (Siggy Brentrup) Date: 26 Dec 1999 10:34:20 +0100 Subject: "Message file not found" In-Reply-To: Stefan Schwarzer's message of "Sun, 26 Dec 1999 00:54:53 +0100" References: <3865594C.1AB35459@ndh.net> Message-ID: <87so0qt59f.fsf@baal.winnegan.de> Stefan Schwarzer writes: > Hello everybody, > I use the Python port (1.5.2) for OS/2 (Warp 4) and have the > following problem: When I type (for example) > >>> f=open( 'spam', 'r' ) # spam doesn't exist > I get > > Traceback (innermost last): > File "", line 1, in ? > IOError: [Errno 10] Message file not found.: 'spam' > while on Solaris it reads > Traceback (innermost last): > File "", line 1, in ? > IOError: [Errno 2] No such file or directory: 'spam' > Obviously, the (more specific) error messages in OS/2 are not there, > but so far I couldn't figure out how to "get them". I'm not sure what you are looking for, obviously on OS/2 the C library sets errno=10 if a file doesn't exist while all Unix variants I know of use errno=2 for this purpose. For portability use the errno module: Python 1.5.2+ (#4, Nov 18 1999, 01:39:08) [GCC egcs-2.91.66 19990314 (egcs-1.1.2 release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam IDLE 0.5 -- press F1 for help >>> import errno >>> try: open('spam','r') except IOError, x: if x.errno == errno.ENOENT: print 'Oops' else: raise Oops btw: To get the symbol for an error number use: >>> errno.errorcode[2] 'ENOENT' HIH Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From greg.ewing at compaq.com Mon Dec 20 12:10:30 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 21 Dec 1999 00:10:30 +1300 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> Message-ID: <385E0EA6.79CD6DE3@compaq.com> Alex Martelli wrote: > > E.g., "lack of full GC", since it can be rephrased as > "with care, you can control where and when your > objects are finalized", would not qualify!-) Perhaps "lack of full GC backing up the reference counting" would qualify? Greg From gerrit.holl at pobox.com Tue Dec 7 21:38:45 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 7 Dec 1999 21:38:45 +0100 Subject: lemmings In-Reply-To: <384D65B8.BF333D3D@callware.com>; from ivanlan@callware.com on Tue, Dec 07, 1999 at 12:53:28PM -0700 References: <82j6o3$jc6$1@news.qub.ac.uk> <19991207171102.A8067@stopcontact.palga.uucp> <384D65B8.BF333D3D@callware.com> Message-ID: <19991207213845.A11288@stopcontact.palga.uucp> Ivan Van Laningham wrote: > Lemmings of Python, Unite-- > > Gerrit Holl wrote: > > > > stuart mcfadden wrote: > > > Where would I find a list of all the stuff that`s already been written in > > > Python ? > > > > www.vex.net/~x/parnassus > > > > And it contains all that will ever be written in Python, too. Does it *already* contain everything that *will* be ever written? I'm disappointed, there will never be written more than 500 Python modules if it already contains everything that ever will be written. groeten, Gerrit. -- "The move was on to 'Free the Lizard'" -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates) 9:37pm up 5:58, 11 users, load average: 1.29, 1.03, 1.09 From warlock at eskimo.com Tue Dec 28 05:08:56 1999 From: warlock at eskimo.com (Jim Richardson) Date: Mon, 27 Dec 1999 20:08:56 -0800 (PST) Subject: Tkinter and sliders In-Reply-To: <386773AC.DE1F8804@home.com> Message-ID: On 27-Dec-1999 Doug Hellmann wrote: > It sounds like you have the command bound to a mouse motion event rather > than an event which is only called while a mouse button is pressed and > the mouse moves. Post some code, and I can try to be more specific. Thanks for the reply, you are absolutely correct. I had simply grabbed some tkinter example, and chopped it to fit without really understanding the code, once I went back and stopped playing s/monkey-see/monkey-do/ things became a little more clear. THanks for the responce. I liked python without the gui stuff, but I really love it with it ! Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From aahz at netcom.com Fri Dec 24 18:32:28 1999 From: aahz at netcom.com (Aahz Maruch) Date: 24 Dec 1999 17:32:28 GMT Subject: Patch: httplib.py default timeout References: Message-ID: <840anc$9j8$1@nntp8.atl.mindspring.net> In article , Oleg Broytmann wrote: >On 22 Dec 1999, Aahz Maruch wrote: >> >> I've got a patch more-or-less ready to go to Guido; I'll probably send >> it next week after we've tested it a bit more thoroughly. > > Show it here for discussion... Here's the top part of httplib.py; the end hasn't changed at all. I'm going to clean it up a bit more before submitting it to Guido. The one question I have left is whether the timeout should be specified in its raw form (milliseconds) or in a more user-friendly form (seconds); I'm currently leaving it as milliseconds: """HTTP client class See the following URL for a description of the HTTP/1.0 protocol: http://www.w3.org/hypertext/WWW/Protocols/ (I actually implemented it from a much earlier draft.) Example: >>> from httplib import HTTP >>> h = HTTP('www.python.org') >>> h.putrequest('GET', '/index.html') >>> h.putheader('Accept', 'text/html') >>> h.putheader('Accept', 'text/plain') >>> h.endheaders() >>> errcode, errmsg, headers = h.getreply() >>> if errcode == 200: ... f = h.getfile() ... print f.read() # Print the raw HTML ... Python Language Home Page [...many more lines...] >>> Note that an HTTP object is used for a single request -- to issue a second request to the same server, you create a new HTTP object. (This is in accordance with the protocol, which uses a new TCP connection for each request.) """ import socket import string import mimetools HTTP_VERSION = 'HTTP/1.0' HTTP_PORT = 80 defaultTimeout = 60 * 1000 # Sixty seconds class HTTP: """This class manages a connection to an HTTP server.""" def __init__(self, host = '', port = 0, timeout = None): """Initialize a new instance. If specified, `host' is the name of the remote host to which to connect. If specified, `port' specifies the port to which to connect. By default, httplib.HTTP_PORT is used. """ self.debuglevel = 0 self.file = None if host: self.connect(host, port, timeout) def set_debuglevel(self, debuglevel): """Set the debug output level. A non-false value results in debug messages for connection and for all messages sent to and received from the server. """ self.debuglevel = debuglevel def connect(self, host, port = 0, timeout = None): """Connect to a host on a given port with timeout in milliseconds. Note: This method is automatically invoked by __init__, if a host is specified during instantiation. """ if not port: i = string.find(host, ':') if i >= 0: host, port = host[:i], host[i+1:] try: port = string.atoi(port) except string.atoi_error: raise socket.error, "nonnumeric port" if not port: port = HTTP_PORT self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) if self.debuglevel > 0: print 'connect:', (host, port) self.sock.connect(host, port) if timeout is None: self.sock.setsockopt ( socket.SOL_SOCKET, socket.SO_RCVTIMEO, defaultTimeout ) elif timeout > 0: self.sock.setsockopt ( socket.SOL_SOCKET, socket.SO_RCVTIMEO, timeout ) -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 8 days and counting! From sklassen at nospam_cncx.com Tue Dec 7 17:39:45 1999 From: sklassen at nospam_cncx.com (Stephen Klassen) Date: 07 Dec 1999 11:39:45 EST Subject: os.system References: Message-ID: <384D382B.7023CC02@nospam_cncx.com> Most webservers run as the user 'nobody'. Unless there was a clear path to this script and the script was runable by everyone it wouldn't work. Check your perms (man chmod). Jim Richardson wrote: > On Sat, 04 Dec 99 19:49:03 GMT, > David Smead, in the persona of , > brought forth the following words...: > > >This works in the test mode, but jeeps isn't called when executed as a > >CGI. Any comments would be appreciated. > > > >#!/usr/bin/python > >import sys, cgi, string, os > >print "content-type: text/html" > >print > >print "Python Rules!" > >print "
" > >sys.stdout.write('who done it?') # no \n at the end > >print "junk" > > > >os.system("jeeps") #doesn't get called when CGI > > > >print "" > >print "" > >if __name__=="__main__": cgi.test() > > > >------- here's the script called jeeps > > > >#!/bin/sh > >date > jnkdate > > > I don't have the solution, but I do know (at least I _think_ I > know) the problem. The return value of the os.system call, is the > error if any of the function, if jeeps runs fine with no returned > error, then the value of return to os.system is either null or 0. > Hope someone has the solution, 'cause I am trying to write a > simple "click here for a fortune" cgi to help me in the learning > of how to type and chew gum at the same time. > -- > Jim Richardson > Anarchist, pagan and proud of it > WWW.eskimo.com/~warlock > Linux, because life's too short for a buggy OS. From mgushee at havenrock.com Thu Dec 16 04:24:32 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 15 Dec 1999 22:24:32 -0500 Subject: help with an error in Tkinter References: <38567BDA.EC2F01D9@pivot.net> Message-ID: Wayne writes: > class App: > def __init__(self, master): > self.var = IntVar() > c = Checkbutton(master, text = "Enable Tab", variable = > self.var, command = self.cb > c.pack() > > self.button = Button(master, text = "Quit", fg = "red", > commnad = master.quit > self.button.pack() > > def cb(self, event): > print "variable is", self.var.get() This one's pretty simple: your definition of cb() calls for an 'event' argument, but widget commands (i.e., those that you specify in a widget's 'command' attribute) don't take a second argument. You're probably confusing this with an event binding, e.g. c.bind('', self.cb) ... in this case you would to define an event handler with an 'event' argument, whether you actually used that argument or not. But in your case, you can just write: def cb(self): Voila! BTW, if you want to write a function that can be called by either a widget command or an event binding, you can do: def cb(self, event=None): Hope this helps. -- Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ From smb at bby.com.au Wed Dec 22 01:27:34 1999 From: smb at bby.com.au (Sarah Burke) Date: Wed, 22 Dec 1999 10:27:34 +1000 Subject: Sydney scoreboard? References: <385DB48C.7A7A52D6@bby.com.au> <8On74.6414$Dh3.85256@ozemail.com.au> Message-ID: <38601AF6.7D39F091@bby.com.au> Very impressive! Since python is so big here, what sort of community activities are there? (I'm only recently arrived from Chicago). Mark Hammond wrote: > "the_wrights" wrote in message > news:8On74.6414$Dh3.85256 at ozemail.com.au... > > > > Sarah Burke wrote in message > > news:385DB48C.7A7A52D6 at bby.com.au... > > > I think I remember reading on the web site a while ago that there > was a > > > scoreboard in a Sydney stadium programmed in Python. Does anyone > know > > > anything more about this? > > > Thanks > > > > > Mark Hammond will correct me if I'm wrong, but I think the MCG > scoreboard is > > written in C++ with an embedded python interpreter for the end-user > to > > This is correct. The same software is also being run at the SCG and > at Olympic stadium for non olympic events. Also at the new Colonial > stadium in Melbourne, and even the Westpac stadium in Auckland! > Python is taking over this half of the world :-) > > Python is a very natural fit for this application - since embedding > Python the software can do for the operators what they could only > dream - in fact, I am constantly surprised how the operators have > abused the embedded interpreter to do things that I wouldnt have > thought feasable! > > Mark. From e.e.sutton at cummins.com Mon Dec 13 17:30:42 1999 From: e.e.sutton at cummins.com (e.e.sutton at cummins.com) Date: Mon, 13 Dec 1999 16:30:42 GMT Subject: Where can I find info on IDispatchEx() References: <1267780385-12582932@hypernet.com> <82m49p$fa5$1@nnrp1.deja.com> <82pc6o$9oj$1@nslave2.tin.it> Message-ID: <8336vj$c8k$1@nnrp1.deja.com> Thank you very much for your response. > > Where can I find info on IDispatchEx()? I am not having much luck on MSDN. > It's in MSDN (the version that came with VC++6) under > "Internet tools: platform SDK"; not in the Contents, but > easy to find under Index or Search. > > I want to write a COM object that can dynamically create interface > > methods which appear as "properties" to a VB script user. > > You can do that with plain old IDispatch. With Microsoft's > ScriptControl, you can load scripts into any ActiveScripting > compatible language (Python should qualify), ask for the > CodeObject of a module, and it should have the dynamic > qualities you require. I am aware that you could do this with scripting languages. However, I wanted to know how it was implemented. Mainly curious at this point but I may have some practical applications as well. IDispatchEx() is apparently the way it is done. If you are interested, I found an interestimg article titled "Dynamic Object Composition Using IDispatchEx" http://www.microsoft.com/mind/1099/dynamicobject/dynamicobject.htm > Actually, what appear as properties are variables, as in > the example you quote: > > > objPerl.EvalScript '$greet = 'Hello, world.\n';" > > See? "$greet" is a _variable_... Sure. But to VB developers it is a property. Even though I'm not a VB developer I try to use their language since they seem to be the majority these days. It is getting harder to find COM examples in C++ anymore and you have to understand VB just so you can figure out how to do it C++. Thanks again for your help! -Ed Sent via Deja.com http://www.deja.com/ Before you buy. From sendzimir at earthlink.net Fri Dec 31 20:27:24 1999 From: sendzimir at earthlink.net (Alexander Sendzimir) Date: Fri, 31 Dec 1999 19:27:24 GMT Subject: File handling summary (was newbie question...)... Message-ID: <386D127F.3840BEE7@earthlink.net> This is a summary of information that I obtained from the "newbie question..." thread started by myself on 1999.12.28 regarding Python idioms for reading text files. Thanks to all those that responded and contributed valuable information. Especially, Justin Sheehy, Eugene Goodrich, Aahz Maruch, Skip Montanaro, Amit Patel, and Fredrik Lundh. All measurements are over 100 runs. Each run timed using GNU time. I won't make any claims to the accuracy of these numbers. I'm exercising my new found Python muscles more than anything. However, I find it interesting that providing a hint to readlines() does seem to cause less time in the kernel. Of course, looping through each line of an input file a line-at-a-time is the slowest by far (duh). I'm curious to know the mechanism by which readlines() and readlines(sizehint) operate and how they differ. I'll sift through Python's source sometime soon. But not now. I think it would be interesting to try this for trully large text files on the order of 80-100MB. The size of the data file is 4,851,630 bytes and was created with the command "su -c 'du -ah /.'". The code I wrote to obtain these values may be ftp'ed from ftp://www.battleface.com/pub/ as fileread.tgz. abs -------------------------------------------------------- Micron Transport Trek2 : 266MHz Pentium anything-but-a-celeron laptop: no swapping infile.readlines() method: Total time: 107.85 Average kernel time/run: 0.13 Average task time/run: 0.95 Average time/run: 1.08 infile.readlines( 4096 << 4 ) method: Total time: 98.04 Average kernel time/run: 0.06 Average task time/run: 0.92 Average time/run: 0.98 infile.readline() loop method: Total time: 212.59 Average kernel time/run: 0.03 Average task time/run: 2.10 Average time/run: 2.13 ------------------------------------------------------ VALinux dual pentium III (XEON) : 500MHz : no swapping infile.readlines() method: Total time: 85.91 Average kernel time/run: 0.14 Average task time/run: 0.72 Average time/run: 0.86 infile.readlines( 4096 << 4 ) method: Total time: 73.56 Average kernel time/run: 0.05 Average task time/run: 0.69 Average time/run: 0.74 infile.readline() loop method: Total time: 162.96 Average kernel time/run: 0.03 Average task time/run: 1.60 Average time/run: 1.63 From darcy at vex.net Sat Dec 11 08:01:10 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 11 Dec 1999 07:01:10 GMT Subject: How to get C and python functions into the same namespace? References: Message-ID: <82ssrm$23gk$1@news.tht.net> Wojciech Zabolotny wrote: > How can I locate both C and python functions in the same namespace? from module import * That imports all the modulue contents into the current namespace and they will be exported with the local ones into the program that calls your wrapper module. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.vex.net/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From ivanlan at callware.com Fri Dec 31 01:09:58 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 30 Dec 1999 17:09:58 -0700 Subject: [OT] OpenSource Python Books? References: <84g70v$tcq$1@nnrp1.deja.com> <386BC2A4.628D9C9A@callware.com> <14443.52642.848176.312416@weyr.cnri.reston.va.us> <386BD8D2.9B82143E@callware.com> <84gqgb$s46$1@nntp6.atl.mindspring.net> Message-ID: <386BF456.C8758624@callware.com> Hi All-- (*How* can the topic of Python books be off-topic for the Python list?!?) Aahz Maruch wrote: > > In article <386BD8D2.9B82143E at callware.com>, > Ivan Van Laningham wrote: > > > >I could easily be persuaded. ... Having just finished Teach Yourself > >Python, [...] > > No, you haven't, you just finished the first draft. ;-) > Aaahhh! You *had* to remind me! ;-) See why Aahz is the tech editor for TYPython? He's keeping me honest (or is that subversive?). > >Fred Drake: > >> I concur. There are too many books with useless CD-ROMs already. > >> The publishing process is slow enough that it's really hard to make > >> this as useful as it used to be (slow downloads, lack of connectivity, > >> etc., were *good* reasons to include the CD-ROM; the little CD-ROM > >> icon on the cover is not). > > > >This is one reason I resisted putting a CD in TYPython. ... > > OTOH, I think it's a Bad Idea to ship a book with lots of example code > and no CD. > If I were using 20,000 Mayan glyphs in the book, I might agree with you;-) Wait'll you see the web site. ... > TEOTWAWKI -- 2 days and counting! I don't know about you, but I'm planning on sleeping through it. Hey, maybe I'll wake up, C++ and Microsoft COM will have been proven to be non-Y2K compliant and self-destructed, and I can go into work and USE PYTHON! -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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From sekter at mail.matav.hu Wed Dec 1 11:44:15 1999 From: sekter at mail.matav.hu (Arpad Kiss) Date: Wed, 1 Dec 1999 11:44:15 +0100 Subject: Python meta object question References: <3842D025.3283C871@linux-france.org> <3844C056.A1E7FF9@linux-france.org> Message-ID: <006c01bf3be9$037a2ae0$029f38c3@geometria.hu> ----- Original Message ----- From: Mickael Remond Newsgroups: comp.lang.python To: Sent: Wednesday, December 01, 1999 7:29 AM Subject: Re: Python meta object question > Mickael Remond wrote: > > > > Hello, > > > > Is there a way to automatically update the class tree to show the change > > in inherited class attributes after a class redefinition ? > > > > [...] > > In fact, this example was an attempt at using meta programming features > of python. > > In a Bytes Magazine article (1997) I read that : > > For a programming language, Python is flexible. Classes and method > refer ences in Python are treated as first-class objects. That is, > new methods and member variables can be added to a class at any > time, and all existing and future instances of classes are affected > by these changes. This way, a scheduled event on a server program > can change a variable in the class definition that defines each > user's privileges. Thus, when standard office hours end, access > could be broadened automatically to certain users with a single > line of code such as userClass.restrictions=3 . All existing and > future instances of userClass are updated and use this new value > until the class variable is changed again. A programmer maintaining > the code for the server could log in and be allowed to add or > update classes and methods without having to take the server down. > > I did not find any clue on how to leverage these features. Are they out > of date ? Well, I use member variables this way: >>> class a: ... ca="dog" ... def __init__(self,name): ... self.name=name ... >>> mydog=a("tibi") >>> mydog.ca, mydog.name ('dog', 'tibi') >>> a.ca="cat" >>> mydog.ca, mydog.name ('cat', 'tibi') Arpad > > Mickael Remond > From aa8vb at yahoo.com Wed Dec 29 18:44:03 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 29 Dec 1999 12:44:03 -0500 Subject: Tkinter documentation? In-Reply-To: <841k01$n16$1@news1.konnect.net> References: <841k01$n16$1@news1.konnect.net> Message-ID: <19991229124403.A692516@vislab.epa.gov> Gregory A McCoy: | I am trying to locate any documentation on tkinter. http://www.python.org/topics/tkinter/doc.html http://www.pythonware.com/library.htm http://www.pythonware.com/fredrik/tkdraft/ |Specifically, how does one bind it to a python program? I have a passing |familiarity with Tcl/Tk and expect that tkinter should behave just like |Tk. They are, after all, the same thing aren't they? The same GUI and interpreter under-the-hood, yes. Different encapsulation on top though which (IMO) makes Tk development more palettable in Python. Not too sure what you mean about "binding" it to a Python program. Are you talking about accessing Tkinter in a Python script? Or are you talking about linking the Python interpreter with Tcl/Tk so you can use Tkinter? If the former, in Tcl/Tk, you just start using Tk commands to create and control Tk widgets: label .label -text "Hello World" pack .label In Python, you do something similar, but with Tkinter's syntax. You just need to import the Tkinter definitions first: from Tkinter import * label = Label( text = "Hello World" ) label.pack() | I would appreciate any pointers to docs that I am missing. Perhaps a |small demonstration program, eh??? Attached. -- Randall Hopper aa8vb at yahoo.com -------------- next part -------------- #!/usr/bin/env python from Tkinter import * root = Tk() w = Label( root, text="Hello, world!" ) w.pack() root.mainloop() From fredrik at pythonware.com Wed Dec 1 09:04:16 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 1 Dec 1999 09:04:16 +0100 Subject: compile time constant to differentiate 1.5.2 from 1.5.1? References: <3844BAEB.41F4@creo.com> Message-ID: <003f01bf3bd2$aac6f600$f29b12c2@secret.pythonware.com> Dale Nagata wrote: > Does anyone know what compile time macros can be used > to detect whether I'm compiling against 1.5.2 or 1.5.1? > > I searched through the headers in a 1.5.1 distribution > and didn't see any obvious version identification macros. > > I would like to be able to build a particular package (CXX) > which is sensitive to changes in the type object internals > between 1.5.1 and 1.5.2. PYTHON_API_VERSION (see Include/modsupport.h for details) From timmuddletin at news.vex.net Tue Dec 14 04:13:03 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 14 Dec 1999 03:13:03 GMT Subject: Need information om Python byte-code References: <8345m3$27t$1@hyperion.nitco.com> Message-ID: <834cjv$duk$1@news.tht.net> jpb at technologist.com (jpb) wrote: >FYI, there is a mud written entirely in Python - look for poo on Joe >Strout's website (www.strout.net). As an additional FYI, POO has been superceded by MOOP (now maintained by Chris Knight), or so it has been said. MOOP's at http://www.accessoft.com/moop/ Though of course our original embedding poster almost certainly is not rushing to abandon his C code upon hearing this information, and may even be mildly annoyed at the tangent which has nothing to do with this question --- nevertheless, let Information abound! (-: ... From roy at popmail.med.nyu.edu Sat Dec 18 19:38:42 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Sat, 18 Dec 1999 13:38:42 -0500 Subject: circular references? References: <385B1AE9.DD4F8ED3@yifan.net> Message-ID: nascheme at enme.ucalgary.ca (Neil Schemenauer) wrote: > Perhaps there is a buffer like object that only gets flushed when > a __del__ method is called. Well, I figured it was something like that too, so I added an explicit call to flush(). Didn't help. Maybe it's kind of like a toilet; when the pipe() is blocked, doing repeated flush()'s just makes a bigger mess :-) From aa8vb at yahoo.com Thu Dec 9 18:57:23 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 9 Dec 1999 12:57:23 -0500 Subject: X display visual In-Reply-To: <384EC71D.E7AACCC0@callware.com> References: <384C39EE.6B5921EC@callware.com> <14412.15539.879016.832154@weyr.cnri.reston.va.us> <384C39EE.6B5921EC@callware.com> <19991208141839.A3847@vislab.epa.gov> <384EBA4B.CC68FBD7@callware.com> <19991208155001.A4994@vislab.epa.gov> <384EC71D.E7AACCC0@callware.com> Message-ID: <19991209125723.A11117@vislab.epa.gov> Ivan Van Laningham: |> |2) winfo_visualsavailable() doesn't work on Windows. I can find out |> |the depth and get the visual string back, but I can't use |> |winfo_visualsavailable(). Here's the traceback: |> |> Interesting. IIRC, MSWin users are going to be limited to one visual at a |> time. The original poster was referring to a UNIX/X box so it'll work for |> them. |> | |Yes, but he was testing stuff for me to make sure that the examples for |my book work on other systems than what I've got ready access to. Even |if M$ users are limited to only one visual, winfo_visualsavailable() |should return that single visual properly. Not puke on people's shoes. | |It looks like the TCL call is returning a string instead of a tuple, so |the parse() call is expecting the tuple and pukes. It would really be |nice if it just worked. | |As it is, I have to wrap the call to winfo_visualsavailable() in a |try:except or test the OS first. Either way, it's excess code that |shouldn't have to be there. Agreed. I suggested Piers Lauder submit a Tkinter bug report. Not there yet, so feel free: http://www.python.org/search/search_bugs.html Randall From Brian at digicool.com Wed Dec 1 15:41:21 1999 From: Brian at digicool.com (Brian Lloyd) Date: Wed, 1 Dec 1999 09:41:21 -0500 Subject: Exposing COM via XML-RPC or Something Else Message-ID: <613145F79272D211914B0020AFF6401914DD81@gandalf.digicool.com> > Anyhow, what you want is SOAP, which was a byproduct of XML-RPC. > Microsoft helped develop XML-RPC, but at one point the committee was > moving too slowly, so MS decided to make an end-run. They > finished SOAP > at about the same time, plus or minus, the committee did, but > I suspect > that they put a lot more into it. > > At any rate, SOAP provides a Simple Object Access Protocol. > Just what you > need. And it's essentially XML-RPC, and it's made to grok COM. > > Highly satisfactory. Now all we need is a truly open COM > implementation. Maybe not - IMHO SOAP is a good step forward, since you will now be able to just implement SOAP-aware Python objects instead of mucking around with COM. You can still interoperate with existing COM objects - hey, you could even declare them to be "legacy" code :^) Brian Lloyd brian at digicool.com Software Engineer 540.371.6909 Digital Creations http://www.digicool.com From smst at quantisci.co.uk Thu Dec 9 17:06:50 1999 From: smst at quantisci.co.uk (Steve Tregidgo) Date: Thu, 09 Dec 1999 16:06:50 GMT Subject: some random reflections... In-Reply-To: <82od57$i7n$1@serv1.iunet.it> Message-ID: <199912091606.QAA08480@cobweb.quantisci.co.uk> Hi Alex, Alex Martelli wrote: > > 4. why can't I overload "in" to have the > expected semantics and maybe be fast...? > > "if a in X:" and "for a in X:" will now both > give errors unless X is a sequence. But > it would seem much more useful, elegant, > natural, polymorphic, and whatever other > buzzwords you desire, if there was some > __whatever__ method, or methods, that > I could overload on my object X, to make > these operations work, without wanting to > make X a sequence (besides, for the > "if a in X" case, I could give my true/false > answer much faster than the currently > rigid linear-iteration semants of "in"...!). > Try this: class X: def __init__(self, length): self.length = length def __getitem__(self, item): if item >= self.length: # Or whatever test you like raise IndexError import random # Insert (useful) things here. return random.random() Python 1.5.1 (#0, Aug 27 1998, 19:32:31) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> >>> x = X(3) >>> for a in x: ... print a ... 0.690979699629 0.155051548276 0.453616478203 >>> if 1 in x: ... print 'unlikely!' ... else: ... print 'spam' ... spam >>>^Z So, if you can't easily get the Nth item but can get the "next" item (as you mention below), you are at least okay in a for-loop -- just remember the last thing you sent out from __getitem__ and work out the next thing accordingly. (I don't know how this would work for ' if a in b ' type statements -- try it and see what happens, maybe). > Regarding the > for a in X: > case, the point is that I can well have a > class X such that linear iteration on it is > natural and smooth, while the random > addressing demanded by being a sequence > (a much stronger demand -- like being > a random iterator, rather than an input > iterator, in C++...) is inappropriate -- i.e. > where I can easily get the "next" item, > but not the "N-th item" for arbitrary N > without a large amount of work. > The locking idea is interesting, too -- not sure how you could implement it currently, but somebody is bound to have an idea. Cheers, Steve Tregidgo http://www.enviros.com/bc From hat at se-46.wpa.wtb.tue.nl Wed Dec 22 11:12:54 1999 From: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) Date: 22 Dec 1999 10:12:54 GMT Subject: List comprehensions References: Message-ID: On 21 Dec 1999 18:20:27 +0100, Magnus L. Hetland wrote: >hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) writes: > >> PS I'd like to have a stronger visual separation between the result >> expression, and the iterations and conditions, so '|' looks better to me >> than ',' . >> This is especially true if you do not start with an iteration, like in >> >> [ x>6, x>5 ] >> >> (Bonus-points for the people who understand what the result is >> :-) ) > >How could you tell, as long as you haven't defined an order over, or >even a range for x? The result could be practically anything. If you look at it as an iteration, then the equivalent Python code is res = [] if x>5: res := res + [x>6] So depending on the value of x, you'd get [], [false], or [true] Albert --- Look ma, windows without Windows !! From skip at mojam.com Tue Dec 28 15:02:59 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 28 Dec 1999 08:02:59 -0600 (CST) Subject: Py2K wishes In-Reply-To: <38687D6A.D525D91F@prescod.net> References: <38675B72.18A139FF@prescod.net> <38687D6A.D525D91F@prescod.net> Message-ID: <14440.49939.489193.842560@dolphin.mojam.com> >> >class Proxy: >> > def __init__ ( self, fallback ): >> > __fallback__=fallback >> >> >a = Proxy( someObject ) >> >> >This would imply the following: >> >> >class SomeClass( someParentClass ): pass >> >assert SomeClass.__fallback__ == someParentClass >> >assert SomeClass().__fallback__ == SomeClass.__fallback__ >> >> I don't have a clue what this is doing. Sorry. Paul> It's doing what Python has always done with instances and their Paul> classes and base classes. Only now it is doing it based on a more Paul> explicit, generalized, reusable mechanism. Please explain for those of us with small brains. 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 fredrik at pythonware.com Thu Dec 9 10:35:17 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 9 Dec 1999 10:35:17 +0100 Subject: How can I get disk space usage? References: <99120914373302.01692@hurd.sds.co.kr> Message-ID: <006f01bf4228$b538b220$f29b12c2@secret.pythonware.com> Youngbong Choe wrote: > Is there a module or function for getting amount of disk free space? > If not, how can i get disk usage infomations in python, like "df" command. os.statvfs (where available). # statvfs-example-1.py import statvfs import os st = os.statvfs(".") print "preferred block size", "=>", st[statvfs.F_BSIZE] print "fundamental block size", "=>", st[statvfs.F_FRSIZE] print "total blocks", "=>", st[statvfs.F_BLOCKS] print "total free blocks", "=>", st[statvfs.F_BFREE] print "available blocks", "=>", st[statvfs.F_BAVAIL] print "total file nodes", "=>", st[statvfs.F_FILES] print "total free nodes", "=>", st[statvfs.F_FFREE] print "available nodes", "=>", st[statvfs.F_FAVAIL] print "max file name length", "=>", st[statvfs.F_NAMEMAX] ## sample output: ## ## preferred block size => 8192 ## fundamental block size => 1024 ## total blocks => 749443 ## total free blocks => 110442 ## available blocks => 35497 ## total file nodes => 92158 ## total free nodes => 68164 ## available nodes => 68164 ## max file name length => 255 From greg.ewing at compaq.com Mon Dec 13 14:43:27 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 14 Dec 1999 02:43:27 +1300 Subject: string interpolation syntactic sugar References: <82ogb2$db2$1@pegasus.csx.cam.ac.uk> <14415.57793.278683.360085@goon.cnri.reston.va.us> <14415.58717.115675.804984@dolphin.mojam.com> <14415.58951.132010.369194@goon.cnri.reston.va.us> <16600266@oberon.noris.de> <14417.10726.522627.251334@dolphin.mojam.com> <16600277@oberon.noris.de> Message-ID: <3854F7FF.7B901BBA@compaq.com> hartmut Goebel wrote: > > I suppose, local() generates a new tuple. This may be quite unefficient. A dictionary, actually. After I posted my suggestion, it occurred to me that the unary % operator should search both the local and global namespaces. This could be done without creating any temporary dictionaries -- just do a normal name lookup in the current scope. It would also give you something more than just syntactic sugar, since this is quite awkward to express using the currently available language features. Greg From morse at harborcom.net Fri Dec 10 15:26:10 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Fri, 10 Dec 1999 14:26:10 GMT Subject: Embedding questions References: <82n5ec$e2a$1@ssauraab-i-1.production.compuserve.com> <82pd4e$2bu$1@vvs.superst.iae.nl> <82qklp$qsu$1@ssauraaa-i-1.production.compuserve.com> Message-ID: <38510920.172174013@news.oh.verio.com> >Shall I take that as a recommendation that I shouldn't use Python for what I >need? Nope, just have to change your paradigm a bit. >Olaf > >class Currency >... >c = Currency () >c = 5 >The above, if I got this correctly would make c first an instance of class >Currency and then re-assign that name to a different variable of type >integer. I think you're abusing operator overloading by saying c=5, and expecting c to maintain other state information, it's not really assigning 5 to 'c', but assiging some single attribute of c to 5, If I had: c = Currency() d = Currency() . . c = d What would you expect/want to happen? I had trouble with not being able to overload the assignment operator when I first started learning Python. After awhile now, I don't miss it. I guess that will change as I start doing more C++. From steriana at gvsu.edu Mon Dec 27 18:33:42 1999 From: steriana at gvsu.edu (Andrew Sterian) Date: Mon, 27 Dec 1999 12:33:42 -0500 Subject: Help with Installer beta 3e Message-ID: <3867a311@news.gvsu.edu> I'm trying to use Gordon McMillan's Installer beta 3e software to distribute a set of scripts as a package. This is simple stuff, just a bunch of scripts that need to be installed in a directory somewhere on the Python path (i.e., no DLL's, no Tkinter, etc.) I need this distribution to be a simple EXE that the user can download and run, assuming Python has already been installed. The problem is I can't figure out how to use the Installer package. I tried running the Simple script on my top-level script and the generated EXE file fails to run (it says it can't find .PY file that is part of my package). I deleted all .PYC files as the installhelp file suggests, but nothing helped. So...is there any documentation or tutorial that explains how to get started with Installer to do basic stuff? I'm afraid Gordon's work is so robust and flexible that the basics have been obscured. Many thanks, Andrew. From alex at magenta.com Wed Dec 15 10:47:45 1999 From: alex at magenta.com (Alex Martelli) Date: Wed, 15 Dec 1999 10:47:45 +0100 Subject: trying again: CgiHttpServer workalike for Win/NT and Win/98? Message-ID: <837o38$b65$1@serv1.iunet.it> I thought I had posted this request (mailed it to the list, to be precise), but it doesn't seem to have 'taken', so, I'm trying again, via the NG this time -- sorry if it's a repeat. To test some CGI scripts with minimal hassle, I would like to be able to run CgiHttpServer.py, or something similar to it, on some Windows/NT and Windows/98 PCs. Unfortunately for this purpose, it seems that CgiHttpServer.py itself is oriented to Unix (e.g., it wants to fork to run the script). I guess I could try to hack it (particularly because I'm really only interested, at this time, in testing CGI scripts which are themselves written in Python), but I thought it might be wiser to ask around first -- likely somebody's already done this kind of thing and has a .py which I could download from somewhere...? In the meantime, I'm using xitami -- small, fast, neat, etc etc -- but I liked the idea of a simple, minimal server in Python, easy to tweak and keep fully under control...:-). TIA, Alex From s323140 at student.uq.edu.au Thu Dec 23 18:48:48 1999 From: s323140 at student.uq.edu.au (Rob Hodges) Date: 24 Dec 1999 03:48:48 +1000 Subject: Question about a regular expression References: <385F67E7.B5E4E83@ikb.mavt.ethz.ch> Message-ID: "Darrell" writes: > This doesn't work if you have nested parens. > > >>> s='(1(2))' > >>> print re.search(r"\((.*?)\)",s).groups() > ('1(2',) > >>> True, but it works fine for what Yoav wanted to do, which was to grab the tokens out of parens that weren't nested (at least in the examples offered) -- >>> s='a(x,y)b(x)' >>> for st in re.findall(r"\((.*?)\)", s): ... print string.split(st, ",") ... ['x', 'y'] ['x'] If they were nested, we'd need to know more precisely what defines a token to approach the problem. For example if it were 'a(w,x(y))b(x)', are 'w' and 'x(y)' the tokens belonging to a, and in turn 'y' the token belonging to x -- or are 'w', 'x' and 'y' what we want to extract for a? It depends on the meaning of the data and the detail you want to extract... and frankly, I ain't *touchin'* that unless I have to ;) Merry Christmas, Pythonistas! -Rob > > > Yoav I H Parish writes: > > > > > > > i have a string which could look something like > > > > > > > > a(x,y)b(x) > > > > or > > > > c(x,y,z)b(x)a(x,y) From mss at transas.com Wed Dec 8 14:17:46 1999 From: mss at transas.com (Michael Sobolev) Date: 8 Dec 1999 16:17:46 +0300 Subject: Widget set for curses? References: Message-ID: <82llpq$hl4$1@anguish.transas.com> Grant Edwards wrote: >Are there any python widget sets that use curses (or slang)? For slang (actually, for newt :) there is a module that comes in newt distribution. If you use Debian, you just may install python-newt package. -- Mike From skaller at maxtal.com.au Sun Dec 26 01:52:54 1999 From: skaller at maxtal.com.au (skaller) Date: Sun, 26 Dec 1999 11:52:54 +1100 Subject: Viper- Dec 1999 progress report References: <386549AD.DD177D2A@maxtal.com.au> Message-ID: <386566E6.ADBEB3E6@maxtal.com.au> Woops: forgot to add: LIST COMPREHENSIONS =================== like: [x + y for x in [1,2,3] for y in [10,20,30]] -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From stalnaker at acm.org Fri Dec 3 04:13:08 1999 From: stalnaker at acm.org (Max M. Stalnaker) Date: Thu, 2 Dec 1999 19:13:08 -0800 Subject: multiline comments References: <8233mi$d5i@mail.psy.uva.nl> Message-ID: Consider doc strings if you have not already. from anydbm.py """Generic interface to all dbm clones. Instead of import dbm d = dbm.open(file, 'w', 0666) use import anydbm d = anydbm.open(file, 'w') The returned object is a dbhash, gdbm, dbm or dumbdbm object, dependent on the type of database being opened (determined by whichdb module) in the case of an existing dbm. If the dbm does not exist and the create or new flag ('c' or 'n') was specified, the dbm type will be determined by the availability of the modules (tested in the above order). It has the following interface (key and data are strings): d[key] = data # store data at key (may override data at # existing key) data = d[key] # retrieve data at key (raise KeyError if no # such key) del d[key] # delete data stored at key (raises KeyError # if no such key) flag = d.has_key(key) # true if the key exists list = d.keys() # return a list of all existing keys (slow!) Future versions may change the order in which implementations are tested for existence, add interfaces to other dbm-like implementations. The open function has an optional second argument. This can be 'r', for read-only access, 'w', for read-write access of an existing database, 'c' for read-write access to a new or existing database, and 'n' for read-write access to a new database. The default is 'r'. Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it only if it doesn't exist; and 'n' always creates a new database. """ "Ionel Simionescu" wrote in message news:8233mi$d5i at mail.psy.uva.nl... > Hi, > > > I would like to see multiline comments possible in some future version of > Python. > > > Thank you, > ionel > > From skaller at maxtal.com.au Tue Dec 28 20:02:14 1999 From: skaller at maxtal.com.au (skaller) Date: Wed, 29 Dec 1999 06:02:14 +1100 Subject: Scalability Research (Was Re: Python suitability) References: <38549DEA.B0157D0@iqsoft.hu> <38664525.1D26C3D4@maxtal.com.au> <1e9c01bf509d$6a76a070$0100a8c0@rochester.rr.com> <99122712553106.01988@quadra.teleo.net> Message-ID: <38690936.EF4E3BC0@maxtal.com.au> Patrick Phalen wrote: > * Interfaces > * Classes vs types > * Static typing > > Three big subjects *is* perhaps a bit much for one poor little sig to > carry. Then again, perhaps the threads are simply migrating to c.l.p. > > Nevertheless, the Eighth International Python Conference is coming up. > Looking at the schedule, including Developer's Day, I can find no > provision for *reviewing* progress made since the 7th Developer's Day > on interfaces, (nor classes vs types or static typing). Shouldn't a time > slot be made for this sort of progress report? FYI: IMHO the Types-Sig is converging to a useful proposal covering interfaces and static typing (together). [As someone that regularly disagrees with everyone, this is a pretty good indicator of progress] -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From wc at zyan.com Thu Dec 23 17:29:35 1999 From: wc at zyan.com (John B. Williston) Date: Thu, 23 Dec 1999 16:29:35 GMT Subject: C++ Source documentation ? References: <38608E94.D37C2B0D@t-online.de> Message-ID: <38634dc7.67319811@news.dslspeed.com> On Wed, 22 Dec 1999 09:40:52 +0100, Stephane wrote: >does somebody know an Python module which parses C++ source-files >(with special comments inside for example) and produce some >output like HTML, TeX, PDf or whatever?? I've really enjoyed using Doc++, which is free and can be found at the following site: http://www.zib.de/Visual/software/doc++/index.html If you don't mind paying for a tool, the documentation system from Genitor is nicer than either AutoDuck or Doc++. John From jim at digicool.com Mon Dec 27 21:12:43 1999 From: jim at digicool.com (Jim Fulton) Date: Mon, 27 Dec 1999 20:12:43 +0000 Subject: Python suitability References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> <113901bf470c$cb236f60$0100a8c0@rochester.rr.com> <38654F5C.378F8338@maxtal.com.au> <005801bf4f7a$059ddf20$bf2b2bc1@martelli> <38664525.1D26C3D4@maxtal.com.au> <3867A2FE.C9FFC5B9@digicool.com> <3867B700.924C18C@maxtal.com.au> Message-ID: <3867C83B.25AC8932@digicool.com> skaller wrote: > > Jim Fulton wrote: > > > > skaller wrote: > > > > > (snip) > > > Let me predict, for example, that Zope will become > > > almost unworkable soon: Python just cannot hack such a large > > > beast. C++ on the other hand, makes getting started > > > much harder, but it then scales better. > > > > I predict that your prediction will be borne out. > > Did you intend 'will not be bourne out' here? Eek, yes, "will *not* be borne out." Thanks ;) -- Jim Fulton mailto:jim at digicool.com Technical Director (888) 344-4332 Python Powered! Digital Creations http://www.digicool.com http://www.python.org Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email address may not be added to any commercial mail list with out my permission. Violation of my privacy with advertising or SPAM will result in a suit for a MINIMUM of $500 damages/incident, $1500 for repeats. From m.faassen at vet.uu.nl Wed Dec 15 11:33:59 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 15 Dec 1999 10:33:59 GMT Subject: Documentation Translations References: <14422.42955.688108.522178@weyr.cnri.reston.va.us> <99121412574105.00954@quadra.teleo.net> Message-ID: <837qqn$ito$1@newshost.accu.uu.nl> Patrick Phalen wrote: > [Fred L. Drake, Jr., on Tue, 14 Dec 1999] > :: If you can help maintain this information in a language other than > :: English, or provide guidance about how I can help support the work of > :: translators, I'd appreciate the help. Please contact me via email if > :: you would like to help. > This sounds like a lot of extra work for you Fred. Why don't we just > standardize on Dutch? Good idea! Everybody who speaks Python speaks Dutch anyway; the cosmic conspiracy I uncovered and all. > it's-frequently-all-Dutch-to-me-anyway-ly y'rs -patrick hey-what-a-coincidence-to-me-too-all-the-time-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From jsight at mindspring.com Wed Dec 1 03:14:58 1999 From: jsight at mindspring.com (Jesse D. Sightler) Date: Tue, 30 Nov 1999 21:14:58 -0500 Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> <38435C43.B238EC15@mindspring.com> Message-ID: <384484A2.AF4BE448@mindspring.com> Michael Hudson wrote: > > wware-nospam at world.std.com (Will Ware) writes: > > > Will Ware wrote: > > > I find myself grumbling about having to type "x = x + 1". The really > > > clean thing to do, given that integers are objects, would be to define > > > increment and decrement methods, so you'd type something like "i.incr()". > > > > Jesse D. Sightler (jsight at mindspring.com) wrote: > > > Wouldn't this be impossible, since Integers are also immutable? So, eg, > > > i.incr() could only return an incremented version of i, but not actually > > > increment i? > > > > Right, this is what Gordon was pointing out. A "++" method could not > > magically reach out of its object, find the "i" variable, and bind it > > to the incremented value. > > Hate to be awkward, but when it comes to things like this, there's > very little like this that can't be done in Python! > > >>> def incr(var): > try: > raise 1/0 > except ZeroDivisionError: > import sys,dis > f = sys.exc_traceback.tb_frame.f_back > loadins = f.f_code.co_code[f.f_lasti - 3:f.f_lasti] > loadop = ord(loadins[0]) > name = dis.opname[loadop] > loadarg = ord(loadins[1]) + 256*ord(loadins[2]) > vname = f.f_code.co_names[loadarg] > f.f_locals[vname] = f.f_locals[vname] + 1 > > > >>> x=1 > >>> incr(x) > >>> x > 2 Ack, and I though Perl was the only language that made you do stuff like that. :) Could you please explain this little piece of code? It sure looks like byte-code dependant, self-modifying crazyness to me. :) --------------- Jesse D. Sightler http://www.biddin.com/delorean/ From mgushee at havenrock.com Thu Dec 30 20:22:49 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 30 Dec 1999 14:22:49 -0500 Subject: HTMLParser bug? Message-ID: Happy Almost Y2K, Everybody-- I'm working on a web-related application, and I wrote a Webhandler class which retrieves and parses web pages. Among other things, it is supposed to return to the main application a list of links from the current page. I'm using htmllib.HTMLParser instantiated like this: f = AbstractFormatter(NullWriter()) self.parser = HTMLParser(f) At first I tried creating the parser instance in my __init__ method, but I ran into trouble because the parser seems to preserve data between invocations, even if I call the reset() method -- so that, when my parsing function has to construct absolute URLs from relative ones, it often puts old paths (i.e., leftover data in self.parser.anchorlist) together with new hostnames. The problem goes away if I create a new parser instance for every page, but I wanted to avoid that if I could. Is this a bug, or have I misunderstood how to use htmllib? -- Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ From rwadkins at flash.net Wed Dec 1 14:01:08 1999 From: rwadkins at flash.net (Very Frustrated) Date: Wed, 01 Dec 1999 13:01:08 GMT Subject: Genetic algorithm lib ports to Python? References: <81u36q$ko9$1@rzcomm2.rz.tu-bs.de> Message-ID: <82366h$8o2$1@nnrp1.deja.com> Hi: Just wondering if anyone had ported any of the genetic algorithm libraries to Python, using (for example) SWIG? The libraries are linked at: http://www.aic.nrl.navy.mil/galist/src/ I'm too much of a novice to get this working by myself. Any help would be appreciated, as well as a cc to my e-mail. --Randy Sent via Deja.com http://www.deja.com/ Before you buy. From claird at aftershock.neosoft.com Fri Dec 31 22:53:29 1999 From: claird at aftershock.neosoft.com (Cameron Laird) Date: 31 Dec 1999 15:53:29 -0600 Subject: [OT] OpenSource Python Books? References: <84g70v$tcq$1@nnrp1.deja.com> <386BC2A4.628D9C9A@callware.com> <3d7lhwrq05.fsf@amarok.cnri.reston.va.us> <84if14$dg6$1@news1.xs4all.nl> Message-ID: <9D035F8F384DB05D.03CDA47A4C817191.9ACB9BD0844E39E2@lp.airnews.net> In article <84if14$dg6$1 at news1.xs4all.nl>, Boudewijn Rempt wrote: . . . >Well, I'd love to write the last one... I guess the problem is in >convincing publishers to publish it - I approached one, but I guess I >didn't go about it the right way, since I didn't get a reply. Now's about . . . To generalize, publishers are *very* receptive to Python books now. An even more important generalization: as in romance, generalities don't matter as much as whether you make the right contact with *one* (as opposed to zero, or the indeterminate horde) partner. Maybe there's matchma- king to be done here ... -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From moonseeker at my-deja.com Thu Dec 30 16:54:53 1999 From: moonseeker at my-deja.com (moonseeker at my-deja.com) Date: Thu, 30 Dec 1999 15:54:53 GMT Subject: setting time? Message-ID: <84fuk4$n83$1@nnrp1.deja.com> Hi! How can I set the system time? I can use the time module to get the time, but I haven't found a way to set the time. Thanks, Mike Sent via Deja.com http://www.deja.com/ Before you buy. From andres at corrada.com Thu Dec 9 11:57:47 1999 From: andres at corrada.com (Andres Corrada) Date: Thu, 09 Dec 1999 05:57:47 -0500 Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <82o0to$6eq$1@serv1.iunet.it> Message-ID: <384F8B2B.73DCCA44@corrada.com> Alex Martelli wrote: > > 2. apparently, no free webspace providers support > Python scripting > > I asked about it here the other day, got zero > answers, and meanwhile diligently combed the > net looking for one. No such luck. If one wants > to write _Perl_ scripts, fine -- it takes some > looking, but one can find half a dozen providers > that will let you do it, some even without imposing > their ads on your pages. I've asked each and > every one of them if they would consider adding > Python too -- apparently, none is interested. > I'm currently building a free web hosting site for a client that will include support for Python (as well as Perl). In fact, the site is being built with Zope with a heavy Python back-end. This doesn't help on the short run but by January the site will be made public. I'll post the opening of the site to the list at the appropriate time. ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------ From quinn at cruzeiro.ugcs.caltech.edu Fri Dec 3 04:21:15 1999 From: quinn at cruzeiro.ugcs.caltech.edu (Quinn Dunkan) Date: 3 Dec 1999 03:21:15 GMT Subject: creating one of a family of classes References: Message-ID: On Thu, 02 Dec 1999 20:11:39 -0500, Roy Smith wrote: >I want to have a family of classes which are all subclasses of a common >ancestor. For the sake of a simple example, let's say I have a class >polygon, with subclasses triangle, square, pentagon, and hexagon. > >I want to be able to call the top-level creator, and have it return an >object of the appropriate subclass based on the argument I give it. For >example: > >p = polygon ([(1,2), (4,5), (0,4)]) > >would return an object of class triangle and > >p = polygon ([(1,2), (4,5), (0,4), (3,4)]) > >would return an object of class square. Is such a thing possible? There's no need to have the superclass do this, just make a function. In fact, if you did have the superclass do it, and the subclasses' __init__ wanted to call their superclass... that's a problem. def try_to_figure_out_what_kind_of_polygon_it_is_from_args_and_return_it(a): if len(a) == 3: return apply(Triankle, a) elif len(a) == 4: return apply(Skware, a) And as for the wisdom of doing this in the first place... well, I don't know the circumstances :) From claird at starbase.neosoft.com Wed Dec 1 00:14:31 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 30 Nov 1999 23:14:31 GMT Subject: performance of tuple-less Python? References: <1268226961-30285235@hypernet.com> <943917954snz@vision25.demon.co.uk> Message-ID: <28AA06A136A68C1C.67A20460768084FC.DEC7E9AA6FF8E72D@lp.airnews.net> In article , Quinn Dunkan wrote: . . . >See any purely functional language, like haskell. You can simulate mutability >in haskell by passing monads around, but you might be surprised at how much >you can get done with no side effects. Indeed; people often *are* "surprised at how much you can get done with no side-effects." > >And what was that party trick of changing 1 to equal 2 in forth? Maybe that's >more at the language level though, but I don't know much about forth (one of >these days...). There are several languages in which "1" can name a variable, which might happen to have the value 2. I can't think of one, though, in which the integers are mutable in the sense of this thread. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From kc5tja at garnet.armored.net Tue Dec 14 06:54:02 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 14 Dec 1999 05:54:02 GMT Subject: win32com: subclass a com object? References: <830pi6$n4k$1@nnrp1.deja.com> <832skg$4bn$1@nnrp1.deja.com> <32f54.31$Nq1.272@news-server.bigpond.net.au> Message-ID: >Yes - you can do this - but only for your own Python code - there is no >reasonable way to setup COM so that anyone else (ie, other languages and >programmers) can create an "Excel.Application" object and have it use yours. >It _would_ be basically possible to have it work with "MyExcel.Application". CoTreatAsClass(). 'Nuff said. ;) -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From skip at mojam.com Mon Dec 20 22:55:39 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 20 Dec 1999 15:55:39 -0600 (CST) Subject: ugly python namespace bug In-Reply-To: References: Message-ID: <14430.42459.231745.510167@dolphin.mojam.com> Roy> I see how it all works now, but boy, stuff like this sure does Roy> invite all sorts of nasty debugging problems! For help with this sort of problem see my hiding.py script at: http://www.musi-cal.com/~skip/python/ 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 stst1234 at my-deja.com Sun Dec 5 02:26:03 1999 From: stst1234 at my-deja.com (stst1234 at my-deja.com) Date: Sun, 05 Dec 1999 01:26:03 GMT Subject: Useful Python related web resource Message-ID: <82cev7$nuk$1@nnrp1.deja.com> http://www.hubat.com/servlets/search?cmd=b&db=hubat&cat=3.14.28&st=0 Sent via Deja.com http://www.deja.com/ Before you buy. From bwarsaw at cnri.reston.va.us Sat Dec 4 04:54:25 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Fri, 3 Dec 1999 22:54:25 -0500 (EST) Subject: Very useful message -- Hah! References: Message-ID: <14408.36977.722575.657267@anthem.cnri.reston.va.us> >>>>> "DG" == Dan Grassi writes: DG> It seems that by design python, by design, is not to be used DG> as a cgi scripting language -- otherwise why would it produce DG> this very meaningful message at the slightest syntax error: Sorry, I'll have to strongly disagree. Python is an excellent language for writing CGI applications. Existence proof: Mailman . You just have to be smart about reporting errors without propagating a non-zero exit status to the Web server. Mailman comes with a script called `driver' which I think does this very well. Since it might be useful to you, I'll attach the file below. You may have to adapt it for your purposes. You may not have all the modules this depends on (get them from the Mailman distro). It's also long because it's well commented and pretty paranoid. Note that this shows a good use of bare excepts! -Barry -------------------- snip snip -------------------- #! /usr/bin/env python # # Copyright (C) 1998 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # This better succeed. If this fails, Python is royally screwed so we might # as well let the Web server give us a fatal and obtrusive error. import sys # From here on we are as bulletproof as possible! # This function is useful for debugging. When an error occurs, this attaches # the file name to the exception string and re-raises. This will be # unnecessary in Python 1.5.2, which also does sensible things to most os # module functions. ##realopen = open ##def open(filename, mode='r', bufsize=-1, realopen=realopen): ## from Mailman.Utils import reraise ## try: ## return realopen(filename, mode, bufsize) ## except IOError, e: ## strerror = e.strerror + ': ' + filename ## e.strerror = strerror ## e.filename = filename ## e.args = (e.args[0], strerror) ## reraise(e) ##import __builtin__ ##__builtin__.__dict__['open'] = open # This standard driver script is used to run CGI programs, wrapped in code # that catches errors, and displays them as HTML. This guarantees that # (almost) any problems in the Mailman software doesn't result in a Web server # error. It is much more helpful to generate and show a traceback, which the # user could send to the administrator, than to display a server error and # have to trudge through server logs. # Note: this isn't 100% perfect! Here are some things that can go wrong that # are not caught and reported as traceback-containing HTML: # # - This file could contain a syntax error. In that case, you would indeed # get a Web server error since this file wouldn't even compile, and there's # no way to catch that. # # - The sys module could be royally screwed, probably we couldn't import it. # Both those would indicate serious problems in the Python installation. # These won't generate Web server errors, but neither will they give # meaningful tracebacks. # # I consider these pretty unlikely. def run_main(): try: # These will ensure that even if something between now and the # creation of the real logger below fails, we can still get # *something* meaningful logger = None # insert the relative path to the parent of the Mailman package # directory, so we can pick up the Utils module import os # sys gets imported at module level below sys.path.insert(0, os.pardir) # map stderr to a logger, if possible from Mailman.Logging.StampedLogger import StampedLogger logger = StampedLogger('error', label='admin', manual_reprime=1, nofail=0, immediate=1) # pre-load the `cgi' module. we do this because we're distributing a # slightly different version than the standard Python module. it's # essentially Python 1.5.2's module, with an experimental patch to # handle clients that give bogus or non-existant content-type headers. # # we assign sys.modules['cgi'] to this special cgi module because we # don't want to have to rewrite all the Mailman.Cgi modules to get the # special one. import Mailman.pythonlib.cgi sys.modules['cgi'] = Mailman.pythonlib.cgi # The name of the module to run is passed in argv[1]. What we # actually do is import the module named by argv[1] that lives in the # Mailman.Cgi package. That module must have a main() function, which # we dig out and call. # scriptname = sys.argv[1] # See the reference manual for why we have to do things this way. # Note that importing should have no side-effects! pkg = __import__('Mailman.Cgi', globals(), locals(), [scriptname]) module = getattr(pkg, scriptname) main = getattr(module, 'main') try: main() except SystemExit: # this is a valid way for the function to exit pass except: print_traceback(logger) print_environment(logger) # We are printing error reporting to two places. One will always be stdout # and the other will always be the log file. It is assumed that stdout is an # HTML sink and the log file is a plain text sink. def print_traceback(logfp=None): if logfp is None: logfp = sys.__stderr__ try: import traceback except ImportError: traceback = None try: from Mailman.mm_cfg import VERSION except ImportError: VERSION = '<undetermined>' # write to the log file first logfp.write('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n') logfp.write('[----- Mailman Version: %s -----]\n' % VERSION) logfp.write('[----- Traceback ------]\n') if traceback: traceback.print_exc(file=logfp) else: logfp.write('[failed to import module traceback]\n') logfp.write('[exc: %s, var: %s]\n' % sys.exc_info()[0:2]) # print to the HTML sink print """\ Content-type: text/html Bug in Mailman version %(VERSION)s

Bug in Mailman version %(VERSION)s

We're sorry, we hit a bug!

If you would like to help us identify the problem, please email a copy of this page to the webmaster for this site with a description of what happened. Thanks!

Traceback:

""" % locals()
    if traceback:
        traceback.print_exc(file=sys.stdout)
    else:
        print '[failed to import module traceback]'
        print '[exc: %s, var: %s]' % sys.exc_info()[0:2]
    print '\n\n
' def print_environment(logfp=None): if logfp is None: logfp = sys.__stderr__ try: import os except ImportError: os = None # write to the log file first logfp.write('[----- Environment Variables -----]\n') if os: for k, v in os.environ.items(): logfp.write('\t%s: %s\n' % (k, v)) else: logfp.write('[failed to import module os]\n') # write to the HTML sink if os: print '''\


Environment variables:

''' for k, v in os.environ.items(): print '' print '
Variable Value
', k, '', v, '
' else: print '


[failed to import module os]' try: # Python 1.5 doesn't have these by default. Let's make our lives easy if not hasattr(sys, '__stderr__'): sys.__stderr__ = sys.stderr if not hasattr(sys, '__stdout__'): sys.__stdout__ = sys.stdout run_main() except: # Some exception percolated all the way back up to the top. This # generally shouldn't happen because the run_main() call is similarly # wrapped, but just in case, we'll give it one last ditch effort to report # problems to *somebody*. Most likely this will end up in the Web server # log file. try: print_traceback() print_environment() except: # Nope, we're quite screwed print """\ Content-type: text/html

We're sorry, we hit a bug!

Mailman experienced a very low level failure and could not even generate a useful traceback for you. Please report this to the Mailman administrator at this site. """ sys.__stderr__.write('[Mailman: low level unrecoverable exception]\n') From anders.eriksson at morateknikutveckling.se Thu Dec 16 14:26:51 1999 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Thu, 16 Dec 1999 14:26:51 +0100 Subject: Multi-User non Client/Server database Message-ID: Hello! I need a database and I can't use a Client/Server database since my ISP refuses to let me install one. The database has to be Multi-User, with record locking so that different user can read and write 'simultaniously' (.don't remember the correct word.) An xBase database would do perfectly! Are there any xBase Python libraries?? The database and the python application will run on a Solaris Sun Sparc station. // Anders From dgrisby at uk.research.att.com Fri Dec 17 11:25:31 1999 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 17 Dec 1999 10:25:31 -0000 Subject: LISTS: Extract every other element References: <19991216131341.A153923@vislab.epa.gov> Message-ID: <83d32r$t5m$1@pineapple.uk.research.att.com> In article <19991216131341.A153923 at vislab.epa.gov>, Randall Hopper wrote: >I want to take a large list: > > [ 1,2,3,4,5,6,7,... ] > >and build a list with every other element: > > [ 1,3,5,7,... ] > >Is there a faster way than looping over indices?: I don't know if it's faster, but how about: class onoff: def __init__(self): self.on = 0 def __call__(self, *args): self.on = not self.on return self.on >>> filter (onoff(), [1,2,3,4,5,6,7,8,9]) [1, 3, 5, 7, 9] It wouldn't be too hard to generalise the onoff class to count in different patterns. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From skip at mojam.com Mon Dec 20 18:13:53 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 20 Dec 1999 11:13:53 -0600 (CST) Subject: shelve In-Reply-To: References: Message-ID: <14430.25553.576208.661666@dolphin.mojam.com> Anders> How do you print out (on screen) all the 'records' in a shelve? Assuming db is your shelve object, the following should work: for k in db.keys(): print db[k] 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 nascheme at enme.ucalgary.ca Thu Dec 9 00:21:03 1999 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Wed, 08 Dec 1999 23:21:03 GMT Subject: FORTRAN (was Re: indentation) References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> <829dlk$12p$1@news.wrc.xerox.com> <14411.53378.154350.793014@weyr.cnri.reston.va.us> <82mjag$7oh$1@nntp2.atl.mindspring.net> Message-ID: Aahz Maruch wrote: >Hmmm... I wonder who the youngest person in this group is who has >actually used FORTRAN on the job. I'm 32; I did the work twelve years >ago. I'm 25 and used it this year. Hopefully never again. :) From sbarron at twilight. Sat Dec 4 02:18:28 1999 From: sbarron at twilight. (Scott Barron) Date: Sat, 04 Dec 1999 01:18:28 GMT Subject: Mutli-Column Listboxes in Tkinter? Message-ID: Hi, Has anyone implemented a multi columned list box in tkinter? I could really use one in my current project and I don't want to switch toolkits. I have rigged one up by throwing a number of listboxes into a grid, but I'm not sure if thats the way to go. Thanks, Scott From scarblac-spamtrap at pino.selwerd.cx Thu Dec 9 11:37:34 1999 From: scarblac-spamtrap at pino.selwerd.cx (Remco Gerlich) Date: 9 Dec 1999 10:37:34 GMT Subject: Numeric Conversion References: <384F6823.E66085F1@cc.huji.ac.il> Message-ID: Iddo Friedberg wrote: > Hi all, > > A small one: atoi &c. recognize the tokens '+' and '-' by themselves as > a numeric value; i.e. > > >>> m=string.atoi('+') > >>> print m > 0 > > My problem: I have text files with fields which are either numeric, or > not. I'd like to convert the numeric ones into numerical values, while > keeping the rest as strings. I initially did that by trapping the > exceptions that atoi() & atol() generate upon hitting a non-numeric > string, but atoi('+') does not generate an exception. >>> import string >>> m=string.atoi('+') Traceback (innermost last): File "", line 1, in ? ValueError: invalid literal for atoi(): '+' So I can't reproduce your problem. Are you sure? And even if you have such a problem, what's wrong with doing something like if s == '+': raise(ValueError("Invalid literal for atoi: '+'")) yourself, before the atoi call? -- Remco Gerlich, scarblac at pino.selwerd.cx "This gubblick contains many nonsklarkish English flutzpahs, but the overall pluggandisp can be glorked from context" (David Moser) From wtanksle at hawking.armored.net Tue Dec 28 23:06:38 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 28 Dec 1999 22:06:38 GMT Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> <38687D6A.D525D91F@prescod.net> Message-ID: On Tue, 28 Dec 1999 04:05:46 -0500, Paul Prescod wrote: >William Tanksley wrote: >> I don't agree directly -- I find "class This(That):" to be quite clear. >In the same sense that "a or b" is clear? I.e. coming from another >language you could read it directly? No; in the sense that it's completely unambiguous. >> In this case, minimal use of keywords is the focus. >Why? Python has a lot of "extra" keywords like "and", "or", "is" "not". Sure. That's pythonic is a completely different sense. There's more than one w-- oops, I mean, Python is perfect. Seriously, though, sometimes Python uses keywords and sometimes it minimizes keyword use. I think I can see the reason in this case: this keyword would have only a single use, and would only appear in one place. Its sole effect would be to expand the size of people's code. >> >class Proxy: >> > def __init__ ( self, fallback ): >> > __fallback__=fallback >> >a = Proxy( someObject ) >> >This would imply the following: >> >class SomeClass( someParentClass ): pass >> >assert SomeClass.__fallback__ == someParentClass >> >assert SomeClass().__fallback__ == SomeClass.__fallback__ >> I don't have a clue what this is doing. Sorry. >It's doing what Python has always done with instances and their classes >and base classes. Only now it is doing it based on a more explicit, >generalized, reusable mechanism. This doesn't even begin to help me. I'm clearly going to have to wildly guess on my own. Would that be equivalent to setting __base__ now? > Paul Prescod -- -William "Billy" Tanksley, in hoc signo hack From jae at ilk.de Thu Dec 2 00:20:11 1999 From: jae at ilk.de (Juergen A. Erhard) Date: Thu, 02 Dec 1999 00:20:11 +0100 Subject: __getslice__ incorrectness Message-ID: <02121999.1@sanctum.jae> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 The implementation of the __getslice__ method is obvious incorrect. The language reference states: Called to implement evaluation of self[i:j]. The returned object should be of the same type as self. Note that missing i or j in the slice expression are replaced by zero or sys.maxint, respectively, and no further transformations on the indices is performed. The interpretation of negative indices and indices larger than the length of the sequence is up to the method. But when I do class X: def __getslice__(self, a, b): return (a,b) x=X() x[:-1] an AttributeError: __len__ is raised. Hmm... So I add a def __len__(self): return 10 and now x[:-1] returns (0, 9). But it should return (0, -1), according to the quoted passage. ("[...] The interpretation of negative indices [...] is up to the method.") Will this be fixed (it's a lot better the way it's documented than the way it's implemented ;-) Bye, J - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 My WebHome: http://Juergen_Erhard.tripod.com GTK - Free X Toolkit (http://www.gtk.org) pros do it for money -- amateurs out of love. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.0 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.5 and Gnu Privacy Guard iEYEARECAAYFAjhFrSkACgkQN0B+CS56qs2bbQCghl9VnCH197zp7dT0sxjnBpLo YfUAoJ5cYUS01alpjzO50PBmorGt4P9a =VAJK -----END PGP SIGNATURE----- From hnowak at cuci.nl Thu Dec 9 22:12:50 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Thu, 9 Dec 1999 22:12:50 +0100 Subject: Parsing functions(?) In-Reply-To: <82p3ll$iqf$1@news.ycc.yale.edu> Message-ID: <199912092115.WAA02274@dionysus.fw.cuci.nl> On 9 Dec 99, at 15:32, Paul M wrote: > Dear Pythoneers, > > I'd like to write a "function recorder" class, something like this: > > class frecorder: > def __init__(self): > self.flist = [] > > def record(self, fxncall): > fxn, arg = **UNKNOWN**(fxncall) > self.flist.append((fxn,arg)) > > Object of this hypothetical class could then be used to build up a > record of function calls and arguments which could then be applied all at > one time, something like the following: > > >>> rec = frecorder() > >>> rec.record(foo(1)) AFAIK, this will pass the *result* of function call foo(1) to the method, which has no way of figuring out which how that value was obtained. > >>> rec.record(bar('string', (t1,t2)) > >>> rec.flist > [(function foo at XXXX, (1,)), (function bar at XXXX, ('string', > (t1,t2))] > >>> for i in rec.flist: > apply(i[0], i[1]) > > etc.... > > I know I could instead define the record method like this: > > def record(self, fname, fargs): > self.flist.append((fname, fargs)) > > which would be called like: > rec.record(foo, (1,)) > > but it doesn't seem as natural as the first example, and besides it > means that one has to remember to do thinks like specify 1-tuples when the > function only takes a single argument. Still, this is the way to go. If you worry about those tuples, try this approach instead: # recorder.py class frecorder: def __init__(self): self.flist = [] def record(self, func, *args): self.flist.append(func, args) def twice(x): return x*2 rec = frecorder() rec.record(id, twice) # one arg rec.record(map, twice, [1,2,3]) # two args rec.record(hex, 78) rec.record(locals) # no args print rec.flist for func, args in rec.flist: print func, '->', args # show function and args print apply(func, args) # show result #----end of code------ You can call rec.record with the function as the first argument, followed by optional second, third, etc. arguments which are the arguments for a call of that function. See the example above. HTH, --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon You call me a masterless man. You are wrong. I am my own master. From grant at nowhere. Mon Dec 13 22:11:32 1999 From: grant at nowhere. (Grant Edwards) Date: Mon, 13 Dec 1999 21:11:32 GMT Subject: Python complaints References: <000201bf3bd4$2bda5e20$542d153f@tim> Message-ID: In article , Fran?ois Pinard wrote: >> There's nothing you can do with "map" you couldn't do "more Pythonically" >> with list comprehensions; e.g. >> sq = map(lambda a: a**2, x) >> vs >> sq = [a**2 for a in x] I like the second syntax better, but having "lambda" available makes us Scheme geeks feel a bit more at home. -- Grant Edwards grante Yow! Wow! Look!! A stray at meatball!! Let's interview visi.com it! From mhammond at skippinet.com.au Tue Dec 14 00:21:00 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 13 Dec 1999 23:21:00 GMT Subject: win32ver module References: <833pct$r5b$1@nnrp1.deja.com> Message-ID: Unfortunately not that I know of - however, I do have someone who keep promising one is to be given to me "real soon now" - I will chase him up, but it does mean it wont be ready in days (or possibly even weeks...) Mark. emuller at painewebber.com wrote in message <833pct$r5b$1 at nnrp1.deja.com>... >Do anyone have a win32ver module that wraps the file version api calls? > > >Sent via Deja.com http://www.deja.com/ >Before you buy. From gmcm at hypernet.com Sun Dec 5 02:10:49 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 4 Dec 1999 20:10:49 -0500 Subject: map versus the 'for' loop In-Reply-To: Message-ID: <1267766477-13420461@hypernet.com> Will Ware wrote: > Tim Peters (tim_one at email.msn.com) wrote: > > If func is None, map is much faster.... > > If func is some builtin operation (like "+" or "len") spelled > > at least roughly the same way in both cases, ... map will > > usually be significantly faster > > Pardon my density: I can easily see how to do this with "len", > since I can type "len" at the prompt and get a " function len>" object back, but I can't see how to do that with > "+". The best I've been able to come up with is the lambda that > you later say isn't a good idea. How do I obtain a " function +>" object? -- import operator - Gordon From gmcm at hypernet.com Sun Dec 5 15:32:23 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sun, 5 Dec 1999 09:32:23 -0500 Subject: Exposing COM via XML-RPC or Something Else In-Reply-To: Message-ID: <1267718418-16313315@hypernet.com> William Tanksley wrote: > On Sat, 4 Dec 1999 16:18:45 -0500, Gordon McMillan wrote: > >"COM" is many (too many) things. At it's core, though, COM is a > >C++ vtable exposed to C. In that sense it is a binary standard, > >and very simple. > I've still got some room to convince my friend to use something > aside from COM, and I'd like to cheat by asking you for the > answers, since you sound knowledgable. Would you recommend COM > over CORBA for a low-level object system? Your "friend" appears to have spoken. I have no experience with the guts of CORBA, so I can't say anything about that. The guts of COM are actually quite simple, but have been endlessly obsfucated by MS market-speak. If you want to untangle it, read Don Box. Personally, I'm fascinated by the history. When CORBA was first a gleam in somebody's eye, DCE was a hot number and it was widely expected to be the core of CORBA. But politics killed it. Guess where DCE shows up now? Hee, hee. DCOM. If you read the Orfali et al book on Distributed Objects (a better book than it appears, actually), you would find that almost none of the stuff they touted as being the crown jewels of a CORBA enabled world has come to pass. All those hopes are now carried on the back of Java Beans (well, EJB, the subset of Java Beans that will run over IIOP). So now for some Python content: notice that all the language facilities necessary for those Bean thingies are right there in Python. We don't even need no stinking "Design Patterns" (hock-ptuie, that's like calling a screen door an "air conditioner"). All we need is an IDE for the keyboard-impaired ;-). We've already got the cross-language bindings, as long as you're willing to use COM or CORBA for the glue. > >CORBA was a full blown spec in 89, but didn't have any > >implementations until 95 or so. COM was working in 90, but if it > >ever had a full blown spec, I must've missed it. > > COM's had a full ISO spec for quite some time. MSFT gives it > away on its website. My friend is quite impressed with it, and > he's normally a pretty rabid MS hater. True, and I've looked at it. It's not at all the same thing as what CORBA has (which tries to map out all the optional services and how they fit, etc.). Of course the latter is so abstract that it leaves plenty of room to build conforming but non- interoperable implementations. As a "start at both ends and work towards the middle" kind of guy, I regard COM and CORBA as object lessons on why neither the "bottom up" nor the "top down" approaches to design work. - Gordon From news at dorb.com Fri Dec 3 05:35:39 1999 From: news at dorb.com (Darrell) Date: Thu, 2 Dec 1999 23:35:39 -0500 Subject: creating one of a family of classes References: Message-ID: I might think of polygon as a function or factory. All the other shapes may or may not inherit from a common base. Here's a quick stab. That could use a comment, I guess. import bisect, copy class Poly: def __init__(self): self._shapes=[] def addShapes(self, shapes): for s in shapes: self._shapes.append((s._numSides, s)) self._shapes.sort() def __call__(self, *args): start=bisect.bisect(self._shapes, (len(args),)) end =bisect.bisect(self._shapes, (len(args)+1,)) for x in range(start,end): shape=self._shapes[x] shapeI=shape[1] cc=shapeI(args) if cc != None: print 'Found:', cc._name return cc return 0 def allSidesEqual(sides): s1=sides[0] for s in sides[1:]: if s != s1: return 0 return 1 def pairsOfSidesEqual(sides): l=list(sides) l.sort() last=None for s in l: if last==None: last=s continue if s != last: return 0 last=None return 1 class Shape: def __init__(self, numSides, name, *tests): self._name=name self._numSides=numSides self._tests=tests self._sides=None def __call__(self, sides): for t in self._tests: if t(sides) ==0: return None newShape=copy.copy(self) newShape._sides=sides return newShape shapes=[Shape(4,'Square', (allSidesEqual)),\ Shape(4,'Rectangle', (pairsOfSidesEqual)),\ Shape(3,'Triangle', (allSidesEqual))] polyFactory=Poly() polyFactory.addShapes(shapes) polyFactory(2,2,2,2) polyFactory(2,2,2) polyFactory(2,2,4,4) #### output poly.py Found: Square Found: Triangle Found: Rectangle -- --Darrell "Roy Smith" wrote in message news:roy-0212992011390001 at mc-as01-p60.med.nyu.edu... > I want to have a family of classes which are all subclasses of a common > ancestor. For the sake of a simple example, let's say I have a class > polygon, with subclasses triangle, square, pentagon, and hexagon. > From tjreedy at udel.edu Mon Dec 13 06:49:18 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 13 Dec 1999 05:49:18 GMT Subject: Newbie: need help with control loop References: <38543b80.289200819@news-server> Message-ID: <8321cu$i1h$1@news.udel.edu> In article <38543b80.289200819 at news-server>, nospam.python at scoobysnacks.com says... > >I'm trying to write a simple program to change passwords on a large >number of routers but I'm having trouble with the control loop. This >may be very poor code but I've only been at this for a week. I want >to do more than one router at a time so I don't have to wait for each >one to finish before I start the next. I also don't want to start ALL >of them at the same time. The problem I'm having is being able to >create an object instance based on a list value. The list is >arbitrary and may change often. Here is where I'm at. > >if __name__ == '__main__': > list=['host1','host2','host3','host4','host5', > 'host6','host7','host8','host9','host0'] 'list' is the name of a built in function, and therefor a bad choice of local variable name. Use 'hosts' instead > running=[] > for machine in range(len(list)): You do not appear to need index. If not, better is for machine in hosts: You should probable create instance next: host_inst = class_name(machine) > running = running + [list[machine]] running.append(host_inst) # does not copy list, merely adds > """I want right here to create a class instance > based on list[machine] and have it begin > > ?? list[machine]=testclass() ?? """ See above > > while len(running) >= 4 : # no more than 4 working > > for currentitem in range(len(running)): here you will want index (for deletion) > # > # kill if done instance = running[currentitem] > # if instance.status == ('done') : > #del instance del running[currentitem] > print running[currentitem], > > del running[0] This makes no sense. Will not be done. > print '' > #loop to finish anything remaining in running[] > >Any and all help appreciated. TJR PS. If you want an email copy of responses, give us a real address. From jam at quark.emich.edu Tue Dec 21 17:35:10 1999 From: jam at quark.emich.edu (Jeff) Date: Tue, 21 Dec 1999 11:35:10 -0500 Subject: ugly python namespace bug In-Reply-To: ; from s323140@student.uq.edu.au on Wed, Dec 22, 1999 at 02:22:24AM +1000 References: <83nkpe$998$1@news1.tele.dk> Message-ID: <19991221113510.A27335@quark.emich.edu> On Wed, Dec 22, 1999 at 02:22:24AM +1000, Rob Hodges wrote: [..snipped...] > I think it would be more appropriate if you could, in each file, > optionally place a statement that tells the interpreter to treat > built-ins as keywords. Then it would stop you dead in your tracks if > you tried to change them, without breaking any old code. What's > another quick statement after the sh'bang and before the imports eh? > > -Rob > personally, instead of adding a directive like this, what about a command line option to the interpreter that will check for usage like that? it would have to tie into the syntax of the language, but it would spit out a warning if it detected a script using a keyword as a variable (like 'dir' or 'type'), and then the programmer has the option to either leave it like that or fix it. this seems a heck of a lot simpler. thoughts? regards, J -- || visit gfd || psa member -- || New Image Systems & Services, Inc. From s.schwarzer at ndh.net Thu Dec 30 18:17:56 1999 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Thu, 30 Dec 1999 18:17:56 +0100 Subject: Speed issues References: <19991227143547.A3500@stopcontact.palga.uucp> Message-ID: <386B93C4.B6549BB7@ndh.net> Hi Gerrit, Gerrit Holl schrieb: > is an assigment slower than appending to a list? > [...] > What is faster? What do you prefer? In addition to that what others have said: What about (not tested) def f( s ): o = map( lambda c: chr( ord(c)/2 ), s ) return string.join( o, '' ) How will this compare? Stefan From gang.li at compuware.com Wed Dec 1 22:26:15 1999 From: gang.li at compuware.com (Gang Li) Date: Wed, 1 Dec 1999 14:26:15 -0700 Subject: Python meta object question References: <3842D025.3283C871@linux-france.org> Message-ID: <384580e0@199.186.16.51> You can try to change the base class for higher class. e.g. localcompany.__base__ = (Company2,)+localcompany.__base__[1:] #assume the first base class is Company1, or you can find it by check all base classes of it "Mickael Remond" wrote in message news:3842D025.3283C871 at linux-france.org... > Hello, > > Is there a way to automatically update the class tree to show the change > in inherited class attributes after a class redefinition ? > > > Look at this example: > > ---------------------------------------- > # Step one > # First description > class company1: > company = "Company1" > > class company2: > company = "Company2" > > class localcompany(company1): > localcompany = "STE France" > > class employee(localcompany): > employee = "Me" > > print > print "Step 1:" > print localcompany.company # => Company1 > print employee.company # => Company1 > > # Step two > # localcompany is sold to company2 > class localcompany(company2): > localcompany="New STE France" > > print > print "Step 2:" > print localcompany.company # => Company2 > print employee.company # => Company1 (outdated!) > > # Step three > # Force employee class update (same class definition) > class employee(localcompany): > employee = "Me" > > print > print "Step 3:" > print localcompany.company # => Company2 > print employee.company # => Company2 > ------------------------------------------------------------- > > This case is very simple but when the class tree becomes complicated it > is difficult to keep all class up to date. > > Is there a way to redefined only one class, as in step 2 and have all > the other class automatically take this change into account ? > > Thank you in advance for your help. > > Mickael Remond From nascheme at enme.ucalgary.ca Sat Dec 18 19:31:16 1999 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Sat, 18 Dec 1999 18:31:16 GMT Subject: circular references? References: <385B1AE9.DD4F8ED3@yifan.net> Message-ID: Roy Smith wrote: >This makes everything work fine. However, I'm still mystified as to the >behavior I was observing. I can understand the memory leak problem, but >not the i/o problem. I sure would like to know what was going on for >real, but I'll admit that not understanding why my code works sure beats >not understanding why it doesn't :-) Perhaps there is a buffer like object that only gets flushed when a __del__ method is called. >BTW, is there any functional difference between "self.record_set = None" >and "del self.record_set", if the object in question is about to go out >of scope anyway? FAQ 4.17 says, "Normally, deleting (better: assigning >None to) sys.exc_traceback will take care of this". Why, in that >situation, the preference of one over the other? No difference. I find deleting it gives better error reporting than setting it to None though (in case you accidently try to use it later). Neil -- "The percentage of users running Windows NT Workstation 4.0 whose PCs stopped working more than once a month was less than half that of Windows 95 users." -- microsoft.com/ntworkstation/overview/Reliability/Highest.asp From ccpowell at ccpowell.com Thu Dec 16 17:01:15 1999 From: ccpowell at ccpowell.com (Christopher C. Powell) Date: Thu, 16 Dec 1999 09:01:15 -0700 Subject: Python 1.5.2 thread support References: Message-ID: <38590CCB.22AE98ED@ccpowell.com> Hello, You need to enable thread support during configuration, before you compile. In the top directory rm config.cache ./configure --with-thread make clean make Enjoy, Christopher Leonel Silva wrote: > Hello, > > I have downloaded Zope 2.1.1 (source) and tried to install it on a PowerMac > running MacOS X Server (after installing Python 1.5.2 bin compiled for MacOS > X Server) unfortunately when I run the command python w_pcgi.py it returns > the error "Zope requires Python thread support". Does any one have a > solution for this? > > I even tried to compile Python from the source (since the bin generated the > above error) without any success, the same error occurs. > > It seems that I can't enable Python thread support even if I compile it from > the source. > > Leonel Joao Silva > Information Systems Manager -- Christopher C. Powell RC-Squared ccpowell at rc2.com 303-749-7922 From root at calvin.gonthier-be.com Mon Dec 27 07:50:03 1999 From: root at calvin.gonthier-be.com (Thomas Lionel SMETS) Date: Mon, 27 Dec 1999 06:50:03 GMT Subject: Tkinter config on RH 5.2 References: <38664B8A.6AEA7758@altern.org> Message-ID: <38670A11.2756FA0A@calvin.gonthier-be.com> bowman wrote: > Thomas Lionel SMETS wrote: > > >Python came "installed" on my RH 5.2 & I now wish to use Tkinter as > > Do yourself a favor, and get the latest Python tarball, build, and > install it yourself. This may break a couple of the RH utilities that > misuse Python, but you can fix them up easily. > > The RH5.2 versions of both Python and Perl are flawed. Yep ... I saw a few problem on the www.python.org web-site. The version is the latest : python 1.5 & TCL/TK 8.0 are apparently the latest ! There however seems to be problem with the header files Thomas, From reio-ta at MailAndNews.com Tue Dec 28 07:33:30 1999 From: reio-ta at MailAndNews.com (jerry smith) Date: Tue, 28 Dec 1999 01:33:30 -0500 Subject: python's for not like c++'s? Message-ID: <38A0267B@MailAndNews.com> for(int x=3;x<10;x+=3) cout << x << " "; cout << endl; for(int y=9;y>0;y-=3) cout << y<< " "; how would i do something similiar to this in python? all i see on the for loops for python are iterating through the whole sequence of a list. as far as i could see there doesnt seem to be an easy way to start somewhere in the middle of a list. also no way to iterate through a list other than the incrament by one and no decramenting through a list. please help? ------------------------------------------------------------ Get your FREE web-based e-mail and newsgroup access at: http://MailAndNews.com Create a new mailbox, or access your existing IMAP4 or POP3 mailbox from anywhere with just a web browser. ------------------------------------------------------------ From dfan at harmonixmusic.com Mon Dec 20 23:54:58 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 20 Dec 1999 17:54:58 -0500 Subject: Lists of lists traversal References: <83m3fn$sb6$1@cronkite.cc.uga.edu> Message-ID: "Benjamin Dixon" writes: | Hello, I am new to Python and am trying to figure out how I can iterate | over a list that I know to contain other lists of integers so that I can | add up the individual lists inside the larger list. | | I tried things like this: | | Sum(input): | for x in input: | value = 0 | for y in input: | value = value + y | return y | | and other stuff but I'm not certain as to how to reference a specific | member of a given sublist. - You're missing a 'def' in the first line. - I think you mean 'for y in x' instead of 'for y in input'. - You probably want to initialize value to 0 outside the x loop, not inside it. - I imagine you mean to return value, not y. Other than that it looks okay. -- Dan Schmidt | http://www.dfan.org From piers at cs.su.oz.au Mon Dec 13 03:23:41 1999 From: piers at cs.su.oz.au (Piers Lauder) Date: Mon, 13 Dec 1999 13:23:41 +1100 Subject: imaplib argument quoting References: <19991212233638.6E51E1CD61@dinsdale.python.org> Message-ID: <945052736.2.270409507@cs.usyd.edu.au> Michael Higgins has pointed out there is a bug in the version of imaplib.py distributed with Python 1.5.2 that prevents passwords being used if they contain characters that are sensitive to the IMAP4 protocol (such as a '('). A horrible oversight on my part - sorry! There is a new version with fixed argument quoting at: http://www.cs.su.oz.au/~piers/imaplib.py Note that the new module now forces quoting of password arguments, so if you have been getting round this bug by quoting the password argument to login yourself before calling the IMAP4 method, the new code won't work. From paul.m at yale.edu Sun Dec 12 22:30:54 1999 From: paul.m at yale.edu (Paul M) Date: Sun, 12 Dec 1999 16:30:54 -0500 Subject: Fun with Tkinter & DISLIN? Message-ID: <83148e$fml$1@news.ycc.yale.edu> Greetings -- I've been playing around developing a object-oriented wrapper around the DISLIN plotting library. For demo purposes I'm trying to write a short Tkinter based interface which shows of some of the functionality of my efforts. I'm not very familiar with GUI programming, so I've been trying to follow the lead of various demos included with the Python Source. Stealing from an earlier exampled posted by Ionel Simionescu using the wxPython toolkit, the following example does what I want it to - it draws a scatter plot in a window, and correctly repaints and resizes. The second version using Tkinter draws the plot correctly, but immediately redraws over it with the standard grey window. If I resize the window I see that the plot is being redrawn at a new size but then immediately gets written over again. Can anyone point me in the right direction? Thanks, Paul ------------wxPython Version------------ from wxPython.wx import * import pxDobject import pxDplot x = [61, 37, 65, 69, 54, 93, 87, 89, 100, 90, 97] y = [14, 17, 24, 25, 27, 33, 34, 37, 40, 41, 42] class dislin_frame(wxFrame): def __init__(self): wxFrame.__init__( self, NULL, -1, "wxDisDemo", wxDefaultPosition, wxSize(600,600) ) self.scatter = pxDplot.dScatter(x,y) self.scatter.external_ID = self.GetHandle() def OnPaint(self, event): self.scatter.draw() event.Skip() class myApp(wxApp): def OnInit(self): dislin_frame().Show(TRUE) return TRUE if __name__ == '__main__': app = myApp(0) app.MainLoop() -----Tkinter version------------------------ from Tkinter import * from pxDplot import * x = [61, 37, 65, 69, 54, 93, 87, 89, 100, 90, 97] y = [14, 17, 24, 25, 27, 33, 34, 37, 40, 41, 42] class Demo(Canvas): def __init__(self, master): self.master = master self.scatter = dScatter(x,y) self.scatter.external_ID = self.master.winfo_id() self.scatter.draw() self.master.bind('', self.reconfigure) def reconfigure(self, event): self.scatter.draw() def main(): root = Tk() demo = Demo(root) root.protocol('WM_DELETE_WINDOW', root.quit) root.mainloop() if __name__ == '__main__': main() From fredrik at pythonware.com Fri Dec 10 10:16:57 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 10 Dec 1999 10:16:57 +0100 Subject: newbie needs help on dictionary References: <38504788.86E9C885@es.co.nz> Message-ID: <014401bf42ef$501b0bf0$f29b12c2@secret.pythonware.com> Matthew Miller wrote: > i've created a list of 20 dictionaries thus... > > turret = [{}] * 20 that's a list of 20 references to the same dictionary. >>> turret = [{}] * 20 >>> turret [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}] >>> turret[0]["foo"] = 1 >>> turret [{'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'f oo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}, {'foo': 1}] see: http://www.python.org/doc/FAQ.html#4.50 for some background. > then scans text-files for tooling information and add entries to a > certain dictionary in list via > > turret[station][tool_name] = 1 > > my question is how do you increment the value accessed by the key. all > i've been able to figure is > > count = turret[station][tool_name] > count = count + 1 > turret[station][tool_name] = count how about: s = turret[station] s[tool_name] = s.get(tool_name, 0) + 1 From Alex.Martelli at think3.com Tue Dec 14 18:29:01 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Tue, 14 Dec 1999 18:29:01 +0100 Subject: Where can I find info on IDispatchEx() Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D39@pces.cadlab.it> Kc5tja writes: > All the other examples used Visual Basic purely as a scripting language -- > ie., a language which bosses other objects around. I'm aware that you can > create new COM objects in VB, but they are accessed almost exclusively > through IDispatch, rather than through native COM interfaces. The only > way > This is false. Visual Basic (6, for sure; but I think 5 could as well) can also be used to implement custom ("native COM") interfaces. > to create REAL COM objects is to use a compiled language, or an > interpretted > language which creates compiled stubs for your COM interfaces. > VB _is_ a compiled language -- compiled to machine code since the times of VB5. It's probably not a GOOD language, but that's a completely different issue... let's not spread disinformation anyway!-) Alex From s323140 at student.uq.edu.au Wed Dec 22 13:32:37 1999 From: s323140 at student.uq.edu.au (Rob Hodges) Date: 22 Dec 1999 22:32:37 +1000 Subject: Question about a regular expression References: <385F67E7.B5E4E83@ikb.mavt.ethz.ch> Message-ID: Rob Hodges writes: > Yoav I H Parish writes: > > > i have a string which could look something like > > > > a(x,y)b(x) > > or > > c(x,y,z)b(x)a(x,y) [...] > I'd use a regexp (.*?) to grab the entire contents of each paren pair, Aarghh! Of course, I meant r"\((.*?)\)" -- you need the real parens as well as the grouping parens. Oops, -Rob From tismer at appliedbiometrics.com Wed Dec 15 15:29:04 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Wed, 15 Dec 1999 15:29:04 +0100 Subject: C++ (was RE: Python suitability) References: <1266856018-8846450@hypernet.com> Message-ID: <3857A5B0.4F49D1B0@appliedbiometrics.com> Gordon McMillan wrote: > > Alex Martelli writes: > > [starting with his conclusion] > > > I'd rather program in Python -- but if the tasks I'm doing > > are not suited for Python (e.g., developing components > > which need to run EXTREMELY fast), then C++ is what > > I'm happiest with. > > It's funny. I agree with that; but I disagree with almost > everything else. I totally agree with Gordon's reply, and I couldn't say it any better! This approach is the only way to survive the future for consultants and small firms that still can outperform large companies. 70's and 80's approach of software engineering belongs to the flint stones. making-my-living-from-that -ly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From prestonlanders at my-deja.com Thu Dec 16 00:52:46 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Wed, 15 Dec 1999 23:52:46 GMT Subject: some random reflections of a "Python newbie": (2) language issues References: <82o0to$6eq$1@serv1.iunet.it> <82od57$i7n$1@serv1.iunet.it> <82pe7b$q76$1@nnrp1.deja.com> <38580410.B29EC285@maxtal.com.au> Message-ID: <8399kd$rj1$1@nnrp1.deja.com> In article <38580410.B29EC285 at maxtal.com.au>, skaller wrote: > Preston Landers wrote: > > > Unfortunately for you, Python dicts are a built-in type (for speed > > reasons) and thus you cannot subclass it, then then implement your > > locking mechanism. This is one of the few obvious inconsistencies in > > Python's implementation. If you could subclass builtins, then what you > > want to do would be completely trivial. > > I don't agree: python is NOT inconsistent here. See how Viper does it, > it retains the Python typing model as is, generalising the notion > of type object instead of insisting that they all be classes, > and that classes are always types. [This is the case in almost all > OO programming languages, including C++, Eiffel, and Java: the core > types are NOT classes. All provide 'class emulations' of the core types, > as python does] Hello, Thanks for the thoughtful post. I think we are talking about two different kinds of inconsistency. I'm not trying to say that the Python implementation diverges from the language specification, or that Python is inconsistent with other object oriented languages. (Though I've not much experience with Eiffel, neither C++ nor Java are "pure" everything-is-an-object languages.) I'm speaking from the point of view of a developer who doesn't care (much) about types vs. classes. he only wants to say, "Okay, here is a thing that is in every respect like a dictionary, only it can be locked and unlocked." Yes, that would break algorithms that accept a dictionary and expect to be able to add new items. However, the developer simply has to keep this in mind and not use such algorithms! No language feature comes for free, of course. In that sense, almost all OO languages suffer from this 'inconsistency.' I'm not really complaining, just noting it. Why should a developer care about a distinction between types and classes? That is an implementation detail that interferes with the "purity" of OO and tends to confuse people. theory-is-always-cleaner-than-practicely-yours, ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From skip at mojam.com Thu Dec 30 18:49:14 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 30 Dec 1999 11:49:14 -0600 (CST) Subject: The Don Beaudry/Jim Fulton hack In-Reply-To: <84g13m$p03$1@nnrp1.deja.com> References: <9GHa4.1682$wG6.149869@ndnws01.ne.mediaone.net> <84g13m$p03$1@nnrp1.deja.com> Message-ID: <14443.39706.250518.228904@dolphin.mojam.com> Dave> Now I'm trying to get MESS to compile and have run into a couple of Dave> seemingly insurmountable obstacles: parts of the Python API used to Dave> implement MESS seem to be missing (?!). They are: Dave> PyAccess_Check Dave> PyAccess_AsValue Dave> PyAccess_SetValue Dave> PyAccess_SetOwner Whoa! You're messing around in some very old code! The access statement was long ago removed from the language (around 1.3 or 1.4 I think). I doubt anyone's actively maintaining the MESS anymore. You're probably going to have to hack the code to eliminate the above calls if you want it to compile. 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 gerrit.holl at pobox.com Tue Dec 21 18:09:30 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 21 Dec 1999 18:09:30 +0100 Subject: Diffs In-Reply-To: <14431.45586.570289.61704@weyr.cnri.reston.va.us>; from fdrake@acm.org on Tue, Dec 21, 1999 at 12:00:02PM -0500 References: <19991218223342.A11575@stopcontact.palga.uucp> <19991221160535.B2087@stopcontact.palga.uucp> <14431.45586.570289.61704@weyr.cnri.reston.va.us> Message-ID: <19991221180930.A1876@stopcontact.palga.uucp> Fred L. Drake, Jr. wrote: > > Gerrit Holl writes: > > Example: > > A diff that moves the string based exception of getopt.py to Class based, > > with 'option' as an attribute...? > > > > A diff that adds docstrings...? > > > > A diff that fixes typo's...? > > Gerrit, > Ah, diffs to *Python*! (Really, it wasn't clear in your original > message!) Hmm, I can't imagine any diffs not to Python being ontopic in this newsgroup, but ok. > If the diff only adds or fixes docstrings, or affects the > documentation sources, send it to python-docs at python.org. > If it affects other aspects of the sources, it should probably be > sent to Guido. Unless it's for the parser module, which has no bugs, > in which case it can be sent to me. ;) Thanks, I'll remember that. regards, Gerrit. -- "The move was on to 'Free the Lizard'" -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates) 6:08pm up 11 min, 16 users, load average: 0.09, 0.50, 0.41 From fredrik at pythonware.com Tue Dec 21 10:51:53 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 21 Dec 1999 10:51:53 +0100 Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <14430.25505.208191.570692@buffalo.fnal.gov> <14430.26227.685044.493207@dolphin.mojam.com> Message-ID: <00e601bf4b99$03390050$f29b12c2@secret.pythonware.com> Anders M Eriksson wrote: > >Regarding C's > > > > (a?b:c) > > > > > > > def ternaryif(a, b, c): > > if a: return b > > return c > > > >folks need to remember that in C's construct, only one of b or c are ever > >evaluated, depending only on the value of a. Of the options I've seen > >posted this morning, only the rather obtuse > > Now I'm confused! in the ternaryif function how will both b and c be > evaluated? when you call a function, *all* arguments are evaluated *before* the call. this only matters if the evaluation has side effects, of course. consider: files = ternaryif( raw_input("remove all files") == "yes", remove_files(), dont_remove_files() ) this will call both "remove_files" and "dont_remove_files", no matter what's returned from raw_input. From fredrik at pythonware.com Wed Dec 1 16:43:42 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 1 Dec 1999 16:43:42 +0100 Subject: wish: multiline comments References: <000b01bf3c10$4faf3910$3acbd9c2@peridot.optichrome.com> Message-ID: <018801bf3c12$d9722e80$f29b12c2@secret.pythonware.com> Adrian Eyre wrote: > Not quite the same is it? A docstring will be put in the .pyc. > A comment won't. well, the compiler throws away strings that does not appear in valid docstring positions. if you put this in a module: class B: "this is class B" """" okay. this is a 42 million line comment string. etc etc etc """ and import it, the PYC file is smaller than you may think. From boncelet at udel.edu Mon Dec 20 11:02:08 1999 From: boncelet at udel.edu (Charles Boncelet) Date: Mon, 20 Dec 1999 10:02:08 +0000 Subject: Python complaints References: <001e01bf4868$86c32d80$63a2143f@tim> Message-ID: <385DFEA0.124CEAAC@udel.edu> I've been away for a few days and it seems I've created a minor tempest. Thanks to all who've responded. I have been using Python for a few months and really like it (perhaps because I don't understand all the little details :-) Tim Peters wrote: > It's a strongly typed language -- more strongly typed than C, for example. > It's not *statically* typed, though. It generally tries hard *not* to do > promotions that aren't "obvious". It was years before, e.g., "int()" was > liberalized to accept string arguments. It's not trying to do the merely > reasonable, it's trying to do the hard-to-be-surprised-by. This, I understand, is the Python way: don't do promotion unless the meaning is 100% clear (even then, don't do it). This is why Python is relatively easy to read, although it may take more lines to do something in Python than it does in, say, Perl. However, I continue to believe that map and lambda don't enhance clarity (except perhaps in highly unusual cases). I do like the "list comprehension" syntax much more. > > > (E.g., the Numeric ufuncs generally do this correctly.) > > NumPy's users are presumed to be mathematical grownups for whom "the usual" > mathematical coercions are indeed "usual". math.sqrt(-30.2) in core Python > is almost certainly due to someone e.g. using a numerically naive method for > computing sample variance <1/sqrt(2*pi) wink>. That is, as even in the > IEEE-754 standard, sqrt(-x) is "an error" to most people. I really like the NumPy extensions. I use Matlab a lot, but Matlab doesn't do a lot of the things I need to do (more complicated algorithms, www, minor database work, etc.). Python+NumPy can do a lot (but, of course, Matlab has many functions that NumPy does not yet.) Unfortunately also, many of my problems are big enough to need C extensions. (I would like to give up C and work only in Python.) > > > If Python is a typed language, shouldn't we be able to determine > > what types are allowed as arguments and returned from functions > > without experimentation (and reverse engineering from the source > > code)? > > Yes, but that's a long and difficult battle in a language without names for > most of its conceptual types. The Types-SIG is trying to address this in > the months it isn't comatosely depressed. This is not my area of strength, so I will wish the Types-SIG good luck. I hope to contribute elsewhere, however. > > It will take a while to get used to what you can and can't get away with! > As general hints, don't try to be clever all the time, and get very > comfortable with interactive mode. Most things are actually quite > reasonable. > > the-night-stars-look-random-at-first-too-ly y'rs - tim Sometimes I wonder whether a middle ground between Perl's promote everything and Python's promote nothing might be the right balance. But I won't bring this up, because I don't want to start another tempest :-) -- Charles Boncelet University of Delaware Newark DE 19716 USA http://www.eecis.udel.edu/~boncelet/ From andres at corrada.com Fri Dec 10 03:31:41 1999 From: andres at corrada.com (Andres Corrada) Date: Thu, 09 Dec 1999 21:31:41 -0500 Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <6D8A17398E28D3119F860090274DD7DB4B3D04@pces.cadlab.it> <384F8E63.95B75B21@corrada.com> Message-ID: <3850660D.6BF34FBD@corrada.com> Robin Becker wrote: > > how do people support 'free' sites? Via advertising? > -- Yup. Nothing is ever really free! ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------ From tim_one at email.msn.com Fri Dec 3 06:25:06 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 3 Dec 1999 00:25:06 -0500 Subject: A Date With Tim Peters... In-Reply-To: <826acr$i8b$1@nnrp1.deja.com> Message-ID: <000701bf3d4e$c2529a40$3a2d153f@tim> [Guido] > Did you ever wonder what Tim Peters looks like? Frequently, yes. [Uwe Zessin] > A _date_ with Tim ?? > > Ah, got it: you want to attract women to the conference ;-) That would have been an excellent plan (women are attracted to bots like lawyers to diseases)! Alas, in America "a date" means something more like either "an appointment" or "forced brutal sex", depending on context. I'm uncertain of which Guido had in mind, but will do it both ways if it advances the cause of Python domination. on-a-date-with-destiny-don't-forget-your-condom-ly y'rs - tim From bobyu5 at mailcity.com Sun Dec 12 21:11:57 1999 From: bobyu5 at mailcity.com (bobyu5 at mailcity.com) Date: Sun, 12 Dec 1999 20:11:57 GMT Subject: Suitability of Python for a Big Application? Message-ID: <830vic$r2t$1@nnrp1.deja.com> I have a project to build a multi-user database intensive application. The 1st phase of the project will be the proof of concept to hammer out all the technology requirements as well as the user requirements. This application should be built using traditional programming languages such as C++ or Java, but development time is limited to 1 year maximum and frankly the time is not sufficient for anything but a quick prototyping language. This application has to run on multiple OSes, access various major relational databases, and internet enabled, meaning that it can FTP or send e-mails as part of its feature. Plus it has to be very easily extensible and modifiable because modification to the requirements will occur very frequently. Also, it has to be blazingly fast. Majority of the heavy duty programming will be done via database programming but tying up those stored procedures as well as supplying a sleek GUI will be the job of this application. And the most important of all, it has already been tried to be built using VB 5.0 with a miserable result. (2 years of effort has still not produced a usable application) All the issues that I have mentionned above are more or less critical. My job is come up with concrete recommendations on what tools to use. After looking at various possibilities, I felt that using a scripting language such as Perl, Rebol, TCL and Python would be the most flexible solution. My fantasy ideal choice would be: Rebol with some amazing and simple to use ODBC and GUI libraries; plus I like the language itself. But it does not for now, so I settled down on Python; however, I have 2 remaining issues on Python. 1) GUI library: I tried to look at TK library and the look and feel was not as sleek as what comes with Windows; plus it felt very slow. 2) Math operation: there is a possibility that some heavy duty calculation would have to be performed on around 100,000 rows of data using Python - how slow would this be? 3) Heavy duty text processing using regexp (at least 40MB big)- I know Perl is really fast in this regard; is Python as fast? For 1) I thought I could solve this problem by using Zope - I get instantly a GUI that is based upon web browsers. This eliminates those annoying installation problems with customized DLLs as I found out using VB development approach. For 2) I am hoping that the Python Math Lib exists and that it is very good. For 3) I am also hoping that Python Regexp Lib is good. Are my assumptions valid? Am I missing anything? Originally we wanted to have Outlook like UI - is this kind of UI possible to build using Python and its libraries? Everybody seems to be using C++ or Java for projects of this scope; has anybody tried to do something similar using Python, or even Perl? Any anecdotes or recommendations would be heartily appreciated! Sent via Deja.com http://www.deja.com/ Before you buy. From martinp at mincom.com Tue Dec 21 09:06:45 1999 From: martinp at mincom.com (Martin Pool) Date: Tue, 21 Dec 1999 18:06:45 +1000 Subject: Size of files in human, readable form References: <3858E970.4D5BC77@bibsyst.no> Message-ID: <385F3515.6606E58F@mincom.com> Thomas Weholt wrote: > Just wondered if there are any modules/methods/ways to get a file`s size > in kilobytes or megabytes etc, based on what`s appropriate? Probably a > simple thing to do, but my attempts have failed. As tim muddletin said, >>> import os,sys >>> os.path.getsize(sys.executable) 24638 >>> os.stat(sys.executable)[6] 24638 >>> to get the size of the file, and then something like this to convert to human-readable form: _abbrevs = [ (1<<50L, 'P'), (1<<40L, 'T'), (1<<30L, 'G'), (1<<20L, 'M'), (1<<10L, 'k'), (1, '') ] def greek(size): """Return a string representing the greek/metric suffix of a size""" for factor, suffix in _abbrevs: if size > factor: break return `int(size/factor)` + suffix You can change the comparison or int if you'd prefer to see things like "3023kb" or "3.02Mb". -- /\\\ Mincom | Martin Pool | martinp at mincom.com // \\\ | Software Engineer | Phone: +61 7 3303-3333 \\ /// | Mincom Limited | Teneriffe, Brisbane \/// | And now a word from our sponsor... This transmission is for the intended addressee only and is confidential information. If you have received this transmission in error, please delete it and notify the sender. The contents of this E-mail are the opinion of the writer only and are not endorsed by Mincom Limited unless expressly stated otherwise. From benji_york at my-deja.com Tue Dec 21 17:28:02 1999 From: benji_york at my-deja.com (benji_york at my-deja.com) Date: Tue, 21 Dec 1999 16:28:02 GMT Subject: mxODBC Problems Message-ID: <83o9qc$v0q$1@nnrp1.deja.com> I've been using mxODBC very successfully for a couple of months now, but a couple of days ago started having a strange problem. I am retrieving data from a TurboIMAGE database on an HP 3000 running MPE (OS). Until now everything has worked flawlessly, but all of a sudden the integer fields contain huge numbers that are offset from the true value by a fixed amount. If I rerun the (python cgi) program the results will sometimes clear up, but will at other times be off by a different fixed amount. I don?t believe this is a problem with my database because the data is being used in a production environment correctly, and I can use another ODBC client like MS Access to browse the data and it?s fine, so I?m left looking at mxODBC. Any ideas would be greatly appreciated. Benji York Calsonic North America Benji_york at cal-na.com Sent via Deja.com http://www.deja.com/ Before you buy. From boud at rempt.xs4all.nl Fri Dec 31 15:39:57 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 31 Dec 1999 14:39:57 GMT Subject: Second language acquisition: was: [OT] OpenSource Python Books? References: <84g70v$tcq$1@nnrp1.deja.com> <386BC2A4.628D9C9A@callware.com> <3d7lhwrq05.fsf@amarok.cnri.reston.va.us> <14443.59621.975171.406252@cmpu.net> Message-ID: <84if7t$dg6$2@news1.xs4all.nl> Kendall Clark wrote: <...> > Also, only marginally off-topic, what is the standard view of what > one's 2nd language should be if one's first language is Python? Well, I don't know about standard view, but I'd suggest SQL - that's useful almost everywhere, from any other language. -- Boudewijn Rempt | http://denden.conlang.org From jeremy at cnri.reston.va.us Thu Dec 9 18:26:31 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 9 Dec 1999 12:26:31 -0500 (EST) Subject: string interpolation syntactic sugar In-Reply-To: <14415.58717.115675.804984@dolphin.mojam.com> References: <82ogb2$db2$1@pegasus.csx.cam.ac.uk> <14415.57793.278683.360085@goon.cnri.reston.va.us> <14415.58717.115675.804984@dolphin.mojam.com> Message-ID: <14415.58951.132010.369194@goon.cnri.reston.va.us> >>>>> "SM" == Skip Montanaro writes: SM> It's perhaps worth pointing out that in situations where all the SM> items you want to interpolate are local variables you can use SM> the locals() builtin function instead of building a dict SM> on-the-fly in your code SM> "a %(x)s b %(y)s" % locals() SM> (I know Jeremy knows this, just pointing it out for others new SM> to Python's string interpolation facility.) And it's a good technique to point out! Another variant of this that I've found useful is: "a %(x)s b %(y)s" % obj.__dict__ Jeremy From Dan at Grassi.com Sun Dec 5 20:16:48 1999 From: Dan at Grassi.com (Dan) Date: Sun, 5 Dec 1999 14:16:48 -0500 Subject: Python sucks -- Hah! Message-ID: <199912051916.LAA18788@mb3.mailbank.com> On 12/5/99 2:02 PM Fredrik Lundh wrote: >http://python.grassi.com is a nice website, btw. >did you design that one yourself? Which has nothing to do with me, I do not own the grassi.com domain, I just rent the mail name "Dan" on that domain. Try grassi.org -- but that is just a stupid vanity thing. For a real web site try http://biffsbunch.com but it is written in WebSiphon and php3, no python yet. Or http://www2.mid-life-crisis.com/Modeline/index.py for something simple in python. Dan, dan at grassi.org From mlh at vier.idi.ntnu.no Fri Dec 31 00:22:31 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 31 Dec 1999 00:22:31 +0100 Subject: RPM-interface/module References: <386B3CDB.FF843280@bibsyst.no> <386BCE53.A8D93A67@es.co.nz> <3daemsrru3.fsf@amarok.cnri.reston.va.us> Message-ID: akuchlin at mems-exchange.org (Andrew M. Kuchling) writes: > > Thomas Weholt wrote: > > > Is there a RedHat package interface/module available for Python?? > > Red Hat actually wrote a Python rpm module for use in their > config. scripts; it's still there in both RH 6.0 and 6.1. (In fact, > it looks like some functions were added in 6.1...) Hm. I was under the impression that rpm was written in Python... I take it it is not? (I guess glint - which, I believe, *is* written in Python - uses the rpm module you refer to? Or...?) -- Magnus Lie Hetland From claird at starbase.neosoft.com Mon Dec 20 22:03:29 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 20 Dec 1999 21:03:29 GMT Subject: Why can pyhton deal with a big project? References: <83lutn$sfn$1@news3.dti.ne.jp> Message-ID: In article <83lutn$sfn$1 at news3.dti.ne.jp>, Hirofumi Furusawa wrote: . . . >Books say "Python can deal with a big project." But they don't say why python >can. . . . aims to explain exactly that proposition. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From kcazabon at home.com Fri Dec 3 05:42:15 1999 From: kcazabon at home.com (Kevin Cazabon) Date: Fri, 03 Dec 1999 04:42:15 GMT Subject: Environment variables References: Message-ID: I ran into the same thing... It's not too hard on NT, as you can set most of them through the registry using Mark Hammonds Win32 Extensions. For Win98, I've been adding the changes to the autoexec.bat and forcing a reboot. One thing I've found though: changing things in the NT registry works, but the changes don't actually become effective immediately. I'd recommend a reboot to be safe after setting up your changes. As for Linux... try the EXPORT suggestions added by Scott. Kevin Cazabon kcazabon at home.com "jeff" wrote in message news:newscache$j0l4mf$sjc$1 at greg.parlant.com... > How do I set environment variables outside the python script? > > Basicaly, I want to run a python script to set some environment variables, > then be able to use them in the shell that had called the python script > (after the script had completed). > > I need this for both Linux and NT/Win2k. > > > From skip at mojam.com Mon Dec 20 18:25:07 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 20 Dec 1999 11:25:07 -0600 (CST) Subject: Equivalent to (a ? b : c) ? In-Reply-To: <14430.25505.208191.570692@buffalo.fnal.gov> References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <14430.25505.208191.570692@buffalo.fnal.gov> Message-ID: <14430.26227.685044.493207@dolphin.mojam.com> Regarding C's (a?b:c) vs. various Python approximations like {0:b, 1:c}[not a] or {1:b, 0:c}[not not a] or a and b or c or def ternaryif(a, b, c): if a: return b return c folks need to remember that in C's construct, only one of b or c are ever evaluated, depending only on the value of a. Of the options I've seen posted this morning, only the rather obtuse (a and (b,) or (c,))[0] meets that criterion. 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 spnee228 at my-deja.com Fri Dec 31 03:00:52 1999 From: spnee228 at my-deja.com (see) Date: Fri, 31 Dec 1999 02:00:52 GMT Subject: Transparent Animated Gif Message-ID: <84h222$h3v$1@nnrp1.deja.com> I have a problem to show animated gif with transparent background. I would very appreciate if somebody can tell me how to do that. Thank you! Sent via Deja.com http://www.deja.com/ Before you buy. From greg.ewing at compaq.com Fri Dec 3 15:51:46 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Sat, 04 Dec 1999 03:51:46 +1300 Subject: Newbie: switch question in Python References: <384605BC.56EAB34E@wjk.mv.com> Message-ID: <3847D902.EC9E3243@compaq.com> "William J. King" wrote: > > -- so I wrote a switch and would like to know if > its ok to do this or if you have any other better > ideas... Using exec for things like this is extremely inefficient, and tends to suffer from scoping problems. A neater way would be def case1: for m in range(1,3): print m def case4: for m in range(4,7): print m #...etc... switch = { 1: case1, 4: case4, ... } # ...and to call it... switch[q]() But unless you really need the speed, it's a lot clearer still just to write a series of if...elifs. Greg From webmaster at python.org Sun Dec 26 17:31:53 1999 From: webmaster at python.org (Python.Org Webmaster) Date: Sun, 26 Dec 1999 11:31:53 -0500 (EST) Subject: Python mode on Macintosh Alpha editor? References: <840m5s$4fq0$1@swen.emba.uvm.edu> <3864C1C4.4BDFBB4C@corrada.com> Message-ID: <14438.17145.231042.436089@anthem.cnri.reston.va.us> >>>>> "AC" == Andres Corrada writes: AC> Howard Oakley (howard at quercus.demon.uk) is currently AC> maintaining a mode for the Alpha editor. I think it is AC> included in the latest releases of Alpha. If someone sends me (via webmaster at python.org) a link to this, I'll add it to the python-mode page. http://www.python.org/emacs/python-mode/ -Barry From cjensen at be-research.ucsd.edu Thu Dec 23 20:40:22 1999 From: cjensen at be-research.ucsd.edu (Curtis Jensen) Date: Thu, 23 Dec 1999 11:40:22 -0800 Subject: Merry Christma Message-ID: <38627AA6.39562FBB@be-research.ucsd.edu> Just thought that I'd say, "Merry Christmas." -- Curtis Jensen cjensen at be-research.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From sendzimir at earthlink.net Tue Dec 28 14:43:00 1999 From: sendzimir at earthlink.net (Alexander Sendzimir) Date: Tue, 28 Dec 1999 13:43:00 GMT Subject: Mailboxes References: <19991228200432.A2164@dark.net> Message-ID: <3868CD49.7914C373@earthlink.net> N E W S F L A S H This just in... http://www.python.org/doc/current/lib/module-mailbox.html abs From jam at quark.emich.edu Sat Dec 11 17:17:07 1999 From: jam at quark.emich.edu (Jeff) Date: Sat, 11 Dec 1999 11:17:07 -0500 Subject: Error confusing a newbie In-Reply-To: <19991211105659.A23924@dmcom.net> References: <19991210100320.B18389@dmcom.net> <19991211105659.A23924@dmcom.net> Message-ID: <19991211111707.A20613@quark.emich.edu> On Sat, Dec 11, 1999 at 10:57:00AM -0500, Wayne Topa wrote: [..snipped..] > > I guess that I can always run it in a bash script like > 'python net_time.py', which seem sort of odd tho. > > Well thanks for the try, anyway! If I ever find out what the problem > is I will let you all know. > > Many Thanks > > Wayne > try running it via the python interpreter directly, as you have suggested ('python net_time.py') and see if that works. if the script runs as expected, then I would definately blame the shell or some configuration thereof (and not python itself). look at the net_time.py script with an editor that will show control characters (including tabs). maybe something odd got inserted that is confusing things? check to make sure that the script is consistent with it's use of spaces-vs-tabs for indentation. it might look right in your text editor because the editor is interpreting (or worse, 'optimizing') those characters for you-- it certainly would have no idea that python cares one way or the other, and posting the script wouldn't really expose that kind of problem either. what text editor are you using? what does your PATH variable look like for the root account? is 'python' in the path? does the situation change if you remove the '/usr/bin/env' and put the absolute path to the interpreter in it's place (i.e. '#!/usr/local/bin/python')? hope that helps.. please keep us advised of your progress. regards, J -- || visit gfd || psa member -- || New Image Systems & Services, Inc. From gerrit.holl at pobox.com Sat Dec 18 22:33:42 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 18 Dec 1999 22:33:42 +0100 Subject: Diffs Message-ID: <19991218223342.A11575@stopcontact.palga.uucp> Hello, where should I send diffs? regards, Gerrit. -- 10:27pm up 12:12, 17 users, load average: 0.00, 0.01, 0.00 From invalid.address at do.not.email Wed Dec 22 19:06:47 1999 From: invalid.address at do.not.email (guppy) Date: Wed, 22 Dec 1999 18:06:47 GMT Subject: Python-powered Win95 Replacement Shell Message-ID: <386112d2.34743796@news.telus.net> http://www.graphite.sh/ Haven't used it a bit (I'm stuck on geoShell as a replacement for Microsoft's nasty Explorer shell). Claims to support Python as the scripting engine. My initial thoughts are this would be boggy-slow, but, hey, maybe there's something that can be done about that. If anyone does give it a whirl, it'd be neat to see a review/overview of it posted here. From coursesm at sbdhcp-4024.statenisland-ny.est.tcg.com Thu Dec 16 15:57:53 1999 From: coursesm at sbdhcp-4024.statenisland-ny.est.tcg.com (Stephen Coursen) Date: 16 Dec 1999 14:57:53 GMT Subject: DNS lookup References: Message-ID: On 16 Dec 1999 09:54:32 -0500, Michael Spalinski wrote: > >Is there a module which would let me do something like > >nslookup('132.151.1.90') > >and get the string 'parrot.python.org'? > How about socket.gethostbyaddr ? >>> import socket >>> socket.gethostbyaddr( "127.0.0.1" ) ('localhost', ['localhost.localdomain'], ['127.0.0.1'] ) >>> Steve > >M. > > From fredrik at pythonware.com Thu Dec 2 00:46:52 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 2 Dec 1999 00:46:52 +0100 Subject: Python doesn't follow it's own scoping rules? References: <8766yil0xp.fsf@drpepper.baker.rice.edu> Message-ID: <001701bf3c56$588b2030$f29b12c2@secret.pythonware.com> Tim Danner wrote: > Consider this python program: > > a = 0 > > def death_and_destruction(): > a = a + 1 > > death_and_destruction() > print a > > My understanding is that it should print "1". that's only because you haven't read the FAQ or the language reference. read on. > Unfortunately, it prints: > > Traceback (innermost last): > File "evil.py", line 6, in ? > death_and_destruction() > File "evil.py", line 4, in death_and_destruction > a = a + 1 > NameError: a > > This is very strange, and in general Not Good. checking the FAQ before positing is Good, though: http://www.python.org/doc/FAQ.html#4.57 (summary: if Python has determined that a name is local, it doesn't look it up in the global name- space). in addition to the FAQ, I suggest reading the language reference, especially the section titled "code blocks, execution frames, and namespaces". From ullrich at math.okstate.edu Wed Dec 22 19:27:26 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Wed, 22 Dec 1999 12:27:26 -0600 Subject: __rcall__??? References: <000a01bf4b38$35da1640$b3a0143f@tim> <385FB976.3F05FD33@math.okstate.edu> <3860720e.120478566@news.erols.com> Message-ID: <3861180E.9916CED0@math.okstate.edu> Robert Kern wrote: > On Tue, 21 Dec 1999 11:31:34 -0600, "David C. Ullrich" > wrote: > [...] > > Does it? I must be a version behind again or something, "Emulating numeric > >types" is 3.3.5 here. Before I spend time trying to catch up: Are you saying > >that > >the current 3.3.6 tells the full story, including the answer to the question I > >asked about the _history_, when __rpow__ was introduced? > > No. Try looking in the ChangeLog and HISTORY files in the source > distribution for the history. And, FWIW, you are a version behind on > the documentation. Thanks. I thought I had the same version at home and at the office. They both claim to be 1.5.2 (in the docs and the interpreter as well). But section 3.3.5 here at the office is the same as section 3.3.6 at home - at least they look the same on first glance. > ["I can't get ternary pow to work"/'Works for me:" snipped] Thanks. Something is very strange here... Let's see, dll this, Delphi component that... OH: If you say "from math import *" first you'll find that pow(2,2,2) doesn't work anymore, for reasons I imagine you can figure out. I was testing all this from a shortcut with command line D:\PYTHON\Python.exe -i startmath.py You can guess what the first line of startmath.py is. Sorry. Thanks. Duh. DU > Robert Kern > kern at caltech.edu From daniel.dittmar at sap.com Wed Dec 15 18:35:37 1999 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Wed, 15 Dec 1999 17:35:37 GMT Subject: Documentation Translations References: <14422.42955.688108.522178@weyr.cnri.reston.va.us> Message-ID: <838jh6$kik$1@mailusr.wdf.sap-ag.de> Have a look at http://www.babylonet.net/ Through a combination of Javascript and CGI, highlighting a word on a web page will display a translation. Not as good as having the whole page translated, but quite helpful for those exotic words. I don't know where the catch is - they don't charge money yet. Daniel Dittmar daniel.dittmar at sap.com SAP AG, Basis Entwicklung Berlin From skaller at maxtal.com.au Mon Dec 27 19:59:12 1999 From: skaller at maxtal.com.au (skaller) Date: Tue, 28 Dec 1999 05:59:12 +1100 Subject: Python suitability References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> <113901bf470c$cb236f60$0100a8c0@rochester.rr.com> <38654F5C.378F8338@maxtal.com.au> <005801bf4f7a$059ddf20$bf2b2bc1@martelli> <38664525.1D26C3D4@maxtal.com.au> <3867A2FE.C9FFC5B9@digicool.com> Message-ID: <3867B700.924C18C@maxtal.com.au> Jim Fulton wrote: > > skaller wrote: > > > (snip) > > Let me predict, for example, that Zope will become > > almost unworkable soon: Python just cannot hack such a large > > beast. C++ on the other hand, makes getting started > > much harder, but it then scales better. > > I predict that your prediction will be borne out. Did you intend 'will not be bourne out' here? -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From davecook at home.com Mon Dec 27 06:28:38 1999 From: davecook at home.com (davecook at home.com) Date: Sun, 26 Dec 1999 21:28:38 -0800 Subject: KOALA 0.9.0 released: A database `microsoft access'-4GL-like backen d for PostGreSQL In-Reply-To: References: Message-ID: <199912270528.VAA11723@rama.escnd1.sdca.home.com> In comp.lang.python, you wrote: >This is an object-database / GUI / database-backend / >data-widget / Microsoft-Access thingie for postgres. Very cool. I get the following error when I try to run extended_bases.py: SyntaxError: non-default argument follows default argument (line 53) Also, where do I put the crypto stuff? I stuck the whole directory in /usr/lib/python/site-packages for want of a better place. Why is the crypto stuff necessary? Thanks, Dave Cook From warlock at eskimo.com Tue Dec 7 05:28:49 1999 From: warlock at eskimo.com (Jim Richardson) Date: Mon, 6 Dec 1999 20:28:49 -0800 Subject: os.system References: Message-ID: On Sat, 04 Dec 99 19:49:03 GMT, David Smead, in the persona of , brought forth the following words...: >This works in the test mode, but jeeps isn't called when executed as a >CGI. Any comments would be appreciated. > >#!/usr/bin/python >import sys, cgi, string, os >print "content-type: text/html" >print >print "Python Rules!" >print "
" >sys.stdout.write('who done it?') # no \n at the end >print "junk" > >os.system("jeeps") #doesn't get called when CGI > >print "" >print "" >if __name__=="__main__": cgi.test() > >------- here's the script called jeeps > >#!/bin/sh >date > jnkdate > I don't have the solution, but I do know (at least I _think_ I know) the problem. The return value of the os.system call, is the error if any of the function, if jeeps runs fine with no returned error, then the value of return to os.system is either null or 0. Hope someone has the solution, 'cause I am trying to write a simple "click here for a fortune" cgi to help me in the learning of how to type and chew gum at the same time. -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From tismer at appliedbiometrics.com Thu Dec 30 21:05:47 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 30 Dec 1999 21:05:47 +0100 Subject: Stackless Python 1.0 + co-module 0.6 this weekend (was: "sins") References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <38656610.E4DA287B@maxtal.com.au> Message-ID: <386BBB1B.E4A7539F@appliedbiometrics.com> Neel Krishnaswami wrote: > > Dan Schmidt wrote: > >neelk at brick.cswv.com (Neel Krishnaswami) writes: > > > >| The general problem that needs fixing is that Python really needs a > >| better iteration protocol. (I understand that Guido has worked one > >| out, but hasn't yet implemented it. You may want to contact him so > >| that the two of you can use Viper as a test bed for advanced Python > >| ideas.) > > > >Anyone who is interested in better iteration protocols would probably be > >interested in looking at how Sather does it. Sather is an Eiffel-like > >language with a home page at ; > >it performs iteration with coroutines, basically. > > It *looks* like with Christian Tismer's Stackless Python, it should be > straightforward to implement Sather-style iterators, since Stackless > IIRC has first-class continuations. If I have time this weekend I'll > give it a shot. I'd be very much interested to see these. Most probably I will publish SLP 1.0 this weekend (no idea wether before or after Y2K) together with continuations 0.6 which is very very stable as far as I can tell. There will then be some further optimized versions of SLP, and the co-module will move on with it. The next planned steps (all before the IPC8 show of course) are: 1) simplify SLP by adding one more callback 2) add some structure to the threadstate structure to support microthread switching 3) further simplifications of the co-module 4) frame caching for code objects 5) slight optimizations to the eval loop This should result in a performance boost which gets SLP near standard Python, and makes the use of continuations definately faster than function calls. The long term direction will be to move away from all too much compatibility. I will extend the frame interface, bundle the eval functions into an interpreter object, try caching of memory de/allocations with frame instances, minimize frame size, try pickling the execution state, and provide an API for pluggable interpreters. My current paper on continuations and Stackless Python can be previewed at http://www.tismer.com/research/stackless/spcpaper.htm -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's D?ppelstr. 31 : *Starship* http://starship.python.net 12163 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From ionel at psy.uva.nl Tue Dec 14 13:06:09 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Tue, 14 Dec 1999 13:06:09 +0100 Subject: __getattr__, hasattr Message-ID: <835crr$fjl@mail.psy.uva.nl> Hi, It seems that since one defines __getattr__, hasattr(obj, name) will happily answer 'yes' irrespective of the attribute name. This does not appear very sound to me. Do I overlook anything? Thanks, ionel From gmcm at hypernet.com Wed Dec 15 15:15:17 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 15 Dec 1999 09:15:17 -0500 Subject: Python complaints In-Reply-To: <38576B73.59C7BA85@udel.edu> Message-ID: <1266856016-8846539@hypernet.com> Charles Boncelet wrote: [snip] > I think all functions that operate on single things should be > able to operate on a list of things and return a list of things. > (Are there obvious reasons why this paradigm can't work?) Yes. > Consider, > > >>> l = [1,2,3] > >>> m = [l,l] > >>> len(l) > 2 > >>> len(m) > 3 > > I want len(m) to return [3,3]. And I want: max(len(m)) to return > 3, etc. > > (Yes, I know I can write my version of > len and have it return whatever I want it to, but I am wondering > about the paradigm and why it is not generally true.) l = [[1,2], [[1,2,3],2], 1, "eggs"] What should len(l) produce? What would we do with all those for i in range(len(...)): ? - Gordon From marc_risney at my-deja.com Wed Dec 15 05:13:40 1999 From: marc_risney at my-deja.com (marc_risney at my-deja.com) Date: Wed, 15 Dec 1999 04:13:40 GMT Subject: capture output from a java class in a cgi Message-ID: <8374hh$8fe$1@nnrp1.deja.com> I do not know how to capture output from a java class within a CGI, and redirect the ouput to either a shelve, text file or sendmail( I may need to do all 3). in essence I am using a java class to encrypt data for a loadkey, I pass the java class a datestring, a product type and other info, and I am supposed to get a output if I pass the class 1-1-1-0--1234-01012000 then the output from the Checksum class would have the following format: 1-1-1-0-ABCDEFGHIHKLM-1234-01012000. I can create a simple script and invoke it from a console, yet when I try to invoke the java interpreter from a CGI or a non console windows .pyw script, I do not get the output, and help would be mucg appreciated, here is my script: def GenerateLicenceKey(prod,exprdate): key = "java Keygen" + str(prod) + "-1-1-0--1234-" + exprdate keyfile = open('keys.txt','a') rslts = os.popen(key) for line in rslts.readlines(): keyfile.write(line) keyfile.close() thanks Sent via Deja.com http://www.deja.com/ Before you buy. From zessin at my-deja.com Sat Dec 4 18:00:20 1999 From: zessin at my-deja.com (Uwe Zessin) Date: Sat, 04 Dec 1999 17:00:20 GMT Subject: A Date With Tim Peters... References: <000701bf3d4e$c2529a40$3a2d153f@tim> Message-ID: <82bhb2$4ri$1@nnrp1.deja.com> In article <000701bf3d4e$c2529a40$3a2d153f at tim>, "Tim Peters" wrote: > [Uwe Zessin] > > A _date_ with Tim ?? > > > > Ah, got it: you want to attract women to the conference ;-) > > That would have been an excellent plan (women are attracted to bots > like lawyers to diseases)! Alas, in America "a date" means something > more like either "an appointment" or "forced brutal sex", depending > on context. OK, thanks. I have learned something very important - I'll check the context and think twice before asking for a date... > I'm uncertain of which Guido had in mind, but will do it both ways if > it advances the cause of Python domination. I'm usually trying to be careful with my promises - no matter if this is for Python domination or something else ;-) -- Uwe Zessin Sent via Deja.com http://www.deja.com/ Before you buy. From darcy at vex.net Tue Dec 7 19:47:49 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 7 Dec 1999 18:47:49 GMT Subject: Converting a Shell Script to run under Python References: <82h11e$f2p$1@gossamer.itmel.bhp.com.au> <82i6dj$b2j$1@gossamer.itmel.bhp.com.au> Message-ID: <82jkol$kl2$1@hub.org> Magnus L. Hetland wrote: > How strange... I can't seem to find any intelligent command for this. > Hm. You could of course read it all in and then write it out again, as > in > open("file3","w").write(open("file1").read()) > though that is probably not a good idea. I guess I would rather do Why don't you find this a good idea? It's pretty much a Python paradigm as far as I'm concerned. I suppose a module with this in it would make it easier to read but I don't know that I care for the extra work and overhead. -- D'Arcy J.M. Cain | Democracy is three wolves http://www.vex.net/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From costas_menico at mindspring.com Thu Dec 30 04:49:18 1999 From: costas_menico at mindspring.com (Costas Menico) Date: Thu, 30 Dec 1999 03:49:18 GMT Subject: How to dates in Python? Message-ID: <386ad5ed.1918579@news.mindspring.com> Is there a datetime manipulation/math module for Python? Costas From aussiepenguin at yahoo.com Tue Dec 28 10:04:32 1999 From: aussiepenguin at yahoo.com (Jeremy Lunn) Date: Tue, 28 Dec 1999 20:04:32 +1100 Subject: Mailboxes Message-ID: <19991228200432.A2164@dark.net> Hi, I would like to write a CGI script to access my mailbox from remote. I looked in the Library Reference for Python and I found a module called mailbox but I couldn't work out how to use it. Can anyone give me some hints or tell me where there is documentation or a tutorial on how to use it? Thanks -- Jeremy Lunn Melbourne, Australia ICQ: 19255837 From davidw at prosa.it Thu Dec 2 07:50:14 1999 From: davidw at prosa.it (David N. Welton) Date: 01 Dec 1999 22:50:14 -0800 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> Message-ID: <87puwpg7kp.fsf@freddy.page.street> Guido van Rossum writes: > Come and join us at the Key Bridge Marriott in Rosslyn (across the > bridge from Georgetown), January 24-27 in 2000. Make the Python > conference the first conference you attend in the new millennium! Doesn't the new millenium actually start in 2001? Ciao, -- David N. Welton -+- davidw at prosa.it -+- http://www.efn.org/~davidw From edwardam at home.com Fri Dec 31 05:12:52 1999 From: edwardam at home.com (Edward Muller) Date: Fri, 31 Dec 1999 04:12:52 GMT Subject: XML-RPC Server in Python Message-ID: <386C2D38.BE2BDFA8@home.com> Has anyone written a multi-threaded XML-RPC server in python? Can anyone give me any hints on writting one? I tried the Medusa code, but it didn't work out of the box (unless I messes something up), but it was a little faster....Anyway....I need to write one up and I don't really know the internals of the httplib stuff...So I'm looking for a little guidance..... -EAM From mk_999 at my-deja.com Tue Dec 7 14:54:50 1999 From: mk_999 at my-deja.com (mk_999 at my-deja.com) Date: Tue, 07 Dec 1999 13:54:50 GMT Subject: 500 Internal ... not the same of Dan Message-ID: <82j3j7$8gc$1@nnrp1.deja.com> Well, I'm a newbie of Python and reading always this message is frustrating, because there is no error in my code (I suppose). I wrote a little code to upload files and register data on a database (Oracle 8.0.4) using DCOracle. (plus Apache Web Server on Linux) Sometimes doing this operation it shows me that message (INTERNAL SERVER ERROR), but it works!!!!! if I control in the destination directory the file is uploaded and in the database a new record is regularly registered. Refreshing the page, sometimes it shows the correct page, others not, but it always add new records. I used traceback (not so usefull in this case), and verified syntax on command line (it seems all right). I would be glad if someone showed me which way I can follow to solve this problem. There could be something wrong about the SQL, but why does it execute the code anyway?!? Here there is the function used to connect: def db_update(product, title, author, descr, path): try: dbc=DCOracle.Connect("***/***@***") if dbc: cur=dbc.cursor() #get cursor if cur: stm = "INSERT INTO dev.procedure VALUES ( '%s', '%s', '%s', '%s', TO_DATE(sysdate,'DD-MM-RRRR') ,'%s')" % (prodotto, title, author, descr, path) #print stm cur.execute(stm) else: print 'Invalid SQL statement' cur.close() dbc.close() else: print 'Unable to connect to db' except: print 'Error on connection' if dbc: if cur: cur.close() dbc.close() Thanks for every suggest, Luca Sent via Deja.com http://www.deja.com/ Before you buy. From Alex.Martelli at think3.com Wed Dec 22 09:51:16 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Wed, 22 Dec 1999 09:51:16 +0100 Subject: Microsoft Python product? Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D70@pces.cadlab.it> Randy Edwards writes: > I just got the O'Reilly book on Python and am working my way through it. > I > There is more than one -- e.g., the neat and useful, pretty new, "Learning Python", and the (IMHO) confused, rambling, big "Programming Python" (which is also a bit dated). > was surprised to see mention of a Microsoft product which was supposed to > be > written partially in Python. > > Since I'm such a *big* Microsoft fan :-), I have to ask, what MS > product(s) > was written partially in Python? TIA. > According to what I've read elsewhere on the net, it was the "Microsoft Merchant Server"; that URL somewhere gave it as a good example of using Python for prototyping -- release 1.0 having lots of Python in it, release 2.0 having moved much of the Python to C++, and release 3.0 being (mostly? entirely?) C++. [Of course, leaving the Python in would be useful for end-user customization etc, and it would save programming effort for the non-performance-crucial parts anyway, but the point is that Python is useful even if in the end you want to use a completely different customization strategy (such as Automation and VBA, or Tcl, or whatever) and even if your eventual plans call for an all-C++ product, etc etc]. Also, the URL hinted that the product had originally been developed by a startup firm, and Microsoft acquired the product when it bought out the startup. Alas, can't find the URL itself (it's sure to be somewhere on my browser's 'history', but, where...?-), but that's the gist of the info in it as I recall it. I don't know what the "Merchant Server" _is_, at all, nor the name of the startup firm in question (which _does_ get mentioned in that URL, but the name didn't register with me). Alex From gawron at obop.com.pl Mon Dec 20 10:11:47 1999 From: gawron at obop.com.pl (=?iso-8859-2?Q?Przemys=B3aw?= G. =?iso-8859-2?Q?Gawro=F1ski?=) Date: Mon, 20 Dec 1999 10:11:47 +0100 Subject: smtp Message-ID: <385DF2D3.A17FBE21@obop.com.pl> I have a problem with smtp module (sending files). Can any one help ? Thankx Przemek -- Przemyslaw G. Gawronski UIN:8358522 mailto:gawronskip at usa.net mailto:gawron at obop.com.pl From greg.ewing at compaq.com Thu Dec 2 11:38:42 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 02 Dec 1999 23:38:42 +1300 Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD7C@gandalf.digicool.com> <00f001bf3b6c$5debe270$4500a8c0@thomasnotebook> <944002498.101563@zx81.mersinet.co.uk> Message-ID: <38464C32.4EC818C9@compaq.com> Phil Harris wrote: > Thomas Heller wrote in message > > Zope and SOAP sounds very similar. > > Is this by accident? > yes And when Zope incorporates SOAP you'll be able to call it ZOAP. Greg From jfarrell at mincom.com Wed Dec 15 02:01:20 1999 From: jfarrell at mincom.com (John Farrell) Date: Wed, 15 Dec 1999 11:01:20 +1000 Subject: Please Critique References: <3855DB3D.998F3081@mincom.com> <3855f936@194.120.211.23> Message-ID: <3856E860.F5BA5DAA@mincom.com> Klaus Baldermann wrote: > John Farrell wrote in message <3855DB3D.998F3081 at mincom.com>... > >> while start < length: > >> end = start + 4 > >> startkey = start + 1 > >> mydict[trimline[startkey:end]] = trimline[start:end] > >> start = end > > > while len(line) >= 4: > > instruction = line[0] > > number = line[1:4] > > line = line[4:] > > mydict[number] = instruction > > This could be even more perlified: > > while len(line) >= 4: > mydict.update({line[1:4]: line[0]}) > line = line[4:] Isn't perlification bad? I realised I could cut down on lines, but given that one of the comments on the original code was that it needed more comments, I decided to write for readability rather than perlicity. On the subject of comments, Kernighan and Plauger wrote: "Do not comment bad code, rewrite it." That is not to say that the original code was bad, just that adding comments is usually not the best solution. See discussion at: http://www.c2.com/cgi/wiki?TreatCommentsWithSuspicion John -- Dr John Farrell - Research Architect - Mincom Limited This transmission is for the intended addressee only and is confidential information. If you have received this transmission in error, please delete it and notify the sender. The contents of this E-mail are the opinion of the writer only and are not endorsed by Mincom Limited unless expressly stated otherwise. ---- I don't suffer from stress. I am a carrier. From news at dorb.com Fri Dec 17 03:13:21 1999 From: news at dorb.com (Darrell) Date: Thu, 16 Dec 1999 21:13:21 -0500 Subject: python constructor overloading References: <3859904B.631359C8@EarthLink.Net> Message-ID: Keeping a reference to the caller can setup a circular reference. Which means memory leak. You might pass id(caller) and have a place to map from id ==> caller. It sounds like the container will be constructing these instances. Then there are ways of using an exception to walk the stack and get variables from previous frames. Same as pdb does. I not sure about the righteousness of this. Such as I wonder if such code will work in future versions of Python. Here's some example code. Code from Jesse Sweeney: Subject: Re: How can I make my assertions smarter? import sys def upglobals(): try: 1/0 except ZeroDivisionError: return sys.exc_info()[2].tb_frame.f_back.f_back.f_globals def uplocals(): try: 1/0 except ZeroDivisionError: return sys.exc_info()[2].tb_frame.f_back.f_back.f_locals def pre(condition, locals=None, globals=None): if not locals: locals = uplocals() if not globals: globals = upglobals() if not eval(condition, locals, globals): raise "Precondition Failure", condition -- --Darrell "Greg Copeland" wrote in message news:3859904B.631359C8 at EarthLink.Net... > Okay, I have two classed in a container object. I'd like to be able to > pass the container to both of the contained objects so that they can > call some methods that exist in the container. Both objects are derived > from objects in another library. So, I don't want to have to change the > other objects (as that would be anti-OO and anti-reuse, IMOHO). At any > rate, my first thought was that I would overload the constructor of my > newly derived objects. The problem is, I'm not sure how to do this. I > looke in the FAQ, needless to say, those solutions suck. As it stands, > it doesn't really look like you can overload constructors. The end > result that I'm looking for is something like this: > > # This is from another library > class base > > # This is mine > class derived( base ): > def __init__( self, caller, arg1, arg2, arg3 ): > self.caller = caller > base.__init__( arg1, arg2, arg3 ) > > As you can see, I still want the base class' constructor, as I'm really > attempting to extend the functionality in the derived class. Of course, > it would be dandy if there is something that will give me the caller's > reference! I realize that there are probably other ways to do this, but > this seems like the right direction (more C++'ish - maybe that's the > problem). > > Please excuse the ignorance of the python newbie! > > Thanks in advanced, > Greg > >  > > -- > http://www.python.org/mailman/listinfo/python-list From fredrik at pythonware.com Mon Dec 27 18:22:20 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 27 Dec 1999 18:22:20 +0100 Subject: Problem Compiling Python on OpenBSD. References: <271219990853502764%petro@bounty.org> Message-ID: <003d01bf508e$f35ade60$f29b12c2@secret.pythonware.com> Crass A. Hole wrote: > Traceback (innermost last): > File "./Lib/test/test_socket.py", line 72, in ? > hname, aliases, ipaddrs = socket.gethostbyaddr(ip) > socket.error: host not found > > when I do a ./python ./Lib/test/test_socketmodule.py > > This is most troublesome, since one of the reasons I am installing > python is to use mailman, and in it's ./configure script, it seems to > want socketmodule to work properly... it's more likely that there's a configuration pro- blem; the most obvious way to get that error is if "gethostbyname" returns an IP address that "gethostbyaddr" cannot map back to a name... if this doesn't make sense to you, just go ahead and install mailman. python probably works just fine on your box. From bwarsaw at python.org Tue Dec 28 00:41:10 1999 From: bwarsaw at python.org (Barry Warsaw) Date: Mon, 27 Dec 1999 18:41:10 -0500 (EST) Subject: Scalability Research (Was Re: Python suitability) References: <38549DEA.B0157D0@iqsoft.hu> <38664525.1D26C3D4@maxtal.com.au> <1e9c01bf509d$6a76a070$0100a8c0@rochester.rr.com> <99122712553106.01988@quadra.teleo.net> Message-ID: <14439.63766.16597.531409@anthem.cnri.reston.va.us> >>>>> "PP" == Patrick Phalen writes: PP> Nevertheless, the Eighth International Python Conference is PP> coming up. Looking at the schedule, including Developer's PP> Day, I can find no provision for *reviewing* progress made PP> since the 7th Developer's Day on interfaces, (nor classes vs PP> types or static typing). Shouldn't a time slot be made for PP> this sort of progress report? Great idea. There is time in the morning Devday session for this, but we need volunteers. I'll try to bug people directly in the next few weeks, but if you'd like to give a short status report, please email me directly. -Barry From aussiepenguin at yahoo.com Fri Dec 31 06:48:28 1999 From: aussiepenguin at yahoo.com (Jeremy Lunn) Date: Fri, 31 Dec 1999 16:48:28 +1100 Subject: Converting an intergar to a string In-Reply-To: <082a01bf533f$a61d3400$0100a8c0@rochester.rr.com>; from darrell@dorb.com on Thu, Dec 30, 1999 at 10:32:21PM -0500 References: <19991231140532.A8331@dark.net> <082a01bf533f$a61d3400$0100a8c0@rochester.rr.com> Message-ID: <19991231164828.A8614@dark.net> That fixed that problem. Now would it be possiable to do the opposite and covert an interger to a string so that it can work like this: print 'some text'+num+'some text' ? Thanks, Jeremy On Thu, Dec 30, 1999 at 10:32:21PM -0500, Darrell wrote: > Try this. > > num = string.atoi( urlargs["num"].value) > -- Jeremy Lunn Melbourne, Australia ICQ: 19255837 From Alex.Martelli at think3.com Fri Dec 17 10:25:26 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Fri, 17 Dec 1999 10:25:26 +0100 Subject: problem with an infinite loop Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D52@pces.cadlab.it> Dave Trombley writes...: > Ionel Simionescu wrote: [snip] > > The code below represents an erroneous snippet that crashes Python > > (1.5.2/WinNT) in a very reproductible manner. > > Maybe this kind of error can be intercepted by the interpreter and raise > an > > exception. [snip] > > # I know this code is bad. [snip] > > def __setattr__(self, name, value): > > if name=='name': self.name = value [snip] > The answer here is to not assign to an attribute in the usual fashion, > ie. ., > but to directly access the object's dictionary. > Yep, but Ionel probably knew that -- the issue, it seems to me, is that this error in __setattr__ is common, and having it crash the interpreter isn't a good thing. Perhaps it would be possible to special-case this, or, more generally, impose some sort of recursion limit in the interpreter's C code on those platforms (such as NT) where erroneous unbounded recursion might otherwise produce a crash. Alex From grant at nowhere. Wed Dec 8 19:15:16 1999 From: grant at nowhere. (Grant Edwards) Date: Wed, 08 Dec 1999 18:15:16 GMT Subject: Widget set for curses? References: <82llpq$hl4$1@anguish.transas.com> Message-ID: In article <82llpq$hl4$1 at anguish.transas.com>, Michael Sobolev wrote: >Grant Edwards wrote: >>Are there any python widget sets that use curses (or slang)? >For slang (actually, for newt :) there is a module that comes in newt >distribution. If you use Debian, you just may install python-newt package. I found snack.py (a newt interface installed by default on Red Hat systems) but haven't yet tried using it. Does anybody have any opinions on snack vs python-newt? (I assume that installing a debian package on a RH system isn't too painful.) -- Grant Edwards grante Yow! I'm shaving!! I'M at SHAVING!! visi.com From: "James C. Ahlstrom" Newsgroups: comp.lang.python Subject: Linux Journal confirms evil rumor Date: Wed, 08 Dec 1999 13:33:51 -0500 Organization: Interet Corporation Lines: 17 Message-ID: <384EA48F.F5190180 at interet.com> References: Your message of "Wed, 08 Dec 1999 11:17:03 EST." <1267453215-32281635 at hypernet.com> <1267450887-32421651 at hypernet.com> <199912081707.MAA04242 at eric.cnri.reston.va.us> NNTP-Posting-Host: 198.5.188.34 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ffx2nh5.news.uu.net 944678125 26324 198.5.188.34 (8 Dec 1999 18:35:25 GMT) X-Complaints-To: news at ffx2nh5.news.uu.net NNTP-Posting-Date: 8 Dec 1999 18:35:25 GMT To: python-dev at python.org X-Mailer: Mozilla 4.51 [en] (WinNT; U) X-Accept-Language: en Path: news!uunet!ffx.uu.net!ffx2nh5!not-for-mail Xref: news comp.lang.python:77916 Sender: python-list-admin at python.org Errors-To: python-list-admin at python.org X-BeenThere: python-list at python.org X-Mailman-Version: 1.2 (experimental) Precedence: bulk List-Id: General discussion list for the Python programming language I finally got around to reading the current Linux Journal (which just keeps getting better and better) and lo! there was a picture of a familiar face I just couldn't quite.... Oh no! Could it be true? I heard rumors but I refused to believe them until now. The glasses are gone! Guido now looks like an investment banker! The sky is falling! Next will probably be a Python 1.6 as a 27 Meg DLL, and a Python IPO. Well, maybe not. Now that I look more closely, he is wearing a black and white and mustard (??MUSTARD) T-shirt which says "You Need Python". At least we ought to make him wear a name tag at IPC8. JimA From oli at rz-online.net Wed Dec 29 07:36:23 1999 From: oli at rz-online.net (Oliver Andrich) Date: Wed, 29 Dec 1999 07:36:23 +0100 Subject: Looking for pysnmp Message-ID: <19991229073623.A19765@gothic.andrich.net> Hi, I am looking for the pysnmp package. Does anybody have a valid link? Bye, Oliver P.S.: Is it just me or does the seach facility at python.org doen't work in general? -- Oliver Andrich, KEVAG Telekom GmbH, Schlossstrasse 42, D-56068 Koblenz Telefon: 0261-3921027 / Fax: 0261-3921033 / Web: http://rhein-zeitung.de From digitome at iol.ie Tue Dec 21 19:15:58 1999 From: digitome at iol.ie (Sean Mc Grath) Date: Tue, 21 Dec 1999 18:15:58 GMT Subject: [Announce] Telecommute or re-locate to Ireland and write Python Message-ID: <385fbf84.1173166@news.iol.ie> See, http://www.digitome.com/Jobs.htm From jon at bezek.csse.monash.edu.au Fri Dec 17 00:16:52 1999 From: jon at bezek.csse.monash.edu.au (Jonathan Giddy) Date: 17 Dec 1999 10:16:52 +1100 Subject: Pipe error codes off by a factor of 256 References: <83ba4k$9ia$1@nnrp1.deja.com> <14425.14021.528956.37955@dolphin.mojam.com> Message-ID: Skip Montanaro writes: ] That's the way the underlying popen works, and it's documented, sort of. ] From the os lib reference page: ] ] The exit status of the command (encoded in the format specified for ] wait()) is available as the return value of the close() method of the ] file object, except that when the exit status is zero (termination ] without errors), None is returned. ] ] Unfortunately, I don't find any documentation on wait's return status. ] The os module provides access to the exit status parsing functions WEXITSTATUS and friends. They are documented in the Process Management section of the os module docs. From namsagga at my-deja.com Mon Dec 27 01:43:02 1999 From: namsagga at my-deja.com (namsagga at my-deja.com) Date: Mon, 27 Dec 1999 00:43:02 GMT Subject: arrays & pickling Message-ID: <846cdp$6i7$1@nnrp1.deja.com> I tried to pickle a class that has instances of several arrays (in Python 1.5.1) I got this message: pickle.PicklingError: can't pickle 'array' objects I would prefer to use arrays rather than lists for size considerations, but need a way to save them to a file. Is there a workaround for this kind of problem? What is the most compact way to save an array to a file? Sent via Deja.com http://www.deja.com/ Before you buy. From paul.m at yale.edu Thu Dec 9 21:32:01 1999 From: paul.m at yale.edu (Paul M) Date: Thu, 9 Dec 1999 15:32:01 -0500 Subject: Parsing functions(?) Message-ID: <82p3ll$iqf$1@news.ycc.yale.edu> Dear Pythoneers, I'd like to write a "function recorder" class, something like this: class frecorder: def __init__(self): self.flist = [] def record(self, fxncall): fxn, arg = **UNKNOWN**(fxncall) self.flist.append((fxn,arg)) Object of this hypothetical class could then be used to build up a record of function calls and arguments which could then be applied all at one time, something like the following: >>> rec = frecorder() >>> rec.record(foo(1)) >>> rec.record(bar('string', (t1,t2)) >>> rec.flist [(function foo at XXXX, (1,)), (function bar at XXXX, ('string', (t1,t2))] >>> for i in rec.flist: apply(i[0], i[1]) etc.... I know I could instead define the record method like this: def record(self, fname, fargs): self.flist.append((fname, fargs)) which would be called like: rec.record(foo, (1,)) but it doesn't seem as natural as the first example, and besides it means that one has to remember to do thinks like specify 1-tuples when the function only takes a single argument. Is this doable without parsing the command-line (or the *.py files - I'd like to do this from within a module hierarchy I'm building)? Thanks Paul From mhammond at skippinet.com.au Tue Dec 14 08:28:36 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 14 Dec 1999 07:28:36 GMT Subject: win32com: subclass a com object? References: <830pi6$n4k$1@nnrp1.deja.com> <832skg$4bn$1@nnrp1.deja.com> <32f54.31$Nq1.272@news-server.bigpond.net.au> Message-ID: Samuel A. Falvo II wrote in message ... >>Yes - you can do this - but only for your own Python code - there is no >>reasonable way to setup COM so that anyone else (ie, other languages and >>programmers) can create an "Excel.Application" object and have it use yours. >>It _would_ be basically possible to have it work with "MyExcel.Application". > >CoTreatAsClass(). 'Nuff said. ;) he - well, that isnt exposed by Python tho! I better add it :-) Mark. From grant at nowhere. Thu Dec 30 12:46:31 1999 From: grant at nowhere. (Grant Edwards) Date: Thu, 30 Dec 1999 11:46:31 GMT Subject: console package? References: <386ADA80.B17F335D@wcnet.net> Message-ID: In article <386ADA80.B17F335D at wcnet.net>, John Estess wrote: >Is there a console package (like dialog) for Python? Yes: snack. It's based on newt/slrn (same as dialog, IIRC). >Where? Good question. RedHat Linux installs it by default, so I never had to go find it. Searching the usual web sites turns up nothing. There's also something called Tinter which claims to be "A curses based interface module for Python. Tinter supports buttons, text boxes, dialog boxes, progress bars, etc." Search for it at http://www.vex.net/parnassus. (I've never tried Tinter.) -- Grant Edwards grante Yow! ... the MYSTERIANS at are in here with my visi.com CORDUROY SOAP DISH!! From aahz at netcom.com Thu Dec 30 01:49:08 1999 From: aahz at netcom.com (Aahz Maruch) Date: 30 Dec 1999 00:49:08 GMT Subject: Python Database Connectivity References: <386AA8C1.EAD7DD3B@exceptionalminds.com> Message-ID: <84ea64$pkt$1@nntp8.atl.mindspring.net> In article <386AA8C1.EAD7DD3B at exceptionalminds.com>, Timothy Grant wrote: > >Just wondering if anyone has used Python on Windows to connect to an >ODBC database? Yes. Use mxODBC. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Eighth Virtual Anniversary -- 2 days and counting! From ejr at CS.Berkeley.EDU Wed Dec 1 22:17:32 1999 From: ejr at CS.Berkeley.EDU (Edward Jason Riedy) Date: Wed, 01 Dec 1999 13:17:32 -0800 Subject: Modules/getpath.c chases links? In-Reply-To: Your message of "Mon, 29 Nov 1999 17:27:36 EST." <14402.64984.900304.580726@weyr.cnri.reston.va.us> Message-ID: <199912012117.NAA07456@lotus.CS.Berkeley.EDU> And "Fred L. Drake, Jr." writes: - - Without that, automatic detection of the installation directories - becomes massively fragile. I'm complaining because it broke. - I'm not sure I follow. This sounds incredibly difficult to - maintain. What does it buy you? Uniformity across hundreds of packages. See http://www.cise.ufl.edu/depot/. I'm not terribly fond of the CMU depot software (there are other implementations), but the organization works quite well. It's not at all complex. Everything gets to play dumb and assume all its pieces are where it expects. Most things just work. With a few thoughtful variable settings, even Perl's CPAN.pm works. - kpathsea is overkill for most things; anything that doesn't have the - number of critical configuration items that a TeX installation has - doesn't need such a heavy approach. True, but it works. I suppose it works by being overly clever and configurable. I prefer packages to take the dumb, installer-said-I-was-installed-here-so-I-was approach. Being to clever makes packages less predictable, and that's bad. Jason From mhammond at skippinet.com.au Sun Dec 5 01:18:09 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 05 Dec 1999 00:18:09 GMT Subject: Environment variables References: <1267895477-5653035@hypernet.com> Message-ID: <5bi24.3542$GA.17975@news-server.bigpond.net.au> Kevin Cazabon wrote in message ... >Then, if I then go to the Control Panel/System/Environment tab, my addition >IS there... If I then say "OK", and try the program again, everything >WORKS. But, until I go into the Control panel, or reboot, it does NOT work. >So, to me it looks like it's just not effective until I force NT to >re-initialize the path. I believe that Control Panel broadcasts a message to all windows - quite possibly WS_SETTINGCHANGED or some other I can't recall. The desktop sees this message and updates its environement, thereby allowing all programs started by the desktop to see the new environment. However, there is no magic involved. If a command-prompt, for example, is already running, it will not see the new environment. This works simply because the desktop sees the ini change and updates its own environment. You could use Cpy++ or some other message sniffer, and attempt to send the same message to the desktop. Starting to get a bit of a hack tho... >os.putenv(), but it's no good for a separate Python thread. (Hey Mark, if >you're out there...) q:] :-) Mark. From moun at usenix.org Fri Dec 3 02:33:21 1999 From: moun at usenix.org (Moun Chau) Date: Fri, 3 Dec 1999 01:33:21 GMT Subject: Registration for 7th USENIX Tcl/2k Conference Message-ID: The Tcl/2K Conference is an excellent opportunity for programmers, designers and specialists to connect with the Tcl community, hear about exciting new projects and developments, and learn from experts with in-depth knowledge of Tcl and related products. 7th USENIX Tcl/2K Conference February 14 - 18, 2000 Marriott Hotel Austin, Texas, USA http://www.usenix.org/events/tcl2k TUTORIAL SESSIONS - MASTER COMPLEX TECHNOLOGIES ================= *Learn in-depth procedures from industry experts and professionals *Select from the following topics: Effective Tcl Programming XML and Tcl/Tk Tcl Extension Building and SWIG Network Management w/ Scotty Building Applications with BLT Object Oriented Programming Embedding Tcl om C/C++ Apps Tcl Internals TECHNICAL SESSIONS - SELECT FROM A VARIETY OF SEMINAR OPTIONS ================== *Keynote by Jim Davidson of America Online, Inc. "Tcl in AOL Digital City: The Architecture of a Multithreaded High Performance Web Site" *Refereed Papers discuss industry research, innovation and trends. Topics include: Middleware, Testing and Integration, Web Technologies, User Interface and Applications, and Extending CORE Tcl *BoFs and WiPs bring attendees together for informal reports on interesting new projects and on-going work. Fast paced and spontaneous, WiPs and BoFs discuss new ideas and novel solutions. See website for schedule and to reserve WiP slots. ====================================================== For detailed a program as well as online registration: http://usenix.org/events/tcl2k ====================================================== From sameer_ at netzero.net Mon Dec 20 05:00:19 1999 From: sameer_ at netzero.net (sameer chowdhury) Date: Sun, 19 Dec 1999 23:00:19 -0500 Subject: sockets Message-ID: <001101bf4a9e$bc716720$aa72d03f@sameer2> Spam detection software, running on the system "albatross.python.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hi everyone: The first time I connect a client and a server using sockets, it works fine, I then close both sockets. But the second and subsequent times, I get the following error, even if I change the ports for both the client and the server. Can anyone tell me what the reason could be? I am using Win98, and running python 1.5.2. [...] Content analysis details: (5.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 FH_DATE_IS_19XX The date is not 19xx. 3.3 DATE_IN_FUTURE_12_24 Date: is 12 to 24 hours after Received: date -------------- next part -------------- An embedded message was scrubbed... From: "sameer chowdhury" Subject: sockets Date: Sun, 19 Dec 1999 23:00:19 -0500 Size: 2884 URL: From aa8vb at yahoo.com Tue Dec 21 13:21:51 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 21 Dec 1999 07:21:51 -0500 Subject: LISTS: Extract every other element In-Reply-To: <385E732C.FA0CCCE5@appliedbiometrics.com> References: <19991216131341.A153923@vislab.epa.gov> <19991217112304.A1847@stopcontact.palga.uucp> <19991216131341.A153923@vislab.epa.gov> <14425.13561.91576.602473@dolphin.mojam.com> <14425.16338.583342.648548@buffalo.fnal.gov> <19991217091256.A168025@vislab.epa.gov> <19991216131341.A153923@vislab.epa.gov> <007501bf486a$1a143b50$83421098@duke.edu> <19991220121716.A5107@vislab.epa.gov> <385E732C.FA0CCCE5@appliedbiometrics.com> Message-ID: <19991221072151.A8466643@vislab.epa.gov> Christian Tismer: |Your results are most interesting. Mike did the Numeric tests |without re-converting to a true list. You do it, and then |I beat Numeric. This was what I expected, btw. I figured it wouldn't be fair not to have the output of all algorithms be the same type of list. |I also assume that you do one test after the other, many times? |If not, I loose! :-)) I thought about that. But the difference isn't that much. One would think the algorithms at the bottom might pay a price due to increased memory fragmentation and garbage collection overhead, but commenting out all but one (yours or the mxTools fragment for example) reveals a difference in the 0.01-0.03 second range. Background noise. -- Randall Hopper aa8vb at yahoo.com From js at ac-copy.net Sat Dec 25 15:18:37 1999 From: js at ac-copy.net (Joachim Schmitz) Date: Sat, 25 Dec 1999 15:18:37 +0100 (CET) Subject: [ANNOUNCE] PySol 3.10 - a solitaire game collection In-Reply-To: <19991222015859.A9045@laetitia.oberhumer.com> Message-ID: Hi, did anyone successfully run it on an iMac. After loading about 85 % the loading stops with an "not enough memory error" ? On Wed, 22 Dec 1999, Markus F.X.J. Oberhumer wrote: > -----BEGIN PGP SIGNED MESSAGE----- > > > PySol - a Solitaire Game Collection > Version 3.10 > > http://wildsau.idv.uni-linz.ac.at/mfx/pysol.html > > Copyright (C) 1998, 1999 Markus F.X.J. Oberhumer > > > > What is PySol ? > =============== > > PySol is an exciting collection of 128 solitaire card games. > > Among the supported games are classics like Aces Up, Baker's Game, > Canfield, FreeCell, Forty Thieves, Golf, Klondike, Monte Carlo, > Osmosis, Pyramid, Scorpion, Spider, Yukon, and many more... > > PySol may be freely distributed under the terms of the GNU GPL. > > PySol aims to be Commercial Quality Freeware. > > > Why yet another solitaire game ? > ================================ > > Here are some highlights of PySol: > > - currently supports 128 (!) distinct solitaire variants > - based upon an extensible solitaire engine > - very nice look and feel including multiple cardsets > and background table tiles > - unlimited undo & redo > - load & save games > - player statistics and log files > - hint system > - demo games > - support for user written plug-ins - add your own solitaire variants > - integrated HTML help browser > - lots of documentation > - fully portable across Unix/X11, Windows 95/98/NT and MacOS > - written in 100% pure Python > - just run it - no need to compile anything > - freely available > - distributed under the GNU GPL with full source code > > > Yeah, I know. But what's new ? > ============================== > > * Implemented 17 new games. > > * Added sound support including samples and background MP3/MOD music. > Sound is implemented by a rather generic server (a C program) using > the SDL library for low-level mixing and playing. > > * Wrote some really fancy tree dialogs - Python programmers will > definitely love these :-) > > * Added 19 great cardsets to pysol-cardsets. Many thanks to T. Kirk. > > > Cool. Where can I get it ? > ========================== > > Point your browser to http://wildsau.idv.uni-linz.ac.at/mfx/pysol.html > The PySol Gallery is awaiting your visit as well. > > > What do I need to start playing ? > ================================= > > PySol requires Python 1.5.2 and Tcl/Tk 8.0.5. Both packages are > freely available for Unix, Windows 95/98/NT and Macintosh. > > BTW, there is no need to compile anything since the whole program is just > a Python script. Just run it, and that's all. > > > Contributions > ============= > > I'm looking for people who want to contibute new games, provide > additional graphics, scan cardset packs, improve the docs, etc. > Please see the README in the distribution about details. > > > License terms > ============= > > PySol is Copyright (C) 1998, 1999 Markus Franz Xaver Johannes Oberhumer > > PySol is distributed under the terms of the GNU General Public License (GPL). > See the file COPYING. > > > Have fun, > Markus > > http://wildsau.idv.uni-linz.ac.at/mfx/pysol.html > > > > -----BEGIN PGP SIGNATURE----- > Version: 2.6.3ia > Charset: noconv > > iQCVAwUBOGAYJ210fyLu8beJAQH9EgQAsRwAPJHhEm1aMN9C+FVbhcDHrkqOUOmT > WrD7sJRtvFpFfZ72GrcYpczgmB3tjwJsfh2C4dOtajrBGdIZuCh5z+f7aHnp77n7 > oOPKxmpmQzlq/l5t2hlhewbE2dXFMh8+dbbygzfGVgORs0SbKi8CxTQFjzoZPy4t > p6TiDKXl9bw= > =5B4i > -----END PGP SIGNATURE----- > > -- > http://www.python.org/mailman/listinfo/python-list > Mit freundlichen Gr??en Joachim Schmitz WWW-Consultant email: js at ac-copy.net tel: +49-241-89491-0 fax: +49-241-89491-29 From tim_one at email.msn.com Wed Dec 15 08:48:42 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 15 Dec 1999 02:48:42 -0500 Subject: Newbie Variable Definition Question In-Reply-To: <38566A51.A1DFD2F6@coastalnet.com> Message-ID: <000c01bf46d0$cecf57a0$05a0143f@tim> [Andrew N. McGuire] > ... > I was wondering if there was a way to check if a variable is > assigned by referencing its name in python, even if there is a > chance that it is not defined.... > All my attempts lead to NameError, perhaps this can be used, > but I have not figured out how to keep the script from stopping > after the NameError error. As has been said, wrapping in a "try:/except NameError:" block is a reliable way to do this. As has not been said, take the opportunity to learn a better of doing this stuff. It's a Real Language; shell hideousisms can be left behind with obscene glee! For example, Python supports default arguments, default values for getattr, default dict lookup values via dict.get(thing, default), and so on. Testing for name definition is a bad old brittle habit. neutrally y'rs - tim From smata1de at gmx.de Mon Dec 20 18:50:33 1999 From: smata1de at gmx.de (stephane) Date: Mon, 20 Dec 1999 18:50:33 +0100 Subject: Next Version 1.6 or 2.0 Message-ID: <385E6C69.C07DC24@gmx.de> hi to all, I have only one little question: -will the next Python version be 1.6 or 2.0?? -at what time will it appear thanks & bye Stephane From niels at endea.demon.nl Fri Dec 24 20:29:22 1999 From: niels at endea.demon.nl (Niels Diepeveen) Date: Fri, 24 Dec 1999 20:29:22 +0100 Subject: strptime on Unix systems References: <19991222110107.A972@Ridcully.home> <19991223104634.A766@Ridcully.home> Message-ID: <3863C992.DD863CDC@endea.demon.nl> Malcolm Tredinnick schreef: > > On Wed, Dec 22, 1999 at 04:46:27PM -0500, Justin Sheehy wrote: > > "Malcolm Tredinnick" writes: > > > > > The following does *not* work under Linux (at least): > > > > > > import time > > > format = '%a %b %d %H:%M:%S %Z %Y' > > > t = time.localtime(time.time()) > My conclusions from this (and private emails a few have sent me): > (1) The problem is with the Linux library Not really. It's standard UNIX. Take a look at http://www.opengroup.org/onlinepubs/7908799/xsh/strftime.html and http://www.opengroup.org/onlinepubs/7908799/xsh/strptime.html I can think of at least two reasons for the omission of %Z from standard strptime(): 1. There is AFAIK no universally accepted standard for naming time zones. This would make it hard to parse a time zone field reliably. 2. If it did parse the time zone, what would it do with it? strftime() just gets the local time zone name from a global variable. If strptime() did the reverse, it might throw the whole program into a time warp. So, on the whole it's not very clear what %Z should do. BTW, what does it do on BSD? -- Niels Diepeveen Endea automatisering From piet at cs.uu.nl Thu Dec 2 16:21:13 1999 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 02 Dec 1999 16:21:13 +0100 Subject: breakout References: <825o0f$250$1@news.qub.ac.uk> Message-ID: >>>>> stuarty at excite.co.uk (s) writes: s> Has anyone wrote a breakout(fairly manditory to have breakout) script in s> python yet ? You mean the Breakout game? I am doing one in wxPython, but it is not yet finished. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: Piet.van.Oostrum at gironet.nl From parkw at better.net Wed Dec 22 19:58:16 1999 From: parkw at better.net (William Park) Date: Wed, 22 Dec 1999 13:58:16 -0500 Subject: Anyone else making music with python? In-Reply-To: <386115AB.A0DD3F6@angelfire.com> References: <386115AB.A0DD3F6@angelfire.com> Message-ID: <19991222135816.A579@better.net> On Wed, Dec 22, 1999 at 01:17:15PM -0500, Paul Winkler wrote: > Hi, > > Am I the only one crazy enough to make music directly in python > scripts? i.e. not with an application but by programming the > composition... Nice going. I write pure Python codes for numerical stuffs, instead of using Fortran libraries, unless I really have to use them. It's faster, I find, if you consider the entire development span and not just execution time. > > I've been working on a module to help me do exactly that. I use the > module to generate csound scores and do nice things like keep track > of tempo changes for me. I'm discovering lots of interesting > problems along the way and actually managing to make a little music. > Eventually I hope to abstract the data away from csound scores so it > could output various types of musical data (midi, csound, cmix, > whatever). No need to define a new file format for saving this > abstract data-- pickle will do nicely! > > I would very much like to hear opinions, advice, improvements, > bugfixes, etc. Especially there are some big problems in the TODO > list I need to solve soon. So far it is procedural in style but I'm > beginning to see how an OO design might hellp. > > The module is called pysco, and currently lives at: > http://www.ulster.net/~abigoo/pw_linux/code.html#pysco > > Current version is pysco 0.0.2. Just read it; unfortunately, I don't know anything about music, other than the fact that I like Beethoven. I usually write procedural design first, play with it, and then re-write it in OO when there is clear separation of data objects. Good luck. --William Park From dannyjob at my-deja.com Wed Dec 1 16:02:48 1999 From: dannyjob at my-deja.com (dannyjob at my-deja.com) Date: Wed, 01 Dec 1999 15:02:48 GMT Subject: GUI : Group Button Message-ID: <823dac$e44$1@nnrp1.deja.com> I am attempting to create a GUI using Tkinter which has "Group buttons" e.g : * Group A Button * Group B Button * Group C Button Option menu 1 Option menu 2 option menu 3 Other Group C Items.... For example when the Group C button is clicked, the option menus etc, will be displayed. If the Group C button is clicked on again , the option menus etc, belonging to group C, will disappear, and only the group button will be displayed. Any help would be greatly appreciated. Thanks in advance, Dan Sent via Deja.com http://www.deja.com/ Before you buy. From fredrik at pythonware.com Mon Dec 27 15:06:16 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 27 Dec 1999 15:06:16 +0100 Subject: Basic extension questions. References: Message-ID: <000901bf5073$8b6a16b0$f29b12c2@secret.pythonware.com> Joakim Ziegler wrote: > So I was wondering if there are any short tutorials or recommended simple > examples out there of how to define a new Python object type using C. What > I'd like is an example of how to create an object with a few methods, which > are also written in C. Does this exist somewhere? from the eff-bot archives: http://www.deja.com/getdoc.xp?AN=318572911&fmt=raw From munif at dnet.net.id Thu Dec 2 09:49:24 1999 From: munif at dnet.net.id (Ahmad Munif) Date: Thu, 2 Dec 1999 15:49:24 +0700 Subject: is possible to put wxCheckbox into wxGrid ? Message-ID: hi, how to put other windows (such as check Box) into wxGrid ? From skip at mojam.com Thu Dec 9 18:22:37 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 9 Dec 1999 11:22:37 -0600 (CST) Subject: string interpolation syntactic sugar In-Reply-To: <14415.57793.278683.360085@goon.cnri.reston.va.us> References: <82ogb2$db2$1@pegasus.csx.cam.ac.uk> <14415.57793.278683.360085@goon.cnri.reston.va.us> Message-ID: <14415.58717.115675.804984@dolphin.mojam.com> >>>>> "Jeremy" == Jeremy Hylton writes: Jeremy> When I have complicated formats, I usually turn to dictionaries Jeremy> rather than trying to match up format strings with a tuple of Jeremy> values: Jeremy> "a %(x)s b %(y)s" % { 'x': math.log(0), Jeremy> 'y': y } It's perhaps worth pointing out that in situations where all the items you want to interpolate are local variables you can use the locals() builtin function instead of building a dict on-the-fly in your code "a %(x)s b %(y)s" % locals() (I know Jeremy knows this, just pointing it out for others new to Python's string interpolation facility.) 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 phd at phd.russ.ru Wed Dec 1 15:14:54 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 1 Dec 1999 14:14:54 +0000 (GMT) Subject: wish: multiline comments In-Reply-To: <11A17AA2B9EAD111BCEA00A0C9B41793034AAF53@molach.origin.ea.com> Message-ID: On Wed, 1 Dec 1999, Stidolph, David wrote: > You've got them. > > """ This is a multi-line comment > that runs until the next set > of triple quotes.""" > > That was a comment in every sense. The only other thing is that following a > class definition, it places the comment in the __doc__ variable. I wanna call this "desired side-effect"! :) Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From a.eyre at optichrome.com Wed Dec 1 16:45:43 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Wed, 1 Dec 1999 15:45:43 -0000 Subject: wish: multiline comments In-Reply-To: <018801bf3c12$d9722e80$f29b12c2@secret.pythonware.com> Message-ID: <000c01bf3c13$202787d0$3acbd9c2@peridot.optichrome.com> > well, the compiler throws away strings that does > not appear in valid docstring positions. if you put > this in a module: > [snip] Fair enough. But that does then place a restriction on where you can use this construct. And I'm willing to bet it'll take longer to compile the pyc. -------------------------------------------- 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 skip at mojam.com Thu Dec 16 20:00:21 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 16 Dec 1999 13:00:21 -0600 (CST) Subject: Pipe error codes off by a factor of 256 In-Reply-To: <83ba4k$9ia$1@nnrp1.deja.com> References: <83ba4k$9ia$1@nnrp1.deja.com> Message-ID: <14425.14021.528956.37955@dolphin.mojam.com> Ben> I'm trying to capture the error code from a pipe opened with Ben> os.popen(). I can successfully store the returned code in a Ben> variable, but the returned code always is exactly 256 times larger Ben> than it should be. That's the way the underlying popen works, and it's documented, sort of. >From the os lib reference page: The exit status of the command (encoded in the format specified for wait()) is available as the return value of the close() method of the file object, except that when the exit status is zero (termination without errors), None is returned. Unfortunately, I don't find any documentation on wait's return status. From grant at nowhere. Thu Dec 23 20:06:12 1999 From: grant at nowhere. (Grant Edwards) Date: Thu, 23 Dec 1999 19:06:12 GMT Subject: __init__ keyword param for sub-class? Message-ID: I want to sub-class something that takes one positional and a whole slew of keyword arguements when the object is instantiated, and I want to add one keyword argument (keyword 'myoption' in the below example) to be handled by my method, and pass the rest on the the super-class. I couldn't find any examples of this type of thing, so this is what I came up with: class execWindow(Pmw.ScrolledText): def __init__(self, *posArgs, **keyArgs): if keyArgs.has_key('myoption'): self.__myoption = keyArgs['myoption'] del keyArgs['myoption'] return apply(Pmw.ScrolledText.__init__, (self,) + posArgs, keyArgs) [ various other methods and stuff ] Is this the "right" way to do this? -- Grant Edwards grante Yow! I just got my PRINCE at bumper sticker... But now I visi.com can't remember WHO he is... From sposhua at my.pc Thu Dec 16 19:21:33 1999 From: sposhua at my.pc (Sposhua) Date: Thu, 16 Dec 1999 18:21:33 +0000 Subject: Multi-User non Client/Server database In-Reply-To: References: Message-ID: On Thu, 16 Dec 1999, Anders M Eriksson wrote: > I need a database and I can't use a Client/Server database since my > ISP refuses to let me install one. The database has to be Multi-User, > with record locking so that different user can read and write > 'simultaniously' (.don't remember the correct word.) > > An xBase database would do perfectly! > > Are there any xBase Python libraries?? Don't know what xBase is, but try the shelve library for databases. I think it also does all the file locking for you. From mlh at vier.idi.ntnu.no Sat Dec 18 18:44:06 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 18 Dec 1999 18:44:06 +0100 Subject: LISTS: Extract every other element References: <19991216131341.A153923@vislab.epa.gov> <19991217112304.A1847@stopcontact.palga.uucp> <14426.29235.486363.37011@buffalo.fnal.gov> Message-ID: Charles G Waldman writes: > Gerrit Holl writes: > > Randall Hopper wrote: > > > I want to take a large list: > > > > > > [ 1,2,3,4,5,6,7,... ] > > > > > > and build a list with every other element: > > > > > > [ 1,3,5,7,... ] How about: def odd(pair): return pair[0] % 2 == 1 def second(pair): return pair[1] lst = range(10) result = map(second,filter(odd,map(None,range(len(lst)),lst))) Quite intuitive ;) -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From sjturner at ix.netcom.com Fri Dec 10 16:23:58 1999 From: sjturner at ix.netcom.com (Stephen J. Turner) Date: Fri, 10 Dec 1999 10:23:58 -0500 Subject: Tk Listbox bindings References: <199912092219.XAA26417@axil.hvision.nl> Message-ID: <38511B0E.D2811B72@ix.netcom.com> Hans Nowak wrote: > While it's easy to bind mouse events to a listbox, I haven't managed > to bind keyboard events to it. In a current project I have a listbox > and I want my users to be able to scroll through it using common keys > like and . However, binding them to the listbox, as done > above, does not work; I don't know why. > > If I do a bind_all, it does work, though. Unfortunately, this is not > the right way to do it; I have another window with a ScrolledText > widget, and if I scroll there, the listbox scrolls too, due to the > bind_all effect! > > Experimenting, I also tried binding "" (etc) to all widgets in > the current frame, which doesn't work either. > > So my obvious question is, how can I bind keyboard events to a > listbox without having to use bind_all? The problem is that key press/release events are sent to the widget that currently has input focus, which by default is the toplevel window. To explicitly set focus to the listbox when clicked, use something like the following: class display_list(Frame): def __init__(self, parent, items, height = 15, width = 20): # ... initialization snipped ... self.listbox.bind('', self.setfocus) def setfocus(self, ev): self.listbox.focus() Incidentally, the and behavior you described is already in Tk's default listbox bindings (see listbox.tcl), so you should be done once you set focus. Regards, Stephen -- Stephen J. Turner From tjreedy at udel.edu Wed Dec 15 06:45:06 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 15 Dec 1999 05:45:06 GMT Subject: Newbie: need help with control loop References: <38543b80.289200819@news-server> <8321cu$i1h$1@news.udel.edu> <3854d1ca.327680172@news-server> Message-ID: <8379t2$v9$1@news.udel.edu> In article <3854d1ca.327680172 at news-server>, nospam.python at scoobysnacks.com says... > >On 13 Dec 1999 05:49:18 GMT, tjreedy at udel.edu (Terry Reedy) wrote: > >>In article <38543b80.289200819 at news-server>, >>nospam.python at scoobysnacks.com says... >>> >>You should probable create instance next: >> host_inst = class_name(machine) > >This was my whole question. Where or what is host_inst. In each case >it will be different I can create the object, I just can't name it. If, as per my suggestion, machine is bound to the name of the host, then the class __init__(self, machine) function should save the name. This is another reason to iterate over the names instead of the indexes. You might need to reread tutorial and ref on class and instances. PS. Sorry for assuming that nospam... was fake. Clever, given that spambots will usually remove it. From wjk at wjk.mv.com Thu Dec 23 06:23:25 1999 From: wjk at wjk.mv.com (Wm. King) Date: Thu, 23 Dec 1999 00:23:25 -0500 Subject: How to read lines from end of a file? References: <4rhfhazoj4.fsf@colargol.tihlde.hist.no> Message-ID: <3861B1CC.F5570E6@wjk.mv.com> Just a newbie comment/question Would another approach be to simply "import os" use a UNIX command to 'tail -10 nameoflogfile' then use ' os.popen(cmd).readlines()' in a for loop or something like that rather than reading in a whole file and reversing it to get the last few lines.... This approach works in shell scripting, so I thought maybe this would work with Python as well... From phd at phd.russ.ru Mon Dec 20 12:57:25 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Mon, 20 Dec 1999 11:57:25 +0000 (GMT) Subject: LISTS: Extract every other element - SUMMARY In-Reply-To: <385E17C2.B69A3C98@udel.edu> Message-ID: On Mon, 20 Dec 1999, Charles Boncelet wrote: > I don't know why mxTools are not more widely used (ie. part of the > standard distribution). Licensing, I think... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From cjc26 at nospam.cornell.edu Sat Dec 4 00:05:42 1999 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: 3 Dec 1999 23:05:42 GMT Subject: indentation References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> <19991203211232.A11045@stopcontact.palga.uucp> <14408.13481.279705.753821@weyr.cnri.reston.va.us> Message-ID: Pada Fri, 3 Dec 1999 16:22:49 -0500 (EST), Fred L. Drake, Jr. bilang: | | Gerrit Holl writes: | > As i said: people who start with Python as a first language like it. | | There are those of us who started with x86 assembly and BASIC who | like it too! (And Pascal, and C, and C++, and... hey, how many places | can one person start in, anyway? ;) Well let's see..I started with Logo actually, when I was six years old. They taught it in elementary school--in fact, that was the only programming class I ever got to take, until I went to college. Then I went on to BASIC when I was eight, and taught myself Forth and C when I was eleven. 65xx assembler the next year, and 680x0 a couple years later. Lisp sometime in high school. I picked up bits of Pascal, Modula-2, Smalltalk, and Pop-11 along the way. Ok, so I was a little geeky as a kid..;) -- cliff crawford http://www.people.cornell.edu/pages/cjc26/ -><- "I am not an HTML tag!" --Manuel From dbenham at mecasw.com Wed Dec 8 20:57:28 1999 From: dbenham at mecasw.com (Doug Benham) Date: Wed, 8 Dec 1999 14:57:28 -0500 Subject: TK tree control References: <82lap0$sa4$1@nnrp1.deja.com> Message-ID: <82mdir$3qsu2@news.mecasw.com> I'm new to this (newsgroup, and Python both), but I did look at the wxPython demo, and it has a pretty nice set of widgets, including a tree control. They also have a grid control, but I can't say how good it is. ======================================================= Doug Benham dbenham at concentrex.com EARTH FIRST--we'll screw up the other planets later ======================================================= yosef at adsc.com wrote in message <82lap0$sa4$1 at nnrp1.deja.com>... >I am thinking of using TK with Python for an upcoming project. >I need a tree control which TK does not seem to have. I have heard >that a list control can be kludged into a sort of tree control. To me >this does not seem like an optimal solution. Is there a way to use any >of the various TK tree controls via Python/Tk? > >Also, what is the best way to do grids in TK? In the C++/MFC side, I >use a 3rd party product for my grids which gives me a lot more >flexibility than trying to do it with the native Windows controls? Is >there a TK grid control that can be used via Python? > > >thanks, >Yosef Gold >yosef at adsc.com > > > >Sent via Deja.com http://www.deja.com/ >Before you buy. From aj10 at my-deja.com Thu Dec 2 01:12:33 1999 From: aj10 at my-deja.com (aj10 at my-deja.com) Date: Thu, 02 Dec 1999 00:12:33 GMT Subject: [Tutor] TKinter References: <003301bf3ab5$13138080$0c5bdfc8@the-user> <38431229.7B60A603@worldnet.att.net> <384314A8.6929482C@callware.com> Message-ID: <824dhd$77f$1@nnrp1.deja.com> Lastly, take a look at PMW (Python Mega Widgets) also. It is well document and it is very simple to make pretty nice apps using it immediately. I struggled with Tkinter, but took to pmw very very fast. Much much more intuitive. It can be found at http://www.dscpl.com.au/pmw/ Definitely worth a look and it is built atop Tkinter. -aj In article <384314A8.6929482C at callware.com>, Ivan Van Laningham wrote: > Hi All-- > > Ralph Alberti wrote: > > > > Have you seen this: > > > > http://starship.python.net/crew/fredrik/tkintro/Introduction.htm > > > > --Ralph > > > > Alexandre Passos wrote: > > > > > > Has someone got a link to some __downloadable__ tutorial of TKinter? > > > > > And also this: > > http://www.pythonware.com/library.htm > > Which has a link to the PDF version of the introduction. > > There're lots of parts missing, 'cause /F is so busy, but it's still > about the best place to start. ... > > Take care, > 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 > Author: Teach Yourself Python in 24 Hours > ---------------------------------------------- > > Sent via Deja.com http://www.deja.com/ Before you buy. From m.faassen at vet.uu.nl Fri Dec 3 17:12:16 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Dec 1999 16:12:16 GMT Subject: split this newsgroup? References: <5650A1190E4FD111BC7E0000F8034D26A0F17A@huina.oceanic.com> Message-ID: <828q50$jco$2@newshost.accu.uu.nl> Doug Stanfield wrote: > I agree, lets split. >> what subgroups did you have in mind? >> >> > I propose: > c.l.py.humorous > c.l.py.that-serious-python-internals-stuff-and-ruby-viper-and-alternates-to > while-1-ladat Darn, I'd be subscribing to both of those! That-reflects-badly-on-my-posting-patterns-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From fdrake at acm.org Wed Dec 1 16:44:31 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 1 Dec 1999 10:44:31 -0500 (EST) Subject: wish: multiline comments In-Reply-To: <000b01bf3c10$4faf3910$3acbd9c2@peridot.optichrome.com> References: <000b01bf3c10$4faf3910$3acbd9c2@peridot.optichrome.com> Message-ID: <14405.16991.260325.16506@weyr.cnri.reston.va.us> Adrian Eyre writes: > I would like to see multiline comments possible in some future > version of Python. Someone suggested: > Use multiline strings. Adrian responded: > Not quite the same is it? A docstring will be put in the .pyc. A comment > won't. Only docstrings will be added to the .pyc, not *every* multiline string. class B: """Okay. This is a short, 1-line docstring.""" """This is my 42-million line extended comment. Pretend I really wrote a lot here. """ pass > In one case, the .pyc generated is much bigger than the other. I not saying > that docstrings are bad, but they are NOT the same as comments, in that they > serve a purpose at runtime. Using multiple long strings allows for both a runtime-accessible docstring, extensive documentation, and minimal .pyc size and runtime memory consumption. Tools that are being prototyped and discussed in the Doc-SIG will be able to make use of multiple long docstring-like strings, so this also provides some forward-compatibility. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From c.evans at clear.net.nz Sat Dec 11 21:09:20 1999 From: c.evans at clear.net.nz (Carey Evans) Date: 12 Dec 1999 09:09:20 +1300 Subject: calling Python from C: I can't get this part. References: <82res6$896$1@nnrp1.deja.com> Message-ID: <87n1rhb5ov.fsf@psyche.evansnet> Very Frustrated writes: [...] > Now, all I want to do is, instead of pointing to a C function that has to > be compiled and included in the library, I want to have ga_info->EV_fun > point to a Python function and have the Python function receive the > (Chrom_Ptr chrom) argument. > > The rest is easy, but even after looking at the examples in the SWIG > manual, I am still not clear how you do this. I don't use SWIG myelf, but this looks like the examples in examples/python/callback and callback2 in my installation. It might be a bit harder since you don't get to specify any data to the callback, so you'd have no way of knowing which instance of GA_config is being used, unless the Chrom_Ptr includes enough info. Have you looked at these examples and gotten completely mystified, or are you having trouble with another bit of this? -- Carey Evans http://home.clear.net.nz/pages/c.evans/ "This is where your sanity gives in..." From aa8vb at yahoo.com Mon Dec 20 18:17:16 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 20 Dec 1999 12:17:16 -0500 Subject: LISTS: Extract every other element In-Reply-To: <007501bf486a$1a143b50$83421098@duke.edu> References: <003801bf488b$76a48250$3acbd9c2@peridot.optichrome.com> <19991216131341.A153923@vislab.epa.gov> <19991217112304.A1847@stopcontact.palga.uucp> <19991216131341.A153923@vislab.epa.gov> <14425.13561.91576.602473@dolphin.mojam.com> <14425.16338.583342.648548@buffalo.fnal.gov> <19991217091256.A168025@vislab.epa.gov> <19991216131341.A153923@vislab.epa.gov> <007501bf486a$1a143b50$83421098@duke.edu> Message-ID: <19991220121716.A5107@vislab.epa.gov> eric jones: Mike Fletcher: |>>> from Numeric import * |>>> a = array(range(10)) |>>> a[::2] Pretty fast. Christian Tismer: |def slice100(d): Most impressive. Not as readable, but amazing performance without having to resort to a C extension. Charles Boncelet: |import NewBuiltins # (mxTools) |lst2=extract(lst,trange(0,len(lst),2)) Fastest yet. Thanks for the tips! This has been fun and educational. Here are the latest results, operating on the same test list: [ 0, 10, 20, 30, 40, 50, 60, 70 ] * 100000 Using range() Using xrange() ----------------------------------------------------------- APPROACH #1 | 100.00% (2.09307 sec) | 100.00% (1.99558 sec) * APPROACH #1b | 95.04% (1.98935 sec) | 98.17% (1.95897 sec) * APPROACH #2 | 689.31% (14.4278 sec) | 729.60% (14.5598 sec) * APPROACH #2b | 593.99% (12.4327 sec) | 619.72% (12.3671 sec) * APPROACH #3 | 121.90% (2.55138 sec) | 120.36% (2.40184 sec) * APPROACH #4 | 322.12% (6.74217 sec) | 338.34% (6.75179 sec) APPROACH #4b | 702.62% (14.7063 sec) | 743.19% (14.831 sec) APPROACH #5 | 108.82% (2.27761 sec) | 108.68% (2.1688 sec) * APPROACH #6 | 67.31% (1.4088 sec) | 70.02% (1.39727 sec) APPROACH #7 | 67.58% (1.4146 sec) | 70.17% (1.40032 sec) APPROACH #8 | 33.29% (0.696691 sec) | 34.40% (0.686397 sec) * APPROACH #9 | 31.34% (0.656048 sec) | 34.14% (0.681241 sec) * = uses range/xrange ----------------------------------------------------------------------------- APPROACH KEY: APPROACH #1 - Original "for loop" implementation APPROACH #1b - #1 but use multiply rather than divide APPROACH #2 - filter( lambda a: a != None, map( even_select, lst, range(len(lst)) ) APPROACH #2b - map( second, filter( odd, map( None, range(len(lst)), lst ) ) ) APPROACH #3 - map( lambda x: lst[x], range(0, len(lst), 2) ) APPROACH #4 - filter( on_off, lst ) , where on_off() funct alternates 1/0 APPROACH #4b - filter( onoff(), lst ), where onoff() class instance alt's 1/0 APPROACH #5 - a = Numeric.array( lst, 'O' ) lst2 = list( Numeric.take( a, range(0,len(a),2) ) ) APPROACH #6 - data = Numeric.array( lst, Numeric.Int32 ) data.shape = ( -1, step ) lst2 = list( data[:,0] ) APPROACH #7 - lst2 = list( Numeric.array( lst, Numeric.Int32 )[::2] ) APPROACH #8 - Christian's 100 element walker APPROACH #9 - lst2 = mxTools.extract( lst, mxTools.trange( 0, len(lst), 2 ) ) ----------------------------------------------------------------------------- -- Randall Hopper aa8vb at yahoo.com From artymiak at safenet.pl Wed Dec 1 10:01:18 1999 From: artymiak at safenet.pl (Jacek Artymiak) Date: Wed, 01 Dec 1999 09:01:18 GMT Subject: Stats Message-ID: <3844E0C0.77C29789@safenet.pl> Does anybody know how many people are using Python? 10,000? 100,000? I'm wondering just how big is our community. Jacek Artymiak ------------------------------------------------------------------ Autor/Dziennikarz/Konsultant - Author/Journalist/Consultant artymiak at safenet.pl, http://www.wszechnica.safenet.pl co-author: StarOffice for Linux Bible (IDG Books Worldwide, Inc.) http://www.amazon.com/exec.obidos/ASIN/0764533630/polskawszechnica ------------------------------------------------------------------ From fredrik at pythonware.com Fri Dec 17 09:28:17 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 17 Dec 1999 09:28:17 +0100 Subject: Idle install - no module time References: <3857EB77.BA02A2CF@pinetel.com> <38594300.8D88CDE2@pinetel.com> Message-ID: <00da01bf4868$ac397ab0$f29b12c2@secret.pythonware.com> Harold Weaver wrote: > I have a better definition of my problem: dynamically loaded modules are > absent from my installation. Should this problem be referred to a > newsgroup that deals with "configure"ing and "make"ing ? not necessarily. let's see if this helps: on unix, dynamically loaded modules have names like "timemodule.so" etc. first, make sure you have them in the build directory (if not, look for *shared* in the Setup file, follow the instructions in there, and rebuild) next, check that they were installed (by default, they should be placed in $prefix/lib/python-1.5/lib-dynload where $prefix is the installation root. use: >>> import sys >>> print sys.prefix to figure out what it is on your box (you can change this by setting PYTHONHOME). next, check that the lib-dynload directory is in the path: >>> import sys >>> print sys.path hope this helps! From nobody at nowhere33.yet Mon Dec 13 18:19:06 1999 From: nobody at nowhere33.yet (nobody at nowhere33.yet) Date: Monday, 13 Dec 1999 11:19:06 -0600 Subject: Your not going to believe this...... Message-ID: <13129911.1906@nowhere33.yet> Tee shirts under $4.00 Classy Fleece $10.00 - $20.00 Denim Shirts $9.38 Sweatshirts $8.44 Hooded Sweatshirts $19.69 Printed T-Shirts $5.00 T-shirts $3.00 Caps under $3.00 The bosses say "Sell it, or ELSE!!" so, we are selling lots of fantastic garments at cost!! At these prices, you can buy presents for everyone, and have money left for yourself!! **Quantities are limited** so hurry on over to www.habitatonline.com Get yours before they are all gone!!! www.habitatonline.com From darrell at dorb.com Fri Dec 24 02:45:31 1999 From: darrell at dorb.com (Darrell) Date: Thu, 23 Dec 1999 20:45:31 -0500 Subject: Super-rexex? References: <19991223151828.A3636@stopcontact.palga.uucp> <14434.14004.510906.767308@weyr.cnri.reston.va.us> <1266159968-30845431@hypernet.com> <19991223214353.A8069@stopcontact.palga.uucp> Message-ID: <0f7501bf4db0$929822d0$0100a8c0@rochester.rr.com> May I suggest an XML approach ? I'm sure this won't fit the minimalist approach. But your translators will be able to use standard tools to view and edit the file. -- --Darrell From prestonlanders at my-deja.com Fri Dec 3 17:51:26 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Fri, 03 Dec 1999 16:51:26 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> Message-ID: <828sec$cpq$1@nnrp1.deja.com> In article <828n3e$8kp$1 at nnrp1.deja.com>, ajmayo at my-deja.com wrote: > 2. Does the debugger report context as in > > foo=bar + splat > ^ undeclared variable bar By the way, I just reread your post, and though this is not the question I was asking, you should understand that there isn't really a concept of "undeclared variables" in Python. Variables are 'declared' in a namespace when you first assign to them. The tutorial section on namespaces contains some helpful pointers on this subject. For example: >>> foo = 1 >>> foo = foo + bar Traceback (innermost last): File "", line 1, in ? NameError: bar This is probably what you meant, but I would just like to point out the difference. The problem here is not that bar is undeclared, since you do not 'declare' variables like you do in C. The NameError simply means that Python tried to look up the name 'bar' in the namespace and didn't find it. Hope this clarifies, ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From paul at prescod.net Wed Dec 29 17:49:24 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 29 Dec 1999 11:49:24 -0500 Subject: Py2K wishes References: <1265703355-58310119@hypernet.com> Message-ID: <386A3B94.45C07705@prescod.net> Python 2 isn't under development yet. I didn't expect you guys to try so hard to make my proposal formal. I'll be more careful with my ramblings in the future. Gordon McMillan wrote: > > Your implications don't make sense to me, either. Does the > first assert imply that MI is passe? Good point. It should be __fallbacks__. That makes it more useful anyhow. > Does the second imply > that the difference between bound and unbound methods (and > the reasons for the difference) have disappeared? I admit that bound/unbound methods are one of the areas of Python that I have to constantly re-learn because it doesn't naturally stick in my brain. You are also right that I can't easily map that into __fallback__ because instances do getattr magic to methods that they do not to other attributes. _fallback__ would be fine for the other attributes but that's half a loaf at best. I'm not 100% sure why Python is specified in terms of runtime re-binding instead of "vtables" but it does cause somewhat of a problem here. Since I am talking about Python 2, I can dream that the binding stuff is simpler there. :) Paul Prescod From fdrake at acm.org Thu Dec 30 20:01:08 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 30 Dec 1999 14:01:08 -0500 (EST) Subject: Py2K wishes In-Reply-To: References: <38675B72.18A139FF@prescod.net> <38687D6A.D525D91F@prescod.net> <14440.49939.489193.842560@dolphin.mojam.com> <38693545.894CE515@prescod.net> Message-ID: <14443.44020.300892.834707@weyr.cnri.reston.va.us> Neel Krishnaswami writes: > There are no distinguished classes -- everything is an object. I > am told Javascript is also prototype-based, but I don't know it.) This is correct; each ECMAScript object has exactly one parent object. It supports a number of rules about how to handle setting an attribute; an object can even be set to disallow descendent objects to set a local attribute of the same name, if I recall correctly. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From bitbucket at isomedia.com Wed Dec 29 20:26:50 1999 From: bitbucket at isomedia.com (Eugene Goodrich) Date: Wed, 29 Dec 1999 19:26:50 GMT Subject: Super Tuples - foo.py (0/1) References: <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <386A1037.C6D458B3@prescod.net> <386a43e3.48679477@news.isomedia.com> Message-ID: <386a6039.55933608@news.isomedia.com> I've attempted to attach the code from my previous message in a more accessible manner. Derrrr. -Eugene import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==') From gmcm at hypernet.com Tue Dec 7 20:31:54 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 7 Dec 1999 14:31:54 -0500 Subject: Converting a Shell Script to run under Python In-Reply-To: <82jkol$kl2$1@hub.org> Message-ID: <1267527838-27788006@hypernet.com> D'Arcy J.M. Cain wrote: > Magnus L. Hetland wrote: [exposes unforgivable ignorance of shutil ] > > open("file3","w").write(open("file1").read()) > > > though that is probably not a good idea. I guess I would rather > > do > > Why don't you find this a good idea? It's pretty much a Python > paradigm as far as I'm concerned. I suppose a module with this > in it would make it easier to read but I don't know that I care > for the extra work and overhead. Although I've been known to do this, I can think of 2 reasons why you shouldn't make a habit of it. First, an IOException will be hard to figure out. Second, the same code in JPython will leave you with a mess on your hands, until GC wakes up and cleans it up for you. I happily ignore the second one all the time, too. make-Barry-clean-it-up-ly y'rs - Gordon From mark at intrepid.net Fri Dec 17 22:05:27 1999 From: mark at intrepid.net (Mark Conway Wirt) Date: Fri, 17 Dec 1999 21:05:27 GMT Subject: Python Image Lib Problems References: Message-ID: In article , Mark Conway Wirt wrote: >I've recently build the Python Imaging Library (PIL) and installed it, >but I'm having problems actually getting it to work. The examples >from the documentation -- even the simple ones -- produce copious >errors. For example: > >>>> import Image >>>> im = Image.open("lena.ppm") >>>> im.show() I'll answer my own question on this one. Apparently this is a problem in the library for some people. I found a patch in the imaging SIG that will supposedly fix this (haven't applied it yet). >>>> draw = ImageDraw.Draw(im) >>>> draw.line((0,0), im.size, fill=128) >Traceback (innermost last): > File "", line 1, in ? >TypeError: keyword parameter redefined >>>> ...and this one is a problem with the documentation -- line takes one tuple as input, as opposed to what is shown in the docs. So, I've answered two of my questions -- I'll ask a new one: Does anyone know of any updated documentation on the PIL library? It'll be difficult to use without it, especially considering that I've only been programming in Python for about a week, and it'll be hard to separate my mistakes from the documentation mistakes. TIA. --Mark From nickliz at t-online.de Wed Dec 29 11:03:00 1999 From: nickliz at t-online.de (Eide) Date: Wed, 29 Dec 1999 11:03:00 +0100 Subject: need help getting tk to work with python References: <3867FF5C.F56F4341@earthlink.net> <015e01bf5117$0788d990$f29b12c2@secret.pythonware.com> Message-ID: <84cm9o$6jj$1@news05.btx.dtag.de> I too have been having this problem. Tk once worked, but does no longer. I run W98 with python at C:\program files\python and tcl at C:\program files\tcl I tried the autoexec.bat fix as suggested at python.org to no avail. Here is what I get when trying the Tkinter._test() -------------------------------------------------- Traceback (innermost last): File "", line1, in ? File "C:\PROGRA~1\PYTHON\LIB\LIB-TK\Tkinter.py", line 1947, in _test root = Tk() File "C:\PROGRA~1\PYTHON\LIB\LIB-TK\Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable init.tcl in the following directories: {} ./lib/tcl8.0 C:/tcl8.0/library {C:/Program Files/library} This probably means that Tcl wasn't installed properly. -------------------------------------------------- My autoexec.bat reads: PATH C:\WINDOWS;C:\WINDOWS\COMMAND;C:\PROGRA~1PYTHON;C:\PROGRA~1\PYTHON\LIB;C:\PR OGRA~\TCL\BIN and I have tried every possible combination of "..\tcl\lib\" or "..\tcl\lib\tcl8.0" etc and again, to no avail. I also uninstalled it all, cleaned my registry and reinstalled it. I have no clue at this point. Please advise. Nick From edwardam at home.com Wed Dec 1 05:09:45 1999 From: edwardam at home.com (Edward Muller) Date: Wed, 01 Dec 1999 04:09:45 GMT Subject: [Zope-dev] Re: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF64019276318@gandalf.digicool.com> Message-ID: <38449F86.D6538558@home.com> Michel Pelletier wrote: > > -----Original Message----- > > From: Thomas Heller [mailto:thomas.heller at ion-tof.com] > > Sent: Tuesday, November 30, 1999 2:52 PM > > To: Brian Lloyd; 'Edward Muller'; python-list at python.org > > Cc: zope-dev at zope.org > > Subject: [Zope-dev] Re: Exposing COM via XML-RPC or Something Else > > > > > > > You might want to take a look at MS' SOAP (Simple Object Access > > > Protocol) spec - it's not fully baked yet, but it basically takes > > > xml-rpc several steps further, allowing you to communicate with > > > SOAP-enabled objects (COM or otherwise) using XML over HTTP. We in > > > Zope-land are keeping a close eye on this, as publishing objects > > > via HTTP is the core idea of Zope already. > > > > Zope and SOAP sounds very similar. > > Is this by accident? > > Yup > > -Michel I took a look at the SOAP specs at work, and it is basically XML-RPC with some differences....It looks like MS is at it again....designing YAAPI (Yet Another API) to confuse the world.... :-( From skip at mojam.com Tue Dec 21 17:59:39 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 21 Dec 1999 10:59:39 -0600 (CST) Subject: shelve In-Reply-To: <19991221155108.A2087@stopcontact.palga.uucp> References: <14430.25553.576208.661666@dolphin.mojam.com> <19991221155108.A2087@stopcontact.palga.uucp> Message-ID: <14431.45563.398666.317256@dolphin.mojam.com> Gerrit> Skip Montanaro wrote: >> for k in db.keys(): >> print db[k] Gerrit> What about: Gerrit> for k in db.values(): Gerrit> print k Well, yeah, but shelves can get big. Grabbing the list of keys is likely to be a heck of a lot smaller than smushing the entire db file into a list. 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 mgushee at havenrock.com Mon Dec 13 16:39:58 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 13 Dec 1999 10:39:58 -0500 Subject: Tkinter Menus on WinXX platform References: Message-ID: pf at artcom-gmbh.de (Peter Funk) writes: > Testing on Win98 using py152.exe I noticed three small problems with menus: > 1. Menu Radio- and Checkbuttons have both a check (tick, peg?) where > Radiobuttons shoulld have a dot (period) when selected. That's weird. > 2. If a menu is drawn the first time, selected check und radio buttons > are not drawn correctly. You have to move the mouse cursor above those > buttons to provoke a redraw. Offhand I would suggest calling foo.update_idletasks() ... but if you're already doing that, then I dunno. -- Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ From ajmayo at my-deja.com Fri Dec 3 16:20:18 1999 From: ajmayo at my-deja.com (ajmayo at my-deja.com) Date: Fri, 03 Dec 1999 15:20:18 GMT Subject: Be gentle with me.... Message-ID: <828n3e$8kp$1@nnrp1.deja.com> I know you are all tired of newbies asking what Python is like as a scripting language, so I won't come at you from that track. No, after lurking for all of five minutes, I see you're an affable bunch of characters (and appear to have perhaps more of a sense of humour than aficionados of a certain other language beginning with p..., who have not always appreciated the spirit of my questions on *their* newsgroup). Where I'm coming from is this. I am building web-enabled applications that currently use Apache, with server-side perl and the wonderful Apache::ASP module which gives me the functionality of Microsoft's IIS Active Server Pages, but in an Open Source environment. Client-side, I'm using Javascript. Now, the thing is..... I don't like perl very much (there, I've said it!). Don't get me wrong, lurking perl fanatics. I've already expressed some constructive criticism on *your* home territory and you told me what you thought about my opinions. If I had to summarise my feelings on perl, they'd be 1. I hate, oh how I hate, the metacharacter at the front of every variable which defines its type. 2. I deeply dislike the inadequate debugging messages. 'missing bareword at line 193'? Gimme a break!. Since my code is embedded server- side code evaluated at runtime, where *is* line 193. Who knows? 3. It doesn't seem to be easy to create the equivalent of C structs where member assignments can be checked AT COMPILE TIME (sorry about the shouting, there, but I think lists of lists and all that don't really hack it, in this context, and objects are simply overkill. I just want a goddamn structure). Ok, that's perl. Now, Python. Why the interest.... well,I've discovered Zope. This looks like a mighty fine piece of work and I am very interested.. but it revolves around Python - sort of a Python 'killer app', if you know what I mean. So if I want to buy into Zope, I'm buying into Python as a scripting language, unless I want to fight it, and what's the point of that? I already knew about Python and I like what I have seen... except for one thing. The indentation that marks block scope. This seems to me a really strange idea in that having whitespace be significant is a totally alien concept in most modern programming languages. Reading some sample Python code, as a complete novice, I like the look of the syntax, which appears to be clean and elegant (I like Javascript very much for the same reason). Apart from the indentation, that is. I had trouble seeing where block scope ends. And if I were dynamically creating code to be runtime evaluated, how would I handle this easily - do I *really* have to emit tabs and/or the right number of spaces for each line of code. What if I want to continue a line of code over multiple physical lines? So tell me, Python aficionados. 1. Will I get over my initial confusion?. (can I use braces, or BEGIN/END - I presume not) 2. Does the debugger report context as in foo=bar + splat ^ undeclared variable bar (oh, please tell me it does, even for runtime evaluated code!) because if it says Syntax error at line 345. Program terminated then I will scream.... 3. Can I create something analogous to C structs (and arrays of same) without recourse to object overkill. The Javascript approach is fine, mind you. It's very elegant, actually. I get the impression Python is a bit like that. 4. Is anyone here also using Zope. What do you think of it? 5. Is there a plug-in scripting language interface from Internet Explorer to Python, as there is for perl (ActiveState), so that if I wanted I could write client-side Python?. (because I'd really like to get down to a single scripting language client and server-side, and although that could be perl, frankly, my colleagues don't like the taste of it so much). Sent via Deja.com http://www.deja.com/ Before you buy. From greg.ewing at compaq.com Wed Dec 15 14:05:17 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 16 Dec 1999 02:05:17 +1300 Subject: Python complaints References: <000201bf3bd4$2bda5e20$542d153f@tim> <38562655.77A3B3DC@udel.edu> Message-ID: <3857920D.342472D3@compaq.com> Charles Boncelet wrote: > > But the savings is minimal versus normal Python > > fx = [] > for a in x: > fx.append(a**2) > > Am I missing something? Well, it's a matter of opinion, obviously, but I think the difference is rather more than minimal. The list comprehension syntax is more declarative -- it says what result is required without dwelling on the details of how to get it. It has the rare quality of being more concise without being more obscure. Also it's an expression, so it can be embedded in other expressions, whereas the above equivalent can't. Greg From gmcm at hypernet.com Thu Dec 30 15:26:13 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 30 Dec 1999 09:26:13 -0500 Subject: Before I go with python ... In-Reply-To: <005b01bf529d$34b84d60$c02b2bc1@martelli> Message-ID: <1265559407-4269043@hypernet.com> Alex Martelli wrote: [asynch sockets on Windows] > Maybe the "asyncore" could also work? Haven't looked into it > yet... async sockets would seem to be the 'mainstream' on Windows > (i.e., with the Winsock library -- although you can ask it for > blocking sockets too, the async variety feeds window messages > into your main window message loop -- smoothest and most > efficient for a program that is organized in the normal Windows > way). The Windows-message passing sockets stuff is a completely separate beast. You can do it with the Win32 extensions, I believe, but it requires a message loop (which a console app doesn't have) and is (IMHO) a hangover from earlier (completely braindead) implementations of WInsock. Normal non-blocking sockets work fine on Windows, modulo a few of the socket options (which aren't very portable anyway). You may also find some surprises in when an error shows up, (eg, where *nix would detect an error during the select, Windows may return it as readable, and then error on the read). - Gordon From psoares at consiste.pt Tue Dec 21 17:02:48 1999 From: psoares at consiste.pt (Paulo Soares) Date: Tue, 21 Dec 1999 16:02:48 -0000 Subject: zlib and zip archives Message-ID: <51998F46F8B7D011BF7C0060B03502AD2F3564@orion.consiste.pt> You must suppress the zlib header with -windowBits in deflateInit2. See the source in deflate.c. This is an undocumented feature. Best Regards, Paulo Soares > -----Original Message----- > From: Nick Collier [SMTP:nick at src.uchicago.edu] > Sent: Sunday, December 19, 1999 22:03 > To: python-list at python.org > Subject: zlib and zip archives > > Hi, > > I've been using zlib to create a zip archive using the pkzip format, > and > I've only been half succesful. The file headers and the central > directory > records and end of central directories records seem to get written > correctly. Winzip and infozip's unzip both report the correct files > and > details when listing the files in the archive. However, when I try to > decompress the data and I get an error with the message "invalid > compressed > data to inflate". I'm using zlib.compress with a level of 8 to > compress the > data. > > Any suggestions as to what I'm doing wrong? > > thanks, > > Nick > > > -- > http://www.python.org/mailman/listinfo/python-list From jamarijr at hotmail.com Tue Dec 7 16:43:06 1999 From: jamarijr at hotmail.com (Arinte) Date: Tue, 07 Dec 1999 15:43:06 GMT Subject: Python type checking? Message-ID: <82j9u8$da7$1@nnrp1.deja.com> class PossArg: def __init__(self,argname, argvalue): self.argname = argname self.argvalue = argvalue def getValue(self): return self.argvalue def getName(self): return self.argname def setValue(self, value): self.argvalue = value On the set setValue(), they set it to an integer value I want to make it a long else if it is a string leave it as a string. How can this be done? I figure I can do a if (type(argvalue)=="int"), but how would I handle a cast in python. TIA Sent via Deja.com http://www.deja.com/ Before you buy. From prestonlanders at my-deja.com Mon Dec 20 23:23:02 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Mon, 20 Dec 1999 22:23:02 GMT Subject: python sizeof()? Message-ID: <83ma82$jl9$1@nnrp1.deja.com> This may be a silly question, but is there an equivelent to C's sizeof() operator? I scanned the docs, and did a search on Deja.com, but I could find nothing relevant. Ideally sizeof(foo) would return the number of bytes required to store the instance of foo. I guess if foo were callable, then it would return the size of the associated Python bytecode. thanks, ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From vladchuk at socal.rr.com Tue Dec 21 04:56:30 1999 From: vladchuk at socal.rr.com (Vladimir Grabarchuk) Date: Tue, 21 Dec 1999 03:56:30 GMT Subject: You got QUESTIONS - they got ANSWERS! Message-ID: <385EF7AB.A6B1C714@socal.rr.com> This is a virtual swap meet where for a nominal fee (you set the price) you can get your technical questions answered within hours or get paid for the answers/projects you provide to others: http://www.hotdispatch.com/home?aff=378972011 Registration is free. You only pay/get paid when you ask/answer the questions. -- Cheers, Vladimir We are the champions of the world... From jae at ilk.de Thu Dec 2 00:30:48 1999 From: jae at ilk.de (Juergen A. Erhard) Date: Thu, 02 Dec 1999 00:30:48 +0100 Subject: __builtins_ weirdness Message-ID: <02121999.2@sanctum.jae> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This really weirded me out: __builtins__.range and __builtins["range"] both are the `range' function, one only works in interactive mode, and the other only in a module. I found this while I wrote this little helper fn: def range(*args): if len(args)==1 and type(args[0])==type([]): return apply(__builtins__["range"], (len(args[0]),)) elif len(args)==1 and type(args[0])==types.InstanceType: return args[0].__range__() else: return apply(__builtins__["range"], args) (should be the real def of `range', obviously ;-) Now, I twiddled with this in the interactive interpreter, where the obvious __builtins__.range works (with __name__=="__main__"). But in a module, __builtins__ `magically' transforms into a dict... I only wish there would be some consistency here. Or some *very* good explanation. Bye, J PS: The above snippet is under GPL ;-) (at least, the module it's in is... the fn itself is obviously to small to be copyrighted). PPS: That __range__ method is something I `invented' so this range fn can also be applied to user-defined objects. - -- J?rgen A. Erhard eMail: jae at ilk.de phone: (GERMANY) 0721 27326 MARS: http://Juergen_Erhard.tripod.com/mars_index.html Debian GNU/Linux (http://www.debian.org) "Windows NT" is an acronym for "Windows? No thanks." -- Russ McManus -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.0 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.5 and Gnu Privacy Guard iEYEARECAAYFAjhFr6YACgkQN0B+CS56qs02vACcDYeC9IgFhe8QqYV5ke74K0bl 0cwAoJAyKVIF8suZkofaKm5X1/yYZPa0 =oUlC -----END PGP SIGNATURE----- From rvollmert at gmx.net Thu Dec 2 17:31:01 1999 From: rvollmert at gmx.net (Robert Vollmert) Date: Thu, 2 Dec 1999 17:31:01 +0100 Subject: Email address check function In-Reply-To: <19991202163334.A3934@stopcontact.palga.uucp>; from gerrit.holl@pobox.com on Thu, Dec 02, 1999 at 04:33:34PM +0100 References: <19991202163334.A3934@stopcontact.palga.uucp> Message-ID: <19991202173101.A1610@krikkit.riednet.wh.tu-darmstadt.de> Hello, > I'm writing some CGI scripts and I want the user to fill in their > real email address. Checking this is more difficult than just look > if it contains an '@'. There must be at least one '.' after the '@' > but there must be non-'@' chars before and after every '.', no white > space, etc. There must be an RFC for this, but is there a function > in the standard library that checks if it's OK? I suppose it would be safest and easiest to lookup up the domain part of the address. I don't know how to do this in python, but you could call something like host -a domain.com and check the output. HTH, Robert -- Robert Vollmert rvollmert at gmx.net From brunomadv at ciudad.com.ar Sat Dec 18 20:22:09 1999 From: brunomadv at ciudad.com.ar (Bruno Mattarollo) Date: Sat, 18 Dec 1999 16:22:09 -0300 Subject: Script to add passwords Message-ID: Hello... Does someone knows of a script that could allow me to add user in a Unix machine (to the /etc/passwd and /etc/shadow) without using interactive mode. I mean, I have to set up an IMAP server and to create users I wish to use a cgi script so I am in the need of a script that would allow me to add users, change their passwords, etc etc from cgi ... I have seen that there is a module (pwd) that allows to GET passwords, but I am in the need to SET passwords. TIA /B Bruno Mattarollo -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 2051 bytes Desc: not available URL: From tbabbittt at netscape.net Wed Dec 29 07:07:04 1999 From: tbabbittt at netscape.net (Tom Babbitt) Date: Tue, 28 Dec 1999 23:07:04 -0700 Subject: Seccond week using Python. WOW! Message-ID: <3869A508.48BDB57A@netscape.net> I picked up Python a little over a week ago and just wanted to tell everybody concerned how impressed and appreciative I am. Every time I've had a question I have been able to find the answers very easily. The sample code and documentation are exemplary. Thank You All Tom Babbitt From sposhua at my.pc Wed Dec 22 10:47:00 1999 From: sposhua at my.pc (Sposhua) Date: Wed, 22 Dec 1999 09:47:00 +0000 Subject: os.popen() vs os.system() Message-ID: Newbie... >From what I've deciphered, the only differences between os.popen() and os.system() are: a) popen automatically starts a new process while system only does it if you include an & b) popen hooks onto stdout and stdin ??? If so, what's the use of os.system()? From cgw at fnal.gov Fri Dec 17 18:26:11 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Fri, 17 Dec 1999 11:26:11 -0600 (CST) Subject: LISTS: Extract every other element In-Reply-To: <19991217112304.A1847@stopcontact.palga.uucp> References: <19991216131341.A153923@vislab.epa.gov> <19991217112304.A1847@stopcontact.palga.uucp> Message-ID: <14426.29235.486363.37011@buffalo.fnal.gov> Gerrit Holl writes: > Randall Hopper wrote: > > I want to take a large list: > > > > [ 1,2,3,4,5,6,7,... ] > > > > and build a list with every other element: > > > > [ 1,3,5,7,... ] > > Use the filter() builtin: > >>> nums = range(10) > >>> print nums > [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] > >>> def odd(i): > ... return i % 2 > ... > >>> filter(odd, nums) > [1, 3, 5, 7, 9] > >>> print filter.__doc__ > filter(function, sequence) -> list > > Return a list containing those items of sequence for which function(item) > is true. If function is None, return a list of items that are true. I think that the point was to return a list of the items for which the *index* is odd, not the value. From dworkin at ccs.neu.edu Tue Dec 28 21:48:08 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 28 Dec 1999 15:48:08 -0500 Subject: newbie question... References: <3869229B.C06B94E5@earthlink.net> Message-ID: Alexander Sendzimir writes: > the following Perl construct is pretty standard. > > while ( ) > { > # process each line as if comes off the file handle... > } Yep. > The equivalent Python appears to be > > somefilehandle = open( "some/file/name.text" ) > all_the_lines_in_the_file = somefilehandle.readlines() > somefilehandle.close() > > # now process the lines in the all_the_lines_... list If you want to be more succint and not mess around with temporary variables, you could do: for line in open('some/file/name.text').readlines(): # process each line... -Justin From aahz at netcom.com Fri Dec 17 16:02:53 1999 From: aahz at netcom.com (Aahz Maruch) Date: 17 Dec 1999 15:02:53 GMT Subject: iteration (was RE: "sins" (aka, acknowledged language problems)) References: <6D8A17398E28D3119F860090274DD7DB4B3D53@pces.cadlab.it> Message-ID: <83djat$u1k$1@nntp9.atl.mindspring.net> In article <6D8A17398E28D3119F860090274DD7DB4B3D53 at pces.cadlab.it>, Alex Martelli wrote: > >but what should I place instead of the 'pass' statements, to make the >'for' construct terminate correctly...? In other words, what does >__getitem__ return, or what exception does it raise, to make a "for >x in y" statement terminate correctly? I see from the sources for >fileinput.py that an IndexError gets raised -- is that the "right" way >to do it (is it documented somewhere as such), or does it just "happen >to work" on the current implementation of the interpreter...? Yes, the "for" construct contains an implicit try/except on IndexError that it uses for loop control. It is documented somewhere, but I don't off-hand know where -- this is not likely to change, though it may get extended. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Eighth Virtual Anniversary -- 14 days and counting! From python-list at teleo.net Tue Dec 7 17:30:04 1999 From: python-list at teleo.net (Patrick Phalen) Date: Tue, 7 Dec 1999 08:30:04 -0800 Subject: browser interface? In-Reply-To: <384D1F58.1459835F@horvath.com> References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> <384D1F58.1459835F@horvath.com> Message-ID: <99120708514400.02363@quadra.teleo.net> [Bob Horvath, on Tue, 07 Dec 1999] :: Patrick Phalen wrote: :: :: > [55555, on Sun, 05 Dec 1999] :: > :: Not having a formal CS background, I have no real idea about how to pass :: > :: information between programs, and I don't have time to teach myself any GUI :: > :: toolkits. I thought using a browser as an interface would be an easy :: > :: compromise. So my question is should I use the cgi module to do that or is :: > :: there a better way? Also, if I'm using cgi, is there a way to not reload my :: > :: script every time a button is clicked? Thanks in advance. :: > :: > Sounds like Zope might be a fit. :: > :: > http://www.zope.org :: :: The Zope learning curve might be a bit much. It depends on what he wants to do. :: I am very intersted in Zope, have it loaded on my machine, but have not been able :: to get off the ground with it. I am anxiously awaiting the O'Reilly book. If :: anyone has any good pointers to where to start with Zope, I'ld love to hear about :: them. :: :: My answer to the original post would have been that cgu is probably what you want :: to look at, but Zope should be considered too. Bob, You make a good point. Zope requires more time and mental investment to learn than cgi.py. However, the original poster asked for a persistance model across requests, too. Given that, I think it *might* be easier overall to learn Zope than try to engineer transaction-like behavior from scratch. IOW, he'd likely end up needing an application server anyway. In regard to documentation, it's improving. Have you looked lately at http://zdp.zope.org and at http://www.zope.org/Documentation? Quite a few Guides and Tips now. Browse through the How-Tos -- there are close to 100 of them now. From tim_one at email.msn.com Wed Dec 1 09:15:09 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 1 Dec 1999 03:15:09 -0500 Subject: Python complaints In-Reply-To: <384484A2.AF4BE448@mindspring.com> Message-ID: <000401bf3bd4$2f000820$542d153f@tim> [Michael Hudson] > >>> def incr(var): > try: > raise 1/0 > except ZeroDivisionError: > import sys,dis > f = sys.exc_traceback.tb_frame.f_back > loadins = f.f_code.co_code[f.f_lasti - 3:f.f_lasti] > loadop = ord(loadins[0]) > name = dis.opname[loadop] > loadarg = ord(loadins[1]) + 256*ord(loadins[2]) > vname = f.f_code.co_names[loadarg] > f.f_locals[vname] = f.f_locals[vname] + 1 > > > >>> x=1 > >>> incr(x) > >>> x > 2 [Jesse D. Sightler] > Ack, and I though Perl was the only language that made you do stuff > like that. :) Could you please explain this little piece of code? That Michael is one sick bastard: he put in these two lines: loadop = ord(loadins[0]) name = dis.opname[loadop] only to throw you off track. Comment them out, and change the obscure loadarg = ord(loadins[1]) + 256*ord(loadins[2]) to import struct loadarg, = struct.unpack('. > It sure looks like byte-code dependant, self-modifying crazyness to me. > :) Seriously, you could spend a long time figuring out how it works (when it does -- it doesn't always). It is indeed picking apart the byte code, trying to figure out the name of the variable passed to incr by the caller, and then modifying the binding of that name in the caller's frame (sometimes even successfully ...). At the risk of obfuscating it, here's another way to write the same thing: x = x+1 exactly-the-same-number-of-characters-ly y'rs - tim From skip at mojam.com Sun Dec 26 22:51:17 1999 From: skip at mojam.com (Skip Montanaro) Date: Sun, 26 Dec 1999 15:51:17 -0600 Subject: A couple MacPython questions... Message-ID: <199912262151.PAA10719@dolphin.mojam.com> I downloaded MacPython 1.5.2 to my Mac and have a couple questions. 1. The Mac's notion of the current directory seems askew to me. If I ask for the current directory I get >>> os.getcwd() 'Macintosh HD:Applications:Python 1.5.2c1' This seems plausible. If I try to change directory to "Macintosh HD" I get an error: >>> os.chdir("Macintosh HD") Traceback (innermost last): File "", line 1, in ? error: (2, 'No such file or directory') Okay, try appending the colon, which works much better: >>> os.chdir("Macintosh HD:") >>> os.getcwd() 'Macintosh HD:' >>> os.listdir(os.getcwd()) ['Apple Extras', 'AppleShare PDS', 'Applications', 'Assistants', 'Cleanup At Startup', 'Desktop DB', 'Desktop DF', 'Desktop Folder', 'DesktopPrinters DB', 'Documents', 'dot_clear.gif', 'iMac Read Me', 'Installer Log File', 'Installer Logs', 'Internet', 'Late Breaking News', 'Mac OS Read Me Files', 'Microsoft Media Player', 'OneClick Folder', 'OpenFolderListDF\015', 'People', 'ReadMe.ssh', 'Shutdown Check', 'System Folder', 'Temporary Items', 'TheFindByContentFolder', 'TheVolumeSettingsFolder', 'Trash', 'Users', 'Utilities', 'VM Storage', 'Web Pages'] Now, if I try to change directory to my Desktop Folder, it lets me, but reports it as empty: >>> os.chdir("Macintosh HD:Desktop Folder:") >>> os.listdir(os.getcwd()) [] >>> os.getcwd() 'Macintosh HD:Desktop Folder' I can see my desktop isn't devoid of entries. I imagine I misunderstand the Mac's idea of building directories. Apparently the Mac's : doesn't mean quite the same thing as Unix's /. Any tutorial out there for a Unix weenie? 2. I miss being able to use command line editing when facing the Python prompt. Readline seems to be unavailable (not really surprising). Is there something similar available for Just van Rossum's MacPython IDE? 3. Greg Stein announced a little type checker to python-dev over the weekend. I downloaded it and tried using BuildApplet to create an applet from check.py. I got the following errors: shift: no mem in addchild Traceback (innermost last): File "flap:jack:Python:Mac:scripts:BuildApplet.py", line 67, in ? File "flap:jack:Python:Mac:scripts:BuildApplet.py", line 22, in main File "flap:jack:Python:Mac:scripts:BuildApplet.py", line 54, in buildapplet File "Macintosh HD:Applications:Python 1.5.2c1:Mac:Lib:buildtools.py", line 73, in process code = compile(text, filename, "exec") MemoryError Any ideas what might be wrong? Thx, 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 tiddlerdeja at my-deja.com Thu Dec 16 17:57:31 1999 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Thu, 16 Dec 1999 16:57:31 GMT Subject: pythoncom and MTS Message-ID: <83b5lq$5tr$1@nnrp1.deja.com> Does anyone know if you can implement MTS (Microsoft Transaction Server) complient/safe COM objects in python? I'm currently using VB and hot the problem where I can't have a class member function called "Get()" (it's a keyword). I realise that this isn't the best choice of for a function call but I'm trying to extend a COM object with the function name and I have to keep the API the same. If anyone could tell me how I can write a function in VB called Get, then please let me know. Well, the main reason for my post. I may perform my task of extending my COM objects in Python. 2 things: - Can I make my python COM objects MTS safe/complient? Does anyone have any experience of this? (I don't know what MTS complient really means. I've been told that I need to make my COM object MTS safe and I don't embark on a python solution if I can't do that). -Also, a serious question, is pythoncom ready for primetime? (I've only just found it really). Again, I don't want to embark on a python solution if I'm going to run into bugs. Any help REALLY appreciated. I've going a funny feeling my "holiday period" isn't going to be much fun. The deadline for my project is Jan 13th. I hope my teammembers aren't reading this! :) Sent via Deja.com http://www.deja.com/ Before you buy. From dbparker at nortelnetworks.com Mon Dec 13 04:26:45 1999 From: dbparker at nortelnetworks.com (Donald Parker) Date: Sun, 12 Dec 1999 22:26:45 -0500 Subject: Need help with Tkinter for dynamic # of objects Message-ID: <831ov7$ap$1@bmerhc5e.ca.nortel.com> Apologies in advance .... I'm quite new to Python so I suspect my problem is quite simple and due to a basic misunderstanding ... nevertheless, some insight into that misunderstanding would be appreciated. I'm trying to define a Frame class that can have a variable number of button widgets. Within the Frame class I've tried coding the constructor as n=0 while n < m : self.set_of_buttons[n] = [Tkinter.Button(self)] n+n+1 ...which results an exception for an attribute error for 'set_of_buttons' I thought types and variables came into existence as a result of assignment, but I am clearly breaking a rule I do not understand here. I would like to know: a) what rule I am breaking b) how to achieve my objective From s.schwarzer at ndh.net Sun Dec 26 00:54:53 1999 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Sun, 26 Dec 1999 00:54:53 +0100 Subject: "Message file not found" Message-ID: <3865594C.1AB35459@ndh.net> Hello everybody, I use the Python port (1.5.2) for OS/2 (Warp 4) and have the following problem: When I type (for example) >>> f=open( 'spam', 'r' ) # spam doesn't exist I get Traceback (innermost last): File "", line 1, in ? IOError: [Errno 10] Message file not found.: 'spam' while on Solaris it reads Traceback (innermost last): File "", line 1, in ? IOError: [Errno 2] No such file or directory: 'spam' Obviously, the (more specific) error messages in OS/2 are not there, but so far I couldn't figure out how to "get them". Any hints on this subject? Any help is appreciated. Stefan From mlh at vier.idi.ntnu.no Mon Dec 27 00:23:02 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 27 Dec 1999 00:23:02 +0100 Subject: control structures (was "Re: Sins") References: Message-ID: Phil Jensen writes: > I forget if I posted this before, but what I'd like to > see is the Zahn construct discussed in Knuth's article - > Pythonically: > > loop until "element found" or "search failed": > ... > if blah1 == blah2: > "element found" > ... > when "element found": > ... > when "search failed": > ... > Phil Jensen > See also http://magnus.n3.net/python/detect.html for another similar construct, suggested at about the same time as Zahn's (supposedly as an improvement. I am working on putting the original article online, but - it's not there yet ;) -- Magnus Lie Hetland From BC at prism.co.nz Mon Dec 6 00:07:33 1999 From: BC at prism.co.nz (Bing Chen) Date: Mon, 6 Dec 1999 12:07:33 +1300 Subject: PyRun_File crash my application Message-ID: <82er9c$hd2$1@newsource.ihug.co.nz> Hi, all I try to embed PyRun_File in my application. It crashed. Anybody know what's happen. How can I run a file in Python interpreter? My code as follows: FILE * fp = fopen( py_token, "r" ); #py_token is a file name PyObject *module = PyImport_AddModule("__main__"); PyObject *dict = PyModule_GetDict(module); PyRun_File( fp, py_token,Py_file_input, dict, dict ); Many thanks BC From skip at mojam.com Tue Dec 7 15:13:35 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 7 Dec 1999 08:13:35 -0600 (CST) Subject: Help with tuples please? In-Reply-To: <14413.5192.187203.108127@dolphin.mojam.com> References: <82ivrl$744$1@rtpnews.raleigh.ibm.com> <14413.5192.187203.108127@dolphin.mojam.com> Message-ID: <14413.5647.769156.550660@dolphin.mojam.com> Ack! So, I'm an idiot before breakfast. I wrote: Skip> It's been awhile since I ran across this problem (and you didn't Skip> post example code ;-), so my memory may fail me here. More like my entire corpus callosum failed me. Just delete my message. 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 glandrum at my-deja.com Thu Dec 9 07:39:21 1999 From: glandrum at my-deja.com (Greg Landrum) Date: Thu, 09 Dec 1999 06:39:21 GMT Subject: Win32 and the clipboard Message-ID: <82niqp$gml$1@nnrp1.deja.com> Hi all, According to the documentation which is distributed with the installer for Build 127 of the Win32 extensions there should be a module for accessing the windows clipboard called (amazingly enough) win32clipboard. In the version I just pulled down, there doesn't seem to be any such thing. Am I being less-than-clever, or is this a real oversight? Any clues? Thanks! -greg Sent via Deja.com http://www.deja.com/ Before you buy. From infotechsys at pivot.net Tue Dec 14 18:18:18 1999 From: infotechsys at pivot.net (Wayne) Date: Tue, 14 Dec 1999 12:18:18 -0500 Subject: help with an error in Tkinter Message-ID: <38567BDA.EC2F01D9@pivot.net> Hello, I'm reading the book(?) " An introduction to Tkinter" and in doing one of the example on Checkbutton Widget I get an error that I don't know how to resolve. Here is the program with a slight change - I left the "Quit" button code in from an earlier example. from Tkinter import * class App: def __init__(self, master): self.var = IntVar() c = Checkbutton(master, text = "Enable Tab", variable = self.var, command = self.cb c.pack() self.button = Button(master, text = "Quit", fg = "red", commnad = master.quit self.button.pack() def cb(self, event): print "variable is", self.var.get() root = Tk() app = App(root) root.mainloop() The error I'm getting: Exception in Tkinter callback Traceback (innermost last): File "/var/tmp/python-root/usr/lib/python1.5/lib-tk/Tkinter.py", line 752, in __call__ return apply(self.func, args) TypeError: not enough arguments; expected 2, got 1 From quinn at ngwee.ugcs.caltech.edu Thu Dec 9 06:25:52 1999 From: quinn at ngwee.ugcs.caltech.edu (Quinn Dunkan) Date: 9 Dec 1999 05:25:52 GMT Subject: Embedding questions References: <82n5ec$e2a$1@ssauraab-i-1.production.compuserve.com> Message-ID: On Thu, 9 Dec 1999 03:52:25 +0100, Olaf Appelt wrote: >The added functionality we need could probably be done via classes. And here >is already my first problem. >It is important that the programmer can use pre-defined named variables with >particular properties. >In short I need to have types. > >All I need can be implemented with classes (I think). Luckily Python allows >defintinition of operator methods so I can make this classes mostly behave >like typical variables. >Sadly I cannot redefine assignment. > >class Currency >... > >c = Currency () > >c = 5 Why not do the usual thing: c = Currency(5) >A possible solution would be to define something like > >class Currency >... > def assign (self, other) > self.value = other >... > >but that would look rather ugly: > >c.assign (a + b) > >instead of the usual > >c = a + b If a and b have __add__ methods that return a Currency, c will be a Currency, and c = a + b will work as expected. Even if a is a Currency(5) and b is int 10, you could have Currency __coerce__ the int into a Currency. >Furthermore I want to avoid having module files lying around in directories. >The code should be compiled, go into database and later be read from db to >be executed. All that without going files. Just strings moved between Python >API and DB. > >Is that possible? Should be. See the pickle and marshal modules, and the compile builtin. From victor_ng at my-deja.com Tue Dec 7 19:24:12 1999 From: victor_ng at my-deja.com (victor_ng at my-deja.com) Date: Tue, 07 Dec 1999 18:24:12 GMT Subject: Converting data to little endian Message-ID: <82jjc6$ks1$1@nnrp1.deja.com> Hi, I was wondering how to get my data to be represented in little endian format. I know that I can use the socket functions to convert to network byte order (big endian), but I need to convert to little endian (not just the host byte order). Vic Sent via Deja.com http://www.deja.com/ Before you buy. From boncelet at udel.edu Mon Dec 13 10:52:36 1999 From: boncelet at udel.edu (Charles Boncelet) Date: Mon, 13 Dec 1999 09:52:36 +0000 Subject: Dot product? References: <3852B91D.6EE31805@math.okstate.edu> <3854CBFF.85A69AA@compaq.com> <3854F1EE.3CA02CD6@compaq.com> Message-ID: <3854C1E4.624F7E3A@udel.edu> Greg Ewing wrote: > > "Magnus L. Hetland" wrote: ... > > > > > And is > > > > for x,y in list1, list2: > > > > ruled out because of anything except aesthetic preference? > > Yes. You're already allowed a comma-separated list of > target variables, in which case unpacking occurs. > How about the the mxTools solution: sum = 0.0 for x,y in tuples(list1, list2): sum = sum + x*y (On my soapbox): I like "tuples(list1, list2)" much better than "map(None, list1, list2)" because the former seems much clearer as to the intent of what the expression is supposed to do. AFAIK, both "tuples" and "map" solutions create an intermediate object. However there seems to be no reason why the internals of Python couldn't be changed so that these could be computed "on the fly" as needed. Of course, if David (who started this thing) is really interested in computing dot products, he should look at Numeric. -- Charles Boncelet University of Delaware Newark DE 19716 USA http://www.eecis.udel.edu/~boncelet/ From Alex.Martelli at think3.com Mon Dec 20 17:49:55 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Mon, 20 Dec 1999 17:49:55 +0100 Subject: Equivalent to (a ? b : c) ? Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> Scott Malraux writes: > I remember seeing the Python equivalent to C's (a?b:c) inline if > statement, but I can't find it for the life of me... can some kind soul > jog my memory for me please? > For the general case I think it was: ((a and (b,)) or (c,))[0] where the tuple trickery is just in case b is false; if you know b can't be false, (a and b) or c seems more readable. I think the parentheses can also be dispensed with, but I'm not conversant enough with the precedence to dare do that:-). Alex From cfelling at iae.nl Sun Dec 26 21:39:47 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 26 Dec 1999 21:39:47 +0100 Subject: tutorial questions (examples fail). References: <386625AE.C88C4992@dial.pipex.com> <19991226181026.A4648@stopcontact.palga.uucp> <38666594.3ED85477@dial.pipex.com> Message-ID: <845uej$v3$1@vvs.superst.iae.nl> Keith White wrote: > Just got to figure the command line editing thing out now. > it worked before in the 1.5.1 that came with the suse distribution. > since i built 1.5.2 from source i`ve lost it. > I`ll read the files that came with the source code,but any hints > would be welcome. just turn on the "Readline" module in Modules/Setup -- groetjes, carel From hurd at sds.co.kr Thu Dec 9 06:27:51 1999 From: hurd at sds.co.kr (Youngbong Choe) Date: Thu, 9 Dec 1999 14:27:51 +0900 Subject: How can I get disk space usage? Message-ID: <99120914373302.01692@hurd.sds.co.kr> Hi, I'm a newbie in python. Is there a module or function for getting amount of disk free space? If not, how can i get disk usage infomations in python, like "df" command. Thank you. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- SDS Co.,Ltd jUsT hUrD. hurd at sds.co.kr hurd at linuxnet.co.kr ------------------------------------------------------ From robin at jessikat.demon.co.uk Thu Dec 2 12:32:14 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 2 Dec 1999 11:32:14 +0000 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: In article , Phil Mayes writes >David N. Welton wrote in message <87puwpg7kp.fsf at freddy.page.street>... >>Guido van Rossum writes: >> >>> Come and join us at the Key Bridge Marriott in Rosslyn (across the >>> bridge from Georgetown), January 24-27 in 2000. Make the Python >>> conference the first conference you attend in the new millennium! >> >>Doesn't the new millenium actually start in 2001? > > >Only for FORTRAN programmers. Python and C programmers, being zero-based, >get to celebrate a year earlier. >-- >Phil Mayes pmayes AT olivebr DOT com -- make that ZeroLiveBr.com > > > > Doesn't matter about the base; to celebrate 2000 years you have to have them. As there's no zero A.D. even C programmers will find it difficult to dig up the extra year. Year 2000 bi-milleniallists should celebrate the start of the 2000'th year next January; then they can celebrate the beginning of the new millenium in 2001. Mere digit preferentialists can do as they please, personally I'm going to try and wait for 2222. Presumably programmers will have another field day in the years running up to 9999. They can mumble on about all the flag dates and also the Y10k problem at the same time. -- Robin Becker From tholap at compuserve.com Fri Dec 10 11:13:43 1999 From: tholap at compuserve.com (Olaf Appelt) Date: Fri, 10 Dec 1999 11:13:43 +0100 Subject: Embedding questions References: <82n5ec$e2a$1@ssauraab-i-1.production.compuserve.com> <82pd4e$2bu$1@vvs.superst.iae.nl> Message-ID: <82qklp$qsu$1@ssauraaa-i-1.production.compuserve.com> Hi Carel, > ...snipped out request for averloading assignment > > > but that would look rather ugly: > > > c.assign (a + b) > > Or you could go on and really abuse the language Shall I take that as a recommendation that I shouldn't use Python for what I need? Olaf From glandrum at my-deja.com Sat Dec 18 15:32:22 1999 From: glandrum at my-deja.com (Greg Landrum) Date: Sat, 18 Dec 1999 14:32:22 GMT Subject: tkinter on AIX References: <385AA5EE.6B31BDA1@austin.ibm.com> Message-ID: <83g5tn$ir8$1@nnrp1.deja.com> In article <385AA5EE.6B31BDA1 at austin.ibm.com>, Tom Smith wrote: > ld: 0706-006 Cannot find or open library file: -l tk8.2 > ld:open(): A file or directory in the path name does not exist. > ld: 0706-006 Cannot find or open library file: -l tcl8.2 > ld:open(): A file or directory in the path name does not exist. > > In Modules/_tkinter.c:/* _tkinter.c it is referred to as "Interface to > libtk.a and libtcl.a.". > My tcl and tk libraries are called libtcl8.2.so and > /usr/local/lib/libtk8.2.so > > These numbers agree with the ones in /usr/local/include/tcl.h and tk.h. I don't have easy access at the moment to a Setup file, so I can't be specific, but I can be general... hopefully this helps. You need (in the Setup file, I believe it's Setup.in, it's described in either the README or INSTALL documents) to expand the load path. In that file is a block where the various directives are set up for Tkinter (things like -ltk8.2 -ltcl8.2). One of the options mentions something about a load path. That one needs -L /usr/local/lib in order for things to go. Again, sorry about the lack of specifics... if you can't parse my generalities, send me mail and I'll track down the exact info. -greg Sent via Deja.com http://www.deja.com/ Before you buy. From ivanlan at callware.com Sat Dec 4 17:32:46 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sat, 04 Dec 1999 09:32:46 -0700 Subject: [Tutor] Overloading + factoring References: <0c64719001604c9MAIL1@mail1.arnet.com.ar> Message-ID: <3849422E.B027F8BE@callware.com> Hi All-- FFlores wrote: > [snip] > Well, that's another thing! I was referring to C++-like > overloading (i. e. several definitions of the same method, > to be tested in order until the parameters fit). But I've > already been told that's not possible. No, it's not possible, but you don't really need it. You can use the special class methods, such as __add__ and __radd__, and those will cover a larger spectrum than C++ does for the + operator. That is, with C++ you can define methods such that + 1 means something, but you can't define a method for 1 + as you can with Python's __radd__ method. Inside each such method, just check the types of the other operand. If it's an int, do thing a, for a long, thing b, and so on. I submit that you'll end up with less code that is far more comprehensible doing it this way in Python than you can ever hope to achieve in C++. [snip] > > > And something else, though it's not Python-related: > > > is there a nice method for factoring numbers, calculating > > > lcd, gcd, and/or a good library of such functions for rational > > > numbers? > > > > Not to my knowledge. But, you could probably write one yourself. > > Oh yes, I could make a function that gives me the prime numbers > I need. But I'd become old and die while the interpreter is still > calculating. :) Thanks anyway. > I think Tim Peters has a rational number library. I posted a gcd() function on the list awhile back, taken from Knuth's extended gcd example, which Tim then proceeded to improve greatly. Deja news lets you search the archives, but I also think that the exgcd() function got snapped up for the snippets website. Sorry I don't have the URLs for either Deja news or the snippets. Shamefully, I don't even remember who is responsible for the snippets site. I bet parnassus would have pointer to the snippets site, and might even have one to Tim's rationals. -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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From michelorengo at netscape.com Thu Dec 2 23:54:55 1999 From: michelorengo at netscape.com (Michel Orengo) Date: Thu, 02 Dec 1999 22:54:55 GMT Subject: windll question References: <826f4t$m0a$1@nnrp1.deja.com> Message-ID: <3846F8C1.D5C16633@netscape.com> I had the same bug with the attribute exception. I did something (stupid?) to correct the script windll.py In the class module change the unload function to: def unload (self): if self.loaded and self.handle: self.funs = {} if calldll: calldll.free_library (self.handle) It works so far with all my scripts, but I do not assume any responsibility. As far as the structure and c word, I have some example I can share with you if you want. I do not attached the files so the sake of this newsgroup but you can write to me directly. Basically, the simple way do to it is to use strucob.Oracle such as: # Definition of the structures # ---------------------------- ctlHdr = structob.Oracle ('Control Header Record', 'N6c6c55c2c', ('Count', 'Processed', 'Pad', 'CrlL') ) ctlRec = structob.Oracle ('Control Record', 'N32c9c9cc10c6c6c2c', ('FileName', 'Start', 'Length', 'Status', 'Comments', 'InSeqNum', 'OutSeqNum', 'CrlL') ) For: typedef struct { char szCount[6]; // total number of records in the file char szProcessed[6]; // number records processed char szPad[55]; // pad char szCrlL[2]; // end of record } CTLHDR; typedef struct { char szFileName[32]; // filename char szStart[9]; // offset of message in file char szLength[9]; // length of message char szStatus[l]; // status char szComment[10]; // comments char szIseq[6]; // input sequence number char szOseq[6]; // output sequence number char szCrLf[2]; // end of record } CTLREC; calishar at my-deja.com wrote: > Hi Folks, > > Thanks to some good advice earlier this week, I am now playing around > with calldll and windll, and thanks to a post from Eric Jacobs (the > Prototype lambda function) it is a lot easier now. > > Unfortunately (you knew there had to be a but right?) there are two > things I can not figure out how to pass. One is a struct, and the other > is a word (c word, not english word). > > I'm not sure what a word is (I know it is a variation of integer, > does that mean I can just use i in the format string?) but I have no > clue what format string to use for a struct, or how to construct it in > Python. > > If one of the Pythonistas could spare some time to help me out with > this, it would be greatly appreciated. Bascially I think what I need is > a step by step guide interfacing with external dll's. > > Also, I followed some of the advice passed on in here earlier on, on > setting up my calldll and dynwin distributions. Well, I can run the > dlldemo script, and get the message box saying my double-click speed > is.... but when I click OK I get an error in the command line window. > 'npstruct module error: unsupported byte order code' > followed by three errors about 'None' objects not having > a 'free_library' attribute. Is this normal for the package at the > moment? > > Sent via Deja.com http://www.deja.com/ > Before you buy. From tim_one at email.msn.com Mon Dec 13 09:43:11 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Dec 1999 03:43:11 -0500 Subject: Tkinter/IDLE crash In-Reply-To: <38549b35_4@news5.newsfeeds.com> Message-ID: <000701bf4546$16a802c0$9e2d153f@tim> [Simon Evans, apparently Tkinter code from within IDLE; the app's "quit" closes down IDLE] > ... > So, gurus, what's my next step? Use IDLE to create the program (or any editor you like), but run it from a DOS box instead (e.g., save in file blah.py, then "python blah.py" from a command line). Then IDLE won't be affected. IDLE is also using a Tk, and the app is apparently telling that one to quit too. As to other stories about mysterious instabilities on Win9x, they didn't come with enough meat to judge. The symtoms sounded more like they had multiple copies of Tk DLLs on the machine and were picking up one or more of the wrong ones. uselessly y'rs - tim From skip at mojam.com Mon Dec 13 15:47:41 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 13 Dec 1999 08:47:41 -0600 (CST) Subject: Python complaints In-Reply-To: <38532BEE.6D0376FB@maxtal.com.au> References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> <3843D685.C8C13355@maxtal.com.au> <38532BEE.6D0376FB@maxtal.com.au> Message-ID: <14421.1805.611346.100979@dolphin.mojam.com> John> [BTW: the first release of Viper has been posted to incoming on John> ftp.python.org, it hasn't made the download section yet] I wait with baited breath. Folks should note that policies related to the contrib section on the PSA web site have changed. Check out http://www.python.org/download/Contributed.html in particular, the "Python.Org anonymous FTP guidelines". 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 ivanlan at callware.com Mon Dec 6 23:34:22 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 06 Dec 1999 15:34:22 -0700 Subject: X display visual Message-ID: <384C39EE.6B5921EC@callware.com> Hi All-- A friend of mine is running Python on a Sparc station. I sent him some code which uses a bunch of colors, and even though he's got a truecolor display it looked screwy. He ran xdpyinfo, and these are his results: xdpyinfo says: supported pixmap formats: depth 1, bits_per_pixel 1, scanline_pad 32 depth 8, bits_per_pixel 8, scanline_pad 32 depth 24, bits_per_pixel 32, scanline_pad 32 xwininfo on the python window says: Depth: 8 Visual Class: PseudoColor so I guess that means python took the first color visual type it found... is there a way to force it to use my 24 bit visual? What say the Tkinter experts? -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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From michael.stroeder at inka.de Tue Dec 7 18:47:26 1999 From: michael.stroeder at inka.de (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Tue, 07 Dec 1999 18:47:26 +0100 Subject: 500 Internal ... not the same of Dan References: <82j3c6$87h$1@nnrp1.deja.com> Message-ID: <384D482E.24DCB666@inka.de> mk_999 at my-deja.com wrote: > > Sometimes doing this operation it shows me that message (INTERNAL SERVER > ERROR), but it works!!!!! > [..] > Refreshing the page, sometimes it shows the correct page, others not, > but it always add new records. Any NFS mounts involved? Ciao, Michael. From mlh at vier.idi.ntnu.no Mon Dec 27 17:03:09 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 27 Dec 1999 17:03:09 +0100 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> Message-ID: Paul Prescod writes: > I propose that in Python 1.6 tuples be given the demonstrated features: > > >>> time = (hour=24, minute=00, second=00 ) Hm... Interesting... [snip] > This proposal has the following benefits: > > * it makes a nice syntax for a 1-item tuple :) At last! ;) > * it makes a nice syntax for non pre-declared struct-like things Yes... Cleaner than time = {'hour':24, 'minute':00, 'second':00} Not *much* cleaner, but a bit. Of course, the tuple would be immutable, though... > * it aligns better with the mathematical notion of tuple Really? I don't think so... The mathematical notion of a tuple is that it is an ordered set, i.e. a set where the elements each have an index. What does that have to do with your version? > * the element referencing syntax is much clearer Hm. > * names are easier to remember and less error prone than indexes. In most cases - probably. > * it is still easy to rip them apart > > This proposal may lead some to consider the unification of tuples and > object instances, which is also a discussion worth having. Immutable object instances? Doesn't that go against some quite basic tenets of object oriented programming? > > Opinions? Bets that Guido would apply a patch to this effect? > > Paul Prescod > -- Magnus Lie Hetland From m.faassen at vet.uu.nl Tue Dec 7 13:39:40 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 7 Dec 1999 12:39:40 GMT Subject: Is there a database in Zope? References: Message-ID: <82iv6c$fis$1@newshost.accu.uu.nl> NH wrote: > Hello, > I am new to Python and Zope, so please don't flame me. I have been assigned > to create a website for the counceling office at my high school. I want to > use either Zope or PHP. (Which is better?) I don't have experience with PHP, and I do with Zope. They're different; PHP is basically a web-programming language, while Zope is a web application server; it does more for you than PHP does (which may be an advantage or a disadvantage). > Anyways, what I need to know is if there is a database with in Zope where I > can store data or variables for an extended period of time. This data would > need to survive rebooting. Something like SQL inside Zope? I know there is > the ZODB, but I am not sure of its capabilities. Zope interfaces with plenty of SQL databases. Personally I've had it working with Access (through ODBC) and with PostgreSQL. It works a lot of other SQL databases too. The ZODB is a way to store objects persistently (across restarts of the server) as well; it's very powerful and quite different from relational databases; it depends on your application what is most useful to you. So, the ZODB is capable of storing data and variables for an extended period of time as well. > What I need to do is have students fill out a form that the councelor can > view at a later time. I will be dealing with many students. The server is > not that good, so I need to keep everything simple. I am not sure if I'd be > able to get a SQL server together. What kind of OS are you running? Getting ODBC to work on NT or Postgres on Linux isn't that hard. Alternatively Zope comes with Gadfly, an SQL database implemented in Python. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From garabik at melkor.dnp.fmph.uniba.sk.spam Thu Dec 9 13:19:59 1999 From: garabik at melkor.dnp.fmph.uniba.sk.spam (Radovan Garabik) Date: 9 Dec 1999 12:19:59 GMT Subject: FORTRAN (was Re: indentation) References: <65118AEEFF5AD3118E8300508B124877073CC6@webmail.altiris.com> Message-ID: <944741966.933486@cdwork.cvt.stuba.sk> Mike Steed wrote: :> In article <14411.53378.154350.793014 at weyr.cnri.reston.va.us>, :> :> Hmmm... I wonder who the youngest person in this group is who has :> actually used FORTRAN on the job. I'm 32; I did the work twelve years :> ago. : I'm 31. I used FORTRAN for a (mercifully brief) project, also 12 years ago. I am 25. My primary programming language I am using on my job[1] is FORTRAN. I have been continuosly using it for 4 years now. [1] when you are doing analysis or simulation in the same field of nuclear physics I do, you really do not have much choice. -- ----------------------------------------------------------- | 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 gerrit.holl at pobox.com Wed Dec 22 11:59:47 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 22 Dec 1999 11:59:47 +0100 Subject: eval vs. atof In-Reply-To: ; from sposhua@my.pc on Wed, Dec 22, 1999 at 09:44:07AM +0000 References: Message-ID: <19991222115947.A3554@stopcontact.palga.uucp> Sposhua wrote: > Newbie... > > Why do string.ato[f/i/l] exist when you can use eval()? There must be a reason > for these things... If one evals something, the error is hard to trace: >>> string.atoi("print") Traceback (innermost last): File "", line 1, in ? ValueError: invalid literal for atoi(): print >>> eval("print") Traceback (innermost last): File "", line 1, in ? File "", line 1 print ^ SyntaxError: unexpected EOF while parsing For example, if you want the user to type a valid number, you shouldn't use input(): >>> input('type a number: ') type a number: ['this', 'is', 'a', 'list!'] ['this', 'is', 'a', 'list!'] You should use this instead: >>> try: ... num = string.atoi(raw_input("type a number: ")) ... except ValueError: ... print 'not a valid number' ... type a number: 24 >>> try: ... num = string.atoi(raw_input("type a number: ")) ... except ValueError: ... print 'not a valid number' ... type a number: ['this', 'is', 'a', 'list] not a valid number regards, Gerrit. -- "Open Standards, Open Documents, and Open Source" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 11:56am up 51 min, 16 users, load average: 0.00, 0.01, 0.01 From jdoe at main.com Fri Dec 10 14:22:43 1999 From: jdoe at main.com (John Doe) Date: 10 Dec 1999 08:22:43 -0500 Subject: Any web automation modules? Message-ID: Is there any modules for getting web pages? Lynx has a simple switch but I do not know how to send user and passwords. I am a complete newbie to python. Regards From roy at popmail.med.nyu.edu Fri Dec 3 02:11:39 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Thu, 02 Dec 1999 20:11:39 -0500 Subject: creating one of a family of classes Message-ID: I want to have a family of classes which are all subclasses of a common ancestor. For the sake of a simple example, let's say I have a class polygon, with subclasses triangle, square, pentagon, and hexagon. I want to be able to call the top-level creator, and have it return an object of the appropriate subclass based on the argument I give it. For example: p = polygon ([(1,2), (4,5), (0,4)]) would return an object of class triangle and p = polygon ([(1,2), (4,5), (0,4), (3,4)]) would return an object of class square. Is such a thing possible? From charles_fenton at NOhotmailSPAM.com Thu Dec 2 19:21:32 1999 From: charles_fenton at NOhotmailSPAM.com (Charles Fenton) Date: Thursday, 02 Dec 1999 12:21:32 -0600 Subject: $9 Domain Hosting - No Internic Fees Message-ID: <02129912.2132@NOhotmailSPAM.com> This place will register your domain name for only $50 without paying the $70 to Internic! Plus you can host your full domain name for only $9 per month. Your yearly renewall fee is only $25, rather than $35 like it usually is. Visit them at http://www.9dollardomains.com and see for yourself. You can also just search for available domains names for free there. Plus, they have a refferal program, so tell them that charles_fenton at NOhotmailSPAM.com sent you. For every person I refer, I can get $10, or a free month's hosting. Thank you. From ads at sst.dynip.com Mon Dec 27 20:37:02 1999 From: ads at sst.dynip.com (ads at sst.dynip.com) Date: Mon, 27 Dec 1999 19:37:02 GMT Subject: Sell or exchange 26 Message-ID: Sell or Exchange Casio E-100 16 megs ram, music, video stereo Exchange l for Computer hard Ware or SRG,CB full Equip etc ... Reply Email... yfugumkhovvzpjpujyftytlssbjyekgrjfd From aa8vb at yahoo.com Thu Dec 16 13:51:38 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 16 Dec 1999 07:51:38 -0500 Subject: Newbie question (fwd) Message-ID: <19991216075138.B156414@vislab.epa.gov> ----- Forwarded message from Dan.Zimmer at icn.siemens.com ----- Date: Wed, 15 Dec 1999 15:24:39 -0500 From: Dan.Zimmer at icn.siemens.com Subject: Newbie question Hello all, I am relatively new to python so don't laugh at me too much... I inherited 2 PCs with python already installed, but the programs that I am running, actually reside on a server. I am attempting to install and run the software on 2 more PCs for back-up purposes. I noticed that I had to add the python directory to the PATH before I could it would find the executable, and I can now run some basic python programs. Now I find that the program is crashing with an attribute error when the __getattr_ is called for wdDoNotSaveChanges. (__init__.py) (One of the systems I inherited already had this problem as well) I know there is something simplistic that I am just overlooking, and its starting to drive me nuts, so any helpful hints would be much appreciated. Thanks, Dan _______________________________________________ XML-SIG maillist - XML-SIG at python.org http://www.python.org/mailman/listinfo/xml-sig ----- End forwarded message ----- From marshall at ufm.org Thu Dec 9 22:13:42 1999 From: marshall at ufm.org (Marshall) Date: Thu, 9 Dec 1999 13:13:42 -0800 Subject: Help! ConfigParser module Message-ID: I can't get ConfigParser to initialize. Here is what I tried: import ConfigParser mycfgfile=ConfigParser.read("myconf.cfg") I get a Attribute error - read message back Thanks in advance for any help From wlfraed at ix.netcom.com Fri Dec 10 05:23:26 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 09 Dec 1999 20:23:26 -0800 Subject: FORTRAN (was Re: indentation) References: <65118AEEFF5AD3118E8300508B124877073CC6@webmail.altiris.com> <384EF139.91ACD637@bioreason.com> <38500A94.FB6EF7DE@be-research.ucsd.edu> <3850368B.F104F1D9@appliedbiometrics.com> <38503F7E.66E9D5BD@lanl.gov> Message-ID: On Thu, 09 Dec 1999 16:47:37 -0700, "William B. Clodius" declaimed the following in comp.lang.python: > Tim Peters may correct me on this, but I believe that all Fortran's up > to Fortran 90 could be implemented with static allocation. It had no > recursion and, in most respects, no dynamic allocation. The one tricky > point in static allocation involves some usages of CHARACTER variables > which result in expressions whose size can vary at runtime. However, I CHARACTER came in with FORTRAN 77. As I recall, the F77 standard had a left-hand and right-hand definition; left-hand being the minimum that had to be implemented to be considered F77, right-hand being the full "standard" language. I believe even in the full F77, there were no real "varying" CHARACTER types -- the closest being "character*(*)" which only applied to arguments passed to a subroutine/function. The actual dimensions (*) were still fixed when the actual variable is declared, and the bounds were then passed along to the subroutine/function as part of the calling mechanism (IE, not just the address of the variable, but a structure containing length and pointer to storage). > believe that the language defined a standard upper bound on the size of > these expressions to allow static allocation in these cases. (No I can't I suspect the "left-hand" standard may have defined a MINIMUM length for character data types. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From wtanksle at hawking.armored.net Sat Dec 4 03:47:34 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 4 Dec 1999 02:47:34 GMT Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD81@gandalf.digicool.com> <3845DEA8.5A2A61A@home.com> Message-ID: On Thu, 02 Dec 1999 02:51:23 GMT, Edward Muller wrote: >I've re-read the SOAP docs, and agree that it looks pretty cool, but there is >NO existing Python implimentation and my goal is not to write EVERYTHING from >scratch. I do not claim to be a great programmer and my time is limited. Zope has implemented it, IIRC. -- -William "Billy" Tanksley, in hoc signo hack From paul at prescod.net Thu Dec 30 10:43:59 1999 From: paul at prescod.net (Paul Prescod) Date: Thu, 30 Dec 1999 04:43:59 -0500 Subject: Py2K wishes References: <1265702489-58362226@hypernet.com> <386A0DC1.471874F2@prescod.net> <14442.17056.773002.697499@dolphin.mojam.com> Message-ID: <386B295F.37E47D07@prescod.net> Skip Montanaro wrote: > > Maybe I'm way out of context here, but can't you subclass on-the-fly with > something like: > > def func(o): > class sub(o.__class__): The problem is that what I want is so much simpler than subclassing. >>> orig = object() >>> orig.foo = 5 >>> newobj = object() >>> newobj.bar = 6 >>> newobj.__fallback__ == orig >>> print newobj.foo, newobj.bar (5,6) I don't claim that this feature would save me so many hours as to even justify the amount of time I've spent explaining it. It just struck me as being in the same category as, for example, importing where you see the language do something magical (finding a file and loading it as a module) and then find out that the magic is based on simpler concepts that are each independently available and overridable. Paul Prescod From XX at XX.COM Wed Dec 1 18:14:36 1999 From: XX at XX.COM (X CB) Date: Wed, 1 Dec 1999 11:14:36 -0600 Subject: trouble with python 1.5.2 install on win98 References: <81elc8$8i2$1@nnrp1.deja.com> Message-ID: <4Hc14.1553$uI1.107478@news2.giganews.com> Lee Fletcher wrote in message news:81elc8$8i2$1 at nnrp1.deja.com... > Hoping for some guidance to my problem w/Python, > > I have installed py152.exe on (2) Win98 machines: > 1 at work, 1 at home > > The installation at home runs. I am having trouble running IDLE at > work. It accesses the hard drive but never becomes a running program. > I have the same problem (NT4). If you run idle.py in /tools/idle you'll probably get an error message similar to.. << Traceback (innermost last): File "idle.py", line 3, in ? PyShell.main() File "D:\Python\Tools\idle\PyShell.py", line 611, in main root = Tk() File "D:\Python\Lib\lib-tk\Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable init.tcl in the following directories: {} ./lib/tcl8.0 D:/Python/tcl8.0/library D:/Python/Tools/library This probably means that Tcl wasn't installed properly. >> I bet this probably means that Tcl wasn't installed properly. The path is probably all wrong or incomplete. Ironically, Until recently, I've not had this problem. Apparently some tcl based program stomped all over my tcl install. Any suggestions?, Comments? ... to help the enthusiastic neophyte... XXXcraig at YYYscbi.ZZZcom remove the xxxyyyzzz...to reply.. From aahz at netcom.com Sat Dec 11 03:33:45 1999 From: aahz at netcom.com (Aahz Maruch) Date: 11 Dec 1999 02:33:45 GMT Subject: FORTRAN (was Re: indentation) References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> <14411.53378.154350.793014@weyr.cnri.reston.va.us> <82mjag$7oh$1@nntp2.atl.mindspring.net> Message-ID: <82sd69$of$1@nntp9.atl.mindspring.net> In article , Phil Austin wrote: > >1) Standard Fortran (aka Fortran95) is a very different language than > whatever flavor Aahz used in 1977. For an introduction to > modern Fortran, check out Paul Dubois' lecture notes at: I was using FORTRAN 77 in 1987; this was a big improvement over my boss's use of FORTRAN IV (aka FORTRAN 66). I got some rather annoyed comments about my use of string functions.... -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Sign up now! http://www.searchbutton.com/ From gmcm at hypernet.com Tue Dec 7 17:31:52 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 7 Dec 1999 11:31:52 -0500 Subject: exchanging data btwn Python and lesser languages In-Reply-To: <82jau6$e72$1@nnrp1.deja.com> Message-ID: <1267538634-27138233@hypernet.com> Preston Landers writes: > As strange as it may sound, Python is not the only language used > in our shop (who shall remain nameless to protect the guilty.) > > I'm looking for a quick-n-dirty way to exchange data between > Python and other languages, especially P*rl. I don't have time > to implement a full-blown XML solution, which is really what this > problem calls for IMHO. > > The data I want to exchange is pretty simple; mainly lists/arrays > and dicts/hashes of integers (possibly longints), strings, and > floats. No fancy objects or anything. Skip Montanaro did something along these lines. He'll probably speak up, but if you're impatient, Dejanews is your friend. I think it was within the last year. Sorry I can't narrow it more than that. - Gordon From skaller at maxtal.com.au Mon Dec 27 21:20:46 1999 From: skaller at maxtal.com.au (skaller) Date: Tue, 28 Dec 1999 07:20:46 +1100 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D83@pces.cadlab.it> Message-ID: <3867CA1E.360E3B0E@maxtal.com.au> Alex Martelli wrote: > But that's just because I'm a newbie in this Python > language -- you should see me operate in realms > I'm more confident about!-) [Despite my verbal > prowess, I've been unable to help others find strong > enough superlatives of "arrogant" to describe my > attitude when experience backs me up:-)]. I'm more arrogant, since I don't care if experience backs me up or not, only if there is a good argument :-) > But as soon as they published, and the book was > such an instant success, I started using their > design pattern names with abandon (with a biblio > reference in a comment, when I remembered:-). I found the book interesting, and nothing more. I gained no enlightenment from it, other than the mild assertion than some patterns could not be encoded IN the language. It turns out this assertion is false in general -- it is language specific. Functional languages have no problem encoding it. > But for this to be effective, it does need to be > widely known. "condition and iftrue or iffalse" > is perceived by many as an unreadable way > to express a ternary operation, although IMHO > it has it all over C's "condition?iftrue:iffalse", > for the sole reason that the latter has had much > exposure (any C programmer has NEEDED to > learn about it), while the former has not -- if > such idioms were more widely promoted in > widespread Python literature, their actual > "readability" would improve... without needing > to change anything in the idiom itself nor in the > Python interpreter. You're right: are these really equivalent? I'd have to go and think a long time about it. Hey, Guido used that once, in some code, and I rewrote it just so I could figure it out. > > functions available, and (b) in except clauses, > > to make the exception available. > > > *blink* isn't that what sys.exc_info() is for...? try: ... except TypeError, x: print x Here, the 'x' is the actual exception object. It is not in global scope. It is not in local scope. At least, not in my implementation (Viper). It is available ONLY in the exception handler. At least, I assumed that: I never bothered to check this :-) > I particularly appreciated Java's abandonment > of classical rules for nested lexical scopes -- the > idea that an identifier in an inner scope hides the > existing outer one silently. Java makes it an > error to have such a 'hiding', and although the > idea was totally novel to me when I tried Java out, > I think it substantially reduced mistakes without any > real cost in expressiveness. Yeah, but the scopes still nest and control object lifetimes accordingly, right? The fact that shadowing generates an error may have some advantages, but it also has disadvantages too: hiding supports 'cut and paste'. > On meeting Python's simplified approach to scoping > (although you tell me that the "simplicity" is really a > misconception), it seemed to me that this would have > similar but even stronger advantages. All I can say is: first, Viper has proper lexical scoping, and it immediately feels cleaner and simpler than Python's hackery. Secondly, I am FINALLY using a real programming language, namely ocaml, in which scopes nest correctly. The ocaml people reckon that ocaml code is ten times more expressive than C/C++. (You can do the same job in 1/10th the number of lines). It is so much easier to do things when scopes nest properly. I abandoned C++, and a book I was writing about it, because they do not nest properly in C++. The lack of proper lexical scoping makes templates more or less useless. > If the wrappers are standardized, readability is no > problem. Most people think highly bracketted expressions are unreadable (eg LISP :-) Or, (did I (actually) mean), that, (most), (people are (finding (that (highly (bracketed))))) expressions are hard to read. :-) Python tries to avoid this: for i in len(x): is already much worse than, say, for i in x.length(): [and now, make 'x' itself an expression ..] I personally think most people like OO for no other good reason than the use of reverse polish syntax: x.y().z() is more readable than z(y(x())) >And efficiency need not be, either; why > cannot you parse and optimize: > > for key,value in kv_enum(sequence): > > just as easily as > > ifor key,value in sequence: Well, in Python 'kv_enum' could be anything. It may default to a standard function, but the client can write: kv_enum = myfunction This cannot be done for the 'ifor' form, since 'ifor' is a keyword. > > Quite a lot of the time, you CAN provide the y: > > using functional programming with map and reduce etc. > > > Yep -- and O-O wrappings work for it, too. The difference is that the 'OO' wrappings, in general, cannot be localised. This leads to spagetti. > > This works well in functional programming languages, > > but it doesn't work nearly as well in python > > What I mean is, the 'y' becomes so cluttered the reader > > isn't sure what is happening. > > > Why would it be less cluttered in a functional PL? At least in ML languages, function calling does not require brackets. Of course, you still need them to override the default precedence. :-( -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From andrew at fc.hp.com Mon Dec 6 19:05:40 1999 From: andrew at fc.hp.com (Andrew Patterson) Date: Mon, 06 Dec 1999 11:05:40 -0700 Subject: How do i get output from pope3 while process is running? References: <384858EA.A9C9D2B7@fc.hp.com> <38489A7A.853E1039@inet.polyu.edu.hk> Message-ID: <384BFAF4.5E19935B@fc.hp.com> Li Dongfeng wrote: > > Try the patch(I think you can't do readlines() more than once): > Which patch is that? Andrew > Andrew Patterson wrote: > > > > I want to run an extremely long running external command and send its output > > > > to stdout of my python program. I started with os.system which works fine > > > > except that I needed to capture the stderr output in a separate stream. The > > > > popen2.Popen3 class seems to fit the bill, however, I can not get any of the > > > > output until the process finishes (hours later). Here is the code I am using: > > > > ################################ run_proc() ################################# > > def run_proc(cmd, capturestdout=0, capturestderr=0, printstdout=0): > > """Run an external command and capture stderr, stdout, and exit code.""" > > > > proc = popen2.Popen3(cmd, capturestderr) > > stdoutlist = [] > > stderrlist = [] > > if capturestdout: > outls=proc.fromchild.readlines() > > for line in outls: > > if printstdout: > > print "\n********* Got Here ************" > > sys.stdout.write(line) > > stdoutlist.append(line) > > if capturestderr: > > stderrlist = proc.childerr.readlines() > > exit_code = proc.wait() > > return (exit_code, stdoutlist, stderrlist) > > > > I get the "Got here" lines after the process finishes. I am running python 1.5.2 > > > > on an HP-UX 11.0 system with native pthreads compiled in. > > > > Can someone please tell me what I am doing wrong. Thanks > > > > Andrew > > =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > > Andrew Patterson Voice: (970) 898-3261 > > Hewlett-Packard Company/DSL FAX: (970) 898-2180 > > 3404 East Harmony Road / MS 7 email: andrew at fc.hp.com > > Fort Collins, Colorado 80525 -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Andrew Patterson Voice: (970) 898-3261 Hewlett-Packard Company/DSL FAX: (970) 898-2180 3404 East Harmony Road / MS 7 email: andrew at fc.hp.com Fort Collins, Colorado 80525 From rsheffield at trestigres.com Fri Dec 3 05:54:28 1999 From: rsheffield at trestigres.com (Raymond Sheffield) Date: Thu, 02 Dec 1999 22:54:28 -0600 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> Message-ID: Guido van Rossum wrote: > Did you ever wonder what Tim Peters looks like? Have you ever wanted > proof that he's not a runaway AI project or a secret alias for the > Benevolent Dictator? > > Now's your chance. Come to the Python Conference in Washington DC and > meet Tim, Guido and the rest of the Python crowd for four days of > intense Pythoneering. Some program highlights: May I suggest that any kind of date with Tim Peters ---- shudder ---- is, perhaps, the least appealing thing about python? We appreciate Peters as a non-real thing . . . but to see him, the creature, in real life might be a little more off-putting than most can endure. I recommend a cage, a whip, and a stun-gun. Washington DC is no doubt a lovely place, museums and all and a 50-year-old pre-pubescent president residing there, God love us, but who's to say it won't turn into another Seattle with the real Peters afoot? I think of Godzilla and Peters in the same sentence. I envision "The Thing From Another Planet" on the loose on terra firma in a hospitable climate . . . . . .and I'd like a few more assurances as an inducement, thank you. From skip at mojam.com Fri Dec 10 17:39:21 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 10 Dec 1999 10:39:21 -0600 (CST) Subject: Enviroment In-Reply-To: References: <013401bf4324$e51ed530$f29b12c2@secret.pythonware.com> Message-ID: <14417.11449.366675.978588@dolphin.mojam.com> >> anyway, the correct syntax is: >> >> os.environ["LD_LIBRARY_PATH"] = "/usr/lib etc Robert> hmmmm but it makes no use of it while importing. If I made a Robert> script I think LD_LIBRARY_PATH is only consulted once by the dynamic linker at program start, so changing its value in a running script won't affect the behavior of the script itself. That explains your results (and probably avoids a security hole you could drive a mack truck through). If you are using a relatively recent version of Apache you can tell it what variables to pass through to CGI scripts and also set their values. Check out the PassEnv directive. I think the setter thing is SetEnv. 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 mal at lemburg.com Tue Dec 28 10:17:01 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 28 Dec 1999 10:17:01 +0100 Subject: strptime on Unix systems References: <19991222110107.A972@Ridcully.home> Message-ID: <3868800D.3EBA053C@lemburg.com> Malcolm Tredinnick wrote: > > On a Linux technical support mailing list I am on, somebody recently posted a > question about Python and although I was able to answer it, the logic behind > the answer has me stumped: > > The following does *not* work under Linux (at least): > > import time > format = '%a %b %d %H:%M:%S %Z %Y' > t = time.localtime(time.time()) > timestring = time.strftime(format, tt) # Works OK > timetuple = time.strptime(tt, format) # Throws ValueError > > The reason for this problem is that strftime and strptime are based on their > C-library counterparts and according the man pages, while strftime does take a > %Z modifier in the format string, strptime does NOT understand this modifier. > (so you can remove the %Z from format and the above snippet is fine.) > > Two questions: > (1) What is the story on other Unix systems? Is this a general problem (I hope > not)? > > (2) Is there any logic hidden behind the fact that one direction takes %Z and > the other does not? Sure: %Z would effectively have to parse *any* timezone string or offset in strptime() while the same in strftime() only needs to know the local timezone string. For date/time parsing try mxDateTime (see my Python Pages). It has quite a few parsers and automates much of the process -- note that it currently doesn't parse literal timezone strings (for the same reason mentioned above) only numeric ones. See the docs for details. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: Get ready to party ! Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From piet at cs.uu.nl Thu Dec 23 11:53:42 1999 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 23 Dec 1999 11:53:42 +0100 Subject: Multi-User non Client/Server database References: <7DE1F51DE6EF8DE2.FEF18A6AB6E94830.57F6A00E6C02B0D3@lp.airnews.net> Message-ID: >>>>> claird at starbase.neosoft.com (Cameron Laird) (CL) writes: CL> You'll want to read the recent MetaKit announcement CL> . MetaKit plays CL> very well with Python, does locking right, ^^^^^^^^^^^^^ I don't think so, see the following snippet from its mailing list: > Could two apps -- one web server generating web pages from the > database contents, and one e-mail list manager -- share the same > MetaKit datafile? Not if both need modify access. Today, MK is multi-reader *or* single- writer, no other combination. In some cases, you can work around this by maintaining a replica. Multi-threading is high on my to-do list. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: Piet.van.Oostrum at gironet.nl From manfred.k.hain at t-online.de Fri Dec 10 00:51:40 1999 From: manfred.k.hain at t-online.de (Manfred Hain) Date: Fri, 10 Dec 1999 00:51:40 +0100 Subject: Problems using Opengl In-Reply-To: <38494049.B955743F@club-internet.fr> References: <38494049.B955743F@club-internet.fr> Message-ID: On Sat, 4 Dec 1999, patrick dutoit wrote: > Hi > I have got the Opengl package for Python and I have tested the examples. > I always obtain the following message: > Traceback (innermost last): > File "first.py", line 3, in ? > from OpenGL.GL import * > File "/usr/lib/python1.5/site-packages/OpenGL/GL/__init__.py", line 7, > in ? > from _opengl import * > ImportError: /usr/X11R6/lib/libMesaGL.so.3: undefined symbol: > XFreePixmap > > Mesa was installed as a rpm package and didn't give me any troubles. So > I don't understand what happens. > If you have any idea or if you have meet the problem and have a solution > to fix it, you're welcome. > > > Regards > > > I just read your question and have a possible solution: if you "import _opengl" somewhere "XFreePixmap" is needed, which is contained in "_glumodule". So try "import _glu", then "import _opengl". I think the "import _opengl" was proposed as a test during installation of PyOpenGL. How to find this out? Scan the symbols of the X-libs (say in path "/usr/X11R6/lib and not stripped) eg. do a nm --print-file-name /usr/X11R6/lib/lib*.so.* | grep "T XFreePixmap" which should report /usr/X11R6/lib/libX11.so.6:0001bdb8 T XFreePixmap /usr/X11R6/lib/libX11.so.6.1:0001bdb8 T XFreePixmap So "libX11" is it. Looking into the libs (with "ldd") in the directory where "_openglmodule" is located you find out that "_glumodule" loads "libX11". To make the expamles in "...site-packages/OpenGL/OpenGL/Demo" working add the "import _glu" statement into "...site-packages/OpenGL/OpenGL/GL/__init.py__" (before "import OpenGL"). Salu Manfred From thomas at bibsyst.no Thu Dec 16 14:34:06 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Thu, 16 Dec 1999 14:34:06 +0100 Subject: Control chars and special chars Message-ID: <3858EA4E.37666179@bibsyst.no> Hi, I want to use special chars. in my script, like the copyright sign or a block-like thing etc. I see Python has something like \013 for return etc. Is there a table containing the rest? And how do I remove all control chars. from strings? Thomas From tonyscaponi at my-deja.com Thu Dec 16 20:16:27 1999 From: tonyscaponi at my-deja.com (tonyscaponi at my-deja.com) Date: Thu, 16 Dec 1999 19:16:27 GMT Subject: cgi authentication Message-ID: <83bdq6$chd$1@nnrp1.deja.com> Magnus L. Hetland wrote: >"Dan Grassi" wrote: >>I need to do authentication from Python, for various reasons using Apache >>and .htaccess is not a workable solution. I can get the request to show up >>with the following code but I can not figure out how to access the returned >>name/password pair. Yes, I have looked hard for the info on the web and in >>the books. "-) > >Well-I have had the same problem, and AFAIK, Apache refuses to give you the >password (ostensibly for security reasons...) There is a patched version >available somewhere... As near as I can tell, Apache (we use 1.3.9) *does* give the password, if you request full headers. The password is stored in the "Authorization:" header in base64. I use the following PHP to get the username/password pair from that header: I Know a Secret!

I Know a Secret!

Your Username: $username
\n"; echo "Your Password: $password
\n"; ?> I'd guess you can do the same thing in Python. I'd like to know how to disable access to the Authorization header; that's how I found this discussion :*) Jerry Sent via Deja.com http://www.deja.com/ Before you buy. From python-list at teleo.net Fri Dec 10 01:31:55 1999 From: python-list at teleo.net (Patrick Phalen) Date: Thu, 9 Dec 1999 16:31:55 -0800 Subject: some random reflections of a "Python newbie": (1) books, and free sites In-Reply-To: <82pcm0$p6t$1@nnrp1.deja.com> References: <82o0to$6eq$1@serv1.iunet.it> <82pcm0$p6t$1@nnrp1.deja.com> Message-ID: <9912091643250Q.02667@quadra.teleo.net> [Preston Landers, on Thu, 09 Dec 1999] :: ... I would :: have recommended this book more whole-heartedly if it had doubled the :: size by including extensive examples. Which leads me to... :: :: In my opinion, what the Python community *really* needs is an :: equivilent to O'Reilly's "Perl Cookbook." A really solid, well written :: book like this would probably sell like hotcakes within the community :: and also prompt new developers to give the language a try. :: :: Something like "Mastering Algorithms in Python" would be cool too, but :: it's not really neccesary. If you can grok the Perl algorithm book, :: you should have little problem translating. Assuming you can read Perl :: syntax, that is. However, basic literacy in Perl is not such a bad :: thing. I just received my copy of Martin C. Brown's _Python Annotated Archives_. This has 700+ pages of example scripts with detailed annotation. Very useful for those who prefer to learn by example. (Brown is also the author of _Perl: The Complete Reference_ and _Perl Annotated Archives_.) _The Quick Python Book_ is worth the price, now that I see it in the printed and bound form. BTW, I notice that my Python bookshelf now comprises 10 volumes, measuring 11 inches in total width. Who says there are no Python books? :-) From tim_one at email.msn.com Wed Dec 15 07:08:55 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 15 Dec 1999 01:08:55 -0500 Subject: Bug in Python 1.5.2 exception handling? In-Reply-To: <87hfhlujfn.fsf@heresy.itga.com.au> Message-ID: <000601bf46c2$de59f3a0$05a0143f@tim> [Dave Cole] > It looks like function locals are not deleted if that function is > terminated by an exception. That's true, but it's not a bug: Python doesn't define the lifetime of objects. CPython is much more predictable than JPython in this respect-- thanks to using refcounts --but you still rely on it at your own risk. In the case of a function that terminates due to exception, the locals are still very much alive, because they *can* be reached via the traceback object (from which the chain of stack frames can be reached, from which the locals can be reached). > They seem to hang around until they are unref'ed when the function > is next called. That one is an illusion. Your function happened always to raise an exception, and the act of raising an exception causes the previous traceback object to become unreachable (and so also the old chain of stack frames, and so also their locals). Change your loop to: for val in range(3): try: check_raise(val) except: try: raise "dummy" except: pass and you'll see that the 'raise "dummy"' has the same effect. > class c: > def __init__(self, val): > self.val = val > def __del__(self): > print val, 'deleted' You really want print self.val, 'deleted' there. As is, it's picking up the global name "val", which is at best accidentally related to the val passed to __init__. This accounts for the "repeated" deletion of object 2 at the end of your msg: > raise: 2 deleted > 2 deleted if-only-illusions-cancelled-out-ly y'rs - tim From python-list at teleo.net Tue Dec 7 08:36:22 1999 From: python-list at teleo.net (Patrick Phalen) Date: Mon, 6 Dec 1999 23:36:22 -0800 Subject: browser interface? In-Reply-To: <384af243_4@news5.newsfeeds.com> References: <384af243_4@news5.newsfeeds.com> Message-ID: <99120623372703.02133@quadra.teleo.net> [55555, on Sun, 05 Dec 1999] :: Not having a formal CS background, I have no real idea about how to pass :: information between programs, and I don't have time to teach myself any GUI :: toolkits. I thought using a browser as an interface would be an easy :: compromise. So my question is should I use the cgi module to do that or is :: there a better way? Also, if I'm using cgi, is there a way to not reload my :: script every time a button is clicked? Thanks in advance. Sounds like Zope might be a fit. http://www.zope.org From andy at robanal.demon.co.uk Wed Dec 8 01:21:27 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Wed, 08 Dec 1999 00:21:27 GMT Subject: Python/cgi Was: Very useful message -- Hah! References: <199912052201.RAA11142@mail3.mia.bellsouth.net> Message-ID: <3854a300.15783926@news.demon.co.uk> dgrassi wrote: >It's python that needs to be changed. Something simple like a keyword >that tells it to put out a header for Apache. That is the fork I >mentioned above. Look, you can write a subroutine in seconds to do exactly that, and keep it in a library module you include in all your scripts. Or, better, write one CGI script handler once, and import the content-generating code from another. Or ten other solutions. Furthermore, most of us don't care much if a CGI 'Hello World' is five lines in PHP and 10 in Python - the 5-line overhead is a constant, not a factor of four. And I think that ultimately you are doing people a favour by helping them learn about what they are writing out - there is no 'magic'. The Python philosophy is to keep the core clean and simple. There are no special builtin commands for web developers, or GUI developers, or sockets developers, or any other kind. If Guido did that, the core language would grow unwieldy for everyone. Out of curiosity, at work I have to control headers for customers in different parts of Asia; stuff like 'content-type=text/html; charset=ShiftJIS' which varies depending on the data I subsequently write out. If PHP builds this into the language, do you lose the ability to control the headers when you actually need to? - Andy From jam at quark.emich.edu Tue Dec 14 19:24:56 1999 From: jam at quark.emich.edu (Jeff) Date: Tue, 14 Dec 1999 13:24:56 -0500 Subject: Not really about python... In-Reply-To: References: Message-ID: <19991214132456.C25296@quark.emich.edu> On Tue, Dec 14, 1999 at 05:58:25PM +0000, Sposhua wrote: > ...but this is the only newsgroup I go to. > > I use Python for my CGI scripting and it looks like I'm gonna have to put > something up on an NT (bleaj!) server. Any1 know the equivalent of Unix's > sendmail on Windows? I doubt /usr/bin/sendmail works ;-) > > Cheers > try the 'smtplib' module in the standard distribution. this 'should' work on NT as well as UNIX platforms. regards, J -- || visit gfd || psa member -- || New Image Systems & Services, Inc. From mkia1 at my-deja.com Fri Dec 17 17:14:48 1999 From: mkia1 at my-deja.com (mkia1 at my-deja.com) Date: Fri, 17 Dec 1999 16:14:48 GMT Subject: Embedded Python 1.5.1 crashes under WIN32 References: <3832F6FB.68AAA96E@tu-bs.de> <38330158.170604796@192.77.87.74> Message-ID: <83dnhj$tu2$1@nnrp1.deja.com> This must be a common setup problem with embedded Python under Win32. I ran into it also. Per the FAQ note, you have to set C/C++ compiler options to "Multithreaded DLL", or include the /MD switch in your Project Options. In article <38330158.170604796 at 192.77.87.74>, jlj at cfdrc.com (Lyle Johnson) wrote: > See this entry in the Python FAQ list: > > http://www.python.org/doc/FAQ.html#8.7 > Sent via Deja.com http://www.deja.com/ Before you buy. From alwyns at prism.co.za Fri Dec 17 12:24:45 1999 From: alwyns at prism.co.za (Alwyn Schoeman) Date: Fri, 17 Dec 1999 13:24:45 +0200 Subject: getattr function Message-ID: <385A1D7D.19262C62@prism.co.za> Hi, Could someone please explain this function to me? Specifically as it relates to use in classes and overloading? Say I've got my own listthingy class without a sort, if I now do X.sort() I can see that a method in my class which looks like def __getattr__(self, name), that sort is probably the name parameter. But how does it know that it must do a list type sort or does this work just because sort is kindof generic? def __getattr__(self, name): return getattr(self.data,name) for the above. -- ~~~~~~~~~~~~~~ Alwyn Schoeman Systems Engineer Prism Secure Solutions From paul.magwene at yale.edu Tue Dec 14 01:45:05 1999 From: paul.magwene at yale.edu (Paul M) Date: Mon, 13 Dec 1999 19:45:05 -0500 Subject: pxDislin - release 0.1 Message-ID: <83440i$er5$1@news.ycc.yale.edu> DESCRIPTION: ----------- pxDislin is an object-oriented wrapper around the DISLIN plotting library. DISLIN is a powerful and flexible multiplatform (Win32, Unix, Linux, etc.) library designed for displaying scientific data. DISLIN's author, Helmut Michels, has made available a DISLIN plotting extension for the Python programming language (see http://www.linmpi.mpg.de/dislin/ for more details). pxDislin provides a set of classes which represent various aspects of DISLIN plots, as well as providing some easy to use classes for creating commonly used plot formats (e.g. scatter plots, histograms, 3-D surface plots). A major goal in designing the library was to facilitate interactive data exploration and plot creation. Documentation and a demo program are included. The library has been tested on WinNT and FreeBSD, but I anticipate that it should work on any platform which can make use of Python, NumPy, and the DISLIN python extensions. Feedback, comments, and critique are gladly accepted (email: paul.magwene at yale.edu). VERSION: ------- This is release 0.1 of pxDislin. URL: ---- You can find pxDislin at: http://pantheon.yale.edu/~pmm34/pxdislin.html Paul Magwene paul.magwene at yale.edu

pxDislin 0.1 - a set of object-oriented classes which work with the DISLIN python extension. (13-Dec-99) From kbaldermann at entire-systems.com Wed Dec 15 15:12:49 1999 From: kbaldermann at entire-systems.com (Klaus Baldermann) Date: Wed, 15 Dec 1999 15:12:49 +0100 Subject: Help?? Struct packing of Date time not has stopped working??!?! References: <835mvi$62t$1@nnrp1.deja.com> <38579924@194.120.211.23> Message-ID: <3857a18a@194.120.211.23> Following up my own posting :-) I just tried the following script: # check time server import telnetlib, sys, time connection = telnetlib.Telnet() line = '' host = sys.argv[1] count = 0 check = {} while count < 1000: connection.open(host, 37) line = connection.read_all() connection.close() count = count + 1 try: check[len(line)] = check[len(line)] + 1 except: check[len(line)] = 1 time.sleep(0.7) c1 = check.keys() c1.sort() for i in c1: print i, check[i] and the result was: 3 11 4 989 I assume our (intranet) time server doesn't use Python, so it is probably not your server script at fault. And to find out more, one would have to capture the server output to see which values are pathological. yours Klaus From bwarsaw at cnri.reston.va.us Wed Dec 1 17:49:06 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Wed, 1 Dec 1999 11:49:06 -0500 (EST) Subject: What's the canonical vi setting for Python indentation References: <38445B6A.A1283D2E@cs.mu.oz.au> <19991201111751.A1277@Ridcully.home> Message-ID: <14405.20866.508340.77528@anthem.cnri.reston.va.us> I don't know enough about vi configuration, but it would be good to follow the simple rule that python-mode uses: if your indent level is not equal to your tab width, use only spaces for all indentation. So for example, if you indent 4 spaces per level but your tab width is 8, never use tabs, even if you're indenting two levels. You can use tabs if your indent level is equal to your tab width, e.g. your tab width is 8 and your indent is 8. Note that the default for python-mode is to indent 4 spaces per level, use a tab width of 8, and always use spaces. -Barry From t.keil at zvs.zgs.de Mon Dec 27 21:11:36 1999 From: t.keil at zvs.zgs.de (Thomas Keil) Date: Mon, 27 Dec 1999 12:11:36 -0800 Subject: Is there a Python for my XT Palmtop (MSDOS) Message-ID: <3867C7F8.2A5E@zvs.zgs.de> I'd like to use Python on my HP 200LX (XT compatible, MS DOS 5). The DOS-binaries from python.org do not work - even Python 1.0.1. Please give a hint. Thanks in advance, Th. Keil --- mailto:mail at thok.de From andrew at one.net.au Mon Dec 6 15:30:01 1999 From: andrew at one.net.au (Andrew Maizels) Date: Tue, 07 Dec 1999 00:30:01 +1000 Subject: Python.org is down! References: Message-ID: <384BC869.2CAD569@one.net.au> John Doe wrote: > > Hello All > > I read that short tutorial on the web site yesterday and > believe that there was a mention of setting a default > root directory within a .py script. > > The time now is 00:10 Eastern Standard Time (GMT -5) > in USA and python.org is down for sometime now. It's not down, it's just shagged out after a long file transfer. Pining for the fjords, I tell you! > I was wondering whether my above belief is correct. > I am writing a script that may involve accessing > files in the user home directory and need that > piece of info in my script. Chapter 13 in the Library Reference details Rexec, which is probably what you're after. It does more (and less) than a simple chroot. When the parrot^Wserver comes back up, download the PDF version of the manuals and keep them handy at all times. If you need it urgently, I've put a copy on my web server: http://platypus.mu.nu/lib.pdf > I have to say that yesterday was my first > introduction to python and now I am off to > writing something useful which I hope will > turn into a GIGANTIC project. I actually > started looking at perl as a possible tool but > ... ... indeed. Andrew. -- The sensitive soul who designs the One.Tel ads and the annual reports has been let loose on the walls, armed with what seems like the nation's entire supply of phosphorescent paint. -- The Australia Financial Review, Tuesday, September 21, 1999 From ilya at glas.net Wed Dec 29 10:28:01 1999 From: ilya at glas.net (ilya at glas.net) Date: 29 Dec 1999 09:28:01 GMT Subject: Looking for pysnmp References: <19991229073623.A19765@gothic.andrich.net> Message-ID: <84ck71$362$1@news.glas.net> The package available at: http://www.glas.net/~ilya/software/pysnmp.html > P.S.: Is it just me or does the seach facility at python.org doen't work in > general? Python folks recommended a Python archive at: http://www.vex.net/parnassus -ilya From claird at starbase.neosoft.com Mon Dec 20 23:07:40 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 20 Dec 1999 22:07:40 GMT Subject: Why can pyhton deal with a big project? References: <83lutn$sfn$1@news3.dti.ne.jp> <19991220142820.A25651@quark.emich.edu> <83m5i2$3qk$1@news3.dti.ne.jp> Message-ID: In article <83m5i2$3qk$1 at news3.dti.ne.jp>, Hirofumi Furusawa wrote: . . . >I found the page titled "Comparing Python to Other Language". That says in >the section of comparing to Tcl: > > Tcl also lacks features needed for writing large programs, such as > modular namespaces. In fact Tcl gained namespaces about two years ago. . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From mgushee at havenrock.com Sat Dec 18 09:16:06 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 18 Dec 1999 03:16:06 -0500 Subject: Announce: Pyxie - an Open Source XML Processing Library for Python References: <3854711d.4263700@news.iol.ie> <83b5m7$5tv$1@nnrp1.deja.com> Message-ID: Andrew Cooke writes: > > Pyxie is an Open Source XML Processing Library for Python > > that lives at http://www.pyxie.org. > This isn't criticism, just a request for information - why go through an > intermediate representation rather than use XML directly? What does Pyx > have/not have that XML doesn't/does? I don't know much about XML, so > this may be a very silly question! I can't speak for Sean McGrath, but IMHO: It's not a silly question. The first thing you need to know about XML is that it's not a programming language. It's a data/document description language. So, by definition, it doesn't and will never *do* anything. You need to use a programming language to manipulate it. Every program that works with XML needs, at a minimum, to have it parsed. Then there are certain higher-level models (e.g. the 'tree' -- a hierarchical structure of data nodes) that are usually or very commonly used. There is no sense in every programmer who wants to work with XML writing their own parsing routines, etc. Pyxie provides some of these infrastructural functions, to make it easier for you & me to start creating cool applications that work with XML. Hope this helps a bit. -- Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ From thomas at bibsyst.no Thu Dec 30 12:07:07 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Thu, 30 Dec 1999 12:07:07 +0100 Subject: RPM-interface/module Message-ID: <386B3CDB.FF843280@bibsyst.no> Is there a RedHat package interface/module available for Python?? Thomas From grant at nowhere. Thu Dec 30 12:36:47 1999 From: grant at nowhere. (Grant Edwards) Date: Thu, 30 Dec 1999 11:36:47 GMT Subject: why? References: <38685b07.189574443@news.isomedia.com> <00b801bf52ac$7f909ea0$f29b12c2@secret.pythonware.com> Message-ID: In article <00b801bf52ac$7f909ea0$f29b12c2 at secret.pythonware.com>, Fredrik Lundh wrote: >Grant Edwards wrote: >> 2) [Python] isn't suitable for use in embedded systems with limited >> memory. > >really? > >http://www.abo.fi/~iporres/python/ > >discusses how to run Python on a >machine with 256k RAM. I should have been more specific than "limited". I was thinking of the more typical embedded system with an 8 bit processor and something like 64K of ROM and 8-16K of RAM. -- Grant Edwards grante Yow! Let's climb to the at TOP of that MOUNTAIN and visi.com think about STRIP MINING!! From mspal at sangria.harvard.edu Mon Dec 27 15:49:16 1999 From: mspal at sangria.harvard.edu (Michael Spalinski) Date: 27 Dec 1999 09:49:16 -0500 Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> Message-ID: >>>>> "Paul" == Paul Prescod writes: Paul> Kidding aside, "class" is a noun and "def" is an abbreviation for Paul> a verb. Furthermore, "def" is way too generic. Python has class I realize that this will not make you completely happy, but you could consider "def" to be an abbreviation for the noun "definition" ... M. From sbarron at twilight. Tue Dec 14 08:25:20 1999 From: sbarron at twilight. (Scott Barron) Date: Tue, 14 Dec 1999 07:25:20 GMT Subject: socket.makefile() question References: <199912140315.VAA14303@giant-curled.mcs.gac.edu> Message-ID: (I tried to reply by mail but the delivery failed) Hi, Are you sure you don't mean: wf = conn.makefile ('wb') rf = conn.makefile ('rb') in service() ? conn is the new socket returned by accept(), s is the original. I changed it and got this: twilight:~$ telnet localhost 5555 Trying 127.0.0.1... Connected to twilight. Escape character is '^]'. generic message Is this what you're looking for? -Scott On Mon, 13 Dec 1999 21:15:59 -0600, Charles Follett wrote: >It is my understanding from the documentation that socket.makefile() >takes a socket object and returns a nice file object, with all the >associated methods. I attempt to use this in the attached code, but to >no avail; I get an error every time I try and write to it: > >Traceback (innermost last): > File "/var/tmp/python-root/usr/lib/python1.5/threading.py", line 376, in __bootstrap > self.run() > File "/var/tmp/python-root/usr/lib/python1.5/threading.py", line 364, in run > apply(self.__target, self.__args, self.__kwargs) > File "./server.py", line 31, in service > wf.flush() >IOError: [Errno 32] Broken pipe > >The client (telnet) never recieves the message. Here is the >code. Perhaps someone can explain what I am doing wrong. > >Thanks.. >charley > From fredrik at pythonware.com Sun Dec 19 17:45:43 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 19 Dec 1999 17:45:43 +0100 Subject: Python complaints References: <3858C226.949FC9C6@udel.edu> <14425.4841.291880.269618@weyr.cnri.reston.va.us> <62ij5sov45demdte805irtg48hd0eu8m3o@4ax.com> Message-ID: <008d01bf4a40$7ebc8670$f29b12c2@secret.pythonware.com> Quinn Dunkan wrote: > >> As someone else pointed out using the buffer object as an example, > >>this doesn't always make sense. > > > >Umm... could someone point me toward some documentation on this > >elusive object? It sounds useful, if I can ever find it. > > I think he's referring to StringIO/cStringIO, which simlpy provides > read() write() etc. so it looks like a file object but really stores > it in a string. It's in the library ref. or maybe he was referring to the kind of objects created by the builtin "buffer" function, which provides a sequence API to any object implementing the internal buffer interface. or in other words, it's n obscure way to peek into the innards of certain kinds of objects: >>> a = "abc" >>> b = buffer(a) >>> b python uses the interface API to avoid copying under certain circumstances. it can also be used to crash the interpreter in various interesting ways... From gerrit.holl at pobox.com Fri Dec 3 13:27:02 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 3 Dec 1999 13:27:02 +0100 Subject: A Date With Tim Peters... In-Reply-To: <826o9s$h4k$9@newshost.accu.uu.nl>; from m.faassen@vet.uu.nl on Thu, Dec 02, 1999 at 09:28:28PM +0000 References: <199912020003.TAA13009@eric.cnri.reston.va.us> <825nbt$p50@mail.psy.uva.nl> <19991202203008.A7698@stopcontact.palga.uucp> <826o9s$h4k$9@newshost.accu.uu.nl> Message-ID: <19991203132702.B2483@stopcontact.palga.uucp> Martijn Faassen wrote: > >> But I would like to. > > > Me too. > > > I'll set up a small page to see how many people would join a Dutch > > Python users group. > > I wanted to work on a Dutch Python group in february or something, so > perhaps I can help. I'd also like to include the Dutch Zope users, of which > there are quite a few as well. I'll ask my sysadmin to make a mailinglist python at nl.linux.org to which Dutch users can subscribe by sending a message to Majordomo at nl.linux.org with "subscribe python" in the body. The interested people can discuss there further. It's not good to discuss in English in a public newsgroup on a Dutch Python group. regards, Gerrit. -- "Nature abhors a Vacuum" -- Brian Behlendorf on OSS (Open Sources, 1999 O'Reilly and Associates) 1:24pm up 58 min, 14 users, load average: 0.00, 0.00, 0.00 From thantos at chancel.org Thu Dec 23 00:27:04 1999 From: thantos at chancel.org (Alexander Williams) Date: Wed, 22 Dec 1999 23:27:04 GMT Subject: How to read lines from end of a file? References: <4rhfhazoj4.fsf@colargol.tihlde.hist.no> Message-ID: On 22 Dec 1999 21:52:31 +0100, Stig Bjorlykke wrote: >open FILE, "/tmp/file"; >foreach (reverse ) { ... } > >I am using it to get the latest entries in a log file. Thought about: >>> data = open("filename").readlines() >>> data.reverse() >>> for lne in data: >>> ... Admittedly this gets rather hairy for long log file analysis since it has to slurp up the whole thing into memory; alternately, you can try opening it in binary mode, seek to the end, start skipping backwards until you find the last CR, then begin loading characters into a buffer in reverse order. Probably not as effortless, but much, much lighter on the memory requirements. -- Alexander Williams (thantos at gw.total-web.net) | In the End, "Join the secret struggle for the soul of the world." | Oblivion Nobilis, a new Kind of RPG | Always http://www.chancel.org | Wins From greg.ewing at compaq.com Wed Dec 15 15:14:22 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 16 Dec 1999 03:14:22 +1300 Subject: Need information om Python byte-code References: <8345m3$27t$1@hyperion.nitco.com> Message-ID: <3857A23E.88463DF5@compaq.com> Nick Maxwell wrote: > > If someone could just tell me the exact > steps to compiling a module into byte-code, I would really appreciate it! You don't have to do anything -- it happens automatically. Whenever a module is imported for the first time, it is compiled into bytecode which is saved in a .pyc file. Next time, if the .pyc file is newer than the .py source file, the bytecode is simply loaded out of the .pyc file. Greg From mlh at vier.idi.ntnu.no Tue Dec 7 22:58:35 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 07 Dec 1999 22:58:35 +0100 Subject: lemmings References: <82j6o3$jc6$1@news.qub.ac.uk> Message-ID: stuarty at excite.co.uk (stuart mcfadden) writes: > Where would I find a list of all the stuff that`s already been written in > Python ? > > TIA, > Stuarty > > p.s. Is Magnus L. Hetland truly the only person to use "snazzy" in > documentation ? I never thought of that... It's not all Python documentation, but a search for python snazzy in alltheweb.com returned 344 documents. I didn't bother to read them all to find out more, though... -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From hat at se-46.wpa.wtb.tue.nl Tue Dec 21 18:21:27 1999 From: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) Date: 21 Dec 1999 17:21:27 GMT Subject: List comprehensions References: <38592275.BBA2B61A@maxtal.com.au> <385E045D.9EC36473@compaq.com> Message-ID: On Tue, 21 Dec 1999 03:44:24 GMT, Alexander Williams wrote: >> print [ (x,y) | x <- xs, x>3, y <- xs, y>x ] > >Oooh, Haskell syntax. I'm feeling perfectly at home. :) Then you are going to like our specification language chi :-) Say for yourself: *[ x<0 -> x:=x+2 | x>0 -> x:=x-3 ] is much nicer than while x<0 or x>0: if x<0: x:=x+2 elif x>0: x:=x-3 >>I'd like to have that, except that I don't know how to write that >>down. On the other hand, in our field, it is probably not needed much. > >I'm not sure that writing parallel iterators as a single line is >really condusive to understanding what is going on under the hood. >You can always nest iterators, as well ... That's always fun. :) But that is not the same thing. For example, xs:=[1,2]; y:=[3,4] then nested, you get [ (1,3), (1,4), (2,3), (2,4) ] and parallel, you get [ (1,3), (2,4) ] In a different posting, I say a few things about parallel iterations. >>Also, I'd like to get rid of fold(). > >Hey, I /like/ fold (foldl, foldr)! After all, the results of fold >aren't lists, they're single values. It makes sense for it to be a Oops, I should have been clearer. I'd like to have fold functionality inside the kind of expressions we are discussing. > sumGreaterThanFive(lst) = foldl(operator.plus, > [e <- lst, e>5]) In our language, you cannot write an expression just like that. You'd have to define a full function for it. I saw the explanation of this in the Python tutorial(?) with the map and filter functions. I think that many users never use it, because it is too much hassle to have to write a separate function. They rather write a for-loop instead. (note that map and filter are not very powerful in that respect. They replace just a single loop. One has to nest calls explicitly before you get power like [ x+3 | y <- ys, z <- zs, y>z, x <- xs, y+z Message-ID: On 2 Dec 1999, Magnus L. Hetland wrote: > I can't get it to work... :( > > I have compiled it and installed it, but when I try to import Numeric, > Python just crashes. I know there isn't much information in that, but > is there anyone, by any chance, who can help me anyway? (I'm on > Solaris...) What version? Do you know how to start Python under a debugger like gdb or dbx? This should allow us to help you figure it out. --david ascher PS: You might want to focus emails to matrix-sig at python.org or support at icf.llnl.gov, which are more 'narrow' audiences. From pf at artcom0.north.de Sun Dec 12 18:26:21 1999 From: pf at artcom0.north.de (Peter Funk) Date: 12 Dec 1999 18:26:21 +0100 Subject: Tk Listbox bindings (was: Tk Listbox Question) References: <199912092219.XAA26417@axil.hvision.nl> Message-ID: <830lrt$geu$1@artcom0.north.de> In <199912092219.XAA26417 at axil.hvision.nl> "Hans Nowak" writes: >> #Here's the bindings >> >> self.listbox.bind('', self.do_this) >> self.listbox.bind('', self.do_that) >> self.listbox.bind('', self.do_something_else) >While it's easy to bind mouse events to a listbox, I haven't managed >to bind keyboard events to it. In a current project I have a listbox >and I want my users to be able to scroll through it using common keys >like and . However, binding them to the listbox, as done >above, does not work; I don't know why. May be because your listbox doesn't got the keyboard focus? You can move around the keyboard focus using the TAB key or otherwise you can set the keyboard focus using the 'focus_set()' method from within your program. Hope this helps. Regards, Peter -- Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260 echo '[dO%O+38%O+PO/d0<0]Fi22os0CC4BA64E418CE7l0xAP'|dc From greybria at direct.ca Wed Dec 29 02:12:33 1999 From: greybria at direct.ca (Colleen & Brian Smith) Date: Tue, 28 Dec 1999 17:12:33 -0800 Subject: ??? Tkinter destroy() - Remove a widget from a frame. Message-ID: <9fda4.2935$BL.215638@brie.direct.ca> What is the proper way to destroy() the "display" widget (which is actually a Label descendent -- taken from the Viewer.py script that comes as a demo for the Python Imaging Library) in the code below, so that I can recreate it and load a new image in the UnloadPic method? Thanks in advance. -------------------------------------------------------------------- from Tkinter import * import Image, ImageTk from viewer import UI from tkFileDialog import * class Application(Frame): def LoadPic(self): self.picname=askopenfilename(filetypes=[("Image Files", "*.bmp;*.gif;*.jpg")]) self.pic = Image.open(self.picname) self.pic.thumbnail((400,300)) self.display = UI(self,self.pic).pack(side=TOP) self.LOAD["state"]="disabled" self.UNLOAD["state"]="normal" def UnloadPic(self): self.display.destroy() # does not work self.LOAD["state"]="normal" self.UNLOAD["state"]="disabled" def createWidgets(self): self.QUIT = Button() self.QUIT["text"] = "QUIT" self.QUIT["fg"] = "red" self.QUIT["command"] = self.quit self.QUIT.pack(side=RIGHT) self.LOAD = Button() self.LOAD ["text"] = "Load" self.LOAD ["command"] = self.LoadPic self.LOAD.pack(side=LEFT) self.UNLOAD = Button() self.UNLOAD ["text"] = "Unload" self.UNLOAD ["command"] = self.UnloadPic self.UNLOAD ["state"] = "disabled" self.UNLOAD.pack(side=TOP) def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets() app = Application() app.mainloop() -- Brian Smith greybria at direct.ca http://mypage.direct.ca/g/greybria From pjensen at columbus.rr.com Sun Dec 26 21:35:56 1999 From: pjensen at columbus.rr.com (Phil Jensen) Date: Sun, 26 Dec 1999 15:35:56 -0500 (EST) Subject: control structures (was "Re: Sins") Message-ID: John Skaller quoted the following: [and by the way, Viper and "environments" sound great. I'm looking forward to this...] > > > But 'break' > > > in python isn't labelled, and there is no goto, > > > so you end up having to use exceptions ... Uggghhhh. > > > > Labeled breaks might well be a good idea, I guess. and wrote: JS> I'm not sure. I also have no candidate syntax JS> for defining the labels. Labelled breaks give me JS> an uneasy feeling. I forget if I posted this before, but what I'd like to see is the Zahn construct discussed in Knuth's article - Pythonically: loop until "element found" or "search failed": ... if blah1 == blah2: "element found" ... when "element found": ... when "search failed": ... Whatever the loop is, its exit or exits have some "meaning" in the program, and this control structure encourages an element of Literacy by forcing them to be named. It deals with multiple exits, and multiple-level exits very nicely. (I've shown strings here because they allow more literacy than identifiers, but they're still intended as mere tokens. "elem" + "ent fou" + "nd" won't do it.) IMHO, "break 3" would be awful. Phil Jensen From sposhua at my.pc Mon Dec 13 13:13:21 1999 From: sposhua at my.pc (Sposhua) Date: Mon, 13 Dec 1999 12:13:21 +0000 Subject: Locking files? n stuff In-Reply-To: References: Message-ID: On Sun, 12 Dec 1999, _martin_ wrote: > I'm new to this so here's a little background... So am I ;-) > I'm writing a guestbook (and eventually counters) in Python and wondered: > Do I need to worry about locking and unlocking files > If I do, can anyone let me know which command to use (flock, fcntl.lock, etc. ?) http://www.python.org/doc/current/lib/module-fcntl.html (or shelve) From cfelling at iae.nl Fri Dec 24 22:00:51 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 24 Dec 1999 22:00:51 +0100 Subject: Bad programming style? References: <6D8A17398E28D3119F860090274DD7DB4B3D7C@pces.cadlab.it> Message-ID: <840mu3$2jh$1@vvs.superst.iae.nl> Alex Martelli wrote: > Carel writes: >> Why not use the following: >> >> >>> locals()['r'] = 'ff' >> >>> print r >> ff >> > Uh, perhaps because the docs specifically tell you not to...?-) Oeps, I've never been a obedient cityzen, but I think it's time to straighten up my act then:) > Reference puts it; I don't see how it could be clearer. It could be clearer by not working:) > I think this "feature" makes a good case for something I for a moment I thought you ment the use of locals() in this way. But elas, you were only after forcing me to give up this good looking though unsafe idiom:( > was wishing for since very early on in my (not yet very > long:-) Python involvement -- a way to "lock" a mapping > so that attempts to write to it will fail *non*-silently, i.e., > raise exceptions. If such a 'locked' state was available, > I imagine locals() would make use of it, preventing such > erroneous usage. So now that all namespaces are locked:) what is the approved way of changing names? In classes we have instance.__dict__, but if I remember correctly somewhere in the docs one is warned that namespaces need not be implemented with dict. Can't find where it said so, might wel have been read in some dreamlike state. In functions and modules we only have locals(), right? Do I really have to switch to exec? -- groetjes, carel From gerrit.holl at pobox.com Fri Dec 17 19:38:36 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 17 Dec 1999 19:38:36 +0100 Subject: exceptions? In-Reply-To: <83bmdq$i8a$1@nnrp1.deja.com>; from zsoltman@my-deja.com on Thu, Dec 16, 1999 at 09:43:22PM +0000 References: <8388m7$1ii$1@nnrp1.deja.com> <83bmdq$i8a$1@nnrp1.deja.com> Message-ID: <19991217193836.A6170@stopcontact.palga.uucp> zsoltman at my-deja.com wrote: > def HandleTraceBack(excinfo2,msg): > import traceback > tb=traceback.format_list(traceback.extract_tb(excinfo2)) > for each in tb: > msg=msg + each > raise ValueError,msg >>> try: ... 1/0 ... except: ... import traceback ... traceback.print_exc() ... print 'still running' ... Traceback (innermost last): File "", line 2, in ? ZeroDivisionError: integer division or modulo still running -- "Nature abhors a Vacuum" -- Brian Behlendorf on OSS (Open Sources, 1999 O'Reilly and Associates) 4:04pm up 4:55, 16 users, load average: 0.00, 0.00, 0.00 From digitome at iol.ie Fri Dec 24 11:51:37 1999 From: digitome at iol.ie (Sean Mc Grath) Date: Fri, 24 Dec 1999 10:51:37 GMT Subject: Patch: httplib.py default timeout References: <83r0lh$mj6$1@nntp6.atl.mindspring.net> Message-ID: <38634ba8.3512711@news.iol.ie> On 22 Dec 1999 17:10:09 GMT, aahz at netcom.com (Aahz Maruch) wrote: >No, I'm not including the actual patch here. I just wanted to see if >anyone had an objection to changing httplib.py so that by default it >times out after sixty seconds. To maintain the current behavior, you'd >have to pass in a parameter of 'timeout=0'. > I'd be interested in hearing the pros/cons of going this route versus packaging socket stuff behind threads with associated timeouts. I looked at the source for Grail and found that it goes right down to the wire rather than use httplib. regards, From tim_one at email.msn.com Thu Dec 2 09:10:37 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 2 Dec 1999 03:10:37 -0500 Subject: __builtins_ weirdness In-Reply-To: <02121999.2@sanctum.jae> Message-ID: <000001bf3c9c$b7391740$0a2d153f@tim> [Juergen A. Erhard] > This really weirded me out: > > __builtins__.range and __builtins["range"] both are the `range' > function, one only works in interactive mode, and the other only in > a module. > ... > I only wish there would be some consistency here. Or some *very* good > explanation. As /F said, you're mucking with internals here. You can find very good explanations in DejaNews if you're determined, but better to just begin your module with _range = range and then refer to _range inside your function. That is, you're mucking with internals when there's no need to muck with internals at all -- indeed, when mucking with internals is much slower and clumsier than doing the obvious thing above. > def range(*args): > ... Redefining builtin names is dubious practice. Name it myrange() (or something), and you wouldn't have to worry about getting back the builtin range -- and your code readers wouldn't have to scratch their heads wondering what the heck e.g. range(list) means (virtually all Python programmers would see that and be certain the code was broken). > ... > But in a module, __builtins__ `magically' transforms into a dict... Section 4.1 ("Code blocks, execution frames, and namespaces") of the Lang Ref explains part of that. __builtins__-is-not-a-module-but-__builtin__-is-ly y'rs - tim From thantos at chancel.org Wed Dec 22 05:06:40 1999 From: thantos at chancel.org (Alexander Williams) Date: Wed, 22 Dec 1999 04:06:40 GMT Subject: List comprehensions References: Message-ID: On 21 Dec 1999 16:54:16 GMT, Albert Hofkamp wrote: >With parallel iteration, you are doing two things at a time. >If you want to be able to do this in Python (a new question !!), >then imho you'd need a single language construct which looks like 'see, >I am iterating over both lists here, watch out !' More and more /this/ construct is looking to be map(). Consider the results of doing: >>> map(None, range(1, 11), >>> range(1, 11)) You get: >>> [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8,8), (9, 9), (10, 10)] ... which is just the parallel construct you wanted. > This is especially true if you do not start with an iteration, like in > > [ x>6, x>5 ] > > (Bonus-points for the people who understand what the result is :-) ) Easy, a two element list consisting of two Boolean values dependent on whether or not the pre-defined value x makes said statement true. :) -- Alexander Williams (thantos at gw.total-web.net) | In the End, "Join the secret struggle for the soul of the world." | Oblivion Nobilis, a new Kind of RPG | Always http://www.chancel.org | Wins From philh at vision25.demon.co.uk Fri Dec 3 00:11:35 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Thu, 02 Dec 99 23:11:35 GMT Subject: RDF/RSS References: <943225647snz@vision25.demon.co.uk> Message-ID: <944176295snz@vision25.demon.co.uk> In article <943225647snz at vision25.demon.co.uk> philh at vision25.demon.co.uk "Phil Hunt" writes: > > As part of my Comuno website, I am creating an RDF file so that other > sites can link to my changing content. I have written some software > to handle RDF (written in python of course), and will be releasing it > under an open source license in the not-too-distant future, i.e. > when I have got it to produce HTML. I was going to release PyRSS last weekend, but it still has a few bugs in it (it works OK with Slashdot, Linux Today and Freshmeat, however). So it looks like it'll be this weekend now. And if I get time, I'll put up some Linux/OSS pages on Comuno. -- Phil Hunt - - - phil at comuno.com "Software is like sex, it's better when it's free" -- Linus Torvalds From michael.stroeder at inka.de Thu Dec 2 20:12:10 1999 From: michael.stroeder at inka.de (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 02 Dec 1999 20:12:10 +0100 Subject: Email address check function References: <19991202163334.A3934@stopcontact.palga.uucp> Message-ID: <3846C48A.F793423A@inka.de> Gerrit Holl wrote: > > I'm writing some CGI scripts and I want the user to fill in their real > email address. Checking this is more difficult than just look if it > contains an '@'. > There must be at least one '.' after the '@' but there must be non-'@' > chars before and after every '.', no white space, etc. How about this: re.compile(r"^([\w at .=/_-]+)@([\w-]+)(\.[\w-]+)*$").match(emailaddress) Well, I think there are some real regex gurus here which can improve my weak guess and provide even stricter patterns. > There must be an RFC for this RFC 822? You could also check if A or MX records exist for the domain part of the email address in the DNS. Watch out for dnslib.py in your Python 1.5.2 distr. under demos(?). This does not prevent people from entering bill.gates at hotmail.com. You could send some access code via email for further access to your system. Ciao, Michael. From marshall at ufm.org Thu Dec 9 01:17:44 1999 From: marshall at ufm.org (Marshall) Date: Wed, 8 Dec 1999 16:17:44 -0800 Subject: browser interface? References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> <19991208005503.CD6AC1CD0A@dinsdale.python.org> <99120800562707.02363@quadra.teleo.net> Message-ID: <5Wz34.5174$O15.2362@client> I have been experimenting with Active Server Pages with some success. I am new to Python and fairly new to ASP, but am basically using HTML and Python in an ASP file as the GUI and processing code combined. It works OK. Active Server Pages are available on non NT platforms through ChiliSoft and others. Marshall Patrick Phalen wrote in message <99120800562707.02363 at quadra.teleo.net>... >[55555, on Tue, 07 Dec 1999] > >:: Thanks for the input. Unfortunately, Zope looks like it's a little over my head, and I'm >:: not even sure what an application server is, although, I can guess. Without getting too >:: complex, is there a way to let the script stay open and "listen" for clicks on a local >:: web page and then respond by printing new html whenever something happens. I am guessing >:: that cgi would do the trick, but as far as I can tell, it would reload the script >:: everytime something is clicked. Is that wrong? I just don't want to open and close an >:: application 50 times. Thanks again. > >Perhaps we could be more helpful if you'd take a wack at describing in >more detail what you're trying to do. > >You say "without getting too complex," but from the sound of it, what >you're looking for is rather complex. > >HTTP is, by design, a stateless protocol. CGI, too, can be thought of >as a sort of stateless remote procedure call; it isn't really connection >oriented and it doesn't natively do what I think you want. > >But, again, I'm not clear on what you're looking to do. Maybe a push or >channel protocol like CDF or RSS? > > > From tholap at compuserve.com Fri Dec 10 11:21:17 1999 From: tholap at compuserve.com (Olaf Appelt) Date: Fri, 10 Dec 1999 11:21:17 +0100 Subject: newbie needs help on dictionary References: <38504788.86E9C885@es.co.nz> Message-ID: <82qklq$qsu$2@ssauraaa-i-1.production.compuserve.com> I'm new to Python so take this with moderate amounts of salt: > count = turret[station][tool_name] > count = count + 1 > turret[station][tool_name] = count 'count' is not a copy of 'turret[station][tool_name]', it's a reference. So the following should result in the same thing: > count = turret[station][tool_name] > count = count + 1 Olaf From dannyjob at my-deja.com Thu Dec 2 15:05:56 1999 From: dannyjob at my-deja.com (Dan) Date: Thu, 02 Dec 1999 14:05:56 GMT Subject: GUI : Group Button References: <823dac$e44$1@nnrp1.deja.com> <016201bf3c0f$8cf9a450$f29b12c2@secret.pythonware.com> Message-ID: <825ubr$8q2$1@nnrp1.deja.com> Fredrik, Thank you so much... this is a great help. Regards, Dan In article <016201bf3c0f$8cf9a450$f29b12c2 at secret.pythonware.com>, "Fredrik Lundh" wrote: > dannyjob at my-deja.com wrote: > > I am attempting to create a GUI using Tkinter > > which has "Group buttons" e.g : > > > > * Group A Button > > > > * Group B Button > > > > * Group C Button > > Option menu 1 > > Option menu 2 > > option menu 3 > > Other Group C Items.... > > > > For example when the Group C button is clicked, > > the option menus etc, will be displayed. > > If the Group C button is clicked on again , > > the option menus etc, belonging to group C, will > > disappear, and only the group button will be > > displayed. > > not really sure if I understand what you're > after, but this article might help a bit: > > http://www.deja.com/getdoc.xp?AN=315540691&fmt=text > > > > Sent via Deja.com http://www.deja.com/ Before you buy. From grant at nowhere. Tue Dec 7 20:53:37 1999 From: grant at nowhere. (Grant Edwards) Date: Tue, 07 Dec 1999 19:53:37 GMT Subject: Class definition example question Message-ID: [background] I'm working on a program to do design verification and production test on a circuit board. Most of the actual testing is done by a C program with a whole boatload of obscure command line options. It works but it's not very friendly, so I'm going to slap a GUI front-end on it. I generally use STk for stuff like this, but this time I decided to try Python since most of the Linux machines around here come with Python and Tkintr already installed, and I've got a better chance of dumping maintenance duties on somebody else if it's not in Scheme. ;) [my example] I've extended the Pmw "ScrolledText" class to add a "run" method that runs a program in a sub-process and displays the standard output in the contained text widget. The class definition is shown below. My question is about the definition of the callback handler "stdoutHandler". If it's done this way, you end up with a complete copy of the handler routine defined each time a program is run. I couldn't figure out any other way for the callback routine to know what widget it belonged to. It seems to work, but I'm pretty sure there's a more elegant way to do this. Would it be better to create a callback class with an instance variable that points to associated widget? Can an object instance be passed to tkintr.createfilehandler? Is this where one needs to define a __call__ method? Any helpful comments will be appreciated #---------------------------------------------------------------------- class execWindow(Pmw.ScrolledText): def run(self,progPath): def stdoutHandler(file,mask,s=self): # read available data line = os.read(s.__fd,4096) # display it in window if line != "": s.insert('end',line) # done? r = s.__child.poll() if r != -1: Tkinter.tkinter.deletefilehandler(file) s.__returnCode = r s.insert('end', '[return=' + str(r) +']\n') self.__child = popen2.Popen3(progPath) self.__fd = self.__child.fromchild.fileno() fcntl.fcntl(self.__fd, FCNTL.F_SETFD, FCNTL.O_NDELAY); Tkinter.tkinter.createfilehandler(self.__child.fromchild, Tkinter.tkinter.READABLE, stdoutHandler) #---------------------------------------------------------------------- -- Grant Edwards grante Yow! I guess we can live at on his POT FARM in HADES!! visi.com From yishai at platonix.com Sun Dec 12 14:58:31 1999 From: yishai at platonix.com (Yishai Beeri) Date: Sun, 12 Dec 1999 15:58:31 +0200 Subject: Python and regexp efficiency.. again.. :) References: <101219992322162268%zippy@cs.brandeis.edu> Message-ID: <3853AA07.BDA8D0E8@platonix.com> What percentage of the lines is expected to actually match? What percentage of the lines match the commonstring but none of the tails? Would it be helpful to look just for the tails and get rid of erroneous matches by then looking for the commonstring? Yishai Markus Stenberg wrote: > Patrick Tufts writes: > > In article , Markus Stenberg > > wrote: > > > One order of magnitude optimization gain was received by writing > > > a specialized regexp optimization tool - as the regexps are mostly > > > of type > > > ^commonstringuniquetail > > > ^commonstringanothertail > > Depending on how many different extensions there are to commonstring, > > you might do better with the regexp: > > Regrettably, there's N different extensions. > > > ^commonstring(.*) > > > > and then matching the saved pattern (.*) against a dictionary of > > possible extensions. > > Basically, the common start is usually date, and the non-common parts are, > depending on log type, for example service name and message string > (syslog). Generally, the service+message combination is the interesting > part, but to prevent false matches, their location on the line must be > verified to be just after the date in the beginning on the line. > > Admittedly, I _think_ it might be somewhat faster (but not much) to do > date-part-checking in C and then just use regexps to parse the tail, but I > doubt I could gain order of magnitude in speed from that. > > > --Pat > > -Markus > > -- > "He who fights with monsters should look to it that he himself does > not become a monster. And when you gaze long into an abyss the abyss > also gazes into you." > - Friedrich Nietzsche, _Beyond Good and Evil_ From drek at MonsterByMistake.Com Sun Dec 19 19:17:28 1999 From: drek at MonsterByMistake.Com (Agent Drek) Date: Sun, 19 Dec 1999 13:17:28 -0500 (EST) Subject: bind In-Reply-To: <945616037.1224942994@news.demon.co.uk> Message-ID: Hey there... I want to have a bunch of Checkbuttons that are bound to alt-rightclick... I can't figure out the syntax to do a multiple bind thanks for any pointers you can give me. I've got this far with the newsgroup archives and the doc's: #!/usr/bin/env python from Tkinter import * root = Tk() def callback(event): event.widget.toggle() frame = Checkbutton(root, state='disabled') # XXX put Alt-Button-3 here somehow... frame.bind("", callback) frame.pack() root.mainloop() From donn at u.washington.edu Thu Dec 30 18:18:58 1999 From: donn at u.washington.edu (Donn Cave) Date: 30 Dec 1999 17:18:58 GMT Subject: complex FETCH using IMAPLIB References: <84f55u$95e$1@snipp.uninett.no> Message-ID: <84g462$1aj4$1@nntp6.u.washington.edu> Quoth "Asle Pedersen" : | Are anyone familiar with the imaplib.py?? I manage to get all the simple | functions working but I'm bit unsure of the syntax with more complicated | commands. I have the book Programming Internet Email where there is a FETCH | command that looks like: | DF56 FETCH 1:3 (RFC822.SIZE BODY[HEADER.FIELDS (FROM SUBJECT)]). | This is supposed to work from a telnet session to a mailserver, but how will | I do this with the IMAPLIB?? | There is no problems with commands like: | typ, data = M.FETCH(1, 'BODY') In my mailer I get headers like this: ok, stuff = service.fetch('%d:%d' % (first, last), '(FLAGS RFC822.HEADER)') and I haven't tried it, but I reckon you could substitute '(RFC822.SIZE ...)' for my '(FLAGS ...)'. I have been meaning to look into some smarter header fetch myself, since the full headers can be awful slow to download. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From mlh at vier.idi.ntnu.no Thu Dec 30 23:59:15 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 30 Dec 1999 23:59:15 +0100 Subject: Regex problem with JPython 1.1b4 and Java 1.2.1 Message-ID: Hi! I am trying to use the lates version of JNumPy, and to do that, I had to use java 1.2 (in my case, 1.2.1 for solaris). With that, I suddenly had a problem pre-compiling the pylib.jar archive. After trying to run some of the statements in the file it stopped at (pyclbr.py) I found this to be the culprit: is_from = re.compile('^from[ \t]+(?P'+id+'([ \t]*\\.[ \t]*'+id+')*)[ \t] +import[ \t]+(?P[^#;]+)') JPython just hangs when I try to run it - I guess it might have to do with the ORO package which was probably not made for 1.2. (I have seen 1.2 crash or hang with lots of old java code - for instance the GUI installator for JPython...) When I removed the newline, it seemed to work. Hm - no, er... That was from my CPython libs (1.5.2) - I only have pylib152d.jar... Oh, well - the point is the same, I guess. The first regex there is still a multiline string, (just much bigger) and it still makes JPython hang. And there was no problem when I used Java 1.1.7B. So - my (preliminary) bug report or request for help or something concludes with that multiline regexps (or something like that) don't work with the following (no wonder with the single-quoted one, of course, but - I should have gotten an exception or something): Java: Solaris VM (build Solaris_JDK_1.2.1_03, native threads, sunwjit) JPython: JPython 1.1beta4 on java1.2.1 (JIT: sunwjit) My guess is that the OROMatcher somehow contains obsolete code. Does anyone know anything about this? (I See they have PerlTools 1.2 out, specifically supporting Java 1.2... Maybe I'll try that...) -- Magnus Lie Hetland From smata1de at gmx.de Thu Dec 23 12:07:03 1999 From: smata1de at gmx.de (stephane) Date: Thu, 23 Dec 1999 12:07:03 +0100 Subject: Next Version 1.6 or 2.0 Message-ID: <38620257.6DD1B4@gmx.de> hi to all, I have only one little question: -will the next Python version be 1.6 or 2.0?? -at what time will it appear thanks & bye Stephane From Alex.Martelli at think3.com Mon Dec 27 16:23:45 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Mon, 27 Dec 1999 16:23:45 +0100 Subject: Xitami CGI scripts & shebang (was RE: How do I make a Python .bat executable file?) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D87@pces.cadlab.it> Gordon McMillan writes: > shebang does nothing on WIndows. > ...except (just a nit, but...) if you're using Xitami, a little, wonderful HTTP server (which I'm currently using to test my Python CGI scripts), in which case shebang is absolutely crucial (each Python script you're using as a CGI script must start with "#!d:/python/pythonw.exe -u", or wherever else it is that you've stashed pythonw.exe). Beats registry hacking, & other ways to 'register' kinds of CGI scripts, IMHO (at least for such simple tests). Alex From spnee228 at my-deja.com Mon Dec 27 04:30:14 1999 From: spnee228 at my-deja.com (spnee228 at my-deja.com) Date: Mon, 27 Dec 1999 03:30:14 GMT Subject: Tcl/Tk and Animated Gif Message-ID: <846m6p$cv2$1@nnrp1.deja.com> How can I embed more than two animated gif in a Tcl/Tk program? The problem is, it can only show one animated gif. Sent via Deja.com http://www.deja.com/ Before you buy. From dworkin at ccs.neu.edu Thu Dec 9 16:50:10 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 09 Dec 1999 10:50:10 -0500 Subject: Numeric Conversion References: <384F6823.E66085F1@cc.huji.ac.il> Message-ID: Iddo Friedberg writes: > My problem: I have text files with fields which are either numeric, or > not. I'd like to convert the numeric ones into numerical values, while > keeping the rest as strings. I initially did that by trapping the > exceptions that atoi() & atol() generate upon hitting a non-numeric > string, but atoi('+') does not generate an exception. > > Anything I can do about it? I managed to solve the problem with regexp > matching: > > >>> > myfloat=re.compile('^[+-]{0,1}\d+\.\d*$|^[+-]{0,1}\d*\.\d*[Ee][+-]*\d+$|^[+-]{0,1}\.\d+$') > > Is there a more elegant solution? (regexpwise or otherwise, I admit I'm > not a very sophisticated user of regexps, AAMOF, I'm PERL illiterate). Pretty much anything other than regexps would be more elegant. ;-) I would use int() (and/or float(), if appropriate) and trap the exceptions, much as you were using string.atoi(). Hm. Actually, now that I test it, string.atoi() does seem to correctly throw exceptions on '+' and '-' in my setup. (1.5.2) This appears to have changed sometime between 1.4 and 1.5.2. -Justin From patdut01 at club-internet.fr Sun Dec 12 23:58:33 1999 From: patdut01 at club-internet.fr (patrick dutoit) Date: Sun, 12 Dec 1999 23:58:33 +0100 Subject: hierboxes with python Message-ID: <38542899.EDFB1664@club-internet.fr> Hi Does anyone knows if it exists an implementation of the hierboxes in python with Tkinter Pmw or something else ? Thanks From jkraai at murl.com Fri Dec 3 17:34:31 1999 From: jkraai at murl.com (jim kraai) Date: Fri, 03 Dec 1999 10:34:31 -0600 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <825nbt$p50@mail.psy.uva.nl> <19991202203008.A7698@stopcontact.palga.uucp> Message-ID: <3847F117.3E2D1545@murl.com> Gerrit Holl wrote: > > Ionel Simionescu wrote: > > > > Guido van Rossum wrote in message > > news:199912020003.TAA13009 at eric.cnri.reston.va.us... > > > > [... Guido invites us to the Python conference ...] > > > > Just an idea - > > > > I cannot attend, because of the distance and the lack of travel funds. > > True. Not very few people in here are Dutch (hint, hint ;-). Only some people > in the USA can go to those conferences. > > > But I would like to. > > Me too. > > I'll set up a small page to see how many people would join a Dutch > Python users group. Just like the Amsterdam Perl Mongers site, but Python > instead. Hosting won't be a problem for me, I'm lucky I found such a kind > sysadmin as I have now... To add nothing of value to this discussion: Hey, I'm Dutch, can I join? I'm afraid that > I cannot attend, because of the distance and the lack of travel funds. but it'd sure be fun to tell people that I am a member of the Holland Pythoneers. stranded-in-iowa'ly yours --jim kraai From prestonlanders at my-deja.com Mon Dec 20 23:38:50 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Mon, 20 Dec 1999 22:38:50 GMT Subject: Is there an easy way to do it again? References: <83jvjd$k0r$1@news05.btx.dtag.de> Message-ID: <83mb5q$k70$1@nnrp1.deja.com> Put the task into a function, then do something like this: while 1: do_menial_task() answer = raw_input("Run task again? y or n > ") if answer in ["n", "no", "N", "quit"]: break In article <83jvjd$k0r$1 at news05.btx.dtag.de>, "Eide" wrote: > I wrote a simple program to do a menial task and it works just fine, but > I'm wondering what the best way is to ask the user to run it again. Do I > set the whole thing in a while loop, or call the prog as a function, or > what? > > Thanks for helping a newbie. > > -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From reic0024 at ub.d.umn.edu Mon Dec 20 03:28:28 1999 From: reic0024 at ub.d.umn.edu (Aaron J Reichow) Date: Sun, 19 Dec 1999 20:28:28 -0600 Subject: Any Python/GUI options for OPENSTEP/Rhapsody? Message-ID: Good day- Are there any Python modules which would allow one to develop GUIs for OPENSTEP, Rhapsody, or possibly Mac OS X? I would prefer something cross-platform (tkinter, wxPython), but would use most anything. Thanks in advance! Aaron From fredrik at pythonware.com Mon Dec 13 11:24:55 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 13 Dec 1999 11:24:55 +0100 Subject: Fun with Tkinter & DISLIN? References: <83148e$fml$1@news.ycc.yale.edu> Message-ID: <012d01bf4554$4d8bcc00$f29b12c2@secret.pythonware.com> Paul M wrote: > The second version using Tkinter draws the plot correctly, but > immediately redraws over it with the standard grey window. If I > resize the window I see that the plot is being redrawn at a new size > but then immediately gets written over again. > > Can anyone point me in the right direction? change "Canvas" to "Frame", and set the background colour to an empty string (this prevents Tkinter from drawing its own contents into the widget). > from Tkinter import * > from pxDplot import * > > x = [61, 37, 65, 69, 54, 93, 87, 89, 100, 90, 97] > y = [14, 17, 24, 25, 27, 33, 34, 37, 40, 41, 42] > > class Demo(Canvas): class Demo(Frame): > def __init__(self, master): umm. python doesn't call base-class constructors by itself, so I'm not sure how this could work at all. anyway, to fix this, change this line: > self.master = master to: Frame.__init__(self, master, bg="") > self.scatter = dScatter(x,y) > self.scatter.external_ID = self.master.winfo_id() > self.scatter.draw() > self.master.bind('', self.reconfigure) > > def reconfigure(self, event): > self.scatter.draw() > > def main(): > root = Tk() > demo = Demo(root) > root.protocol('WM_DELETE_WINDOW', root.quit) make that "root.destroy", not "root.quit". not that it matters much in this little program... > root.mainloop() > > if __name__ == '__main__': > main() hope this helps! From akuchlin at mems-exchange.org Tue Dec 28 21:41:34 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 28 Dec 1999 15:41:34 -0500 Subject: Problem with open() References: <84b5b0$ebp$1@nnrp1.deja.com> Message-ID: <3dzouuer29.fsf@amarok.cnri.reston.va.us> ckrohn at my-deja.com writes: > modem = open('/dev/ttyS1', 'w+') > print "Modem opened!" I'd be really suspicious of using Python file objects to control a serial port connection, because they're built on top of the C library's FILE objects, which perform I/O buffering. Try disabling the buffering with open('/dev/ttyS1', 'w+', 0), or try the following class (hard-wired to 9600 baud, 8N1). Sample code would look something like this: p = SerialPort('/dev/ttyS1') p.write('ATDT 5554543\n') while 1: c = p.read(1) print repr(c), if c == '\n': break p.close() -- A.M. Kuchling http://starship.python.net/crew/amk/ The world is governed more by appearances than realities, so that it is fully as necessary to seem to know something as to know it. -- Daniel Webster import os, termios import FCNTL, TERMIOS class SerialPort: """Basic serial port class. This simply encapsulates a file descriptor for the desired serial port. """ def __init__(self, dev): fd = self.fd = os.open(dev, FCNTL.O_RDWR) # Save the current state of the serial port self.original_state = termios.tcgetattr(fd) # Set connection parameters to 9600 baud, 8N1, two stop bits L = termios.tcgetattr(fd) iflag, oflag, cflag, lflag, ispeed, ospeed, chars = L ispeed = ospeed = TERMIOS.B9600 cflag = (cflag & ~TERMIOS.CSIZE) | TERMIOS.CS8 | TERMIOS.CSTOPB cflag = (cflag | TERMIOS.CLOCAL | TERMIOS.CREAD) & ~TERMIOS.CRTSCTS iflag = TERMIOS.IGNBRK lflag = 0 oflag = 0 chars[ TERMIOS.VMIN ] = 1 chars[ TERMIOS.VTIME ] = 5 iflag = iflag & ~(TERMIOS.IXON | TERMIOS.IXOFF | TERMIOS.IXANY) cflag = cflag & ~(TERMIOS.PARENB | TERMIOS.PARODD) L = [iflag, oflag, cflag, lflag, ispeed, ospeed, chars] termios.tcsetattr(fd, TERMIOS.TCSANOW, L) def write(self, string): "Write a string to the port" os.write(self.fd, string) def read(self, N=1): "Read a string from the port" return os.read(self.fd, N) def close(self): "Restore the port to its starting state and close the file descriptor." termios.tcsetattr(self.fd, TERMIOS.TCSANOW, self.original_state) if self.fd is None: return os.close( self.fd ) self.fd = None From xeno at bigger.aa.net Wed Dec 22 05:32:10 1999 From: xeno at bigger.aa.net (Xeno Campanoli) Date: 21 Dec 1999 20:32:10 -0800 Subject: Order of keyword arguments References: <1268910662-35645762@hypernet.com> Message-ID: <3860544a$1_1@huge.aa.net> Gordon McMillan wrote: : Andres Corrada wrote: : Well I'm feeling amiably disagreeable too, so I'll differ with that. : A "dictionary" in the wider-than-Python sense has an ordering : to it that is based on it's keys. The order of arguments to a : function is _not_ an ordering based on the argument names; : ergo, the existence of an American Heritage Dictionary gets : you no closer to your goal (in this sense, at least). What : you're apparently arguing for is an ordered dictionary. What : you _want_ is an indexed list. Um, why not make a simple python class that implements methods for an ordered dictionary. You just define the definitions in the object, and define any of various sorting methods, and access methods. This is easy enough that I'm not sure it would be necessary to have it a hard coded part of the language. Sincerely, Xeno Python novice and desperate emigre from Perl. -- Xeno Campanoli All I want for Christmas is some contract Linux/Python/Zope contract work Email: xeno at aa.net (Web pages: http://www.aa.net/~xeno) From gerrit.holl at pobox.com Sat Dec 4 23:14:39 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 4 Dec 1999 23:14:39 +0100 Subject: Annoying error message Message-ID: <19991204231439.A1477@stopcontact.palga.uucp> Hello, if one uses a dict that spans multiple lines, the error message produced can be very annoying: 23:11:20:5/505:gerrit at stopcontact:~$ python /tmp/a.py Traceback (innermost last): File "/tmp/a.py", line 3, in ? d = {'a': 1, NameError: c 23:11:27:7/507:gerrit at stopcontact:~$ cat /tmp/a.py #!/usr/bin/python d = {'a': 1, 'b': 2, c: 3} IMO, the Python traceback should say this instead: Traceback (innermost last): File "/tmp/a.py", line 5, in ? d = {'a': 1, 'b': 2, c: 3} NameError: c or: File "/tmp/a.py", line 3-5, in ? or: d = {'a': 1, ... # I mean this literally. c: e} because sometime dictionaries span MANY lines. That's much more clear when debugging. Or does that have major disadvantages? regards, Gerrit. -- "The move was on to 'Free the Lizard'" -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates) 11:09pm up 46 min, 8 users, load average: 0.00, 0.00, 0.00 From ivanlan at callware.com Sat Dec 25 16:30:44 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sat, 25 Dec 1999 08:30:44 -0700 Subject: calling functions from Tk References: <842ma7$u2u$1@nnrp1.deja.com> Message-ID: <3864E324.11308615@callware.com> Hi All-- scoobysnax5336 at my-deja.com wrote: > > I'm trying to understand this. I've cleaned it up as much as I can to > illustrate my problem. From my buttons, if I call a function with no > value, it works fine. When I call it with a value, it executes at > runtime but not when the button is pressed. > But that's exactly what you're telling it to do. command=test vs. command=test('blah') The first method tells Button that 'test' is the name of the function to call when the button is pressed. The second method says that the result of running "test('blah') is the function to call when the button is pressed. So, when you create the button, it calls the test() function. Your test() function returns None (all functions without an explicit return value return a None when they finish), so the result that is stored in the command field is a None. Thus, nothing happens when you push the button. There are other ways to specify arguments for callback functions. ... > from Tkinter import * > > def test(stuff='test'): > print stuff > > root = Tk() > > b=Button(root, text="Call test", width=8, command=test) > b.pack(side=LEFT) > > b=Button(root, text="Call test('blah')", width=12, command=test('blah')) > b.pack(side=LEFT) > > b=Button(root, text='Exit', width=6, command=root.quit) > b.pack(side=LEFT) > > root.mainloop() > -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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From m.faassen at vet.uu.nl Tue Dec 14 11:51:48 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 14 Dec 1999 10:51:48 GMT Subject: Suitability of Python for a Big Application? References: <830vic$r2t$1@nnrp1.deja.com> <83125j$5d$1@news1.xs4all.nl> <832f5s$iio$1@newshost.accu.uu.nl> <833hnb$n42$1@news1.xs4all.nl> Message-ID: <8357g4$57q$1@newshost.accu.uu.nl> Boudewijn Rempt wrote: > Martijn Faassen wrote: >> Boudewijn Rempt wrote: >>> I do find Zope a bit slow - even when I browse a Zope database on a >>> machine on my local network. >> I'm not entirely sure what you mean by this; Zope by itself isn't slow. I've >> heard both good and bad performance reports about Zope, but with tuning it >> can certainly be fast enough to handle even the slashdotting of a site. >> [snip rest] > Well, what I meant is that 'standard' interface, with the stuff > at the left side gives the impression of an interface that's as > responsive as, say, Explorer, or Kfm - and since most clicks seem > to load a chunk of html, that's not the case. It's more a matter > of not matching with the expectations generated by the interface. Most clicks do load a chunk of HTML, but on a local network it's plenty fast though. Not as fast as explorer, I'd guess, but close to it (though sometimes on a network one may get glitches and slowdowns, true). It can of course be improved -- there's just a project started adapt Mozilla to be a Zope front end, for these and other reasons. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mal at lemburg.com Thu Dec 9 12:17:03 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Thu, 09 Dec 1999 12:17:03 +0100 Subject: ANN: Python Netzwerk Deutschland Message-ID: <384F8FAF.3A5E3C8D@lemburg.com> I am pleased to announce the: ---------------------- Python Network Germany ---------------------- The Network is a closed mailing list aimed at simplifying contacts between Python/Zope developers and companies seeking Python/Zope skills. The Network does not charge anything for subscription, nor does it get involved in the contract business between the partners. Its only intent is to provide a low bandwidth highly specialized contact platform. The only restriction currently applied is the need to subscribe through a special subscription mailing list which is maintained by volunteers. Subscribers should post a brief description of their background and will then get subscribed to the main list by the administrators where they can then scan the lists archives and post details of their projects and skills. More information (in German) and the links to the subscription address are available at: http://www.python-netzwerk.de/

Python Network Germany - German Business Contact Forum intended to make simplify contacts between developers and company seeking Python skills. (09-Dec-1999) -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 22 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From makarki.NOSPAM at news.hit.fi Thu Dec 9 10:22:51 1999 From: makarki.NOSPAM at news.hit.fi (Matti Johannes Kärki) Date: 9 Dec 1999 09:22:51 GMT Subject: Printing under Win32 Message-ID: <82nsdb$djj$1@news.hit.fi> Hi! Is there any modules for Python to print under Win32 with native Windows functions? Now I'm using HTML-pages and web browser for printing and print preview. I know that there is this this "save as postscript" under TK-library but I'm now looking for some deirect way to manage non-ps-printers under Windows. Thanks in advance, Matti J. K?rki From sendzimir at earthlink.net Tue Dec 28 14:25:39 1999 From: sendzimir at earthlink.net (Alexander Sendzimir) Date: Tue, 28 Dec 1999 13:25:39 GMT Subject: why? References: <386847C5.3CEB812F@earthlink.net> Message-ID: <3868C937.A36FDF7@earthlink.net> Perhaps the best place to start out is looking through the Python third party modules http://www.vex.net/parnassus/ Check out the modules that are available. Likewise, if you have an installation to work with, look through the modules directory. Under Linux, for example, you will find it under /usr/local/lib/python1.5 or /usr/lib/python1.5 (most likely). All you really need to look at are the names of the modules. This will give you some idea what's available. Some modules won't make any sense. Ignore these. You may find out later what they're for. Want to argue about which language to learn? Python or Perl? I say, go for both. They both entail different approaches to similar problems and each is a fine universe in which to romp. It would be more work, of course, however, learning a little of both languages would be worth your while (and the rest of the world as you just might become a more skillful crafter of code.) After some time you might find one language more valuable than the other. In that case, dumb the less useful one. You can always come back to it later. Last, should you ever be walking down a busy city street and come across two guys arguing the merits of python versus perl (or perl vs python), you are in a great situation to smooth the waters. ;-) ekko wrote: > The only language I am familiar with is QBASIC and a little HTML (if that > even is a programming language). From akuchlin at mems-exchange.org Fri Dec 31 00:02:50 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 30 Dec 1999 18:02:50 -0500 Subject: [OT] OpenSource Python Books? References: <84g70v$tcq$1@nnrp1.deja.com> <386BC2A4.628D9C9A@callware.com> Message-ID: <3d7lhwrq05.fsf@amarok.cnri.reston.va.us> Ivan Van Laningham writes: > There are *lots* of holes in the potential Python bookshelf; Tkinter(!) > (but there's at least two coming out soon), XML (there's one coming > there, too), higher math with Python, Astronomy with Python, Python & > Com, and on and on and on. ... Book topics... hmmm. A good JPython book would be great, and would probably increase JPython's visibility in the Java community a lot; a book about Numeric Python would probably have the same effect in the Fortran community. I suspect there's room for several Tkinter books beyond the two upcoming ones, and there's space for GTk and Qt books, too. A cookbook-like volume would be nice; I haven't yet read either Python Annotated Archives or /F's eMatter book, so perhaps that void is already filled. It would also be nice if more books paid attention to the relevant Python modules; for example, the recent books about Qt and GTk+/GNOME have focused almost completely on C-level programming, with only passing mentions of Python bindings; a chapter or appendix on using PyKDE or PyGTK+ would probably be enough to encourage people to try them out. And who's going to write "Python for Dummies"? -- A.M. Kuchling http://starship.python.net/crew/amk/ Where is human nature so weak as in the bookstore? -- Henry Ward Beecher From cesar_da_silva at my-deja.com Fri Dec 10 09:55:30 1999 From: cesar_da_silva at my-deja.com (Cesar da Silva) Date: Fri, 10 Dec 1999 08:55:30 GMT Subject: WWW site headline grabber in Python? Message-ID: <82qf61$h7s$1@nnrp1.deja.com> Hi! Just wondering if there is any available Python source code that grabs the headlines from any web site? If there is, where can I get it? Sent via Deja.com http://www.deja.com/ Before you buy. From ngps at madcap.dyn.ml.org Wed Dec 29 15:52:40 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 29 Dec 99 14:52:40 GMT Subject: Which grid widget? References: <38623573.0@news.cyberway.com.sg> <83tuqo$csb$1@news1.xs4all.nl> Message-ID: <386a2038.0@news.cyberway.com.sg> According to Boudewijn Rempt : > PyKDE and PyQt are also very actively developed, and nowadays, with > version 0.10 *), PyQt also works with the Windows version of Qt: > > http://www.river-bank.demon.co.uk/software/ Thanks for the pointer. One thing puzzles me: 1. You say "PyQt also works with the Windows version of Qt". 2. The above website says Qt 2 is not done yet. 3. Qt's home site says Qt 1 is X11 only. > I've taken a look myself, but wxWindows doesn't offer a fully editable, > spreadsheet-like grid either, I have just installed the latest wxPython Windoze installer. It comes with a grid widget. Haven't exercised it much, yet. Also, PyGTK has a grid widget, as well, and wxPython on Unix builds with PyGTK. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From mgm at unpkhswm04.bscc.bls.com Mon Dec 13 14:25:38 1999 From: mgm at unpkhswm04.bscc.bls.com (Mitchell Morris) Date: 13 Dec 1999 13:25:38 GMT Subject: Old-timer UN*X trivia [was Re: Error confusing a newbie] References: <19991210100320.B18389@dmcom.net> <19991211161917.C27756@dmcom.net> Message-ID: In article , Keith Dart wrote: [snip] >In Linux, it runs with a shell! It seems Linux defaults to /bin/sh if an >executable text file is executed even without a #! as the "magic" number. >I'm not sure if this is a bug or a feature... As a completely off-topic aside, when did the magic number cease being "#! /" and turn into just "#!"? I still edit every script I see that's missing the space between the sh-bang and the full path, 'cause that's how I learned it all those many years ago. I will admit to having formed many of my UN*X habits years ago on a (then smokin' fast) AT&T 3B2, and haven't bothered to optimize all of them. +Mitchell -- Mitchell Morris Wait... someone once manufactured a TV that didn't have a remote control? Then what do you sit on when you need to accidentally start recording something? -- Kibo From Gaetan_Corneau at baan.com Fri Dec 17 17:09:09 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Fri, 17 Dec 1999 11:09:09 -0500 Subject: NT Desktop question Message-ID: <816010E2456BD111A48700805FBBE2EEFDF926@ex-quebec-u1.baan.com> Thanks Gordon, that will do the trick! ______________________________________________________ Gaetan Corneau Software Developer Software Engineering Process Group BaaN Supply Chain Solutions http://www.baan.com E-mail: Gaetan_Corneau at baan.com Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" > What works today is: > create a bat file: > python.exe d:\path\to\myscript.py "%1" From a.eyre at optichrome.com Fri Dec 17 13:37:21 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 17 Dec 1999 12:37:21 -0000 Subject: LISTS: Extract every other element In-Reply-To: <19991216131341.A153923@vislab.epa.gov> Message-ID: <003801bf488b$76a48250$3acbd9c2@peridot.optichrome.com> > and build a list with every other element: > > [ 1,3,5,7,... ] No idea how efficient these are: >>> l = ['a', 'b', 'c', 'd'] >>> map(lambda x: l[x], range(0, len(l), 2)) ['a', 'c'] or >>> map(lambda x: l[x*2], range(len(l)/2)) ['a', 'c'] -------------------------------------------- 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 rob at hooft.net Tue Dec 7 14:08:59 1999 From: rob at hooft.net (Rob W. W. Hooft) Date: 07 Dec 1999 14:08:59 +0100 Subject: A Date With Tim Peters... References: <001801bf4073$033e6260$88a0143f@tim> Message-ID: >>>>> "TP" == Tim Peters writes: >>>>> [Tres Seaver] >> Heh, I recall fondly one machine where +0 and -0 were different, >> so why not? >> >> (A Cyber mainframe, ones-complement, if the faded label on the >> card deck box isn't fooling me :) TP>>> import math TP>>> zero = 0.0 TP>>> math.atan2(zero, zero) TP> 0.0 TP>>> zero = -zero TP>>> math.atan2(zero, zero) TP> -3.14159265359 TP> That is, IEEE-754 mandates signed zeroes too, in part so that an TP> underflow "remembers which direction it came from". Python 1.5.2b1 (#4, Jan 14 1999, 12:05:48) [GCC egcs-2.90.21 971202 (egc on irix5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import math >>> zero=0.0 >>> math.atan2(zero,zero) Traceback (innermost last): File "", line 1, in ? ValueError: math domain error >>> no11[101]nonius% uname -a IRIX no11 5.3 02091401 IP22 mips So it is not portable..... IIRC, on a VAX Using -0.0 would result in an "operand reserved to digital" fault. 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 darcy at vex.net Wed Dec 8 11:56:34 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 8 Dec 1999 10:56:34 GMT Subject: "%(a)s ... %(b)s" % {'a': foo, 'b': '%(b)s'} References: <19991204161814.A5289@stopcontact.palga.uucp> Message-ID: <82ldh2$1e47$1@hub.org> Gerrit Holl wrote: > MAIL = '''From: someone <%(email)s> > Subject: test > this is feedback.py %(version) > ''' % {'version': __version__} > This raises a KeyError. I have to type: > ... % {'version': __version__, 'email': '%(email)s'} > This is ugly! Isn't there a better way to fill in just SOME of the %(...)s > values in a string and leave the rest as is? You mean like this? MAIL = '''From: someone <%%(email)s> Subject: test this is feedback.py %(version) ''' % {'version': __version__} -- D'Arcy J.M. Cain | Democracy is three wolves http://www.vex.net/ | and a sheep voting on +1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner. From mlh at vier.idi.ntnu.no Tue Dec 21 18:38:26 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 21 Dec 1999 18:38:26 +0100 Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <83lnq7$c9d$1@news1.tele.dk> <385EFB90.4EFC4C0F@Lugoj.Com> Message-ID: James Logajan writes: > I think you spelled "idiotic" incorrectly. (Sorry, cheap shot.) More like "lame shot" ;) > I don't have a dictionary in front of me, but I'm pretty sure that > by definition an idiom can not be unilaterally declared. I never claimed it could. It is not something I invented myself. I was actually referring to the use of short-circuit logic operators for implementing conditional expressions in general. As far as I have been able to gather in the last couple of years it is idiomatic. Feel free to disagree, or to dislike it. -- Magnus Lie Hetland From gmcm at hypernet.com Thu Dec 9 17:54:57 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 9 Dec 1999 11:54:57 -0500 Subject: Packaging packages? In-Reply-To: Message-ID: <1267364603-37615442@hypernet.com> Jeffrey Kunce writes: > Is there a way to collect all the python modules in a package > into one file? > > I've been a big fan of Fredrik's "Squeeze" and Gordon's "Win32 > Installer", but as far as I know, they pakage an entire > application into one file. Look more closely. Just create a config file with a PYZ section pointing to your package. Run Builder.py on it. Make sure imputil.py and archive_rt.py are available outside the archive. Then the magic incantation: imputil.FuncImporter( archive_rt.ZlibArchive("mypyz.pyz",0).get_code).install() will make everything in your package available to normal "import" statements. - Gordon From garyseven at earthlink.net Tue Dec 28 01:07:56 1999 From: garyseven at earthlink.net (Gary Bankston) Date: Tue, 28 Dec 1999 00:07:56 +0000 Subject: need help getting tk to work with python Message-ID: <3867FF5C.F56F4341@earthlink.net> I had python and tcl working about 6 months ago but haven't used it in a while. I recently tried to pick up where I left off and downloaded the latest python for windows (py152.exe) and installed it. I let it install tcl-tk as well. For some reason tcl (or more precisely tkinter) does not work now. when I attempt to run hello1.py from the introduction to Tkinter I get the following: #----------------------------------------------------------- >hello1.py Traceback (innermost last): File "D:\PROGRA~1\Python\Doc\Tkinter\Library\Tk-intro\INTROD~1\hello1.py", line 13, in ? root = Tk() File "D:\Program Files\Python\Lib\lib-tk\Tkinter.py", line 886, in __init__ self.tk = _tkinter.create(screenName, baseName, className) TclError: Can't find a usable init.tcl in the following directories: {} ./lib/tcl8.0 {D:/Program Files/Python/Doc/Tkinter/Library/tcl8.0/library} {D:/Program Files/Python/Doc/Tkinter/Library/Tk-intro/library} This probably means that Tcl wasn't installed properly. #----------------------------------------------------------- I have no idea what the problem could be here. Any help anyone can provide will really be appreciated. Here is some additional information. python is installed at d:\Program Files\Python tcl is installed at d:\Program Files\Tcl The widget tour included with tcl works fine. I'm running Windows NT v4.0 w/ service pack 5 -- __^__ /_______\ glary \_______/ sandstorm /|\ From cgw at fnal.gov Tue Dec 21 18:53:27 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Tue, 21 Dec 1999 11:53:27 -0600 (CST) Subject: Equivalent to (a ? b : c) ? In-Reply-To: References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <83lnq7$c9d$1@news1.tele.dk> <385EFB90.4EFC4C0F@Lugoj.Com> Message-ID: <14431.48791.513755.655775@buffalo.fnal.gov> How about this variation? eval({1:"a_expr(args)", 0:"b_expr(args)"}[not not c]) (Posted for entertainment value only, I've never actually used anything like this in real code) From neelk at brick.cswv.com Sun Dec 12 23:06:50 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 12 Dec 1999 22:06:50 GMT Subject: Unreal Tournament>>To Use Python?! References: <384808f3.3299668@news.telus.net> <82cp29$lmr$1@ssauraaa-i-1.production.compuserve.com> <384AC05A.9A69DBD2@mindspring.com> <38540790.98868144@maxtal.com.au> Message-ID: skaller wrote: > >The theory is called 'category theory', and it is the central >theory of modern mathematics (obsoleting set theory). >There are programming languages based on it, or at least >influenced by it, and almost all modern language design >is discussed using its terminology. The module system >of Standard ML has been based on it for a number of years, >and computing engines using categorical combinators and >other technhiques are beginning to dominate new language >designs, especially in the functional area. IIUC[*], category theory is seeing some heavy use in the formal semantics of OO languages, as well, because OO type theory slams headfirst into one of the many variations of Russel's paradox if you try to use a set-theoretic-inspired notion of subtype. Personally, I think the *MLs haven't taken off because they are all astonishingly ugly to look at. The semantics are beautiful; but the code is just really disgusting to look at, imo. ML makes Lisp look transparent and readable -- and Lisp is a language whose syntax was designed for the convenience of the macro system rather than human factors. Neel [*] If I Understand Correctly -- which I may very well not! I am definitely not an expert (or anything more than an interested amateur) in either category or type theory. From garry at sage.att.com Wed Dec 15 17:09:22 1999 From: garry at sage.att.com (Garrett G. Hodgson) Date: Wed, 15 Dec 1999 16:09:22 GMT Subject: pytags ????? References: Message-ID: <3857BD32.A5A53203@sage.att.com> Keith Dart wrote: > > Is anyone aware of a program that generates ctags-like tags file, except > for Python code? I guess it would be named something like pytags (ptags is > already taken by perl-tags and prolog-tags). I can't seem to find one. look in your python distribution, at Tools/scripts/ptags.py -- Garry Hodgson "Hey, mister, can ya tell me, garry at sage.att.com where a man might find a bed?" Software Innovation Services He just grinned and shook my hand, AT&T Labs "No", was all he said. From gang.li at compuware.com Thu Dec 2 20:27:57 1999 From: gang.li at compuware.com (Gang Li) Date: Thu, 2 Dec 1999 12:27:57 -0700 Subject: use Userdict for class __dict__ References: <1268037651-41672093@hypernet.com> Message-ID: <3846b6aa@199.186.16.51> The proxy only works with instance. I want something working with class, and the class subclass it will inherent the same properties. "Gordon McMillan" wrote in message news:1268037651-41672093 at hypernet.com... > Gang Li writes: > > > In order to monitor access of class attributes, I tried to > > replace class __dict__ with UserDict. > > > > class Foo: pass > > > > class MyUserDict(UserDict.UserDict): > > def __getitem__(self, name): > > ...... > > > > Foo.__dict__ = MyUserDict(Foo.__dict__) > > > > But python bit me with: > > TypeError: __dict__ must be a dictionary object > > > > How can I avoid this kind error. > > Wrap your object in a proxy: > > class Proxy: > def __init__(self, obj=None): > self.__obj__ = obj > def __getattr__(self,name): > print "getattr called for", name > return getattr(self.__obj__, name) > def __repr__(self): > return "Proxy for "+`self.__obj__` > __str__ = __repr__ > > > - Gordon > > From wtopa at dmcom.net Sat Dec 11 03:18:02 1999 From: wtopa at dmcom.net (Wayne Topa) Date: Fri, 10 Dec 1999 21:18:02 -0500 Subject: Error confusing a newbie In-Reply-To: <008e01bf4321$d3705780$f29b12c2@secret.pythonware.com>; from Fredrik Lundh on Fri, Dec 10, 1999 at 04:18:33PM +0100 References: <19991210100320.B18389@dmcom.net> <008e01bf4321$d3705780$f29b12c2@secret.pythonware.com> Message-ID: <19991210211802.C17533@dmcom.net> Subject: Re: Error confusing a newbie Date: Fri, Dec 10, 1999 at 04:18:33PM +0100 In reply to:Fredrik Lundh Quoting Fredrik Lundh(fredrik at pythonware.com): >| Wayne Topa wrote: >| > The problem is that when run with #> python net_time.py it works >| > and does what I want. But - see below. >| >| what happens if you run: >| >| $ /usr/bin/env python >| >| VT2 root-Deb-Slink:~# /usr/bin/env python Python 1.5.2 (#0, Jul 16 1999, 19:48:11) [GCC egcs-2.91.60 Debian 2.1 (egcs-1.1.1 release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> Which is what I believe it should be. Thanks Wayne -- Windows is a multi-tasking OS: Do one task, reboot, do another task, reboot... _______________________________________________________ From reic0024 at ub.d.umn.edu Wed Dec 8 07:03:26 1999 From: reic0024 at ub.d.umn.edu (Aaron J Reichow) Date: Wed, 8 Dec 1999 00:03:26 -0600 Subject: mod_python.o binaries for RH linux 6.0? Message-ID: I know I'm probably a big wuss for this, but does anyone have a binary of mod_python.o for Apache 1.3.6 and RH 6.0/i386? Aaron From sendzimir at earthlink.net Tue Dec 28 14:32:44 1999 From: sendzimir at earthlink.net (Alexander Sendzimir) Date: Tue, 28 Dec 1999 13:32:44 GMT Subject: Mailboxes References: <19991228200432.A2164@dark.net> Message-ID: <3868CAE1.312E8AA8@earthlink.net> Funny you should ask. I was just going through it myself. Look at the _test() function at the bottom of the mailbox module. There is no documentation on it that I can find. Are you using a unix-based system? If so, you can use either of the following approaches to _test() the module. APPROACH #1 (csh/tcsh) setenv MAILDIR /my/home/directory/mailfolder/mailboxfile /biff/bang/boom/python1.5/mailbox.py APPROACH #2 /biff/bang/boom/python1.5/mailbox.py /my/home/directory/mailfolder/mailboxfile Both #1 and #2 should spill the guts of your mailboxfile. abs From kbaldermann at entire-systems.com Fri Dec 3 16:28:10 1999 From: kbaldermann at entire-systems.com (Klaus Baldermann) Date: Fri, 3 Dec 1999 16:28:10 +0100 Subject: Email address check function References: <19991202163334.A3934@stopcontact.palga.uucp> <3846C48A.F793423A@inka.de> <828ega$2a8$1@nnrp1.deja.com> Message-ID: <3847e186@194.120.211.23> Georg Mischler wrote in message <828ega$2a8$1 at nnrp1.deja.com>... >- The last (toplevel) "name" must be two or three characters long. it is planned for this to change (.firm, .info, ...) >- Every "name" must start with one of [a-z]. e.g. a domain "3com.com" _does_ exist... Sorry for nitpicking, that's just a habit of mine :-) Klaus From cjw at connection.com Tue Dec 28 22:49:22 1999 From: cjw at connection.com (Colin J. Williams) Date: Tue, 28 Dec 1999 16:49:22 -0500 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> Message-ID: <38693062.E31E65E@connection.com> Paul Prescod wrote: > I propose that in Python 1.6 tuples be given the demonstrated features: > > >>> time = (hour=24, minute=00, second=00 ) > > >>> print time.hour > 24 > > >>> hr, min, sec = time > >>> print hr, min, sec > (24, 00, 00 ) > >>> min, sec, hr = time > >>> print min, sec, hr > (24, 00, 00 ) > > (this last just demonstrates that tuples continue to work the way they > always have. There is no magic about looking at the names of > assignments) This seems to be the PL1/Pascal record idea. I like it. Could one use this in a multi-level manner? eg. >>> transaction= (addressee= 'bloggs at dot.com', contentType= 'HTML', ... dispatchedAt= time) # time as defined above >>> print transaction.dispatchedAt.hour 24 > > > This proposal has the following benefits: > > * it makes a nice syntax for a 1-item tuple :) > * it makes a nice syntax for non pre-declared struct-like things > * it aligns better with the mathematical notion of tuple > * the element referencing syntax is much clearer > * names are easier to remember and less error prone than indexes. > * it is still easy to rip them apart > > This proposal may lead some to consider the unification of tuples and > object instances, which is also a discussion worth having. > > OpiniX-Mozilla-Status: 0009ould apply a patch to this effect? > > Paul Prescod Colin W. From aa126 at DELETE.fan.nb.ca Wed Dec 8 18:52:32 1999 From: aa126 at DELETE.fan.nb.ca (William Burrow) Date: 8 Dec 1999 17:52:32 GMT Subject: Python and ASP References: <_ji34.8719$523.343739@news.chello.at> Message-ID: On Wed, 08 Dec 1999 03:51:35 GMT, Mark Hammond wrote: >Yes - the latest versions of IIS retain all whitespace in a script block >(ie, it was an IIS bug, not a Python bug) Let me get this straight, you can do ASP in Python? Is there any place with details? Is VB involved in any way, shape, manner or form (ie. is it possible in some way to develop Python programs on a Unix box and install them on an IIS site with little or no modifications?) A copy to email would be nice as well, but remove the anti-spam first. -- William Burrow -- New Brunswick, Canada o Copyright 1999 William Burrow ~ /\ ~ ()>() From aj10 at my-deja.com Wed Dec 1 00:19:58 1999 From: aj10 at my-deja.com (aj10 at my-deja.com) Date: Tue, 30 Nov 1999 23:19:58 GMT Subject: XPython (X11) References: <383E5350.1E07536A@xrce.xerox.com> Message-ID: <821m2h$7ne$1@nnrp1.deja.com> In article <383E5350.1E07536A at xrce.xerox.com>, Emmanuel Pietriga wrote: > Is anyone using XPython around here? > > I need help, or at least links to examples (I haven't found any but the > ones within the package) > > Thanks. > Emmanuel > > Python over Tcl/Tk - which runs over XWindows - is well supported and you will find lots of good examples, experience and support. Also this way you would make your app more reusable. So why do you want XPython ? Graphics performance is critical or something? Just curious. Thanks aj Sent via Deja.com http://www.deja.com/ Before you buy. From tbradshaw at orchestream.com Thu Dec 9 20:56:10 1999 From: tbradshaw at orchestream.com (Tobe Bradshaw) Date: Thu, 09 Dec 1999 19:56:10 +0000 Subject: Tk stuff... Message-ID: <3850095A.9935920D@orchestream.com> Folks, I'm an intermediate Python user starting to get to grips with Tkinter.. and I could do with some help here.. Hopefully if I just state the basic problem you'll not laugh too much at me... I want to write a one window application which contains just a canvas. Unfortunately I've fallen at the first hurdle 'cause I can't figure out how you'd make it so that resizing the main window will cause the canvas to be appropriately resized. Currently I've got a callback on which simply calls .pack() on the canvas.. this obviously doesn't work. So.. bearing in mind that I know absolutely nothing about tcl (he says, glaring at Ousterhout.. much use *that* is to me).. but a lot about Java (I notice at least a few common concepts in Tk, or do I misunderstand?) and GUIs in general.. can anyone give me a good overview of how you'd go about common GUI tasks using Tkinter/show me a good place to look for such info/come and write my code for me (delete as applicable)... (And sorry to be a pain, but could I request you cc: my inbox, I am fighting with our Tech. dept. to fix their ***ing newsfeed). Thanks, -- Toby Bradshaw 'It's probably not my fault' -- Software Engineer, Orchestream, Glen House, 125, Old Brompton Road, London SW7 3RP. -- Tel +44 (0) 171 598 7553 From nemeth at iqsoft.hu Tue Dec 28 22:53:57 1999 From: nemeth at iqsoft.hu (Nemeth Miklos) Date: Tue, 28 Dec 1999 22:53:57 +0100 Subject: Python & Corba Message-ID: <38693175.4F97DBAE@iqsoft.hu> > Corba > Date: > Thu, 23 Dec 1999 08:12:03 +0200 > From: > "jaakovb" > Organization: > NetVision Israel > To: > python-list at python.org > Newsgroups: > comp.lang.python > > > > Hi, > > is anybody know if i can do CORBA call into python script ? > > Do i need to load a C++ module that contains the CORBA access methods ? > > I'm very,very new in python so my question is perhaps stupid and the > response is probably ... simple. > > Thanks for any tips. > > Yaakov > > jaakovb at orckit.com > I evaluated FNORB with my ORBacus/C++ CORBA Server, having a very complex IDL interface, and it worked without a hitch. FNORB is great! NM > > > From ivanlan at callware.com Tue Dec 7 06:34:01 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 06 Dec 1999 22:34:01 -0700 Subject: Very useful message -- Hah! References: <82do53$2rhr$1@hub.org><384A9BE0.B345509@inka.de> <384ABC57.DDC3B61E@inka.de> Message-ID: <384C9C49.37000B13@callware.com> Hi All-- Dan Grassi wrote: > > in article 384ABC57.DDC3B61E at inka.de, Michael Str?der at > michael.stroeder at inka.de wrote on 12/5/99 2:26 PM: > > > OK. Name another programming language which seems more appropriate for > > developing CGI-BINs to you and let's analyze that... > > PHP3 > So use it. And talk about it on the PHP3 list. Bye ---------------------------------------------- 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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From thantos at chancel.org Thu Dec 23 05:47:09 1999 From: thantos at chancel.org (Alexander Williams) Date: Thu, 23 Dec 1999 04:47:09 GMT Subject: playing well with others (newbie question) References: <83rvrl$heu$0@216.39.162.232> Message-ID: On 23 Dec 1999 02:02:29 GMT, Michael Esveldt wrote: >others." Is there some similar command in python? Something to replace >that pass with that allows me to do other things with my system? Well, normally one actually does some useful computation in a while 1: loop, which breaks up the computation into interruptible operations. If you /absolutely/ want a break in there, you need the time module and the sleep function therein: >>> import time >>> while 1: >>> time.sleep(1) >>> pass The above gets you a 1sec break every time through the loop. Adjust to taste. -- Alexander Williams (thantos at gw.total-web.net) | In the End, "Join the secret struggle for the soul of the world." | Oblivion Nobilis, a new Kind of RPG | Always http://www.chancel.org | Wins From mstenber at cc.Helsinki.FI Wed Dec 29 10:30:31 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 29 Dec 1999 11:30:31 +0200 Subject: why? References: <38685b07.189574443@news.isomedia.com> Message-ID: grant at nowhere. (Grant Edwards) writes: > In article <38685b07.189574443 at news.isomedia.com>, Eugene Goodrich wrote: > >On Tue, 28 Dec 1999 03:40:32 GMT, "ekko" wrote: > > > >>I don't know that much about Python and I have some questions. Why would I > >>want to learn Python. What uses does it have? What kind of programs can I > >>make with Python? Thanks. > > > >I think it might be quicker if we answered the inverses of some of > >these questions. For instance, What uses doesn't it have? > OK, I'll start: > > 1) You can't write device drivers in Python (at least not for > any OS of which I am aware). As a matter of fact, given small stub in kernel, it would be entirely possible to do Python-based device drivers in userland. It might not be sensible though, but last summer I wrote a filesystem driver for Linux that way using Python. other comment removed. -Markus -- "On the subject of C program indentation: In My Egotistical Opinion, most people's C programs should be indented six feet downward and covered with dirt." -- Blair P. Houghton From bitbucket at isomedia.com Sat Dec 25 20:49:52 1999 From: bitbucket at isomedia.com (Eugene Goodrich) Date: Sat, 25 Dec 1999 19:49:52 GMT Subject: Python and ASP Observations Message-ID: <38651fc7.144536242@news.isomedia.com> I do a lot of ASP coding, so I'm getting to really hate VBScript for all the features it doesn't have. Since Python is so great (especially compared to VBScript) and I like it so much, an obvious improvement to my obsessive situation is to code ASP in Python instead. Aside from the initial stumbling blocks (1: I spaced on the most likely capitalization of the Request and Response objects; 2: Must use .SetValue on Session / Application objects), things are going well, but there are quirks at every turn. I haven't seen all my questions answered or my observations already observed in the newsgroup. (To be fair, I've only done a bit of DejaNews searching, and I have only recently begun to keep up with the news.) Anyway, working from these assumptions, I figured I'd post some of what I found using Python for ASP in case anyone else would like to go that way. My config: Wint NT 4.0 SP 4 or so (you can't say "no" to SPs forever), IIS 4, Python 1.52, and Win32whatever to match. Simple stuff: * the "5 magic objects" in ASP are all English-capitalized. But you knew that. * to stick stuff into the Session and Application objects, you need to use Session/Application.SetValue (key, value). You also knew that; I read it in this newsgroup. Quirks: * You can store lists in the Session and Application objects, but when you retrieve them, they come back as tuples. * You can't store dictionaries directly in the Session / Application objects. But you can convert them to strings first, and eval them when you retrieve them to inflate them back into dictionaries. * I've read that some people have had trouble putting references to COM objects into the Session / Application objects. (The example I saw used the fileSystemObject, but for me the applicable object would definitely be the ADO Connection object.) Well, if you put the COM object reference in a list, then you can put it into the Session / Application object no problem. When you retrieve your reference, everything appears to work hunky-dory. I've tried it with the Application and Session objects using the ADO Connection and Recordset objects while they were "in operation," and they worked fine. I should point out, however, that I generated my references using ASP's Server.CreateObject (sProdID), not win32com.client.Dispatch (). * You can't store python object instances in the Session / Application objects, not even if they're wrapped in lists. This behavior probably explains the problem with dictionaries, and also probably why lists get converted to tuples, but since I'm not an expert on the internals, I couldn't say for sure. For my ASP style, being able to persist the connection object(s) and a cache of commonly used database tables (e.g. the table where I store all my queries :) is a must. Plus, I like to do my own recordset pooling. For some time I had been disappointed that Python didn't play well enough with ASP to do what I required. So far, though, it looks like it's just going to take doing things a little differently. The benefits of Python over VBScript still vastly outweigh the costs of the tricky bits. -Eugene import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==') From tseaver at starbase.neosoft.com Wed Dec 1 17:56:49 1999 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 1 Dec 1999 16:56:49 GMT Subject: python test frameworks References: <3d903fhhch.fsf@amarok.cnri.reston.va.us> <14405.12387.436432.910120@weyr.cnri.reston.va.us> <_Ob14.44147$oa2.324786@iad-read.news.verio.net> Message-ID: <5A491469A8B9A76F.6C99F8B64A7980FA.6A6B56E1ECAE4466@lp.airnews.net> In article <_Ob14.44147$oa2.324786 at iad-read.news.verio.net>, Tom Culliton wrote: >In article <14405.12387.436432.910120 at weyr.cnri.reston.va.us>, >Fred L. Drake, Jr. wrote: >> Now we just need to draft someone knowledgeable in the area and >>inflict upon him or her the burning itch to write documentation...! > >Sounds like something you'd want to see a doctor about before doing >anything rash... ;-) ;-) ;-) > >Tom (Sure Tim would think of something even wittier to say...) I must say I find your comment the acne of wittiness. :) Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From alex at magenta.com Wed Dec 22 22:16:52 1999 From: alex at magenta.com (Alex Martelli) Date: Wed, 22 Dec 1999 22:16:52 +0100 Subject: Python-powered Win95 Replacement Shell References: <386112d2.34743796@news.telus.net> Message-ID: <009601bf4cc1$e270b6e0$c02b2bc1@martelli> Guppy writes: > http://www.graphite.sh/ > > Haven't used it a bit (I'm stuck on geoShell as a replacement for > Microsoft's nasty Explorer shell). What's "nasty" about Internet Explorer...? You may dislike the way MS top mgmt browbeat all sorts of suppliers into giving IE preference over NN, but, technically speaking, it's _neat_, with full support for W3C DOM, good componentization, etc. Much my favourite way to cook up a UI to any old thing I may be writing, these days -- just some COM (well supported by Python, and decently supported by just about everybody else;-), some DHTML and CSS and A/X etc (well supported by myself with a good text editor such as GVIM, and decently supported by lots of tools;-), and I'm done. And with IE (and the so-called 'active desktop' that lets IE act as my Windows shell), I can easily embed the GUI for my apps right into the desktop if I so wish -- just as I can do for any site I happen to like, etc, etc. > Claims to support Python as the scripting engine. My initial thoughts are Actually, Graphite claims to support 4 active-Scripting engines (VBscript, Jscript, PerlScript, and now, new in the current patch, Python). > this would be boggy-slow, but, hey, maybe there's something that can be > done about that. Why ever should any of these Active-X engines be slow?! Besides, they are already supported as "the" Microsoft-blessed solution to the issue of scripting Windows -- cfr. the "Windows Scripting Host". > If anyone does give it a whirl, it'd be neat to see a review/overview of it > posted here. I'm not going to download it unless I hear some compelling reason why I should -- it _is_ over a MB, and still beta, after all; _what_ does it give me over Internet Explorer, exactly? Its emphasis on "themes" sort of throws me off -- I've never particularly liked the 'theme' idea, anyway, and I get pretty much all the dynamic contents I can handle from the existing 'active desktop' shell. Alex From nobody at nowhere.nohow Wed Dec 29 23:14:20 1999 From: nobody at nowhere.nohow (Grant Edwards) Date: Wed, 29 Dec 1999 22:14:20 GMT Subject: why? References: <38685b07.189574443@news.isomedia.com> <38694EBA.31EF2141@rubic.com> Message-ID: In article <38694EBA.31EF2141 at rubic.com>, Jeff Bauer wrote: >>> I think it might be quicker if we answered the inverses of some of >>> these questions. For instance, What uses doesn't it have? >> 2) It isn't suitable for use in embedded systems with limited >> memory. >Python runs fine on a Cassiopeia E-11 Palm PC with 8MB of memory. > Microsoft's CE platform has redefined what is meant by "limited > memory". <0.5 wink> Well, they've tried. But in the real embedded system market (i.e. things without windows-like UIs) they've failed spectacularly [a situation from which I draw an entirely unhealthy amount of satisfaction]. -- Grant Edwards grante Yow! OVER the at underpass! UNDER the visi.com overpass! Around the FUTURE and BEYOND REPAIR!! From python-list at teleo.net Sat Dec 4 18:36:45 1999 From: python-list at teleo.net (Patrick Phalen) Date: Sat, 4 Dec 1999 09:36:45 -0800 Subject: Naive Question In-Reply-To: References: <38484DC9.3FF755EB@murl.com> Message-ID: <9912040951240B.00844@quadra.teleo.net> [Michael Hudson, on Sat, 04 Dec 1999] :: Hmm... what are you trying to do? Have you looked at Acquisition: :: :: http://www.zope.org/Members/Amos/WhatIsAcquisition :: :: (which is zope biased; there may be another more generic intro :: somewhere but I can't find it just now). The conceptual framework for Acquisition was developed by Joseph Gill and David Lorenz in the Computer Science Dept. at Technion, Israel Institute of Technology, and presented at OOPSLA '96. Postscript versions of their original 1995 paper are available from: http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-info.cgi?1995/LPCR/LPCR9507 From frohne at gci.net Thu Dec 30 02:37:44 1999 From: frohne at gci.net (Ivan Frohne) Date: Wed, 29 Dec 1999 16:37:44 -0900 Subject: random number generation: the newbie asks for advice References: <6D8A17398E28D3119F860090274DD7DB4B3D91@pces.cadlab.it> Message-ID: See http://starship.skyport.net/crew/statistics for an all-Python random number generator. Maybe it's fast enough -- try it out. Uniform random number algorithm options include the Mersenne Twister, one from Knuth, and two other good ones -- all much more 'random' than whrandom. --Ivan Frohne Alex Martelli wrote in message news:6D8A17398E28D3119F860090274DD7DB4B3D91 at pces.cadlab.it... > I need a decent random number generator (the 24 bits of randomness > in the builtin whRandom are not enough), fast (probably needs to be > written in C), whose state can be persisted and de-persisted. The > ranlibmodule in "Numeric" would seem to be almost perfect, except > that it seems strange to make the whole "Numeric" a pre-req when I > only use the random generation part, AND, the ran*.c files in the > sources of Numeric leave me wondering -- how much can one trust > in a C source file whose comments repeatedly say it's a Fortran > translation of a Pascal routine...? (the sources do seem like some > machine-translated Fortran, including 1-letter identifiers and goto > as the main control structure). It also seems to me that the C sources > are implementing a bazillion wonderful and exoteric generators which > are not in fact exported -- making a larger .pyd to no benefit...? Or > trusting in linker's fine-grained optimization abilities...? > > Is there a decent, Python-interfaced, C-written, stand-alone random > number generator, with persistable/de-persistable state? Or am I > being too suspicious of ranlibmodule's quality and should just try to > yank it out of "Numeric" for a smaller set of dependencies...? > > Advice is welcome! > > I would also welcome algorithmic advice on another somewhat > related issue. I need to shuffle 39 out of 52 cards, i.e., 13 of them, > aka one "hand", are "pre-dealt"; I also need to guarantee that, > if I generate two deal sequences with my algorithm, based on > the same sequences of random numbers, such that the pre-dealt > hands only differ by 1 card pair being "swapped", (say, in hand > X there is a HJ and 12 other cards; in hand Y, the same 12 > other cards but the D8 instead of the HJ), then each pair of deals > in the two sequences will also only differ by that same swap. > > (Hands are taken as sets, i.e. order of cards does not matter; > the deal of the 39 non-pre-dealt cards is into 3 13-card piles, > each also taken as a set of 13 cards). > > It seems trivial, and I was _sure_ I had an algorithm with this > property (it turns out I was wrong), but... > > I can't come up with a general approach to ensure that, except, > basically, by taking one pre-dealt hand as the "reference" one, > and expressing every other in terms of changes to that one > hand -- but then, I cannot find an "editing-change metric" that > will ensure the above property for *any* pair of pre-dealt hands. > > Again, any advice (or proof that it can't be done!-) will be > most gratefully received -- TIA! > > > Alex > > From sekter at matavnet.hu Wed Dec 29 12:01:58 1999 From: sekter at matavnet.hu (Arpad Kiss) Date: Wed, 29 Dec 1999 12:01:58 +0100 Subject: Python native compiler on NT References: <84cdo5$9u0$1@nnrp1.deja.com> Message-ID: <3869EA26.9AE31E6F@matavnet.hu> tpchang at excite.com wrote: > > I wonder if there is a Python native compiler for NT. This will help me > to sell Python to people in my company who are more familiar with .exe > files than the .py files :-) > > Thanks in advance, > > Ben > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list Check out http://starship.python.net/crew/gmcm/install.html Arpad Kiss From glazer at scicomp.com Thu Dec 16 19:13:46 1999 From: glazer at scicomp.com (Ben Glazer) Date: Thu, 16 Dec 1999 18:13:46 GMT Subject: Pipe error codes off by a factor of 256 Message-ID: <83ba4k$9ia$1@nnrp1.deja.com> I'm trying to capture the error code from a pipe opened with os.popen(). I can successfully store the returned code in a variable, but the returned code always is exactly 256 times larger than it should be. i.e., if I should be receiving an error value of 1, I actually receive 256. If I should receive 2, I actually receive 512. And so on. I can work around this bug by following any error capture with this line: if err: err = err / 256 However, it isn't really an optimal situation to include this line every time I store an error code. Has anyone witnessed this strange behavior before? Is there a way to fix this problem? Thanks, Ben Sent via Deja.com http://www.deja.com/ Before you buy. From alex at magenta.com Fri Dec 10 14:41:38 1999 From: alex at magenta.com (alex at magenta.com) Date: Fri, 10 Dec 1999 13:41:38 GMT Subject: Tkinter/IDLE crash References: <82pkpk$3o0$1@mirv.unsw.edu.au> Message-ID: <82qvui$s5t$1@nnrp1.deja.com> In article <82pkpk$3o0$1 at mirv.unsw.edu.au>, simon at george.maths.unsw.edu.au (Simon Evans) wrote: > I was making my first foray into Tkinter last night (using Py 1.5.2 > and IDLE with Win 95). [snip] > the "Quit" button, and *everything* quits. The window, the IDLE > session, everything! Goodbye python, goodbye IDLE, hello desktop. The release notes for the current PythonWin mention this, and I get identical problems (at home, on Win98 -- not here at work, on Win/NT, where things appear stable). There is something badly broken with 1.5.2 on both Win95 and Win98, it seems -- something that affects IDLE, PythonWin, _and_ the command line interpreter too, to different degrees. I get a crash on _exit_ from the whatever-environment by far most of the time -- always, if I've been using Tkinter in the session; and, not often, crashes "in the middle", such as you describe. I consider this to be the biggest current "environment" problem with Python -- that the latest implementation is SO fragile on the (alas) single most widespread platform, that it cannot really be used to develop for it:-(. I just joined the PSA, so, among other benefits, I'll get access to the current betas of PythonWin -- and, if the bugs persist there, I guess I'll try to spend some of my abundant free time to understand the crashes better (e.g., by throwing NuMega's DevPartner at the code -- sometimes it does help in finding not-quite-kosher system calls, &c). Alex Sent via Deja.com http://www.deja.com/ Before you buy. From fredrik at pythonware.com Tue Dec 28 14:15:58 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 28 Dec 1999 14:15:58 +0100 Subject: newbie question... References: <3868C1D2.614DA917@earthlink.net> Message-ID: <024601bf5135$af400c30$f29b12c2@secret.pythonware.com> Alexander Sendzimir wrote: > According to David Beazley's invaluable book, mailbox.py > is an undocumented module. guess david missed this one: http://www.python.org/doc/current/lib/module-mailbox.html ... here's an example (from the eff-bot guide): ## ## mailbox-example-1.py import mailbox mb = mailbox.UnixMailbox(open("/var/spool/mail/effbot")) while 1: msg = mb.next() if not msg: break for k, v in msg.items(): print k, "=", v body = msg.fp.read() print len(body), "bytes in body" ## sample output: ## ## subject = for he's a ... ## message-id = <199910150027.CAA03202 at spam.egg> ## received = (from fredrik at pythonware.com) ## by spam.egg (8.8.7/8.8.5) id CAA03202 ## for effbot; Fri, 15 Oct 1999 02:27:36 +0200 ## from = Fredrik Lundh ## date = Fri, 15 Oct 1999 12:35:36 +0200 ## to = effbot at spam.egg ## 1295 bytes in body From mhammond at skippinet.com.au Thu Dec 9 12:10:25 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 09 Dec 1999 11:10:25 GMT Subject: Win32 and the clipboard References: <326536345498D311B3BC00105A39802A074522@newsintern.dspace.de> Message-ID: >Mark must somehow missed that thing. If you are building from the >sources this module is available. Since I haven't used it I don't >know if it was left out intentionally or by mistake. Oops - definately a mistake :-( From sdossett at metaphoria.net Wed Dec 1 13:13:32 1999 From: sdossett at metaphoria.net (sdossett at metaphoria.net) Date: 01 Dec 99 07:13:32 -0500 Subject: Java 1.2 and JPython Message-ID: <199912011207.HAA04934@python.org> Does JPython 'fully support' Java 1.2? I've scoured the web-site and haven't found much information on this. I read the NEWS section and it said that JPython 1.1 supports Java 1.2 style Collections... but does it support everything else? Suppose this might be a newbie question - but I'm moving a system using JPython from Java 1.1 to Java1.2 and wanted to be sure there were no issues. Thanks, Scott > ** Original Subject: [JPython] CFP Developers' Day - 8th International Python Conference > ** Original Sender: bwarsaw at python.org (Barry Warsaw) > ** Original Date: Tue, 30 Nov 1999 15:23:40 -0500 (EST) > ** Original Message follows... > > Hello Python Developers! > > Thursday January 27 2000, the final day of the 8th International > Python Conference is Developers' Day, where Python hackers get > together to discuss and reach agreements on the outstanding issues > facing Python. This is also your once-a-year chance for face-to-face > interactions with Python's creator Guido van Rossum and other > experienced Python developers. > > To make Developers' Day a success, we need you! We're looking for a > few good champions to lead topic sessions. As a champion, you will > choose a topic that fires you up and write a short position paper for > publication on the web prior to the conference. You'll also prepare > introductory material for the topic overview session, and lead a 90 > minute topic breakout group. > > We've had great champions and topics in previous years, and many > features of today's Python had their start at past Developers' Days. > This is your chance to help shape the future of Python for 1.6, > 2.0 and beyond. > > If you are interested in becoming a topic champion, you must email me > by Wednesday December 15, 1999. For more information, please visit > the IPC8 Developers' Day web page at > > > > This page has more detail on schedule, suggested topics, important > dates, etc. To volunteer as a champion, or to ask other questions, > you can email me at bwarsaw at python.org. > > -Barry > > _______________________________________________ > JPython-Interest maillist - JPython-Interest at python.org > http://www.python.org/mailman/listinfo/jpython-interest >** --------- End Original Message ----------- ** > 'not with a bang, but a whimper...' t. s. elliot Download NeoPlanet at http://www.neoplanet.com From pinard at iro.umontreal.ca Mon Dec 13 19:07:39 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 13 Dec 1999 13:07:39 -0500 Subject: Python complaints In-Reply-To: "Tim Peters"'s message of "Wed, 1 Dec 1999 03:15:04 -0500" References: <000201bf3bd4$2bda5e20$542d153f@tim> Message-ID: "Tim Peters" ?crit: > It's not the functionality of "map" that's objectionable, it's the > politics. Oh, I see. > The unwanted side-effect is that their addition opened the doors > to endless clamoring for more of the same, and griping about the > limitations of lambda (which was conceived as a minor convenience, > not as the foundation of an alternative programming style). Guido could keep `map', `reduce' and `filter', and get rid of `lambda'. I guess it might solve the bigger part of the political problem. :-) > There's nothing you can do with "map" you couldn't do "more Pythonically" > with list comprehensions; e.g. > sq = map(lambda a: a**2, x) > vs > sq = [a**2 for a in x] The main thing, above, is that you are getting rid of `lambda'. But, to be honest, you are also avoiding the need for an accessory function. Yet, accessory functions are easy to write, and contribute somewhat to the better documentation of the Python code. (A bit the same as writing a class to produce closures is more cumbersome than the Scheme way, but yields better documentation for such effects, a bit "unusual" in Python.) > In the bowels of DejaNews [...] One of these days, I should learn how to use this famous `DejaNews' everybody speaks about :-). I am rather disconnected, am I not? :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From gmcm at hypernet.com Tue Dec 21 17:13:44 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: 21 Dec 1999 10:13:44 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 21) Message-ID: <7D99E9F5B20B4BA9.D1FD33F5C753DF5C.FCBA193C7D9DF095@lp.airnews.net> People interested in optional static typing in Python should look at the types SIG http://www.python.org/pipermail/types-sig/ which is experiencing a flood of activity, (including unauthorized use of Guido's time-machine). Meanwhile, a minor flood of announcements in Pythondom: Jean-Claude Wippler announces that MetaKit (a fast, lightweight embedded DB library with surprising capabilities) is now Open Source http://www.deja.com/getdoc.xp?AN=561017677 http://www.equi4.com/metakit/ Last week we saw the announcement that DISLIN (a cross platform plotting package) comes with Python bindings; this week Paul Magwene announces a Python OO wrapper library http://www.deja.com/getdoc.xp?AN=560482093 A bug fix release of Zope http://www.deja.com/getdoc.xp?AN=560591351 A new release of PyQt/PyKDE (now compiling on Windows NT) from Phil Thompson http://www.deja.com/getdoc.xp?AN=562647925 A very early (developer only) release of Python Builder (an IDE for the keyboard impared) is now available from Cliff Baeseman http://www.deja.com/getdoc.xp?AN=560830466 William Annis releases a developer-only snapshot of Mom - a Unix system monitoring tool (primary platform: Solaris) http://www.deja.com/getdoc.xp?AN=561060235 John Aycock announces an early version of his Decompyle package (reconstruct source from bytecodes) http://www.deja.com/getdoc.xp?AN=563144526 Two juicy tidbits in the "completely different" category: Looking for something interesting to do with that huge power-sucking box in the basement? IBM has posted instructions on porting Python 1.4 to OS/390 http://www2.s390.ibm.com/products/oe/python.html (If you have a spare, please ship one to Tim, so he can test floating point conformance .) Those in search of a license model might consider Just van Rossum's unique approach http://www.deja.com/getdoc.xp?AN=562607678 Don't forget that the early-bird prices for the Python conference expire on January 5th http://www.python.org/workshops/2000-01/ ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the center of Pythonia http://www.python.org Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ Python Consortium emerges as an independent nexus of activity http://www.python.org/consortium Python To-Do List anticipates some of Python's future direction http://www.python.org/cgi-bin/todo.py Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Archive probing trick of the trade: http://www.dejanews.com/dnquery.xp?QRY=&DBS=2&ST=PS&defaultOp=AND&LNG=ALL&format=threaded&showsort=date&maxhits=100&groups=comp.lang.python Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://purl.org/thecliff/python/url.html or http://www.dejanews.com/dnquery.xp?QRY=~g%20comp.lang.python%20Python-URL%21 Suggestions/corrections for next week's posting are always welcome. http://www.egroups.com/list/python-url-leads/ To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From paul.magwene at yale.edu Tue Dec 14 12:25:49 1999 From: paul.magwene at yale.edu (Paul M) Date: Tue, 14 Dec 99 11:25:49 GMT Subject: pxDislin - release 0.1 Message-ID: DESCRIPTION: ----------- pxDislin is an object-oriented wrapper around the DISLIN plotting library. DISLIN is a powerful and flexible multiplatform (Win32, Unix, Linux, etc.) library designed for displaying scientific data. DISLIN's author, Helmut Michels, has made available a DISLIN plotting extension for the Python programming language (see http://www.linmpi.mpg.de/dislin/ for more details). pxDislin provides a set of classes which represent various aspects of DISLIN plots, as well as providing some easy to use classes for creating commonly used plot formats (e.g. scatter plots, histograms, 3-D surface plots). A major goal in designing the library was to facilitate interactive data exploration and plot creation. Documentation and a demo program are included. The library has been tested on WinNT and FreeBSD, but I anticipate that it should work on any platform which can make use of Python, NumPy, and the DISLIN python extensions. Feedback, comments, and critique are gladly accepted (email: paul.magwene at yale.edu). VERSION: ------- This is release 0.1 of pxDislin. URL: ---- You can find pxDislin at: http://pantheon.yale.edu/~pmm34/pxdislin.html Paul Magwene paul.magwene at yale.edu

pxDislin 0.1 - a set of object-oriented classes which work with the DISLIN Python extension (for displaying scientific data). (13-Dec-99) -- ----------- comp.lang.python.announce (moderated) ---------- Article Submission Address: python-announce at python.org Python Language Home Page: http://www.python.org/ Python Quick Help Index: http://www.python.org/Help.html ------------------------------------------------------------ From aahz at netcom.com Thu Dec 23 20:05:04 1999 From: aahz at netcom.com (Aahz Maruch) Date: 23 Dec 1999 19:05:04 GMT Subject: Patch: httplib.py default timeout References: <83r0lh$mj6$1@nntp6.atl.mindspring.net> Message-ID: <83trp0$ubi$1@nntp8.atl.mindspring.net> In article , Phil Mayes wrote: >Aahz Maruch wrote in message <83r0lh$mj6$1 at nntp6.atl.mindspring.net>... >> >>No, I'm not including the actual patch here. I just wanted to see if >>anyone had an objection to changing httplib.py so that by default it >>times out after sixty seconds. To maintain the current behavior, you'd >>have to pass in a parameter of 'timeout=0'. > >It seems to me that this is a subset of the more general problem of >socket timeouts. There is a timeout_socket class and a method of >injecting it into existing Python modules at > http://www.vex.net/parnassus/apyllo.py?i=97250001 >that -might- work for you. That's a good suggestion, but I'll have to reject it unless the timeout_socket class is migrating to the core distribution -- I really think that the CP4E concept requires that we automatically handle this kind of problem. Since httplib is the one that's biting me now (and is likely to be the most common one for casual users IMO), that's the one I'm fixing. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Eighth Virtual Anniversary -- 8 days and counting! From tomhs at austin.ibm.com Wed Dec 1 17:34:37 1999 From: tomhs at austin.ibm.com (Tom Smith) Date: Wed, 01 Dec 1999 10:34:37 -0600 Subject: [Tutor] TKinter References: <003301bf3ab5$13138080$0c5bdfc8@the-user> <38431229.7B60A603@worldnet.att.net> <384314A8.6929482C@callware.com> Message-ID: <38454E1D.167E@austin.ibm.com> Not Found The requested URL /library.htm was not found on this server. Ivan Van Laningham wrote: > > Hi All-- > > Ralph Alberti wrote: > > > > Have you seen this: > > > > http://starship.python.net/crew/fredrik/tkintro/Introduction.htm > > > > --Ralph > > > > Alexandre Passos wrote: > > > > > > Has someone got a link to some __downloadable__ tutorial of TKinter? > > > > > And also this: > > http://www.pythonware.com/library.htm > > Which has a link to the PDF version of the introduction. > > There're lots of parts missing, 'cause /F is so busy, but it's still > about the best place to start. ... > > Take care, > 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 > Author: Teach Yourself Python in 24 Hours > ---------------------------------------------- -- |---------------------------------------------------------| | Tom Smith | | tomhs at austin.ibm.com 512-838-8842 | | PSW Technologies IBM RISC/System Graphics | | AIX GOS/PVT Bldg 45, 2L-070, Austin, TX USA | |---------------------------------------------------------| From kc5tja at garnet.armored.net Mon Dec 13 21:14:20 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 13 Dec 1999 20:14:20 GMT Subject: win32com: subclass a com object? References: <830pi6$n4k$1@nnrp1.deja.com> <832skg$4bn$1@nnrp1.deja.com> Message-ID: In article <832skg$4bn$1 at nnrp1.deja.com>, tiddlerdeja at my-deja.com wrote: >Is COM just interface inheritance? What about implementation >inheritance? COM isn't even about interface inheritance. It's about asking the object, "Just what is it you can do?" Until you read up on how the methods of IUnknown work, you'll be perpetually lost in this regard. I strongly recommend that you read the first two chapters of the Microsoft Component Object Model specification (http://www.microsoft.com/com). However, to answer your question more directly, COM supports a technique called "aggregation," which is semantically equivalent to implementation inheritance. Aggregation is actually somewhat more powerful, as it gives you all the capabilities of multiple inheritance without the ambiguities that come from it. The memory consumed by "an object" need not reside in one memory space, either -- it could be scattered between address spaces or between computers on a network. Aggregation does require a bit more boiler-plate code on the part of the COM object implementor, but not too much -- and the results are well worth it. The client of the COM object (that is, the programmer USING the COM object) doesn't see anything more complicated about the object. Delegation (which is what you ended up doing in your second Python example) is another technique to implementation re-use. However, it's much more suited for customizing or wrapping an interface in code. It's roots are in more traditional object oriented programming examples. For example: class foo: def __init__(self, a, b, c): self.anA = a self.aB = b self.aC = c def dump(self): print "A is %s" % self.anA print "B is %s" % self.aB print "C is %s" % self.aC class myFoo( foo ): def __init__(self,a,b,c,d,e): # Note that we /delegate/ to the superclass' __init__ method # to initialize the super-object. foo.__init__(self,a,b,c) self.aD = d self.anE = e def dump(self): # Note that we delegate to the superclass' dump() method. print "The results from dump() is as follows:" foo.dump(self) print "D is %s" % self.aD print "E is %s" % self.anE print "There. All done!" Both examples above fall under the category of "delegation." Any library which promises an object oriented interface to a system service which itself isn't inherently object oriented is guaranteed to use delegation to do its work. Note that you can use aggregation and delegation concurrently in a single COM object implementation, producing some of the most flexible code re-use capabilities I'd ever seen. For example, let's say I want to log all file access to a particular file. I can create a "customized file object" which aggregates a Log object, and delegates a normal File object. I want to delegate the file interfaces because I want to "trap" or "hook" the function calls, so that I can keep a record of what functions are called and when, as well as actually perform the file operations. Of course, this could easily be done with multiple inheritance in traditional object oriented systems, but the results are semantically the same, with the additional benefit that there is no confusion as to which method to invoke if multiple interfaces implement the same method. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From dotproduct at usa.net Mon Dec 13 02:03:58 1999 From: dotproduct at usa.net (Nick Maxwell) Date: Sun, 12 Dec 1999 19:03:58 -0600 Subject: Need information om Python byte-code Message-ID: <8345m3$27t$1@hyperion.nitco.com> I am currently writing MUD software with a server written in C++. I have plans to embed Python into the server so it can act as the mud language. I was reading the Python tutorials a while ago, and found that modules can be compiled into byte-code for faster compiling. I have messed around with the compile function, but to no avail. I have RTFM many times now on this subject, and I just can't get it. If someone could just tell me the exact steps to compiling a module into byte-code, I would really appreciate it! Please reply to my email, as I don't have much time to check the newsgroups, and thanks for any replies... - Nick Maxwell dotproduct at usa.net From harri.pasanen at trema.com Thu Dec 23 12:44:04 1999 From: harri.pasanen at trema.com (Harri Pasanen) Date: Thu, 23 Dec 1999 13:44:04 +0200 Subject: [PSA MEMBERS] Please test new dynamic load behavior References: Message-ID: <38620B04.7CC64485@trema.com> Greg Stein wrote: > > Hi all, > > I reorganized Python's dynamic load/import code over the past few days. > Gudio provided some feedback, I did some more mods, and now it is checked > into CVS. The new loading behavior has been tested on Linux, IRIX, and > Solaris (and probably Windows by now). > ... What was the motivation behind this modification? Just curious, -Harri From lazrnerd at ufl.edu Mon Dec 13 23:07:59 1999 From: lazrnerd at ufl.edu (Craig Schardt) Date: Mon, 13 Dec 1999 22:07:59 GMT Subject: Dot product? References: <3852B91D.6EE31805@math.okstate.edu> <3854CBFF.85A69AA@compaq.com> <3854F1EE.3CA02CD6@compaq.com> <3854C1E4.624F7E3A@udel.edu> Message-ID: <38556c96.37842981@news.ufl.edu> On Mon, 13 Dec 1999 09:52:36 +0000, Charles Boncelet wrote: >How about the the mxTools solution: > >sum = 0.0 >for x,y in tuples(list1, list2): > sum = sum + x*y > This could also be acheived with the following Python class: class Iter: onelist = 0 def __init__(self, *args): if len(args) == 1: self.onelist = 1 self.items = args[0] else: self.items = args def __getitem__(self, index): if self.onelist: return self.items[index] values = [] for seq in self.items: try: values.append(seq[index]) except IndexError: values.append(None) for val in values: if val is not None: break else: raise IndexError return tuple(values) Sorry for the lack of documentation but I just whipped it up. Just call it as: for i,j in Iter(list1,list2): dosomething(i,j) > >AFAIK, both "tuples" and "map" solutions create an intermediate object. >However there seems to be no reason why the internals of Python couldn't >be changed so that these could be computed "on the fly" as needed. > The class version doesn't create any intermediate copies of the lists. If this lists are large, this could be an advantage. Otherwise I can't see any good justification for the extra overhead. -craig. From donn at u.washington.edu Wed Dec 29 18:39:30 1999 From: donn at u.washington.edu (Donn Cave) Date: 29 Dec 1999 17:39:30 GMT Subject: Super Tuples References: <386A1037.C6D458B3@prescod.net> <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> Message-ID: <84dh0i$17io$1@nntp6.u.washington.edu> I'm not too worried about the mathematicians, they'll probably be able to cope with the differences between their tuples and Python's, but there does seem to be a big gap between the tuple and class instance as ways to express the equivalent of a C struct. The tuple is right for it, it's an efficient and ordered data structure, but the resulting programming idiom (access by index) is hard to read and prone to error. What if the compiler could convert names to indices at compile time? while the runtime could continue to use tuples as it always has, as the simplest of sequences. Um, st:struct_stat = posix.stat(file) size = st.size # Literally st[6]. Size is not an attribute of st I have no idea how the compiler would know what :struct_stat means. Wouldn't have even mentioned it, but for some vague idea that this general kind of compile time resolution might figure in other plans for the distant future. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From hildeb at www.stahl.bau.tu-bs.de Fri Dec 3 13:57:05 1999 From: hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt) Date: 3 Dec 1999 12:57:05 GMT Subject: printable characters Message-ID: How can I find out if a character is printable? There seems to be no equivalent to isprint() of C. Right now I use: def isprint(char): return (ord(char) in range(32, 127)) From greg.ewing at compaq.com Wed Dec 15 09:19:16 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 15 Dec 1999 21:19:16 +1300 Subject: Newbie: need help with control loop References: <38543b80.289200819@news-server> <8321cu$i1h$1@news.udel.edu> <3854d1ca.327680172@news-server> Message-ID: <38574F04.7DD0AFBA@compaq.com> Shaggy wrote: > > This was my whole question. Where or what is host_inst. In each case > it will be different I can create the object, I just can't name it. I think you want to build a list of instances. hosts = ['host1','host2','host3','host4','host5', 'host6','host7','host8','host9','host0'] insts = [] for machine in hosts: insts.append(class_name(machine)) Then you can iterate over insts, initiating the operations, checking for completion, etc. Greg From fredrik at pythonware.com Fri Dec 17 12:57:08 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 17 Dec 1999 12:57:08 +0100 Subject: getattr function References: <385A1D7D.19262C62@prism.co.za> Message-ID: <030501bf4885$e1a35050$f29b12c2@secret.pythonware.com> Alwyn Schoeman wrote: > Could someone please explain this function to me? Specifically as > it relates to use in classes and overloading? __getattr__ is called as a last resort, when Python fails to resolve an attribute name in any other way. the docs say: "Called when an attribute lookup has not found the attribute in the usual places (i.e. it is not an instance attribute nor is it found in the class tree). Note that if the attribute is found through the normal mechanism, __getattr__() is not called." see any available python introduction for more info on how this works. (the technical details can be found under "class instances" here: http://www.python.org/doc/current/ref/types.html ) > Say I've got my own listthingy class without a sort, if I now do > X.sort() I can see that a method in my class which looks like > def __getattr__(self, name), that sort is probably the name > parameter. But how does it know that it must do a list type sort > or does this work just because sort is kindof generic? afaik, it doesn't work -- unless you implement it your- self. and if you do, it's usually easier to just define a "sort" method, and let python handle the rest in the usual way... From delgado at pinax.Mathematik.Uni-Bielefeld.DE Thu Dec 2 11:54:06 1999 From: delgado at pinax.Mathematik.Uni-Bielefeld.DE (Olaf Delgado) Date: 2 Dec 1999 12:54:06 +0200 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: <38465dde@news.uni-bielefeld.de> In article , "Phil Mayes" writes: > David N. Welton wrote in message <87puwpg7kp.fsf at freddy.page.street>... >> >>Doesn't the new millenium actually start in 2001? > > > Only for FORTRAN programmers. Python and C programmers, being zero-based, > get to celebrate a year earlier. Unfortunately then, our calender must be written in FORTRAN. Olaf From donn at oz.net Sat Dec 11 19:59:17 1999 From: donn at oz.net (Donn Cave) Date: 11 Dec 1999 18:59:17 GMT Subject: Inconsistent socket.gethostbyname exceptions References: <384F13A1.B9A9C675@graburn.com> Message-ID: <82u6u5$3la$0@216.39.151.169> Quoth Ronald Hiller : | I've noticed that the socket.gethostbyname function doesn't return the | same format of exceptions as other socket operations (like connect). | For example, a failed get hostbyname returns a simple string 'host not | found' whereas a failed connect returns a list (146, 'Connection | refused'). | | I've looked at socketmodule.c and noticed that gethostbyname puts | together it's own exception while connect calls PySocket_Err to pack up | errno with the string into a tuple. | | Now, I understand that there is no errno value for 'host not found' and | synthesizing something may be a "bad thing". However, testing | exceptions is somewhat tricky since the format apparently differs | between operations. Now, if these are the only two cases, I guess it's | not so bad, but I worry (I admit to not having searched the source) that | there could be more cases with different formats. | | Is this a bug, or am I getting excited about nothing? Somewhere in between the two, I think. It's a good question, too good for me or apparently anyone else to have a good answer! If it's not a bug, certainly it's not a strong point of the runtime either. I hope in some future version of Python, the exception will have more reliable attributes. I have no specific idea how that would actually look, what attributes precisely I'm looking for, but I think if the socket module ever gets the 1.5 OO exception treatment, like the posix module did, that will probably help. I wouldn't be surprised if this is on the list of things to do, but there also might be room for someone to contribute that change. Donn Cave, donn at oz.net From a.eyre at optichrome.com Fri Dec 17 12:54:23 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 17 Dec 1999 11:54:23 -0000 Subject: knee.py In-Reply-To: <19991216203150.A6293@stopcontact.palga.uucp> Message-ID: <003501bf4885$760c6fc0$3acbd9c2@peridot.optichrome.com> > So why is it in the module library? I think the Demo/ dir. should be a > better place, why isn't it there? Or remove it altogether. Is it not obsolete? -------------------------------------------- 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 dfan at harmonixmusic.com Tue Dec 28 14:53:51 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 28 Dec 1999 08:53:51 -0500 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <38656610.E4DA287B@maxtal.com.au> Message-ID: neelk at brick.cswv.com (Neel Krishnaswami) writes: | The general problem that needs fixing is that Python really needs a | better iteration protocol. (I understand that Guido has worked one | out, but hasn't yet implemented it. You may want to contact him so | that the two of you can use Viper as a test bed for advanced Python | ideas.) Anyone who is interested in better iteration protocols would probably be interested in looking at how Sather does it. Sather is an Eiffel-like language with a home page at ; it performs iteration with coroutines, basically. See , section 3.2, for a description of how you write them. -- Dan Schmidt | http://www.dfan.org From quinn at krone.ugcs.caltech.edu Wed Dec 15 21:58:25 1999 From: quinn at krone.ugcs.caltech.edu (Quinn Dunkan) Date: 15 Dec 1999 20:58:25 GMT Subject: Python complaints References: <38576B73.59C7BA85@udel.edu> <838o42$dsu$1@nnrp1.deja.com> Message-ID: On Wed, 15 Dec 1999 18:54:04 GMT, choffman at dvcorp.com wrote: >In article <38576B73.59C7BA85 at udel.edu>, > Charles Boncelet wrote: > >> >> I think all functions that operate on single things should be able to >> operate on a list of things and return a list of things. (Are there >> obvious reasons why this paradigm can't work?) Consider, > >Ignoring the suggestion that 'len' itself be changed, if you truly mean >the language should automatically loop over lists, then there is >certainly an obvious reason why this can't work. Maybe it's just me, but I think that: map(sin, [1, 2, 3]) is explicit and clear and already works. Wheras modifying built in functions so that some take lists makes things unclear unless the reader knows about that 'feature' of that function. And in the time it takes to read the docs to find out if this is one of those special functions you could have just written a map or loop anyway. Even though python gives you the power to have functions try to figure out what to do based on the type of their arguments, be careful with it. I think there's a lot to be said for functions which take only one type of arg and do one well defined thing with it. Especially in the builtins. Trying to make functions too smart is more trouble that it's worth, IMHO. Explicit is better than implicit. Tim 14:10 (ok, so I don't remember the msg id...) From lazareff at onera.fr Wed Dec 8 11:17:43 1999 From: lazareff at onera.fr (Marc LAZAREFF) Date: Wed, 08 Dec 1999 11:17:43 +0100 Subject: Object identifier in constructor Message-ID: <384E3046.7846F325@onera.fr> I have the following problem : In the Python interface of a C++ CFD code (the elsA software, developed here at ONERA), cross-references between user defined objects are made through string identifiers, which should be the same as the Python object identifiers, ex: Creating the 'm1' instance of the 'model' class like this : m1=model() should (for the current scheme to work celanly) allow for the 'm1` string identifier for object m1 to be recovered (in the `model' class constructor) and properly conveyed to the C++ kernel to be stored as an attribute of the bound C++ object (we use SWIG with shadow mode). Such a string identifier allows user defined references to 'm1' from other Python objects, ex: b1=block() b1.attach('m1') We can't use a hash or equivalent on the m1 object to use as an identifier, because the reference to it may be made before it is created (this allows cross-references between two objects without the chicken-egg problem). A `link-like' post processing is not appropriate, because the interface may be used interactively. The present solution involves scanning __main__.__dict__ (the scope in which all user objects are registered by the interface) as soon as possible after the object creation, to lookup the object's address in __main__.__dict__.values() and thus get at the corresponding key (the object's name). This sounds silly, and I guess it is. Also, using the code on a large number of user objects leads to a time penalty which is not fully acceptable. So, apart from the possibility of other possible cross-referencing schemes, is there a solution to : "Get the object's Python identifier (as in dir()) while still in the constructor" ??? 8-P Hopefully (and anyway) with many thanks, Marc -- Marc Lazareff | Phone (direct) 1 46 73 42 73 ONERA 29,Ave de la Division Leclerc | 92320 CHATILLON FRANCE | E-Mail lazareff at onera.fr From sposhua at my.pc Wed Dec 22 15:01:57 1999 From: sposhua at my.pc (Sposhua) Date: Wed, 22 Dec 1999 14:01:57 +0000 Subject: Bad programming style? Message-ID: I'm sure this is bad programming (though I'm sure I'll be proved wrong), but I'd like to know how to do it anyway... I want to create a varaible name and use it as a normal variable, something like: c=['r','g','b'] VARIABLE_CALLED(c[0])='ff' obviously there are ways around it using dictionaries or whatever, but I'd like to know if it's possible to actually _create_ this variable r='ff' 'on the fly'. And can anyone tell me if it actually has any use. Did that sense make?? From aahz at netcom.com Wed Dec 22 18:19:54 1999 From: aahz at netcom.com (Aahz Maruch) Date: 22 Dec 1999 17:19:54 GMT Subject: Module urllib References: <3860C639.17CF1185@digitalmap.hi.bosch.de> <3860e4da.0@news.cyberway.com.sg> Message-ID: <83r17q$1nj$1@nntp8.atl.mindspring.net> In article <3860e4da.0 at news.cyberway.com.sg>, Ng Pheng Siong wrote: > >3. Your web proxy demands http basic authentication before doing >its business for you. I think an environmental variable like this > > http_proxy=http://proxy_user:proxy_password at proxy.../ > >should work. Of course, this exposes your proxy username/password >in your environment. I'm not positive, but you should be able to set the environment variable from within your Python script. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 10 days and counting! From JamesL at Lugoj.Com Tue Dec 21 05:01:20 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 20 Dec 1999 20:01:20 -0800 Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <83lnq7$c9d$1@news1.tele.dk> Message-ID: <385EFB90.4EFC4C0F@Lugoj.Com> "Magnus L. Hetland" wrote: > > "Jesper Hertel" writes: > > > I hope this was a joke. That kind of constructions is impossible to read for > > other programmers, making the program hard to maintain. > > > > It is idiomatic python, really... I think you spelled "idiotic" incorrectly. (Sorry, cheap shot.) I don't have a dictionary in front of me, but I'm pretty sure that by definition an idiom can not be unilaterally declared. By the way, I would agree that my function solution is not the same at all as the "C" "?:" operation. I've been programming in "C" for almost 20 years now and have been moving away from using that operator. I use its short-circuit evaluation now mostly in printf debug statements for such things like: char *var = 0; /* Or NULL if you're old fashioned like me. */ /* something happens to var...maybe. */ printf("[%s]\n", var ? var : ""); From rwadkins at flash.net Tue Dec 14 23:40:41 1999 From: rwadkins at flash.net (Very Frustrated) Date: Tue, 14 Dec 1999 22:40:41 GMT Subject: calling Python from C: I can't get this part. References: <82res6$896$1@nnrp1.deja.com> <385399BB.2BC1D709@appliedbiometrics.com> Message-ID: <836h18$qnu$1@nnrp1.deja.com> Okay, almost there. This is adapted from callback2 in the SWIG examples. Here's a reminder: SWIG keeps up with pointers as strings. For example, if you have a function like: *void myfunc(void) { int *p = NULL; return p; } using SWIG, from Python you would write: >>>pointer = myfunc() >>>print pointer _0_void_p or something to that effect. This is causing some problems for me because my python functions need this string value to work properly using the getattr and setattr helper functions. Here's where I am now: /* set up the python callback evaluation */ static PyObject *my_pycallback = NULL; static int PythonCallBack(Chrom_Ptr *chrom) { PyObject *func, *arglist; PyObject *result; func = my_pycallback; /* This is the function .... */ /* the following almost works, but not quite */ arglist = Py_BuildValue("s", chrom); /* the chrom pointer as string?*/ result = PyEval_CallObject(func, arglist); Py_DECREF(arglist); Py_XDECREF(result); return /*void*/; } /*Here's a helper function to call from Python to set the callback */ /* This part works okay, inasmuch as I get a pointer returned */ GA_Info_Ptr GA_py_config(char *cfg_name, PyObject *PyFunc) { GA_Info_Ptr ga_info; /* the GA_config returns a pointer */ Py_XDECREF(my_pycallback); /* Dispose of previous callback */ Py_XINCREF(PyFunc); /* Add a reference to new callback */ my_pycallback = PyFunc; /* Remember new callback */ ga_info = GA_config(cfg_name,PythonCallBack); return ga_info; } Now, here's the Python version of the C evaluation function. It takes a Chrom_Ptr argument (again, a string) and operates on it. It works fine as long as it's called from within Python. The problem is that when it's used as a callback, it doesn't work. I believe this is due to alteration to the Chrom_Ptr chrom argument when the function is called with : arglist = Py_BuildValue("s", chrom); /* the chrom pointer as string?*/ result = PyEval_CallObject(func, arglist); Okay, here's the python function: def func(chrom) : # import all the GA functions from libga import * val = 0.0 penalty = 1.0 # python will then exit the function while trying to execute the # following statement fudge_factor = 1.0/(GA_chrom_length_get(chrom)*10.0) for i in range(GA_chrom_length_get(chrom)): if (GA_chrom_gene_get(chrom,i)!= i+1): how_far_off = GA_chrom_gene_get(chrom,i)-(i+1) if how_far_off < 0: how_far_off = - how_far_off val = val + penalty + how_far_off*fudge_factor GA_chrom_fitness_set(chrom, val) return val Any ideas how I get SWIG or Python to pass the Chrom_Ptr object to Python as a string? Thanks, --Randy Sent via Deja.com http://www.deja.com/ Before you buy. From ivanlan at callware.com Wed Dec 29 02:11:37 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 28 Dec 1999 18:11:37 -0700 Subject: Py2K wishes References: <1265702487-58362302@hypernet.com> Message-ID: <38695FC9.E12455BD@callware.com> Hi All-- Gordon McMillan wrote: > > > In article <87aemwuowv.fsf at den.home.net>, Frank Sergeant wrote: > > >mlh at vier.idi.ntnu.no (Magnus L. Hetland) writes: > >> > > > abbreviation for the noun 'define'. >> >> What is a define? (I > > assume that it is a word of your own construction?) > >I'm sorry; > > I screwed it up; the joke is ruined! > >I meant to say 'def' is > > an abbreviation for the noun 'definition'. > > -- Frank > > > > Uh, is that the noun "frank", the verb "frank", or the > > adjective "frank"? > > Frankly-I-don't-give-a-damn-ly y'rs > Oh, trust Gordon. Faced with three choices, he takes the fourth. -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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From m-titus at usa.net Mon Dec 13 21:22:36 1999 From: m-titus at usa.net (MARGINEAN TITUS) Date: 13 Dec 99 15:22:36 EST Subject: (no subject) Message-ID: <19991213202236.18024.qmail@www0a.netaddress.usa.net> I created a class to help me to debug an communication protocol. It work really fine, but I got a problem about some kind of share of global variables between interpreter and module. Please reply directly to me, because I'm not in the list. In module FibSel.py I have the FMServer class definition folowed by the next piece of code: ############################################## # # Estabilish the default connection when module is imported # ############################################## fm=None def ReConnect(): global fm if not fm: print 'Try to estabilish the default conexion on the object called fm' fm=FMServer() fm.Connect() fm.Login('python'+`time.time()`) print fm ReConnect() # connect when module is imported # End of FibSel.py module From command line: Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> from FibSel import * Try to estabilish the default conexion on the object called fm connected with wl01191.corning.com on port 3490 >>> # Was called ReConnect so I have in fm an FMServer object >>> print fm >>> # Is OK >>> fm.Disconnect() >>> # now distroy the fm object >>> fm=None >>> # Then reconnect >>> ReConnect() connected with wl01191.corning.com on port 3490 >>> # I expect to have in fm an FMServer object >>> print fm None >>> # ????????????????????????????????????????????????????? As you seen, in ReConect function object was right ( print fm gave: "") but from command line I got None. Why first time ( when reconnect was called during module import) I got the global fm object and when I try calling by hand reconnect it goes wrong? TIA ____________________________________________________________________ Get free email and a permanent address at http://www.netaddress.com/?N=1 From torppa at polykoira.megabaud.fi Wed Dec 1 22:36:25 1999 From: torppa at polykoira.megabaud.fi (Jarkko Torppa) Date: 1 Dec 1999 21:36:25 GMT Subject: Python and SSL References: <19991130080326.A1376@quark.emich.edu> <823q95$ofa$1@nnrp1.deja.com> Message-ID: <8244cp$n5j$1@news.kolumbus.fi> In article <823q95$ofa$1 at nnrp1.deja.com>, Preston Landers wrote: >BTW, as an aside, I recently wanted to automate some of my bank >transactions that I do via http/SSL. Unfortunately I found the state >of http/SSL support in Python rather lacking, and I had to turn to Perl >to acccomplish what I needed, simply because the modules were availible >and more robust and mature. If I had time I would rectify this >situation. :-( I have sslmodule that is also lacking, it's comment says basic ssl-module that has just enough stuff that i can connect to https site and get stuff from there. it is quite ugly, but if somebody wants it I can see if I get permissions to release it (written in work). When (start of 1999) I wrote it I were able to find two other attempts, - one that was a patch to socketmodule.c - one based on very old SSleay, could'nt get it to compile both were quite unacceptable after that there have come at least M2Crypto 0.02 http://www.post1.com/home/ngps ssl_wrapper http://home.att.net/~nvsoft1/ssl_wrapper.html from quick glance at the sites M2Crypto looks better. -- Jarkko Torppa torppa at staff.megabaud.fi Megabaud Internet-palvelut From dan at control.com Thu Dec 2 17:03:11 1999 From: dan at control.com (Dan L. Pierson) Date: Thu, 02 Dec 1999 11:03:11 -0500 Subject: [Zope-dev] Re: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF64019276318@gandalf.digicool.com> <38449F86.D6538558@home.com> <00f701bf3bdd$52aaf510$f29b12c2@secret.pythonware.com> <3845D940.6048E8EF@home.com> Message-ID: <=ZdGOGKcgbpRCjmVV8txR3mLHRo8@4ax.com> Edward Muller wrote: > I do completly agree. I spent some more time looking at the specs. But what > languages/platforms is SOAP CURRENTLY implimented on? CURRENTLY being the key > here. XML-RPC is implimented in C/Python/Java, etc, etc....That means I can do > what I want to do from just about ANY OS, as a cgi script, or a java > applet....With SOAP I can't.... > > I do agree with you that SOAP would address my problem, > AND I WILL LOOK INTO DOING A PYTHON IMPLIMENTATION > > ...EAM... This page references C++/COM, Java, and Perl implementations. The Perl ones seem to have the only download links... http://www.develop.com/soap/ Dan Pierson, Control Technology Corporation dan at control.com From timmuddletin at news.vex.net Sat Dec 11 08:05:38 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 11 Dec 1999 07:05:38 GMT Subject: Python and regexp efficiency.. again.. :) References: <38518D51.4A32C685@lemburg.com> Message-ID: <82st42$23oe$1@news.tht.net> On 11 Dec 1999 13:21:52 +0200, Markus Stenberg wrote: >Meta-language link didn't work and EBNF is bit too low-level for my liking VoP to the rescue! Url should be... http://www.tibsnjoan.demon.co.uk/mxtext/Metalang.html (the mxTextTools page accidentally has lower case 'm') From mhammond at skippinet.com.au Sun Dec 12 23:46:42 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 12 Dec 1999 22:46:42 GMT Subject: win32com: subclass a com object? References: <830pi6$n4k$1@nnrp1.deja.com> Message-ID: tiddlerdeja at my-deja.com wrote in message <830pi6$n4k$1 at nnrp1.deja.com>... >I'd like to know how to subclass or derive from a existing COM object. >This subclass would implemented as a COM object itself. The "create a >COM object in python" I can do. It's just the inheritance I can't. I'd >like then to override a method of the base class in the derived class. >(I have run makepy.py over the existing/base COM object already). Another reply suggested using delegation - ie, create a completely seperate class, and have it hold the "real" COM object. This is a good suggestion. However, to implement sub-classing you can do the following: >>> klass = win32com.client.gencache.GetClassForProgId("Excel.Application") >>> if klass is None: raise RuntimeError, "Please run makepy for this object." >>> class MyExcel(klass): ... pass Mark. From paul at prescod.net Sat Dec 18 19:54:10 1999 From: paul at prescod.net (Paul Prescod) Date: Sat, 18 Dec 1999 12:54:10 -0600 Subject: Announce: Pyxie - an Open Source XML Processing Library for Python References: <3854711d.4263700@news.iol.ie> <83b5m7$5tv$1@nnrp1.deja.com> Message-ID: <385BD852.F0B9D23@prescod.net> Robin Becker wrote: > > Can someone explain in simple terms what the real advantages of XML as > an intermediate language are? XML has the following virtues: technical: * it is text, and therefore hackable * it is relatively convenient for both document data and machine to machine data * it has a well-defined schema language (the DTD) practical: * various interesting technologies build upon it * it is a W3C and ISO standard * it is implemented in almost every programming language on almost every platform In perhaps a week we could come up with another language with all of the technical features (especially given that we could build on our understanding of XML) but the practical advantages are not likely to go away soon. And we adopt standards more for their practical advantages than for the technical one. > I'm also a bit suspicious of something which M$ seems really > enthusiastic about. M$ is enthusiastic about it because they need to do web-based data interchange and programmers were not buying into their binary-based schemes. M$ would be enthusiastic about Java for similar reasons (web-based code distribution) if it were not controlled by one of their mortal enemies. I honestly believe that Microsoft must play a different game now that the world of interconnected computers has gone so far out of their control. In the Internet market they are just another vendor and standards compliance has marketing benefit just as it would for Digital Creations or Sybase. -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself Three things never trust in: That's the vendor's final bill The promises your boss makes, and the customer's good will http://www.geezjan.org/humor/computers/threes.html From uho at pizzicato.kbbs.org Wed Dec 29 23:42:39 1999 From: uho at pizzicato.kbbs.org (Ulrich Hoffmann) Date: Wed, 29 Dec 1999 22:42:39 GMT Subject: pound bang (#!) problem... References: <3866C427.C4124694@sprint.ca> Message-ID: Orlando Vazquez writes: Hi Orlando, >If my UNIX skills serve me correctly running: > ./index.pyhtml >should be the same as running: > ./preprocessor.py < index.pyhtml >Right? But, when I do run index.pyhtm alone it just sits there and does >not read the file. I'm probably making a silly mistake, but I can't see >it.. My understanding is that in your case ./index.pyhtml is expanded to: ./preprocessor.py index.pyhtml Notice the missing redirection "<". Your program however ignores the command line argument and instead tries to read from stdin. Since this is still the keyboard, it waits for you to type something. Try to parse command line arguments and open the file to read using open and a distinct file object. (If you insist on reading stdin, then sys.stdin=open(sys.argv[1],"r") after some error checking should do the trick). Regards, Ulli From andymac at bullseye.apana.org.au Tue Dec 7 21:26:46 1999 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Wed, 8 Dec 1999 07:26:46 +1100 (EDT) Subject: Converting data to little endian In-Reply-To: <82jjc6$ks1$1@nnrp1.deja.com> Message-ID: On Tue, 7 Dec 1999 victor_ng at my-deja.com wrote: > Hi, I was wondering how to get my data to be represented in little > endian format. I know that I can use the socket functions to convert to > network byte order (big endian), but I need to convert to little endian > (not just the host byte order). module struct? -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andrew.macintyre at aba.gov.au (work) | Snail: PO Box 370 andymac at bullseye.apana.org.au (play) | Belconnen ACT 2616 Fido: Andrew MacIntyre, 3:620/243.18 | Australia From fredrik at pythonware.com Tue Dec 14 10:21:46 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 14 Dec 1999 10:21:46 +0100 Subject: Please Critique References: <3855DB3D.998F3081@mincom.com> <3855f936@194.120.211.23> Message-ID: <01af01bf4614$a625d250$f29b12c2@secret.pythonware.com> Klaus Baldermann wrote: > This could be even more perlified: > > while len(line) >= 4: > mydict.update({line[1:4]: line[0]}) ouch. that's a really inefficient way to modify a dictionary... mydict[line[1:4]] = line[0] is not only easier to decipher, but also about 10 times faster than your version... From anders.eriksson at morateknikutveckling.se Tue Dec 21 13:29:05 1999 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Tue, 21 Dec 1999 13:29:05 +0100 Subject: downloading a file Message-ID: Hello! I need a script which will log the number of times a specifik file has been downloaded. I have created a script that will do the logging but I don't know how to perform the downloading. I want it to behave like when you download a file thru the web browser. The user just select the link and gets the standard downloading question by the web browser. I have tried to use httplib but I don't know what kind of file to 'Accept' // Anders From stuart at excite.co.uk Fri Dec 10 15:52:20 1999 From: stuart at excite.co.uk (stuart mcfadden) Date: Fri, 10 Dec 1999 14:52:20 +0000 Subject: lemmings References: <82j6o3$jc6$1@news.qub.ac.uk> Message-ID: <385113A4.1B1005F2@excite.co.uk> "Magnus L. Hetland" wrote: > stuarty at excite.co.uk (stuart mcfadden) writes: > > > Where would I find a list of all the stuff that`s already been written in > > Python ? > > > > TIA, > > Stuarty > > > > p.s. Is Magnus L. Hetland truly the only person to use "snazzy" in > > documentation ? > > > > I never thought of that... > > It's not all Python documentation, but a search for > > python snazzy > > in alltheweb.com returned 344 documents. I didn't bother to read them > all to find out more, though... > > -- > > Magnus Echelon jamming noise: > Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism > Hetland Special Forces Delta Force AK47 Hillary Clinton another interseting result is snazzy hetland ..... From nhv at cape.com Fri Dec 31 17:25:31 1999 From: nhv at cape.com (Norman Vine) Date: Fri, 31 Dec 1999 11:25:31 -0500 Subject: RPM-interface/module References: <386B3CDB.FF843280@bibsyst.no> <16600370@oberon.noris.de> Message-ID: <84imcd$1m25$1@newsie2.cent.net> > >Is there a RedHat package interface/module available for Python?? > > I've been looking for that just some days ago, without result yet. There some rpm code at http://cygutils.netpedia.net/ < snipped from above link > 'RPM, the RedHat Package Manager, is a useful utility for managing the installation of complex packages. It works on most platforms; you do not need to run RedHat Linux to use rpm' Haven't used it though Norman Vine From thor at localhost.localdomain Tue Dec 28 11:43:49 1999 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 28 Dec 1999 10:43:49 GMT Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> Message-ID: On Mon, 27 Dec 1999 05:55:34 -0500, Paul Prescod wrote: >I propose that in Python 1.6 tuples be given the demonstrated features: > >>>> time = (hour=24, minute=00, second=00 ) > >(this last just demonstrates that tuples continue to work the way they >always have. There is no magic about looking at the names of >assignments) > >This proposal has the following benefits: > > * it makes a nice syntax for a 1-item tuple :) > * it makes a nice syntax for non pre-declared struct-like things > * it aligns better with the mathematical notion of tuple This is a waste of "syntax", we could have an object in a very similar fashion: t = mytime(hour = ....) > * the element referencing syntax is much clearer > * names are easier to remember and less error prone than indexes. > * it is still easy to rip them apart Is this the start of a switching to tuple-oriented programming instead of OO-programming? Is python going back to Lisp ? > >This proposal may lead some to consider the unification of tuples and >object instances, which is also a discussion worth having. No unification, every idea must have a clearly defined syntax construct. tuples are not for holding "enriched" "labelled" data, their aim is to be simple. Rich tuples may handicap further development of objects and overuse algorithms instead of algorithms+data model of OO programming. -- Manolo From doughellmann at home.com Wed Dec 8 13:22:42 1999 From: doughellmann at home.com (Doug Hellmann) Date: Wed, 08 Dec 1999 12:22:42 GMT Subject: How to create cross between __getattr__() and __getitem__()? References: <55ii4so0ljj78e6lb2tjv0s7ien861iaps@4ax.com> Message-ID: <384E4EF2.80F01626@home.com> John Lull wrote: > > I need to have both of these work with a single invocation of > queryRemoteDatabase(): > > print a.dog > print a.cat[4] > > in a system where class A cannot know ahead of time which is an > integer and which is a tuple. Why not make the call, store the return value, and test the type once you have the value? Doug From aprasad at magix.com.sg Fri Dec 31 12:40:19 1999 From: aprasad at magix.com.sg (Ajith Prasad) Date: Fri, 31 Dec 1999 19:40:19 +0800 Subject: Python not a Very High-Level Language? Message-ID: <84i4bn$rqh$1@clematis.singnet.com.sg> http://www.oreilly.com/news/vhll_1299.html is an article by Greg Wilson casting doubts on the effectiveness/value of Python and other very high level scripting languages. Wilson comments that: "Over the past few years, I have done several medium-sized projects using both Perl and Python. At first, I was very excited by what these Very-High Level Languages (VHLLs) let me do, and how quickly. The more I played with them, however, the less satisfied I was. In particular, I no longer believe that they deserve the 'V' in their name. This article explores why, and suggests some ways in which they could evolve." Worth responding to as it includes detailed criticisms of Python in particular. From cfelling at iae.nl Thu Dec 30 21:08:17 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 30 Dec 1999 21:08:17 +0100 Subject: pound bang (#!) problem... References: <3866C427.C4124694@sprint.ca> Message-ID: <84ge3h$1k6$1@vvs.superst.iae.nl> Orlando Vazquez wrote: > for simplicity's sake say this is my preprocessor (preprocessor.py): > #!/usr/local/bin/python > import sys > s = sys.stdin.read() # read until EOF and store in "s" > print s # print what we read > and my un processed file (index.pyhtml) looks like.. > #!./preprocessor.py I'm afraid the shebang thing isn't recursive. In index.pyhtml you should use something like: #!/usr/local/bin/python /perhaps-a-path/preprocessor.py > If my UNIX skills serve me correctly running: > ./index.pyhtml > should be the same as running: > ./preprocessor.py < index.pyhtml > Right? But, when I do run index.pyhtm alone it just sits there and does I'm afraid not. It is more like: ./preprocessor.py index.pyhtml so index.pyhtml ends up as a argument to preprocessor.py, therefor you have to use something like open(sys.argv[1]) in preprocessor.py as someone else already suggested. -- groetjes, carel From kuncej at mail.conservation.state.mo.us Thu Dec 9 17:20:41 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Thu, 09 Dec 1999 10:20:41 -0600 Subject: Packaging packages? Message-ID: Is there a way to collect all the python modules in a package into one file? I'm thinking of something like a "DLL for python code". It would be nice if the normal import syntax would work transparantly on such files, as well as with the standard directory-based packages. During development, modules in individual files is a convenient system. But when applications are distributed, it would really help to have the code packaged in larger units. I could go on about all the advantages, but I think the analogy to windows DLLs pretty much sums it up. I've been a big fan of Fredrik's "Squeeze" and Gordon's "Win32 Installer", but as far as I know, they pakage an entire application into one file. I'm looking for a little more modularity than that, and something that can be imported from native python. Is this already available? If not, has anyone worked on this? Does anyone else see the need? --Jeff From aahz at netcom.com Thu Dec 16 17:34:13 1999 From: aahz at netcom.com (Aahz Maruch) Date: 16 Dec 1999 16:34:13 GMT Subject: trying again: CgiHttpServer workalike for Win/NT and Win/98? References: <837o38$b65$1@serv1.iunet.it> Message-ID: <83b4a5$d5r$1@nntp3.atl.mindspring.net> In article <837o38$b65$1 at serv1.iunet.it>, Alex Martelli wrote: > >To test some CGI scripts with minimal hassle, I would like to >be able to run CgiHttpServer.py, or something similar to it, >on some Windows/NT and Windows/98 PCs. Unfortunately >for this purpose, it seems that CgiHttpServer.py itself is oriented >to Unix (e.g., it wants to fork to run the script). The /F-bot gave you an answer, but it needs a bit of fleshing: unless you specifically need to run CGI scripts, you may be better off running them as Python modules underneath Medusa (which would take some rewriting on your part); this would make OSes completely transparent. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 16 days and counting! From kno at jtan.com Thu Dec 23 00:08:35 1999 From: kno at jtan.com (Matt Dunford) Date: Wed, 22 Dec 1999 23:08:35 GMT Subject: How to read lines from end of a file? References: <4rhfhazoj4.fsf@colargol.tihlde.hist.no> Message-ID: Stig Bjorlykke writes: >Hi all. >I wonder how to read lines from end of a file, like this perl code: >open FILE, "/tmp/file"; >foreach (reverse ) { ... } >I am using it to get the latest entries in a log file. >-- >Stig Bjrlykke >Linux user why not use the reverse method in python. f = open( "/tmp/file", 'r' ); buffer = f.readlines() buffer.reverse() for line in buffer: # do what you want -- From info at odb.vrn.ru Wed Dec 15 14:41:42 1999 From: info at odb.vrn.ru (Dmitry Orishenko) Date: Wed, 15 Dec 1999 16:41:42 +0300 Subject: Calling C functions (libs) from Python Message-ID: <8385kg$cck$1@serv.vrn.ru> Hi! How i can call external C functions from Python? I don't have sources, only *.h and *.lib files. Thnx. -- Eugene Akovantsev. mailto:aei at ic.vrn.ru From roth at teleport.com Wed Dec 15 16:30:34 1999 From: roth at teleport.com (tony roth) Date: Wed, 15 Dec 1999 07:30:34 -0800 Subject: win32api question Message-ID: I do the following import win32api import win32con rk=win32api.RegConnectRegistry('blmw2ktr',win32con.HKEY_LOCAL_MACHINE) test=win32api.RegQueryValueEx(rk,"software") and I receive the following error Traceback (innermost last): File "", line 1, in ? api_error: (2, 'RegQueryValueEx', 'The system cannot find the file specified.') I'm a python newbie and I'm not sure whats wrong any advice would be appreciated thanks tr From emile at fenx.com Sat Dec 4 04:54:36 1999 From: emile at fenx.com (Emile van Sebille) Date: Fri, 3 Dec 1999 19:54:36 -0800 Subject: indentation Message-ID: <019b01bf3e0b$4a133b80$01ffffc0@worldnet.att.net> Well, if fortran counts, does RPG? there's-*so*-many-reasons-to-like-python-ly yr's -- Emile van Sebille emile at fenx.com ------------------- Mark Jackson wrote in message news:829dlk$12p$1 at news.wrc.xerox.com... > "Fred L. Drake, Jr." writes: > > > Gerrit Holl writes: > > > As i said: people who start with Python as a first language like it. > > > > There are those of us who started with x86 assembly and BASIC who > > like it too! (And Pascal, and C, and C++, and... hey, how many places > > can one person start in, anyway? ;) > > And Fortran. Don't forget Fortran. > > -- > Mark Jackson - http://www.alumni.caltech.edu/~mjackson > It doesn't matter that I'm a crab! I'm an Internet visionary! > - Hawthorne (Jim Toomey) > > > > -- > http://www.python.org/mailman/listinfo/python-list > > Emile van Sebille emile at fenx.com ------------------- From rgruet at ina.fr Fri Dec 3 14:53:17 1999 From: rgruet at ina.fr (Richard Gruet) Date: Fri, 03 Dec 1999 14:53:17 +0100 Subject: emulating `` shell operator in Python? Message-ID: <3847CB4D.8690D7E7@ina.fr> Hi there, I'm looking for a way to redirect stdout (and/or stderr) into a string to emulate the Unix shell operator ``, so that if I have a function like this one: def hello(): print 'hello, world' and I call an emulated 'backquote' function like this: s = backquote(hello) ...I'd get the string 'hello, world' in s. The problem is to implement the 'backquote' function. It should be able to take args and pass them to the function: def backquote(func, args=()) To redirect stdout and/or stderr, I could reassign sys.stdout and sys.stderr. I don't want to use an intermediate file, so I could use a StringIO (or cStringIO) to avoid this. Here is a possible implementation: def backquotefunc(func, args=()): ''' Emulate the `` Unix shell operator for a function call. ''' import sys, cStringIO f = cStringIO.StringIO() try: sys.stdout = f sys.stderr = f try: apply(func, args) finally: sys.stderr = sys.__stderr__ sys.stdout = sys.__stdout__ s = f.getvalue() finally: f.close() return s ...and it seems to work. (some improvements could be: make stdout/stderr choice parametrable, allow the called func to return its value, we then would ADD the redirected string in the returned tuple, this way backquotefunc() would look like a specialized call!) - A variant accepting a Python *command* rather than a function could be: def backquotecmd(pyCmd): ''' Emulate the `` Unix shell operator for a Python command. ''' import sys, cStringIO f = cStringIO.StringIO() try: sys.stdout = f sys.stderr = f try: exec pyCmd finally: sys.stderr = sys.__stderr__ sys.stdout = sys.__stdout__ s = f.getvalue() finally: f.close() return s - But the really tricky case is to catch in a string the output of a *shell* command, such as os.system('ls'). The above strategy doesnt work because the command executes in a sub-shell (external to python) with its own stdout and stderr. Any comment or suggestion ? Thank you Richard From python-list at teleo.net Mon Dec 13 19:15:58 1999 From: python-list at teleo.net (Patrick Phalen) Date: Mon, 13 Dec 1999 10:15:58 -0800 Subject: Locking files? n stuff In-Reply-To: References: Message-ID: <99121310343600.04942@quadra.teleo.net> [_martin_, on Sun, 12 Dec 1999] :: I've been reading up on Python for a few weeks (Learning Python) :: and was trying to get hold of the Internet programming book, but :: sadly it's out of print. Yes that is sad, but ... See http://www.python.org/psa/bookstore Check out The Quick Python Book and The Python Annotated Archives, both of which devote sections to Web programming. Lundh's the eff-bot guide to The Standard Python Library and Beazley's Python Essential Reference are also excellent general Python references. :: So can anybody help me with this? :: :: I'm writing a guestbook (and eventually counters) in Python The Quick Python Book features a guestbook with source code and annotation in the Zope chapter. From tony at lsl.co.uk Mon Dec 13 14:38:17 1999 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Mon, 13 Dec 1999 13:38:17 -0000 Subject: Python and regexp efficiency.. again.. :) In-Reply-To: <82st42$23oe$1@news.tht.net> Message-ID: <000001bf456f$50125b90$f0c809c0@lslp7o.lsl.co.uk> > On 11 Dec 1999 13:21:52 +0200, Markus Stenberg > wrote: > >Meta-language link didn't work and EBNF is bit too low-level for > my liking Tim (from Parnassus, but he likes to hide that (which is strange given the cudos he's due) - at least it ain't obvious in any of the mail headers that Outlook 98 will deign to show) - said: > VoP to the rescue! Url should be... > http://www.tibsnjoan.demon.co.uk/mxtext/Metalang.html > (the mxTextTools page accidentally has lower case 'm') Apologies about that - it's my fault, not Marc's. The URL *used* to be correct, since the previous version of the page had a lower case "m". Then I started working on the project at home on Windows95, and things tended to acquire capital letters (mostly without my requesting them - as we know, MS know how to spell better than we do), and when I updated the pages I forgot to think about this sort of thing. And Demon obviously case-preserve URL-to-file dereferencing. Ho hum. -- Tony J Ibbs (Tibs) http://www.tibsnjoan.demon.co.uk/ "How fleeting are all human passions compared with the massive continuity of ducks." - Dorothy L. Sayers, "Gaudy Night" My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From kbaldermann at entire-systems.com Tue Dec 14 09:00:14 1999 From: kbaldermann at entire-systems.com (Klaus Baldermann) Date: Tue, 14 Dec 1999 09:00:14 +0100 Subject: Please Critique References: <3855DB3D.998F3081@mincom.com> Message-ID: <3855f936@194.120.211.23> John Farrell wrote in message <3855DB3D.998F3081 at mincom.com>... >> while start < length: >> end = start + 4 >> startkey = start + 1 >> mydict[trimline[startkey:end]] = trimline[start:end] >> start = end > while len(line) >= 4: > instruction = line[0] > number = line[1:4] > line = line[4:] > mydict[number] = instruction This could be even more perlified: while len(line) >= 4: mydict.update({line[1:4]: line[0]}) line = line[4:] Klaus From nospam.python at scoobysnacks.com Mon Dec 13 01:33:22 1999 From: nospam.python at scoobysnacks.com (Shaggy) Date: Mon, 13 Dec 1999 00:33:22 GMT Subject: Newbie: need help with control loop Message-ID: <38543b80.289200819@news-server> I'm trying to write a simple program to change passwords on a large number of routers but I'm having trouble with the control loop. This may be very poor code but I've only been at this for a week. I want to do more than one router at a time so I don't have to wait for each one to finish before I start the next. I also don't want to start ALL of them at the same time. The problem I'm having is being able to create an object instance based on a list value. The list is arbitrary and may change often. Here is where I'm at. if __name__ == '__main__': list=['host1','host2','host3','host4','host5', 'host6','host7','host8','host9','host0'] running=[] for machine in range(len(list)): running = running + [list[machine]] """I want right here to create a class instance based on list[machine] and have it begin ?? list[machine]=testclass() ?? """ while len(running) >= 4 : # no more than 4 working for currentitem in range(len(running)): # # kill if done # if instance.status == ('done') : #del instance print running[currentitem], del running[0] print '' #loop to finish anything remaining in running[] Any and all help appreciated. From mstenber at cc.Helsinki.FI Fri Dec 10 10:22:24 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 10 Dec 1999 11:22:24 +0200 Subject: Python and regexp efficiency.. again.. :) Message-ID: I'm actually looking for bit of a ClueBrick(tm) regarding a system I have been writing for awhile now. The basic idea of The System(tm) is to monitor log files of various systems' different components (syslog, ..). Writing the toy in Python was very straightforward and quick process. Problems started to surface when I raised to myself a question, "is this fast enough?". As a background, I intended to use the tool to monitor fairly _heavily_ now and then spamming services, and therefore N megabytes of logs/day would be expected. Problem: ~900k log file (~10k lines) takes roughly 16 seconds to process, after optimization, with roughly 150 different things to match for (combined to one massive regexp). Initial version took half a minute. Question: Can this be optimized further? One order of magnitude optimization gain was received by writing a specialized regexp optimization tool - as the regexps are mostly of type ^commonstringuniquetail ^commonstringanothertail optimizing that to ^commonstring(?:uniquetail|anothertail) seemed to make things much snappier (and actually it could be done from tail direction as well, and with nastier substring optimizations, but I do not think the gains would be that great, as the common strings in beginning are the ~70% of the overhead. The parsing loop is something of the type compiled_regexp = re.compile(massive_regexp).search for line in lines: if compiled_regexp(line): # do things with line Getting the initial data (lines), compilation of regexp, and the actual processing of regexp result take negligible amount of time, according to profiler. The N re.search's seem to use almost all the CPU, according to pdb. And yes, it needs to be search, not match; AFAIK, doing re.match('^.*foo') is about same speed as re.search('foo'). Hmm.. actually, I'm not sure if re.match('^.*(foo|bar|baz)') is as fast as re.search('(foo|bar|baz)'). For this toy to be useful, I need to squeeze at least another 2-3x speedup out of it, and I'm bit .. uh. clueless on how to proceed next. Brute-force filtering of masses of non-interesting stuff with egrep _could_ be one option, but I'd prefer the pure-Python+m4-approach that has been good enough so far. -Markus Stenberg -- "Okay," Bobby said, getting the hang of it, "then what's the matrix? If she's a deck, and Danbala's a program, what's cyberspace?" "The world," Lucas said. -- William Gibson, "Count Zero" From aahz at netcom.com Sun Dec 5 18:59:55 1999 From: aahz at netcom.com (Aahz Maruch) Date: 5 Dec 1999 17:59:55 GMT Subject: Email address check function References: <19991202163334.A3934@stopcontact.palga.uucp> Message-ID: <82e96r$tig$1@nntp9.atl.mindspring.net> In article <19991202163334.A3934 at stopcontact.palga.uucp>, Gerrit Holl wrote: > >I'm writing some CGI scripts and I want the user to fill in their real email >address. Checking this is more difficult than just look if it contains an '@'. >There must be at least one '.' after the '@' but there must be non-'@' chars >before and after every '.', no white space, etc. There must be an RFC for >this, but is there a function in the standard library that checks if it's >OK? And, just to throw a monkey wrench in the works, some people might write their address like this: netcom.com!aahz -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Sign up now! http://www.searchbutton.com/ From cwr at cts.com Wed Dec 29 10:32:11 1999 From: cwr at cts.com (Will Rose) Date: 29 Dec 1999 09:32:11 GMT Subject: "Message file not found" References: <3865594C.1AB35459@ndh.net> <847nak$16ph$1@thoth.cts.com> <386783C9.8836E073@ndh.net> Message-ID: <84cker$u8p$1@thoth.cts.com> Stefan Schwarzer wrote: : Hello Will :) : Will Rose schrieb: :> At a guess it's a setup problem. I get (on Warp 3.0): :> :> Python 1.5.2 (#0, Jun 27 1999, 11:23:01) [VisualAge C/C++] on os2 :> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam :> >>> f=open("spam", "r") :> Traceback (innnermost last): :> File "", line 1, in ? :> IOError: [Errno 10] The file cannot be found.: 'spam' :> >>> :> :> which seems a bit more useful. But the only environment variables :> I have declared are the standard PYTHONHOME and PYTHONSTARTUP, so :> there's nothing unusual about my setup. : I tried more: : On Solaris: :>>> f=open('WWW','r') :>>> f.read() : Traceback (innermost last): : File "", line 1, in ? : IOError: [Errno 21] Is a directory : On OS/2: :>>> f=open('dist','r') # also a directory : Traceback (innermost last): : File "", line 1, in ? : IOError: [Errno 60] Message file not found.: 'dist' : In my original posting I got errorcode 10, like you for an unfound : file, now 60 for trying to open a directory as a file, so there is : a hope that the error information doesn't get lost during it's : handling. :-) Ok, I get IOError: [Errno 60] OS/2 returned error code 5: 'TMP' for the directory case. I'll mail you anything useful I can find. Will cwr at crash.cts.com From nickliz at t-online.de Mon Dec 20 02:09:15 1999 From: nickliz at t-online.de (Eide) Date: Mon, 20 Dec 1999 02:09:15 +0100 Subject: Is there an easy way to do it again? Message-ID: <83jvjd$k0r$1@news05.btx.dtag.de> I wrote a simple program to do a menial task and it works just fine, but I'm wondering what the best way is to ask the user to run it again. Do I set the whole thing in a while loop, or call the prog as a function, or what? Thanks for helping a newbie. From mikael at isy.liu.se Fri Dec 3 13:13:16 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 03 Dec 1999 13:13:16 +0100 (MET) Subject: split this newsgroup? In-Reply-To: <8282v6$8b5@mail.psy.uva.nl> Message-ID: On 03-Dec-99 Ionel Simionescu wrote: > (On c.l.py there is no month > without less than 2 loong holy wars leaving scars and bloody threads > behind... :-) Could you rephrase that? I can't parse all the negations. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 03-Dec-99 Time: 13:12:00 This message was sent by XF-Mail. ----------------------------------------------------------------------- From Alex.Martelli at think3.com Fri Dec 24 08:48:44 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Fri, 24 Dec 1999 08:48:44 +0100 Subject: Bad programming style? Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D7C@pces.cadlab.it> Carel writes: > Why not use the following: > > >>> locals()['r'] = 'ff' > >>> print r > ff > Uh, perhaps because the docs specifically tell you not to...?-) "WARNING: the contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter", is the way the Library Reference puts it; I don't see how it could be clearer. > I think this isn't garanteed to work in future versions of Python, but > it sure is crisp to me. And no hidden explosives involved at all:) > I think the quote from the docs tell me this is anything BUT "guaranteed" to work in THIS version, either -- it may well depend on the port, the phase of the moon, whatever; and if it fals it will probably fail silently, undetected, changing program semantics in hard-to-predict ways. I think this "feature" makes a good case for something I was wishing for since very early on in my (not yet very long:-) Python involvement -- a way to "lock" a mapping so that attempts to write to it will fail *non*-silently, i.e., raise exceptions. If such a 'locked' state was available, I imagine locals() would make use of it, preventing such erroneous usage. (Yeah, yeah, I know -- in the Perl community, people call this the "bondage & discipline" approach to programming, mostly with derisive intent; but I still think it's worthwhile to actively try to prevent erroneous usage when feasible -- I guess this comes from being a BDSM enthusiast?-) Alex From skip at mojam.com Thu Dec 9 17:38:25 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 9 Dec 1999 10:38:25 -0600 (CST) Subject: Packaging packages? In-Reply-To: References: Message-ID: <14415.56065.880225.522740@dolphin.mojam.com> Jeff> Is there a way to collect all the python modules in a package into Jeff> one file? I'm thinking of something like a "DLL for python Jeff> code". Yes, check with (I think) Greg Stein and/or Gordon MacMillan and/or Jim Ahlstrom. One or all of them have developed at least one Python bytecode archive that uses import hooks to search the archive for modules. If I understand things correctly, startup performance is enhanced because the number of file system operations (stats, directory reads) drops dramatically during module search. 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 paul.magwene at yale.edu Tue Dec 14 01:45:05 1999 From: paul.magwene at yale.edu (Paul M) Date: Mon, 13 Dec 1999 19:45:05 -0500 Subject: pxDislin - release 0.1 Message-ID: <83hc95$5q1$1@news.ycc.yale.edu> DESCRIPTION: ----------- pxDislin is an object-oriented wrapper around the DISLIN plotting library. DISLIN is a powerful and flexible multiplatform (Win32, Unix, Linux, etc.) library designed for displaying scientific data. DISLIN's author, Helmut Michels, has made available a DISLIN plotting extension for the Python programming language (see http://www.linmpi.mpg.de/dislin/ for more details). pxDislin provides a set of classes which represent various aspects of DISLIN plots, as well as providing some easy to use classes for creating commonly used plot formats (e.g. scatter plots, histograms, 3-D surface plots). A major goal in designing the library was to facilitate interactive data exploration and plot creation. Documentation and a demo program are included. The library has been tested on WinNT and FreeBSD, but I anticipate that it should work on any platform which can make use of Python, NumPy, and the DISLIN python extensions. Feedback, comments, and critique are gladly accepted (email: paul.magwene at yale.edu). VERSION: ------- This is release 0.1 of pxDislin. URL: ---- You can find pxDislin at: http://pantheon.yale.edu/~pmm34/pxdislin.html Paul Magwene paul.magwene at yale.edu

pxDislin 0.1 - a set of object-oriented classes which work with the DISLIN python extension. (13-Dec-99) From nasshi at tm.net Sat Dec 4 06:02:31 1999 From: nasshi at tm.net (Nasshi) Date: Sat, 04 Dec 1999 05:02:31 GMT Subject: Tutorial for a NEWBIE Message-ID: I'm a newbie, and I need a tutorial. Know of a good place to start? I just downloaded the 5.0meg executable from python.org From skip at mojam.com Tue Dec 28 05:14:13 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 27 Dec 1999 22:14:13 -0600 (CST) Subject: Py2K wishes In-Reply-To: <87ogbcuym5.fsf@den.home.net> References: <38675B72.18A139FF@prescod.net> <87ogbcuym5.fsf@den.home.net> Message-ID: <14440.14613.951856.73684@dolphin.mojam.com> Frank> Just as clearly, 'def' is an abbreviation for the noun 'define'. Was there a missing smiley? Last time I looked, "define" was a verb... 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 alex at magenta.com Fri Dec 10 00:02:36 1999 From: alex at magenta.com (Alex Martelli) Date: Fri, 10 Dec 1999 00:02:36 +0100 Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <6D8A17398E28D3119F860090274DD7DB4B3D04@pces.cadlab.it><384F8E63.95B75B21@corrada.com> Message-ID: <82pcg8$kqj$1@nslave1.tin.it> Robin Becker wrote in message rJUX$EAAr8T4EwlD at jessikat.demon.co.uk... [snip] > how do people support 'free' sites? Via advertising? Mostly, but not only. One of the sites I listed earlier does not demand advertising -- their main business is professionally building/hosting/managing sites, and they must count on their generosity and the resulting goodwill/word-of-mouth about their good services bringing them extra business in a very competitive field. Alex From mlh at vier.idi.ntnu.no Tue Dec 7 15:53:39 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 07 Dec 1999 15:53:39 +0100 Subject: Converting a Shell Script to run under Python References: <82h11e$f2p$1@gossamer.itmel.bhp.com.au> <82i6dj$b2j$1@gossamer.itmel.bhp.com.au> Message-ID: "Austin Wilson" writes: > Thanks. That worked beautifully. :) You should check out the library reference at www.python.org, and look into the os module. > > What is the command for copying file1 to file3 (eg equivalent to cp file1 > file3) How strange... I can't seem to find any intelligent command for this. Hm. You could of course read it all in and then write it out again, as in open("file3","w").write(open("file1").read()) though that is probably not a good idea. I guess I would rather do os.system("cp file1 file2") although that seems like cheating... ;) > and creating a soft link to a file (eg ln -s file2 file1)? os.symlink("file2","file1") > > Thanks > Austin -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From skaller at maxtal.com.au Wed Dec 15 19:13:05 1999 From: skaller at maxtal.com.au (skaller) Date: Thu, 16 Dec 1999 05:13:05 +1100 Subject: Viper Availability Message-ID: <3857DA31.C18C0463@maxtal.com.au> Since a couple of people have asked for a copy of Viper, here is a quick status report. An early evaluation release of Viperi (the run time test harnes/interpreter) has been posted to ftp.python.org/incoming, but has not been put up in the contrib section. In fact this directory is now completely empty, and the old contents have been moved to contrib-Dec09-1999, I do not know why. I have posted it now to: ftp://ftp.cs.usyd.edu.au/jskaller/viper_2_0_a1.tar.gz Please note this is a very temporary location. The version there is alpha 1. The '2' in the version number means this is a Python 2 compatible product. :-) Please note the LICENSE is for evaluation only: this version is free (no cost) but NOT YET public software. you can redistribute the original tarball, and you can modify the source, but you cannot redistribute the modified source, and you cannot use the product except for evaluation (at the moment). DON'T BE SURPRISED IF YOU CANNOT BUILD IT OR IT DOESN'T RUN. THIS IS SNAPSHOT OF WORK IN PROGRESS, NO CARE HAS BEEN TAKEN TO MAKE IT EASY TO BUILD OR INSTALL (at this time). Send bug reports to mailto:skaller at maxtal.com.au BINARY: you will need linux2, with /usr/local/lib/Python1.5 as the python location. Please let me know if this works at all! SOURCE: you will need * Unix or Linux * ocaml 2.02 or 2.04 (untested) from caml.inria.fr * Python 1.5 installed * Gtk 1.2 (probably, 1.2.3) * compatible C compiler (gcc/ecgs is fine) * whatever Gtk requires * gnu readline IF you have a standard (and recent) Redhat linux system, you should already have all of this except ocaml. Posix threads are required. You must build ocaml using the -pthread option. Build the Viper sources by executing the python script 'maker'. This script requires the optimised versions of ocaml, but you can edit it if you don't have them. I have built the package on Solaris, but only by commenting out all references in the source to Gtk and readline. --------------------------- Now for a Viper status report: for version alpha 2, not yet posted! (watch for announcement here) [I will wait for feedback from the first release, in case I have forgotten some files] The run time test harness (interpreter) Viperi, now has a thread module, but the interpreter is not thread safe yet [tracbacks will be jumbled, for example]. Some top level architectural rearrangement is required here. The GUI module can now do drawing, and the number of widgets supported is slowly increasing. The eventual aim is to provide a fully interactive visual debugger [and this will come quickly, because _I_ need it to test the system :-] List comprehensions have been added to the grammar, and by the time you read this article will probably be working (non-lazily). C style assignment operators are available. Rational numbers are available. C style comments are available. Sensible radix prefixed can be used, and underscores are permitted in numbers. [O777 style octal is deprecated] Lexical scoping is standard. positive strides are supported. Builtin functions have been split into two kinds: functions, which are dependent only on arguments and the definition environment, and macros, which may also access the calling environment: globals(), dir(), etc, are macros. What works? ------------ Pystone executes. {Viper is slower than CPython, but it is getting faster .. ] Interscript runs, except for the summary tables (which are invoked by __del__ methods), and the cache: this is a fairly heavy duty test! My micky mouse test codes work. The following CPython builtin modules are implemented: sys, strop, pickle, marshal, thread, re, posix, errno, struct, time In addition, traceback is replaced by a Viper module. [Do NOT expect any python AST modules or other implementation level services to work] Other 'pure python' modules work: os, string, types, exception What isn't available? ---------------------- 0) probably more than on this list :-) 1) socket is not yet implemented (easy) 2) select is not yet implemented (easy) 3) array is not yet implemented (*** see below) 4) CPython interface (may be much easier than I thought) 5) operator is not implemented (some work) 6) some class methods (__xxxx___) are not implemented 7) __del__ method do not execute [will not be available until ocaml3 is released, an earlier hack is possible] 8) re only supports matching, not splitting It doesn't support any python extensions either 9) International characters in identifiers are not checked for compliance [Any character is accepted] 10) doc strings are ignored 11) Partial evaluation is not yet completed 12) lazy evaluation is not yet completed 13) closures, interpreter objects, and other exotica are supported by the run time but cannot be accessed by the client programmer 14) continuations and coroutines [this is hard] 15) name binding only works for functions and modules, binding for classes and instances has yet to be done [name binding converts named lookups in dictionaries into indexed lookups into arrays, like CPython does with FAST-LOAD for functions] 16) operator The threading module will probably be re-implemented using native threading support. This will also include channels. Internet wide file opening. [ie. open('http://www.xxx.org/document.html') should work] What doesn't work? ------------------ 1) Marshal doesn't seem to work with interscript: interscript uses it via pickle 2) Quite a lot of functionality of CPython builtin-modules is incomplete and untested ---------------------------- *** Arrays. Viper could support the array module easily. However, there is also a NumPy array subsystem which has much more functionality. However, there is a third, interesting, alternative. Array support in Viper will be intrinsic (i.e. arrays will be a native type): this is necessary to allow optimisation, and array processing is one of the areas that can use optimisation well. I've also got a softspot for numerical programmers. There is in fact a superior mechanism for array handling called FISh based on high level category theory: this mechanism outperforms all others including hand written C and Fortran [work is being done to extend FISh to support parallel processing by load balancing based on shape analysis] It is not clear how, or whether, to integrate FISh arrays with Viper. For example, it is possible to make 'array of Something' a native type, but it is possible to do the opposite as well: make EVERYTHING an array. Also, the FISh front end uses an ML dialect, and it is not clear how (or whether) to replace this with a Python one. FISh is a code generator, so it works by partial evaluation with shape analysis, followed by generating (straight line) code which is then compiled and executed: this is much faster than using a binary library. -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From kbaldermann at entire-systems.com Wed Dec 15 14:30:14 1999 From: kbaldermann at entire-systems.com (Klaus Baldermann) Date: Wed, 15 Dec 1999 14:30:14 +0100 Subject: Help?? Struct packing of Date time not has stopped working??!?! References: <835mvi$62t$1@nnrp1.deja.com> Message-ID: <38579924@194.120.211.23> quickbbs at my-deja.com wrote in message <835mvi$62t$1 at nnrp1.deja.com>... >In other words, the client attachs, and reports: "struct.err: str size >does not match format". One of my first Python exercises was a (rdate) client. It had the problem that the read_all() sometimes returned less than 4 characters. This happened only intermittently, so I simply put a loop around the thing: line = "" while len(line) != 4: connection.open(host, 37) line = connection.read_all() connection.close Of course, this is most inelegant solution (might even take looong), and I still don't know what the reason was/is. I thought about nulls '\0', but now I think it might have to do with newlines. What will telnetlib's read_all() return if the data is containing newlines? Will it return a string with embedded \n's or a list of strings, like a file's readlines() method? yours Klaus From jkraai at murl.com Sat Dec 4 00:10:01 1999 From: jkraai at murl.com (jim kraai) Date: Fri, 03 Dec 1999 17:10:01 -0600 Subject: Naive Question Message-ID: <38484DC9.3FF755EB@murl.com> Greetings, If I have: class contrived_collection: def __init__(self): self.item = [{1,2},{3,4},{5,6}] a = contrived_collection() b = a.item[2] How can I ask b what it is a member of? I need to somehow know later in processing that: 1. b is a member of a.item 2. a.item is a member of a Thanks, --jim From greg.ewing at compaq.com Thu Dec 2 11:34:36 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 02 Dec 1999 23:34:36 +1300 Subject: Does this code create a circular reference ? References: <8216ih$2ki@mail.psy.uva.nl> Message-ID: <38464B3C.211A394E@compaq.com> Ionel Simionescu wrote: > > class child: > def __init__(self, parent): > self.parent = parent > def do_something(self): > pass > class headache: > def method(self): > a_child = child(self) > a_child.do_something() As long as a_child.do_something() doesn't cause a reference to a_child to be stored in its parent (or grand-parent, etc.), there is no problem. When headache.method() returns, its local references will disappear, and the child will be deallocated. No aspirin required. Greg From robin at jessikat.demon.co.uk Thu Dec 23 20:22:47 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 23 Dec 1999 19:22:47 +0000 Subject: Please test new dynamic load behavior References: <38620B04.7CC64485@trema.com> Message-ID: In article , Greg Stein writes .... >> ... >> >> What was the motivation behind this modification? > >Harri - > >With the new code structure, it is much easier to maintain Python's >loading code. > >Each platform has its own file (e.g. dynload_aix.c) rather than being all >jammed together into importdl.c. This isn't a huge win by itself, but does >increase readability/maintainability. The big improvement, however, is >when you are adding support for new platforms or loading mechanisms. A new >dynload_*.c can be written and one line added to configure.in, and you're >done. No need to make importdl.c even uglier. (actually, importdl.c no >longer contains *any* platform specific code; it has all been moved to the >dynload_*.c files) > >Cheers, >-g > ok so presumably the selection logic now is in the config.in/makefile.in and as that's already there, this is a win. -- Robin Becker From boncelet at udel.edu Wed Dec 15 11:20:35 1999 From: boncelet at udel.edu (Charles Boncelet) Date: Wed, 15 Dec 1999 10:20:35 +0000 Subject: Python complaints References: Message-ID: <38576B73.59C7BA85@udel.edu> Mike Fletcher wrote: > > for first, second, third in [ > (a/x, a**2, y) > for a in listone, > for y in [(l3val**4) for l3val in listthree], > for x in [(2**math.PI**l4val) for l4val in listfour], > ]: > print first, second, third > > Or something similar is probably what people are hyped about. I.e. complex > parallel processing of multiple lists with multiple levels of comprehension > (ww?). Note, I'm sure someone will want to add "for i indexing x in []" > syntax to this construct :) . Well, I like this syntax a helluva lot more than map(lambda x: f(x), list) etc. But I wonder if adding these things might take Python too far down the dark side. However, if adding list comprehension allows Python to remove lambda and map, then maybe that's a risk worth taking... However, I often want more list processing functionality: Eg. >>> from math import sin >>> sin([1,2,3]) returns a "TypeError: illegal argument type for built-in operation" (instead of saying "sin() requires a single number for an argument, not a list", but that's another story) rather than what I wanted: [sin(1), sin(2), sin(3)] (Note, if I said "from Numeric import sin" it works just fine.) I think all functions that operate on single things should be able to operate on a list of things and return a list of things. (Are there obvious reasons why this paradigm can't work?) Consider, >>> l = [1,2,3] >>> m = [l,l] >>> len(l) 2 >>> len(m) 3 I want len(m) to return [3,3]. And I want: max(len(m)) to return 3, etc. (Yes, I know I can write my version of len and have it return whatever I want it to, but I am wondering about the paradigm and why it is not generally true.) -- Charles Boncelet University of Delaware Newark DE 19716 USA http://www.eecis.udel.edu/~boncelet/ From jima at aspectdv.com Tue Dec 14 01:02:57 1999 From: jima at aspectdv.com (Jim Althoff) Date: Mon, 13 Dec 1999 16:02:57 -0800 Subject: Suitability of Python for a Big Application? In-Reply-To: <83181a$n90$1@ssauraab-i-1.production.compuserve.com> References: <830vic$r2t$1@nnrp1.deja.com> Message-ID: <4.2.0.58.19991213155935.00b194f0@mail.aspectdv.com> Or you could consider JPython. JPython lets you use both Java and Python nearly seemlessly. You can program in Python but still take advantage of the entire Java API set. If necessary, you can write some of the speed-critical pieces in Java. Mixing Java and Python in JPython requires virtually no work. BTW, I was faced with a situation similar to yours and decided to go with JPython. So far, I am happy with the choice. Jim At 10:59 PM 12/12/99 +0100, Olaf Appelt wrote: >I'm new to Python, so take this with some salt. > >I like Python, but I don't think it's well suited for large projectes. Also >it lacks in the speed department. >Also, I believe that it's lack of type safety and access restrictions, which >is a bonus for small projects beccomes a liability in large, >multi-programmer projects. > >Given your requirements I would go with Java + C++. Most work should be done >with Java, with a few speed critical modules done in C++ integrated via JNI > >That way you get your portability, speed and flexiblity. > >Also the skills of your development team should be considered. You didn't >mention whether everybody is experienced with Python, but given the tone of >your questions and general skill distribution, I guess that again going with >Java/C++ you'd be better off than with Python. > >A possible alternative might also be Smalltalk (again for flexibility, >portability and speed), but again there's the problem with available >programmer skills. If your team has to learn Smalltalk first, it's not >realistic given the time frame. > > >Olaf > > > >-- >http://www.python.org/mailman/listinfo/python-list From e.e.sutton at cummins.com Wed Dec 15 17:25:23 1999 From: e.e.sutton at cummins.com (e.e.sutton at cummins.com) Date: Wed, 15 Dec 1999 16:25:23 GMT Subject: Where can I find info on using Python w/ Windows Scripting Host Message-ID: <838fdd$6od$1@nnrp1.deja.com> Where can I get info on Python for use under Windows? I am especially interested in a version that can run under the Windows Scripting Host. I am evaluating various scripting languages for use on the Windows platform. I expect we will end making VBScript the company standard but I wanted to evaluate Python and TCL/TKL as well. Thanks in advance, -Ed Sent via Deja.com http://www.deja.com/ Before you buy. From amitp at Xenon.Stanford.EDU Wed Dec 22 22:44:03 1999 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 22 Dec 1999 21:44:03 GMT Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <385EFB90.4EFC4C0F@Lugoj.Com> <14431.48791.513755.655775@buffalo.fnal.gov> Message-ID: <83rgn3$3t3$1@nntp.Stanford.EDU> Charles G Waldman wrote: | | How about this variation? | | eval({1:"a_expr(args)", 0:"b_expr(args)"}[not not c]) | Shortens to: eval(["b_expr(args)", "a_expr(args)"][not c]) ;-) Amit From ionel at psy.uva.nl Wed Dec 15 13:29:55 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Wed, 15 Dec 1999 13:29:55 +0100 Subject: problem with an infinite loop Message-ID: <8381in$de3@mail.psy.uva.nl> Hi, The code below represents an erroneous snippet that crashes Python (1.5.2/WinNT) in a very reproductible manner. Maybe this kind of error can be intercepted by the interpreter and raise an exception. ionel --- # I know this code is bad. class node: def __init__(self, name=''): self.name = name def __setattr__(self, name, value): if name=='name': self.name = value f = node() From mlh at vier.idi.ntnu.no Tue Dec 7 01:14:30 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 07 Dec 1999 01:14:30 +0100 Subject: Converting a Shell Script to run under Python References: <82h11e$f2p$1@gossamer.itmel.bhp.com.au> Message-ID: "Austin Wilson" writes: > Hi > > I was hoping someone may be able to help me convert the following Shell > Script to perform the same functions under python. Basically it just reads a > filename which is stored in file1 and then renames file2 to that name. I suspect you'll get several responses in parallel here, but that's just the spirit of c.l.p :) > > #!/bin/sh > read name < file1 > mv file2 $name > rm file1 #!/usr/bin/env python import os name = open("file1").read() os.rename("file2",name) os.remove("file1") (Remember not to put a newline character after the filename in file1... :) > > Thanks > Austin > -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From gerrit.holl at pobox.com Thu Dec 23 22:32:48 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 23 Dec 1999 22:32:48 +0100 Subject: TMTOWTDI In-Reply-To: <83trlo$8ka$1@nntp9.atl.mindspring.net>; from aahz@netcom.com on Thu, Dec 23, 1999 at 07:03:20PM +0000 References: <19991223151828.A3636@stopcontact.palga.uucp> <1266159968-30845431@hypernet.com> <83trlo$8ka$1@nntp9.atl.mindspring.net> Message-ID: <19991223223248.A9749@stopcontact.palga.uucp> Hi, > Uh-oh. Are we headed for TMTOWTDI? also for Python, it's sometimes true: >>> print "a"+str(os)+"b" ab >>> print "a%sb" % os ab regards, Gerrit. -- "People get annoyed when you try to debug them." -- Larry Wall (Open Sources, 1999 O'Reilly and Associates) 10:15pm up 11:33, 13 users, load average: 0.14, 0.07, 0.02 From neelk at brick.cswv.com Wed Dec 1 02:56:47 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 1 Dec 1999 01:56:47 GMT Subject: predicate classes References: <81uo0t$2rr$1@nnrp1.deja.com> Message-ID: Justus Pendleton wrote: >I decided to broaden my horizons so I was reading about/playing around with >Cecil. One of the things Cecil has that I hadn't heard of before are >predicate classes: > >(http://www.cs.washington.edu/research/projects/cecil/cecil/www/www/Papers/ > predicate-classes.html), which I thought were nifty beyond all belief. Good for you! I like Cecil a lot, too. You might also be interested in Self (http://self.sunlabs.com) -- it implements dynamic inheritance, which is one of the motivations for Chambers' invention of predicate classes. >I also thought it would be nifty if Python had them so I got the source >from the CVS respository and started hacking the grammar and realized I >had no idea what I was doing :-). > >Before getting in any deeper in something I only vaguely understand I >thought I would ask the opinions of people who know more about Python >than I whether they think it would be easy/hard/well-damn-nigh-impossible >to add this kind of dynamic retyping of objects based on predicates. Fortunately, you don't need to hack the Python source in order to experiment with dynamic inheritance or predicate classes in Python, because you can change a class's inheritance tree by assigning to a class's __bases__ attribute at runtime. Here's a quick, rather kludged-together example: class Foo: x = 4 class Bar: predicate = 1 __bases__ = (Foo,) # def __setattr__(self, name, value): if name == 'predicate': self.__class__.predicate = value if value: self.__class__.__bases__ = (Foo,) else: self.__class__.__bases__ = () At the interpreter prompt: >>> s = Bar() >>> isinstance(s, Foo) 1 >>> s.x 4 >>> s.predicate = 0 >>> isinstance(s, Foo) 0 >>> s.x Traceback (innermost last): File "", line 1, in ? AttributeError: x Whether or not s, the instance of Bar, inherited from Foo depends on what the value of Bar.predicate was. Note that this isn't the same thing as real predicate dispatch, yet, since different instances of Foo can't have different virtual classes. To make that work, you would need to create a custom sequence object for your __bases__ object and hack together a metaclass to install it cleanly. This isn't a simple project, but fortunately, it's not a big job either -- most of the work is conceptual rather than writing reams of code. It will also be lots of fun; my current Python project right now is writing a multimethod class for Python and I can vouch for the hack value of something like this. Some day in the future, *after* you have a good idea of what semantics you want to implement, you can create a C extension type implementing predicate classes and then extend the interpreter. But that's for later; first prototype it in Python itself before wasting time writing C code. Remember you won't know what the right thing is until you've used your metaclass in a variety of projects, and you will feel much easier about modifying and rewriting a Python class than a C extension. >(I did a quick search on deja and didn't find any talk about this, so >apologies in advance if this is something that has been as talked to >death as the indentation thing.) Not at all! Cecil, Dylan and Self are all great languages to use to discover Pythonic features in. :) Neel From bruce_dodson.nospam at bigfoot.com Sun Dec 12 21:01:04 1999 From: bruce_dodson.nospam at bigfoot.com (Bruce Dodson) Date: Sun, 12 Dec 1999 16:01:04 -0400 Subject: win32com: subclass a com object? References: <830pi6$n4k$1@nnrp1.deja.com> Message-ID: COM is not simpler in Python than it is in VB, if by COM you mean ActiveX automation. That is VB's native format for objects, whereas in Python it is just that the language is flexible enough to make it seem native. However, sometimes Python makes it easier to implement some piece of functionality than it would be in VB. Python has a richer standard library of its own plus access to VB's libraries through COM. And the language is more flexible yet than VB. The two languages are about equally quirky. VB is a good language to know alongside Python. If you were on a budget or were passively anti-microsoft, Python would be a good choice for COM development. WBD tiddlerdeja at my-deja.com wrote in message <830pi6$n4k$1 at nnrp1.deja.com>... >Also, an aside question about win32com. Would someone use win32com just >to avoid paying for a VB license to develop COM object? Or are there >actual benefit to scripting COM in python? Is COM simpler in python? From sashaNOsaSPAM at ofoto.com.invalid Tue Dec 28 00:08:40 1999 From: sashaNOsaSPAM at ofoto.com.invalid (sven) Date: Mon, 27 Dec 1999 15:08:40 -0800 Subject: COM exceptions Message-ID: <05108cf7.cd1ab828@usw-ex0102-015.remarq.com> A question for any and all Python/COM experts: I'm writing a multi-threaded app (under WinNT using the threading module) that makes heavy use of a third party COM component. Occasionally the component will throw an OLE Error, which bubbles up to my code as a pywintypes.com_error. I can't figure out how to gracefully handle these things. When any thread encounters one of these, *all* the threads stop (however, the main interpreter thread does not exit). I've tried looking for dead threads and restarting them (or replacing them with new ones with the same target), but apparently these 'stopped' threads are still considered alive. I'm not sure if this is a threading issue, a COM issue or some fiendish combination of the two. Any thoughts? Thanks for your time. Sasha * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * The fastest and easiest way to search and participate in Usenet - Free! From mk_999 at my-deja.com Tue Dec 7 14:51:04 1999 From: mk_999 at my-deja.com (mk_999 at my-deja.com) Date: Tue, 07 Dec 1999 13:51:04 GMT Subject: 500 Internal ... not the same of Dan Message-ID: <82j3c6$87h$1@nnrp1.deja.com> Well, I'm a newbie of Python and reading always this message is frustrating, because there is no error in my code (I suppose). I wrote a little code to upload files and register data on a database (Oracle 8.0.4) using DCOracle. (plus Apache Web Server on Linux) Sometimes doing this operation it shows me that message (INTERNAL SERVER ERROR), but it works!!!!! if I control in the destination directory the file is uploaded and in the database a new record is regularly registered. Refreshing the page, sometimes it shows the correct page, others not, but it always add new records. I used traceback (not so usefull in this case), and verified syntax on command line (it seems all right). I would be glad if someone showed me which way I can follow to solve this problem. There could be something wrong about the SQL, but why does it execute the code anyway?!? Here there is the function used to connect def db_update(product, title, author, descr, path): try: dbc=DCOracle.Connect("***/***@***") if dbc: cur=dbc.cursor() #get cursor if cur: stm = "INSERT INTO dev.procedure VALUES ( '%s', '%s', '%s', '%s', TO_DATE(sysdate,'DD-MM-RRRR') ,'%s')" % (prodotto, title, author, descr, path) #print stm cur.execute(stm) else: print 'Invalid SQL statement' cur.close() dbc.close() else: print 'Unable to connect to db' except: print 'Error on connection' if dbc: if cur: cur.close() dbc.close() Sent via Deja.com http://www.deja.com/ Before you buy. From tpchang at excite.com Wed Dec 29 08:46:27 1999 From: tpchang at excite.com (tpchang at excite.com) Date: Wed, 29 Dec 1999 07:46:27 GMT Subject: Python native compiler on NT Message-ID: <84cdo5$9u0$1@nnrp1.deja.com> I wonder if there is a Python native compiler for NT. This will help me to sell Python to people in my company who are more familiar with .exe files than the .py files :-) Thanks in advance, Ben Sent via Deja.com http://www.deja.com/ Before you buy. From philh at vision25.demon.co.uk Tue Dec 14 01:50:45 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Tue, 14 Dec 99 00:50:45 GMT Subject: XML parsing References: <945048362snz@vision25.demon.co.uk> Message-ID: <945132645snz@vision25.demon.co.uk> In article mgushee at havenrock.com "Matt Gushee" writes: > philh at vision25.demon.co.uk (Phil Hunt) writes: > > I am getting an error because my input file starts with > > > but xmllib checks for this and raises an exception because it > > isn't version 1.0. > > > > Is there any way to get xmllib to attempt to do something > > sensible when it gets input it doesn't like, rather than just > > raising an exception and refusding to read the file? > > Uh, first of all, could I ask why your input file starts with version="1.1"?> Because it is what I am getting from the URL http://www.theregister.co.uk/tonys/slashdot.html In spite of its name this is a RSS file (version 0.91). > -- since there isn't any such thing yet ... AFAIK > there isn't even a working draft for XML 1.1. *Please* don't tell me > somebody's going off and trying to create their own 'improved' version > of XML -- that's exactly how HTML got ruined. It wouldn't surprise me. > If it were me, I'd want to have a conversation with the producer(s) of > the documents about what is and is not XML. Or if their authoring > tools are at fault, find whoever programmed those tools and give them > an earfull. > > But if you must accommodate this garbage, you might try writing your > own XMLParser class: > > import xmllib > > class XMLParser(xmllib.XMLParser): > > ## and define only the following method -- which you can cut and > ## paste from xmllib.py, editing only the line that says > ## if version[1:-1] != '1.0': > > def goahead(self, end): Yeah, that did occur to me -- I was hoping to do it a bit more elegantly. Oh well, if it works... > Hope this helps a bit. Oh, and if you happen to be part of a > super-secret group within the W3C that is, unbeknownst to the unwashed > masses, actually working on XML 1.1, I apologize for the above rant. Our dastardly plot has been uncovered at last! :-) -- Phil Hunt - - - phil at comuno.com "Software is like sex, it's better when it's free" -- Linus Torvalds From kern at caltech.edu Wed Dec 22 07:43:24 1999 From: kern at caltech.edu (Robert Kern) Date: Wed, 22 Dec 1999 06:43:24 GMT Subject: __rcall__??? References: <000a01bf4b38$35da1640$b3a0143f@tim> <385FB976.3F05FD33@math.okstate.edu> Message-ID: <3860720e.120478566@news.erols.com> On Tue, 21 Dec 1999 11:31:34 -0600, "David C. Ullrich" wrote: > > >Tim Peters wrote: > >> [...] >> >> > What's the story on __rpow__, natural-wise? I have a book that >> > lists all the magic methods but leaves out __rpow__. Was that >> > just an omission in the book, or did __rpow__ get added some time >> > after version 1.3 (the version in the book)? >> >> 1.3 predates my reliable memory -- if I'm not mistaken, that's even earlier >> than 1.4, which latter not even Guido remembers . Section 3.3.6 >> ("Emulating numeric types") of a current Language Reference Manual tells the >> full story on __rpow__. > > Does it? I must be a version behind again or something, "Emulating numeric >types" is 3.3.5 here. Before I spend time trying to catch up: Are you saying >that >the current 3.3.6 tells the full story, including the answer to the question I >asked about the _history_, when __rpow__ was introduced? No. Try looking in the ChangeLog and HISTORY files in the source distribution for the history. And, FWIW, you are a version behind on the documentation. >> >> > If the latter, I'd like to say that when I saw no __rpow__ in >> > the book I decided I couldn't do what I was trying to do that day >> > (I've got my own clumsy __rcall__ working but I don't know how >> > I'd do __rpow__ by hand the same way) - when I found __rpow__ >> > in the docs I decided that project was doable. It seems clear that >> > there's no need for an __rpow__, but I've used it several times. >> >> __rpow__ is clearly needed to implement new "numeric" types, which latter >> many people did ask for. Note that it's a bit of a strain, though: __pow__ >> takes an optional 3rd argument, > > Again, does it? A few weeks ago 1.5.2 was the latest version - there the >docs say that __pow__ takes a third argument but the interpreter disagrees. >Well, of course I can make __rpow__ take whatever arguments I like, >but the point is to implement pow, and pow seems to barf on a third >argument: > >>>> pow(2,2) >4.0 >>>> pow(2,2,2) >Traceback (innermost last): > File "", line 1, in ? >TypeError: 2-sequence, 3-sequence >>>> > >This would be the Windows 1.5.2. I read that the next version >would be 1.6 and it wasn't due for a while - am I behind again >or what? Not sure. This is what I get (Windows 1.5.2, freshly downloaded): Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> pow(2,2) 4 >>> pow(2,2,2) 0 >>> [snip] Robert Kern kern at caltech.edu From bitbucket at isomedia.com Tue Dec 28 08:15:11 1999 From: bitbucket at isomedia.com (Eugene Goodrich) Date: Tue, 28 Dec 1999 07:15:11 GMT Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> <19991227235513.A917@Ridcully.home> <848sak$1a2$1@vvs.superst.iae.nl> Message-ID: <38686359.191704606@news.isomedia.com> I vote we should adjust English to, er, define "def" as something we like better. It would break less scripts... -Eugene On 28 Dec 1999 00:21:56 +0100, Carel Fellinger wrote: >Malcolm Tredinnick wrote: >> On Mon, Dec 27, 1999 at 07:28:34AM -0500, Paul Prescod wrote: > >>> Kidding aside, "class" is a noun and "def" is an abbreviation for a >>> verb. Furthermore, "def" is way too generic. Python has class >>> definitions and function definitions. The keywords should be >>> "func"/"function" and "class". > >> To console yourself, just think, it could have been worse: Guido may have >> chosen Dutch keywords. :-) > >But he has! And both are abbreviations too. >def an abbreviation of the imperative definieer, and >class again an abbreviation, now from the imperative classificeer > >> He who laughs last thinks slowest > >And he keeps on laughing has eternal joy > >-- >groetjes, carel import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==') From tim_one at email.msn.com Mon Dec 13 11:05:27 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Dec 1999 05:05:27 -0500 Subject: some random reflections of a "Python newbie": (2) language issues In-Reply-To: <82qoq8$nbd$1@nnrp1.deja.com> Message-ID: <000b01bf4551$944ff9c0$9e2d153f@tim> [alex at magenta.com] > ... > The only problem with not looking at __getitem__'s "key" > parameter seems to be that there is no way to "restart > from the beginning" -- but I guess one could easily > special-case-interpret a key of 0 to mean that. E.g.: > > class fib: > "Enumerate the rabbits of a guy from Pisa" > def __init__(self): > (self.old, self.lat) = (0, 1) > def __getitem__(self, key): > if key==0: > self.__init__() > return self.old > new = self.old+self.lat > (self.old, self.lat) = (self.lat, new) > return self.old > > Now, > >>> rabbits=fib.fib() > >>> for i in rabbits: > ... if i>100: break > ... print i > does work as I thought it should. > > [... and more about enumerators ...] The for/__getitem__ protocol was really designed for sequences, and it's a strain to push it beyond that. This kind of stuff is cool, but after a few years you may tire of it <0.7 wink>. Here's a __getitem__ I've got sitting around in a Set class, that represents a set of values via a dict self.d: def __getitem__(self, i): if i == 0: self.keys = self.d.keys() return self.keys[i] Even that's a bit of a strain, but it does nest correctly -- albeit by accident . > ... > However, there is one little problem remaining... being > an enumerator doesn't let the object support nested loops > on itself, which a "real" sequence has no problems with. Exactly. > If the object "can give out an enumerator" to itself, > rather than keeping state itself for the enumeration, > it would be more general/cleaner. (At least) The same options are available in Python as in C++. The relative burden of method overheads being what they are, though, the aforementioned Set class also has a method that's much more heavily used than Set.__getitem__: # return set members, as a list def tolist(self): return self.d.keys() That is, for/in works much faster on a native sequence type, so I generally have a "tolist" or "totuple" method and do "for thing in collection.tolist():". That doesn't work at all for unbounded collections (like your rabbits), but is fast and obvious for most collections. > I guess I can live with that through an "enumerator" func, > somewhat like (if I define __enumerator__ to be the > "give-out-an-enumerator" method): Note that double-double-underscore names are technically reserved for the implementation (i.e., Guido may stomp on any such name in a future release). > def enumerate(obj): > try: > return obj.__enumerator__() > except: > try: > return obj[:] > except: > return obj > > (not ideal, sure -- I actually want to give out the obj > if it's an immutable sequence [can I rely on its having > __hash__ for that...?], Classes only have __hash__ if the user defines it. Contrarily, some mutable objects do define __hash__; e.g., back to that surprisingly educational Set class: def __hash__(self): if self.frozen: hashcode = self.hashcode else: # The hash code must not depend on the order of the # keys. self.frozen = 1 hashcode = 0 _hash = hash for x in self.d.keys(): hashcode = hashcode ^ _hash(x) self.hashcode = hashcode return hashcode This makes it possible to have Sets of Sets (& so on), although putting a set S in a set T freezes S. The mutating methods of Set complain if self.frozen is true. Most times I lazier than that, though, and pass out hashes without any protection. The point is that people can & do abuse everything in the language in all conceivable ways -- and in quite a few that aren't conceivable. There's almost nothing you can count on without exception. > slice it if it's a mutable one, etc, but, basically...), so I can > have a loop such as "for x in enumerate(whatever):" which _is_ > polymorphic _and_ nestable. > > _WAY_ cool...!!! > > Btw, a request for stylistic advice -- am I overusing > try/except in the above sketch for "enumerate"? Python > seems to make it so easy and elegant to apply the good > old "easier to ask for forgiveness than permission" idea, > that my C++-programmer-instincts of only using exceptions > in truly exceptional cases are eroding fast -- yet I see > that recommendation in Guido's own book (p. 192 -- soon > belied by the example on p. 194 that shows exceptions > used to implement an anything-but-exceptional typeswitch, > but...). Maybe in a smoothly dynamic language such as > Python keeping "exception purity" is not such a high > priority as in C++ or Java...? You'll note that the docs rarely mention which exceptions may be raised, or when or why; I'm still unsure whether that's Good or Bad! In the case of checking an object for __enumerator__, that's what hasattr was designed for, so most people would instead write if hasattr(obj, "__enumerator__"): ... But there's no way to test for whether obj[:] is possible without trying it, so try/except is your only choice there. The Types-SIG archive (from about a year ago) has many delightful words about all this . > How would/should I implement "enumerate" without so much > reliance on try/except, i.e. by explicitly testing "does > this object have an __enumerator__ method that can be > called without arguments, or, if not, can I slice it to get > a copy, or, ...", etc...? In C++ I guess I'd do a > dynamic_cast<> for this kind of thing (assuming inheritance > from suitable abstract classes) -- what's the "best" Python > idioms, and what are the trade-offs here...? A dynamic language presents a great temptation to hyper-generalization. Resist it! Not for your sake so much as for ours -- we'll never be able to understand your code. If you want to define a new all-encompassing protocol (like __enumerate__), chances are excellent you're the only person in the world who will use it -- much as if 8 groups within a department are using C++, they'll maintain at least 16 incompatible array classes <0.5 wink>. If it's something you can't live without, then-- as its likely sole user --the tradeoffs are entirely up to your judgment. Indeed, *I'm* the world's only user of my Set class: everyone else just manipulates a dict explicitly! "Programming infrastructure" classes & frameworks have a much bigger audience in C++/Java, and for good reasons: it takes many more lines of code to get something done in the latter. An enumerator in Python usually takes no more than 4 lines of dirt-simple code, so people instinctively realize it would take longer to read & understand the __enumerator__ docs than to roll their own one-shots 100 times over. That's why Python is so productive: nobody spends any time reading docs . >> [1.6 is supposed to add a __contains__ method] > Oh my -- I even guessed the *name* of the special method > needed...?!-) That cuts it, I guess -- Python and I were > just _made_ for each other!-). Python was made for everyone equally, Alex -- although I am pleased to say you do seem to be *especially* equal . python-farm-ly y'rs - tim From parkw at better.net Sun Dec 12 12:05:21 1999 From: parkw at better.net (William Park) Date: Sun, 12 Dec 1999 06:05:21 -0500 Subject: Suitability of Python for a Big Application? In-Reply-To: <830vic$r2t$1@nnrp1.deja.com> References: <830vic$r2t$1@nnrp1.deja.com> Message-ID: <19991212060521.A404@better.net> On Sun, Dec 12, 1999 at 08:11:57PM +0000, bobyu5 at mailcity.com wrote: ... > But it does not for now, so I settled down on Python; however, I have 2 > remaining issues on Python. I think you made the right choice. > > 1) GUI library: I tried to look at TK library and the look and feel was > not as sleek as what comes with Windows; plus it felt very slow. > 2) Math operation: there is a possibility that some heavy duty > calculation would have to be performed on around 100,000 rows of data > using Python - how slow would this be? > 3) Heavy duty text processing using regexp (at least 40MB big)- I know > Perl is really fast in this regard; is Python as fast? > > For 1) I thought I could solve this problem by using Zope - I get > instantly a GUI that is based upon web browsers. This eliminates those > annoying installation problems with customized DLLs as I found out using > VB development approach. I can't help you here. I tried to read Zope's documentations, but I couldn't make head or tail out of it. > > For 2) I am hoping that the Python Math Lib exists and that it is very > good. There is NumPy package which is wrapper around Fortran libraries. But, it's usually for vector, matrix, and linear system stuffs. There are other numerical modules written by many people. If you are talking about arithmatic math, then even native Python code will suffice. > > For 3) I am also hoping that Python Regexp Lib is good. Python 're' module probably is not as fast as Perl's. But, it's decent. > > Are my assumptions valid? Am I missing anything? Originally we wanted to > have Outlook like UI - is this kind of UI possible to build using Python > and its libraries? > > Everybody seems to be using C++ or Java for projects of this scope; has > anybody tried to do something similar using Python, or even Perl? > > Any anecdotes or recommendations would be heartily appreciated! From mlh at vier.idi.ntnu.no Tue Dec 21 18:20:27 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 21 Dec 1999 18:20:27 +0100 Subject: List comprehensions References: Message-ID: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) writes: > PS I'd like to have a stronger visual separation between the result > expression, and the iterations and conditions, so '|' looks better to me > than ',' . > This is especially true if you do not start with an iteration, like in > > [ x>6, x>5 ] > > (Bonus-points for the people who understand what the result is > :-) ) How could you tell, as long as you haven't defined an order over, or even a range for x? The result could be practically anything. > > Albert -- Magnus Lie Hetland From kuncej at mail.conservation.state.mo.us Thu Dec 2 17:34:07 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Thu, 02 Dec 1999 10:34:07 -0600 Subject: how to get methods from COM objects Message-ID: >Can anybody tell me how to extract methods from a COM object. >For instance i=B4d like to know what methods internet explorer exposes, >so i can direct IE from within python. As Bernhard said, pythonwin has built-in tools (COM browser and makepy) to see what COM servers and methods are available on your system. However, to get more detailed information about the COM objects and methods, you have to get documentation from whoever produced the particular COM server. It is usually on the net, but not always easy to find. The internet really needs a "COM Documentation Clearinghouse"! Here are some starting points for documentation on MSIE COM: http://msdn.microsoft.com/workshop/browser/webbrowser/reference/ifaces/IWebBrowser2/IWebBrowser2.asp#IWebBrowser2 http://msdn.microsoft.com/workshop/author/dhtml/reference/objects.asp#om40_objects http://msdn.microsoft.com/workshop/browser/mshtml/reference/ifaces/Document2/document2.asp For an example of controlling IE with Python and COM, see: msiecom.py at http://starship.python.net/crew/jjkunce/ --Jeff From thomas at bibsyst.no Wed Dec 29 15:21:27 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Wed, 29 Dec 1999 15:21:27 +0100 Subject: Module-repository References: <386A02A2.5CB32ED9@bibsyst.no> <84ctcp$88k$1@news.glas.net> Message-ID: <386A18E7.99420D1E@bibsyst.no> ilya at glas.net wrote: > > http://www.vex.net/parnassus > > > Just wondering why there`s no module repository for Python, like ... eh > > ... Perl has in CPAN?? How hard can that be? Just some space to upload > > modules and some sort of folder-structure would be enough, at least for > > starters. Hey!! I must have been asleep when this was announced. Great !! Thomas From ullrich at math.okstate.edu Tue Dec 21 18:31:34 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 21 Dec 1999 11:31:34 -0600 Subject: __rcall__??? References: <000a01bf4b38$35da1640$b3a0143f@tim> Message-ID: <385FB976.3F05FD33@math.okstate.edu> Tim Peters wrote: > [...] > > > What's the story on __rpow__, natural-wise? I have a book that > > lists all the magic methods but leaves out __rpow__. Was that > > just an omission in the book, or did __rpow__ get added some time > > after version 1.3 (the version in the book)? > > 1.3 predates my reliable memory -- if I'm not mistaken, that's even earlier > than 1.4, which latter not even Guido remembers . Section 3.3.6 > ("Emulating numeric types") of a current Language Reference Manual tells the > full story on __rpow__. Does it? I must be a version behind again or something, "Emulating numeric types" is 3.3.5 here. Before I spend time trying to catch up: Are you saying that the current 3.3.6 tells the full story, including the answer to the question I asked about the _history_, when __rpow__ was introduced? > > > If the latter, I'd like to say that when I saw no __rpow__ in > > the book I decided I couldn't do what I was trying to do that day > > (I've got my own clumsy __rcall__ working but I don't know how > > I'd do __rpow__ by hand the same way) - when I found __rpow__ > > in the docs I decided that project was doable. It seems clear that > > there's no need for an __rpow__, but I've used it several times. > > __rpow__ is clearly needed to implement new "numeric" types, which latter > many people did ask for. Note that it's a bit of a strain, though: __pow__ > takes an optional 3rd argument, Again, does it? A few weeks ago 1.5.2 was the latest version - there the docs say that __pow__ takes a third argument but the interpreter disagrees. Well, of course I can make __rpow__ take whatever arguments I like, but the point is to implement pow, and pow seems to barf on a third argument: >>> pow(2,2) 4.0 >>> pow(2,2,2) Traceback (innermost last): File "", line 1, in ? TypeError: 2-sequence, 3-sequence >>> This would be the Windows 1.5.2. I read that the next version would be 1.6 and it wasn't due for a while - am I behind again or what? (Oh. Maybe you're assuming I'm using the prelease 1.6? No, I'm a weenie.) > so people can implement their own notion of > modular exponentiation. It's not clear how to work that option into > __rpow__ too, & I'm not sure the implementation does something sensible if > you try. > > IOW, the __rxxx__ methods are clear only to the extent that they're hooking > binary (two-argument) functions. Calls of the very special form "f(x)" are > important in your app, but in the *general* case > > f(x, y, z, key='howdy', ...) > > what the heck is __rcall__ supposed to mean? You can make something up, but > it won't be compelling; picking on x.__rcall__ is as arbitrary as picking on > y.__rcall__. The meaning *is* compelling for binary operators, and for that > reason __rgetitem__ would be more "screamingly natural" than __rcall__. Well, again, I wasn't actually making a request. If you're curious what the current thing actually _does_ in that situation, the answer is that there are no Functions that take more than one parameter. (It's supposed to be a math thing - "officially" there's no such thing as a function of two variables in mathematics either, "officially" they get emulated by functions of one variable.) > As someone else said, you have a particular kind of multiple dispatch in > mind here (meaning that which function gets called in the end depends on > more than one of the arguments), and Python doesn't have a *general* > approach to that built in. Your __rcall__ invention looks fine for your > particular version of this problem. > > but-likely-not-fine-for-the-next-fellow's-ly y'rs - tim From malcolmt at smart.net.au Fri Dec 3 06:11:10 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Fri, 3 Dec 1999 16:11:10 +1100 Subject: Compiling with Pthreads In-Reply-To: <826j58$oeb$1@bgtnsc02.worldnet.att.net>; from Brian Kennison on Thu, Dec 02, 1999 at 03:00:04PM -0500 References: <826j58$oeb$1@bgtnsc02.worldnet.att.net> Message-ID: <19991203161110.A809@Ridcully.home> On Thu, Dec 02, 1999 at 03:00:04PM -0500, Brian Kennison wrote: > I posted this earlier but I didn't get many responses and I would > like to get this thing going so I'm posting it again. I'm trying to compile > with threads so that I can use Zope. > > I'm not a programmer so I'm having trouble understanding the following > compiler errors. (I know that these symbols are coming from pthread.h but > don't know enough about it to even attempt a fix) I'm working with Python > 1.5.2,the FSU pthread library on the MachTen platform. Amazingly enough (for non-programmers), almost all of these error messages may be the result of a single missing character! the hint comes from the first bunch of error messages [... snip...] > thread_pthread.h:113: parse error before `pthread_cond_t' > thread_pthread.h:113: warning: no semicolon at end of struct or union Look at the file thread_pthread.h, line number 113. There will probably be a closing brave on that line that ends a structure or a union. There will *not* be a semicolon after that brace. That is why you are getting the error messages. Insert a semicolon immediately after the brace and recompile. Everything should go a lot better. If you still have problems, email me the section of thread_pthread.h that comes just before line 113 (say, the last 20 lines, or so). No need to send it to the list. Cheers, Malcolm Tredinnick -- On the other hand you have ... more fingers. From tim_one at email.msn.com Mon Dec 13 09:43:16 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Dec 1999 03:43:16 -0500 Subject: Need help with Tkinter for dynamic # of objects In-Reply-To: <831ov7$ap$1@bmerhc5e.ca.nortel.com> Message-ID: <000901bf4546$19ac1b00$9e2d153f@tim> [Donald Parker] > ... > I'm trying to define a Frame class that can have a variable > number of button widgets. Within the Frame class I've tried > coding the constructor as > > n=0 > while n < m : > self.set_of_buttons[n] = [Tkinter.Button(self)] > n+n+1 > > ...which results an exception for an attribute error for > 'set_of_buttons' Do either self.set_of_buttons = [None] * m before the loop and self.set_of_buttons[n] = Tkinter.Button(self) within the loop; or self.set_of_buttons = [] before the loop and self.set_of_buttons.append(Tkinter.Button(self)) within the loop. I assume "n+n+1" is a typo; also assume you really want each element of set_of_buttons to be a button, not a 1-element list containing a button > I thought types and variables came into existence as a result of > assignment, There's your problem . Attributes of objects come into existence as a result of assignment, but while .set_of_buttons is an attribute .set_of_buttons[n] is not (it's the "[n]" mapping operator applied *to* the attribute set_of_buttons, and the attribute must exist first else there's nothing to apply [n] to). AttributeError-never-lies-ly y'rs - tim From slinkp at angelfire.com Thu Dec 23 20:39:34 1999 From: slinkp at angelfire.com (Paul Winkler) Date: Thu, 23 Dec 1999 14:39:34 -0500 Subject: Anyone else making music with python? References: <386115AB.A0DD3F6@angelfire.com> <3861B360.5F891CF7@wipsys.soft.net> Message-ID: <38627A76.3E4AD134@angelfire.com> "BALAJI YOGESH K.V." wrote: > > Hi, > What is csound format and where do I get the csound module. > I am using Windows-NT 4.0 and Python 1.51. > > I am not able to play sound in NT. But your website marks that > any platform with python should be fine for psyco. > > Pls give me more info on how to make this work in NT. Whoops, I should have given more info on that. Csound is a software synthesis language / "soundfile compiler". It has been referred to as the "POVRay of sound" which is not a bad analogy. To hear sounds from pysco, you need to have csound installed. Csound compiles and runs on most platforms. More info on csound: http://mitpress.mit.edu/e-books/csound/frontpage.html --PW ----------- paul winkler ----------------------------- slinkP arts: music, sound, illustration, design, etc. A member of ARMS -----> http://www.reacharms.com or http://www.mp3.com/arms or http://www.amp3.net/arms personal page ----> http://www.ulster.net/~abigoo From bitbucket at isomedia.com Wed Dec 29 04:58:07 1999 From: bitbucket at isomedia.com (Eugene Goodrich) Date: Wed, 29 Dec 1999 03:58:07 GMT Subject: why? References: Message-ID: <386986aa.238773@news.isomedia.com> I just remembered: you should Python because it has cool file icons. -Eugene On Tue, 28 Dec 1999 03:40:32 GMT, "ekko" wrote: >I don't know that much about Python and I have some questions. Why would I >want to learn Python. What uses does it have? What kind of programs can I >make with Python? Thanks. > > import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==') From skaller at maxtal.com.au Wed Dec 1 15:03:04 1999 From: skaller at maxtal.com.au (skaller) Date: Thu, 02 Dec 1999 01:03:04 +1100 Subject: Python complaints References: Message-ID: <38452A98.DFDEAFA7@maxtal.com.au> Dan Schmidt wrote: > The main thing I find frustrating is that lambdas are not very > powerful. I'm not sure exactly what you mean .. but in Viper, lambdas are lexically scoped, and operate just the same as in functional programming languages. I think this fixes at least some of the most annoying features of lambdas. Did you have anything else in mind? -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From claird at starbase.neosoft.com Wed Dec 1 14:33:01 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 1 Dec 1999 13:33:01 GMT Subject: Python publicity Message-ID: <960B293B8A1D102B.35ECFD1852AB22AB.D78EE2A4662509A2@lp.airnews.net> Bruce Eckel advocates Python again for the *Software Development*-MIS-Win* crowd: -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From jmace at ior.com Sun Dec 19 20:53:33 1999 From: jmace at ior.com (Jim Mace) Date: Sun, 19 Dec 1999 11:53:33 -0800 Subject: help with negative numbers please Message-ID: <83jd7t$mi1$1@hardcore.ivn.net> This is a really quick question from an extreme newbie, after all I'm only 14. If I have an equation like this: y = z - x. How can I get y to equal either a negative or positive number. Thank you for your help, Jim From dfan at harmonixmusic.com Mon Dec 20 20:21:48 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 20 Dec 1999 14:21:48 -0500 Subject: List comprehensions References: <38592275.BBA2B61A@maxtal.com.au> <385E045D.9EC36473@compaq.com> Message-ID: mlh at vier.idi.ntnu.no (Magnus L. Hetland) writes: | P = [(x, y) for x in X for y in Y] | | Hm... Do the iterators work in parallel? Or would I end up with a | Cartesian product here? Logically (or intuitively), the above | expression would seem (to me) to mean: | | P = [] | for x in X: | for y in Y: | P.append((x,y)) | | which is, come to think of it, exactly what it means. Cool! But what | could the version with "and" mean, then? Since it is a bit more | verbose, it should probably be something less often used... Hm. It | seems to me to mean something like: | | P = [] | for i in range(min(len(X),len(Y))): | x, y = X[i], Y[i] | P.append(x,y) You know, I'm only half kidding when I say that the syntax for that second type of loop should be P = [(x, y) for x in X while y in Y] -- Dan Schmidt | http://www.dfan.org From alex at magenta.com Sun Dec 26 10:21:40 1999 From: alex at magenta.com (Alex Martelli) Date: Sun, 26 Dec 1999 10:21:40 +0100 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <38656610.E4DA287B@maxtal.com.au> Message-ID: <006c01bf4f82$a39bc220$bf2b2bc1@martelli> John Skaller writes: > > But why can't I change those 4 lines to, say: > > while line := inp.readline(): > > using the suggested ":=" operator that I've > > seen mentioned now and then? Or, maybe > > even better, "while line from inp.readline()" > > or other variants suggested in the past. > > Ok. You have set me a problem here. > I need more cases to examine! Please see my answer to Neel Krishnaswami -- I think I've come upon a good solution to the dilemma -- a simple wrapper class (small set of wrapper classes, actually) that will let me use elegant "for/in" syntax in these cases, without (I think/hope) substantial overhead. Tim's responses were of course precious in getting me to think along the right lines. > > And yet, what else can you expect when a > > language lets a newbie develop in 15 minutes > > a task that by rights should take quite a few > > hours...? > > You can expect other ways of doing > something which you would learn later. And I got that -- even better, perhaps, I got the added intellectual stimulus of seeing that the solution "was" already "in" the language, yet I had to exert a modicum of effort to see it and package it up. Didactically speaking, this IS something of an ideal outcome!-) (Despite which, I'd still like to see this wrapper idea [a] either shot to pieces because of some subtle problem I can't see, or [b] made more available as a 'standard' idiom, perhaps in an example or tutorial). > > Another way to put it -- when a language > > manages to combine expressiveness, clarity, > > concision, and power, to the extent that > > Python exhibits even in a newbie's hands [snip] > I agree with you entirely. > What happened to me was: I needed to do a lot > of these thing SO often, that the resulting > code was more cluttered than the equivalent > C would have been. > > I have introduced ONE entirely > new statement into Viper (my version of Python): > > with: ... > do: ... > > in which the variables introduced in the with part > are available in the do part, and then forgotten. > This adds to the lexical scoping Viper provides, > to correct Python's lousy scope control. Now that sounds extremely interesting. Python's scopes are extremely simple, but perhaps this IS too simple, as you claim. In my newbie status, in your shoes, I would probably introduce a temporary dictionary to fake out a scope, but I realize readability would suffer -- "d['x']" is more verbose than plain simple "x" by enough to matter. Perhaps a solution might hinge around extending the "exec" statement, which already provides for explicitly supplied local and global dictionaries, but currently only executes a string or a code object. If "exec" would let me express the "code object to be executed" as a plain suite of normal Python statements, we'd be there, wouldn't we? I.e., rather than your: with: x=23 y=45 do: z=x+y we might instead write: exec: z=x+y in {'x':23, 'y':45} or some similar variation thereof. This might fit better with existing constructs, requiring no new keywords, and perhaps providing better control thanks to the explicit supplying of the dictionaries being used/affected...? > Unfortunately, new control structures are easy to introduce, > but we don't want to litter the language with TOO many. Absolute agreement here! > Here's one that is going in to Viper, when I can > come up with the right keyword: > > ifor k,v in e: .. > > where k and v are the keys and values of a dictionary, > or, the indices and values of a sequence. This is > commonly needed, instead of: > > for k in d.keys(): > v = d[k] Neel Krishnaswami already suggested "items" for the dictionary case, and I proposed a tiny wrapper that would let you write for k,v in seqenum(e): ... for the sequence case. > i = 0 > while 1: > v = seq[i] > .. > i = i + 1 > if i>= len(seq): break > > The latter is almost essential when generalising > to parallel sequence processing. But "for" already internally provides the semantics of starting the key from 0, stepping it, and bailing out (albeit when it gets an IndexError, rather than based on a test of "len") -- the idea of having a wrapper can be seen as an attempt to reuse these parts (and the nice semantics that goes with them). What are the drawbacks of supplying the needed wrappers, rather than adding new syntax...? > But 'break' > in python isn't labelled, and there is no goto, > so you end up having to use exceptions ... Uggghhhh. Labeled breaks might well be a good idea, I guess. > Of course, most functional languages provide coherent > and very concise ways of doing this kind of thing. > So it is fairly well known WHAT is required, just not > what syntax to use in a 'pythonic' version. :-) What about the "for x in y" syntax -- that seems neat to me, as long as we can supply the y appropriately:-). Alex From skaller at maxtal.com.au Thu Dec 16 21:37:04 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 17 Dec 1999 07:37:04 +1100 Subject: some random reflections of a "Python newbie": (2) language issues References: <82o0to$6eq$1@serv1.iunet.it> <82od57$i7n$1@serv1.iunet.it> <3857FAE0.427FE0FC@maxtal.com.au> <007f01bf4759$f741a880$c02b2bc1@martelli> Message-ID: <38594D70.EBCDCEC7@maxtal.com.au> Alex Martelli wrote: > > John Skaller writes (and I focus on my sole > disagreement with his long fascinating post): > [big snip] > > > how to prototype in Python-as-it-stands > > > (not with the needed polymorphism, and > > > good performance, etc, which are the > > > whole point of the suggestion:-). > > > > The answer is to use named methods, like: > > > > x.contains(y) > > > > This works, even if the syntax is not > > exactly what you want. And it is safer, since it > > Nope, this gives no _polymorphism_ whatsoever. That's not quite correct. It is correct to say that this will not work with _existing_ objects, such as PyTuples. But using the 'contains' method as illustrated is every bit as polymorphic: it works for every object providing a 'contains' method, just as y in x works for every object providing a __contains__ method (or the C equivalent, which is a slot filled in a type objects vtable). The _only_ difference is syntax (which is not unimportant). -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From fredrik at pythonware.com Thu Dec 2 01:42:55 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 2 Dec 1999 01:42:55 +0100 Subject: syntax checking underway; question about catching exceptions References: <824chl$6ev$1@nnrp1.deja.com> Message-ID: <00ce01bf3c5e$2d1645d0$f29b12c2@secret.pythonware.com> Preston Landers wrote: > If I catch the exception like so: > > try: > compile(file, "", "exec") > except: > exception, msg, tb = sys.exc_info() > # look at traceback here > > then I effectively lose where in the source file the exception > occured. If I examine the tb with the traceback module, I get > something like this: > > File "./syntax_checker.py", line 36, in examine_files > compile(file, "", "exec") > > So I can do post-processing, check other files, and so on, which is > nice, but I am not able to determine automatically where the problem is > in the source file. So, it's effectively useless. oh, you're close. the exception instance (msg in your case) contains the information you're looking for. consider this little example: import sys, traceback try: compile("""\ while 1: prnt 'foo' """, "", "exec") except SyntaxError: ev = sys.exc_info()[1] for k, v in vars(ev).items(): print k, "=", repr(v) which prints: filename = None lineno = 2 args = ('invalid syntax', (None, 2, 14, " prnt 'foo'\012")) offset = 14 text = " prnt 'foo'\012" msg = 'invalid syntax' also see: http://www.python.org/doc/current/lib/module-exceptions.html hope this helps! From Sander.Rosenberg at sdsu.edu Fri Dec 10 06:42:56 1999 From: Sander.Rosenberg at sdsu.edu (Sander Rosenberg) Date: Thu, 09 Dec 1999 21:42:56 -0800 Subject: Is low-level parallel port I/O feasible? Message-ID: <385092E0.62B2AA4B@sdsu.edu> I need to read and write single bytes from/to the parallel port on a PC. I know some implementations of C have "in/outportb" functions for use with hardware ports. Might Python have an equivalent? From wtanksle at hawking.armored.net Tue Dec 28 04:04:57 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 28 Dec 1999 03:04:57 GMT Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> Message-ID: On Mon, 27 Dec 1999 07:28:34 -0500, Paul Prescod wrote: >I would love it if one of my Python nits was corrected in Python 2 >whenever that comes about. Consider the keywords "def" and "class" >Kidding aside, "class" is a noun and "def" is an abbreviation for a >verb. Furthermore, "def" is way too generic. Python has class >definitions and function definitions. The keywords should be >"func"/"function" and "class". I agree -- abbreviations are a little silly. >----- >The syntax for selecting base classes is un-Pythonic in the sense that >it is not clearly obvious what is going on. Java's "extends" keyword is >more Pythonic (if only the rest of Java was!). I don't agree directly -- I find "class This(That):" to be quite clear. In this case, minimal use of keywords is the focus. However, I would like us to look at some other models for inheritance -- Sather's split between interface and implementation is interesting, as is Lagoon's split between category and structure (Lagoon actually looks quite Pythonic for a Pascal-derived language!). Lagoon is discussed at http://www.ics.uci.edu/~franz/publications/J9703%20ProgLanguageLagoona.pdf >----- >Python has an efficient multi-level dispatching mechanism that is used >as the basis for name lookup and attribute lookup. The implementation of >this mechanism should be made availab le to the programmer. I should be >able to make a proxy object something like this: >class Proxy: > def __init__ ( self, fallback ): > __fallback__=fallback >a = Proxy( someObject ) >This would imply the following: >class SomeClass( someParentClass ): pass >assert SomeClass.__fallback__ == someParentClass >assert SomeClass().__fallback__ == SomeClass.__fallback__ I don't have a clue what this is doing. Sorry. > Paul Prescod -- -William "Billy" Tanksley, in hoc signo hack From gmcm at hypernet.com Thu Dec 30 15:14:49 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 30 Dec 1999 09:14:49 -0500 Subject: The Don Beaudry/Jim Fulton hack In-Reply-To: <9GHa4.1682$wG6.149869@ndnws01.ne.mediaone.net> Message-ID: <1265560092-4227862@hypernet.com> Dave Abrahams wrote: > > I've recently been crawling through the source code (trying to > understand what all those fields in PyTypeObject really do), and > stumbled across an explanation for what I had read about being > able to subclass a type extension in Python: there's special code > to make this possible! Not really. That special code allows you to take over the building of a new instance from Python. Subclassing a type takes a whole lot of C code. > I think: it would be cool to experiment with this before writing > any C code, just to make sure I understand it. So I fire up > Python. Since the special code is never entered if the base is a > real class (not shown), I figure it has to be an instance: > otherwise, how could it have an attribute called "__class__"? Correct. > >>> class Empty: pass > ... > >>> base = Empty() > >>> base.__class__ = stupid_class > Traceback (innermost last): > File "", line 1, in ? > TypeError: __class__ must be set to a class > >>> Nope. The above magic is invoked when the "class" statement is run. So the key is class MyClass(magicinstance): That is, you "derive" from an instance. The magicinstance has nothing to do with the result. It's the magicinstance's class that provides the magic. IOW, this was an easy way to test out an experimental feature, not an axiom of the object model. Look at Demo/metaclasses. > Finally, another point. It is now possible to make extension > classes which walk, talk, and smell just like built-in classes Not at all. Making a type subclassable means bridging the two different "method" mechanisms. Types have slots, classes / instances have magic dictionaries. Take a look at ExtensionClass from Digital Creations (comes with Zope). Notice that it reimplements 99% of everything, and only types of the ExtensionClass type are subclassable (so you still can't subclass lists or dictionaries). Most of the type-checking at the C level consists of seeing whether the object's typeobject is (same address) some well known typeobject. Since the methods are on the typeobject, you can't trick the C code. - Gordon From aahz at netcom.com Wed Dec 8 22:52:17 1999 From: aahz at netcom.com (Aahz Maruch) Date: 8 Dec 1999 21:52:17 GMT Subject: Is there a database in Zope? References: Message-ID: <82mjuh$uf8$1@nntp9.atl.mindspring.net> In article , NH wrote: > >What I need to do is have students fill out a form that the councelor >can view at a later time. I will be dealing with many students. The >server is not that good, so I need to keep everything simple. I am not >sure if I'd be able to get a SQL server together. I know this isn't what you asked about, but you should probably consider security. For example, what if student A fakes a form from student B? -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Sign up now! http://www.searchbutton.com/ From prestonlanders at my-deja.com Thu Dec 16 22:35:59 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Thu, 16 Dec 1999 21:35:59 GMT Subject: whrandom seed question References: <81eu22$411al$1@umbc7.umbc.edu> Message-ID: <83blvv$huh$1@nnrp1.deja.com> Greetings, According to Beazley's "Essential Python Reference" (I haven't checked the 'official' docs) if the three parameters given to whrandom.seed() are equal, then *the current time* is used as the seed. Presumably, the clock is ticking in between your .seed() statements below. If you want predictable 'random' numbers, then use nonequal parameters to seed(). ---Preston In article <81eu22$411al$1 at umbc7.umbc.edu>, kyriacou at umbc.edu (Stelios Kyriacou) wrote: > Shouldn't the following 3 lines produce the same number? > > >>> whrandom.seed(0,0,0); print whrandom.random() > 0.39613674715 > >>> whrandom.seed(0,0,0); print whrandom.random() > 0.170188890936 > >>> whrandom.seed(0,0,0); print whrandom.random() > 0.831213988577 > >>> -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From mal at lemburg.com Fri Dec 10 18:14:18 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 10 Dec 1999 18:14:18 +0100 Subject: Error confusing a newbie References: <19991210100320.B18389@dmcom.net> Message-ID: <385134EA.7D3281BB@lemburg.com> Wayne Topa wrote: > > Hello > > I seem to have run into an error that I can't figure out. I have > written a python program to replace a somewhat unintelligable perl > script I wrote about a year ago. The python replacement (improvement) > is 1/4 the size and I can understand it! > > The problem is that when run with #> python net_time.py it works > and does what I want. But - see below. > > mtntop:~# ls -l net_time.py > -rwxr-xr-x 1 root root 835 Dec 10 09:52 net_time.py > > mtntop:~# python net_time.py > > Current Totals > 013 Hours 0 Minutes 42 Seconds > > mtntop:~# net_time.py > import: Unable to connect to X server () [No such file or directory]. > from: can't read /var/spool/mail/DateTime. > ./net_time.py: line 7: syntax error near unexpected token `open('' > ./net_time.py: line 7: `input = open('/var/log/totalppp', 'r')' Your shell is obviously trying to execute the script as-is instead of calling Python to do the job. One possible explanation for this is that there is no /usr/bin/env command installed on your machine (could be in /bin though). Note that 'import' is a tool to capture screen content and write it to a file. > Here is the script > --------------------------------------------- > #!/usr/bin/env python > > import string,sys > from DateTime import * > ... Hope that helps, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 21 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From tsmets at altern.org Sun Dec 26 18:17:13 1999 From: tsmets at altern.org (Thomas Lionel SMETS) Date: Sun, 26 Dec 1999 17:17:13 GMT Subject: Tkinter config on RH 5.2 Message-ID: <38664B8A.6AEA7758@altern.org> Hi, Python came "installed" on my RH 5.2 & I now wish to use Tkinter as explained in the ORA's book (Learning PYTHON). I modified the different environemnt variables (under bash) so I thought I could use TCL-TK (i'm running KDE as desktop environment). Here are the lines I added to the /etc/profile file : #Environment variables for "everybody" echo "Python environment variables ..." PATH="$PATH:/usr/lib/python1.5/lib-tk" TCL_LIBRARY="/usr/lib/tcl8.0" TK_LIBRARY="/usr/lib/tk8.0" export TCL_LIBRARY TK_LIBRARY The /etc/profile was openned under the root account so I could save it. To be sure everything was OK I reboot to have all setting available to all environment. Could someone give me an hint over what's wrong, 'cause I can't run the example page 22 from Tkinter import * w=Button(text="Hello", command='exit') w.pack() w.mainloop() when importing I get : Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 5, in ? import _tkinter # IF this fails your Python is not configured for TkImportError : BLAB LA BLA Thanks for help ... ! Thomas, -- e-mail : tsmets at altern.org (private) -------------- next part -------------- A non-text attachment was scrubbed... Name: vcard.vcf Type: text/x-vcard Size: 316 bytes Desc: Card for Thomas, Lionel SMETS URL: From mhammond at skippinet.com.au Wed Dec 15 23:36:27 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 15 Dec 1999 22:36:27 GMT Subject: Where can I find info on using Python w/ Windows Scripting Host References: <838fdd$6od$1@nnrp1.deja.com> Message-ID: Simply install the standard Python distribution (pyth152.exe) and also win32all-127.exe (from starship.python.net/crew/mhammond). You will then have the Active Scripting engine installed and ready to go. Read the installed "COM Readme" file for more details on the AXScript engine. Mark. e.e.sutton at cummins.com wrote in message <838fdd$6od$1 at nnrp1.deja.com>... >Where can I get info on Python for use under Windows? I am especially >interested in a version that can run under the Windows Scripting Host. > >I am evaluating various scripting languages for use on the Windows >platform. I expect we will end making VBScript the company standard >but I wanted to evaluate Python and TCL/TKL as well. From dave.rose at wcom.com Tue Dec 14 23:10:16 1999 From: dave.rose at wcom.com (Dave Rose) Date: Tue, 14 Dec 1999 22:10:16 GMT Subject: AIX Py compiling errors? References: <81r96t$meq$1@nnrp1.deja.com> <38421A64.6A7001E2@inrialpes.fr> Message-ID: I am also having a problem with AIX and compiling. I am getting an error from the munch command about not being able to open the .so file during the compilation. I know this is an old issue, but I was unable to find a solution to it in any of the old messages. Dave Rose Vladimir Marangozov wrote in message news:38421A64.6A7001E2 at inrialpes.fr... > moonseeker at my-deja.com wrote: > > > > Hi! > > > > Anyone using Python on AIX here? I tried to compile Python on my AIX 4.1.5 > > box using the IBM compiler but I get an error (or warning): > > > > cc_r -O -qmaxmem=4000 -I./../Include -I.. -DHAVE_CONFIG_H -c > > ./socketmodule.c "./socketmodule.c", line 1127.22: 1506-280 (W) Function > > argument assignment between types "struct sockaddr*" and "unsigned char*" is > > not allowed. > > > > Anyone a suggestion? > > A warning. It doesn't hurt. > > -- > Vladimir MARANGOZOV | Vladimir.Marangozov at inrialpes.fr > http://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252 From ivanlan at callware.com Thu Dec 2 19:54:28 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 02 Dec 1999 11:54:28 -0700 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> <826dtd$bre$1@newshost.accu.uu.nl> Message-ID: <3846C064.8112D053@callware.com> Hi All-- Martijn Faassen wrote: > > Robin Becker wrote: > [2000 vs 2001 as the start of the new millenium] > > Doesn't matter about the base; to celebrate 2000 years you have to have > > them. As there's no zero A.D. even C programmers will find it difficult > > to dig up the extra year. Year 2000 bi-milleniallists should celebrate > > the start of the 2000'th year next January; then they can celebrate the > > beginning of the new millenium in 2001. Mere digit preferentialists can > > do as they please, personally I'm going to try and wait for 2222. > > I propose to retroactively introduce a year 0 AD. Just use the currently > 1 BC for it and substract 1 from all BC numbers. Besides, we should be > using negatives for BC anyway. > Actually, since there were no Gregorian years before the Gregorian calendar was introduced in 1582, and since the practice of dating from the incarnation was begun by Dionysus Exiguus in or around 532 AD (or 754+532 = 1286 AUC), _all_ dates that refer to 1BC, 1AD, 0 CE, -1CE or pretty much _anything_ before 532 are _proleptic_, that is, applied retroactively to times before the calendars they refer to existed. In such a case, there is no reason whatsoever to throw out the retroactive application of a year 0 when you're already using a proleptic calendar anyway. It's just pettifoggery; "I know better than you." Humbug. > After all as far as I understand nobody knows when Christ was born exactly > anyway, so it doesn't really matter. Historians will just have to adapt, > their fault for coming up with such a bizarre system in the first place. :) > Yah, yah, blame the victims. ;-) > Proposal-has-been-sent-to-the-W3C-ly yours, > > Martijn > -- > History of the 20th Century: WW1, WW2, WW3? > No, WWW -- Could we be going in the right direction? > -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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From mlh at vier.idi.ntnu.no Thu Dec 2 18:20:15 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 02 Dec 1999 18:20:15 +0100 Subject: [NumPy] :( Message-ID: I can't get it to work... :( I have compiled it and installed it, but when I try to import Numeric, Python just crashes. I know there isn't much information in that, but is there anyone, by any chance, who can help me anyway? (I'm on Solaris...) -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From lull at acm.org Thu Dec 30 06:38:53 1999 From: lull at acm.org (John Lull) Date: Thu, 30 Dec 1999 05:38:53 GMT Subject: tkSimpleDialog focus problem Message-ID: I'm trying to write a very simple app using Tkinter, and have gotten as far as showing a simple dialog box derived from tkSimpleDialog, as shown in listing 1 below. The dialog box looks as I expected, except.... When I run this (under Win98), it displays the main window on *top* of the dialog box, even though the dialog box has the focus. I can type into the edit field, even when it's obscured behind the main window. If I > to the program, the main window seems to get the focus, but now moves *behind* the dialog box. I can click on the dialog box title bar & bring it to the front, and have it retain or get the focus. Clearly, I'm doing something wrong. Any hints? Regards, John Listing 1: # file test.py from Tkinter import * import tkSimpleDialog # =================================================================== class TestDialog(tkSimpleDialog.Dialog): # ---------------------------------------------------------------- def body(self, master): # Add label + entry field Label(master, text="A").grid(row=0) e = Entry(master) e.insert(0, 1) e.grid(row=0, column=1, sticky=E+W) # Set initial focus to entry field return e # =================================================================== def t(): m=Tk() d=TestDialog(m, "testing, testing...") print d.result t() From python-list at teleo.net Wed Dec 29 22:18:03 1999 From: python-list at teleo.net (Patrick Phalen) Date: Wed, 29 Dec 1999 13:18:03 -0800 Subject: Python books review ? In-Reply-To: References: Message-ID: <99122913521807.03115@quadra.teleo.net> [Hirendra Hindocha, on Wed, 29 Dec 1999] :: It seems that suddenly there are a lot of Python books on the market. :: Has anyone bought them ? If so, can u post a review of them ? :: :: Please post to the newsgroup. :: :: I'm looking for reviews on - :: :: Programming With Python :: Tim Altom; Paperback Haven't seen it. Anyone know anything about the author (Altom)? :: Python Annotated Archives :: Martin C. Brown, et al; Paperback I like this one. 700 pages of scripts, annotated line-by-line, covering a wide range of problem types: * Data manipulation * Networking * Web development * Interface development * Entertainment and graphics * Sending and organizing email * Tools for programming * Systems administration * Cross-platform support The scripts are well selected and the annotations very clear. Recommended for those who like to learn by example. :: The Quick Python Book :: Kenneth McDonald, Daryl D. Harms; Paperback This is my new go-to book. Very lucidly written with generously detailed explanations. Very complete. The organization of the content is logical, making it easy to find what you want. The best explanation of Python classes I've seen anywhere. Very nice HTMLgen chapter (by Robin) Especially useful for Win32 folk (which I'm not), due to the attention it pays to that platform's umhhh ... "special needs." (Not that it short-changes the *nix users either.) Devotes chapters to some advanced topics that other books might not -- JPython, COM, Zope, extending Python with C/C++. Not mentioned in your list, but also worth purchasing IMO: * Learning Python The best introduction for beginners * Python Essential Reference Nice, rather complete expansion of the online docs. A handy reference; I use it often. Typeface too small for comfortable reading, though. * the effbot Guide to the Python Standard Library An e-book. Example usage for (I think) the whole standard library. Very useful. Fun to browse. Sprinkled with amusing quotations too. Windows-only PDF format may leave some people out. Note, too, that Open Source Library now has commercially printed, bound copies of: * Python Tutorial * Python Reference Manual * Python Library Reference (good bedtime reading) ... at a good price, with, I believe, some proceeds going to PSA. It's nice to have these in book form. From paul at prescod.net Tue Dec 28 23:02:38 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 28 Dec 1999 17:02:38 -0500 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> Message-ID: <3869337E.996B9BAE@prescod.net> Manuel Gutierrez Algaba wrote: > > > This is a waste of "syntax", Actually it is a very efficient use of syntax. We have attribute access and keyword assignment syntax and both are wasted on tuples. > we could have an object in > a very similar fashion: > t = mytime(hour = ....) But then we have an object. It is not a tuple. If you feel that tuples have no virtues then you should petition for their removal from Python. If you feel that they DO have virtues then you should argue more persuasively that improving them somehow hurts things. > Is this the start of a switching to tuple-oriented programming instead > of OO-programming? No. It is the start of making tuples more useful. That doesn't destroy OO. I strongly doubt that serious Python programmers would abandon objects for tuples. Tuples don't even have a concept of methods. Paul Prescod From mwh21 at cam.ac.uk Thu Dec 2 08:32:08 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 02 Dec 1999 07:32:08 +0000 Subject: Python doesn't follow it's own scoping rules? References: <8766yil0xp.fsf@drpepper.baker.rice.edu> <873dtml0g5.fsf@drpepper.baker.rice.edu> Message-ID: Tim Danner writes: > Apologies - I didn't find the answer in the Language Reference, so I gave > up. After posting this, I thought to look in the *tutorial*, and it was quite > clearly explained. I should have written: FWIW, with Python 1.5.2+ (i.e. from CVS): Traceback (innermost last): File "", line 1, in ? File "", line 2, in death_and_destruction UnboundLocalError: a which makes rather more sense! Cheers, Michael From Gaetan_Corneau at baan.com Fri Dec 17 16:28:54 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Fri, 17 Dec 1999 10:28:54 -0500 Subject: NT Desktop question Message-ID: <816010E2456BD111A48700805FBBE2EEFDF925@ex-quebec-u1.baan.com> Hello, I would like to be able to invoke "python.exe somescript.py droppedfilename" under NT just by dropping a file on an icon on my desktop. Is this possible? If it's not, I'll just code a small app that will receive the dropped file and then call the Python script. Thanks, ______________________________________________________ Gaetan Corneau Software Developer Software Engineering Process Group BaaN Supply Chain Solutions http://www.baan.com E-mail: Gaetan_Corneau at baan.com Tel: (418) 266-8252 ______________________________________________________ "Profanity is the one language all programmers know best" From grant at nowhere. Tue Dec 7 20:02:41 1999 From: grant at nowhere. (Grant Edwards) Date: Tue, 07 Dec 1999 19:02:41 GMT Subject: Need python mode for Jed References: <384D5F1D.C1F2CE6E@corrada.com> Message-ID: In article <384D5F1D.C1F2CE6E at corrada.com>, andres wrote: >Grant Edwards wrote: > >> Could somebody point me to a copy of pymode.sl v1.3? > >Grant, doesn't jed already have a python mode built-in? Yes -- for some definitions of "built-in" ;) Most of what appears to be built-in to jed is actually implimented by an external library of slang routines. Python mode is one of these things: it is implimented by the file pymode.sl. Jed is currently shipping with version 1.2 of that file. Version 1.3 of pymode.sl was posted here last month, and I wanted to try it, but can't find it anywhere except deja.com, where it has been "re-formatted" (lines wrapped, etc.) so as to make it a PITA to use. -- Grant Edwards grante Yow! Finally, Zippy at drives his 1958 RAMBLER visi.com METROPOLITAN into the faculty dining room. From Dan at Grassi.com Mon Dec 6 00:30:22 1999 From: Dan at Grassi.com (Dan Grassi) Date: Sun, 05 Dec 1999 18:30:22 -0500 Subject: Very useful message -- Hah! References: <82do53$2rhr$1@hub.org><384A9BE0.B345509@inka.de> <384ABC57.DDC3B61E@inka.de> <87u2lxuooi.fsf@freddy.page.street> <87bt85dlxz.fsf@freddy.page.street> Message-ID: in article 87bt85dlxz.fsf at freddy.page.street, David N. Welton at davidw at prosa.it wrote on 12/5/99 6:09 PM: > Python is extensible to make it do whatever you want. As is any good > language. >It sucks to build a language that is built around one and > only one thing, IMO. If you that is a reference to php I only have one comment: It works well and python doesn't. > Ummm, CGI's are definitely not mod_php. CGI is an interface between > the server and seperate processes. Mod_php is a module compiled (or > loaded, if you have DSO support) into Apache, which gives you a lot of > advantages. Look, I'm really getting tired of the symantics! I don't care if it is cgi or whatever, I want the _results_, he _capabilities_. To put this in perspective I'm saying that the bird is dead. You are telling me that the Norwegian Blue has great plumage. :-) Dan From kc5tja at garnet.armored.net Tue Dec 7 23:56:06 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 7 Dec 1999 22:56:06 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: In article , Neel Krishnaswami wrote: >parenthesized s-exps is why Lisp has a macro system that does not >suck -- Lisp macros are essentially transformations of the abstract >syntax. And that macro system is why even novel ideas can always be >expressed cleanly in Lisp. Forth has much the same capabilities without the use of parentheses. In fact, it uses zero punctuation at all. :-) -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From bwarsaw at cnri.reston.va.us Fri Dec 10 07:51:09 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Fri, 10 Dec 1999 01:51:09 -0500 (EST) Subject: string interpolation in doc strings... References: <14416.3969.90448.612046@anthem.cnri.reston.va.us> <14416.41089.649043.126089@dolphin.mojam.com> Message-ID: <14416.41693.114874.290122@anthem.cnri.reston.va.us> >>>>> "SM" == Skip Montanaro writes: SM> I imagine some of the active particpants in the doc sig will SM> have some opinions about the use of format strings embedded in SM> doc strings. It's not immediately obvious to me that it's SM> good docstring stewardship. That's a good point Skip. Looking back over my use of this, it's fairly limited to things like PROGRAM = sys.argv[0] __version__ == '0.1' and then interpolating just those two globals into the docstring. Very occasionally, it'll be something more, but it's also just as likely that I might generate dynamic information to tack onto the end of the script's module docstring. Lately, I haven't been doing any of that though, and just printing __doc__ in the usage() function. That alone is a mighty handy way of doing it. -Barry From randy_shaffer at my-deja.com Fri Dec 3 20:22:03 1999 From: randy_shaffer at my-deja.com (randy_shaffer at my-deja.com) Date: Fri, 03 Dec 1999 19:22:03 GMT Subject: newbie: package and import problems References: <828toe$dog$1@nnrp1.deja.com> Message-ID: <82958m$jgo$1@nnrp1.deja.com> The problem was a duplicate TestHarness directory in the system search path. Sorry. In article <828toe$dog$1 at nnrp1.deja.com>, randy_shaffer at my-deja.com wrote: > Hello. I'm experiencing an ImportError that I do not understand. I'm > hoping someone can point out what I'm missing - thanks in advance. > > I have a package directory structure that looks like this: > > TestHarness/ > __init__.py > THDatabase/ > __init__.py > THUser.py > THUniverse.py > > In THUser.py file, I have various class and function definitions > including a top level test() function that excersizes all the code in > the file. From the interpreter command line, I can type: > > >>> from TestHarness.THDatabase.THUser import * > >>> test() > > Everything works just fine here. There is a problem when just > executing the file stand-alone. The two lines I have in the file that > I understand will enable this are the first: > > #!/usr/local/bin/python > > and the last: > > if __name__ == '__main__': test() > > The top few lines in the file look like this: > > import TestHarness > import cPickle > import os > import string > from TestHarness.THDatabase.THUniverse import KnownUniverse > > This last line causes the exception: > > ImportError: No module named THDatabase.THUniverse > > Why doesn't python see this file? The top level package name is known > to sys.path. > > I can make this go away by including the lines: > > from TestHarness import * > from THDatabase import * > from THUniverse import * > > But then, in a statement buried in the THUniverse.py file I get an > AttributeError for the variable TestHarness.RootDir. This is given a > value in __init__.py in the top level package, TestHarness/. > > What am I doing wrong? > > Randy > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From patdut01 at club-internet.fr Sat Dec 4 21:47:48 1999 From: patdut01 at club-internet.fr (patrick dutoit) Date: Sat, 04 Dec 1999 21:47:48 +0100 Subject: to the tkinter experts Message-ID: <38497DF4.C28A1863@club-internet.fr> Does anybody knows what to do to use BLT instead of Tk ? Thanks Regards From donn at u.washington.edu Fri Dec 17 21:37:50 1999 From: donn at u.washington.edu (Donn Cave) Date: 17 Dec 1999 20:37:50 GMT Subject: multiple threads & environment References: Message-ID: <83e6uu$1652$1@nntp6.u.washington.edu> Quoth c.kotsokalis at noc.ntua.gr (Constantinos A. Kotsokalis): | a (simple?) question: If I have a python program with multiple threads | of execution, does each one of them start with their own os.environ | dictionary? What I want to do is to have an environment variable | different for each thread. I am using the Threading module, if that | is any further help, and add/change the environment variable in the | function that the thread executes (i.e. not passing it as an | argument). I think there are two ways to look at this. On one hand, the environment is a region of memory in the executing image, and the program units that refer to it do so via a global address. So there is only one environment, however many threads there may be. On the other hand, it's data like any other dictionary, and each thread can certainly maintain its own private "environment" data. What use is this? Well, it depends on what you want to do with the data. If it's to be passed to another program the thread will execute, then you could use the posix.execve() function, whose last parameter is the environment - data, that is. Donn Cave, University Computiong Services, University of Washington donn at u.washington.edu From neelk at brick.cswv.com Tue Dec 7 23:49:43 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 7 Dec 1999 22:49:43 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: William Tanksley wrote: > >Wow. It took me a few weeks to get over Lisp's parens, and they're WAY >nastier than Python's indentation. A year, though... Hey, Lisp's parens are a big part of the reason Lisp is beautiful! The combination of symbols as a language feature and fully parenthesized s-exps is why Lisp has a macro system that does not suck -- Lisp macros are essentially transformations of the abstract syntax. And that macro system is why even novel ideas can always be expressed cleanly in Lisp. Neel From grant at nowhere. Tue Dec 14 15:54:11 1999 From: grant at nowhere. (Grant Edwards) Date: Tue, 14 Dec 1999 14:54:11 GMT Subject: Tkintr uses Tcl? Message-ID: I get the impression from various postings and documentation that Tkintr uses Tcl. Is this true? I come from an STk background where the Tk binding doesn't use Tcl, so I was a bit surprised to see references that implied that Tkintr still included some sort of a Tcl interpreter. Doesn't this add a lot of overhead? I presume it is less work than the Stk approach? -- Grant Edwards grante Yow! .. Everything at is....FLIPPING AROUND!! visi.com From olivier.deckmyn at mail.dotcom.fr Thu Dec 2 13:06:49 1999 From: olivier.deckmyn at mail.dotcom.fr (Olivier Deckmyn) Date: Thu, 2 Dec 1999 13:06:49 +0100 Subject: Python Code Completion Message-ID: <825nj7$2o02$1@feed.teaser.fr> Hi all ! I am writing an application (using Delphi) that embeds some python sources... In fact, the whole application rules are written in python, and only the GUI uses Delphi. I've choosen Delphi because the GUI is quite complex and because I know how to program Delphi much quicker than any other language. Here I come : The users of my application have the possibility to modify python script from inside the product itself. I would like to provide to the users of this application the ability to use the code completion on their own scripts ; like in PythonWin or IDLE... But found I no documentation on how to do such a feature :( So here is my question : "How can I use python code completion in my own application?" Is this integration difficult ? I really hope that someone will be able to help me. Olivier Deckmyn, Paris - France. From gerrit.holl at pobox.com Sun Dec 26 16:12:53 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sun, 26 Dec 1999 16:12:53 +0100 Subject: Inheritance, __getattr__...? Message-ID: <19991226161253.A3714@stopcontact.palga.uucp> Hello, I currently have a subclass of UserDict with the following methods: ... def __setitem__(self, key, value): UserDict.__setitem__(self, key, value) if not self.buffered: self.flush() def __delitem__(self, key): UserDict.__delitem__(self, key) if not self.buffered: self.flush() def clear(self): UserDict.clear(self) if not self.buffered: self.flush() ... As you can see, I'm looking for a construct: For every method, first do the method of base class UserDict and next do code. I think I'm close with this code: class MyClass(UserDict.UserDict): def method(*args, **kw): apply(UserDict.??????, args, kw) if not self.buffered: self.flush() __setitem__ = __getitem__ = __delitem = __del__ = \ keys = values = has_key = get = update = method # for all methods... But I don't know what to put in apply(...) Should I just be content with the first code, which is IMHO ugly? regards, Gerrit. -- "The world is beating a path to our door" -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates) 3:33pm up 5:04, 16 users, load average: 0.00, 0.00, 0.00 From emile at fenx.com Wed Dec 15 04:04:02 1999 From: emile at fenx.com (Emile van Sebille) Date: Tue, 14 Dec 1999 19:04:02 -0800 Subject: Newbie Variable Definition Question References: <38566A51.A1DFD2F6@coastalnet.com> <38566D2E.1916DABD@callware.com> <19991214175140.A507@stopcontact.palga.uucp> Message-ID: <010201bf46a9$0aea2e40$01ffffc0@worldnet.att.net> I seem to recall from the docs that locals and globals could not always be relied on. Something ... ah... here it is: .. undefined.4.2 The current implementations return the dictionary actually used to implement the namespace, except for functions, where the optimizer may cause the local namespace to be implemented differently, and locals() returns a read-only dictionary. >From the python reference manual. You're probably ok, but watch out. Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Gerrit Holl To: Sent: Tuesday, December 14, 1999 8:51 AM Subject: Re: Newbie Variable Definition Question > I prefer: > if not locals.has_key('x') or globals.has_key('x'): > x='default value' > > -- > "Nature abhors a Vacuum" > > -- Brian Behlendorf on OSS (Open Sources, 1999 O'Reilly and Associates) > 5:49pm up 4 min, 3 users, load average: 0.28, 0.37, 0.17 > > -- > http://www.python.org/mailman/listinfo/python-list > > From cwr at cts.com Sat Dec 18 08:06:09 1999 From: cwr at cts.com (Will Rose) Date: 18 Dec 1999 07:06:09 GMT Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> Message-ID: <83fbp1$14qq$1@thoth.cts.com> Alex Martelli wrote: [...] : I (think I) need a simple "template" sort of : operation whereby an input stream (mostly a : file) is copied to an output (ditto), with some : kind of "substitution" happening on the fly, and : a reasonable amount of generality. There is : sure to be something around, but, hey, I'm a : newbie, I need to learn, so yesterday evening : I decide to design my own -- looks like trying to : implement it may make for a nice weekend kind : of project. Starting from a newbie's vague : acquaintance with Python facilities, I reason...: : Let's see -- basically I want line by line copying : of an input "template" stream, to an output one, : while some variables get substituted. But why : just variables -- let's make it expressions -- the : "eval" builtin should make those just as easy, I : think. But how do I demarcate the expressions, : any given syntax I might choose would surely : be awkward for some uses. Hmm, regular : expressions should help -- the caller will pass : me a re, and the first parenthesized group in : it will be the expression to eval, with which the : re itself will be substituted -- neat. Of course, : I'll also need a dictionary for the eval itself. I messed with this problem the other day, and ended up with (roughly): for filename in filenames: try: # scan the input file fpin = open(filename, "r") lines = fpin.readlines() newlines = [] for line in lines: newline = cleanline(line) newlines.append(newline) fpin.close() os.remove(filename) # write out the results fpout = open(filename, "w") fpout.writelines(newlines) fpout.close() except IOError, badthing: print sys.exc_value Cleaner than the setup you used, but not the way I'd have chosen to write the program - I'd have preferred to read and write single lines at a time. However, the files I was working on were all < 10K, so I accepted the additional memory usage. My initial shot used a line count variable in addition to the for loop, and was really clumsy. It would be nice if there were some built-in index to a for loop, but I can't see how it could be reliably implemented. Will cwr at crash.cts.com From grant at nowhere. Thu Dec 9 20:52:20 1999 From: grant at nowhere. (Grant Edwards) Date: Thu, 09 Dec 1999 19:52:20 GMT Subject: Examples or docs for snack? Message-ID: Can anybody suggest any pointers to documentation for or examples of using the snack module (wrapper for newt/slang)? -- Grant Edwards grante Yow! I want another at RE-WRITE on my CEASAR visi.com SALAD!! From skip at mojam.com Wed Dec 8 17:43:18 1999 From: skip at mojam.com (Skip Montanaro) Date: Wed, 8 Dec 1999 10:43:18 -0600 (CST) Subject: exchanging data btwn Python and lesser languages In-Reply-To: References: <82jau6$e72$1@nnrp1.deja.com> <1267538634-27138233@hypernet.com> <14413.33938.300484.712295@dolphin.mojam.com> Message-ID: <14414.35494.430554.162727@dolphin.mojam.com> Harry> What's the relationship between XML-RPC and Microsoft's SOAP? To vastly oversimplify: same roots, different result. As I understand it, the SOAP stuff actually started before XML-RPC. Dave Winer was involved with SOAP and eventually wanted something for Frontier before SOAP was going to be available. XML-RPC is the result. 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 garry at sage.att.com Thu Dec 2 23:21:07 1999 From: garry at sage.att.com (Garrett G. Hodgson) Date: Thu, 2 Dec 1999 22:21:07 GMT Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: <3846F0D3.CA1E75@sage.att.com> Robin Becker wrote: > Presumably programmers will have another field day in the years running > up to 9999. sooner. in 2038 or so the unix time value runs out of bits. > They can mumble on about all the flag dates and also the > Y10k problem at the same time. we'll just let the cockroaches deal with that one. -- Garry Hodgson "Hey, mister, can ya tell me, garry at sage.att.com where a man might find a bed?" Software Innovation Services He just grinned and shook my hand, AT&T Labs "No", was all he said. From paul at prescod.net Tue Dec 28 10:02:04 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 28 Dec 1999 04:02:04 -0500 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <14439.35987.402193.17280@anthem.cnri.reston.va.us> <14440.14505.603625.329128@dolphin.mojam.com> Message-ID: <38687C8C.DAAB9513@prescod.net> Skip Montanaro wrote: > > ... > > Hmm. Attributes, but no methods? Why doesn't the current class notion > solve the problem? Class instances are not tuples. If you use tuples in your code then you know that they have virtues that instances do not. > In fact, I'm not sure what the problem you're trying to > solve is. Unreadable tuple-based code like this: j = mytuple[11] Of course the usual way to work around this is to do this: j = mytuple[someconstantpool.someconstant] But now you have to memorize the location of the constant pool (if available!) and your execution is slowed by all of the lookups. > What's the result of > > time = (hour=24, minute=00, second=00) > point = (x=1, y=2, z=3) > > time = point "time" is an alias for "point"! Python doesn't do type checking of assignments. It doesn't matter whether time and point are tuples, super-tuples, classes or integers. Paul Prescod From guido at CNRI.Reston.VA.US Wed Dec 15 00:26:34 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Tue, 14 Dec 1999 18:26:34 -0500 Subject: Don't forget to register for the Python conference! Message-ID: <199912142326.SAA00634@eric.cnri.reston.va.us> We know that the Python conference isn't until the next millennium. You still have THREE WHOLE WEEKS to register and qualify for the early bird registration. However, at least one of those weeks you will have partying and family gatherings on your mind, and when that week's over, recovery from the partying and gathering will probably take priority over registering for the conference, and as a result you might be PAYING FULL PRICE! (The horror!) That is, if your payment isn't received by January 5, 2000. So, be smart and register *before* Christmas. That's still more than ten days -- plenty of time to make travel arrangements, register for the conference, and present your boss with the bill (in that order). Our motto, due to Bruce Eckel, is: "Life's better without braces." Some highlights from the conference program: - 8 tutorials on topics ranging from JPython to Fnorb; - a keynote by Open Source evangelist Eric Raymond; - another by Randy Pausch, father of the Alice Virtual Reality project; - a separate track for Zope developers and users; - live demonstrations of important Python applications; - refereed papers, and short talks on current topics; - a developers' day where the feature set of Python 2.0 is worked out. Come and join us at the Key Bridge Marriott in Rosslyn (across the bridge from Georgetown), January 24-27 in 2000. Make the Python conference the first conference you attend in the new millennium! The early bird registration deadline is January 5. More info: http://www.python.org/workshops/2000-01/ --Guido van Rossum (home page: http://www.python.org/~guido/) From fredrik at pythonware.com Fri Dec 3 13:45:11 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 3 Dec 1999 13:45:11 +0100 Subject: Is there a proxy-enabled version of httplib.py anywhere? References: Message-ID: <009801bf3d8c$3e2ff7b0$f29b12c2@secret.pythonware.com> Tony McDonald wrote: > The subject says it all really - I believe that I'm supposed to use urllib > rather than httplib, but what can you do when urllib calls httplib to do > some calls! :( set the http_proxy environment variable, and be done with it? :) (urllib implements the proxy stuff on top of httplib. see the code for details; especially the getproxies function). From robin at jessikat.demon.co.uk Sun Dec 19 01:53:36 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sun, 19 Dec 1999 00:53:36 +0000 Subject: The Official Naughty Or Nice List References: <199912190039.TAA30901@peterjh.goshen.edu> Message-ID: In article <199912190039.TAA30901 at peterjh.goshen.edu>, Santa's Little Helper writes > >Ho, Ho, Ho, python-list at python.org, > ... Satan's little helper is always welcome. Santa in Dutchland is to be accompanied by Black Pete. Interestingly my spell checker insists that satan be spelled with a capital. -- Robin Becker From gmcm at hypernet.com Tue Dec 7 20:38:33 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 7 Dec 1999 14:38:33 -0500 Subject: tiny python In-Reply-To: References: Noel Burton-Krahn's message of "7 Dec 1999 17:44:30 -0000" Message-ID: <1267527440-27811987@hypernet.com> Fran?ois Pinard wrote: > Could we turn this into a contest? It might be instructive. A > bit like with SIOD for Scheme, say. By the way, would it be > workable to implement Python in Scheme? Who knows, this might > buy us a compact notation for algorithms. There is little chance > to see a winning solution in COBOL, say. :-) One year, the Deming prize in the object oriented category went to a system written in COBOL. certifiably-non-ISO-9K-ly y'rs - Gordon From fredrik at pythonware.com Wed Dec 15 10:46:55 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 15 Dec 1999 10:46:55 +0100 Subject: Tkinter/IDLE crash References: <000c01bf4553$5e739b20$9e2d153f@tim> Message-ID: <007001bf46e1$535aaaa0$f29b12c2@secret.pythonware.com> dg wrote: > > WRT the IDLE problem, check the FAQ and/or DejaNews for things that can go > > wrong with your Tcl/Tk installation. Make sure that's working *before* > > messing with IDLE. You may have a conflicting set of Tcl DLLs on your > > system. > > > > Get into a DOS box Python and try this: > > > > >>> import Tkinter > > >>> Tkinter._test() > > >>> > > > > Chances are it will fail; the msgs you get will help you to fix it. > > Yes, I had discovered this a couple days ago. What happens is an error > messages that says init_tcl cannot be found. However the list of places > that the program is looking for init_tcl bear no relation to where it was > installed. I've checked the registry entries for Python and they appear > to be ok according to what is published at python.org. Any ideas where > to look next? Thanks. the info on this page might help: http://www.pythonware.com/people/fredrik/fyi/fyi02.htm cannot recall ever seeing messages about "init_tcl", though... From emile at fenx.com Sat Dec 4 04:45:32 1999 From: emile at fenx.com (Emile van Sebille) Date: Fri, 3 Dec 1999 19:45:32 -0800 Subject: indentation Message-ID: <016f01bf3e0a$04a85900$01ffffc0@worldnet.att.net> I like Python's indentation... but I also recently got pulled back into a postscript project I did 10 years ago and someone had *cleaned* up the code with indentation! I actually found it harder to follow (than my continue-as-one-line-to-emulate-the-stack((lack-of))style). It just felt as if the whitespace got in the way of what was happening. Things like, why break there? etc, crept into my thoughts and then I could start again... consider- if-tim- signed-off-like- this- all-the- time-ly yr's -- Emile van Sebille emile at fenx.com ------------------- Thomas Hamelryck wrote in message news:829da5$s4d$2 at mach.vub.ac.be... > Fred L. Drake, Jr. (fdrake at acm.org) wrote: > : Gerrit Holl writes: > : > As i said: people who start with Python as a first language like it. > : There are those of us who started with x86 assembly and BASIC who > : like it too! (And Pascal, and C, and C++, and... hey, how many places > : can one person start in, anyway? ;) > > As far as I can tell it's certainly not only the novices who like the use > of indentation. Some pretty experienced programmers are very much in favor > of indentation as well. I guess it's just not my thing. > > -- > Cheers, > > ------------------------------------------------ > Thomas Hamelryck//Free University Brussels (VUB) > Intitute for Molecular Biology// ULTR Department > Paardestraat 65//1640 Sint-Gensius-Rode//Belgium > ------------------------------------------------ > > -- > http://www.python.org/mailman/listinfo/python-list > > From allen at rrsg.ee.uct.ac.za Wed Dec 22 09:36:56 1999 From: allen at rrsg.ee.uct.ac.za (Allen Wallis) Date: Wed, 22 Dec 1999 10:36:56 +0200 Subject: JPython newbie, CLASSPATH question Message-ID: <83q2c5$4ac$1@news.adamastor.ac.za> Hi, I'm just starting out with JPython, but I have a fair experience in Java programming. Is there a means by which one can can alter the classpath from within python's shell? It's easy to adjust the .bat file that starts JPython to include my java classes there, but is it possible to do this once jpython has started? Basically I want to be able to type "from mypackage import myclass", but obviously mypackage must be accessible from some path that python knows about. any help appreciated. Allen From mlh at vier.idi.ntnu.no Tue Dec 7 01:52:32 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 07 Dec 1999 01:52:32 +0100 Subject: About PIL References: <007601bf3fe5$6f11c740$f29b12c2@secret.pythonware.com> Message-ID: Is PIL written entirely in Python, or is there a C module lurking in there? -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From greg.ewing at compaq.com Fri Dec 3 15:42:01 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Sat, 04 Dec 1999 03:42:01 +1300 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: <3847D6B9.881D7602@compaq.com> "David N. Welton" wrote: > > Doesn't the new millenium actually start in 2001? Just make the conference last all year, then you'll be right either way. Greg From m.faassen at vet.uu.nl Mon Dec 13 10:44:28 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 13 Dec 1999 09:44:28 GMT Subject: Suitability of Python for a Big Application? References: <830vic$r2t$1@nnrp1.deja.com> <83125j$5d$1@news1.xs4all.nl> Message-ID: <832f5s$iio$1@newshost.accu.uu.nl> Boudewijn Rempt wrote: > bobyu5 at mailcity.com wrote: [snip lots of good advice by Boudewijn] >> For 1) I thought I could solve this problem by using Zope - I get >> instantly a GUI that is based upon web browsers. This eliminates those >> annoying installation problems with customized DLLs as I found out using >> VB development approach. > I do find Zope a bit slow - even when I browse a Zope database on a > machine on my local network. I'm not entirely sure what you mean by this; Zope by itself isn't slow. I've heard both good and bad performance reports about Zope, but with tuning it can certainly be fast enough to handle even the slashdotting of a site. [snip rest] Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From godzilla at netmeg.net Tue Dec 7 00:04:09 1999 From: godzilla at netmeg.net (Les Schaffer) Date: Mon, 06 Dec 1999 23:04:09 GMT Subject: Video analysis with numpy... References: <007601bf3fe5$6f11c740$f29b12c2@secret.pythonware.com> Message-ID: said: > it would be *very* nice if the multiarray module was added to the > python core... (any volunteers?) i am confused by this question. i was under the distinct impression that it is a top down decision (guido on down) on whether to integrate multiarray into python. no? or am i confusing a call for volunteers with a command level decision to give go ahead to such project? does the latter already exist? lastly, whats there to read on how to "add to the python core". i've done extensions in C, but dont know nuttin about core coding. les From gmcm at hypernet.com Wed Dec 22 17:39:23 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 22 Dec 1999 11:39:23 -0500 Subject: file time to dos time In-Reply-To: <3860F59A.9CEEE42E@src.uchicago.edu> Message-ID: <1266242622-25873811@hypernet.com> Nick Collier writes: > > I'm trying to convert the results of os.path.getmtime(path) - > last modification time in seconds since the epoch - to the dos > time format which I think is a 36 bit number with bit fields for > the year, month, day, hour, seconds. I'm coming close with some > guessed at bitwise arthimetic, but can't get the year correct. > Any suggestions? Since what you're doing is platform specific, why not use DosDateTimeToTime from the Win32 extensions? MSVC Help text says (hope the paste comes out looking OK): wFatDate Specifies the MS-DOS date. The date is a packed 16-bit value with the following format: {PRIVATE}Bits  Contents   0-4  Day of the month (1-31)   5-8  Month (1 = January, 2 = February, and so on)   9-15  Year offset from 1980 (add 1980 to get actual year)   wFatTime Specifies the MS-DOS time. The time is a packed 16-bit value with the following format: {PRIVATE}Bits  Contents   0-4  Second divided by 2   5-10  Minute (0-59)   11-15  Hour (0-23 on a 24-hour clock)   - Gordon From gmcm at hypernet.com Sun Dec 12 20:47:54 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sun, 12 Dec 1999 14:47:54 -0500 Subject: Packaging packages? In-Reply-To: <_LQ44.106$Ef6.30979@news.shore.net> Message-ID: <1267095148-9883194@hypernet.com> Michael P. Reilly wrote: > Gordon McMillan wrote: [some stuff about Installer & archives...] > My first point was that mine is a native _or_ C implimentation > (read/write compatibility). Last summer you would only make the > docs and a win32 installer available (I even asked and just got > that info), so I just had the docs to go on; you still only > mention Windows and Linux. My second point that your format > implimentation in CArchive was more usable than mine. Um, I wasn't comparing or contrasting in any way. I was trying to counter some misperceptions, (in fact, I wasn't really replying to you - this has come up recently both on c.l.py and other venues). [Not sure why you say you just had the docs to go on - all source is and has always been included. It's true you need a Windows box for the self-extracting executable, but I can make tar.gz's too.] > I didn't object to your module, or publish mine, last summer > because I thought CArchive had potential, just not complete > (considering I could only get design specs). Mine was more akin > to your ZlibArchive, which is also why I didn't mention mine last > summer. > > You concentrate too much on encapsulating everything into one > file - archive, executable, etc. As you say, this is only useful > for Windows, useless for anything else. Mine concentrated in > encapsulating modules and packages into one or more "cans" to > allow transparent loading (adding the filename to sys.path > directly). Different approaches. And that's the other one (that gave rise to this thread). It's true that the announcements have emphasized "encapsulating everything", because it's the most oft repeated request is for a compiler-less freeze. But the lower levels are there, and have a documented API. I hadn't pushed them as cross-platform because Windows users kept me real busy with their bug reports / enhancement requests. In fact, I was saying "it *should be* cross platform" and only got around to verifying that it is a couple weeks ago. I'm also lazy - I don't want to do 2 announcements. Unfortunately, people who aren't attracted by Win32 Installers don't read the announcements, and so miss out on the fact that there's a bunch of stuff they could potentially use. > I do not care at all for imputil, but made my module compatable > with it. Get used to it ;-). It's going to be the basis for importing in 1.6. Jim Ahlstrom also has an archive format; see ftp://ftp.interet.com/pub/pylib.html I'm really not attached to one format over another; except that I see reaons for having 2 types (one strictly for .pyc's, another that can contain anything). What I would like people to realize is that I've put considerable effort into generalizing the building of these things, to the point where, 99% of the time, you can create a simple config file, run Builder on it and out pops an archive. - Gordon From pinard at IRO.UMontreal.CA Sat Dec 11 04:18:02 1999 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 10 Dec 1999 22:18:02 -0500 Subject: TECO (was: Re: FORTRAN (was Re: indentation)) In-Reply-To: aahz@netcom.com's message of "11 Dec 1999 02:30:58 GMT" References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> <82mjag$7oh$1@nntp2.atl.mindspring.net> <38509328.B0844DD6@Lugoj.Com> <82sd12$1b3$1@nntp3.atl.mindspring.net> Message-ID: aahz at netcom.com (Aahz Maruch) writes: > >Jim (who once started to argue with Marvin Minsky without knowing who he > >was) I will always remember the first time I met Marvin, quite a long while ago. I was invited by Seymour Papert and Cinthia Solomon (some of you might know them?) to spend a few days in the AI labs of the MIT. I did not know that Marvin Minsky was working there (yet the name was familiar to me already, because older people told me about him, and got me to see some of his books). While walking in, I merely saw the top of his half-bold head facing me, bent as he was over his TFH machine (a CPU specialized towards turtle graphics), with a soldering gun I guess, as tiny smoke was climbing up through him, from the table. Seymour told me who he was, and that he was just beginning repairs after a power supply burned out, due to some short-circuit. Not a fun day for him, apparently. But Marvin, his daughter Margaret, and all the team in fact, have been absolutely superb with me all along, while I was there. That's one of the good rememberings of my naive youth. Among many, many interesting projects, ideas, prototypes and machines, they showed me a terminal (no much personal computers at that time! :-), maybe using around 2400 bauds, in which the cursor was running like hell all over the screen to balance et re-indent LISP expressions, in full duplex with the typing. They told me that this was a sophisticated TECO application, for which they felt really proud. I do not know exactly what it was, but I later wondered if it was not the original EMACS, there... -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From Alex.Martelli at think3.com Wed Dec 15 17:47:45 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Wed, 15 Dec 1999 17:47:45 +0100 Subject: C++ (was RE: Python suitability) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D47@pces.cadlab.it> Brett writes: > "Alex Martelli" wrote in message > news:6D8A17398E28D3119F860090274DD7DB4B3D43 at pces.cadlab.it... > > Grant writes: > > > > I'm not surprised that a Python enthusiast may not appreciate > > C++'s basic underlying philosophy, since it's so close in many > > surprising respects to Perl's -- reading Larry Wall's musings on > > his language, and Stroustrup's on his own, side by side, can > > be very enlightening in this respect, more than the huge surface > > differences between Perl and C++ might lead one to expect. > > > Alex -- > could you give a quick followup to this paragraph? If the LW 'musings' are > available online, URLs would be fine -- I've got the important Stroustrup > stuff here. Just having difficulty picturing the philosophical common > ground > between these 2 languages. > > Basically, TMTOWTDI <-> "multi-paradigm" -- the Stroustrup/C++ way of expressing it is more "pompous", or "dignified" if you prefer:-), of course. I'm pretty sure the author's prefaces to "Programming in Perl" and "The C++ Programming Language" have a summary of these stances on "why I designed/developed this language, and, why this way" (but "C++ Design and Evolution" might have more, I don't recall) and you stand a good chance of finding similar material on Stroustrup's homepage (whose URL I don't have at hand) and on www.perl.org. Alex From mfletch at tpresence.com Sun Dec 19 21:50:49 1999 From: mfletch at tpresence.com (Mike Fletcher) Date: Sun, 19 Dec 1999 15:50:49 -0500 Subject: LISTS: Extract every other element - SUMMARY Message-ID: Was a problem with my testing methodology (profile). Apparently profile adds an extra penalty for each function call :( . Revised testing framework is below, along with results (that do, indeed, show a significant speedup for algo7). Sorry about that. Guess I'll have to stop trusting profile for my profiling needs :( . Revised testing algo: def bigTest( ): for exponent in range(1, 7): # up to 10**7 (10 million) data = range( 10**exponent) print 'DATA LENGTH', len(data) for function in [ forMult,forDiv, numReshape, numSlicing, chrisGiven, chrisInline]: avg = [] for x in range(5): t = time.clock() function( data ) avg.append( time.clock()-t ) print '%s %.4f'%(function, reduce( lambda x,y: x+y, avg )/len(avg)) p:\>take DATA LENGTH 10 0.0001 0.0000 0.0001 0.0001 0.0001 0.0001 DATA LENGTH 100 0.0001 0.0001 0.0001 0.0001 0.0002 0.0002 DATA LENGTH 1000 0.0010 0.0010 0.0004 0.0005 0.0006 0.0005 DATA LENGTH 10000 0.0092 0.0106 0.0036 0.0035 0.0051 0.0040 DATA LENGTH 100000 0.1048 0.1174 0.0423 0.0429 0.0625 0.0503 DATA LENGTH 1000000 1.0831 1.2168 0.4660 0.4605 0.6465 0.5405 p:\> -----Original Message----- From: Christian Tismer [mailto:tismer at appliedbiometrics.com] Sent: Sunday, December 19, 1999 3:19 PM To: Mike Fletcher Cc: python-list at python.org Subject: Re: LISTS: Extract every other element - SUMMARY ... What funny machine/Python do you have ??? Algo 7 is 2.5 times faster on my P200 /Py1.5.2/Windooze. Here Algo 8 vs. Algo 7: (as expected): >>> timing(algo7, data, 10)[0] 1.15 >>> timing(algo8, data, 10)[0] 1.1 >>> ... From tony at lsl.co.uk Mon Dec 13 14:45:08 1999 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Mon, 13 Dec 1999 13:45:08 -0000 Subject: Python and regexp efficiency.. again.. :) Message-ID: <000101bf4570$44a745d0$f0c809c0@lslp7o.lsl.co.uk> > Tim (from Parnassus) - said: > > VoP to the rescue! Url should be... > > http://www.tibsnjoan.demon.co.uk/mxtext/Metalang.html > > (the mxTextTools page accidentally has lower case 'm') and I apologised that it was my fault. I have now fixed this by the Brute Force (TM) method - i.e., there is now a copy of that page at the URL with a lower case "m" as well as the URL with an upper case "M". Sorry to anyone this has incovenienced. -- Tony J Ibbs (Tibs) http://www.tibsnjoan.demon.co.uk/ "How fleeting are all human passions compared with the massive continuity of ducks." - Dorothy L. Sayers, "Gaudy Night" My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From robin at jessikat.demon.co.uk Thu Dec 23 01:08:53 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 23 Dec 1999 00:08:53 +0000 Subject: Please test new dynamic load behavior References: Message-ID: In article , Greg Stein writes >Hi all, > >I reorganized Python's dynamic load/import code over the past few days. >Gudio provided some feedback, I did some more mods, and now it is checked >into CVS. The new loading behavior has been tested on Linux, IRIX, and >Solaris (and probably Windows by now). > what problem is the updated code a fix to? -- Robin Becker From fredrik at pythonware.com Tue Dec 7 14:11:31 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 7 Dec 1999 14:11:31 +0100 Subject: Help with tuples please? References: <82ivrl$744$1@rtpnews.raleigh.ibm.com> Message-ID: <01fa01bf40b4$c570acd0$f29b12c2@secret.pythonware.com> Arinte wrote: > Here is were my PyArg_ParseTuple is failing... > > in python's source getargs.c > > if (!PyTuple_Check(args)) > > PyErr_SetString(PyExc_SystemError, > "new style getargs format but argument is not a tuple"); > > I don't understand why that is happening? Is there another way to get the > value from a PyObject > > This is my c++ code... > > char* vstr; > nobj = PyObject_GetAttrString(tobj,"argname"); <-successful, nobj not null > if(!PyArg_ParseTuple(nobj, "s", &vstr)){ <-here is where it fails > appcallback()->messageBox("not again"); > } > > tobj is an object of the type below from an array (list) that I pass from > python to c++. > > class PossArg: > argname="" argname sure looks like a string to me. the parsetuple function is used to pull tuples apart, mostly when dealing with argument tuples. but a string is not a tuple. to deal with string objects, use the PyString functions: http://www.python.org/doc/current/api/stringObjects.html typical usage patterns: char *p; int n; if (PyString_Check(nobj)) { p = PyString_AS_STRING(nobj); n = PyString_GET_SIZE(nobj); ... /* use as byte buffer */ } or: if ((p = PyString_AsString(nobj)) != NULL) ... /* use as null terminated C string */ From vaton at postoffice.pacbell.net Tue Dec 28 03:35:39 1999 From: vaton at postoffice.pacbell.net (Robert Shockley) Date: Mon, 27 Dec 1999 18:35:39 -0800 Subject: How do I make a Python .bat executable file? References: <1265818152-51405200@hypernet.com> Message-ID: <386821FB.E71BD847@postoffice.pacbell.net> Thanks a lot for the info, your solution is the one I was looking for (a windows equivalent to the pound-bang trick ~Rob~ Gordon McMillan wrote: > Robert Schockley writes: > > > What kind of 'wrapper' is needed to make a python script an > > executable .bat file in Windows? Is the she-bang (#!/...) line > > required? I would appreciate any help. ~Rob~ > > shebang does nothing on WIndows. > > Most people use the file extension association (.py -> > python.exe) which the installer sets up for you. Unfortunately, > file redirection is broken (in general) when using file > associations, so: > >python myscript.py >out.txt # works > >myscript.py >out.txt # doesn't > > The more direct equivalent of the shebang trick would be (this > version courtesy of Bruce Eckel): > ---------------------------------------------------------- > @echo off > rem = """ > rem run python on this bat file. Needs the full path where > rem you keep your python files. The -x causes python to skip > rem the first line of the file: > python -x c:\aaa\Python\\"%0".bat %1 %2 %3 %4 %5 %6 %7 %8 %9 > goto endofpython > rem """ > > # The python program goes here: > > print "hello, Python" > > # For the end of the batch file: > rem = """ > :endofpython > -------------------------------------------------------------- > ...which I never use because none of my editors are smart enough to > syntax colorize a Python script with a .bat extension. > > - Gordon From gchiaramonte at ibl.bm Mon Dec 27 15:32:13 1999 From: gchiaramonte at ibl.bm (Gene Chiaramonte) Date: Mon, 27 Dec 1999 10:32:13 -0400 Subject: File Size Limits on Windows 98 and NT Message-ID: <847sq7$spe$1@ffx2nh5.news.uu.net> Anyone know the file size limits for marshal, pickle, cPickle and shelve created files under windows 98 and NT? Thanks, Gene From gmcm at hypernet.com Tue Dec 28 23:41:32 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 28 Dec 1999 17:41:32 -0500 Subject: Py2K wishes In-Reply-To: <38693545.894CE515@prescod.net> Message-ID: <1265702489-58362226@hypernet.com> Paul Prescod wrote: [his __fallback__ idea] > The "fallback" code is presumably very optimized and is of course > written in Python. It is often the case that I want to have a an > instance that "falls back" to some other instance. For instance I > might have an object that almost does what I want but I need to > wrap some of the methods to be Unicode aware. The other methods > should just "fall back" automatically. This sort of proxying is > also useful for working around cycles. Typically we code this by > hand using __getattr__. If you're catching specific methods, why not subclass? OTOH, if your code looks like: class Proxy: ... def __getattr__(self, nm): attr = getattr(self.__obj, nm) if type(attr) == type(''): return Unicode(attr) return attr then I fail to see how a __fallback__ thingie is going to make your life any easier. - Gordon From jeremy at cnri.reston.va.us Fri Dec 3 18:16:37 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Fri, 3 Dec 1999 12:16:37 -0500 (EST) Subject: Python Type-Inference based LINT.. (pylint.py) In-Reply-To: <14406.62038.707967.348914@dolphin.mojam.com> References: <19991121180043.B3184@teapot.egroups.net> <81e2r7$j14$1@newshost.accu.uu.nl> <383BC3D2.98BCD1FF@compaq.com> <81ktpm$33g$1@newshost.accu.uu.nl> <3843D365.8B530226@maxtal.com.au> <38466D02.BAC4A1F6@compaq.com> <14406.62038.707967.348914@dolphin.mojam.com> Message-ID: <14407.64245.424116.159879@goon.cnri.reston.va.us> >>>>> "SM" == Skip Montanaro writes: SM> 2. I'd add a few meta types that correspond to the API SM> behaviors (e.g., "number", "sequence", "mapping", ...). That SM> would allow the type inferencer to make assumptions about the SM> behavior of an argument without the programmer enumerating all SM> the possible objects that could fill the bill. These fake types SM> could be added to the types module and set equal to None. All SM> you'd really be interested in is the names anyway (I think). Here's a variation that I have been thinking about; not sure if it makes sense. Instead of having types that correspond to sequence, mapping, etc. use a set of micro-types that apply to specific API calls. So a type might have __getitem__ and __len__. It's not unusual to have a user-defined class that only implements a few of the methods you'd expect a sequence to have. Jeremy From chapman at bioreason.com Thu Dec 16 20:13:03 1999 From: chapman at bioreason.com (Mitch Chapman) Date: Thu, 16 Dec 1999 12:13:03 -0700 Subject: Pipe error codes off by a factor of 256 References: <83ba4k$9ia$1@nnrp1.deja.com> Message-ID: <385939BF.7B21C26E@bioreason.com> I assume you're talking about the value you get when you close the pipe. The semantics for that value are the same as for the wait(2) system call. The exit code for a process which exits of its own free will is stored in the top 8 bits of the 16-bit return code. In other words, see the man page for wait(2). Ben Glazer wrote: > > I'm trying to capture the error code from a pipe opened with os.popen(). > > I can successfully store the returned code in a variable, but the > returned code always is exactly 256 times larger than it should be. -- Mitch Chapman chapman at bioreason.com From fdrake at acm.org Tue Dec 14 21:25:47 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 14 Dec 1999 15:25:47 -0500 (EST) Subject: Documentation Translations Message-ID: <14422.42955.688108.522178@weyr.cnri.reston.va.us> I'd like to thank Marcos S?nchez Provencio for his translation of the Python Tutorial into Spanish; thanks! I've added a link from the list of non-English resources available at: http://www.python.org/doc/NonEnglish.html I think Python has benefitted from an involved, international community, and we're seeing an increase in the number of available translations. Unfortunately, the list of available materials is *in* English. While that's convenient for Barry & me as we maintain www.python.org, that doesn't seem to be the best way to provide information to people who either don't read English or don't read it well. I'd appreciate help in maintaining the list of non-English resources in the languages those resources are in. I can handle setting up additional pages and configuring the Web server to add any headers needed to properly identify language and character sets for non-English pages if I can get someone to provide and maintain the content in each of the languages represented. If you can help maintain this information in a language other than English, or provide guidance about how I can help support the work of translators, I'd appreciate the help. Please contact me via email if you would like to help. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From grant at nowhere. Tue Dec 28 23:27:26 1999 From: grant at nowhere. (Grant Edwards) Date: Tue, 28 Dec 1999 22:27:26 GMT Subject: why? References: <38685b07.189574443@news.isomedia.com> Message-ID: In article <38685b07.189574443 at news.isomedia.com>, Eugene Goodrich wrote: >On Tue, 28 Dec 1999 03:40:32 GMT, "ekko" wrote: > >>I don't know that much about Python and I have some questions. Why would I >>want to learn Python. What uses does it have? What kind of programs can I >>make with Python? Thanks. > >I think it might be quicker if we answered the inverses of some of >these questions. For instance, What uses doesn't it have? OK, I'll start: 1) You can't write device drivers in Python (at least not for any OS of which I am aware). 2) It isn't suitable for use in embedded systems with limited memory. -- Grant Edwards grante Yow! I feel like I am at sharing a "CORN-DOG" with visi.com NIKITA KHRUSCHEV... From fdrake at acm.org Thu Dec 23 14:59:01 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 23 Dec 1999 08:59:01 -0500 (EST) Subject: Matching a constant string at beginning In-Reply-To: References: Message-ID: <14434.10917.222100.686450@weyr.cnri.reston.va.us> Fran?ois Pinard writes: > is rather tedious. Of course, I could write a very small function to > match a constant string at the beginning of another, but there just must > be some idiom for doing this. Fran?ois, Another possibility, if you're willing to use the CVS version(!), is to use the string methods: s = some string... if s.startswith("Simpsons"): do something interesting... Or you could write that annoying little function while waiting for 1.6. ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From aa8vb at yahoo.com Wed Dec 29 19:08:07 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 29 Dec 1999 13:08:07 -0500 Subject: ??? Tkinter destroy() - Remove a widget from a frame. In-Reply-To: <9fda4.2935$BL.215638@brie.direct.ca> References: <9fda4.2935$BL.215638@brie.direct.ca> Message-ID: <19991229130807.C692595@vislab.epa.gov> Colleen & Brian Smith: |What is the proper way to destroy() the "display" widget (which is actually |a Label descendent -- taken from the Viewer.py script that comes as a demo |for the Python Imaging Library) in the code below, so that I can recreate |it and load a new image in the UnloadPic method? ... |from viewer import UI ... |from tkFileDialog import * | |class Application(Frame): ... | self.display = UI(self,self.pic).pack(side=TOP) ... | self.display.destroy() # does not work Yep, I've done that. :-) You're not doing what you think you're doing. Notice: > python >>> from Tkinter import * >>> root = Tk() >>> btn1 = Button( text="1" ) >>> btn1.pack() >>> hmmm = Button( text="2" ).pack() >>> print btn1 .270148832 >>> print hmmm None hmmm is not the second Button you created. It's not set to what Button() returns, but rather what Button.pack() returns. This is self.display in your case. Are you getting an error that looks something like this?: AttributeError: 'None' object has no attribute 'destroy' That's what's going on. -- Randall Hopper aa8vb at yahoo.com From gerglery at usa.net Wed Dec 1 14:37:03 1999 From: gerglery at usa.net (Alternative Fluffy) Date: 01 Dec 1999 08:37:03 -0500 Subject: PyArg_ParseTuple() and oprtional remaining argument lists References: <000c01bf3a70$ae184ec0$3acbd9c2@peridot.optichrome.com> <_k914.622$3N2.155189@news.shore.net> Message-ID: <8766yiaikg.fsf@meowhost.meow.invalid> Michael P Reilly wrote: > It might be better to use METH_VARARGS instead of 1, in case the value > changes in a future release. An old one, but... From drek at MonsterByMistake.Com Thu Dec 16 23:36:58 1999 From: drek at MonsterByMistake.Com (Agent Drek) Date: Thu, 16 Dec 1999 17:36:58 -0500 (EST) Subject: Newbie Getopts Question In-Reply-To: <385952D1.AB04A9FF@coastalnet.com> Message-ID: On Thu, 16 Dec 1999, Andrew N. McGuire wrote: |Date: Thu, 16 Dec 1999 15:00:01 -0600 |From: Andrew N. McGuire |To: python-list at python.org |Newsgroups: comp.lang.python |Subject: Newbie Getopts Question | |Hey all, | | I picked up my first python book 5 days ago, so dont laugh at me too |hard. I have looked in man |page, Learning Python by O &A, and python.org, as well as here, and |found nothing __substantial__ |on the use of getopts. Here is a code snipet of a program I have |written... The programs works |fine, and I really like the language, but this seems like a somewhat |ineffecient way of handling |options. I always check: /usr/local/src/lang/Python-1.5.2/Demo the 'scripts' directory has some examples of getopt which I assume to be the most 'correct'. good luck, =derek From alex at magenta.com Fri Dec 10 14:30:13 1999 From: alex at magenta.com (Alex Martelli) Date: Fri, 10 Dec 1999 14:30:13 +0100 Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <001d01bf42bd$4c9d69a0$60a2143f@tim> Message-ID: <82qv8m$jbf$1@serv1.iunet.it> Tim Peters wrote in message news:001d01bf42bd$4c9d69a0$60a2143f at tim... [snip] > Join the PSA (see http://www.python.org/) and you'll get a free account on ok -- I just faxed my Cc data for the $50... I'll think of it as a Christmas gift to myself!-) Alex From robin at jessikat.demon.co.uk Sat Dec 11 18:12:03 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sat, 11 Dec 1999 17:12:03 +0000 Subject: FORTRAN (was Re: indentation) References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> <82mjag$7oh$1@nntp2.atl.mindspring.net> <38509328.B0844DD6@Lugoj.Com> <82sd12$1b3$1@nntp3.atl.mindspring.net> Message-ID: In article <82sd12$1b3$1 at nntp3.atl.mindspring.net>, Aahz Maruch writes >In article <38509328.B0844DD6 at Lugoj.Com>, >James Logajan wrote: >> >>Jim (who once started to argue with Marvin Minsky without knowing who he >>was) > >Oh, as long as we're name-dropping, I've swapped posts with Minsky in >comp.os.cpm.amethyst. ;-) >-- > --- Aahz (@netcom.com) > >Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ >Hugs and backrubs -- I break Rule 6 > >Sign up now! http://www.searchbutton.com/ I used to know Rudi Kalman, and earlier I played bongos in the park with Marc Bolan; used to work with Eric Clapton & nearly got sacked by Mick Jagger. Everybody knows somebody. As for the strong AI people, aren't they regarded as hopeless failures these days? -- Robin Becker From tiddlerdeja at my-deja.com Fri Dec 17 11:17:11 1999 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Fri, 17 Dec 1999 10:17:11 GMT Subject: pythoncom and MTS References: <83b5lq$5tr$1@nnrp1.deja.com> Message-ID: <83d2j6$ffv$1@nnrp1.deja.com> > Yep - no problems at all. (Well, actually a tiny registration problem in > builds 127 and earlier, but now fixed). Did you try a DejaNews search for > MTS on this newsgroup? Yep, didn't seem to get terribly much. Just my messages and some "exposing COM via" something. Is it related? Would you happen to have a noddy python COM object that implements MTS that I could have a look at? > > > -Also, a serious question, is pythoncom ready for primetime? (I've only > > just found it really). Again, I don't want to embark on a python > > solution if I'm going to run into bugs. > > If you dont want bugs, get out of the software game :-) pythoncom is very > stable - the guts is a couple of years old and been used heavily in a number > of projects. Thanks again. I didn't know the projects background. > > Mark. > > Sent via Deja.com http://www.deja.com/ Before you buy. From mkurzmann at carinthia.com Thu Dec 30 15:10:50 1999 From: mkurzmann at carinthia.com (Kurzmann Martin) Date: Thu, 30 Dec 1999 14:10:50 GMT Subject: Problems With stringformating... URGEND Message-ID: <386c66fc.6336922@news.carinthia.com> Hi ! i'm a kind of newbie in python an at now i have following problem: i will format the follosing text and insert some Variables (excerpt of my code) print "\n BEFORE MSG \n" msg="""Sehr geehrte/r %s ! Treffer! Diesen Moment sind neue Inserate auf unserem Online-Server im Bereich %s eingelangt, die unser Suchagent f?r Sie aufgesp?rt hat, passend zu Ihrer gespeicherten Suchabfrage. Genau diese Inserate k?nnen Sie unter folgender Adresse abrufen: http://xxx.xx.xxx.xx/%s/anzclu_%s.taf?_what=search&suchtyp=6&qid=%d Wir freuen uns auf Ihren Besuch und w?nschen Ihnen viel Erfolg beim Suchen und Inserieren! Mit freundlichen Gr??en, das Kleine Zeitung Online Team PS: F?r Anregungen und Kritik in Bezug auf unsere Online-Dienste sind wir sehr dankbar. Mail an den Webmaster (webmaster at kleinezeitung.at) gen?gt! Kleine Zeitung Online: http://www.kleinezeitung.at """ %emailrec, markt_alt, markt, markt, id print "\n AFTER MSG \n" print "\n" + msg + "\n" ANY IDEA WHATS wrong?? thanks in advance and a happy Y2K !! Kurzmann Martin mkurzmann at carinthia.com From ingling at ctrvax.vanderbilt.edu Tue Dec 28 00:05:32 1999 From: ingling at ctrvax.vanderbilt.edu (Allen W. Ingling) Date: Mon, 27 Dec 1999 23:05:32 GMT Subject: configuring 1.5.2c1 on Mac for Tkinter ? Message-ID: <3867F0AD.361B33D1@ctrvax.vanderbilt.edu> Hello, I'm new to Python. I've just installed the Macintosh self-installing python distribution version 1.5.2c1. Apparenlty, it is not pre-configured for Tkinter. If I import Tkinter, I get an error, "No Module Named Tkinter". So what must I do to import Tkinter ? Is it just a matter of adding directories to the Python path ? If so, which directories directories are needed for Tkinter ? I think the 1.5.2c1 installer claimed that it would install Tkinter, so I suspect it's all here but the paths are just not setup properly. Thanks. Allen Ingling Allen.W.Ingling at vanderbilt..edu From tomaz.ficko at agroruse.si Fri Dec 10 10:39:47 1999 From: tomaz.ficko at agroruse.si (Tomaz Ficko) Date: Fri, 10 Dec 1999 10:39:47 +0100 Subject: Copying files to file server References: <5_V34.3331$Cl3.17409@news-server.bigpond.net.au> Message-ID: Mark Hammond wrote in message <5_V34.3331$Cl3.17409 at news-server.bigpond.net.au>... >You can specify the file name with the UNC syntax: > >f = open(r"\\server\sharename\dir\filename.txt") > >Why didnt win32wnet work? What did you try and do? Are you sure you have >access to the share name - eg, can you type "dir \\server\sharename\dir" >from a command prompt? > >Mark. > > I want to login on the network and map remote dir to local dir. Here is what I tried with win32wnet: >>> import win32wnet >>> from winnetwk import * >>> win32wnet.WNetAddConnection2(RESOURCETYPE_DISK,'e:/','\\\\mars\\tehnolog\\fi cko','','username','password') Traceback (innermost last): File "", line 1, in ? win32wnet.WNetAddConnection2(RESOURCETYPE_DISK,'e:/','\\\\mars\\tehnolog\\fi cko','','username','password') api_error: (0, 'WNetAddConnection2', 'No error message is available') I want to write a script that will login on the network, copy the files to the server (backup) and disconnect from server. Is that possible with Python from Windows 95. Tom From jeff at parlant.com Thu Dec 2 19:09:26 1999 From: jeff at parlant.com (jeff) Date: Thu, 2 Dec 1999 11:09:26 -0700 Subject: Environment variables Message-ID: How do I set environment variables outside the python script? Basicaly, I want to run a python script to set some environment variables, then be able to use them in the shell that had called the python script (after the script had completed). I need this for both Linux and NT/Win2k. From grant at nowhere. Mon Dec 13 15:31:31 1999 From: grant at nowhere. (Grant Edwards) Date: Mon, 13 Dec 1999 14:31:31 GMT Subject: Old-timer UN*X trivia [was Re: Error confusing a newbie] References: <19991210100320.B18389@dmcom.net> <19991211161917.C27756@dmcom.net> Message-ID: In article , Mitchell Morris wrote: >Keith Dart wrote: >[snip] >>In Linux, it runs with a shell! It seems Linux defaults to >>/bin/sh if an executable text file is executed even without a >>#! as the "magic" number. I'm not sure if this is a bug or a >>feature... That's the way all of the Unix systems I've used for the past 15 years have worked. If a file is executble, and doesn't have a magic number, then it is assumed to be a /bin/sh script. >As a completely off-topic aside, when did the magic number >cease being "#! /" and turn into just "#!"? You'd have to look at the sources for the exec system call, but I've always understood that magic numbers were traditionally 16 bit values. -- Grant Edwards grante Yow! I like your SNOOPY at POSTER!! visi.com From LCortes at Flash.Net Thu Dec 30 05:01:27 1999 From: LCortes at Flash.Net (Luis Cortes) Date: Thu, 30 Dec 1999 04:01:27 GMT Subject: Python - CGI script Message-ID: <19991230.3584900@negrita.brunner.org> Hello, I am trying to figure out how to make a HTML page that will allow me to "upload" files to the server from the Client system. If anyone out there has some code I sure would appreciate it. Thanks, Luis. -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon at george.maths.unsw.edu.au Fri Dec 10 02:25:08 1999 From: simon at george.maths.unsw.edu.au (Simon Evans) Date: 10 Dec 1999 01:25:08 GMT Subject: Tkinter/IDLE crash Message-ID: <82pkpk$3o0$1@mirv.unsw.edu.au> I was making my first foray into Tkinter last night (using Py 1.5.2 and IDLE with Win 95). Like a good little learner, I typed in the simple example from "An introduction to Tkinter", chapter 3: --------------------------- from Tkinter import * class App: def __init__(self, master): frame = Frame(master) frame.pack() self.button = Button(frame, text="QUIT", fg="red", command=frame.quit) self.button.pack(side=LEFT) self.hi_there = Button(frame, text="Hello", command=self.say_hi) self.hi_there.pack(side=LEFT) def say_hi(self): print "hi there, everyone!" root = Tk() app = App(root) root.mainloop() --------------------------- Press the "Hello" button, and it says hello. Fine and dandy. But press the "Quit" button, and *everything* quits. The window, the IDLE session, everything! Goodbye python, goodbye IDLE, hello desktop. Anyone know what's going on here? Something wrong with my installation, perhaps? I'm a Unix boy, so I'll be the first to admit that I might have stuffed up the Windows setup somehow. ================================================================= Simon Evans (simon at maths.unsw.edu.au) Physical Oceanography Group School of Mathematics, University of New South Wales, Australia. http://www.maths.unsw.edu.au/ ================================================================= From aj10 at my-deja.com Wed Dec 1 00:36:02 1999 From: aj10 at my-deja.com (aj10 at my-deja.com) Date: Tue, 30 Nov 1999 23:36:02 GMT Subject: Removing null items References: <821761$s8u$1@nnrp1.deja.com> Message-ID: <821n12$8in$1@nnrp1.deja.com> In article <821761$s8u$1 at nnrp1.deja.com>, sragsdale at my-deja.com wrote: > So I've got a very simple desire: to remove all false (I.E. None, 0, '', > []) items from a list. > > As it is I've got this function which works fine, but it offends my > sight. Is there any better (or at least different) way to do this? > > ################################################################# > # return non-null items from the first list > def foo(lst): > rlist = [] > for i in lst: > if i: > rlist.append(i) > return rlist > > Sent via Deja.com http://www.deja.com/ > Before you buy. > This has been answered just recently. Repeating it in the right place with an example. -- Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> a=[None, 'aj', 'mk', 10, {1:2, 'a':10}, {}, None, []] >>> a [None, 'aj', 'mk', 10, {1: 2, 'a': 10}, {}, None, []] >>> filter(None, a) ['aj', 'mk', 10, {1: 2, 'a': 10}] >>> -- Thx -aj Sent via Deja.com http://www.deja.com/ Before you buy. From patdut01 at club-internet.fr Sat Dec 4 17:24:41 1999 From: patdut01 at club-internet.fr (patrick dutoit) Date: Sat, 04 Dec 1999 17:24:41 +0100 Subject: Problems using Opengl Message-ID: <38494049.B955743F@club-internet.fr> Hi I have got the Opengl package for Python and I have tested the examples. I always obtain the following message: Traceback (innermost last): File "first.py", line 3, in ? from OpenGL.GL import * File "/usr/lib/python1.5/site-packages/OpenGL/GL/__init__.py", line 7, in ? from _opengl import * ImportError: /usr/X11R6/lib/libMesaGL.so.3: undefined symbol: XFreePixmap Mesa was installed as a rpm package and didn't give me any troubles. So I don't understand what happens. If you have any idea or if you have meet the problem and have a solution to fix it, you're welcome. Regards From greg.ewing at compaq.com Fri Dec 10 08:55:44 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 10 Dec 1999 20:55:44 +1300 Subject: string interpolation syntactic sugar References: <82ogb2$db2$1@pegasus.csx.cam.ac.uk> <14415.57793.278683.360085@goon.cnri.reston.va.us> <14415.58717.115675.804984@dolphin.mojam.com> <14415.58951.132010.369194@goon.cnri.reston.va.us> Message-ID: <3850B200.B2094DE5@compaq.com> Jeremy Hylton wrote: > > SM> "a %(x)s b %(y)s" % locals() How about a unary version of the % operator: %"a %(x)s b %(y)s" would be equivalent to "a %(x)s b %(y)s" % locals() Greg From hansen at fsl.noaa.gov Tue Dec 21 23:26:11 1999 From: hansen at fsl.noaa.gov (Tracy Lee Hansen) Date: Tue, 21 Dec 1999 15:26:11 -0700 Subject: loading a Module from a Code object Message-ID: <385FFE83.6954B346@fsl.noaa.gov> Given a text string of Python code, I am making a code object as follows: result = code.compile_command(text) How can I load/create a module using this code object? In other words, I am storing text strings of Python code and do not want to store them in a file. Also, I need to examine the module.__dict__ to pick out methods and variables. Thanks! Tracy From rdudfield at my-deja.com Wed Dec 29 07:58:57 1999 From: rdudfield at my-deja.com (rdudfield at my-deja.com) Date: Wed, 29 Dec 1999 06:58:57 GMT Subject: obj in list and list ids the same References: <84a8k4$puq$1@nnrp1.deja.com> <84btoo$mem$1@nntp.Stanford.EDU> Message-ID: <84cavh$8cb$1@nnrp1.deja.com> In article <84btoo$mem$1 at nntp.Stanford.EDU>, amitp at Xenon.Stanford.EDU (Amit Patel) wrote: > wrote: > | Hello, > | > | I've got a problem where a list has the same id as a object instance in that > | same list. This is as returned by id(). > | > | Is this ever supposed to happen? I just thought this was odd. > > It is odd. > > Here's how it could happen: > > >>> a = [] > >>> a.append(a) > > >>> id(a) > 135070976 > > >>> id(a[0]) > 135070976 > > Let's try printing this: > > >>> a > [[...]] > > The list has a pointer to itself. I'm not sure if this is the same > problem you're seeing, but you might poke around to see if you're > accidentally using some list instead of some list[some index]. > Looks like I was doing something wrong for the id. After a nights sleep I found it in the morning. Thanks for the help Laurence and Amit :) It seems that deepcopy doesn't work for what I am doing. That is tempNode = copy.deepcopy(self) because tempNode.value[0].listOfShapes and self.value[0].listOfShapes have the same id. I guess this is reasonable. So I just manually copy the list with a new one, not too hard now that I know :) Sent via Deja.com http://www.deja.com/ Before you buy. From neelk at brick.cswv.com Sat Dec 18 01:28:38 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 18 Dec 1999 00:28:38 GMT Subject: LISTS: Extract every other element References: <19991216131341.A153923@vislab.epa.gov> <19991217112304.A1847@stopcontact.palga.uucp> <14426.29235.486363.37011@buffalo.fnal.gov> Message-ID: Charles G Waldman wrote: >Gerrit Holl writes: > > > Use the filter() builtin: > > > > Return a list containing those items of sequence for which function(item) > > is true. If function is None, return a list of items that are true. > >I think that the point was to return a list of the items for which the >*index* is odd, not the value. No problem: lst = range(10) class Predicate: def __init__(self): self.x = -1 def __call__(self, foo): self.x = self.x + 1 return self.x % 2 print filter(Predicate(), lst) => [1, 3, 5, 7, 9] Of course, this is not very^H^H^H^H at all fast. :) Neel From martineg at ifi.uio.no Sun Dec 19 06:21:01 1999 From: martineg at ifi.uio.no (Martin Eggen) Date: 19 Dec 1999 06:21:01 +0100 Subject: Python port on Open Edition References: <8E9EBCE5Etheistoperamailcom@207.69.128.201> <385A25BF.C718E4FA@bam.com> Message-ID: * Bill Scherer | http://www2.s390.ibm.com/products/oe/python.html | | Theist wrote: | | > I was unable to find the Python binaries for IBM OS390 Open | > Edition (a Unix variant running on IBM mainframes). Does | > anyone know if there is such a thing? | > | > Thanks, | > Raj | > -- | > http://www.python.org/mailman/listinfo/python-list Well, those are just patches for 1.4. I have not been able to get Python 1.5.x (or 1.4, for what it's worth) to compile on OS390V2R5 (also tried on R7). That is, it compiles nicely, but I got the weirdest problems linking it. It's been a while since I played around with it, but binaries (or proper patches for 1.5) would sure be nice. Nice to see other than me has been trying to get it to work, though. :) -- Martin Eggen http://www.stud.ifi.uio.no/~martineg/ From roy at popmail.med.nyu.edu Sat Dec 18 16:55:53 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Sat, 18 Dec 1999 10:55:53 -0500 Subject: circular references? References: <385B1AE9.DD4F8ED3@yifan.net> Message-ID: dj trombley wrote: > Introspection: That all depends on what one views as 'bad'. =) In this case, bad means I spend two days being in a really grumpy mood because my program isn't working and I can't figure out why :-) > What it _does_ actually do is prevent the garbage collector from > cleaning up the memory, because there will always be a valid reference > chain. OK, I understand how the circular pointer chain will cause a memory leak. I suppose this is bad, but it doesn't explain what's going on, since the failures occur after just a very small number of object creations, long before memory exhaustion could possibly be a problem. Here's what's going on. I've got a web server, using a subclass of BaseHTTPServer. It starts out getting called from a cgi script, but it forks to detach itself and run in the background listening on a new port. This child process logs into an oracle database using oracledb. The overall application is a web front end to the database. It sounds complicated (and it is), but I've gotten that part to work. Or at least I thought I did until I made the most recent changes :-) I have a page class which takes care of creating most of a generic page of HTML, and subclasses of that for each specific page type. Each time my server responds to a HTTP request, it creates a new object of one of the page subclasses, then calls that object's show() method, which will typically perform some database access and produce HTML output. My latest page subclass utilizes a data object to do some of the lower level work. The page subclass looks essentially like this, where main_content is a callback function from an ancestor class's show() method: class new_domain (netdbpage): def main_content (self): domain = db_record.domain (self, self.handler.form['f_hostname'][0], 1) self.record_set = [domain] self.display_record_set () self.add_menu_command ('save') self.add_menu_command ('cancel') Inherited from the netdbpage superclass is: def display_record_set (self): i = 0 for record in self.record_set: record.display(i, self) i = i + 1 and my domain class looks like the following. The db_record superclass doesn't do anything for now, but it's a placeholder; eventually there will be a number of different subclasses, with some shared functionality. class db_record: pass class domain (db_record): def __init__ (self, page, name, new = 0): name = string.lower (name) cur = page.handler.server.db.cursor() if (new): cur.execute ("select id_seq.nextval from dual") id = cur.fetchone()[0] cur.execute ("insert into domain (id, name) values (:1, :2)", [id, name]) cur.execute ("select id, name, comments from domain where id = :1", [id]) id, name, comments = cur.fetchone() cur.close() self.data = {} self.data["id"] = id self.data["name"] = name self.data["comments"] = comments def display (self, n, page): page.put ('

%d

\n' % n) The put method that's called is in one of netdbpage's ancestor classes: def put (self, s): self.handler.wfile.write (s) As shown above, this works. But, it's ugly passing the "page" argument into each method of domain that needs it, just so domain can reference page's put() method (and a few other things). The initial plan was to have domain.__init__ store a copy of page in self.page, and then things like domain.display could have one less argument and call self.page.put() to produce output. This of course, is the circular reference; the page object contains a link to the domain object, and the domain object contains a link back to the page. That's where things start to go bad. If I do that, I get no output. I know my put() function gets called, because if I change it to: def put (self, s): self.handler.wfile.write (s) # wfile connected to network socket sys.stderr.write (s) The strings all show up in stderr (which is connected to a log file) just like they should. If I change display to be any of: def display (self, n, page): self.page = page # circular reference self.page.put ('

%d

\n' % n) def display (self, n, page): self.page = page # circular reference page.put ('

%d

\n' % n) # but I use the local copy def display (self, n, page): self.foo = page # member name "page" is not magic page.put ('

%d

\n' % n) I get no output to my browser (even though I know put() gets called because I can see the stderr output). If I make it: def display (self, n, page): self.page = page self.page.put ('

%d

\n' % n) self.page = None then I get output like I should. Clearly the circular reference is doing something worse than simply causing a memory leak. It's almost as if somewhere deeper in the file code than I can see, a copy is being made of a file descriptor or buffer or something like that and if I have the circular link, my output goes to the wrong copy, which isn't connected to anything I can see. The fact that breaking the circle *after* the call to put fixes something makes me think output buffering. Also, even after this fails, I can continue to access my server through a browser, and use other functions, which create additional objects. This says to me that memory exhaustion is not an issue. Obviously, I will need to address the memory leak problem, because it *will* become an issue at some point, but for now I havn't hit that wall yet. So, does that fit your definition of "bad" :-) From gmcm at hypernet.com Mon Dec 20 22:13:06 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 20 Dec 1999 16:13:06 -0500 Subject: windll exception In-Reply-To: <83lpss$7q3@tu228.tus.ssi1.com> Message-ID: <1266398999-16467601@hypernet.com> Mike Palmer wrote: > Below is a simple test file I wrote. It opens bwcc32.dll, and > runs the BWCCGetVersion() function to get the version, then > prints the version as a hex value. All that works fine. > > As the output shows, an exception occurs when the program > finishes, but ONLY if I run it from the command line (NT4, SP4). > If open PythonWin and run it using execfile(), no exception is > reported. > > I thought the problem might be related to the bwcc.unload() line, > but it doesn't matter whether I include that line or not. The > error message is the same. > > This leads me to believe that Python is generating the error on > cleanup, and that somehow Python thinks None has been attached to > a class in the same way that bwcc was when I called > windll.module(). I suspect that I don't see the error from within > PythonWin because it's only generated when PythonWin closes, and > there probably isn't any mechanism to trap exceptions and report > them on closing. > > Can anyone confirm this? Is there any known fix or workaround? You got most of it. The solution goes something like this: def __del__(self) xxx.free_library() becomes: def __del__(self, xxx=xxx): xxx.free_library() The __del__ method (or whatever cleanup function) needs to squirrel away a reference to the module it is using. Otherwise, Python's order-of-destruction will clean up the module and set it to None, yielding the AttributeError. > Thanks, > > -- Mike -- > > ------- Python windll test file ------- > # Python windll test > import windll > bwcc = windll.module('bwcc32') > ver = bwcc.BWCCGetVersion() > verstr = "%x" % ver > print verstr # should print '10200' > bwcc.unload() > ---------------------------------------- > > ------- Output ------- > 10200 > Exception exceptions.AttributeError: "'None' object has no > attribute 'free_library'" in instance at 7fd610> ignored > ---------------------- > > > > > -- > http://www.python.org/mailman/listinfo/python-list - Gordon From Dom.Mitchell at palmerharvey.co.uk Tue Dec 7 17:57:22 1999 From: Dom.Mitchell at palmerharvey.co.uk (Dominic Mitchell) Date: 07 Dec 1999 16:57:22 +0000 Subject: exchanging data btwn Python and lesser languages References: <82jau6$e72$1@nnrp1.deja.com> Message-ID: Preston Landers writes: > As strange as it may sound, Python is not the only language used in our > shop (who shall remain nameless to protect the guilty.) > > I'm looking for a quick-n-dirty way to exchange data between Python and > other languages, especially P*rl. I don't have time to implement a > full-blown XML solution, which is really what this problem calls for > IMHO. > > The data I want to exchange is pretty simple; mainly lists/arrays and > dicts/hashes of integers (possibly longints), strings, and floats. No > fancy objects or anything. > > I see that Python has an XDR module that may suit my needs, but I can't > find the equivilent P*rl module... > > Essentially I want to write out my data to a file, similar to pickle or > marshal, and be able to read the data easily in popular languages. > > What solution have people out there been using for this kind of > problem? An obvious quick hack suggests itself: Write out data as Perl code so that it can be eval'd in the Perl world. Perl itself can do this with it's Data::Dumper module. Reading it back into python would be harder, though. -- Dom Mitchell -- Palmer & Harvey McLane -- Unix Systems Administrator "vi has two modes the one in which it beeps and the one in which it doesnt." -- Anon. From djc at itga.com.au Thu Dec 16 00:42:14 1999 From: djc at itga.com.au (Dave Cole) Date: 16 Dec 1999 10:42:14 +1100 Subject: Bug in Python 1.5.2 exception handling? References: <000601bf46c2$de59f3a0$05a0143f@tim> Message-ID: <87u2lju5yh.fsf@heresy.itga.com.au> Tim> [Dave Cole] Tim> > It looks like function locals are not deleted if that function is Tim> > terminated by an exception. Tim> Tim> That's true, but it's not a bug: Python doesn't define the Tim> lifetime of objects. CPython is much more predictable than Tim> JPython in this respect-- thanks to using refcounts --but you Tim> still rely on it at your own risk. In the case of a function Tim> that terminates due to exception, the locals are still very much Tim> alive, because they *can* be reached via the traceback object Tim> (from which the chain of stack frames can be reached, from which Tim> the locals can be reached). Der... I forgot about the traceback stuff. I have even written some code to give nice pretty HTML formatted tracebacks for the Python CGI stuff I have written here. A trap for young players if ever there was one. Tim> Change your loop to: Tim> Tim> for val in range(3): Tim> try: Tim> check_raise(val) Tim> except: Tim> try: Tim> raise "dummy" Tim> except: Tim> pass Tim> Tim> and you'll see that the 'raise "dummy"' has the same effect. And in doing so, you end up dropping all references to the previous traceback. Not really what I was after, but oh well. The reason that I was worried about this was that I am doing some database stuff using my Sybase module: plug: http://www.itga.com.au/~djc/sybase.html I wanted to automatically rollback a transaction when an exception was raised during processing. I made a class like this: class Transaction: def __init__(self, db, name): self.db = db self.name = name self.db.execute('begin transaction %s' % (self.name,)) self.commit = 0 def __del__(self): if self.commit: self.db.execute('commit transaction %s' % (self.name,)) else: self.db.execute('rollback transaction %s' % (self.name,)) Then I thought that all I would have to do was: def something_or_other(self): tran = Transaction(self.db, 'update_id') # lots o' database stuff tran.commit = 1 I suppose it will still work for the rollback case, but just not when I expect it to. Tim> > class c: Tim> > def __init__(self, val): Tim> > self.val = val Tim> > def __del__(self): Tim> > print val, 'deleted' Tim> Tim> You really want Tim> Tim> print self.val, 'deleted' I was really quite determined to confuse myself. - Dave From c00cwc00 at nchc.gov.tw Fri Dec 10 09:47:37 1999 From: c00cwc00 at nchc.gov.tw (ppling) Date: Fri, 10 Dec 1999 16:47:37 +0800 Subject: How can I use tcl/tk 8.2.2 in Python Message-ID: <82qf4h$goo$1@news2.nctu.edu.tw> I try to use Tkinter with tcl/tk 8.1~8.2. And I get an error that tell me It can not find tcl80.dll ..... How can I configure my Python to let it use tcl/tk after 8.1? I use in windows 98/NT Thanks From jhauser at ifm.uni-kiel.de Wed Dec 8 19:53:27 1999 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 08 Dec 1999 19:53:27 +0100 Subject: How to build the Python Numeric double array in a C extension module? References: Message-ID: <873dtdnu1k.fsf@ifm.uni-kiel.de> Look at these pages, there is documentation and also some fine modules, which can server as an example. http://oliphant.netpedia.net/ HTH, __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From ullrich at math.okstate.edu Thu Dec 30 19:37:22 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Thu, 30 Dec 1999 12:37:22 -0600 Subject: __rcall__??? References: <000401bf528c$6d78de00$a02d153f@tim> Message-ID: <386BA662.112B4C19@math.okstate.edu> Tim Peters wrote: > [David C. Ullrich] > [...] > > Before I spend time trying to catch up: Are you saying that > > the current 3.3.6 tells the full story, including the answer to > > the question I asked about the _history_, when __rpow__ was > > introduced? > > No, there's no info in the manual about the history. Misc/HISTORY (from the > source distribution) doesn't say anything about rpow either. If it really > matters to you when __rpow__ got introduced, you'll have to ask someone at > CNRI to dig thru old CVS diffs. No, it doesn't matter a bit. I was assuming that your reply had at least _some_ relevance to the question I'd asked - if so there would have to be information on the history in that section of the docs. I guess I shouldn't assume things like that. > >> ... __pow__ takes an optional 3rd argument, > > > Again, does it? [...] > I suspect you shot yourself in the foot by doing something like > > from math import * > > without admitting to it . Again, thanks for your assistance - I figured out I think it was a week or so ago that this was the problem, and then I "admitted" it right here, in a post that has just fallen off the local server. Thanks. > > ... there are no Functions that take more than one parameter. (It's > > supposed to be a math thing - "officially" there's no such thing as > > a function of two variables in mathematics either, "officially" they > > get emulated by functions of one variable.) > > This explains why Guido is agonizing over whether Python2 should represent > integers as nested sets or via lambda composition . I see your point. Probably the answer to a question like "should there be multi-variable functions or just functions with single arguments?" is exactly the same for a programming language like Python and for every possible application written in that langauge - the idea that different answers are appropriate in different contexts is just silly. The idea that a person needs to know what the _goal_ is before determining what methods are appropriate is even sillier. Thanks for clarifying that. Which seems "simpler" to you, the chain rule in "several-variable calculus", with all those partial derivatives and sums and things, or the equivalent chain rule in "vector calculus", that just happens to look exactly the same as the calc-101 chain rule? Never mind, there's no calculus at all in out-of-box Python so there can't be any point to it. > in-a-language-with-curried-functions-rcall-could-be-natural-ly y'rs > - tim From fredrik at pythonware.com Wed Dec 8 08:45:44 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 8 Dec 1999 08:45:44 +0100 Subject: tiny python References: <19991207174430.7096.qmail@burton-krahn.com> Message-ID: <00cf01bf4150$3e9d0450$f29b12c2@secret.pythonware.com> Noel Burton-Krahn wrote: > I would like to make the smallest python interpreter possible. Is it > possible to build a python interpreter which just reads byte code? > Can I cut out the compiler? The stock python (1.5.2) compiles to over > 480K on my redhat-5.2 linux box. I need to get that below 200K to fit > on my system. start here: http://www.abo.fi/~iporres/python/ "With this patch, it is possible to build a python interpreter WITHOUT support for float, complex and long numbers, file objects, parser, compiler and depedencies with any operating system." From akuchlin at mems-exchange.org Thu Dec 9 23:34:18 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 09 Dec 1999 17:34:18 -0500 Subject: FORTRAN (was Re: indentation) References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> <829dlk$12p$1@news.wrc.xerox.com> <14411.53378.154350.793014@weyr.cnri.reston.va.us> <82mjag$7oh$1@nntp2.atl.mindspring.net> Message-ID: <3dd7sfd9qt.fsf@amarok.cnri.reston.va.us> Phil Austin writes: > MHz pentium. Once C++ compilers mature to the point where > expression templates impose as little compile-time overhead as > Fortran intrinsic arrays, it might be time for scientists to reexamine > their language choices. A while back David Ascher pointed out "Techniques for Scientific C++", by Todd Veldhuizen , the author of Blitz++. It's a great paper for language geeks, even if you're not interested in numerics: http://www.extreme.indiana.edu/~tveldhui/papers/techniques/techniques.html An excerpt from section 11 on template metaprograms: Unruh's program tricks the compiler into printing out a list of prime numbers at compile time. It turns out that C++ templates are an interpreted programming ``language'' all on their own. There are analogues for the common control flow structures: if/else/else if, for, do..while, switch, and subroutine calls. ... Are there any limits to what computations one can do with templates at compile time? In theory, no-- it's possible to implement a Turing machine using template instantiation. The implications are that (1) any arbitrary computation can be carried out by a C++ compiler; (2) whether a C++ compiler will ever halt when processing a given program is undecidable. The idea that C++ compilers are Turing complete blew me away. (Hours of fun ... if you're Tim Peters.) In the paper Veldhuizen shows how to use this more practically, to generate unrolled code for things like FFTs, a complex optimization that no compiler is going to do for you. -- A.M. Kuchling http://starship.python.net/crew/amk/ Years later I was regaining consciousness in America, which is no mean feat. -- Waking from memories of a sister, in EGYPT #1 From skip at mojam.com Thu Dec 16 15:48:35 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 16 Dec 1999 08:48:35 -0600 (CST) Subject: download web page with python In-Reply-To: <83a3m4$diq$1@nnrp1.deja.com> References: <83a3m4$diq$1@nnrp1.deja.com> Message-ID: <14424.64451.803370.60208@dolphin.mojam.com> Here's a simple recipe for downloading a URL that's the result of a form fill-in (examples from the original request): 1. Download the page the form resides on. base = http://www.symantec.com/avcenter/download.html 2. Locate the ACTION attribute of the form of interest. action = /avcenter/cgi-bin/navsarc.cgi 3. Make note of the METHOD attribute of the form. 4. Identify all the form's variables and any possible values they might assume. Don't forget hidden s and the name and value of submit s if any were given. PROD NDW, GW, NMC, GW, ... LANG DA, DE, UK, US, ... 5. Build a base URL from the result of 1 & 2 using urlparse.urljoin. baseurl = urlparse.urljoin(base, action) 6. If you have a GET method URL, build a full URL from the combination of the base url and the paramenters. url = "%s?PROD=NDW&LANG=DA" % baseurl valuedict = None If you have a POST method URL, you can try the above (many CGI scripts are method-agnostic), but the server may actually require the URL be called using a POST method, so be prepared to build a value dict. valuedict = {'PROD': 'NDW', 'LANG': 'DA'} 7. Grab the fully parameterized URL using urllib.urlopen and read it. if valuedict: params = urllib.urlencode(valuedict) else: params = None f = urllib.urlopen(url, params) bytes = f.read() 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 sdossett at metaphoria.net Tue Dec 14 21:43:57 1999 From: sdossett at metaphoria.net (sdossett at metaphoria.net) Date: 14 Dec 99 15:43:57 -0500 Subject: fw: Jpython problem Message-ID: <199912142036.PAA15205@python.org> Anybody got an answer for this one??? > ** Original Subject: fw: Jpython problem > ** Original Sender: Michael Christian > ** Original Date: Tue, 14 Dec 1999 15:38:09 -0500 > ** Original Message follows... >Hi, > > I'm having a problem when I try to import certain Java packages. I'm > using Jpython 1.1 Beta 2 and I've subclassed PythonInterpreter and am > trying to execute the following code: > > > import sys > from java.lang import String > from java import lang > from java import util > from java import io > from net.metaphoria.toolkit.html import HtmlGenerator > from net.metaphoria.toolkit import net > from net.metaphoria.toolkit.access import DataAccessor > from net.metaphoria.toolkit.access import DataAccessFactory > from net.metaphoria.toolkit.access import ReadableResponse > from net.metaphoria.toolkit.util import WrapException > from net.metaphoria.toolkit.io import StreamStringer > from net.metaphoria.toolkit.net import URI > from net.metaphoria.toolkit import service > sys.add_package('net.metaphoria.test.rdl') > sys.add_package('net.metaphoria.test.rdl.set') > from net.metaphoria.dts.respond import ResponderManager > from net.metaphoria.test.rdl.encapsulators import TestEncapsulator; > from net.metaphoria.test.rdl.responders import TestResponder; > I previously had this code working under Jpython 1.0, calling classes > from Java 1.1.8, but I've > added classes which rely on Java 1.2 and consequently now am using jdk > 1.2.2. The imports of Sun-supplied classes appear to work. The custom > imports up until line 18 also appear to work. > These are all supplied in a jar file that I've included in my classpath. > The custom import on line 18 > appears to cause the problem. It is not included in a jar file, but the > root path to it is specified in my > classpath. I originally tried this without the two sys.add_package > statements, but thought I would > add it just to see if this resolved anything, which it did not. > Following is the exception stack trace that was produced. Thanks in > advance for any help you > can give. > > [Tue Dec 14 12:36:06 EST 1999] [OperationThread for: RDLTest2] Caught > PyException: Traceback (innermost last): > File "", line 18, in ? > java.security.AccessControlException: access denied > (java.io.FilePermission C:\JavaWebServer2.0\classes\net read) > > at > java.security.AccessControlContext.checkPermission(AccessControlContext.java, > Compiled Code) > at > java.security.AccessController.checkPermission(AccessController.java, > Compiled Code) > at java.lang.SecurityManager.checkPermission(SecurityManager.java, > Compiled Code) > at java.lang.SecurityManager.checkRead(SecurityManager.java, Compiled > Code) > at java.io.File.isDirectory(File.java:566) > at org.python.core.PyJavaDirPackage.__findattr__(PyJavaDirPackage.java, > Compiled Code) > at org.python.core.PyJavaPackage.getDirPackage(PyJavaPackage.java:152) > at org.python.core.PyJavaPackage.getDirPackage(PyJavaPackage.java:140) > at org.python.core.PyJavaPackage.getDirPackage(PyJavaPackage.java:140) > at org.python.core.PyJavaPackage.getDirPackage(PyJavaPackage.java:140) > at org.python.core.PyJavaPackage.__findattr__(PyJavaPackage.java, > Compiled Code) > at org.python.core.PyObject.__getattr__(PyObject.java, Compiled Code) > at org.python.core.imp.importName(imp.java, Compiled Code) > at org.python.core.imp.importName(imp.java:435) > at org.python.core.imp.importFrom(imp.java, Compiled Code) > at org.python.pycode._pyx0.f$0() > at org.python.pycode._pyx0.call_function() > at org.python.core.PyTableCode.call(PyTableCode.java:75) > at org.python.core.Py.runCode(Py.java:935) > at org.python.core.Py.exec(Py.java:949) > at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:112) > at > net.metaphoria.test.rdl.RDLMetaRepository.generate(RDLMetaRepository.java:232) > > at > net.metaphoria.dts.repository.RepositoryGenerator.perform(RepositoryGenerator.java:119) > > at > net.metaphoria.dts.repository.RepositoryOperation.performOperation(RepositoryOperation.j ava:358) > > at > net.metaphoria.dts.repository.OperationThread.run(MetaRepository.java, > Compiled Code) > > java.security.AccessControlException: > java.security.AccessControlException: access denied > (java.io.FilePermission C:\JavaWebServer2.0\classes\net read) > The Christian ideal has not been tried and found wanting. It has been found difficult; and left untried. - G. K. Chesterton Download NeoPlanet at http://www.neoplanet.com From calishar at *NOSPAM*home.com Wed Dec 1 00:29:02 1999 From: calishar at *NOSPAM*home.com (Calishar) Date: Tue, 30 Nov 1999 23:29:02 GMT Subject: WinNT and DLL's References: <001701bf3b3b$e7a39570$3acbd9c2@peridot.optichrome.com> Message-ID: <2dn84ssgdboo47m0dqaavii70badgl6ctj@4ax.com> On Tue, 30 Nov 1999 14:05:06 -0000, "Adrian Eyre" wrote: >> Is there a way that I can simply access the pre-compiled dll files? > >Have a look at the calldll module: http://www.nightmare.com/software.html Thanks, got the same tip in my mailbox first thing this morning (my brain sort of clued in to what it was, but my eyes were almost screaming 'LOOK...' Played with it a bit during the day, looks like it (and struct) will do what I need. Thanks for all who came up with this idea. Calishar From info at pythonware.com Wed Dec 1 21:44:19 1999 From: info at pythonware.com (PythonWare) Date: Wed, 1 Dec 1999 21:44:19 +0100 Subject: ADM: www.pythonware.com network problems References: <003301bf3ab5$13138080$0c5bdfc8@the-user> <38431229.7B60A603@worldnet.att.net> <384314A8.6929482C@callware.com> <38454E1D.167E@austin.ibm.com> <007a01bf3c33$e2107030$f29b12c2@secret.pythonware.com> Message-ID: <00e001bf3c3c$d83e7760$f29b12c2@secret.pythonware.com> fredrik wrote: > the URL is correct, and the server is working > just fine. and a few minutes later, our webserver com- pletely lost its mind :-( in case you really need to get your hands on PIL, our tkinter docs, or anything else on our site, the following temporary mirror should work: http://www.algonet.se/~d89653/ we hope to have the pythonware site back up again within 12 hours. sorry for the in- convenience. From meera_bavadekar at hp.com Thu Dec 9 23:15:39 1999 From: meera_bavadekar at hp.com (Meera) Date: Thu, 09 Dec 1999 14:15:39 -0800 Subject: X509 certificate Message-ID: <38502A0B.969E3BFD@hp.com> Hello, How can I extract certificate DN (distinguished name) and issuer DN from a X.509 certificate in python ? Appreciate your help Thanks, Meera From greg.ewing at compaq.com Mon Dec 20 11:26:37 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Mon, 20 Dec 1999 23:26:37 +1300 Subject: List comprehensions References: <38592275.BBA2B61A@maxtal.com.au> Message-ID: <385E045D.9EC36473@compaq.com> skaller wrote: > > What is the proposed syntax for list comprehensions? The one my patch currently implements is: list_comprehension :== '[' expr iterator... ']' iterator :== 'for' target 'in' expr | 'if' expr > But the idea of the syntax is to reduce the need for > functional syntax. Indeed. Greg From paul.robinson at quantisci.co.uk Tue Dec 7 14:18:11 1999 From: paul.robinson at quantisci.co.uk (Paul Robinson) Date: Tue, 07 Dec 1999 13:18:11 +0000 Subject: Help! References: <82bvla$q70$1@sparky.wolfe.net> Message-ID: <384D0912.CD4DC6D6@quantisci.co.uk> Jon Cosby wrote: > > Has anyone out there used Microsoft Personal Web Server to run Python-CGI > scripts? If so, I'd really like to hear how you've done it. Using PWS (from Option Pack 4) on NT 4: Simply make sure you install MS Management Console (which is an option pack option!!). >From here you can set up the "App Mappings" (as it refers to them). 1) From the Virtual Folder view, right click the root (or a specific folder) 2) Select the Home Directory (or Virtual Directory) tab. 3) In the "Application Settings" Frame click "Configuration..." 4) Add a new entry: Executable: "C:\Program Files\Python\python.exe" -u "%s" (including the quotes - obviously change the path to Python as appropriate) Extension: .cgi (or whatever you want it to be e.g. .py) Other options are left blank. 5) CLick all the OK buttons and you should be up and running. As I mentioned this works on PWS 4 (and IIS 4) using the management console which I get as an option when installing Option Pack 4 for NT. If you are using 9x then I don't have any experience of this - but how difficult can it be? ;-) AFAIK the reason the registry hacking wasn't working is that since version 4 (of IIS and PWS) settings have been stored in the "Metabase" or some similarly unlikely sounding object, hence rendering the registry settings obsolete. Of course if you're not using version 4 then this may be completely irrelevant! Hope this helps (if not, then more information about operating system and PWS version might help me give you a better answer...), Paul From dave.rose at wcom.com Wed Dec 1 22:25:34 1999 From: dave.rose at wcom.com (Dave Rose) Date: Wed, 01 Dec 1999 21:25:34 GMT Subject: Scoping for Tkinter Variables. Message-ID: Has anyone out there run into problems with Tkinter variables (e.g. PY_VAR0 ... Tkinter.Int_Var). I am using a MessageDialog box from Pmw and when I call the Message Dialog box the dialog box functions fine, but when the program attempts to exit normally, it does not exit. It appears through some level of debugging that it is waiting for a Tkinter call wait_variable. Anybody that might know what causes this, it would be greatly appreciated. It may have something to do with scoping, but in this instance, I am not creating the variable and therefore can not control its scope. Thanks Dave Rose From arcege at shore.net Sun Dec 12 16:05:23 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sun, 12 Dec 1999 15:05:23 GMT Subject: Packaging packages? References: <035d01bf4263$c7272490$f29b12c2@secret.pythonware.com> Message-ID: Fredrik Lundh wrote: : Jeffrey Kunce wrote: :> Is there a way to collect all the python modules in a package into one file? :> I'm thinking of something like a "DLL for python code". It would be :> nice if the normal import syntax would work transparantly on such files, :> as well as with the standard directory-based packages. : you can use Greg Stein's imputil.py [1] for this. see : my reply in the recent "Embedding questions" for a : code sample. :> I've been a big fan of Fredrik's "Squeeze" and Gordon's "Win32 Installer", :> but as far as I know, they pakage an entire application into one file. :> I'm looking for a little more modularity than that, and something that :> can be imported from native python. : iirc, Gordon's stuff is about as modular as it can be. : using it to create library packages shouldn't be much : of a problem. :> Is this already available? If not, has anyone worked on this? :> Does anyone else see the need? Last summer I also created a native (or C) implimentation of something similar to what was describe in the distutils SIG, something I called Spamcan. It's not as extensive as Gordon's Installer but is a little more portable (works on just about any platform). The purpose of this module was to have something similar to JAR files, so the can file only stores PYC files. The general consensus on the distutils list was that something more generic was needed (pyz) so I didn't really spend more time or even announce it (Gordon's technical implimentation was more versatile than mine). Contact me if you're interested. -Arcege From calishar at my-deja.com Thu Dec 16 01:44:06 1999 From: calishar at my-deja.com (calishar at my-deja.com) Date: Thu, 16 Dec 1999 00:44:06 GMT Subject: pilot-link for win32 Message-ID: <839ckl$u0d$1@nnrp1.deja.com> Hi Folks, Does anyone know somewhere I could find either a pre-built, or VC++ compatible source version of pilot-link? Calishar Sent via Deja.com http://www.deja.com/ Before you buy. From doughellmann at home.com Mon Dec 27 15:05:55 1999 From: doughellmann at home.com (Doug Hellmann) Date: Mon, 27 Dec 1999 14:05:55 GMT Subject: Tkinter and sliders References: Message-ID: <386773AC.DE1F8804@home.com> It sounds like you have the command bound to a mouse motion event rather than an event which is only called while a mouse button is pressed and the mouse moves. Post some code, and I can try to be more specific. Doug Jim Richardson wrote: > > *Newbie Alert. Set phasers to stun* > > I have a slider widget I have created with tkinter, it works > fine, except the command associated with it is executed whenever > the mouse moves over the widget, irrespective of whether the > slider bar is actually actuated or moved. Is there a way to force > the command to only go off if the slider is moved or activated? > thanks. > (if this is a dumb question with an obvious answer emblazoned in > the tkinter docs, please let me know, but I can't seem to find > it, thanks all) > > -- > Jim Richardson > Anarchist, pagan and proud of it > WWW.eskimo.com/~warlock > Linux, because life's too short for a buggy OS. From wtanksle at hawking.armored.net Tue Dec 28 02:27:28 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 28 Dec 1999 01:27:28 GMT Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D83@pces.cadlab.it> <3867CA1E.360E3B0E@maxtal.com.au> Message-ID: On Tue, 28 Dec 1999 07:20:46 +1100, skaller wrote: >Alex Martelli wrote: >> But as soon as they published, and the book was >> such an instant success, I started using their >> design pattern names with abandon (with a biblio >> reference in a comment, when I remembered:-). > I found the book interesting, and nothing >more. I didn't consider it enourmously interesting, although I dutifully took note of the nomenclature it used. It turns out that the nomenclature is precisely what makes the book so useful. >I gained no enlightenment from it, other than >the mild assertion than some patterns could not >be encoded IN the language. It turns out this >assertion is false in general -- it is language specific. >Functional languages have no problem encoding it. They didn't make that assertion in general (although, let it be noted that your statement about functional languages is also false in general; there are functional languages which cannot implement specifc patterns, and no functional language can implement all patterns). They made it in specific about C++ and Smalltalk; they also noted that had the book's target language been C, they would have documented some other patterns, such as "prototyping object system" and such. >> I particularly appreciated Java's abandonment >> of classical rules for nested lexical scopes -- the >> idea that an identifier in an inner scope hides the >> existing outer one silently. Java makes it an >> error to have such a 'hiding', and although the >> idea was totally novel to me when I tried Java out, >> I think it substantially reduced mistakes without any >> real cost in expressiveness. > Yeah, but the scopes still nest and control >object lifetimes accordingly, right? The fact that >shadowing generates an error may have some >advantages, but it also has disadvantages too: >hiding supports 'cut and paste'. This is why it's easier to refactor Forth than Scheme. >> If the wrappers are standardized, readability is no >> problem. > Most people think highly bracketted expressions >are unreadable (eg LISP :-) > Or, (did I (actually) mean), that, (most), >(people are (finding (that (highly (bracketed))))) >expressions are hard to read. :-) That's more like what I think. Rebol discards the brackets while keeping the backward execution; it's a bit odd, but winds up looking not too bad, so long as you don't get fancy. >>And efficiency need not be, either; why >> cannot you parse and optimize: >> for key,value in kv_enum(sequence): >> just as easily as >> ifor key,value in sequence: > Well, in Python 'kv_enum' could be >anything. It may default to a standard function, >but the client can write: > kv_enum = myfunction >This cannot be done for the 'ifor' form, since 'ifor' >is a keyword. Please don't use ifor! You're inventing a new keyword to do what 'for' does perfectly well. What you actually want is a way to iterate over both sequence items and locations at the same time. Why not define a method which is valid for all sequences; I'll call it "items" because dictionaries already have such a method. for index,value in x.items(): assert x[index] = value >> > Quite a lot of the time, you CAN provide the y: >> > using functional programming with map and reduce etc. >> Yep -- and O-O wrappings work for it, too. > The difference is that the 'OO' wrappings, in general, >cannot be localised. This leads to spagetti. And spaghetti leads to hate, which leads to suffering. Seriously, though, I don't understand your usage of the word "localized". In my dictionary localizing a program means translating it to be appropriate for some specific language/locality. >> > This works well in functional programming languages, >> > but it doesn't work nearly as well in python >> > What I mean is, the 'y' becomes so cluttered the reader >> > isn't sure what is happening. >> Why would it be less cluttered in a functional PL? > At least in ML languages, function calling does >not require brackets. Of course, you still need them >to override the default precedence. :-( Many functional languages implement function calls via currying. Interesting, and makes parentheses irrelevant. >John Skaller, mailto:skaller at maxtal.com.au -- -William "Billy" Tanksley, in hoc signo hack From dnagata at creo.com Tue Dec 14 07:39:55 1999 From: dnagata at creo.com (Dale Nagata) Date: Mon, 13 Dec 1999 22:39:55 -0800 Subject: win32ver module References: <833pct$r5b$1@nnrp1.deja.com> Message-ID: <3855E63B.54E2@creo.com> Mark Hammond wrote: > > Unfortunately not that I know of - however, I do have someone who keep > promising one is to be given to me "real soon now" - I will chase him up, > but it does mean it wont be ready in days (or possibly even weeks...) > > Mark. > > emuller at painewebber.com wrote in message <833pct$r5b$1 at nnrp1.deja.com>... > >Do anyone have a win32ver module that wraps the file version api calls? > > > > > >Sent via Deja.com http://www.deja.com/ > >Before you buy. You can also use the windll module to call the VER.DLL functions directly. I did this, 'cause I couldn't wait... -- 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 tim_one at email.msn.com Mon Dec 13 11:18:15 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Dec 1999 05:18:15 -0500 Subject: Tkinter/IDLE crash In-Reply-To: Message-ID: <000c01bf4553$5e739b20$9e2d153f@tim> [dg] > I have Python 1.5.2 on an NT box and I can run python ok but > whenever I try to run pythonw or idle, I get nothing. Well, pythonw's purpose in life is *not* to show you anything, so that one isn't surprising. > There is a slight pause, as if something is being loaded, but then > I'm back at the command line with no app running. WRT the IDLE problem, check the FAQ and/or DejaNews for things that can go wrong with your Tcl/Tk installation. Make sure that's working *before* messing with IDLE. You may have a conflicting set of Tcl DLLs on your system. Get into a DOS box Python and try this: >>> import Tkinter >>> Tkinter._test() >>> Chances are it will fail; the msgs you get will help you to fix it. tcl-is-short-for-Tk-Can't-Load-ly y'rs - tim From mark at chem.uwa.edu.au Tue Dec 7 18:06:46 1999 From: mark at chem.uwa.edu.au (Mark C Favas) Date: 7 Dec 99 17:06:46 GMT Subject: A Date With Tim Peters... References: <001801bf4073$033e6260$88a0143f@tim> Message-ID: rob at hooft.net (Rob W. W. Hooft) writes: >>>>>> "TP" == Tim Peters writes: > TP>>> import math > TP>>> zero = 0.0 > TP>>> math.atan2(zero, zero) > TP> 0.0 > TP>>> zero = -zero > TP>>> math.atan2(zero, zero) > TP> -3.14159265359 > TP> That is, IEEE-754 mandates signed zeroes too, in part so that an > TP> underflow "remembers which direction it came from". >Python 1.5.2b1 (#4, Jan 14 1999, 12:05:48) [GCC egcs-2.90.21 971202 (egc on irix5 >Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>>> import math >>>> zero=0.0 >>>> math.atan2(zero,zero) >Traceback (innermost last): > File "", line 1, in ? >ValueError: math domain error >>>> >no11[101]nonius% uname -a >IRIX no11 5.3 02091401 IP22 mips >So it is not portable..... And indeed I get the same result as Rob on DEC^H^H^HCompaq Alpha, Tru64Unix Version 4.0F (with current CVS version of Python 1.5.2) - portably non-portable... (modulo -ieee compilation flags) Mark -- 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 skaller at maxtal.com.au Sun Dec 12 05:53:19 1999 From: skaller at maxtal.com.au (skaller) Date: Sun, 12 Dec 1999 15:53:19 +1100 Subject: Python Type-Inference based LINT.. (pylint.py) References: <199912040336.WAA22210@python.org> <19991205131549.M19929@teapot.egroups.net> Message-ID: <38532A3F.7CD2346C@maxtal.com.au> David Jeske wrote: > Does it seem more proper to: > > I. Do all static checking based on the micro-types, and require > the function writer to define the type constraints if they want > larger granularity? > > def sumListElements(a_list): > 'pylint a_list (SequenceType,)' ## <- this is the syntax pylint.py > ## supports currently for type > ## declarations Hmmm. A specialised docstring .. > > II. Always "upgrade" types to proper-types during static checking. > If someone wants to have a fine-grained type which just includes > __getitem__ and __len__, then force them to at least declare > this as a proper type, like "SimpleSequenceType" and then > show the signature as: > > sumListElements( SimpleSequenceType of AddableType ) -> AddableType I think it depends on what you want to do. First, in the ISO C++ Standard, the same issue arose for algoithms that didn't need the full functionality of some iterator kind, but the specification requires the full kind all the same, because there is no compact wording for anything else (and it allows implementors more freedom). In functional programming languages, signatures tend to be used. [I.e. mico types]. In Viper, the issue will arise -- but when we're talking about calling class methods, the overheads are so large optimisation isn't relevant. I'm interested in knowing whether something is an integer or not, or whether it is precisely a Tuple or not: if a class emulating a sequence is used, it's irrelevant because optimisation is impossible [by type inference] in this case. OTOH knowing _exactly_ which class is passed to a function in a particular call is important, since it allows the method calls to be inlined. -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From tony at lsl.co.uk Tue Dec 21 13:09:30 1999 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Tue, 21 Dec 1999 12:09:30 -0000 Subject: Size of files in human, readable form In-Reply-To: Message-ID: <003801bf4bac$3c123eb0$f0c809c0@lslp7o.lsl.co.uk> Tim Muddletin came up with the "modern" Python solution. Attached is a small utility (written back when Python was at 1.3, so not quite as sophisticated in the way it gets the file size) that wraps the same concept up *as* a utility. It takes a filename (reports on its size) or a number of bytes/megabytes/etc (converts it). If you don't give any arguments, it explains this... -- Tony J Ibbs (Tibs) http://www.tibsnjoan.demon.co.uk/ 'Tim happens. Get used to it'. (David Ascher, on the Doc-SIG) My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) -------------- next part -------------- A non-text attachment was scrubbed... Name: mb Type: application/octet-stream Size: 2615 bytes Desc: not available URL: From skaller at maxtal.com.au Sun Dec 12 05:12:29 1999 From: skaller at maxtal.com.au (skaller) Date: Sun, 12 Dec 1999 15:12:29 +1100 Subject: FORTRAN (was Re: indentation) References: <=CNPOJoL=1A0AudQdqJsHw5LCpzM@4ax.com> <82nb40$cv3$1@news.wrc.xerox.com> Message-ID: <385320AD.FCE81CE0@maxtal.com.au> Mark Jackson wrote: > We have legacy code written, and "legacy" xerographic physicists most > comfortable, in the language. The physicists are right, because they care about efficiency. Fortran is still MUCH faster than C. I recently implemented a Fortran back end for a high performance array processing compiler, there was a C back end too. Initial tests indicated about the same speed -- until the boss pointed out I forgot to use the optimisation switch on the fortran compiler. With that switched on, f90 executed the SAME highly optimised program something like 30% faster than C. [Using Solaris on a large sparc server] [now consider parallel computing ...] C9X has a few new features that might narrow the gap -- variable length arrays on the stack, a 'restricted' qualifier for function arguments which emulates fortran's built in rules about aliasing, and inlining. [Forget OO, it was designed to support abstraction dynamically, and that usually involves overhead] -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From hweaver at pinetel.com Thu Dec 16 20:52:32 1999 From: hweaver at pinetel.com (Harold Weaver) Date: Thu, 16 Dec 1999 11:52:32 -0800 Subject: Idle install - no module time References: <3857EB77.BA02A2CF@pinetel.com> Message-ID: <38594300.8D88CDE2@pinetel.com> I have a better definition of my problem: dynamically loaded modules are absent from my installation. Should this problem be referred to a newsgroup that deals with "configure"ing and "make"ing ? Harold Weaver wrote: > When trying to start idle under Linux Redhat 5.1, it fails because it > can't find the module, time. > The interpreter can't find it, either: > > > > Python 1.5.2 (#1, Apr 18 1999, 16:03:16) [GCC pgcc-2.91.60 19981201 > (egcs-1.1.1 on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import time > Traceback (innermost last): > File "", line 1, in ? > ImportError: No module named time > < > > This really stumps me because I have an identical installion on another > box, which works fine. I ran diff on the relevant Setup*, Makefile*, > config* files for the two boxes. > > Actually I can't import any of the modules that Setup should have made > available: > > ( from Setup) > > > > ... > > array arraymodule.c # array objects > cmath cmathmodule.c # -lm # complex math library functions > math mathmodule.c # -lm # math library functions, e.g. sin() > strop stropmodule.c # fast string operations implemented in C > struct structmodule.c # binary structure packing/unpacking > time timemodule.c # -lm # time operations and variables > operator operator.c # operator.add() and similar goodies > > #_locale _localemodule.c # access to ISO C locale support > > # Modules with some UNIX dependencies -- on by default: > # (If you have a really backward UNIX, select and socket may not be > # supported...) > > fcntl fcntlmodule.c # fcntl(2) and ioctl(2) > pwd pwdmodule.c # pwd(3) > grp grpmodule.c # grp(3) > select selectmodule.c # select(2); not on ancient System V > socket socketmodule.c # socket(2); not on ancient System V > #_socket socketmodule.c # socket(2); use this one for BeOS sockets > errno errnomodule.c # posix (UNIX) errno values > > ... > < > The shared modules, *.so, are missing from ../lib-dynload, except for _tkinter.so. "make install" gives: ------------------------------------------------------------------ ... cd Modules; make OPT="-g -O2" VERSION="1.5" \ prefix="/usr/local" exec_prefix="/usr/local" \ sharedmods make[1]: Entering directory `/usr/src/Python-1.5.2/Modules' make[1]: Nothing to be done for `sharedmods'. make[1]: Leaving directory `/usr/src/Python-1.5.2/Modules' ... make[1]: Entering directory `/usr/src/Python-1.5.2/Modules' for i in X ; do \ if test $i != X; \ then ./../install-sh -c -m 555 $i /usr/local/lib/python1.5/lib-dynload/$i; \ fi; \ done make[1]: Leaving directory `/usr/src/Python-1.5.2/Modules' ... ---------------------------------------------------------------- AFAIK this is the only deficiency in the installation. If the solution is obvious, let me know. Thanks. -- Hal From theist at operamail.com Fri Dec 17 03:14:43 1999 From: theist at operamail.com (Theist) Date: 17 Dec 1999 02:14:43 GMT Subject: Python port on Open Edition Message-ID: <8E9EBCE5Etheistoperamailcom@207.69.128.201> I was unable to find the Python binaries for IBM OS390 Open Edition (a Unix variant running on IBM mainframes). Does anyone know if there is such a thing? Thanks, Raj From kbaldermann at entire-systems.com Thu Dec 16 13:10:05 1999 From: kbaldermann at entire-systems.com (Klaus Baldermann) Date: Thu, 16 Dec 1999 13:10:05 +0100 Subject: Help?? Struct packing of Date time not has stopped working??!?! References: <835mvi$62t$1@nnrp1.deja.com> <38579924@194.120.211.23> Message-ID: <3858d6a1@194.120.211.23> Benjamin Schollnick wrote in message ... >Both !L, & !d (Long, and Double), were not unpacking >correctly. no wonder, when the buffer passed to it doesn't match the format. >Is there someway to have telnetlib return BINARY data directly? Now THIS is the key. After a bit more checking the time server's output as returned by telnetlib I found out that several characters are not passed through (Nulls, Control-Q, etc). After a look at telnetlib.py it became obvious that telnetlib is too sophisticated for our purpose. A simple socket should do, see below --- snip --- # set the time from server import socket, struct, time, os, sys corr = 2208988800L # Differenz zwischen 1.1.1900 (vom Server) und 1.1.1970 (localtime) if len(sys.argv) < 2: host = 'www.alz.mgi.de' else: host = sys.argv[1] connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM) connection.connect((host, 37)) line = connection.recv(4) connection.close() seconds = struct.unpack('!L',line)[0] - corr timestring = time.strftime("%X", time.localtime(seconds)) os.system("time " + timestring) # this is for MS-DOG, Losedows, etc. print "time set to", timestring --- snip --- HTH Klaus From herzog at online.de Thu Dec 23 21:35:32 1999 From: herzog at online.de (Bernhard Herzog) Date: 23 Dec 1999 21:35:32 +0100 Subject: __init__ keyword param for sub-class? References: <14434.30055.405044.204758@weyr.cnri.reston.va.us> Message-ID: "Fred L. Drake, Jr." writes: > I think it would be nice to have a way to specify that an argument > *must* be given as a keyword parameter, and have it never be filled in > from positional parameters. Perhaps something lispish: > > def __init__(self, *posArgs, **keyArgs, :myoption): > self.__myoption = myoption > return Pmw.ScrolledText.__init__(self, *posArgs, **keyArgs) I agree that this would be a very useful feature, although I think def __init__(self, *posArgs, myoption=, **keyArgs): would be a more pythonic notation and the order of arguments makes more sense to me. After all, the myoption argument is to be bound to the local variable myoption and **keyArgs collects all remaining keyword args. In my example, myoption must be provided because it has no default value and it must be a keyword argument. It should also be possible to assign a default value with the obvious notation: def __init__(self, *posArgs, myoption=1, **keyArgs): In this case, myoption may be given as an argument or not, but if it's given it must be a keyword arg. Hmm, my post almost sounds like a proposal... -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From jsight at mindspring.com Mon Dec 6 05:26:46 1999 From: jsight at mindspring.com (Jesse D. Sightler) Date: Sun, 05 Dec 1999 23:26:46 -0500 Subject: Very useful message -- Hah! References: <82do53$2rhr$1@hub.org><384A9BE0.B345509@inka.de> <384ABC57.DDC3B61E@inka.de> <87u2lxuooi.fsf@freddy.page.street> <87bt85dlxz.fsf@freddy.page.street> Message-ID: <384B3B06.9FB9B4F0@mindspring.com> Dan Grassi wrote: > > in article 87bt85dlxz.fsf at freddy.page.street, David N. Welton at > davidw at prosa.it wrote on 12/5/99 6:09 PM: > > > Python is extensible to make it do whatever you want. As is any good > > language. > > >It sucks to build a language that is built around one and > > only one thing, IMO. > > If you that is a reference to php I only have one comment: It works well and > python doesn't. > > > Ummm, CGI's are definitely not mod_php. CGI is an interface between > > the server and seperate processes. Mod_php is a module compiled (or > > loaded, if you have DSO support) into Apache, which gives you a lot of > > advantages. > > Look, I'm really getting tired of the symantics! I don't care if it is cgi > or whatever, I want the _results_, he _capabilities_. This is NOT a symantic difference! Running code as CGI is vastly different from running code underneath an Apache-Integrated Web Application Server. CGI will always be more difficult to debug. If you wish a better way, you should use an application server environment that supports Zope, or Microsoft ASP, or roll-your-own CGI-wrapper/miniAppServer. That IS the Python community's answer to PHP (and others) right now, it simply takes time for IHPs to catch on. None of this has anything to do with Python or Python limitations whatsoever. PS - The real problem is that PHP doesn't support the embedding of alternative languages within its page-compilation technology. Why don't you whine to them about that? :-) -- --------------- Jesse D. Sightler http://www3.pair.com/jsight/ "Do not use a hatchet to remove a fly from your friend's forehead." - Chinese Proverb From hinsen at cnrs-orleans.fr Fri Dec 10 15:03:46 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 10 Dec 1999 15:03:46 +0100 Subject: FORTRAN (and Python!) References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> <829dlk$12p$1@news.wrc.xerox.com> <14411.53378.154350.793014@weyr.cnri.reston.va.us> <82mjag$7oh$1@nntp2.atl.mindspring.net> Message-ID: Phil Austin writes: > 2) I'm hard pressed to think of a reason why working scientists who > solve numerical problems every day shouldn't be steered towards > Fortran/Python, at least until a C++ compiler vendor comes up with I know of exactly one (potential) reason: portability. I have never tried it myself, so I'd like to hear from people who did. Is it possible, with standard tools (i.e. standard Fortran and compilers, Python, PyFort) to write extension modules in Fortran 90 in such a way that they can be compiled and installed as shared libraries on any Unix platform by someone who knows nothing about either Fortran or C? And of course without requiring the original author of the module to know details of all possible Fortran compilers. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From fdrake at cnri.reston.va.us Tue Dec 21 22:03:25 1999 From: fdrake at cnri.reston.va.us (Fred L. Drake, Jr.) Date: Tue, 21 Dec 1999 16:03:25 -0500 (EST) Subject: Arg! [Long] In-Reply-To: References: <14431.56728.357282.276777@weyr.cnri.reston.va.us> <14431.58546.940849.802614@weyr.cnri.reston.va.us> Message-ID: <14431.60189.682411.792427@weyr.cnri.reston.va.us> Magnus L. Hetland writes: > Yup. Sorry about that... But that didn't work either. Ouch. > Well - I didn't write it ;) I was suspecting that the gcc command line was being mis-generated because of the typo. So much for that idea. > vier:~/python/extension$ ls > Makefile.pre.in Setup.in Perhaps this is the problem. ;) There's no spammodule.c (exactly as the message says!). That needs to be here as well; you can't compile without source! > After poring over this dump I think I suspect something (which *might* > be construed as a weakness in the make-control ;)... It guesses the > wrong location for my installation... The /store/lib/python1.5 stuff > isn't mine... I have used an alias for python to point to my own > installation. That *might* be a problem. "python" needs to resolve to the actual python executable from the installation you're building for. If Python isn't itself correctly (say, it's finding the other installed python...), the whole thing will simple build for the wrong installation. But you haven't gotten there yet. For now, what you need is a sufficiently interesting spammodule.c. ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From rjroy at takingcontrol.com Thu Dec 16 18:37:13 1999 From: rjroy at takingcontrol.com (Robert Roy) Date: Thu, 16 Dec 1999 17:37:13 GMT Subject: Please Critique References: Message-ID: <38592109.83771265@news1.on.sympatico.ca> On 7 Dec 1999 02:32:04 GMT, fraley at usfca.edu (Michael Fraley) wrote: >Hello, > >This is my first real-world Python script, I'd like to hear any >pointers on how to improve it or do things better. > >I used it to organize screen access to one of our production systems. >First I dumped the screen access into a text file. The lead four bytes >are the operator number in question, followed by four bytes for each >screen (or wild card ~) and the access. Example - > > 0007D102A204I~~~ > > This means for operator '0007', deny screen 102, allow screen 204, > and inquire only on everything else ('~~~') > >My python script sorts on screen number and writes out a neatly sorted >list. The input is all jumbled up, from years of user updates: > >sample scracc.txt input >----------------------- >0006D900DWEBA~~~A023 >0361D307D023A100A001DWEBI023A~~~ >0733D006A~~~I004 > >Here's how it should look when straightened out > >sample scrnew.txt output >----------------------------------------------- >0006A023D900DWEBA~~~ >0361A001I023A100D307DWEBA~~~ >0733I004D006A~~~ > This is a different approach using regular expressions and a sort function. Much terser though somewhat slower (about 2.5x) because of the re and the call to the sort function. import re import string reFIND4= re.compile('....') outfile = open('srcaccessnew.txt', 'w') for line in open('scraccess.txt').readlines(): l=reFIND4.findall(line) l.sort(lambda x,y: cmp(x[1:4],y[1:4])) outfile.write(string.join(l,'') + '\n') outfile.close() From paul at prescod.net Mon Dec 27 13:28:34 1999 From: paul at prescod.net (Paul Prescod) Date: Mon, 27 Dec 1999 07:28:34 -0500 Subject: Py2K wishes Message-ID: <38675B72.18A139FF@prescod.net> I would love it if one of my Python nits was corrected in Python 2 whenever that comes about. Consider the keywords "def" and "class" "class": noun, taken from Marxist literature, as in "class war" and "history class" "def": adjective, taken from urban slang as in "def comedy jam" Kidding aside, "class" is a noun and "def" is an abbreviation for a verb. Furthermore, "def" is way too generic. Python has class definitions and function definitions. The keywords should be "func"/"function" and "class". ----- The syntax for selecting base classes is un-Pythonic in the sense that it is not clearly obvious what is going on. Java's "extends" keyword is more Pythonic (if only the rest of Java was!). ----- Python has an efficient multi-level dispatching mechanism that is used as the basis for name lookup and attribute lookup. The implementation of this mechanism should be made availab le to the programmer. I should be able to make a proxy object something like this: class Proxy: def __init__ ( self, fallback ): __fallback__=fallback a = Proxy( someObject ) This would imply the following: class SomeClass( someParentClass ): pass assert SomeClass.__fallback__ == someParentClass assert SomeClass().__fallback__ == SomeClass.__fallback__ Paul Prescod From thomas at madeforchina.com Sun Dec 26 02:05:34 1999 From: thomas at madeforchina.com (Thomas Duterme) Date: Sat, 25 Dec 1999 19:05:34 -0600 Subject: pythonpath problems on NT Message-ID: <4.1.19991225185359.00a3bc90@202.95.0.15> Spam detection software, running on the system "albatross.python.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hello Everyone, this may be a really dumb question but I am having some problem with my Zope installation on my Win NT system. I believe it may be a Pythonpath problem as I can see that python is having problems importing modules after running z2.py. [...] Content analysis details: (5.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 FH_DATE_IS_19XX The date is not 19xx. 1.8 DATE_IN_PAST_12_24 Date: is 12 to 24 hours before Received: date 1.7 FORGED_MUA_EUDORA Forged mail pretending to be from Eudora -------------- next part -------------- An embedded message was scrubbed... From: Thomas Duterme Subject: pythonpath problems on NT Date: Sat, 25 Dec 1999 19:05:34 -0600 Size: 2868 URL: From mstenber at cc.Helsinki.FI Mon Dec 13 07:57:52 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 13 Dec 1999 08:57:52 +0200 Subject: Python and regexp efficiency.. again.. :) References: <101219992322162268%zippy@cs.brandeis.edu> <3853AA07.BDA8D0E8@platonix.com> Message-ID: Yishai Beeri writes: > What percentage of the lines is expected to actually match? Very few. Preferably none. Although the real match definition is as follows: (expr|expr|expr|not expr) match. Thus, the last expr usually matches. > What percentage of the lines match the commonstring but none of the tails? About all lines match initial commonstring, but then next sub-commonstrings (that my specialized automated regexp optimizer notices) are rarer (roughly, ~100 different cases, one matches about every time). The final non-common parts do not usually match, except in terminal case. > Would it be helpful to look just for the tails and get rid of erroneous > matches by then looking for the commonstring? Possibly, yes. Hmm.. I have to think about it - main problem is that last "not expr" part, as not-matching-something is much more nontrivial than matching-something. > Yishai -Markus -- The IBM Principle: Machines should work. People should think. The Truth About the IBM Principle: Machines don't often work, people don't often think. From arcege at shore.net Sun Dec 12 18:16:42 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sun, 12 Dec 1999 17:16:42 GMT Subject: Packaging packages? References: <1267109922-8994161@hypernet.com> Message-ID: <_LQ44.106$Ef6.30979@news.shore.net> Gordon McMillan wrote: : Michael P. Reilly wrote: :> Last summer I also created a native (or C) implimentation of :> something similar to what was describe in the distutils SIG, :> something I called Spamcan. It's not as extensive as Gordon's :> Installer but is a little more portable (works on just about any :> platform). The purpose of this module was to have something :> similar to JAR files, so the can file only stores PYC files. The :> general consensus on the distutils list was that something more :> generic was needed (pyz) so I didn't really spend more time or :> even announce it (Gordon's technical implimentation was more :> versatile than mine). : Actually, that part of my Installer package is portable. To be : more precise: : ZlibArchives (including the "building" stuff) work anywhere that : you have zlib, and the base Archive class should work : anywhere, period. This includes building on one machine and : running on another. : CArchives (which can contain anything) are inhibited by : endianness issues (and perhaps alignment issues). But, for : example, I can build a CArchive on Windows and use it on a : 386 Linux. : The trick of appending a CArchive to the executable is only : known to work on ELF / COFF platforms. : The further trick of sticking binaries into the CArchive and : unpacking them / loading them on the fly (self extracting : executables) only works (and is only culturally appropriate) on : Windows. : I have the "standalone" configuration working on Linux. In this : configuration, everything is in one directory: you have an : executable with all the pure Python resources appended to it, : and all the C extensions in one directory, with absolutely no : interference from existing Python installations. I'll be releasing : this when I get my head above water. : And, to emphasize Fredrik's points, this all relies heavily on : Greg's imputil, and it comes in three distinct layers, with : (learning_curve, flexibility) in [(None, tiny), (moderate, : moderate), (large, large)]. My first point was that mine is a native _or_ C implimentation (read/write compatibility). Last summer you would only make the docs and a win32 installer available (I even asked and just got that info), so I just had the docs to go on; you still only mention Windows and Linux. My second point that your format implimentation in CArchive was more usable than mine. I didn't object to your module, or publish mine, last summer because I thought CArchive had potential, just not complete (considering I could only get design specs). Mine was more akin to your ZlibArchive, which is also why I didn't mention mine last summer. You concentrate too much on encapsulating everything into one file - archive, executable, etc. As you say, this is only useful for Windows, useless for anything else. Mine concentrated in encapsulating modules and packages into one or more "cans" to allow transparent loading (adding the filename to sys.path directly). Different approaches. I do not care at all for imputil, but made my module compatable with it. -Arcege From ilya at glas.net Wed Dec 29 13:04:41 1999 From: ilya at glas.net (ilya at glas.net) Date: 29 Dec 1999 12:04:41 GMT Subject: Module-repository References: <386A02A2.5CB32ED9@bibsyst.no> Message-ID: <84ctcp$88k$1@news.glas.net> http://www.vex.net/parnassus > Just wondering why there`s no module repository for Python, like ... eh > ... Perl has in CPAN?? How hard can that be? Just some space to upload > modules and some sort of folder-structure would be enough, at least for > starters. From bwarsaw at cnri.reston.va.us Fri Dec 3 16:46:23 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Fri, 3 Dec 1999 10:46:23 -0500 (EST) Subject: Airline discounts to IPC8 Message-ID: <14407.58831.108498.487329@anthem.cnri.reston.va.us> We've arranged for some great discounts on airfares to IPC8. For more information please see http://www.python.org/workshops/2000-01/local.html -Barry From j.spies at hccnet.nl Wed Dec 1 23:48:48 1999 From: j.spies at hccnet.nl (J.Spies) Date: Wed, 01 Dec 1999 23:48:48 +0100 Subject: What's the canonical vi setting for Python indentation References: <38445B6A.A1283D2E@cs.mu.oz.au> <19991130191414.A2060@better.net> Message-ID: <3845A5D0.46F1575D@hccnet.nl> William Park wrote: > > On Wed, Dec 01, 1999 at 10:19:06AM +1100, Chris WRIGHT wrote: > > I've tried to find out the "OK" indentation settings for python with vi, > > and a troll through deja-news found some hints (like don't do indent = > > 4). Yet I seem to also remember some advice to the contrary?? I want > > indentation to be 4 characters, and readable by/ acceptable to emacs > > python-mode, and to pass tabnanny... > > I use 'vim', and my ~/.vimrc contains (among other things) > set smarttab " use 'shiftwidth' at beginning of line > set shiftwidth=4 " use 4 spaces for indenting > " indentation after Python keywords > autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class > > Yours truly, > William Park > > > > > I think that this should go in the faq...(Couldn't find it from > > www.python.org search) > > > > > > cheers > > and thanks > > > > chris wright > > -- > > Dr. Chris Wright > > Deputy Director, Intensive Care Unit > > Monash Medical Centre It's not in the FAQ, but in the doc/howto/editor Add to your ~/.vimrc file: autocmd BufRead, BufNewfile *.py syntax on autocmd BufRead, BufNewfile *.py se ai if you want to enable syntax coloring and automatic indentation. Jaap Spies Hogeschool Drenthe Let's keep Peace in Mind From jody at sccsi.com Fri Dec 31 01:47:36 1999 From: jody at sccsi.com (Jody Winston) Date: 30 Dec 1999 18:47:36 -0600 Subject: [ANNOUNCE] Pygasm IDE wxWindows Linux Developer Release References: <386B510D.3EC3B9DB@pcpros.net> <19991230070826.B778039@vislab.epa.gov> <19991230161952.A7052@vislab.epa.gov> Message-ID: The program fails with a core dump on an SGI when the first BMP is loaded. But the wxGTK C++ image example and the wxPython BMP code work. A quick hack of changing all of the BMPs to GIFs has the program kind-of working. Fewer core dumps, but none of the icons are being shown. -- Jody Winston From mhammond at skippinet.com.au Wed Dec 29 02:11:19 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 29 Dec 1999 01:11:19 GMT Subject: COM exceptions References: <05108cf7.cd1ab828@usw-ex0102-015.remarq.com> Message-ID: You really need to look into the object. There is nothing special about a COM exception - all it means is that a COM method returned a non-zero result, and this is transformed into a Python exception. There is no code in the PythonCOM support that could explain this... Mark. "sven" wrote in message news:05108cf7.cd1ab828 at usw-ex0102-015.remarq.com... > > A question for any and all Python/COM experts: > > I'm writing a multi-threaded app (under WinNT using the threading > module) that makes heavy use of a third party COM component. > Occasionally the component will throw an OLE Error, which bubbles up to > my code as a pywintypes.com_error. > I can't figure out how to gracefully handle these things. When any > thread encounters one of these, *all* the threads stop (however, the > main interpreter thread does not exit). I've tried looking for dead > threads and restarting them (or replacing them with new ones with the > same target), but apparently these 'stopped' threads are still > considered alive. > I'm not sure if this is a threading issue, a COM issue or some fiendish > combination of the two. > > Any thoughts? > > Thanks for your time. > > Sasha > > > > * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network * > The fastest and easiest way to search and participate in Usenet - Free! > From mstenber at cc.Helsinki.FI Tue Dec 28 13:33:22 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 28 Dec 1999 14:33:22 +0200 Subject: Anyone know of a simple socket proxy in python? References: Message-ID: Sean True writes: > I've searched a bit and not found what I was looking for. I'm looking > for a bit of source code in Python that would run on a firewall and > connect external requests to internal TCP servers. Something like: I'm curious about why it needs to be in Python: there are gazillion(tm) toys that do that already, written mostly in portable-ish C. [1] > python plug.py hostname 80 21 23 For example, redir package does this - can't remember origins, see www.debian.org->packages->redir for details. > I'll reinvent the wheel if necessary, but wanted to check. Comments on > the practicality of such a plug in Python are also welcome. Reinventing the wheel is always fun. > -- Sean -Markus [1] I have one available[2], although it has not been released to public. Mail me if you want it. [2] Many-to-many, many-to-single TCP connection multiplexer. I have used it primarily for allowing me to use say, multiple clients on same persistent connection to remote host. People[3] have claimed it works for your use case as well, though. [3] Some friends needed exactly what you needed -> I supplied them with the program. -- UNIX sysadmin's day: gawk; talk; date; wine; grep; touch; unzip; touch; gasp; finger; gasp; mount; fsck; more; yes; gasp; umount; make clean; make mrproper; sleep From drek at MonsterByMistake.Com Mon Dec 13 22:11:37 1999 From: drek at MonsterByMistake.Com (Agent Drek) Date: Mon, 13 Dec 1999 16:11:37 -0500 (EST) Subject: building string for __import__() Message-ID: I have searched deja, python.org/* and cannot find an answer to my problem. I'm sure I'm just missing something very simple... I have three directory attributes: dirdata = { 'somewhere': '0', 'foo': '1', 'flub': '2' } FILE = "/mnt/somewhere" + dirdata['somewhere'] + \ "/foo" + dirdata['foo'] \ "/flub" + dirdata['flub'] \ "/TARGET" RMDATA = __import__(FILE) will get me the error: ImportError: No module named /mnt/somewhere0/foo1/flub2/TARGET however when I do this from the cmdline: >>> RMDATA = __import__("/mnt/somewhere0/foo1/flub2/TARGET") everything works. The file is called TARGET.py I think that I don't understand how to build up a proper string to pass on to __import__() thanks for any help. cheers, =derek Monster By Mistake Inc > 'digital plumber' http://www.interlog.com/~drek From wware at world.std.com Wed Dec 29 19:04:36 1999 From: wware at world.std.com (Will Ware) Date: Wed, 29 Dec 1999 18:04:36 GMT Subject: dump 8IPC question Message-ID: Is there any special conference rate at the Marriott for us out-of-town cheapskates? Otherwise, are there any nearby cheap hotels (Motel 6, Red Roof Inn, etc)? Thanks. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From ionel at psy.uva.nl Thu Dec 2 13:04:56 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Thu, 2 Dec 1999 13:04:56 +0100 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> Message-ID: <825nbt$p50@mail.psy.uva.nl> Guido van Rossum wrote in message news:199912020003.TAA13009 at eric.cnri.reston.va.us... [... Guido invites us to the Python conference ...] Just an idea - I cannot attend, because of the distance and the lack of travel funds. But I would like to. Frustration and the name of Tim, rang a bell: what if the next Python conference will have a live web-based side? The bell rang by Tim is related to the fact that this web-side of the conference may benefit from Dragon's "Naturally Speaking" speech-to-text conversion facilities, and thus provide live news feeds from the conference and seminar rooms to the web-attendance. To really organize such a dual-event, that is simultaneously ongoing in a normal location and over the web, while providing as much as possible communication and interactivity between the two kinds of participants, is a huge task. However, many pieces of the technology exist already and putting them together is exactly the kind of job that Python handles excellently. So, If you are (an) ambitious (company) consider such a (live-on-the-internet-conferencing) project. You'll definitely get clients. ionel From joakim at login1.styx.net Thu Dec 30 14:15:39 1999 From: joakim at login1.styx.net (Joakim Ziegler) Date: 30 Dec 1999 13:15:39 GMT Subject: Module destructor function? Message-ID: I'm writing a Python module in C. How can I make sure a destructor function gets called when the module is unloaded (similar to init but on unload)? I need to deallocate a couple of things that I allocate in the module init function. -- Joakim Ziegler - styx research director - joakim at styx.net FIX sysop - FIXmud admin - FIDEL & Conglomerate developer From beatle at arches.uga.edu Mon Dec 20 21:27:35 1999 From: beatle at arches.uga.edu (Benjamin Dixon) Date: 20 Dec 1999 20:27:35 GMT Subject: Lists of lists traversal Message-ID: <83m3fn$sb6$1@cronkite.cc.uga.edu> Hello, I am new to Python and am trying to figure out how I can iterate over a list that I know to contain other lists of integers so that I can add up the individual lists inside the larger list. I tried things like this: Sum(input): for x in input: value = 0 for y in input: value = value + y return y and other stuff but I'm not certain as to how to reference a specific member of a given sublist. Ben From simon at george.maths.unsw.edu.au Mon Dec 13 02:24:36 1999 From: simon at george.maths.unsw.edu.au (Simon Evans) Date: 13 Dec 1999 01:24:36 GMT Subject: Tkinter/IDLE crash References: <82pkpk$3o0$1@mirv.unsw.edu.au> <82qvui$s5t$1@nnrp1.deja.com> Message-ID: <831hsk$dij$1@mirv.unsw.edu.au> : In article <82pkpk$3o0$1 at mirv.unsw.edu.au>, I wrote: : > I was making my first foray into Tkinter last night (using Py 1.5.2 : > and IDLE with Win 95). : [snip] : > the "Quit" button, and *everything* quits. The window, the IDLE : > session, everything! Goodbye python, goodbye IDLE, hello desktop. Alex replied: : There is : something badly broken with 1.5.2 on both Win95 and Win98, : it seems -- something that affects IDLE, PythonWin, _and_ : the command line interpreter too, to different degrees. It looks as though this is bigger than I thought. There must be lots of others out there having the same problem, surely? Or am I the only one who types in the examples out of tutorials? I'm fairly new to Python, but I'm pretty sure that IDLE and Tkinter are both pretty standard. If 1.5.2/Tkinter/IDLE can't manage the second-simplest example in the Tkinter tutorial on a popular platform like win9x, how on earth has anyone managed to use it for anything worthwhile? I can't be the first to make a big noise about this. : I consider this to be the biggest current "environment" : problem with Python -- that the latest implementation is : SO fragile on the (alas) single most widespread platform, : that it cannot really be used to develop for it:-(. Ok, now I'm really getting worried...I like Python, I've got a to-do list of applications, and I need my Tkinter, blast it! So, gurus, what's my next step? ================================================================= Simon Evans (simon_at_maths.unsw.edu.au) Physical Oceanography Group School of Mathematics, University of New South Wales, Australia. ================================================================= From jcw at equi4.com Wed Dec 15 15:21:46 1999 From: jcw at equi4.com (Jean-Claude Wippler) Date: Wed, 15 Dec 1999 15:21:46 +0100 Subject: ANN: MetaKit 2.0 open source embedded database Message-ID: <3857A3F7.3191C525@equi4.com> This announcement marks the release of MetaKit as open source. MetaKit is an efficient database library with a small footprint. It's a cross between flat-file, relational databases, and OODBMS. Keywords: structured storage, transacted commit, load on-demand, portable, C++, Python, Tcl, scripting, instant schema evolution. RELEASE NOTES: The new release is nearly identical to the recent 1.9 release, with a few minor tweaks, and updated documentation. The change is that source code is now freely available to anyone. License: X/MIT-style open source. Commercial support is provided though an Enterprise License from Equi4 Software, see the website. MetaKit 2.0 embodies the evolution of 3 years of development and production use, and is considered a pretty stable release. Both the Python and the Tcl extension interfaces have been adjusted to use the new 2.0 release number, and are now part of the core. The MetaKit home page is at: http://www.equi4.com/metakit/ with links to documentation, source code, all license details, mailing lists (moved), defect tracking (new), and a CVS repository (new). The new services are hosted on the SourceForge Open Source site. Binary builds of this library are currently available by FTP for: Unix (AIX, Digital Unix, HP-UX, Linux, Solaris), Windows (9X/NT), and Macintosh (PPC). Older release builds are available for VMS, BeOS, SGI, and a few others (all the way down to 16-bit MS-DOS). Both old and new releases remain 100% supported by yours truly. The bug database is there to report problems, and CVS is there to get fixes and patches back out to everyone - so let's use them! As the 2.0 version number indicates, this also marks the start of a new range of MetaKit releases. Having successfully proven the concepts that underpin MetaKit over the last several years, it is time to open up the system to all developers who are interested in simplicity and raw performance. Over the coming months, I'll be making a substantial number of new contributions, while at the same time inviting every interested developer to discuss ideas to make MetaKit even faster, more scalable, multi-user / -threading, and binding it to many more languages and platforms. If there is a need, separate "stable" & "bleeding-edge" areas will be set up. The website, code, and documentation are currently being adjusted to iron out all wrinkles of these changes. Hello, DBMS world :) -- Jean-Claude Wippler From bwarsaw at cnri.reston.va.us Mon Dec 27 16:58:11 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Mon, 27 Dec 1999 10:58:11 -0500 (EST) Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> Message-ID: <14439.35987.402193.17280@anthem.cnri.reston.va.us> >>>>> "PP" == Paul Prescod writes: PP> I propose that in Python 1.6 tuples be given the demonstrated PP> features: >>> time = (hour=24, minute=00, second=00 ) >>> print time.hour >>> 24 Neat idea, but what about >>> second, hour, minute = (hour=24, minute=0, second=0) >>> print hour ? :) Even though I think this should print `0', it does look weird. -Barry From ivanlan at callware.com Thu Dec 30 15:31:28 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 30 Dec 1999 07:31:28 -0700 Subject: Problems With stringformating... URGEND References: <386c66fc.6336922@news.carinthia.com> Message-ID: <386B6CC0.11976B55@callware.com> Hi All, Kurzmann-- Kurzmann Martin wrote: > > Hi ! > > i'm a kind of newbie in python an at now i have following problem: > > i will format the follosing text and insert some Variables > (excerpt of my code) > > print "\n BEFORE MSG \n" > > msg="""Sehr geehrte/r %s ! > > Treffer! Diesen Moment sind neue Inserate auf unserem Online-Server im > Bereich %s eingelangt, die unser Suchagent f?r Sie aufgesp?rt hat, > passend zu Ihrer gespeicherten Suchabfrage. > > Genau diese Inserate k?nnen Sie unter folgender Adresse abrufen: > http://xxx.xx.xxx.xx/%s/anzclu_%s.taf?_what=search&suchtyp=6&qid=%d > > Wir freuen uns auf Ihren Besuch und w?nschen Ihnen viel Erfolg beim > Suchen und Inserieren! > > Mit freundlichen Gr??en, > das Kleine Zeitung Online Team > > PS: F?r Anregungen und Kritik in Bezug auf unsere Online-Dienste sind > wir sehr dankbar. > > Mail an den Webmaster (webmaster at kleinezeitung.at) gen?gt! > > Kleine Zeitung Online: http://www.kleinezeitung.at > Change this line from: > """ %emailrec, markt_alt, markt, markt, id to: > """ %(emailrec, markt_alt, markt, markt, id) The % operator with strings *requires* a tuple; a single item not in a tuple is treated as a 1-element tuple, and this is probably what's confusing you. Make it a habit to always tuplize items feeding %. > > print "\n AFTER MSG \n" > print "\n" + msg + "\n" > > ANY IDEA WHATS wrong?? > > thanks in advance and a happy Y2K !! > -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 Author: Teach Yourself Python in 24 Hours ---------------------------------------------- From stregidgo at quantisci.co.uk Tue Dec 14 14:28:47 1999 From: stregidgo at quantisci.co.uk (Steve Tregidgo) Date: Tue, 14 Dec 1999 13:28:47 +0000 Subject: __getattr__, hasattr References: <835crr$fjl@mail.psy.uva.nl> Message-ID: <3856460F.5D7FC1B@quantisci.co.uk> Hi Ionel, For hasattr to return 0, __getattr__ must raise an AttributeError: class does_not_work: def __getattr__(self, name): if name in ['spam', 'eggs', 'chips']: return 1 return 0 class works: def __getattr__(self, name): if name not in ['spam', 'eggs', 'chips']: raise AttributeError, name >>> x = does_not_work() >>> y = works() >>> hasattr(x, 'spam') # Seems okay... 1 >>> hasattr(x, 'a') # Whoops! It's broken. 1 >>> hasattr(y, 'spam') # As expected 1 >>> hasattr(y, 'a') # Hurrah! False! 0 >>> It is possible for __getattr__ to return any value at all, so testing its output won't work -- if x.spam is actually None, which evaluates as false, you'd be told that spam was not an attribute of x! Hope this helps, Steve Tregidgo http://www.enviros.com/bc Ionel Simionescu wrote: > > Hi, > > It seems that since one defines __getattr__, > hasattr(obj, name) will happily answer 'yes' irrespective of the attribute > name. > > This does not appear very sound to me. > Do I overlook anything? > > Thanks, > ionel From stalnaker at acm.org Fri Dec 3 04:22:51 1999 From: stalnaker at acm.org (Max M. Stalnaker) Date: Thu, 2 Dec 1999 19:22:51 -0800 Subject: split this newsgroup? Message-ID: The volume on this newgroup might justify splitting the newgroup. Comments? -- Max M. Stalnaker mailto:stalnaker at acm.org http://www.astarcc.com From ionel at psy.uva.nl Wed Dec 1 13:16:59 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Wed, 1 Dec 1999 13:16:59 +0100 Subject: wish: multiline comments Message-ID: <8233mi$d5i@mail.psy.uva.nl> Hi, I would like to see multiline comments possible in some future version of Python. Thank you, ionel From sposhua at my.pc Wed Dec 22 10:44:07 1999 From: sposhua at my.pc (Sposhua) Date: Wed, 22 Dec 1999 09:44:07 +0000 Subject: eval vs. atof Message-ID: Newbie... Why do string.ato[f/i/l] exist when you can use eval()? There must be a reason for these things... From wlfraed at ix.netcom.com Fri Dec 10 05:23:28 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 09 Dec 1999 20:23:28 -0800 Subject: FORTRAN (was Re: indentation) References: <65118AEEFF5AD3118E8300508B124877073CC6@webmail.altiris.com> <384EF139.91ACD637@bioreason.com> <38500A94.FB6EF7DE@be-research.ucsd.edu> <3850368B.F104F1D9@appliedbiometrics.com> Message-ID: On 09 Dec 1999 19:25:32 -0500, Fran?ois Pinard declaimed the following in comp.lang.python: > Christian Tismer writes: > > > I'm 43, and I learned FORTRAN IV right after Algol 64 in the late 70s. > > There was Algol 60, and later Algol 68. Most probably not Algol 64. And FORTRAN IV is effectively equal to "FORTRAN 66" (the year it was standardized). Very late 70's may have had an early FORTRAN 77 compiler out... -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ < From fredrik at pythonware.com Mon Dec 13 10:05:51 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 13 Dec 1999 10:05:51 +0100 Subject: Need help with Tkinter for dynamic # of objects References: <831ov7$ap$1@bmerhc5e.ca.nortel.com> Message-ID: <006301bf4549$44c8c240$f29b12c2@secret.pythonware.com> Donald Parker wrote: > I'm trying to define a Frame class that can have a variable number of button > widgets. Within the Frame class I've tried coding the constructor as > > n=0 > while n < m : > self.set_of_buttons[n] = [Tkinter.Button(self)] > n+n+1 that's just plain weird ;-) try this: self.set_of_buttons = [] for n in range(m): b = Tkinter.Button(self) b.pack(...) self.set_of_buttons.append(b) > I thought types and variables came into existence as a result of assignment, yes, but assigning to a *member* of a collection variable doesn't create the collection itself. (and lists don't grow by themselves either). From Alex.Martelli at think3.com Wed Dec 15 18:33:06 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Wed, 15 Dec 1999 18:33:06 +0100 Subject: Where can I find info on using Python w/ Windows Scripting Ho st Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D49@pces.cadlab.it> Ed writes: > Where can I get info on Python for use under Windows? I am especially > interested in a version that can run under the Windows Scripting Host. > Download Python and PythonWin (aka windows extensions) from www.python.org, and you'll get excellent documentation and information accompanying it; I believe the version you get this way is also fully Active-Scripting compliant (to the point of also being able to HOST other Active-Scripting compliant languages, which I believe is a unique feat!-). There's a book on Python for Win32 programming coming out in January, I believe (I have it on hold at Amazon...), and it should be very good from what I hear. Meanwhile, the book "Learning Python", published by O'Reilly, is a great buy. > I am evaluating various scripting languages for use on the Windows > platform. I expect we will end making VBScript the company standard > but I wanted to evaluate Python and TCL/TKL as well. > Speaking as one very experienced in VBScript, reasonably experienced in Tcl, and a Python newbie -- Tcl is an order of magnitude more usable and productive than VBScript, and Python is at least an order of magnitude more powerful than Tcl. Perl is the scripting language I currently know best, and the original reason I started looking into Python is that it integrates SO much better with Windows, despite all the funding that ActiveState gets from Microsoft to enhance their Windows Perl port. I was surprised to find out that Python manages to deliver just about the same awesome amount of power as Perl, while avoiding its defects and particularly its notorious "steep learning curve" -- Python is a language that I'd have no trouble recommending for use in a first programming course for any kind of audience, yet it STILL manages to be as powerful as anything. As for, why is the Win32 port of Python so good -- well, I assume it has something to do with the fact that the porters are geniuses, of course:_), but given that the people at ActiveState are far from slouches either, I think that's another field where Python's outstanding _cleanliness_ helped. You may be just in time to save your company from a lost opportunity (standardizing on VBScript would be at least that:-)... by all means look into Python in more depth! Alex From vbman at pcpros.net Wed Dec 15 11:17:52 1999 From: vbman at pcpros.net (Cliff Baeseman) Date: Wed, 15 Dec 1999 04:17:52 -0600 Subject: [Announce] Python Builder Developer Release 0.1 Message-ID: <38576AD0.BF96F59A@pcpros.net> I would like to announce the availability of the first development release of Python Builder. The Python Builder team is constructing a Visual Developement Environment much like Visual Basic. The IDE is built with and uses the wxPython port of wxWindows by Robin Dunn. Planned features of the IDE are as follows. 1. WYSIWYG Forms Editor 2. Application Wizards 3. Component Wizards 4. Plugin Capability 5. Source Highlighting Code Editor 6. Integrated Debugger 7. Code Complete / Intellisense Please Note: This is only a release to gain developer support. The project is currently released under a GPL license. This is code that is being heavily worked at the moment but is already semi wysiwyg forms layout. The IDE can be seen at http://www.pcpros.net/~vbman To Join this fast moving project contact Cliff Baeseman vbman at pcpros.net Thanx Everyone! From wware at world.std.com Sun Dec 26 02:02:59 1999 From: wware at world.std.com (Will Ware) Date: Sun, 26 Dec 1999 01:02:59 GMT Subject: midi stuff? Message-ID: Is there any Python code floating around for generating MIDI files, starting from any sort of human-readable score? I'm not looking for anything fancy enough to define sounds or instruments, just use any preexisting instruments already in my soundcard. I'd be particularly pleased if human-readable scores were themselves Python scripts. Thanks for any responses. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From stuarty at excite.co.uk Fri Dec 3 15:51:15 1999 From: stuarty at excite.co.uk (stuart mcfadden) Date: 3 Dec 1999 14:51:15 GMT Subject: breakout References: <825o0f$250$1@news.qub.ac.uk> <826poi$uef$1@nnrp1.deja.com> Message-ID: <828ld3$rb4$1@news.qub.ac.uk> In article <826poi$uef$1 at nnrp1.deja.com>, prestonlanders at my-deja.com says... > >Um, is that the game with the bricks? Glorified pong? > >In article <825o0f$250$1 at news.qub.ac.uk>, > stuarty at excite.co.uk wrote: >> Has anyone wrote a breakout(fairly manditory to have breakout) script >in >> python yet ? >> >> > >-- Yeah. >|| Preston Landers || > > >Sent via Deja.com http://www.deja.com/ >Before you buy. From culliton at clark.net Wed Dec 1 17:13:46 1999 From: culliton at clark.net (Tom Culliton) Date: Wed, 01 Dec 1999 16:13:46 GMT Subject: python test frameworks References: <14402.65296.413573.98151@weyr.cnri.reston.va.us> <3d903fhhch.fsf@amarok.cnri.reston.va.us> <14405.12387.436432.910120@weyr.cnri.reston.va.us> Message-ID: <_Ob14.44147$oa2.324786@iad-read.news.verio.net> In article <14405.12387.436432.910120 at weyr.cnri.reston.va.us>, Fred L. Drake, Jr. wrote: > Now we just need to draft someone knowledgeable in the area and >inflict upon him or her the burning itch to write documentation...! Sounds like something you'd want to see a doctor about before doing anything rash... ;-) ;-) ;-) Tom (Sure Tim would think of something even wittier to say...) From kc5tja at garnet.armored.net Sun Dec 5 04:37:30 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 5 Dec 1999 03:37:30 GMT Subject: Exposing COM via XML-RPC or Something Else References: <1267780385-12582932@hypernet.com> Message-ID: >>COM development followed two conflicting tracks. The C/C++ >>folks followed one track, and the VB folks took another. The >>VB stuff is complex (because the VB folks took all kinds of >>shortcuts based on VB internals). It's also what caught on >>(IDispatch, Automation, the stuff the Python's COM IDispatch is a nice idea, as it provides a language-neutral way of scripting things. AmigaOS implements highly similar capability via ARexx-ports. AmigaOS has benefitted //greatly// from this facility. I can't speak for the complexity of IDispatch, as I've not yet seen its interface definition. However, for my projects at least, if it's too Windows specific, or if it's too complicated for my purposes, I plan on creating an ARexx-like scripting interface called IScriptingInterface. Otherwise, I see absolutely no problems with using an already defined interface standard. >>discovery) is probably better architected, but nowhere near as >>widely used. The part of CORBA that is widely used is >>actually much more straightforward in COM. This I can believe, as most of the CORBA implementations I've seen were dynamic dispatch implementations (oddly enough!) :). >I've still got some room to convince my friend to use something aside from YOU'LL NEVER CONVINCE ME, EVIL FIEND!! ;) >COM, and I'd like to cheat by asking you for the answers, since you sound >knowledgable. Would you recommend COM over CORBA for a low-level object >system? Component system, at least. The word "object" has been too-far overloaded with things that are instantiated from a "class", and exhibits "inheritance," etc. Never mind the fact that aggregation produces the exact same end-result... ;) >Mainly assembler right now; we'll be using C to implement the object >system and most of its components, but also some assembly. Correction -- Dolphin is almost entirely in C now. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From jkraai at murl.com Sat Dec 4 19:25:37 1999 From: jkraai at murl.com (jim kraai) Date: Sat, 04 Dec 1999 12:25:37 -0600 Subject: Naive Question References: <38484DC9.3FF755EB@murl.com> Message-ID: <38495CA1.C1414DCA@murl.com> Michael Hudson wrote: > > jim kraai writes: > > > Greetings, > > > > If I have: > > > > class contrived_collection: > > def __init__(self): > > self.item = [{1,2},{3,4},{5,6}] > > > > a = contrived_collection() > > b = a.item[2] > > > > How can I ask b what it is a member of? > > You can't, at least not without basically adding the information > yourself. Watch out for cycles! That's what I was afraid of. > > I need to somehow know later in processing that: > > 1. b is a member of a.item > > 2. a.item is a member of a > > Hmm... what are you trying to do? Have you looked at Acquisition: I want to make a recursive directory'ish listing and have a list of indexes into it. Now, I believe that I'll do it backwards. Have a linear list of directory objects, and have a nested list of refs to them. Doesn't solve the problem in the way that I wanted to do it, but thats OK! Thanks! > http://www.zope.org/Members/Amos/WhatIsAcquisition > > (which is zope biased; there may be another more generic intro > somewhere but I can't find it just now). > > It s a very cute method for dealing with some problems a bit like > this. Hm, I've been able to avoid the Alternate Zope Universe to date. Thanks for the answer to the question! --jim From Richard.Jones at fulcrum.com.au Wed Dec 15 23:11:38 1999 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Thu, 16 Dec 1999 09:11:38 +1100 Subject: Perl to Python In-Reply-To: Message from Amber Shao of 1999-Dec-15 14:43:33, <38581995.91AC5AA8@exelixis.com> Message-ID: <199912152211.JAA08267@envy.fulcrum.com.au> [Amber Shao] > Does anyone know if there is a way to call Python module from a Perl > script? Look up http://mini.net/pub/ts2/minotaur.html It - with some mucking around getting the appropriate libraries compiled - will let you load pretty much any shared library and call functions within them. You can then use that to load up Python (or Perl or Tcl) from Perl (or Python or Tcl) and call functions that do stuff like execute code. State is preserved within the loaded library's runtime, of course. The one major drawback is that since you're just calling some arbitrary C function, you have to understand what is being returned and deal with it accordingly. It's entirely possible (as long as your computer's architecture allows it) to have Python object references returned from the calls into the Python library and then have them passed back into the Python runtime. I found it interesting, but it needs work to handle at least the basic types that might be transferred between the various languages. Then it would be very, very powerful. Richard From tim_one at email.msn.com Mon Dec 13 23:11:37 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Dec 1999 17:11:37 -0500 Subject: Multiple interpreters and the global lock In-Reply-To: <832pti$7u2$1@mailusr.wdf.sap-ag.de> Message-ID: <000501bf45b7$06bacb60$96a2143f@tim> [Daniel Dittmar] > Problem: > > One topic that occasionally crops up is the wish to keep > multiple interpreters completely separated. The standard > answer is a reference to the 'global lock', which allows > only one interpreter to run at a time. This of course > limits scalability of Python on the server side, especially > on multi processor machines. It's easy to keep multiple interpreters completely separate, with no scalability hassles: if you want N separate interpreters, fire up N distinct copies of Python! There's no problem if you keep the distinction at the process level. The global lock only affects multiple interpreters and/or multiple threads running within a single process (it's a process-global lock, not a system-global lock). > While searching DejaNews for the topic, I found that GvR is > not opposed to removing the lock, provided that there is no > negative impact on stability and performance. > > What I hope to get as answers: > - is it possible? > - would patches be accepted, welcomed, frenetically applauded? You've already been pointed wisely to Greg Stein, and see the Thread-SIG archives where this comes up periodically. Greg's thrust is toward "free-threading", though, which, while it implies no global lock, must deal with all the thread issues. If you run separate processes, it's irrelevant. > - what would be the smoothest path to completition, breaking > the least code? It's unclear that you're asking for free-threading. If you are, it's not easy (for example, the refcount issues you dismiss later can't be ignored in free-threading); if you aren't, what's wrong with running separate processes (in which case the code is already complete -- it comes with the OS <0.7 wink>)? > ... > Disclaimer: > > The cause for this post is not to advance mankind, but to > advance a commercial product. Relax: If the commerical product doesn't advance mankind either, it won't sell . writing-the-os-in-python-is-much-harder-than-writing-a-little-ipc-ly y'rs - tim From skaller at maxtal.com.au Tue Dec 28 20:08:55 1999 From: skaller at maxtal.com.au (skaller) Date: Wed, 29 Dec 1999 06:08:55 +1100 Subject: Python newbie References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> <113901bf470c$cb236f60$0100a8c0@rochester.rr.com> <38654F5C.378F8338@maxtal.com.au> <002601bf4f42$58e98cc0$49294b0c@amd> <000d01bf4ff5$e33d7220$5c2a4b0c@amd> Message-ID: <38690AC7.3A526581@maxtal.com.au> John Ratcliff wrote: > > Thanks for all of the informative messages. It certainly sounds like Python > may be the language I want to use. A few more quick questions. Is there a > C++ implementation of Python? I really prefer *not* to put a large > collection of C code into my C++ application if I can avoid it. As you know, ISO C is pretty much a subset of ISO C++. The current CPython implementation is 'almost' ISO C++ compliant. The code quality is very good. If you want details on ISO C++ compliance, send me an email. [But don't ask me about ANSI C++, I have no idea what that is, I'm Australian :-] -- John Skaller, mailto:skaller at maxtal.com.au 10/1 Toxteth Rd Glebe NSW 2037 Australia homepage: http://www.maxtal.com.au/~skaller voice: 61-2-9660-0850 From clarence at beach.silcom.com Mon Dec 20 20:11:14 1999 From: clarence at beach.silcom.com (Clarence Gardner) Date: Mon, 20 Dec 1999 19:11:14 GMT Subject: Wrong Executable? or something Message-ID: This is a problem I've seen on many linux systems. They're all RedHat or Mandrake (extended RedHat). The python executable in /usr/bin seems to affect scripts that are supposed to be run by other executables. Here's what I mean: First, let's see each python: [clarence at serials2 clarence]$ /usr/bin/python Python 1.5.1 (#1, Mar 21 1999, 22:49:36) ... Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> [clarence at serials2 clarence]$ /usr/local/bin/python Python 1.5.2 (#14, Dec 20 1999, 10:21:32) ... Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> Now here is a little script that explicitly wants to be run by the python in /usr/local/bin: [clarence at serials2 clarence]$ cat pyver #!/usr/local/bin/python import sys print sys.version If I run /usr/local/bin/python and tell it to run this script, all is fine: [clarence at serials2 clarence]$ /usr/local/bin/python ./pyver 1.5.2 (#14, Dec 20 1999, 10:21:32) ... But if I just run the script, something weird happens (I don't really know what): [clarence at serials2 clarence]$ ./pyver Built-in exception class not found: EnvironmentError. Library mismatch? Warning! Falling back to string-based exceptions 1.5.2 (#14, Dec 20 1999, 10:21:32) ... However, if remove the python in /usr/bin: [clarence at serials2 clarence]$ su Password: [root at serials2 clarence]# cd /usr/bin [root at serials2 bin]# mv python Python [root at serials2 bin]# exit Then it runs as expected: [clarence at serials2 clarence]$ ./pyver 1.5.2 (#14, Dec 20 1999, 10:21:32) ... I am one confused puppy :( Does anyone have a clue what's going on here? I would think it must be a Linux thing, but I'm crossposting to comp.lang.python just in case. -=-=-=-=-=-=-=-= Clarence Gardner Software Engineer NetLojix Communications, Inc. NASDAQ:NETX clarence at netlojix.com From sposhua at my.pc Tue Dec 14 18:58:25 1999 From: sposhua at my.pc (Sposhua) Date: Tue, 14 Dec 1999 17:58:25 +0000 Subject: Not really about python... Message-ID: ...but this is the only newsgroup I go to. I use Python for my CGI scripting and it looks like I'm gonna have to put something up on an NT (bleaj!) server. Any1 know the equivalent of Unix's sendmail on Windows? I doubt /usr/bin/sendmail works ;-) Cheers From gerrit.holl at pobox.com Wed Dec 15 17:29:47 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 15 Dec 1999 17:29:47 +0100 Subject: Interpolation between multiple modules of an application. In-Reply-To: <00aa01bf4708$b6714410$f29b12c2@secret.pythonware.com>; from fredrik@pythonware.com on Wed, Dec 15, 1999 at 03:28:46PM +0100 References: <19991215144523.A1707@stopcontact.palga.uucp> <00aa01bf4708$b6714410$f29b12c2@secret.pythonware.com> Message-ID: <19991215172947.A5432@stopcontact.palga.uucp> Fredrik Lundh wrote: > yes, that's wrong. the "import" statement only reads > the module and creates the class once -- the first time > you import the module. > > see "What Does Python Do to Import a Module?" on > http://www.pythonware.com/people/fredrik/fyi/fyi06.htm > for more info (and the one exception to the above rule). Thanks! > > How do I share session-depentent objects between modules, without them all > > doing the same over and over again? > > create them once, on the module level. that's all > you need to do. Thanks! I didn't know this construction works: # a.py a='this' b='that' # main.py import a a.a = 'not this, but another thing' import b # b.py import a print a.a # not what I exspected! Thanks... didn't I search well or isn't this explained in the docs as clear as Fredrik explains it in is FYI 6? regards, Gerrit. -- "The IETF motto is 'rough consensus and running code'" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 5:19pm up 3:15, 10 users, load average: 0.60, 0.25, 0.66 From dr10009 at cl.cam.ac.uk Thu Dec 9 16:02:58 1999 From: dr10009 at cl.cam.ac.uk (Dickon Reed) Date: 9 Dec 1999 15:02:58 GMT Subject: string interpolation syntactic sugar Message-ID: <82ogb2$db2$1@pegasus.csx.cam.ac.uk> As far as I know, if in Python I want a string comprised of the concatenation of some strings and some expressions converted to strings, I have to do something like: " a "+`x`+" b "+`y` or: " a %s b %s" % (`x`, `y`) The first sometimes gets awkward and the second means I have to match up the format string with the tuple which can be a source of bugs. I propose a new kind of string literal wherein bracketed expressions are evaluated then converted to strings. A syntax might be that the string must be prefixed with an e and that curly braces should be used for bracketing, but this the details obviously could vary. So I would write the above case as: e" a {x} b {y}" Backslashifying the curly braces would have the obvious effect. Background: I've used Python a fair bit for the last few years, but had to learn Perl recently, and am starting to miss Perl's string interpolation. But, Perl's syntax won't really work verbatim because Python's variable names aren't prefixed. And this proposal is more powerful because you get things like e"The square root of 5 is {math.sqrt(5.0)}", or nest it should you be that way inclined- eg e"lots of numbers{ e" {x} "*y}". I wouldn't advocate nesting it, but at least nothing obvious breaks. I also think that, for non C programmers at least, writing e" {hex(x)} " might be more intuitive than: " %x " % x I'd imagine that it might be fairly efficient to implement, because the e" a {x} b {y}" could perhaps be transformed in the bytecode generator in to the same resulting bytecode as " a "+`x`+" b"+`y`. An alternative approach might have a function to do this: interpolate("a {x} b {y}") I wonder if this could be implemented as a library service (if it hasn't already been done). Is it as simple as chopping up the string and calling str(eval(foo)) on each bracketted component? The place I come unstuck with this is obtaining the globals and locals of the caller so that the expressions are evaluated in the environment where interpolate is called, but perhaps I'm missing something. In any case, implementing such a routine as a Python function is probably suboptimal because then the string would have to be lexed every time the expression containg the interpolate was evaluated. I think it would be better for the lexing to be done only once, and preferably at byte code compilation time. Comments? Dickon Reed From python-list at teleo.net Wed Dec 1 17:26:48 1999 From: python-list at teleo.net (Patrick Phalen) Date: Wed, 1 Dec 1999 08:26:48 -0800 Subject: Stats In-Reply-To: <3844E0C0.77C29789@safenet.pl> References: <3844E0C0.77C29789@safenet.pl> Message-ID: <99120108474600.03915@quadra.teleo.net> [Jacek Artymiak, on Wed, 01 Dec 1999] :: Does anybody know how many people are using Python? 10,000? 100,000? :: I'm wondering just how big is our community. :: :: Jacek Artymiak :: co-author: StarOffice for Linux Bible (IDG Books Worldwide, Inc.) Since you're a Linux book author, you may have a subscription to Linux Journal. In the December issue, Phil Hughes interviews GvR and poses the same question. The answer is that noone knows. (BTW, in the same issue, Doc Searls interviews ESR, who says, once again, that he has dropped Perl for Python.) Guido does say that his gut tells him the Python community is an order of magnitude smaller than Perl's. so-the-answer-is-42-ly y'rs -patrick From culliton at clark.net Tue Dec 14 21:47:55 1999 From: culliton at clark.net (Tom Culliton) Date: Tue, 14 Dec 1999 20:47:55 GMT Subject: Python suitability References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> Message-ID: <%1y54.9585$W2.27026@iad-read.news.verio.net> In article <38556449.903DA931 at iqsoft.hu>, Nemeth Miklos wrote: >> From: >> bobyu5 at mailcity.com >> I wonder whether you have enough developers who are proficient with >> Python and all the other new technologies you want to use - Python is >> good, but it isn't a panacea, > >How many time (days or weeks) do you think is needed for a good C++ >programmer to become a good Python programmer? Maybe I need to write white paper or a FAQ wizard entry on this so I can just post the URL every time this comes up. Learning python is very quick and easy, especially for developers with experience in more than one computer language. Typically it takes about a day to learn the basics, and a week to get quite comfortable. Developers can be productive with it from the first day. Tutoring helps, since there are a handful of minor conceptual issues which are a bit unusual (e.g. - how "assignment" and "variables" really work), and learning to use the builtin types and the libraries is easier given a few helpful nudges. This is based on having taught Python to around a dozen people. In most cases it has simply been a matter of pointing them at the tutorial and answering questions while they learned it themselves, rather than actually sitting down and teaching. In the cases where I actually walked them through the basics it went even faster. My buddy Dan was the first person I taught Python to after learning it myself. He had a data migration problem that he needed to solve, and I suggested trying Python. Over the course of an afternoon we sat down together and wrote a first cut that worked and Dan learned Python by example. He then was able to pick up the ball and run with it himself, with the occasional answer to a question, or clearing up a misunderstanding, and a few informal reviews. Suggestions like "it would be much easier if you used a dictionary there" or "why don't you make a class/module out of that?" where my biggest inputs to the evolving design. By the end of the next day he had a full featured "prototype". By the end of the week Dan wasn't asking questions any more and came up with some stuff that was really dynamite. Granted Dan is a very bright guy, but his experience with Python has proven to be fairly repeatable. Even just pointing CS new grads at the tutorial and giving them some examples has proven workable on about the same time table. From mlh at vier.idi.ntnu.no Tue Dec 21 21:50:53 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 21 Dec 1999 21:50:53 +0100 Subject: Arg! [Long] References: <14431.56728.357282.276777@weyr.cnri.reston.va.us> <14431.58546.940849.802614@weyr.cnri.reston.va.us> Message-ID: "Fred L. Drake, Jr." writes: > Magnus L. Hetland writes: > > Setup.in contains: > > > > *shared* > > spam spamodule.c > > Should that be spammodule.c? (Note the second "m".) Yup. Sorry about that... But that didn't work either. > That's OK; it detects that from the python on your $PATH as part of > the boot phase. Your final Makefile should have the right value, the > rest is temporary. OK. > > gcc -g -O2 -I/store/include/python1.5 -I/store/include/python1.5 > > -DHAVE_CONFIG_H spammodule.c -o spammodule > The gcc command line is not good. Well - I didn't write it ;) > There should be a "-c" on there > somewhere; Sounds reasonable indeed... > I don't see it here. Without that, gcc tries to link it as > an executable, which doesn't work because the libraries aren't passed > in via -l... (they shouldn't be if you're trying to build a > dynamically loadable module!). Ah... I see. > The doesn't seem to have any relation to the source code; it's all > build control. Yes - that's how it looked to me to (hence the subject :) > True. After checking for the typo I mention above, if it still > doesn't work, try including a complete capture of your session, > starting with "make -f Makefile.pre.in boot". ;) Hm. OK - this posting is getting long-winded anyway... :) vier:~/python/extension$ ls Makefile.pre.in Setup.in vier:~/python/extension$ make -f Makefile.pre.in boot rm -f *.o *~ rm -f *.a tags TAGS config.c Makefile.pre python sedscript rm -f *.so *.sl so_locations VERSION=`python -c "import sys; print sys.version[:3]"`; \ installdir=`python -c "import sys; print sys.prefix"`; \ exec_installdir=`python -c "import sys; print sys.exec_prefix"`; \ make -f ./Makefile.pre.in VPATH=. srcdir=. \ VERSION=$VERSION \ installdir=$installdir \ exec_installdir=$exec_installdir \ Makefile make[1]: Entering directory `/home/stud/f/mlh/python/extension' sed -n \ -e '1s/.*/1i\\/p' \ -e '2s%.*%# Generated automatically from Makefile.pre.in by sedscript.%p' \ -e '/^VERSION=/s/^VERSION=[ ]*\(.*\)/s%@VERSION[@]%\1%/p' \ -e '/^CC=/s/^CC=[ ]*\(.*\)/s%@CC[@]%\1%/p' \ -e '/^CCC=/s/^CCC=[ ]*\(.*\)/s%#@SET_CCC[@]%CCC=\1%/p' \ -e '/^LINKCC=/s/^LINKCC=[ ]*\(.*\)/s%@LINKCC[@]%\1%/p' \ -e '/^OPT=/s/^OPT=[ ]*\(.*\)/s%@OPT[@]%\1%/p' \ -e '/^LDFLAGS=/s/^LDFLAGS=[ ]*\(.*\)/s%@LDFLAGS[@]%\1%/p' \ -e '/^LDLAST=/s/^LDLAST=[ ]*\(.*\)/s%@LDLAST[@]%\1%/p' \ -e '/^DEFS=/s/^DEFS=[ ]*\(.*\)/s%@DEFS[@]%\1%/p' \ -e '/^LIBS=/s/^LIBS=[ ]*\(.*\)/s%@LIBS[@]%\1%/p' \ -e '/^LIBM=/s/^LIBM=[ ]*\(.*\)/s%@LIBM[@]%\1%/p' \ -e '/^LIBC=/s/^LIBC=[ ]*\(.*\)/s%@LIBC[@]%\1%/p' \ -e '/^RANLIB=/s/^RANLIB=[ ]*\(.*\)/s%@RANLIB[@]%\1%/p' \ -e '/^MACHDEP=/s/^MACHDEP=[ ]*\(.*\)/s%@MACHDEP[@]%\1%/p' \ -e '/^SO=/s/^SO=[ ]*\(.*\)/s%@SO[@]%\1%/p' \ -e '/^LDSHARED=/s/^LDSHARED=[ ]*\(.*\)/s%@LDSHARED[@]%\1%/p' \ -e '/^CCSHARED=/s/^CCSHARED=[ ]*\(.*\)/s%@CCSHARED[@]%\1%/p' \ -e '/^SGI_ABI=/s/^SGI_ABI=[ ]*\(.*\)/s%@SGI_ABI[@]%\1%/p' \ -e '/^LINKFORSHARED=/s/^LINKFORSHARED=[ ]*\(.*\)/s%@LINKFORSHARED[@]%\1%/p' \ -e '/^prefix=/s/^prefix=\(.*\)/s%^prefix=.*%prefix=\1%/p' \ -e '/^exec_prefix=/s/^exec_prefix=\(.*\)/s%^exec_prefix=.*%exec_prefix=\1%/p' \ /store/lib/python1.5/config/Makefile >sedscript echo "/^#@SET_CCC@/d" >>sedscript echo "/^installdir=/s%=.*%= /store%" >>sedscript echo "/^exec_installdir=/s%=.*%=/store%" >>sedscript echo "/^srcdir=/s%=.*%= .%" >>sedscript echo "/^VPATH=/s%=.*%= .%" >>sedscript echo "/^LINKPATH=/s%=.*%= %" >>sedscript echo "/^BASELIB=/s%=.*%= %" >>sedscript echo "/^BASESETUP=/s%=.*%= %" >>sedscript sed -f sedscript ./Makefile.pre.in >Makefile.pre cp ./Setup.in Setup /store/lib/python1.5/config/makesetup \ -m Makefile.pre -c /store/lib/python1.5/config/config.c.in Setup -n /store/lib/python1.5/config/Setup.thread /store/lib/python1.5/config/Setup.local /store/lib/python1.5/config/Setup make -f Makefile do-it-again make[2]: Entering directory `/home/stud/f/mlh/python/extension' /store/lib/python1.5/config/makesetup \ -m Makefile.pre -c /store/lib/python1.5/config/config.c.in Setup -n /store/lib/python1.5/config/Setup.thread /store/lib/python1.5/config/Setup.local /store/lib/python1.5/config/Setup make[2]: Leaving directory `/home/stud/f/mlh/python/extension' make[1]: Leaving directory `/home/stud/f/mlh/python/extension' vier:~/python/extension$ make make: *** No rule to make target `spammodule.c', needed by `spammodule.o'. Stop. After poring over this dump I think I suspect something (which *might* be construed as a weakness in the make-control ;)... It guesses the wrong location for my installation... The /store/lib/python1.5 stuff isn't mine... I have used an alias for python to point to my own installation. But even so, I'm to tired to figure out the connections... > > > Yes... There is no ./Makefile.pre.in that I can see... :) > > Ah! You can tell I haven't set up a new extension module in months! > (This is a good thing! ;) :) > > > -Fred -- Magnus Lie Hetland From tiddlerdeja at my-deja.com Mon Dec 13 01:05:14 1999 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Mon, 13 Dec 1999 00:05:14 GMT Subject: win32com: subclass a com object? References: <830pi6$n4k$1@nnrp1.deja.com> Message-ID: <831d7o$4gs$1@nnrp1.deja.com> In article , "Mark Hammond" wrote: > Another reply suggested using delegation - ie, create a completely seperate > class, and have it hold the "real" COM object. This is a good suggestion. > Thanks for this. The thought had crossed my mind to use delegation, but that would not follow the "isa" inheritence model I'd like to use. I'll try your code below too as it looks like what I'm after. Thanks for your help. > However, to implement sub-classing you can do the following: > >>> klass = win32com.client.gencache.GetClassForProgId("Excel.Application") > >>> if klass is None: raise RuntimeError, "Please run makepy for this > object." > >>> class MyExcel(klass): > ... pass > > Mark. > > Sent via Deja.com http://www.deja.com/ Before you buy. From mjackson at wc.eso.mc.xerox.com Thu Dec 9 05:27:44 1999 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 9 Dec 1999 04:27:44 GMT Subject: FORTRAN (was Re: indentation) References: <=CNPOJoL=1A0AudQdqJsHw5LCpzM@4ax.com> Message-ID: <82nb40$cv3$1@news.wrc.xerox.com> Dennis Lee Bieber writes: > On 8 Dec 1999 21:41:36 GMT, aahz at netcom.com (Aahz Maruch) declaimed the > following in comp.lang.python: > > > Hmmm... I wonder who the youngest person in this group is who has > > actually used FORTRAN on the job. I'm 32; I did the work twelve years > > ago. > > I'm feeling archaic... I'm 42 (or close-enough not to worry)... > I'm STILL using FORTRAN at work... Have been since 1981 (anything older > was college course-work). Feel young again: I'm 51 and am still working with Fortran. We have legacy code written, and "legacy" xerographic physicists most comfortable, in the language. But for some of them (I include myself) Python has provided an accessible, even relatively non-threatening, path to OO. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson It doesn't matter that I'm a crab! I'm an Internet visionary! - Hawthorne (Jim Toomey) From mlh at vier.idi.ntnu.no Mon Dec 20 21:43:46 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 20 Dec 1999 21:43:46 +0100 Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <83lnq7$c9d$1@news1.tele.dk> Message-ID: "Jesper Hertel" writes: > I hope this was a joke. That kind of constructions is impossible to read for > other programmers, making the program hard to maintain. > It is idiomatic python, really... > > > Jesper Hertel -- Magnus Lie Hetland From fredrik at pythonware.com Tue Dec 28 15:58:10 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 28 Dec 1999 15:58:10 +0100 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> Message-ID: <02bf01bf5143$f6285400$f29b12c2@secret.pythonware.com> Paul Prescod wrote: > I propose that in Python 1.6 tuples be given the > demonstrated features: > > >>> time = (hour=24, minute=00, second=00 ) > > >>> print time.hour > 24 > > >>> hr, min, sec = time > >>> print hr, min, sec > (24, 00, 00 ) > >>> min, sec, hr = time > >>> print min, sec, hr > (24, 00, 00 ) > > (this last just demonstrates that tuples continue to work the way they > always have. There is no magic about looking at the names of > assignments) footnote: this is a generalization of an old proposal from Thomas Bellman: http://www.deja.com/getdoc.xp?AN=280528262 (includes "super tuple" implementations for time, pwd, grp, and os.stat) From alwyns at prism.co.za Wed Dec 29 12:32:19 1999 From: alwyns at prism.co.za (Alwyn Schoeman) Date: Wed, 29 Dec 1999 13:32:19 +0200 Subject: why? References: <386986aa.238773@news.isomedia.com> Message-ID: <3869F143.90051270@prism.co.za> Could someone please port those to KDE and GNOME? :) Eugene Goodrich wrote: > I just remembered: you should Python because it has cool file icons. > > -Eugene > > On Tue, 28 Dec 1999 03:40:32 GMT, "ekko" wrote: > > >I don't know that much about Python and I have some questions. Why would I > >want to learn Python. What uses does it have? What kind of programs can I > >make with Python? Thanks. > > > > > > import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==') > -- > http://www.python.org/mailman/listinfo/python-list -- ~~~~~~~~~~~~~~ Alwyn Schoeman Systems Engineer Prism Secure Solutions From thantos at chancel.org Fri Dec 17 00:53:38 1999 From: thantos at chancel.org (Alexander Williams) Date: Thu, 16 Dec 1999 23:53:38 GMT Subject: Python complaints References: <3858C226.949FC9C6@udel.edu> <38592B4A.9CB86B0E@maxtal.com.au> Message-ID: On Fri, 17 Dec 1999 05:11:22 +1100, skaller wrote: >Unfortunately, new technology supporting literate programming >is generally fairly arcane, hard to use, and slow I rather lik how Haskell adresses the problem; simple, easy, and without structure or boundary. For the uninitiated: Most Haskell code has a .hs extension. .lhs is Literate Haskell. In Literate Haskell /every/ line is assumed to be comment ... unless it starts with >. Thus, to document you just write along as if writing a paper, embedding the code with >s in front of it after you've discussed it or interspersed with discussion. Simple, direct, unstructured. It suits my passion for simplicity. :) -- Alexander Williams (thantos at gw.total-web.net) | In the End, "Join the secret struggle for the soul of the world." | Oblivion Nobilis, a new Kind of RPG | Always http://www.chancel.org | Wins From tescoil at rtpro.net Mon Dec 13 08:13:26 1999 From: tescoil at rtpro.net (Tesla Coil) Date: Mon, 13 Dec 1999 08:13:26 +0100 Subject: What do we call ourselves? References: <3850734D.FD1D7A2C@callware.com> Message-ID: <38549C96.43AE8478@rtpro.net> On 9 Dec 1999, Ivan Van Laningham wrote: > "'A _Parselmouth_!' said Ron. 'You can talk to snakes!'" > > --_Harry Potter and the Chamber of Secrets_, by J.K. Rowling. > Arthur A. Levine Books, New York: 1999. > > A Parselmouth understands parseltongue, it says later in the book. > Presumably, speaking, reading and writing all come under the rubric > of understanding. > > Quod erat demonstrandum: we are all Parselmouths! Which would make messages to this newsgroup Parsel-posts, no? From rgruet at ina.fr Fri Dec 3 15:44:24 1999 From: rgruet at ina.fr (Richard Gruet) Date: Fri, 03 Dec 1999 15:44:24 +0100 Subject: emulating `` shell operator in Python? References: <001101bf3d9a$0cb2b700$3acbd9c2@peridot.optichrome.com> Message-ID: <3847D748.924500E8@ina.fr> Thank U, it works. In fact, I've already tried popen() one year ago, but it behaved strangely on Windows (or I misused it). Now, everything looks OK. Adrian Eyre wrote: > > - But the really tricky case is to catch in a string the output of a > > *shell* command, such as os.system('ls'). > > The above strategy doesnt work because the command executes in a > > sub-shell (external to python) with its own stdout and stderr. > > import os > > f = os.popen("ls", "r") > s = f.read() > f.close() > print s Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From dworkin at ccs.neu.edu Thu Dec 16 17:08:30 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 16 Dec 1999 11:08:30 -0500 Subject: Please Critique References: <3855DB3D.998F3081@mincom.com> <3855f936@194.120.211.23> Message-ID: "Klaus Baldermann" writes: > This could be even more perlified: Well, sure. Most things could. But it isn't usually a good idea. -Justin From cwr at cts.com Sat Dec 4 13:43:19 1999 From: cwr at cts.com (Will Rose) Date: 4 Dec 1999 12:43:19 GMT Subject: indentation References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> <829dlk$12p$1@news.wrc.xerox.com> Message-ID: <82b297$1lq$1@thoth.cts.com> Mark Jackson wrote: : "Fred L. Drake, Jr." writes: :> Gerrit Holl writes: :> > As i said: people who start with Python as a first language like it. :> :> There are those of us who started with x86 assembly and BASIC who :> like it too! (And Pascal, and C, and C++, and... hey, how many places :> can one person start in, anyway? ;) : And Fortran. Don't forget Fortran. I always assumed that Python's whitespace rules _came_ from Fortran IV: or at least something overly intimate with 80-col punched cards. Will cwr at crash.cts.com And now, little kitties, this job is urgent so we will drop the nice cards all _over_ the floor! From parkw at better.net Wed Dec 1 01:14:14 1999 From: parkw at better.net (William Park) Date: Tue, 30 Nov 1999 19:14:14 -0500 Subject: What's the canonical vi setting for Python indentation In-Reply-To: <38445B6A.A1283D2E@cs.mu.oz.au> References: <38445B6A.A1283D2E@cs.mu.oz.au> Message-ID: <19991130191414.A2060@better.net> On Wed, Dec 01, 1999 at 10:19:06AM +1100, Chris WRIGHT wrote: > I've tried to find out the "OK" indentation settings for python with vi, > and a troll through deja-news found some hints (like don't do indent = > 4). Yet I seem to also remember some advice to the contrary?? I want > indentation to be 4 characters, and readable by/ acceptable to emacs > python-mode, and to pass tabnanny... I use 'vim', and my ~/.vimrc contains (among other things) set smarttab " use 'shiftwidth' at beginning of line set shiftwidth=4 " use 4 spaces for indenting " indentation after Python keywords autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class Yours truly, William Park > > I think that this should go in the faq...(Couldn't find it from > www.python.org search) > > > cheers > and thanks > > chris wright > -- > Dr. Chris Wright > Deputy Director, Intensive Care Unit > Monash Medical Centre From mfletch at tpresence.com Tue Dec 14 16:13:55 1999 From: mfletch at tpresence.com (Mike Fletcher) Date: Tue, 14 Dec 1999 10:13:55 -0500 Subject: Python complaints Message-ID: for first, second, third in [ (a/x, a**2, y) for a in listone, for y in [(l3val**4) for l3val in listthree], for x in [(2**math.PI**l4val) for l4val in listfour], ]: print first, second, third Or something similar is probably what people are hyped about. I.e. complex parallel processing of multiple lists with multiple levels of comprehension (ww?). Note, I'm sure someone will want to add "for i indexing x in []" syntax to this construct :) . Cheers, Mike -----Original Message----- From: Charles Boncelet [mailto:boncelet at udel.edu] Sent: Tuesday, December 14, 1999 6:13 AM To: python-list at python.org Subject: Re: Python complaints ... This is the first I've seen of this notation and it is simple and (reasonably) understandable. But the savings is minimal versus normal Python fx = [] for a in x: fx.append(a**2) Am I missing something? ... From roth at teleport.com Tue Dec 28 15:53:09 1999 From: roth at teleport.com (tony roth) Date: Tue, 28 Dec 1999 06:53:09 -0800 Subject: newbie win32 stuff References: <848tpj$tdf$1@nnrp1.deja.com> Message-ID: Thanks for the reply John, the funny thing is that it executes fine sometimes but if it fails it will not work correctly until I exit python and then re execute python! anyway thanks tr "John Nielsen" wrote in message news:848tpj$tdf$1 at nnrp1.deja.com... > I recently switched to python for win32 stuff from using C++ and Perl > and have found it to be very easy to use. > > The try: except: block catches 'exceptions' which are basically errors > that typically cause the program to halt. In other words, it gives you > the ability to decide what the program should do when faced with an > error. Perhaps you don't want it to exit or maybe you need to do some > cleanup before exiting. > > Another useful thing to do with the 'except:' part of the block is print > out the actual error. > > For example, > try: > . . . bad code here . . . > except: > print 'I got an error and it is',sys.exc_type , sys.exc_value > > If you import sys, you can use that module to show you the error python > got. > > I tried some some registry code in conjunction with NetServerEnum in > pythonwin and had no problems. Where is your code hanging? > > john > > > > In article , > "tony roth" wrote: > > I have a script that when I run it within pythonwin it behaves poorly > but > > when I run it within idle it runs just fine. Below is the code, I'm > just > > learning python so forgive me if it looks screwy. Under idle it > creates a > > tuple "dm" which contains the names of all workstations within the > > "xyzdomain" and then enumerates the nameserver values but under > pythonwin it > > just hangs the process. Any ideas. > > thanks > > > > ps the try/except construct is still confusing to me. Is the try > catching > > all exceptions generated beween the the try: except: construct? > > > > import win32net,win32netcon,win32api,win32con > > > dm=win32net.NetServerEnum('',100,win32netcon.SV_TYPE_WORKSTATION,'xyzdom > ain' > > ,0,4096*2) > > for x in dm[0]: > > try: > > > > > rk=win32api.RegConnectRegistry(str(x['name']),win32con.HKEY_LOCAL_MACHIN > E) > > > > > nk=win32api.RegOpenKeyExrk,'SYSTEM\\CurrentControlSet\\Services\\NetBT\\ > Adap > > ters\\',0,win32con.KEY_ALL_ACCESS) > > test=win32api.RegEnumKey(nk,0) > > regkey='SYSTEM\\CurrentControlSet\\Services\\NetBT\\Adapters\\' > + test > > nk=win32api.RegOpenKeyEx(rk,regkey,0,win32con.KEY_ALL_ACCESS) > > ns=win32api.RegQueryValueEx(nk,'NameServer') > > print str(x['name']), > > print ns[0][0], > > except: > > print "can not contact " + str(x['name']) > > > > > > -- > nielsenjf at my-Deja.com > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From nielsenjf at my-deja.com Wed Dec 22 05:11:26 1999 From: nielsenjf at my-deja.com (John Nielsen) Date: Wed, 22 Dec 1999 04:11:26 GMT Subject: pythoncom and MTS References: <4D0A23B3F74DD111ACCD00805F31D8101D8BCB5A@RED-MSG-50> Message-ID: <83pj1c$sl7$1@nnrp1.deja.com> Here is some code that may help you. To get the IIS ADSI component try something like this: adsi=win32com.client.Dispatch('ADsNameSpaces') adspath='IIS://localhost/w3svc/1' adsobj=adsi.getobject("",adspath) If you have the latest pythoncom, search in the COM section for ADSI. You'll find some examples using get,put, putex, etc. for ADSI (though in this case using exchange). john In article , "Stephen Milton" wrote: > Could someone give me an example of how to work with the IIS/MTS server > components thru Python. All of the supplied examples for administration of > the IIS/MTS server are written in VBScript, but I would like to be able to > directly work with the various objects thru Python. An example of the VBS > code I am trying to implement in Python follows: > > ADSPath = "IIS://localhost/w3svc/1" > Set ADSObject = GetObject (ADSPath) > ADSObject.Put ObjectParameter, (ValueList) > > Email CC on replies would be appreciated. > > Thanks in advance, > > Steve Milton > ISOMEDIA, Inc. > > "Bill Tutt" wrote in message > news:4D0A23B3F74DD111ACCD00805F31D8101D8BCB5A at RED-MSG-50... > > Well, not the sole developer as other people pitch in from time to time. > > (Me, Greg Stein, Christian Tismer, and a couple of other people.) > > Mark's just the guy that tends to fix most of the problems people find. :) > > > > Bill > > > > > From: tiddlerdeja at my-deja.com [mailto:tiddlerdeja at my-deja.com] > > > > > > > > > Also Mark, I was just wondering, are you the sole developer on > > > pythoncom? Are there others? > > > > > > > -- nielsenjf at my-Deja.com Sent via Deja.com http://www.deja.com/ Before you buy. From jam at quark.emich.edu Tue Dec 14 19:23:40 1999 From: jam at quark.emich.edu (Jeff) Date: Tue, 14 Dec 1999 13:23:40 -0500 Subject: Not really about python... In-Reply-To: References: Message-ID: <19991214132340.B25296@quark.emich.edu> On Tue, Dec 14, 1999 at 05:58:25PM +0000, Sposhua wrote: > ...but this is the only newsgroup I go to. > > I use Python for my CGI scripting and it looks like I'm gonna have to put > something up on an NT (bleaj!) server. Any1 know the equivalent of Unix's > sendmail on Windows? I doubt /usr/bin/sendmail works ;-) > > Cheers > I would suggest using the 'smtplib' module, and pointing at an appropriately sanctioned host. this will solve the problem neatly and portably on unix and on NT. regards, J -- || visit gfd || psa member -- || New Image Systems & Services, Inc. From pf at artcom-gmbh.de Mon Dec 13 10:09:35 1999 From: pf at artcom-gmbh.de (Peter Funk) Date: Mon, 13 Dec 1999 10:09:35 +0100 (MET) Subject: Tkinter Menus on WinXX platform Message-ID: Hi! Using Linux as main development platform I'm trying to write a portable GUI application using Python and Tkinter. Testing on Win98 using py152.exe I noticed three small problems with menus: 1. Menu Radio- and Checkbuttons have both a check (tick, peg?) where Radiobuttons shoulld have a dot (period) when selected. 2. If a menu is drawn the first time, selected check und radio buttons are not drawn correctly. You have to move the mouse cursor above those buttons to provoke a redraw. 3. If tear off menus using the perforation and than close (withdraw) the window containing the menu, the "teared off" menu window stays on the screen (which also happens on Linux ) These are all problems not directly related to python. May be they would disappear, if using a newer version of Tcl/Tk? How much work is required, to replace Tcl/Tk 8.0.5 with version 8.2? I've had a look at the python-cvs-tarball recently and haven't seen any change in tkinter towards a newer version? Is there somebody working on that? Regards, Peter -- Peter Funk, Oldenburger Str.86, D-27777 Ganderkesee, Germany, Fax:+49 4222950260 From nick at src.uchicago.edu Wed Dec 22 17:00:26 1999 From: nick at src.uchicago.edu (Nick Collier) Date: Wed, 22 Dec 1999 10:00:26 -0600 Subject: file time to dos time Message-ID: <3860F59A.9CEEE42E@src.uchicago.edu> Hi, I'm trying to convert the results of os.path.getmtime(path) - last modification time in seconds since the epoch - to the dos time format which I think is a 36 bit number with bit fields for the year, month, day, hour, seconds. I'm coming close with some guessed at bitwise arthimetic, but can't get the year correct. Any suggestions? thanks, Nick -- Nick Collier nick at src.uchicago.edu Social Science Research Computing University of Chicago Chicago, IL 60637 From ullrich at math.okstate.edu Sun Dec 12 20:39:14 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 12 Dec 1999 13:39:14 -0600 Subject: Dot product? References: <3852B91D.6EE31805@math.okstate.edu> Message-ID: <3853F9E2.AD7B8F9C@math.okstate.edu> Berthold H?llmann wrote: > "David C. Ullrich" writes: > > > Ok, so I'm dense. [...] > How about: > > def Dot(X, Y): > res = 0. > for (x,y) in map(None, X, Y): > res = res + x * y > return res Aha - I knew there must be something I was missing, thanks. I would never guessed that that's what map(None, X, Y) would do. Let's see... nope, I got no excuse, all explained clearly in the docs under "map". I didn't realize that map could take more than one parameter. Exactly what I was hoping to find, thanks. DU From gmcm at hypernet.com Tue Dec 28 23:27:06 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 28 Dec 1999 17:27:06 -0500 Subject: Py2K wishes In-Reply-To: <38687D6A.D525D91F@prescod.net> Message-ID: <1265703355-58310119@hypernet.com> Paul Prescod wrote: > > >class Proxy: > > > def __init__ ( self, fallback ): > > > __fallback__=fallback > > > > >a = Proxy( someObject ) > > > > >This would imply the following: > > > > >class SomeClass( someParentClass ): pass > > >assert SomeClass.__fallback__ == someParentClass > > >assert SomeClass().__fallback__ == SomeClass.__fallback__ [William Tanksley] > > I don't have a clue what this is doing. Sorry. > > It's doing what Python has always done with instances and their > classes and base classes. Only now it is doing it based on a more > explicit, generalized, reusable mechanism. Sorry Paul, but I can't connect these statements. In class Proxy, I've got an instance wrapping an instance, with the wrap being done magically by "__fallback__". Presumably this means that __getattr__ and __setattr__ have been overridden for me. OK, now I can override methods on the wrapped instance by adding methods to Proxy. But if I were doing that, I wouldn't proxy, I would subclass. Don't know about you, but I proxy when I'm changing the mechanics of an object (eg, marshalling, tracing, or some meta-behavior), not twiddling with methods. Your implications don't make sense to me, either. Does the first assert imply that MI is passe? Does the second imply that the difference between bound and unbound methods (and the reasons for the difference) have disappeared? - Gordon From ssimonet at omnitechconsulting.com Sun Dec 19 17:48:45 1999 From: ssimonet at omnitechconsulting.com (Steve Simonet (Omni)) Date: Sun, 19 Dec 1999 11:48:45 -0500 Subject: Tcl/Tk 8.2 Message-ID: <385D0C6D.D92B2F12@omnitechconsulting.com> Python 1.5.2 on Windows does not appear to work out of the box with Tcl/Tk 8.2, even after modifying TkFix.py to look for 82 rather than 80. Can this be overcome? -- Steve From jose.manuel.esteve at xps.xerox.com Fri Dec 17 18:14:34 1999 From: jose.manuel.esteve at xps.xerox.com (José Manuel Esteve Gómez) Date: Fri, 17 Dec 1999 18:14:34 +0100 Subject: MultiProcessor and Win32 threads Message-ID: <83droq$ocp$1@news.wrc.xerox.com> I am trying to write a multithreading application in Python to work on Windows NT multiprocessor (4 processor) hardware. Basically I am using the beginthreadex function from the win32 process extension mudule from Mark Hammond. The application runs fine and in fact the threads run on the different processor, But it seems that the interpreter is proccesiing them sequentially rather than in parallel, so they only profit 25% cpu time of each processor. I have been trying to find some info in the thread interest group , but the only hint is that threading in Python depends o n a central lock, and seems to be a patch for Python 1.4 but no patch for Python 1.52 to avoid this problem. Is win32 process threading dependant on this central lock ??? Is there in fact a central lock that prevents parallel processing on a multiprocessor NT environment ?? Is there any way to avoid that ??? On the other hand the function SetThreadIdealprocessor from win32process seems to be broken. Please take into account that the environment for this application will always be Win NT that is why i am using win32 extension module. Best Regards From rouanet at bordeaux.inserm.fr Wed Dec 15 17:59:50 1999 From: rouanet at bordeaux.inserm.fr (Rouanet Jean-Francois) Date: 15 Dec 1999 16:59:50 GMT Subject: PygreSQL and Windows NT Message-ID: <8E9DB5409rouanetbordeauxinser@195.221.150.12> I have to write an application on Windows Nt who need to connect to a Linux PostgreSQL server. I'd like to use Python and PygreSQL but I have not succeeded in compiling PygreSQL on Win32 (I am not an expert). Has anybody a compiled version of pgmodule.c for Nt or some hints to compile it? Thank you. J.Francois From NOSPAMbruce_wheeler at hp.com.NOSPAM Fri Dec 3 22:32:48 1999 From: NOSPAMbruce_wheeler at hp.com.NOSPAM (Bruce Wheeler) Date: Fri, 03 Dec 1999 13:32:48 -0800 Subject: Environment variables References: Message-ID: <38483700.99BFEC46@hp.com.NOSPAM> Kevin Cazabon wrote: > > I ran into the same thing... It's not too hard on NT, as you can set most > of them through the registry using Mark Hammonds Win32 Extensions. For > Win98, I've been adding the changes to the autoexec.bat and forcing a > reboot. > > One thing I've found though: changing things in the NT registry works, but > the changes don't actually become effective immediately. I'd recommend a > reboot to be safe after setting up your changes. > I've found just a logoff/logon works. However if you use the control panel / system / environment to add a new variable, any new shell for python will have the new variable. The environment variables are permanently stored in either HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session Manager/Environment for system variables. HKEY_USERS//Environment for user variables. I'm guessing, but if you also updated HKEY_CURRENT_USER\Environment it might work the same as using the control panel. I need to solve the same problem in the next week or so. I'll post the answer when I do. Hope this helps Bruce_Wheeler at hp.com From tim_one at email.msn.com Wed Dec 8 08:45:58 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 8 Dec 1999 02:45:58 -0500 Subject: ANN: grassi python 3.0 In-Reply-To: <82ftb9$2gat$1@hub.org> Message-ID: <000101bf4150$44b895c0$5aa2143f@tim> [t. muddletyn] > ... > If you shove the following at the top of your perl CGI .... > > use CGI::Carp qw(fatalsToBrowser); > > ... It does indeed dump syntax/compile errors to the browser > (ie. prints the content type and a minimal HTML file reporting > the syntax (or whatever) error). > > use CGI::Carp qw(fatalsToBrowser); > print 1/0; > > will spit out... > > --snip-- > Content-type: text/html > >

Software error:

> Illegal division by zero at ./test.cgi line 4. > >

> Please send mail to this site's webmaster for help. > [Mon Dec 6 03:21:03 1999] test.cgi: Illegal division by zero at > ./test.cgi line 4. > --unsnip-- > ... > Anyhow, i have long wondered if, besides the exception wrapper > hacks we've seen in these threads (and i use one of my own > devising myself), is it possible to somehow hack python ... to > operate similar to the above CGI::Carp hack? Not really. The Perl gimmick relies on Perl's $SIG[__DIE__] hook (a user-settable callback function invoked prior to a fatal error). Python doesn't have that hook; by using try/except, you're essentially building such a hook by hand. I fail to see why try/except would be thought insufficient in this case. If someone is terminally lazy , they might consider importing this module (call it, say, fatalsToBrowser.py): import StringIO import sys def report(): guts = file.getvalue() if not guts: return sys.__stderr__.write(guts) # to the server log guts = "Whoopee!! An error!\n" + guts # etc sys.stdout.write(guts) # to the browser file = StringIO.StringIO() sys.stderr = file sys.exitfunc = report This arranges to redirect all stderr output to a StringIO object, and to call report() when the interpreter exits (except in case of death in response to a signal, fatal internal interpreter error, or os._exit()). report() can then look at everything (if anything) that was sent to stderr, reformat it any way it likes, and print it to stdout instead (or throw it away, or import a Perl module and let CGI::Carp handle it ). vaults-of-despair-ly y'rs - tim From rurban at xarch.tu-graz.ac.at Tue Dec 14 23:09:41 1999 From: rurban at xarch.tu-graz.ac.at (Reini Urban) Date: Tue, 14 Dec 1999 22:09:41 GMT Subject: Declaring COM-interfaces in Python? References: <38562ebd.0@pandora.research.kpn.com> Message-ID: <3856bffe.121727274@judy> Mark Hammond wrote: >Richard Smol wrote in message <38562ebd.0 at pandora.research.kpn.com>... >>Is it possible to declare COM-interfaces in Python? I need to build >>a COM-server that implements several interfaces. >> >>If that is not possible, what ways are there to implement >>interfaces in Python? > >If you want to implement new vtable based interfaces, Im afraid you have to >create a new extension module in C++. The good news is that there is a tool >that does a good job of generating C++ code from an interface's .h file (as >long as the .h was generated from the .idl) Mail me if you want to do >this... > >There is some work underway on a way to handle this on the fly, but its >still early days for that... And dispinterfaces? I would like to have user-defined callbacks for example. i.e. controlable OLE controls, where you can add events (hard) and IDispatch functionality, methods and props, (simple) at run-time. Currently I'm trying to do that in LISP (we can do that in lisp, even with fast vtables), but perl or pythonwin look also promising. The static rest of the croud (VB, java, C, C++, Delphi) would have to stand back then. -- Reini Urban http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html From bwarsaw at cnri.reston.va.us Wed Dec 1 18:18:45 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Wed, 1 Dec 1999 12:18:45 -0500 (EST) Subject: Java 1.2 and JPython References: <199912011207.HAA04934@python.org> Message-ID: <14405.22645.870071.798313@anthem.cnri.reston.va.us> >>>>> "sdossett" == writes: sdossett> Does JPython 'fully support' Java 1.2? I've scoured the sdossett> web-site and haven't found much information on this. I sdossett> read the NEWS section and it said that JPython 1.1 sdossett> supports Java 1.2 style Collections... but does it sdossett> support everything else? Suppose this might be a newbie sdossett> question - but I'm moving a system using JPython from sdossett> Java 1.1 to Java1.2 and wanted to be sure there were no sdossett> issues. I develop JPython on Solaris using 1.2 and it works fine for me. I'm not sure what issues you're concerned with. It'll certainly work with all the standard 1.2 Java packages, and there are a few other features of JPython that are only available when using Java 1.2 (since they can't be implemented onto of 1.1). -Barry From wtanksle at hawking.armored.net Fri Dec 3 01:19:22 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 3 Dec 1999 00:19:22 GMT Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: On Thu, 2 Dec 1999 01:27:34 -0800, Phil Mayes wrote: >David N. Welton wrote in message <87puwpg7kp.fsf at freddy.page.street>... >>Guido van Rossum writes: >>> Come and join us at the Key Bridge Marriott in Rosslyn (across the >>> bridge from Georgetown), January 24-27 in 2000. Make the Python >>> conference the first conference you attend in the new millennium! >>Doesn't the new millenium actually start in 2001? >Only for FORTRAN programmers. Python and C programmers, being zero-based, >get to celebrate a year earlier. Ah! So APL programmers will get to celebrate both times! Perl programmers... Will be debugging their scripts both times. There's more than one way to celebrate, after all. Smirk. >Phil Mayes pmayes AT olivebr DOT com -- make that ZeroLiveBr.com -- -William "Billy" Tanksley, in hoc signo hack From JamesL at Lugoj.Com Mon Dec 27 18:15:06 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Mon, 27 Dec 1999 09:15:06 -0800 Subject: Interface files was: Re: Python Considered Harmful References: <38673E22.C0D2155A@prescod.net> Message-ID: <38679E9A.5402795B@Lugoj.Com> Eric Lee Green wrote: > > Paul Prescod wrote: > > > Eric Lee Green wrote: > > > [Python is]... making keeping the design doc and > > > the implementation in sync a pain in the @%!#.... > > > > Pythonistsas tend to think that keeping the ".h" and ".c" files in sync > > is a pain in the @%!#. > > True enough, but it's easy to find out whether they're in sync or not -- just > type 'make' :-). > And you need to keep your makefile in sync with your .c, .h, and .cpp files if you want to do incremental compile and links. That can be a pain unless you add in supplemental tools and compiler flags to handle dependencies. > > I'll take a look at that when I'm not under deadline pressures so much. > Documentation, BTW, was not my only gripe there -- the whole > interface/implementation issue lies at the heart of object oriented > programming. > As far as I can tell, it appears that Java has the same philosophy: no distinction between interface and implementation. You need additional tools to extract the interface. From garry at sage.att.com Fri Dec 3 21:43:07 1999 From: garry at sage.att.com (Garrett G. Hodgson) Date: Fri, 3 Dec 1999 20:43:07 GMT Subject: split this newsgroup? References: <5650A1190E4FD111BC7E0000F8034D26A0F17A@huina.oceanic.com> Message-ID: <38482B5B.F6B52E49@sage.att.com> Doug Stanfield wrote: > I propose: > > c.l.py.humorous > -&- > c.l.py.that-serious-python-internals-stuff-and-ruby-viper-and-alternates-to > while-1-ladat you forgot comp.lang.python-is-an-evil-plot-to-infringe-on-my-programming-freedom if that's too long to type, you could call it comp.lang.perl -- Garry Hodgson "Hey, mister, can ya tell me, garry at sage.att.com where a man might find a bed?" Software Innovation Services He just grinned and shook my hand, AT&T Labs "No", was all he said. From jima at aspectdv.com Thu Dec 2 02:38:53 1999 From: jima at aspectdv.com (Jim Althoff) Date: Wed, 01 Dec 1999 17:38:53 -0800 Subject: Java 1.2 and JPython In-Reply-To: <14405.22645.870071.798313@anthem.cnri.reston.va.us> References: <199912011207.HAA04934@python.org> Message-ID: <4.2.0.58.19991201173736.00b81e00@mail.aspectdv.com> All of our JPython development is being done using Java 1.2.2. We have not hit any problems that are related to Java 1.2.2. Jim At 12:18 PM 12/1/99 -0500, Barry A. Warsaw wrote: > >>>>> "sdossett" == writes: > > sdossett> Does JPython 'fully support' Java 1.2? I've scoured the > sdossett> web-site and haven't found much information on this. I > sdossett> read the NEWS section and it said that JPython 1.1 > sdossett> supports Java 1.2 style Collections... but does it > sdossett> support everything else? Suppose this might be a newbie > sdossett> question - but I'm moving a system using JPython from > sdossett> Java 1.1 to Java1.2 and wanted to be sure there were no > sdossett> issues. > >I develop JPython on Solaris using 1.2 and it works fine for me. I'm >not sure what issues you're concerned with. It'll certainly work with >all the standard 1.2 Java packages, and there are a few other features >of JPython that are only available when using Java 1.2 (since they >can't be implemented onto of 1.1). > >-Barry > >-- >http://www.python.org/mailman/listinfo/python-list From redwards at golgotha.net Wed Dec 22 03:04:06 1999 From: redwards at golgotha.net (Randy Edwards) Date: Wed, 22 Dec 1999 02:04:06 +0000 Subject: Microsoft Python product? Message-ID: <38603196.4EA438BD@golgotha.net> I just got the O'Reilly book on Python and am working my way through it. I was surprised to see mention of a Microsoft product which was supposed to be written partially in Python. Since I'm such a *big* Microsoft fan :-), I have to ask, what MS product(s) was written partially in Python? TIA. -- Regards, | | Upgrade your old legacy NT . | | machines to GNU/Linux! Randy | | See http://www.debian.org From Alex.Martelli at think3.com Mon Dec 20 09:13:09 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Mon, 20 Dec 1999 09:13:09 +0100 Subject: FW: "sins" (aka, acknowledged language problems) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D5A@pces.cadlab.it> > Han-Wen writes: > def repl(match,dict=dict): return eval(match.group(1),dict) oup.write (re.sub (repl, inp.read())) > yep, if the input file fits _comfortably_ in memory I can > slurp it in at one go (although I'd still prefer to loop over > lines to insert other features, see my more recent post > about 'critique please') -- I did it with readlines and a for > loop in my latest version. > > I would still prefer to do sequential processing rather > than chewing up the memory to hold all of the input > file at once (in your version, about twice as much > memory, since output is also prepared in-storage > then emitted at once), just in case the input file should > be big (even if only moderately so, consuming lots of > virtual memory will slow things down horribly). > > And I think it a pity that syntax issues twist my arm > so noticeably towards changing semantics...:-). > > > Thanks for your response, anyway! > > Alex > From aahz at netcom.com Wed Dec 15 06:04:09 1999 From: aahz at netcom.com (Aahz Maruch) Date: 15 Dec 1999 05:04:09 GMT Subject: this is a test, please ignore References: <613dt6nnc5.fsf@anthem.cnri.reston.va.us> Message-ID: <8377g9$cb9$1@nntp8.atl.mindspring.net> In article <613dt6nnc5.fsf at anthem.cnri.reston.va.us>, Barry A. Warsaw wrote: > >sorry for the intrusion. Oh, c'mon, you know that nobody can resist a test. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 18 days and counting! From feoh at cosmic.com Thu Dec 30 18:44:10 1999 From: feoh at cosmic.com (feoh at cosmic.com) Date: Thu, 30 Dec 1999 17:44:10 GMT Subject: htmllib question - Is this the best tool for my task? References: <84ecvh$mh2$1@nnrp1.deja.com> <84efnr$rgl$1@nntp9.atl.mindspring.net> Message-ID: <84g50u$rtf$1@nnrp1.deja.com> Folks; I have a task where I need to figure out if certain HTML tags (Rather Java Server Pages tags, but they're still HTML, kinda :) contain certain things in an HTML document I'd feed to the script. I'm thinking htmllib is the right tool for this task, am I wrong? So as far as I understand things thus far, I should subclass HTMLParser, define start_java and end_java tag functions.. But where from there? How do I get a hold of the text within the tag I'm processing? None of this is clear from the htmllib doc. Thanks! -Chris P. -- ------------------------------------------------- Chris Patti feoh at cosmic.com Geek at Large "P Sent via Deja.com http://www.deja.com/ Before you buy. From choffman at dvcorp.com Wed Dec 15 19:54:04 1999 From: choffman at dvcorp.com (choffman at dvcorp.com) Date: Wed, 15 Dec 1999 18:54:04 GMT Subject: Python complaints References: <38576B73.59C7BA85@udel.edu> Message-ID: <838o42$dsu$1@nnrp1.deja.com> In article <38576B73.59C7BA85 at udel.edu>, Charles Boncelet wrote: > > I think all functions that operate on single things should be able to > operate on a list of things and return a list of things. (Are there > obvious reasons why this paradigm can't work?) Consider, Ignoring the suggestion that 'len' itself be changed, if you truly mean the language should automatically loop over lists, then there is certainly an obvious reason why this can't work. def max(arg): # return the maximum value in arg, which should be a list or tuple def sin(arg): # return the sin of arg, which must be a single number How does the compiler distinguish between sin(myList) # have to unroll myList and do multiple calls and max(myList) # must pass myList in unchanged or, worse if condition: f = max else: f = sin f(listOrNumberDependingOnTheValueOfCondition) Your suggestion would imply that no function could ever take a list as an argument. The language would have to be extended so the argument to 'sin' is declared as scalar, or that to 'max' must be a list. And then what if you want to write a function that can accept either? On the other hand, if you are simply suggesting that all the functions in the standard modules that accept scalar arguments should have their bodies rewritten so they also accept lists, and do an implicit loop over the list, your idea is reasonable. It would be a lot of work, and might break existing programs expecting to trap errors on previously bad arguments, and the fight over which functions make sense to change (sin: seems OK, len: definitely not) could drag on for years! Chris Sent via Deja.com http://www.deja.com/ Before you buy. From ullrich at math.okstate.edu Sun Dec 12 20:52:10 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sun, 12 Dec 1999 13:52:10 -0600 Subject: Dot product? References: Message-ID: <3853FCEA.57BC7595@math.okstate.edu> Excellent - thanks. Never noticed map took more than two parameters. Mike Fletcher wrote: > Maybe not what you were asking, but some food for thought :) . Of course, > we're told that all this mapping and reducing will get replaced by list > comprehensions, so maybe I shouldn't post this... I haven't been paying close enough attention to know what you mean by that - it's going to be replaced in the next version, or it's going to be replaced by the interpreter on compile? So I dunno what's so rebellious about your post. I do want a Transpose fairly regularly, and it seems to me that getting my Transose from one call to one built-in function must be at least as efficient as the code I'm not willing to show you that did it by hand.(???) > oh well, I'll be a rebel > ;) . > > >>> import operator > >>> a = (2,3,4) > >>> b = (3,4,5) > >>> def Transpose( a, b ): > ... return map( None, a, b ) > ... > >>> Transpose( a, b ) > [(2, 3), (3, 4), (4, 5)] > >>> def Dot( a, b ): > ... return reduce( operator.add, map( operator.mul, a, b)) > ... > >>> Dot( a, b ) > 38 > >>> def Transpose( *args ): > ... '''General version, takes any number of sequences (kind of silly > anyway :) )''' > ... return apply( map, (None,)+args ) Don't seem so silly to me - for the second between the time when I saw the Transpose(a,b) and the time I saw this I was planning on figuring out how to make it work for any number of sequences. (Pretty sure I could got that one, having seen how to do it for two...) > ... > >>> Transpose( a, b ) > [(2, 3), (3, 4), (4, 5)] > >>> Transpose( a, b, () ) > [(2, 3, None), (3, 4, None), (4, 5, None)] > >>> > > Enjoy, I'm having fun with it already. > > Mike DU From skip at mojam.com Tue Dec 28 05:28:28 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 27 Dec 1999 22:28:28 -0600 (CST) Subject: configuring 1.5.2c1 on Mac for Tkinter ? In-Reply-To: <3867F0AD.361B33D1@ctrvax.vanderbilt.edu> References: <3867F0AD.361B33D1@ctrvax.vanderbilt.edu> Message-ID: <14440.15468.932822.113667@dolphin.mojam.com> Allen> I'm new to Python. I've just installed the Macintosh Allen> self-installing python distribution version 1.5.2c1. Apparenlty, Allen> it is not pre-configured for Tkinter. If I import Tkinter, I get Allen> an error, "No Module Named Tkinter". Looks to me like sys.path is missing the lib-tk directory. It was on my Mac. Try the equivalent of >>> import sys >>> sys.path.append("Macintosh HD:Applications:Python 1.5.2c1:Lib:lib-tk") changing the "Macintosh HD:Applications:" part to correspond to your installation. 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 fstajano at uk.research.att.com Tue Dec 7 21:04:08 1999 From: fstajano at uk.research.att.com (Frank Stajano) Date: Tue, 07 Dec 99 20:04:08 GMT Subject: IPC8 tutorials material Message-ID: I finally registered for IPC8 and found somewhere on the forms a reference to the fact that attendees to the tutorials will receive the printed materials for "all the tutorials", where it wasn't clear whether this meant "all of the 2 out of 8 tutorials attended", or "all of the 8 tutorials including the ones you missed because they were all running in parallel and damn damn damn wouldn't it have been nicer to be able to go to more than two so at least here's some consolation". Speaking as someone who at IPC7 bought the tutorial material for ALL the tutorials from the remainders pile, and found it quite interesting, I would encourage the organisers to either, and preferably, assign the second meaning above to the ambiguous