From wware at world.std.com Sun Dec 26 02: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 16: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 14: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 Tue Dec 21 19: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 11: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 10: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 Sun Dec 12 23: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 12: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 16: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 15: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 17: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 16: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 11: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 07: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 13: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 17: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 14: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 14: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 07: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 00: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 02: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 Mon Dec 27 18: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 13: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 12: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 08: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 16: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 06: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 06: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 07: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 09: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 Thu Dec 30 23: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 15: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 09: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 17: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 14: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 06: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 06: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 16: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 11: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 14: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 Thu Dec 9 19: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 00: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 05: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 01: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 Sun Dec 12 19: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 16: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 13: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 05: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 14: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 11: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 Thu Dec 30 19: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 Thu Dec 9 22: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 09: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 15: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 16: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 10: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 11: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 06: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 14: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 02: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 07: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 02: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 14: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 06: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 05: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 12: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 02: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 04: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 13: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 17: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 16: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 09: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 03: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 15: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 14: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 guido at CNRI.Reston.VA.US Wed Dec 22 15: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 17: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 Tue Dec 21 19: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 11: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 17: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 15: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 m.faassen at vet.uu.nl Thu Dec 2 13: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 05: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 Tue Dec 7 19: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 16: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 11: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 00: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 17: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 08: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 16: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 13: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 12: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 16: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 09: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 16: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 03: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 04: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 04: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 06: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 15: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 Mon Dec 27 23: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 12: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 11: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 Wed Dec 15 22: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 Tue Dec 21 19: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 11: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 14: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 02: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 Thu Dec 30 19: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 05: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 12: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 03: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 Mon Dec 13 22: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 13: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 12: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 09: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 11: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 05: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 09: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 04: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 08: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 09: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 12: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 04: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 12: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 08: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 Sat Dec 25 19: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 Thu Dec 2 22: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 14: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 11: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 15: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 05: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 mgushee at havenrock.com Thu Dec 30 14: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 08: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 16: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 10: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 05: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 Thu Dec 2 22: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 kc5tja at garnet.armored.net Tue Dec 14 00: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 16: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 Sat Dec 4 20: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 Fri Dec 3 22: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 08: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 05: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 12: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 Wed Dec 8 18: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. Fri Dec 3 20: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 05: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 17: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 Wed Dec 1 18: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 16: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 16: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 Mon Dec 13 18: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 Sat Dec 4 20: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 09: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 Thu Dec 2 23: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 00: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 11: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 12: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 16: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 13: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 11: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 01: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 01: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 17: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 Sun Dec 12 21: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 16: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 04: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 12: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 07: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 09: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 Wed Dec 15 18: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 12: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 12: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 04: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 10: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 05: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 Thu Dec 9 21: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 00: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 15: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 03: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 11: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 55555 at dakotacom.net Thu Dec 9 15:18:11 1999 From: 55555 at dakotacom.net (55555) Date: 9 Dec 1999 14:18:11 -0600 Subject: browser interface? References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> Message-ID: <38500e83_3@news5.newsfeeds.com> On Wed, 8 Dec 1999 00:27:31 -0800, Patrick Phalen wrote: > [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? > I am basically trying to cheat learning how to program a GUI. I've played around with Tkinter before, but I wasn't moving along quickly enough. So I'm thinking I could print html to a browser on my machine using cgi instead of using the python console or Tkinter (this would not at all involve the internet). I figure that any links that I print could just lead back to the script that was used to create the page in the first page and use arguements from the hyperlink to call a new function. The negative part of this is that I don't want to reparse a bunch of text files every time I need user input. Does this make sense? I'm trying to create a mail client if that helps. Thanks again. -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==---------- http://www.newsfeeds.com The Largest Usenet Servers in the World! ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==----- From boud at rempt.xs4all.nl Fri Dec 31 09: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 12: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 14: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 Thu Dec 30 18: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 16: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 Thu Dec 2 23: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 12: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 Thu Dec 30 21: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 09: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 11: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 14: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 08: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 11: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 16: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 13: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 09: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 Wed Dec 1 18: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 13: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 12: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 13: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 00: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 Mon Dec 6 23: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 15: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 07: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 09: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 Tue Dec 14 23: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 12: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 13: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 Wed Dec 29 22: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 04: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 01: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 Thu Dec 30 23: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 08: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 03: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 04: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 05: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 Tue Dec 14 20: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 Thu Dec 16 21: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 12: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 Mon Dec 27 18: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 00: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 04: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 13: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 01: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 13: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 Thu Dec 16 18: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 Sun Dec 26 19: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 15: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 02: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 06: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 Wed Dec 29 19: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 16: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 Sat Dec 4 19: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 Thu Dec 2 20: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 Sun Dec 19 23: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: 2883 URL: From aa8vb at yahoo.com Tue Dec 21 07: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 09: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 02: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 12: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 14: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 10: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 13: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 10: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 09: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 03: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 12: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 09: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 10: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 14: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 14: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 13: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 12: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 10: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 00: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 00: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 06: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 Fri Dec 3 18: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 14: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 Wed Dec 1 19: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 11: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 10: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 15: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 12: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 04: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 03: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 12: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 Thu Dec 23 20: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 11: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 11: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 14: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 14: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 14: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 16: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 05: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 skip at mojam.com Tue Dec 21 11: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 10: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 10: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 08: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 09: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 11: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 10: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 17: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 Mon Dec 20 22: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 Wed Dec 1 18: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 11: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 14: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 01: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 04: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 12: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 15: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 10: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 11: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 03: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 16: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 11: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 Sun Dec 12 22: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 Sat Dec 25 18: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 Sun Dec 26 18: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 Sun Dec 5 18: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 09: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 01: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 12: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 00: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 13: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 04: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 11: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 15: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 00: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 06: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 05: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 09: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 11: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 17: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 03: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 09: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 17: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 12: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 11: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 07: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 07: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 05: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 08: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 Thu Dec 2 20: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 13: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 14: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 07: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 16: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 Thu Dec 9 23: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 Fri Dec 3 21: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 04: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 12: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 Fri Dec 10 21: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 11: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 15: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 13: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 Thu Dec 2 23: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 11: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 04: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 05: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 Thu Dec 9 18: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 08: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 14: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 Thu Dec 9 19: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 01: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 02: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 Tue Dec 7 19: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 13: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 11: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 06: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 Mon Dec 13 19: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 09: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 11: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 15: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 09: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 04: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 17: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 03: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 06: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 06: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 09: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 02: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 11: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 07: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 Wed Dec 22 18: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 09: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 16: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 12: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 12: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 Tue Dec 28 20: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 15: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 07: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 16: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 13: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 05: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 03: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 Tue Dec 21 23: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 Thu Dec 2 18: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 14: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 Wed Dec 8 19: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 05: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 09: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 14: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 08: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 13: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 12: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 17: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 06: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 10: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 Sun Dec 26 22: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 10: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 17: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 11: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 17: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 Sun Dec 19 21: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 05: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 15: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 Tue Dec 21 23: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 17: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 10: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 05: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 06: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 04: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 08: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 Thu Dec 30 18: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 03: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 09: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 08: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 11: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 07: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 08: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 05: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 12: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 11: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 Mon Dec 27 19: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 12: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 17: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 11: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 14: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 Fri Dec 10 21: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 01: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 08: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 10: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 16: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 12: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 tbradshaw at orchestream.com Thu Dec 9 14: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 16: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 00: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 Wed Dec 22 23: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 04: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 14: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 11: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 16: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 17: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 12: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 Wed Dec 29 20: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 06: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 13: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 08: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 08: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 06: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 07: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 13: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 11: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 06: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 14: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 11: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 15: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 Sun Dec 12 20: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 06: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 17: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 12: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 07: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 03: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 06: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 05: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 13: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 06: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 08: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 15: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 05: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 09: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 12: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 Mon Dec 20 23: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 17: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 Tue Dec 28 20: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 15: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 16: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 11: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 02: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 17: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 13: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 17: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 15: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 04: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 07: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 09: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 11: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 05: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 07: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 06: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 15: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 11: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 11: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 Wed Dec 22 18: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 08: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 10: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 Fri Dec 3 22: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 08: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 13: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 08: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 03: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 Sun Dec 12 19: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 04: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 12: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 04: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 Sun Dec 19 20: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 07: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 02: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 11: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 Mon Dec 13 19: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 00: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 Mon Dec 27 23: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 Thu Dec 9 18: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 09: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 13: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 08: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 Fri Dec 3 18: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 05: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 14: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 05: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 Mon Dec 13 19: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 11: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 16: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 07: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 Mon Dec 6 19: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 16: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 bruce_dodson.nospam at bigfoot.com Sun Dec 12 15: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 Mon Dec 27 18: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 08: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 02: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 Mon Dec 13 19: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 01: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 02: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 05: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 06: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 12: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 11: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 09: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 12: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 00: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 03: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 14: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 Tue Dec 28 22: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 09: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 08: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 14: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 14: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 04: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 15: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 Wed Dec 1 19: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 00: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 Mon Dec 27 22: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 09: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 16: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 16: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 12: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 12: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 17: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 17: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 13: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 12: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 00: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 16: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 17: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 02: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 10: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 14: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 Sun Dec 5 18: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 17: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 01: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 14: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 15: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 15: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 17: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 09: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 07: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 10: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 Tue Dec 14 22: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 02: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 14: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 11: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 17: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 04: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 Tue Dec 14 18: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 07: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 Sat Dec 18 19: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 14: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 04: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 Fri Dec 3 22: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 03: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 Mon Dec 6 19: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 09: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 04: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 Mon Dec 6 18: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 11: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 14: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 Fri Dec 10 22: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 11: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 15: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 08: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 Wed Dec 22 19: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 08: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 Mon Dec 27 21: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 09: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 17: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 12: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 14: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 15: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 17: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 08: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 13: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 08: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 17: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 08: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 12: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 05: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 09: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 Mon Dec 27 18: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 04: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 13: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 09: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 Wed Dec 29 23: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 Thu Dec 9 20: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 patdut01 at club-internet.fr Sat Dec 4 11: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 02: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 17: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 01: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 Fri Dec 17 19: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 00: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 10: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 16: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 11: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 Wed Dec 15 18: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 03: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 13: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 13: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 02: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 17: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 09: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 15: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 info at pythonware.com Wed Dec 1 15: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 17: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 05: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 08: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 16: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 10: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 Wed Dec 15 19: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 09: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 Mon Dec 27 20: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 01: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 05: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 12: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 Sat Dec 11 23: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 07: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 Sat Dec 11 23: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 14: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 Thu Dec 16 21: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 07: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 15: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 Sun Dec 5 23: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 09: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 16: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 12: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 07: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 Sat Dec 25 20: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: 2867 URL: From mstenber at cc.Helsinki.FI Mon Dec 13 01: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 12: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 07: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 10: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 17: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 Thu Dec 30 19: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 Tue Dec 28 20: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 07: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 16: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 13: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 07: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 08: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 15: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 Sun Dec 12 20: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 09: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 10: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 09: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 08: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 Thu Dec 2 22: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 07: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 04: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 Thu Dec 9 23: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 04: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 12: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 05: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 Sat Dec 25 20: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 09: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 11: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 Sat Dec 4 22: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 13: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 17: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 17: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 14: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 14: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 12: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 11: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 10: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 11: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 15: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 15: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 Sun Dec 12 19: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 Wed Dec 8 23: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 15: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 09: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 06: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 Thu Dec 16 18: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 02: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 09: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 11: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 07: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 mfletch at tpresence.com Tue Dec 14 10: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 09: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 Tue Dec 21 23: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 13: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 04: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 11: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 14: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 17: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 11: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 12: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 11: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 16: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 02: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 17: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 12: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 Thu Dec 2 19: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 12: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 15: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 Wed Dec 1 20: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 Tue Dec 21 21: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 03: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 00: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 12: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 13: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 14: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 Mon Dec 27 23: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 15: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 wording on the web site, or at least be generous with the print runs so that a similar "remainders sale" can be run this year too. Frank (http://i.am/filologo.disneyano/) http://www.uk.research.att.com/~fms/ From echeverria at interactiva.cl Sat Dec 4 22:26:25 1999 From: echeverria at interactiva.cl (Cristian Echeverria) Date: Sat, 4 Dec 1999 23:26:25 -0400 Subject: Mutli-Column Listboxes in Tkinter? References: Message-ID: <3849cda1@omega> I have something like a Windows List Control implemented using many Listboxes. This is part of a gui package that has something like configurable look and feel. If you want I can send you all the package in a zip file and you can take what you need. Cristian Echeverria Scott Barron escribi? en el mensaje de noticias EZZ14.1069$e03.102190 at typ12.deja.bcandid.com... > 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 philh at vision25.demon.co.uk Sun Dec 12 20:26:02 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Mon, 13 Dec 99 01:26:02 GMT Subject: XML parsing Message-ID: <945048362snz@vision25.demon.co.uk> I am parsing some XML input using the xmllib module. I am getting an error because my input file starts with Hi All, I'm preparing a python extension module which is partially implemented as in "C" (cmymodule.c), and partially in python (mymodule.py). I'd like to have functions defined in both files in the same namespace. Let's assume, that the functions are defined as follows: cmymodule.c: open, read, write, close mymodule.py: info, encrypt If I import both extensions into the user program, the functions should be called as cmy.open(), cmy.read(),... but my.info(), my.encrypt(). If I include the "import cmy" into mymodule.py, then syntax will be even worse: my.cmy.open() and so on. Due to performace reasons I don't want to add the python "wrappers" in mymodule.py for C functions. How can I locate both C and python functions in the same namespace? Please Cc the answer to my e-mail (given below). -- TIA Wojciech Zabolotny wzab at ise.pw.edu.pl http://www.ise.pw.edu.pl/~wzab http://www.freedos.org Free DOS for free people! From robert.meegan at murl.com Thu Dec 30 10:46:10 1999 From: robert.meegan at murl.com (Robert Meegan) Date: Thu, 30 Dec 1999 15:46:10 GMT Subject: How to dates in Python? In-Reply-To: <386ad5ed.1918579@news.mindspring.com> References: <386ad5ed.1918579@news.mindspring.com> Message-ID: <19991230.15461000@robert.polytopic.com> Costas - There is a very complete time module included in the standard library, called Time. There is also an additional module by Marc-Andre Lembur called mxDateTime that can be hunted down from the Python website. Since you are apparently new to the Python world, let me offer the additional suggestion that you look at the Python Library Reference Manual before asking a question online. The Python community is friendly and helpful, but you loose points for asking questions that are clearly explained in the documentation. - Robert >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<< On 12/29/99, 9:49:18 PM, costas_menico at mindspring.com (Costas Menico) wrote regarding How to dates in Python?: > Is there a datetime manipulation/math module for Python? > Costas > -- > http://www.python.org/mailman/listinfo/python-list From aflinsch at att.com Fri Dec 10 08:58:53 1999 From: aflinsch at att.com (Alex Flinsch) Date: Fri, 10 Dec 1999 08:58:53 -0500 Subject: Linux.Com References: <384DC8F1.9A1F135F@easystreet.com> <14413.59272.858902.938397@anthem.cnri.reston.va.us> Message-ID: <3851071C.DF33A5DD@att.com> Jim Richardson wrote: > > > > >Hmm... anybody think we need more `P' languages? > > > >-Barry > > > (not scripting but whattheheck) > Prolog? > PL/1 (One of my favorites...) > > pan > umm... I am running out, any others? > pascal, pilot, pl/sql From clopez at abo.fi Wed Dec 15 08:30:32 1999 From: clopez at abo.fi (Cesar Lopez) Date: Wed, 15 Dec 1999 15:30:32 +0200 Subject: problems with SWIG and C++ Message-ID: <385797F8.D6A8AD65@abo.fi> I?m a beginner with python and SWIG, I want to include some C++ classes and methods definitions into python interpreter so that I define the file derive.i in this way: %module derived %import device.h class Led : public Device { public: // constructor Led(int id); // Led Identifier // destructor ~Led(); // members function int Setup(int state); // state = 1 --> ON ; state = 0 --> OFF }; Here is my device.h file: //device.h // This module implements the main class device that will used by the others devices definit ions // class Device{ // Base class of Devices system public: // variables int Id; // Device Identifier char *Comments; // Special things about the device // constructors Device(int id); // All devices needs an Id number // virtual destructor! virtual ~Device(); virtual int Setup(); // return 0 if all goes well or error number in other case }; Then when I run SWIG there is no problem: bash-2.02$ swig -python -c++ derived.i Generating wrappers for Python The problem is when I try to compile it: bash-2.02$ sh-hms-g++ -c led.c++ derived_wrap.c -I/usr/include/python1.5 derived_wrap.c: In function `void * SwigLedToDevice(void *)': derived_wrap.c:556: `Led' undeclared (first use this function) derived_wrap.c:556: (Each undeclared identifier is reported only once derived_wrap.c:556: for each function it appears in.) I?ve try to put in my derived.i file this lines: %include device.cpp and %include led.cpp even I try to combine them with %import device.cpp and %import led.cpp but doesn?t work. So I think that I need to expecify something more in my derived.i but I don?t know How. If you know how to solve this problem, please e-mail me. Perhaps I must to use old C and no c++ classes.!! From htrd90 at zepler.org Wed Dec 1 15:33:36 1999 From: htrd90 at zepler.org (Toby Dickenson) Date: Wed, 01 Dec 1999 20:33:36 +0000 Subject: Exposing COM via XML-RPC or Something Else References: <38435919.D88B4EC0@home.com> Message-ID: Edward Muller wrote: >I'm playing around with a way to expose Windows COM object via >XML-RPC (or something else). ... >OR should I shot for the stars and try to write >an abtraction layer allowing us to expose MS COM objects with something >like Corba, ILU or PYRO? This (if it worked) would allow us all to use >COM objects from other platforms that support whatever library I've used >to abstract/expose the COM object(s). This all assumes someone is >running a COM server on the machine the client would connect to... I've written a general purpose gateway going the other direction (ie exposing xmlrpc objects in an IDispatch disguise) by mixing pythoncom and xmlrpclib.py. Assuming you don't mind the mismatch in capabilities (xmlrpc can return 'structures', IDispatch has named parameters) its a straightforward exercise. hth, Toby Dickenson htrd90 at zepler.org From fdrake at acm.org Mon Dec 6 10:04:34 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Mon, 6 Dec 1999 10:04:34 -0500 (EST) Subject: indentation In-Reply-To: <829dlk$12p$1@news.wrc.xerox.com> References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> <829dlk$12p$1@news.wrc.xerox.com> Message-ID: <14411.53378.154350.793014@weyr.cnri.reston.va.us> Mark Jackson writes: > And Fortran. Don't forget Fortran. I guess I got lucky; having never learned Fortran, I don't have to forget it. ;-) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From mlh at vier.idi.ntnu.no Mon Dec 20 19:01:13 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 21 Dec 1999 01:01:13 +0100 Subject: List comprehensions References: <38592275.BBA2B61A@maxtal.com.au> <385E045D.9EC36473@compaq.com> Message-ID: Dan Schmidt writes: > mlh at vier.idi.ntnu.no (Magnus L. Hetland) writes: [...] > 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] It's not that bad :) However - it has a temporality to it that I don't think fits the sentence... I think "for all xs in X and ys in Y, do something" is quite standard english, yet "for all xs in X while ys in Y, do something" sounds a bit silly... -- Magnus Lie Hetland From bernhard at alpha1.csd.uwm.edu Sun Dec 12 14:38:23 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 12 Dec 1999 19:38:23 GMT Subject: win32com: subclass a com object? References: <830pi6$n4k$1@nnrp1.deja.com> Message-ID: On Sun, 12 Dec 1999 18:29:31 GMT, tiddlerdeja at my-deja.com wrote: >I'm fairly new to python and am currently using it to script COM >objects. Welcome to the pythodome! >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). Hmm. I haven't done this, but you certainly can derive from the class, which wraps the COM object and intercept the method. Mark can tell you more about it. The most easiest solution would be to write your own class, initialise instances with the original COM instance and just imitate all methods and call the original object except of course for the method you want to change. >Also, an aside question about win32com. Would someone use win32com just >to avoid paying for a VB license to develop COM object? No. >Or are there >actual benefit to scripting COM in python? Yes there are actual benefits. >Is COM simpler in python? Yes. I will only give you the two most obvious ones: - Python is Free Software and brings you more freedom as VB, which is proprietory. This includes a bunch of advantages. - You only have to learn one more powerful language, because python is cross platform and simple. 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 greybria at direct.ca Mon Dec 27 12:50:04 1999 From: greybria at direct.ca (Colleen & Brian Smith) Date: Mon, 27 Dec 1999 09:50:04 -0800 Subject: Remove/Replace Tkinter Widget from Frame Message-ID: Hi gang, I'm back! The buttons are now working after the image is loaded. Thanks for the various suggestions. I'm not sure which one actually fixed it as many had no trouble with the code before. This is what it looks like now: from Tkinter import * import Image, ImageTk from viewer import UI from tkFileDialog import * class Application(Frame): def LoadPic(self): self.picname=askopenfilename(filetypes=[("JPEG", "*.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): delete(self.display) 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() What I want to do is on the UNLOAD button, remove the image and allow a new one to be loaded, without creating two images. I've tried various combinations of self.pic.destroy() etc. What is the "proper" way to remove the image and allow a new one to be loaded? Thanks. -- Brian Smith greybria at direct.ca http://mypage.direct.ca/g/greybria From da at ski.org Thu Dec 16 15:40:57 1999 From: da at ski.org (David Ascher) Date: Thu, 16 Dec 1999 12:40:57 -0800 Subject: cursors for Tk References: <38534DC5.82CEB43A@trojanslair.zzn.com> <3857BFC4.F501503F@caere.com> Message-ID: <04ea01bf4805$e0917a50$c355cfc0@ski.org> > > can someone tell me a list of all the cursor types available for a > > windows 95 machine? > > you can find the list of cursor types in the tk source in the win\rc\tk.rc > file. > the available names are FWIW, I just got an announcement a few days ago that my patch to allow the use of custom cursor files in Tk on Windows is part of the Tk 8.3 beta source tree. (I submitted the patch about a year ago =(). --david ascher From kwesterback at home.com Tue Dec 28 09:36:10 1999 From: kwesterback at home.com (Kenneth R Westerback) Date: Tue, 28 Dec 1999 14:36:10 GMT Subject: Problem Compiling Python on OpenBSD. References: <271219990853502764%petro@bounty.org> Message-ID: <3868CADA.846D83AC@home.com> There is a python port in the /usr/ports/lang directory. On 2.5 this will be 1.5 I believe. In the current ports tree there is now a 1.5.2 port that works fine for me, i.e. compiles and functions. This port MAY work on 2.5 but you would need to update the mk infrastructure file for the make I believe. Easiest would be to install 2.6 and then update your ports tree and then install the port. Alternatively you might just update your ports tree, look at the patches (/usr/ports/lang/python/patches/*) to see what had to be patched to get 1.5.2 working. .... Ken "Crass A. Hole" wrote: > > I am trying to compile and install Python 1.5.2 from source on an > OpenBSD 2.5 (uname -a= "OpenBSD loki.mysoapbox.org 2.5 GENERIC#243 > i386") machine. > > I have installed GCC 2.95.1 and am using that as the compiler. > > Most of the peices parts compile just fine, but longs of things break > if I try to compile the modules as shared (which is ok, I just compile > them statically), and the big problem is that the socketmodule fails on > "make test". It gives me a: > > 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... > > Do I also need to install the newest glibc in order for things to work > properly, or is glibc just a Linux thing (most of my "Unix" experience > is on Linux, with some Solaris. I've just got this one BSD box for > variety and security). > > Is the problem with OpenBSD, or GCC? I know it isn't Python, since in > builds fine on Solaris and Linux. From aaron_watters at my-deja.com Thu Dec 16 14:53:15 1999 From: aaron_watters at my-deja.com (aaron_watters at my-deja.com) Date: Thu, 16 Dec 1999 19:53:15 GMT Subject: Merging dictionaries References: <8391di$l4a$1@nnrp1.deja.com> Message-ID: <83bfv9$e83$1@nnrp1.deja.com> In article <8391di$l4a$1 at nnrp1.deja.com>, Preston Landers wrote: > Hello all, > > I've got a program that works with large data structures in the form of > nested dictionaries. > > The task at hand is to 'merge' two dictionaries with a special > merge_function() called for items that exist in both dictionaries. You really should consider using kjbuckets.kjDict's (an alternate Python dictionary implementation) for this. If you only want to call the merge_function where keys match but values don't match then: def combine(d1, d2): "d1 and d2 should be kjDicts" from kjbuckets import kjSet test = d1+d2 if test.Clean(): return test # no conflicts test.Wash() commonkeyset = kjSet(d1)&kjSet(d2) result = test - commonkeyset*test for ck in commonkeyset.items(): result[ck] = merge_function(d1[ck], d2[ck]) return result alternatively if you always want to call the merge function on common keys, even if the values match: def combine(d1, d2): "d1 and d2 should be kjDicts" from kjbuckets import kjSet test = d1+d2 test.Wash() commonkeyset = kjSet(d1)&kjSet(d2) if not commonkeyset: return test # no conflicts result = test - commonkeyset*test for ck in commonkeyset.items(): result[ck] = merge_function(d1[ck], d2[ck]) return result If you use the C extension module version this should be much faster than the alternative implementation in the average case (ie, unless the dictionaries have lots of common keys). Find out more about kjbuckets at http://www.chordate.com -- Aaron Watters === "So, what do you do?" "I'm a puppeteer." "Check, please!" -- from "Being John Malkovich" Sent via Deja.com http://www.deja.com/ Before you buy. From tim_one at email.msn.com Sat Dec 4 17:12:21 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 4 Dec 1999 17:12:21 -0500 Subject: including column information when an exception occurs In-Reply-To: <384957FA.164010A6@mikemccandless.com> Message-ID: <000301bf3ea4$a28be8e0$df2d153f@tim> [Michael McCandless] > When a Python exception occurs, the interpreter shows you the stack > traceback to the line where the error occurred. Why, when it gets down > to the actual line, does it not also report, eg, the column or > subexpression in which the error occurs? It does, but only if the exception is a Syntaxrror. Column information is available while the program is being parsed (the only time you can get a SyntaxError), but is not available at runtime (which is when almost all other exceptions get raised). The interpreter incurs a good deal of pain to keep the line number available at runtime, but even that's limited (e.g., if an exception occurs in an expression spanning multiple lines, you only get the number of the line that begins the stmt that contains the expression). The easiest way to get more context is probably to disassemble the byte code near the point of failure. For example, putting the attached in module tbrev.py and running your test case like so: def test0(tup, i0, i1): test1(tup, i0, i1) def test1(tup, i0, i1): return tup[i0] + tup[i1] try: test0((1, 2, 3), 2, 4) except: from misc import tbrev # import from where you store it tbrev.show_context() prints this new line before the usual traceback: Probably near a reference to local variable i1, That wouldn't do you a lot of good if the failing code looked like tup1[i] + tup2[i] instead! Disassembling more context gets messier. This is a job for Michael Hudson <0.9 wink>. if-python-were-written-in-python-it-would-be-easier-ly y'rs - tim import dis LOAD_GLOBAL = dis.opname.index('LOAD_GLOBAL') LOAD_FAST = dis.opname.index('LOAD_FAST') LOAD_ATTR = dis.opname.index('LOAD_ATTR') LOADOPS = (LOAD_GLOBAL, LOAD_FAST, LOAD_ATTR) HAVE_ARGUMENT = dis.HAVE_ARGUMENT del dis def show_context(): import sys tb = sys.exc_info()[2] if tb is None: return while tb.tb_next: tb = tb.tb_next lasti = tb.tb_lasti code = tb.tb_frame.f_code bytecode = code.co_code i = 0 limit = min(lasti, len(bytecode)) loads = [] while i < limit: c = bytecode[i] op = ord(c) i = i+1 if op >= HAVE_ARGUMENT: oparg = ord(bytecode[i]) + ord(bytecode[i+1])*256 i = i+2 if op in LOADOPS: loads.append((op, oparg)) if loads: op, arg = loads[-1] if op == LOAD_GLOBAL: msg = "global variable " + code.co_names[arg] elif op == LOAD_FAST: msg = "local variable " + code.co_varnames[arg] elif op == LOAD_ATTR: msg = "attribute " + code.co_names[arg] else: msg = "" print "Probably near a reference to", msg + "," raise From cgw at fnal.gov Thu Dec 16 14:38:58 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Thu, 16 Dec 1999 13:38:58 -0600 (CST) Subject: LISTS: Extract every other element In-Reply-To: <14425.13561.91576.602473@dolphin.mojam.com> References: <19991216131341.A153923@vislab.epa.gov> <14425.13561.91576.602473@dolphin.mojam.com> Message-ID: <14425.16338.583342.648548@buffalo.fnal.gov> Skip Montanaro writes: > > Randall> I want to take a large list: > Randall> [ 1,2,3,4,5,6,7,... ] > > Randall> and build a list with every other element: > Randall> [ 1,3,5,7,... ] > > Randall> Is there a faster way than looping over indices?: > > I'm pretty sure you can do this with NumPy. I'm not a NumPy user though, so > I'll have to defer to the rocket scientists... ;-) > (Disclaimer: I may work at a government lab, but I'm not a rocket scientist) You could do this: >>> from Numeric import * >>> a = array(mylist, 'O') >>> b = take(a,range(0,len(a),2) For the case where "mylist" is a list of numbers, this works fine: >>> mylist = [3,1,4,1,5,9,2,6,5,3,6] >>> a = array(mylist, 'O') >>> b = take(a,range(0,len(a),2) >>> b array([3 , 4 , 5 , 2 , 5 , 6 ],'O') It *should* work for general lists, using Numeric arrays of type 'O' (Python Object). However, in the course of writing and testing this I found a bug in Numeric, where it mis-handles initialization of arrays of type 'O' (Python Object). >>> from Numeric import array >>> l = ['abc','def','ghi'] >>> array(l,'O') array([[abc , abc , abc ], [def , def , def ], [ghi , ghi , ghi ]],'O') Oops! That should have been array([abc, def, ghi], 'O') So, in fact, you *could* use Numeric to do this, if it weren't broken. Sigh. I'm taking this thread over to the Matrix-SIG. From ullrich at math.okstate.edu Mon Dec 20 13:26:00 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 20 Dec 1999 12:26:00 -0600 Subject: __rcall__??? References: <002101bf4a98$01eda860$922d153f@tim> Message-ID: <385E74B8.CC2CFFC8@math.okstate.edu> Tres Seaver wrote: > In article <002101bf4a98$01eda860$922d153f at tim>, > Tim Peters wrote: > >[David C. Ullrich] > >> So why isn't there a magic __rcall__, that would go with > >> __call__ like the other __rop__'s go with __op__? > >> > >> It seems useful to me to allow x to alter the way f behaves > >> when you call f(x); ... > > > >Probably for the same reason there's no __rgetitem__ for the benefit of the > >millions of programmers who want > > > > x[i] > > > >to use x as an index into sequence i . That is, AFAIK nobody ever > >asked for it before, and it's not screamingly natural (you're not really > >*surprised* at the lack of __rcall__, right?). > > Smells like Visitor/multimethods/DoubleDispatch to me, and it _is_ a vacuum > which people code around, in most languages except Lisp and its progenty; > David is apparently the first to propose this particular solution > (quite Pythonic, it seems to me, I got an email saying something about "Visitor methods". I won't ask what that is, I'll look it up somewhere. (I didn't think that I was the first person in the universe to wonder about this, but I don't know any of that programming stuff. In my implementation the concept is "ettiquette": Data and Function both descend from Nice. Nice objects are very careful about stepping on other objects' toes - everyone else has a veto power.) > only adding slots to the jump > table is not likely to win wide support). Wasn't actually saying that it should be added to the langauge, mainly wanted to make certain that it wasn't already there. > >better-hope-for-santa-to-do-it-cuz-i-doubt-guido-will-ly y'rs - tim > > Looking-hopefully-for-sinterklaas'ly, > > Tres. > -- > --------------------------------------------------------------- > Tres Seaver tseaver at palladion.com 713-523-6582 > Palladion Software http://www.palladion.com Wondering-whether-you-guys-find-your-'-'-keys-wear-out-first, um, I mean Wondering-whether-you-guys-find-your-'-'-keys-wear-out-first'ly, DU From cfelling at iae.nl Fri Dec 10 20:08:38 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 11 Dec 1999 02:08:38 +0100 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> <38510920.172174013@news.oh.verio.com> <82ro5c$9n1$2@ssauraab-i-1.production.compuserve.com> Message-ID: <82s86m$1oi$1@vvs.superst.iae.nl> Hi Olaf, reading the other postings in this tread and learning more of what you seek to achieve, I got second thoughts: maybe my proposal might not be that ugly after all. Let us expand on it: >>> class Currency: >>> def __init__(self, value=None, **others): >>> self.__dict__.update(others) >>> self.read, self.written = 0, 0 >>> if value != None: >>> self(value) >>> >>> def __call__(self, value=None): >>> if value == None: >>> self.read = self.read + 1 >>> return self.value >>> else: >>> self.value = value >>> self.written = self.written + 1 >>> >>> c = C(3, state_var='Pipo de Clown') >>> c(5) >>> print c(), c.read, c.written 5 1 2 This class seems to offer what you need: it keeps track of read and write access to the value attribute, its notation is concise and familiar. Read and write access look like applying a SUB, the write one with side effects, probably not that unfamiliar to BASIC programmers:) To me the use of functions to get to the value is quite acceptable considering that c has some state info that you normally discard. OTOH assignment to c that leaves the extra state info unchanged is much harder to appreciate for me (been brainwashed to long:) -- groetjes, carel From kc5tja at garnet.armored.net Tue Dec 14 14:20:48 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 14 Dec 1999 19:20:48 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: In article , Mark Hammond wrote: >>CoTreatAsClass(). 'Nuff said. ;) > >he - well, that isnt exposed by Python tho! I better add it :-) Well, if it's needed. :) Unless you have the ability to create vtable-type COM objects in Python, I don't see much use for it right now (in Python, at least) -- except perhaps if you hand-write the C/C++ extensions to Python. I just thought I'd throw that in there though -- I thought it was a cute and succinct reply to your message. ;-) -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA Return-Path: Delivered-To: python-list at dinsdale.python.org Received: from python.org (parrot.python.org [132.151.1.90]) by dinsdale.python.org (Postfix) with ESMTP id D33921CE1D for ; Tue, 14 Dec 1999 14:55:18 -0500 (EST) Received: from ra.obsidian.co.za (lava.obsidian.co.za [160.124.182.1]) by python.org (8.9.1a/8.9.1) with ESMTP id OAA13963; Tue, 14 Dec 1999 14:55:06 -0500 (EST) Received: from cericon.obsidian.co.za ([192.168.3.9]) by ra.obsidian.co.za (8.9.3/8.9.3) with ESMTP id VAA18312; Tue, 14 Dec 1999 21:54:20 +0200 Received: from [127.0.0.1] (helo=obsidian.co.za) by cericon.obsidian.co.za with esmtp (Exim 3.03 #1) id 11xy13-0000CN-00; Tue, 14 Dec 1999 21:53:46 +0200 Date: Tue, 14 Dec 1999 21:53:38 +0200 (RSA) From: Paul Sheer Reply-To: Paul Sheer Subject: Expect module for Python that opens pseudo pty To: obs-devel at obsidian.co.za, python-announce at python.org, python-list at python.org MIME-Version: 1.0 Content-Type: MULTIPART/mixed; BOUNDARY="-1463809789-1804289383-945201226=:30024" Message-Id: 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 ---1463809789-1804289383-945201226=:30024 Content-Type: TEXT/plain; charset=us-ascii Expect Module for Python ------------------------ This is Python module that does most of what you would normally need from Tcl's expect, but it works like a standard popen(1) call but with BOTH reading AND writing. FTP: ---- ftp://ftp.obsidian.co.za/pub/expect/ Example: -------- #!/usr/bin/python import sys from expect import * f = popen2 ("passwd " + sys.argv[1]) print f.read ("word: ") f.write (sys.argv[2]) print f.read ("word: ") f.write (sys.argv[2]) print f.read () or #!/usr/bin/python import sys, time from expect import * f = popen2 ("passwd " + sys.argv[1], "p") print f.read (": ") time.sleep (0.1) f.write (sys.argv[2] + "\r\n") print f.read (":") time.sleep (0.1) f.write (sys.argv[2] + "\r\n") print f.read() Classes: -------- There are three classes defined by this module: popen - this is like a standard UNIX popen command the difference being that you can both read and write to the result file object. The stderr stream of the process is NOT redirected and will hence appear on the terminal exactly like with popen or back-quotes under sh. popen2 - like popen, but both stderr AND stdout of the process can be read through the same pipe. i.e. f.read() calls return ALL output of the process. popen3 - like popen2, but stderr and stdout are read through two separate functions: f.read() returns stdout of the process. f.read_error() returns stderr. How it works: ------------- This is a completely standalone implementation of popen. It does not rely on the existing popen in any way. The problem with reading and writing to a process is that it is easy to write code that blocks indefinitely waiting for IO. This library works by queueing reads when doing either a read or a write call. Read operations are buffered so that incoming data (the stderr and stdout of the process) are queued in anticipation of any future read(). write() operations are unbuffered. This allows you to arbitrarily read to and write from a process without worrying about an indefinite block. It is hence very similar to Tcl's expect program. Invocation: ----------- f = popen (command, options) f = popen2 (command, options) f = popen3 (command, options) command is a string. command is a shell program passed as to /bin/sh -c options is a string. If options contains the character `b' then the blocking is turned off. read() and write() will then not block waiting for data. This is untested. If options contains the character `p', then a pseudo tty is opened for the process. The process will still inherit all environment variables, hence for consistent behaviour, the caller may want to explicitly set the TERM environment variable. Note that many programs follow different behaviour depending on whether they are attached to a tty or not. In the passwd examples above, passwd is happy to read from a pipe. If you use a terminal (`p') then you are required to send a '\n' at the end of the line, and pause a small amount while the getpass C library function switches into ICANON mode (whatever that is) causing passwd to raw read separately from the normal read queue. All other letters passed to options are ignored. Methods: -------- f.read (integer) * Can take a normal integer to read a finite amount of data in the same way as usual file object's read does. f.read () * If no arguments are passed, then this reads as much data as is outputted by the process, blocking until it reads nothing (i.e. the process has exited). f.read (string) * If a single string is passed, then read() reads up to and including the matching string. f.read ((string, string, ...)) * If a tuple of strings are passed, then read() reads up to and including the first matching string. f.read_error () * works just like read. Typically you would check for errors with read_error() after calling read(). f.close () * closes all pipes and returns the exit code of the process. If the process has been killed, then this raises an error giving the terminating signal. f.flush () * does nothing f.isatty () * returns 0 f.readline () * reads up to an including a newline character. takes no arguments f.readlines () * analogous to file objects readline(). takes no arguments f.seek (offset, whence) * reads and discards offset amount of data. whence must be 1. returns nothing f.tell () * returns the total amount of data read from stdout (or in the case of popen2) from stdout and stderr. f.writelines (list) * analogous to file objects writelines (). returns nothing. f.pid () * get the pid of the child process. Returns -1 if the child has died. f.setblocking (block) * takes an integer. 1 turns blocking on, 0 turns blocking off. This overrides the options string. f.command * a copy of the command. Backquote notation: ------------------- Backquotes work the same as in sh. It does this by binding the the __repr__ method. Hence a=`popen ("echo hello")` Works just like a=`echo hello` under a sh or perl. Intricacies: ------------ - To save invocation of /bin/sh, popen checks if the command contains any shell special characters i.e. > ` ! < & $ \n ; ( ) { } and then, failing this, tries to interpret the command-line by itself, following the exact conventions of bash. If you are not convinced, add in a ; at the end of your command to force use of /bin/sh. - If you try to close a process that has stopped or still executing, close blocks waiting for the process to die. - del f is just like f.close, but sends the process the SIGTERM signal before blocking waiting for the child to die. Since a process can intercept the SIGTERM signal, its is still possible for Python to block at an arbitrary location. For instance: def func (): f = popen2 ("prog") time.sleep (0.1) func () If prog were to ignore SIGTERM, then func would block until prog had exited because python dereferences f before returning from func. (The reason you need to sleep(0.1) is to give prog a chance to set its signal handlers.) - f.p is the internal object that you would normally not be interested in. However `f.p` prints useful output like: f = popen2 ("echo 'Hi there!'") print `f.p` - You can carry on reading from a process even after it has died and been close()'d. So long as there is still data in the queue. If there is no data, read just returns an empty string. - Opening a pty currently works BSD style using /dev/pty?? To support other kinds, I'll probably copy some of the rxvt code across. -- -----BEGIN PGP PUBLIC KEY BLOCK----- Version: 2.6.3i mQCNAzdiRpAAAAEEANPUPC/Lrs4OCJOjWaIWaCYTzTIY1p73uPY+8ZOJH5fc4QNp IAX+EFQ/yZ3RMOLg8yy++HufzBwDoePO4W0MKwyVFCcNIIjsY6JCXWdbpQXsY1LL OASlGexQnEQ4mfc7ThOAKWSgPyiMv5vDJ6S0EL8rdIFL7fVv56BAxnN042FRAAUR tCJQYXVsIFNoZWVyIDxwc2hlZXJAb2JzaWRpYW4uY28uemE+iQCVAwUQN2JGkKBA xnN042FRAQF5CAP/Y0TaguqCpYiTEBHxZPpT/dliInVRBzryi4gdlgX6CCLDRRGH ATP4ac8aiATegc4ev4+vcdn4fBwc6fQ2AP6hd25ZI93vShxztM/bQlGWy0zp79Uo +69uGdJhdvgYpIsTCqppM/yjeXAJEqq5TG2Gy4pqHY235rspmeA/fX7kgIo= =aX4m -----END PGP PUBLIC KEY BLOCK----- Cellular . . . +27 83 604 0615 . . . . Land . . . +27 21 761 7224 Obsidian Systems . . . . Linux installations, support, networking info at obsidian.co.za . . . . . . . . . . Tel . . +27 21 448 9265 http://www.obsidian.co.za . . . . . . . Jhb . . . +27 11 792 6500 L I N U X . . . . . . . . . . . . . The Choice of a GNU Generation ---1463809789-1804289383-945201226=:30024 Content-Type: APPLICATION/octet-stream Content-Transfer-Encoding: BASE64 Content-Description: expect-1.0.0.tar.gz H4sIAA+fVjgAA+w8+3PbNtL91fwrUFVztnIWZSexc5E/daTISqKrbXkkOW2+ pqNQFCRxIpE6krLjPv7328UbfNhOLm2/Rz2TiAAWi31hsQCWpB831E/rh+6B e9D46vf5I08Pnh0dka8I/h1kfkWBPDt4fHR0ePz48JiQw4Nnx8dfkaPfiR7r b5ukXkzIV3EUpXfB3df+v/SPmvo/9z7QebCibhB+yTEODw6Onz4t0/+T4+OD I6V/+B/0/wQeviIHX5KIsr//5/r/hhhKJwsa0thL6Yx42zRae2nge6vVLZne iooPlBy6T8k8jta6o7d2nG9IN9rcxsFimZK9bo0cPn/+dB//P6r/g/0+Jy9j Sskomqc3XkzJy2gbzmCAKNwn/dB3AcN4GSQWOVCcY6dEdDoh6ZKW4gEMi+Ca JmQbroJ1gFxsaLwOkgQaSRoRHygkXjhrRDGZBUkaB9NtSkmQ7kPXmyBdEmjA 32ibknU0C+bAPmJO9omXkFUULvA3RTLDCGRDkcJNTBMaX9OZ60geNnG0iL01 tupxZgQ4QvqX0YbCg5fCyDDcakWmlGwTOt+ukBCAJd/3x68HV2PSuXhLvu8M h52L8dt9ZAH7048pDVPOW4p4QTsr7+ZEkg446DXlYwXrzSoAEBBV7IXpLYnm 5Lw37L4GjJ0X/bP++C0y/bI/vuiNRuTlYEg60P+yMxz3u1dnnSG5vBpeDkY9 YM4Zve6dnZEWabOHtuMksT8LYqzhT20njTYTXatLbefNZWf82gQFuc2Dj1jD n9oO/Uj9ia42ijDWNAgFVv7UdhJdlci6VTDFbqJal9oO2IgnqsUjYLhN/Cic SySqBC1LsK0ZuAaQr2i1amCkCKaGCWBVMEo0FawmCOeRqBKPbWftSRb4E0L5 q+2MKkBZajvRamY1NrZJ3BA1jnPaG41P+0PScpzNh4XmtronnmuN9mWn+13n Va+NEIq+6h5/zLRbQ1X3dNGEY/qeboPVjMOBlXS6Z4Nuh5mJeGw7navxoDu4 eMkqxTOvPe9815O1+MxrX/c6p72hrOclGKx/MRp3uAWKx7asm1wOB6+GnXOj TVa1gfrO+SRTO3l51nk1qqn+p51xx+yMZY191B32L8dmO68Bg4dplcyjeM0N mc37iaqchN6aAuUXg+F552yiGWg6l8OeXR6MxlaF6HN1ke2VqcF+dlW3i8R0 u20H5vN3l+O3k7P+C6wyim0Hxd2/eDnABvncdgaczQHyJtSMZaXxy7fgmS5Y FXuSNZMuE6huEBWqvX/RPbsCIzUgZJWCOetffGe0Y7HtjBiFI6DtTW846vPB xSNY6q0x31UB68EXhqpeFEAVo6sXME2QDDQoRVN1L0NUTVd1ha2IwaQJYbcJ j59gsdiuaHVvNKg5vR/Gw44J4zgW1GQyGuC/q2GXjWy2uX4R7Nlp5/Q0p78i QC4/RTiWa44xmyd8LnGquFQmSqMcn7u5dcIoCJNUtziCqdP+CK1DzvHJ+VM2 mnbztYbnMz/orp866w+IBeIHaEgYIFs3apkeFpiDrqH/aqI8AHrkYOEuZUP3 rNe5mLzsnzHZOYaYAW1GP8A6uMWXzOTwt03qfRf+VffE2Fh2upeXynTlc9s5 O1WV4hHq+i94BfwWyn/w4p+97pgRY2k1KgI+7V32Lk57F90+Z6VQ8ZIIR08v Oa+6g/NLEAMTbLeLUkUe8dc0YfB0kiksms/YpBuEjXe7Z6cSpaPsCWvLusCT oBPkGZGqnM1SR4ZdbW4nfrTeQHSXs5vNbV00OdpGUaU52wWtoh1OgP9zZp1k CA3nPWX2bOAacRtgVetNfYmRJKwjrweAszu4fNu/eEXeOd2lFy7oWbQg0nUa 8awVhV70vh8Rz5eWSLSJAxpZi4D8eQtBqXpiUSw373qyJCwYhSjSnhrvHIN7 zp0UHihV84qiFn4DH6U84HHc+wHdN3vWUxUkNe7gJFrAFsd59d/9y0nv4g2U 6/UpTVJH+6DqXrmLqjnarAvhRDOMBgw1CbIaY6AAYI47unr5sv9Db9Q0Hok7 Iq5P3Ii4iaMmo7n7bFrKsC3Fki2YpPJFNeLs+DMbmvztbwgjogsw0Poi3ML/ wqbqM7rRWw7HkU9NUkgWEchlxCOJcTHs2ybG8AoClLtDkArhv5hiW9U2sRzd yPCObgapY/HYJLZxiTFtdjk4KMTCZDKlTRXmMacEJsH4amS5pZqzU0YWyBAU vKT+B6cAa+FQeX3Jsa8gqsmMW8CVCBw1W8smEVPc2WkHc5KCUZOvSX0OToht FUOU/g7EZlAlIE9YVXWPm4NZSVcJJc0TMg8cUZ3ngs/zL2QEWRNQDoZBE1Ju EjttED1sBoM1ZaSSbyUn5PG3pDGj141wu1rlNMPIN7nSHvIBEizqZouzFMKQ bRFM8+FTXPvhuyY7F2mtSFBF49tSc9ZRkq5u/RX1wvpyFjfB4Ixn3NEb5Z06 l44iC/Z0QZjCPxrXzX4mVh6oyDhFDZCt3qkzhdR/JpV8cFMhv/5KpGbykY8m MzdYjsAchFyyMg1FA+20q3v29oZ5DWuF48EJ25/WJApUAXReAZmt3TzeXTCW KCYbPDSpVhHqhMwiPjWkoSLn1Y22U5wzTN8VwqIga8NXQ9gSOhrvWTcA+DWh M7KbNHAZ7cFKWqtWG41dXgu2Jvd1tV0FWNWwjd33lRNj9v4pFAgC9IxjFbMo hOVtG5Yo1tSi2kuCej5HO9Ik/wA2OVeu70ZNtDkREcMq75Pqf0FDUtYwKmkw 56gIyPQMf+TiESIsmY9c/JGTVsEZU66gb+pNYXeXn3u6e34v2bw74CpuzSyk bU5AwUZ1p7A72zMWY1Zh/mdQxfawbK8Am6eaLWm+3eTBu/KFmUot20xDTqDZ dsvt4o43M1Cm0vSbVkOB17Ta9dQyqpnHNLbZn+cvxemF7S9NrMXzMecs1dL3 SW7T7FVCGDZp16eR4CnawzHc4bp2xJlQS27yakyycjuJgf3US9hpZTH+vCIs b2hq8l5feL/kyz1hAb/3gP2y+c1/MGRk+EXFndpCi0izWbKv/gzTNM+JLfPM o3/gil7hpsSMc9YiJ9wcZq2KtqKKsg1luDmTq85ytmbRalrsZ3UuXlZzor7X mj5NUAUWcBdl4j6Kb8aj+HY3Icl2KosBTQheoXEXCcPBbpjCfyEMeBttie+F xJ8BEnB87OppjbdnJN6G5D1eBe6qy7JFhKca6TKOtoslvyBT22YkAhZOdtzC 7qSuvdUWRo7mEsu1FwfedEVhh4qCpN4MG4GfFLFKRAleju0d1pixMDS8F96y JTRFab23tkm7+wxHthaw4N/ezTLwl/z+zfe2CadNDYaXbVNKYqqvRG/QJFEu WgC1E6TpcY1E0Dm+CRK6TzZekjBcM5qAoGeKX34jJ3gGx4U3PmQFC4rrOO1R bzzhFyAOP0Dxt3ESXFN1eoS3OAXVGFkZ1e8cY64WgOsabbS6Ds+zcEuf75iv nkdGcXYd6BLaPCpkHkYx7tCQLR44nBBvPW9Vq4+FiaaThNKwFXKvlXrxgqYt ESK2ya8EQ7+koTE3Gjzuk5NHnOXLGcNNu2jacC8BykWDqlb5SByQd5KuQDqi imogLVJxK/ZqqSi/pYla9dih4EQwUZGD1L11xVzX7gSWkMq77eEWV1DCd7dy o905n2i5Ir8GQnHegPtDHxZFZAbkXkF+H7Ue1Qj9CLPi8OSEPPoApbkXrBgj UDbaaOL5ypOwB0M2UgBMOmFkiaeMRkskSJsYCnshw3qrW0WSKnbopm0tW9YB mzkNctHaf2yeMb1u7YKlfbLxYUdlT9AKZanoQltDRecsTGmhTAXYi43kmkM8 fE5leQAUv9v8+b88VXDsnCmn3iKxLPCTjSgvVReJfijXSEDNCAyw3CRjaHOc /mnTvk0w7hjO+qNLI1opuH3YZVhhNfnXlrbeIxNBhn6x5Q+wAPL5lTPk3Xwg u6jfXwhbcH+sVg9+ArbAIfymzlAIga0sQgDaPYaXwdbIJobpTQDlb+IoAJZf GH5zM3uPYrBOj+XhK8SxM4ieqlWEbfRPgSZOtuLTQYE0ia2tEtnYB8LY0d55 a+EhulaGyM9YxkjJ7HLF3GqeWNNGn5Bx0AaSyIwTyWHzaJGQekCEPCw4NrsI MbdgNsX/Y+3AODDtMaV0hmD/hrKk0oV6uBwqfCQ5ocyLB8rkZGEjQniWCWRs iV2FcsmOefKAuZqx6ScPIERBr2O8Qh4dMb31TwsOIIyOMk1H5GnU6tU9kSJR Yzk6Jox4rqntgXDnW8Aei9AVQJiIWcCf8p0C4Slc8nCeZca5BFBQTL0DX7jY ephkRjF6xvQ2iYnlv2EOHovUV/M6oGCMsNS1NV9VvJDF0IAJqOAbByYRDDyb DI2QSDw3edjBa81WdU/ebrLb0M6wRn7+aMK5gNRd/OzsrD/wMwLZ0GixW5qi Bgx9wfb9iYiBJ3jC0HrPDMSGQjtRszrTztArH+S6xtVbvc7trOW68Mwz3SD8 yIyo+pb59vvaITi/F4aJ+V4oQdZD4R6GtFy17akXgrXj1j+jR7SkGPaJt8wj mDbG44KZlyxpIsIe8HUcUUWFP26j1VhwdUkQ3qVi1YluRXDMOLldAl1Av79c R7C8DIn39/hBBgr4fi4wUatvgVTwoc4u2v+cseEBwwWVpFAMmZtOispnz57Z SkYNMlfDFlKNV8c+s5byyJkws47RzwzWLkRgx5j+hsCUInhtwFrNSSnhc7Gm PinNwEoAWCFWoTFmAaR5l2h0Y/Tc3ROgmnZYy88+M0GBihfy52cPDwxm9vgC vSY35w4LYIwNHJN4gX5VNwX14IhVr1rgHxsaJSms1fQpOBU8ZEk1hcsOMrx1 kz00M+caDp5rYCP8Nu1DDnFQAo0s4cVbO2KlypyUONYBCh9IVzRLzlfsMyA2 ir72LpOY1Ucf/7ITIsRQfPdnwTVLzpU0NnYMZWPTZ+ek9BzU6t8sOdTSoxhi xfPTO1cZySDJkCiRNfOHX8aJLY5Udi1Kim8IWMrDHWe+Gnuz6JTNkcPKs0YM 2+TFqrnZUBo3M6qaJGsaSmi4CG6a5fZRlgTdqidSRObpoZKbfZRoHTCiPedv CEouf8tuZngGSemlgh05s+PYwFfBsy7r+FnVyRDakHQ+jbSWTeHwPZiNsrCK Fiq3Rvz+eFB//tOjgnhcjWsSjJommYwSUp4LwqRRcA1Nyi5Mcx0sU81uOnLQ gmZLyE1SePImRc440rwUcmHTjoMWUF5Ab4ZSi0Zii1WQ08weCJqWwEi1EnaM Uobk3O09o6D43tnCkvEM9j6O5MySaAZUW7PoFDNrlzIfMGd33MQKso64tu/O 9imGUVZ31+16GXrT/or2rMX9pHhM7ckErgrbp8o7kwD9VYo3VTMW/2tU7Npm m9CTiuoJ6/6MrihEPURc7ODWdO3dwgbiX1vwqSTZUD/wVtA1WjEEMWWbNreS l3Uzz9G9+nIvQRJvmzknYNul4RyKNXmHzyi16XeFiWX5EXLdSpfEkuoij/Uu nxBD7rEu3bXU3ZVMyELrvNt6S53mu5IkkCKHdbf5vytJMiiOnu6IKfTFXkFb yRWhOfhDbw91j0xT8bWiAs/Uv8tcYn7ereI7xwq5i1elwvufT7kPYgei2TPf gnUz49eNx2InJ4/cxA6D/QqWoISHMvx8RO4MbKFkyrmozzCIbPyL5WwwbJVV wURDzJhYF6x0fhGT449lECYerCAFEUbpQihLBTqyAE2kGllO+E4mkc6FXV3m FSs896TAwjUsGPh2L/nxiXv0fP+Je/ykhpkHry6uCHvVGdaCMEqxexQz5nWq AqY1DOSlP/FIcpukdE3Yi8dkD1el0W3yhsBSA0QlaY2tOFN8edendIYvC7sX g94Pl4PhuOn8ie9/W+//qzd1vuwYd7//T54cHB1k3v9//Ozx4V/v//8Rf06w ZsYt5gwG1Zi/sok2NHzcdFi2A52TySQIg3QyIXt4gL9PHnnxIqnBDguL7oa0 iLfZrG6JTP10OYJ9wuAEmIzf1GuT7oKmE1m7x1HBhk8Oiie8uQFjmm7jMDsc gu5LFPs18ncxsIVrQuMYL5CyGPPUM2hw39ChCKskItb4b+IgpQ8klsHeSa2/ ihKBzUAj+xutlrzmq22y1L0wEUk3BomXprc5nAe2iDAdqXRcrQ+gmuy+C3dr +d6J0R0E++NPzs7NEmO6w6a4zzf0X4SRAQVz5nlXTXz7RAqbtcQuSJOivayM 0RNKP0jpR/N5QtN9lq/lUyQEsPEC+bql6Ig99NxvMDmrh3axTyqIpYnpa/EM NULW4BzQaR9WJBMcN/mWHDQVoaru+OjoyTFSLGpasqkOi0BoW5fmmvWqCb7x oPaTMXCYmiGOFJe3MjXySbcN0wIT2gSzO/updqsXjD5dRT67xxNKYGVEInsD zMQGQtI5WGYaGWa0T1JEguvpin0/QyrPJs2YfYjVtIzJJKabWHque6y6Zvk/ sse9WO0/9YOf5wYNSp58MVKefB4tf2aI8tff7/hnxX/6TeUvOgbEf3d8/wuC vSfHue8/HR7/Ff/9EX/ffN2YBmEjWTrfsERvvumrqydPfsxonyR+HGxgXcUb d9hFsjemRQYJOAw8X8OvQv1weDg8InuwDWps02DV4L0SaVtusqy5bCz9vajD 588PMROEJ2Aniecvt7BcpAnpQ6cgxY80wbZsTP1lGK2ixS3rf2l922mLqdf4 gad9/uUm+NWfXtpnaSwJLoosN11+T4pVB2kC2GaRv11T2EmyRBVcb7zwlmy2 8QZjLeiDqTxA44JluMxU5vucYsp3HF0HeBqJZ4uYwQKMeNMIDyIUk+KDURi8 eOweF6ULzSy1JuRdyTRKlxJJviuDws9Lac5zWJPtBuN5WGSzTO3rYZA+/DIN +xqU23fHLou2+Geo2HeqvBlsjtOAfawgwqSczXa6CvwAIkgYHffbLOE/svN7 Ip6Zr8QrhcROWOeBz76zFeNHq0LM3MKXHBQrLpGk4NYbP7BFcOGmiaQ/QZFu GfGAJtkGqTcNVgH/ppWt1oz6AHU/5Z/qEnqqeAmUK+KzX4gV/CCMlaBxZ7+Z JcwV9MVfcsCRmFGbX3bgHwKbw4YBeoLmY6INnn25C1qvgRXAJN4AYMOAREm8 XcnJ40Mwwl568HhKBH59jSmET0YGEyAO9i4CHj8w2wRZGa9byEkpiWTTcwN4 8WUJ9pkzVNKL0anCK2c2fnrsBkQjdASI2IjQ7KX+kosRXwqJQva6CO+MuXw8 VSwFsvFVa7A00B3ahS++y8Y/nsUHX6NmBqNddekoPUyC3xj7hr3LcTroj/Fs GQXH3+COeN6CIX2EPY3C3RSNljTrBIwVpsJT9wmyhrYOUwIUGcPoMPMTzDoE 4FXwAT/55jqzKMB84l/kWPXfKmz8zZZlNnvTJFqh5wHJLROM8/HVD45j6V1T /j5MwN4IiRnQCRoP0kLDaxdPipCh9TVyh+Ocv2GjrK9hHH8ja7uXrNbfYC0m UKiG1+eDU96G1aw5ugl18+D7C9EM1ax5EWu0r18NBWashmZ2OyybR+Nhnzez amiO17JteM4a4jXUsiwQxcB3p/0h5wGrUVzqPV1MVEOP0qpUdOUEIk2sQD37 a3yFi0tDcMqrFNMEgwTBJWsSLIlnRqh4jte8Lyea1OdA6bU9QhL7CDlLUvYT xJIYh2/kfiQfK9XDCm4IP5KfMJOGBdYsCbx6SPCDCHWf5xgIOjccMdt+JMtg noqslyiEGbulJycOdJlhegofK4239B7odY0USqL6OD9OKZKIpXMJmVWVkXwa kgUikcKuKlP6NCQJflBDaqmqDO4+maWYaK+MBkUnXlc4FPl6u0kDgBqN3ff3 YJpamJRNFqCb/ru9f+1u48gWREHW41Qd5qnuPj09q+89d/WdDkOUAdAASJB6 2KSoMkVCEk5RJA9BWXKJMpQEkiRKABJGAiJZtq7Xmp4/MfMr5uv8u9mveCUS IGWr5HqIVRYyIyN2vHbs2LFjP64BDmDhsidMAXRClSpAFVGiQqXX+XnEsoWq PbpD0g2mUS1gVEjhFSjXeTx8DacudFQJlHH18ztIoITtApp7CqXwzI+4qoGd dGa1jaoDNikQQ8/JRnL75AZUlFHmYZvo9JG8EbmWTTlqw/ywelTAXSDEhQYY uILRdrEwdGov1BnMy2KbJ0nLC1Iug48257xeRthNi/E5dgzifCfCguZA3BSg xs9CtgLELZ0Glu3y2tEIji2sQIy7WW5BQChsEVU/6g1y+soYAPWIlWJLP9cA kuHRxhu1UWhEVoHxuNsmcb1cDqMP1LCtkEU+4SoKzE2NE10ZKewgZ5So/GIe SL8MhuQvxzQu+Ag4JOPCNEIGwZ8txXnbMfFCyKAAp5XDbDxXOEh6wHGO4KNG UAE+Oftt2EI7fWZx3ek3MKUl3CxEgRuqfuIV66AiuLEnLSkRxpGvUYNbuOrW ZcscytUIsaPSF9qD2/EYGZKkSwq1WqcfiyYl2mvxxqQfIVcdAz8K/DscMhSw /6itkkI002ei9zQYS6/0+qeBfDXZOeqfLFekC1rqEfXG3XAUaU34IcHQiNRm 3UMhKVg5E5VyBHSl9OKbpZeLC6XSelJa4p9vFkqVElCagB3tAt86jBzteGdk zaDyVNMNk/D74ZDYuBEA6DNLthuHZ+ohIHAbWgWslO9QzDJIjdedAYzZiMxt USGBWMpEu6IdJ+OwS5tehVf7JzimNICkRKpXcDs6CcfdUf1hYyM/H+QDfACO AH7KC9/Zj2+RJ4jtx7fIYTdw2pIzaCSwjsQ89dsw75hrie1dMAOsvwQOAQQ5 fzMfsNBThvk7bs9bd6y/XPry5peneXn55ia8wzBL3TFXHiBbhszvRj5vN/6F G6oMPOuyeqlo3583uaCkfn678F0VIMwzARZ8k9GxmXIII5B7LE3sFgzX5OfN WF7ZVS/lmLDPoMFC4BeQiVWW9rXJFiGwZEFzBj7tVlJOf6WCoiWMjVNoYI+A HDjMHEyDw1+vhqP5g2w4+ut12sObyLT28NdMOGZrAcp2HuVhOYr1Oh44aa3j yjiBZdlVeJU+HuGFb4m2HDis9iN7fO7H5xVnsF0eRoixcikT0rcNhyxBkiVL 2d/VwgQ7A4sAss/jQvBqfDWZVdNwPrXAwo/P+YDuUDvyiw1HUegdbHIRXmAD QdKDwAQ58PYZTH3n7rlbChFCOCpGvQGzIpRfSBKsm0E0tNQQB5g32A0hS0s3 EN8rCws3CBiKWYCKkHNv3WiGKP6yqR7pRnrBOMwCLxwYw4HKiZuF7/gLLPNl +npD5Egjki7EAxJLkBY+677DVjaSsz65BMes4w4wEihjYoyjgiQmAZxE41Bg OUhYNOQd4fws7uLgA0bieRtRFI7kfQSLzMdpHx0Q0T2miAxcgCX1J7yx6pmN BjdbaA8XQ7/gTkErpMrNGBXDQlV+HFUBEM4CXP/xZGU2oHegK1e16NqEJRMQ DPIurDKPknQNKsIu13U3/YpFSTrTEtYJluulRs2TTHTKNQg7kTMIpBEBMXTL 17i18eT/4p70fcuYr5D/31qprqb1P24vf9T/+CB/Nz5R5gJAbcFSx6PBaHzM MlR1Ep0bp7WoFqVFdYqZKWE6kVhlRYC4Q5Ef7l4d+eEh7FytUgw87j6sjGFb 3RvQ75edYVwZQ5tGuHIqrfA+QbyTGWohFSpCe7BB5TUn1oMOAMG3BGy4Cu2J hrJXDHuJlmNjhx+R+5eu2if5t9rptKI+KnwlLBGHowueQUXmP62fQCY6KKzV GmdqhW5RCsCO0wmJd5Ii7S8Yy2Fks/6Fg0qsWwH4jJARuM1eETQiK2SEUo0o Enn9jLEkFW7c1oDDgg0xoS5/DbOXnNExnKStwA1EnTcYmIR3+iunCAeTInaI xNuO4Lpol5REaUdoszd5iJMpNC2p21+owwhZJbXfDVsRnE8aYwSwurpcUg/i ZIRZn2D8jOWVarVarq4u3y2pp43NCvHxJMDGw0f0rVqWg5W41qje/3RF5Q7h 7Hf0amFZlctnUXeQtyODuqPDHjUmh2X4uI7clHitqKLLClR6KJ99X+b/Ivqn y/8Oiiw0IpHAUQB1vNjbP6zv7b6sVCpKB094sXnw6OmT2u4hpgbBYz6pHb3K /M7No4sI/R3GWIgF4bfWfuoHrHglnoPZf5O5uXgNXHSfT4Va0CPwoAl7zGOt Uc9KMjC8b8AiGHTDS55aSqbDOwwNZn6DmfVyUwowHIUTOsEZT1sqaPDdGSCZ 7hC7bsLaxem3HPTiceuMN/ajV9YdeB7zjUcx6v9P5jN23zrbWRQi2cnMRk4F dEbi5yw8ssB+5bilzrNlA+Q+7iTUXfpjmRZkvSTnky9aZy/zJRz9QQxzRGca YgRJ3IBDT1kAykk3ulATUCCxcnlZaV0BowUA3PI/CgD2mPSlba9xicos0s2z UpdhqzVZyzt1NkerAqW9iDKwVOi/iP4Z8r+J/HT0b2we+u6i0rtkmWhSt3OM DFhl2ath0SnAS35heU097fMSgKVfzctekEtnvDZtMNTB1isYOlH5UQDbwG59 99Ga1G3XL3orc4R3QModgkzXfySZg4o6J0b+wVI7ipsE33BliKECrg0kCM4i QLQVqCyZxUOOhYSHFrkdxIk/erUp6yBP6xVIUjTs5tUgbL0OT6MEID0ahsd8 J4fzbCHhjoozEg5bZ6jZnwDFrvBAyXKyESucIZNl/MHHbPYApcbFQuEBwsJ6 gEiJ/daMIdIj4wzVtCEyjUqNEFOwnwGvNJF8H1h13UGzYNzRyxo0osYbr0hU 2cfrpm9eqJeLmy+2nrxsej7fC0eFF98UXy4eFYuVxaWj6tIg73n3f8VzYFza EGDy9MVV5PQ4OJPV5E/cEHStQD4DKNHccirt7Io8XUnS4hpenjkgcgvOm8pp ZxpQ5nsUQGnPPEYiC938Zu3l4trSkkhll9agV+irWYtIZ1awcAI9zpm8dL+F DyQKtbjolkmhI9KHD46MTqAK2HCuQfQspJlr+2qaZwFlL+xs1ARIFVUeXcJx 4QTQE6UUbqyNMntU+p7uHOW29Ag+LCxB42Fi+QOf/khz9oTkXzw3iBzrdsJ4 Zogn+R436w88NyEArVwyc6SJgrlSogF+gE0zI2rBwIqJh8ib8a0jaoB54QDp yIBMWXRygjqzDBwPm6fRyCXKUsFVs8LiRuZcWvJ7Rl9ILCUXFlVzHaMriIA/ VTubjUPgyzdyRwvfLdzAawZZ3PKBlvj8YuVSVMwbB1to926c45hs5nb8cmGp ZW7H9SVmbkEK2luhedPT1sD9Lh3xb7KvVe3ZT6/2zK0WMHDeEBJIMpA/sQN+ ZgFT0+674z+lTCtVJo9WaIWi+k6feZbRI5kG5VXPiwJ44e+Rzf45lkR31pJ4 CI36S64Ihn+9BaEPDO97JXSvvRK6P3ElmB5cGyd1iWsimDdEHobpI9TPgWEj OILI3kfP0AzGORIL0I0FicPkIGdwjC99oJqQsIjVLVHYhjJqLfLphf0xsOvk eE4lg/GwE48TCwXvt2VXDbsJKXeM2J1HEn07JiMgADROWMvyeHx6igcr3mYL m/XnJQtq+2lJ1Q/qz4tX8eEA4FB3U5YOas0aQJxFm5WaPJq7FOHgddhKg6uL GkuZw6wslmOF3KRCblIzk680cvksZM5bPNlgCaaFqBYXEKRA1IV0/UvfoEdd fVu4BFiaWXpdDdbVt4S41I5XLtYKd2dQgrF48sSchb59MqllBWfW0qSbryQC jghmigSIHdY8uNQ4bmfHQ3aeYyphcJoUFJhJ1dJSyCDYaeHIzSW7kSDWezyk iTWyLWTRoJ4tsuhmpODYdbI6nLWA6I5q0iNSXcVOGe1n6S7eMooLC9Tx5iqt QN7FPtIh0SiniT6tjgHazYWjTLQrIdVHCuoMFY4Er12N56wqJapPXJemJjw/ InWtZAkniA5e/7Lq4997//Pu/yRK4vuu4wr7b6XgY+r+b/nO3Y/3fx/ibz8c d1XjLIIVfW+Q4O+X8XHSaXfCfqUVV/4c3v9o+/f3/Oetf4mO+r7rmL3+71RX 7lTT6796a+Xj+v8QfyjGw41/p/7gYPPga/Wotls72NxR+08f7NS3IHmrttuo BUba95W9wf73MR7FvviiCozaxNV/9apLf5Xxd+fubTIAVJtvgPvYCnvHw077 NMJLVbxSXf2CblMDVXsTDS/R7kgbw41GkWiyDS6JC3Su/CHvMVTcE2O7wJiL deX+WVvJsf0TBapB7qUz4gtKUZxDly3BC7qJ7ySi2DMErnoYoYMXDPMiIyPH lG7neBgOgava39H2Z4Hqj3vHEVpCrcC5hHXR0W92LJyl1Q/QUODQjYoQDOZl EIjYdX8YweBgxFo+BklXErkVgmZZE8chR6I57fMQ0Sk9PAcGkLhgVJpox8Qm k5EWjZ4E6+ngOf7BJTF3wzCBAcq+cg92dPUh3UeJazYAaTyC87FyRmWBp71R LkOWnqMv7RgVak0PUlBBR0TA+sJAkrWVYlUJGQ5u746eiEw1AdJg74ohALK3 gdX452Gj2D/TkNk0S6wrY+SkA+aQGQMQ9DkJTMIxnB2GCYBtddqRGK3yIGth iSAEdC2gATMg0IQwpg4+wwv3czLfCF8jmngDx9qEQ5TNoi2i6LXKuJcQm4PB EHoOde4B/OwxSSaQpuerrkPbAm0D506qs+rEsjXdPjabgCkfntIMBqJ9P3yD ZqxiZHfeSc6KJVOV1v0AIONhC0G3WeOTpUtoEKkL4tG8M3KKUggrG3rKNEMs 9aCNLW4lAunDyeqc26v1nNat0SyCw4taA7cdixonaWsK+qHyZ4y2KYzxRBMT mhVtykBj6ZhHikdCGIzjTjsA9EHChoMZ9WmNSiUMCRuOSJa85k8xzsowMvpL nKsSHHIZrxbUDu6GrPDSYiNezDGAjx2ypO0IAUHInZOATtJZM+qQNxLoyOiz RhXZVsJIPIQP0UWI6jIlYz15JbTzs4jWzimGF0iCeGj00CIxCkEF19OO4B5g Rgfg4OlXi2JknGhMYdRPAU2xJ/rg6+vHakOMS1pfJYNpDnYx2iDiBYh4rJSL LYFD9mtrHm8Na01fTHPF7DjQetYqPv4TYogJNJbqShLbhokKG1VGt5CT9YQn qC8mYRQY2Q1UvQtR3LaI3SuicICozqaIS6iRyRkrh/c0UpMmHDUFWkGID0+d oUGxgElIDyYspoBtgvjYCgf31VkIrTkHRB1Fg2SNIrgZ0/bA7wi6HMFgaidA uwT1nX2aTbNw7lkg0o1Ow24w8NwAsAcAB888bT93SKgDm90EZh1RLAoBtikX D/OJ6Q+yLFYLm7FH1k9A8xRpdoT0CIGf7LdtBAyj52T06YwpG1KaQDeH8Mqd MhSkaAnU8SXtTVgHKRzjSKF7J7Q1p9YFQvoSF49GsZ43XAsGo1gcxqwN8xid U7R2CIT7KBkEJBv6YQyMRo9crg7j9rjFzaEtLmFNQwQE+02XhLT9wIWpN708 GvOPxZC/EvwOCQR+79K0X3pEl/kr0ufpk6ECyrT6KBamYRAFvQF+HuEN/bOI dgyii2/iDt9ktHEZDLkbZP7eR3JjvRWgphkOv+OrgJwatjuwVMe0/cfHRCK5 IsNildjoDz7wVYc1d9biatONPpkCxLDhRiOcUV1XRfYJcghAqFAKAMFY6Bi2 iQVAX4ZDZxa4EdohlTSG3d9q9MsnzEThxgbJbGgn+ULiYgnnnyB7iEyc5Rn4 xhrbzzZ2lusgS9Y3xLKKpaXmSIPpqpfGijJMLBeBLUWHIORCQhv8M78WePwa nUauz7Pplegwa6b9FZ8fxN58SxqbsKyAxOCIGlMI0y+KdXSsN4iYb7k75BPg ZNztMpkSi5okGfciM0vEB2A+OjrQOkjwfj009naGnZcWVTQDz+ZvSmNBCCzR IMSwk+J4w3TBGMxZ7rLDxCagxX3cHTMn0CY9NyJfCJYs/bqXTL2Oo9F5FPWF KrKPDzSxFHYxDDQKk7kLKgRfyo0J7Rs7sBnx9Ym3+YXONs5i8sAcpjw6T/6b uRcJdcqrYmJLgKEMgVTEp/GY3TOP+32uPoVP1AvEDL6UNJJnpR7D+Q2wGDE9 QMOjixHaPVL8TdxEuBklqbr/Omo7ll9s8go05JgiFqExN7QL8G3YeQP1vIns WU1ontd6/xSXraqM2u1Ar1E5HQO0ts4ILx7ICVGfV3FqcSE6M1tyxixdSZCh Zm2Rpg10ksyK+abtDRp/wXj1YMuzNBYPaaTMqw+rdLRsw1B28arDQtHhU92V 9wwZHvHjr9kxQD601OpjaFfkSfm2xdTL1SF6AvdBY2AmbtzXzCwtcEbAGPW4 +2WPY5cLiXYEZJe5xIBOhzyMeA4zOSElJEX5fnTScUgBn1hYWZnnNrADhyxS EnXfWOoym1h53spHMfMr3iBm9kJOh5To0GNSvAnEvsxwWvoIFiKmYm/J2hfv 01x4zjnI4Tw62iU6n91b8XAQc7xbplm4fArPhC7JrVpfEbMIlKJ11oGO8Cku RObjNBwC86O5UAAhWs4cwZc9zGgix4XbgvdSNnDK0uVvi9bqybgv5xhZbTLq lSITULJ/6Bi2C2gGbehdJN54Ag4TZJJl1FHaY46mFmc1MR4gD2VYYDqwWpQ9 EVtDWhee9yM0D3eVIiArCo5g/PbDS3HpGaJfnZEwq0ymeSdqWaocBjnyGEEB zXXYYKEpOWpOqDgHdXaciKm6zsJX4wGyJLza2CkBHZuJauFurHHdOXmRnRom YSOHdN8fYDWIPKd8LEsfPmjIduORNT1BiZxoXMvRTfOz4mhhGjeRvXgAE8+Y jetzEZQWiL/+GCMn/y64pgRTwajUDp401Obuttra292uo/kDW6+I3LukMPrU Qf3BU/xEGZ/sbdcf1rc2MQH7ulzRa57bt3kKKETo5LAkyLAZvlJ3n1iiwMxG qF13DdCUxIyHdfp1Fndx3cAQsjSJGenOn6N2gP4AoIbwUsSU4lratQrKtGiy tGracBfoUli8TuVGTk9zqARRw0OScCIR7cvtNnrNQgYzUTmgRTk+Vqmcwdde FPZ5A+12+TRFxMm46jLrWk5q6FoOCdyAPEYlKOswqNMHhhmPNt1LvU0z4zG5 5yeBxPdGIsq31pr8ezVSdUWiELBcnF3fUoOcjFkOt0FYzyWWrdmZRjo7Md1o GgNrJ+BW4Bn4GNd25hxpUlOhkZtY+8GOP5aiLuLKNkWrxuFJCArVEFic6obn a7JSWd4ZIpPCeQUzNTfhQg7IoxxPHErXrDEbC9ZjIQy+RpjMpxE7tdGFU4jt gKGGsWqTDzEaRJGXAt0fs45C4TEQCSAMKNkoGRDsfyTQwYGMMgY5XZfPfYP0 Kue2J1chn7C5hpUh5oRAUfd5aPn4pt24EUrIdkOZUGApcpYJ7TfijB+6FK9k DOs9ySXVFGhxlftFS7TZUT3xg5pelIBOjBOaZDh0xED/cECRrxieoClaGziY fod3Hd5pKT/VwA4Y2bUfiUjwIN9VLAyiDgTEZrPqSDiavMTgRY1sIgsJY0uU p26F3ggRc4HCZ4/8W+qyzpIJksyOR0mHzsDoxwR2ddH0CkkDLLDMv2b6LQe8 YyUnLJLQDCNz4tp6CM1DaNGGrsRBt4x9251Q/ThUJEkhGQQ7ohR8oQUayOas Ky50YMGhPxzhL0Zncho/8dvXR+8HMcwBIhQaITIhRxL7TASgZpWi2woGmiA9 0GIcAwyd6tD8mS+6Uz534ObH2zf4f7VilIGucXGW6kU+CTLRO0w8mT3SC+wv IG4vanfGvbS3TJKmw/AOOq0xHPC63IxwwIKTkLxSiKkt9p/kdNLawMmV7S4T etPqhp0ec8RaAreuXkfRAIkPIJVZiVxMOEiiAcyjObu9XPEQW3qcaF1CvPGx oFOD6JqrupBc01RD4WmdmSnhSxKSfYvMEOb27DLpoB1iKAqRJHySmx6uqxRo NTjS8vJMjEW0akSRVsRJAq0LOSIQIQqgXpbUrVg8ETkqgeSODbPRQ29JsnUE snWQ7EwLy9ylpPylVBK2m7EycAaUVq5PfWWvzWJ6GtK7akCuLlLIx3p1yPL0 oogDfBjfHJblX2Nn4sAmIB0yMlneNlAgB6Qi6p4gixJOMAIVLnxctNcPfJQe nWmdQgMRiTPMDB/EO30kIoKUBANPpEzq9OUWzVbbAaUFDu1wpFFTckk7Wpnt YKcj7k7HHJcrPuyLg0TGSty22ZvusE3+qRADpjOdVtilVLtIflDgSNZi6Y3s 2WYYNAY5bJZh2pgfIa1Gks1AFRTRhtuLzm+7Ii8P+1l8oSWKDARHTtpRcrc1 PEnjrnVKmgFa1q69rpoyrF+LZ9U38WvcZ0aY49K7aArVaRy30dcLLPbo5IQ8 vcQKRkTfQLHepwwDC4VTrTee06iHwnM6Y2JHpOS1D3AGT8EoZ0CPZryq4AVX YEI7BkpX2MFYzCrduO9pt8fDqEeHFWRZAPNOxl2Zw4J3u+dMD21tzokPtwha td+O6VY6jvlGiFeUqUjvdng2HiLFP48wVhEyNSSISO+qXNwOEPMIgDAxirMb YyDO3J6Vtg7zpqUc/ct04bJBGxfLGL+IadLMivmMk8vLOhLCGmKYUV4/s+at IzoUPBxs6gBD4kOWScsaOmRi9dWuo/nLjv5lZ/IJFImEaH3TDVPQwVGE79Q7 GSVZqSihY0+VLOiZkBVo2kwbDN5LHmvBNUAjNRHk3IapGWOXSSLNZnkCXZxp MZosGpdSlLRjbiYkJa3Q7fQTsCYwzT/Xq87ZJ+gqE8WpXtWo0IIiKCkQ+AVY XG/AholeGXoM5WKDJMJT2cCSkb+nHWMzDH2JE/c9Whn4I8A6I/Z2kyVPWrOE j+CwYC5GkWFKAl4+XI2WPrPMnNgm8nSAl0XcLRa4dcnrNQZIidU5sgMBXeAf QsGSowOFLSUx5si625Y1hsscmSxHRYEY52QUuPfA2hGqdgBu1vox8RPrIusp uVXRMTWAU/mQBXL6ft89x2QNtiucxwMwix7eaPzL4jigz/U+XYKwYL2HN7fh 6SmOkgarT6rUD/KYngHI3tCbY4E+IM9geIr4Hqo3cXdMwooAWIlRPGRLEr9/ zEdb2nI8NFcAtnV89OfzH4pGs/biVcvXARWjjZYXmL+Du1cLU3W/6PiIwtY0 p0vbN17a9z3HLXrU6Sq0HRPyOyoTYRdFkNdnzfHOOrBKE06ema23xa1nnsDt iV8LSiaId+lH5443H+IY0qp7wTWqJbkQ++73mAekreyf9ZI7Zf2WcNMcRSkU gG8zeWR2w1hXaS0+IraJGUXm6ffw8MKeiiVbInfPfW++NA3oDPG6emgEu4Hc rGOO5Nrj7ElJu104hh+zVdbIDYWQEmNJw2Qbklqtsp+cbDqJuDuyu4HWCiC8 05ScpaztiCmueygnTPX4RK3/6THzt2afmtMLP1RGejZMXRoiN8A8sz6mrBTJ 0pLVg7Sem3MViXxbMP2Yk6gqNWdFHPtlHHZarAxxGZCbKCFU5iDfioesEUZX wT28oelHZbwBZ37BnvPljj/Qm9kVwucpDUSaFwg9awGkuBcOO3QTLBoDVusT RV3OUQbdEqeIvjtsGptRUwWPvHTcbLVwrxOECNjczlXyJFG8LENTCvmsN2GX OBkPAC1yT3yn+STiIggYPI46yYncG7pMG+5raebDHV1xxxWPT89SpywrSusN IhLUOw3SQHz5gjs0NHq3K2rTR3VzMUFuol0sdU7xmrQZRgev8zqJpyrKe3x6 CzzGGwrST+MIv21cDa4Mn+REib56yL7g0nJwdCxG8ruAL+NR4yKJu6JdbhZt Whru7zzEHyEF4FMDHJnQ0E5LH2dvnOZWums0IWa1d2I4AvZWRGdMZ3VrmhOq SeUCQ1Ks3ri9TJLpSctgiiXv/iyzkVr/TG4NU3oPdnimCG4rgSZdd0g+EQnL Tos3vUDp1Jq+YiF95ivGj1J66BYP7/1k4ToXy4EeOZfIe9y4Sxu0LI0FOHx3 5ulzZGBLaj36Ik/GuEpgZbdiJICyWzzVWpVyXCckuULm1pG38GnKXRHa2NN0 gxVtTQmsguVOdnvii1/UnUvw+jDtNF+3B5eH3HGTljufso/R8+C5Jq4sIO+7 qqo8DWwGDkzqkOSQeLjqoWdkPKXh1R1M+bg1QtFGN7zE5cTyXCKd8VBEEEmP 7jnC1jBOnIROH0P/BfaGroAHBQ4HiNorSH1hsQMxPh2xhnik/ZhbLRxqcEAN Rp6g714DpI88PF/M4ZAmEIqfndVHBAa5vprFWv+mDBkQB7fo1iW1HDW5ZBVD PtyfcMRld++/wzdUJqhwKT3dM8iCcZif3lOm4v0MWemdSrDZv3QXqt9lIydA wWlWR0qBHllRQzSXO4Lfxs5/Yp9glGYW9Q5sUkIiW9HAVZow3IQIdY2wm26v JYa8bDDvSpvZfzMpusoG4/Z+CqUtTXKBMkqaW9ODzJLzs7jTmhBG28lgHSFf mSR1D8l8G7FMESorowO5sVxRMKeO4oBTWDrMxhA9jtDdAal5TgjR7dWDUbBP S6F5qOwFjCcvlg4YXO8kJpYY+1y1fdRZtIyHmu1tMUHq0GXaJWK07EsVq0JN A98eM/9GaMwBFshhZDJxVeQePOVymfoycaWkx930oBeLVX8JhUUotGSBG50/ 8X4oYFTXB3TSzRIkntIFVkk37WnHqOcSmGsJtjWxVxKbmqG3c3EFW08lZ7H2 E9206sFaYqyvAkhR6xwlJXqyTStE/2Lq+YBAZB8LinSLNkn/PGaJSQlBSS/h UsYQTHTYEgWCMUEYaEZd8in6DB6X7lhqaChsOeLYG7joThuWtuZw6IwR2oqP BNPLlFZG+o6EBBIj3ufI9CCO23KxIYuNWoSyPWMYchbZe20SlWnNgUQukXgW CYy3cyEl76O9VMKHNGSbjruiI62pbkoCLq49jIKo6YBTbaVo7simYXNopIZ0 LiuhY9YO8zcyf2iEiT1Gjb7LKBySxZw1FKIjGa8+bIWwknKvpiPhYM+du4M7 YUlvMKwoIndfcEJCx5t6nPsypAlxnnK5YpgDlwe2d3AZp1cX0686uiKUqcdX vuKdeWzlbqU6bwYl6yBr7+6+gkyE2S6CkRyri2vrcoqnZvEiYiuJh1Yqweqg Uj7RRhEMOrTiHtKu6XtBOZxTta+vk3XUsXpULqUnxSm8Q8QFmrZQ0L5WUOKF 4ShxverF6MplODCjq2lO+4BWVTQcTClIHx5cwkgmgrjMnLaxUYEVRw2RU3b5 vDaqnWidLIEMA3XMsjgck6Klh73wTyQQ78FmQBSgIAsXWvw6GvYjsW9IcNsp Gp6a7g+JcSBfOWjlw+Q9NQ7DMaoqjfvEYRvbG6rKnFZaxhwn8Evz0YPVGc8o rpTGsk7iiU7YHrkNPL1WfGU1es/cEQVCNCSuBU5K5Vmulcyghh75SffaiB2c BrA8HlXHRG6LkhkkdhLJNeqZO3nLX4oyLanFTJz//Vsp5oTvWpEji5X0Davc 83o63BmXDIYrQ9lG+fiyzBpWeO5G5alu5FzZupq+rh3zZeBUhqM2RSIwwQon eszYgEILHLK4X3NXN5U46l55oltS7hJMdVvsDk9HtNbwZBUYnwFyIT4hJrWm vefxFSyXMQwxir68YbksMtFRYkppn8vUd4EzrzExIQhGjq/Hn6i+6ZG2Prim AFbv6P7RyWqnPJrO8Wf2Unp2ghpUhuHQ4pfOKH1FmqneE10ANhNzw2wcGUui Km5HloxZj7gInQFyCb0ZW+rL53alMI66AaETuotgJCUWDLtX8u7XIg+xmGwj KZfwwGwkw8iiB9nn3vtARUYYcWhk8c0apl7ZkvT53TlOoWkjjxtxY+zwdoRC GLyyo9BUuHTIq4NcuWY20exQWqCM3KEfY4HvYkpofq0N2GmHw6UxCdNyh9on QMdcUQON1y2jTYXE0mLkZBrAaibawI559k7YF67jC55SrZVgdnsyP6H5SV0E Uhhgw1YgQRbptL9B410uHRDRoJbCejMR9w2KhZGfPjMolhslE3dWLItLSG+V 1xvarA7jM3QMb6RtNqwwy6wn++NrtsDR2LPZ8+xZPTGxqN9N3QqKfMZEg9eW RhupPxS9xvQ1bhsdZLDYXPvdeBcLGW6xaX6QGsTUzbx4EaguV9jqAONKi2Lp rMu2K7rM7KIYSKeWkGB/QvJUMZkTRjhwTPvwCzthSNuaO0vZ9tRtIl530nly ZLaXjPFz/bIiK9gjDSkykmZ/gik+p+/3Kskroy8hJFKogQ5df0a69ZXAX1Xi B0LMdiIMKtDSFza8GmWnd66iRrEvqSFmpVqtwPlGGOCU201MgE6oP43bp2yE RZf8jooFGzoHnf4JHnwinUlHdOcdUaxlC2zi3OuI9x8xkobFO46SYilwcJKu EGkk2+IAEgUUzOocX0qryMMtNNzY9MCqN0S8qMw9GbN++iStq0itmBJLPXll B7CTIFeI9ZrT1fSy1smEcJQuO6UtYvhqEXm63rgLizZi7WnW9oXt5VS0Yy3B NroaJJE3owkEb8S7vlNMhOsTk4jsqUbNKQtRbM0nXYCEenaNRwcy1aTrCLaK HMaXYXd0ybaQzkp32EB7oyia2zG5hoiNxrkoEhgZM3nFNG+jsyHd4UA/uIvs rgAvNcQnEiIDtEoPLzHyRoTp7no6RjCsAqDPQ9zCjE4TTfKM5qO2UcbVqqNV xUFtUCbBsg40n+/zsoxYNZHmFa/yaTm2xt0Q6G5n2Br3EqLhTO6Ow64l6JEL 3nXURIo/rNjn5rLag5kFSFmBcMitF2XJdU9xTKt5ZmiOwdSMZbumN1720i0R Ug2dk1yEpm8slCWlM+0RRzTOWDDUoahVBIQYDc657ldOfknoMN71Wui4MUHS j50+HQpEYnk9f0beHMvpWCsJBmjWTpSEN/yUKf9giLxBi1j5J4QKUYzBpYwf iOAUlWjQ6p2ojtRifLuc4yFuSMo7rkWdcxAINLYT6ZLWdVgCyUjRZ63NZGRM GN3rhhBYJyq0Liz9eGDsH8gccakd93n8xakVrHLSBFLJGaEMsoa02XvOoUxb dfssMZJGspWrMTUUMih7IRNiukMhTUV/1bhYShpR2FCsBVVUyavGuQhTjmEY yAAZVvBxNLlb8b6ajCbIM3EmKxV93ZA2fVoS71Jps5/EMUlCtSzthAkIDk5v ZEz7jrXDD8Lu40t7Y0EFxeiLabTlTSZsR5EqkrzAtwDK4ODp8qyN3qfoUNZp oVe6CEVggzO65vW66Njbwb4mVwNMiE1XSoGWjXtFPYd9bGrFOv10k2IHginH OAm4gqiNW2Kfjw3okrjkt9+xW9ciIdNE9L5xEmj5sVxRHMftycsXmtbVCulB THX4RkIYsUcaRm86ZB7Bc96PzrUPnQlzmGmx74gZ6EiwWvitBCRjQkdkBpQO 5wc7fQeJPDrPGHSgQ3oxkj+AvlETLAWol4MNZetyLMCx9RSHUsejLFVhnPuw zi4gJN0EEsdtdA4TUQcMxfPE6Rj6jlOuc7BXQ3v9ZthdkS3jJuLnnTheMMl0 tAN5xw1yEwERcyV7tmMpnaZXbG6vT0KGtXbZQFlfWt3duGwcakUnryo/xONo BlZM9N3R/Gc9ThUarscfCnt7DRRNc/o6C1tnXLsVzH/fqmjuUStAOsuDePcJ 7CTlR/HJj64hnDCf2CRvCae56j7JaEZ0dNDyIliggRdckbcL7boOuXl7zBZO 0Xpi0tunS/XEPn66U9GJWI5BZiDOczYHx6WW8PZgZPOJ0Zdh74gB7mk0DXoB Aua3bVtQNnga013GiXJcclgmgVyIBOJmxEoIWDgtfjscT5197UatF5sDvfhE CfheX3YVU+SUqUqXomSza9DdPRPck+jZ7Yp6UNvafNqoqcPHNeMlod7QnhG2 1cODWk3tPVRbjzcPHtVKmO+ghjl29wINi/wkOAAg1x69154f1nYP1X7t4En9 8BCgPfhabe7vA/DNBzuQffNZJag936rtH6pnj2u7ag+hP6tDcxqHm5i/vque HdQP67uPCB76YjioP3p8qB7v7WzXDshhw9LeQUAFOcxorYERGr+qb/t9ym02 oNU5E+jUtB36trn7dfCH+u52SdXqBKj2fP+g1sDuQ8fqT6DBNfhY393aebpN viAeAITdvUOADh2DbId7NDKB5NXQsTEAPx0fFZ1HTAuQGtgAqTSCAATG+6De +IOCHsi4/sfTTQMIBhdgPNnc3aJ5wlY484jdVV/vPcX7Cej3zrY3KDhQNbVd e1jbOqx/BbMLOaGaxtMntYDHu3FIA7Szo3ZrW9BeLNWoHXxV36JxOKjtb9YP FLnJODhAKHu7vFXeqeDkAcLVvkIUeLq7g709qP3HU+hPBiIgjM1HgGw4mFA0 0PP+rA6VY1ja9OSXqAh8sJP/NaDRnnqy+TX75vg6YPSAao3zDh8rYEgtcm4+ 2MMxeICfqVnQEBiQAKdoe/PJ5qNaw0ECqlr8iZRUY7+2VccH+A6oB3O9A80L tvZgEf3HU5xFSBAgahOmEyEgHvKUKVyCiGu7GkegblmWZjoLtu5J/FM7ew1C tu3Nw01FLYbfBzXIHRzUdmG8aDltbm09PYClhTmwBLSm8RQWW32XJwURgBZz /WDbrCcc5+DhZn3n6YHGMTOCUPMeDCGCJFyzE9LYe3gI66BWLBEOqPrDoPF0 67HMHgJ1J+4xTMWDGmTb3P6qTiuP64G10KjLmEASQghkHImukW9o6B/lz/Dh Qtse/G3inWG7c7GGQl7cCjbpkMpy2EPiByDxa6S8u8D87OjLQFF5JEEsOwhi Ew/fkZfjYFb0KWUTPWVl3lFgHN+ME7MT8ZmPHEiSkkQPzbXEhwT5nIq84xCc uIw3yYng1dZbsuMymKSydGJgvho3i5TkZMLRCMpKS2xj0w/Z+Vdp2qXRFb7L itrtrTEd0pWU0NlRKHfEljcztjyeg1LjIjsJT/DEhYyCKd3TmdFVO53GSAlN 7rpJ05Mk9YnnziwgfzGXckUNpwjtndu31SdQBMMNNw3ModYoiYKcYURypIwq p9NBTEcxUnrnqyvs6JjvQsidMXIUMKxyy3YPJ5XKu5opXe1OQVEsPgZ9DGh5 ooDZCFlPlX0rkeuG+wTL97d+DzVe7kMNBAL5DWK37nO94gLRHELfKU46a21o z76zIqVnn3REjSgzavpMjk7HTCcAE37RjZA1I4z6JCNfyR6Idw2jTlelPy2Q OoL4SaHUTcTWqw6Wk0HVsZQTz+uqsOrXmc9UgHUZ2xkB1vkOelpQgNI1IwBA Z1BNEo+yXijv2DimI705dsKNiBah/ecw7sMAsevcAXlM7qA9uzMkpD+MTp8J nTDUe3wJGQva3M4YVMv5qBcNi4odZg+DBM9vXRZ098mhNGn7o/6xlcxYhyQ5 o2Zp/WKeBFq/DgniY/EdHOId96ALS5WtIrEMLnRWSfg6vozbl/1IjyBSouNL UxE7xrYNIJIVkfqT6AToBfHq4TA+zsNqsuoT2EB02oh0+3U/Pk6KRg8Pqvh3 bIM6gAGNe+px2HotPhvvsUYamgAAOh1eArGK+/dLqgr78bDTxegQy7hn8IcS BjNIOtq4/ytALZTphaO88enNw0BCgU8+BqN5v39+/BdiLnbi0/dbx5Xxn+Al Ff/l9q3qx/gvH+LPm/8ncEagc8L7jQF25fyv3p6Y/+qtj/P/If5quAuuqczQ Xx9p7d//n7/+bSDw91nHVev/9kT8v1Uo8nH9f4i/xtMH2/WDhtpQQcCyp1pj Qy0U9r+GM85uUycVbdLWw53NR41iEAwuUXe5uX+w9+hg8wmCaDI2sf/KhUJj rxjUnh8ebDp5gsDL1Gw29vC/pwdbNYTgfqu0svLubG9ub0POL+Gs9If9w6+b O/UHX2ZmrO/+QTldwXds9etT0a5vPq5tkoAZ+z64hNNbv8l5TUMqg8ugH6PX Dfsl1YNKvJZutXQa5ZGU/+ee41l/3vrfrT1778E/566z/6+m1n/14/7/gf5o 4jMj2v1Vo+3Hv/f0561/Dkb93uuYvf6rt1erhv+/e2t5Fdf/3Y/xfz/MX1Aj BFBPaPMikc8+bYVBecqfaFzB/zmjuKsWZZ+YHJqyztS5NqfRep5iZkVmbqT5 ctjq5hPZPsWbzEg0wbsd8p1J0bRC1DmOB1G/UC0GLYrZMRb3RQ/2Dh9TiB6U UeG1kLhTrgRB8PBwfy3gJp+MBmtLS/BvxT/iLA3Gx0tc/xKUqLG26lpgO4so euOTpXEyXDru9JeYT+BkVEcbkl6dtchkWPrTImc8ATaA2r+iCjn0JXreVjn1 GZashMPTNy+qLznO/WDYwZhEFYo5VEAbxvaayvG3kwpLUwum1Mp7LAWcUTy8 Zm9LpKn00/tcUrlBLrMLpvmkEpV00V1zYblSnd4ngJw7Gh71p8B7j+BwqIKt LnqETVxEITMNJVqNqLPIWVz/KiQk5+WyxnBxgFRZaY8xaaR/ult/Lpnw7hC1 meg2lLUOncghvl9gdCaDasvYXC5AZkOuMH4YJeOu+HVhK3fWe0tG7Wg45EIJ xiUyhlaDYUx2xNBMvJbG6yLUqWb1Ny5AFyZn1CT2auf6uCQdxegibHH4hteR LgMN5S6irmPYel3+dhyPjDvh5EyuLgSZyjxI9MYkg7rK7SYKAI94DyP3l/M8 f9x267S0raxurDZ07qCz+U4lqnAhPd3klAp1N0fjYZ/0JMSTvD8wbjNXvWau cDuliWRey03kQK2hmVRpEAZL1JaQxhfOmkU/ys3NSfzemrZI5iZUGA8zikA6 Uki8J9cUdy2YQuZD40UBHRgRanYp+LLWbrbGG9jbCt7kkld6NixBFXxxbXzB +oMy3eIW/jy8JC3eSGsjMkpomq4xV8cmc/HQBp0JgGMl1y2M5GRZTV+Pu3GL PM6KwwFyLhwyONzs6ntahdjYb7Ih0qX6dhyNaWFhU8TJbDsmkzFWIwwZkYBu hrpeMnw4oFS2HtZqcsdjWq1t4zKC9OYQGHlNKozM2nMRxJ/VIkGiZpH+cNgf dVqdgeOeFG2E6OKFMaXCzQIU9lsTjPu6Pbr3FOM60Xr44fC4Mxqym4ehhFCy JERcD0irAn3xCQM3JMO08JiQu++MOs9DhS/5hUSgnkOgdVqhApcZMLHbAnTL +iZmrXQPRWFT11sMWbH3yGcI3wEnxcDdf2Z8Xc36GkiS3L6NUAOvovzEM3T2 ol3oiX/wMFH3YAO5jwrluOBoD03OVLnF6YHU4MOtn+iarRc+sg86C9FCABDt 1XGezXGQoNFIkvoIZIP1jIrUJycVmXI7TYUi02MqSH5isaBG/uBEYu1IQCNy IYJaLIQS12jSIK9NhNQgicZoMY2+3JMARzVqm9tNQ5EOnT3E8YTV6cNS6pDJ UBD133SGcZ9sr94A9pHzqZKgC5sVGmOF4+gsfNOJx+wwmLhCutO9NIFatSY7 Ui0J5IvaQyqrlkpgo1j1JOwpa8Cy5ooTMdJULGE5yLCxb1xejbSvK9ZfEWsZ Ghz2hsWOhmlomCsSEynjzUqScZ3ALnppYlDysgt4mxJ9JfKdZLfXAkxLkafl Uqz7XHvZJELbTZU/6ueVmNxH1nYeVVPEID5kuOyVLeyhWr6EniOFp2iEbVRb 9qZY+y9PgBhApxPWKK5vbe7u7SLHE2E8JvE2L74sihSAgLYD7jD2Mzznvur9 T0ypqFo+P/B3IoKkBtDVVvIUNDDRSxH1mQeOlvIplCbUDp5QwGKPddN8Itn6 REPm+RbVFvp2YRf+UrdkMFMSKiFvMkY6HIFcrs+zcToaVyQcgdNluPIJA+GI LIHlxLn2OupQmBAE3A3unOsxnfemEP0AYABj8mOCqzmYZybF0Z2WxVdShoJA kztoyCtQxCI6mC8gE+QxfWdkA4+GlkWnqUzBnAYbfxL8hV0yOk0WGsXVsTER MY/Ww9SI3fO0yMBAKKStUGosKf1bqVSKXv2j8YDDQnCOjGG7XhtYFDatJcxX 2blinuFP6IqB2D7MAxTvciC2xfYQDIujxQrwBCIhZieYd5k1CeiNJTX3UeBR 5xiCplZ6ZS0JJAqJOH9jJk8YLu1GOMUe1k+C+fT8UoCy1x10wOphWNhJxFUp dfq084aQxOHr2UkKan10qZ0n3THseqad2haCkAs+d5IQyaH5rpu8rIeXlOSc z+5MOd7ISEmT8pp9qUILNvFWjgs1sWC9mLLOsuQ1hZmRgcoGl0TRa1WAbRc2 FgpaDxuU31wdfYjCYXLGFJGoSDnjwaNaQTzgoXBGa4SMxsRY0ejHo7CbJj12 qxAeskAGsLx9o1h3XjPqK0Uvn7CdfDKQM7EMWRf23KuHzS1RrKhUVwjooOMQ uFPZlDFRO+aGPaZtsfRAQJSr2hccZQjmEV3bHaLnOBkjQ9EK9KRr4MkjnCG6 XVFVxRBNAVRAWp5IBH4qmGfv4m8wuFJbzMr0luKQA30ul9Hx1OjkG+46D+Bg S+daHI9JZtbuRSZjoj0relGk4Tisz1e8PNGzcqev6RZtlM0muqpqNlWPtrqK ekyuCNl/zcYrYZlzUQsdfwB2xbniqyB45tMwk91mg0xidKwScnEAh4ouc+ho 1Ri2OlHqFAnfyqgcnFDIecPH4/gIb1zS4g2ki4mZZmdQbchMDLZIbLd2q2WW fULHdqXuq1fqE3VPfaoW1FFfrXOwGlVU36m3ynjgK2Ewnq520YbxBbXRGSrH DYaRdegnDSkTlTnW/klLKVszkmoojk+pDfq1q58zw6tpXwuYD32UoDcXUmCE 8Vz3+TEqLEG2+NDBESpbxtWtDF8FB1jgjyTkDgeaNaSd2C1cMMkoHgzI87aw 3uIaE/ZR7isVlAOze0Z2Nwoy5I2o2nYE7AyFP7Ibn+xRIvCgoHVeae2FqP6I WHHeM4D4kY9ps/7SlTNZ0FUTAHLyEnqCHXYRzw5UolQVJXJX0tGBtLD3Xpha EWWjXj+dkkIOwSTH4EvVFczl2h8SSWVr97UgmIdTLrHAQNvWRHbkST/hLJET GcyEBDKYl5K84OpkAHbKTjURJYlx1b2RfZlKiP8Bai4xciKphMJnYVu4NRO5 myW5aISmXZMm2EoZ+sCKh2jccVvASnS4p8MzE6IeMY0E+HiewH5QN0RBU/uN PWVviUh1qNMxncAopCPPOHxrw3mNfD+WAWsG+gqSJhFziOvNUfYdAh9oGbpW aSWhSEU7+FGvAOorltya0BAiuENUxXnzZonoXP5xhzVOP8njjLHclyAF8/f4 qmSPG6YDUeoFOlkeKHYwP4+7W3V59e4q4tTny8ery63l+9hpbcDBId/ivpF4 +eIV1idnlrAzMrGzcPcjgkZcGy26QjEPtL5hnSwZ1VlGeBI08YDRUPMZSgxX h+IZnHKVmIugZa238ZB9eaJnq0u7/5XVHgyfBOSEDy0MUU8BepklftBAeewl 2cRgrqV29GYJMv7+96yRH5NLX7w24FMcLP82UOR6noUrxxJYanDpBPEVbL14 ox2zohdxPEF9vLF+9z/v/hcdIp1G/Upy9l7rqC4v3719e6r+x+pytZrW/1q+ ffvj/e+H+LvxiXASwQ11MJYjH1JysvpAyYbEYCJvvWGXbKYlxHA0wg1iu17b gJNbAZEHWJsTVS6L2U0RODFa8H00irrvPK/c/7Sqvv9efRfMI9nkf1XO+Plm GywNUCIT60gn7GgY9sVeVOZtrZLTELbj8343DsV9oBMedgBsdSihTYmxci3k SqY8nm/lWCLmZYAdxyQFGyl7iXzaH1fi4SndHsPzEpTHYagGb2UgyLL8fQ4E AXyHgXgUue1tXUIrEzyrUJPPoMTSCLaZ6HJJAwcSsNKuQG8rp382UDiAkR/t qmP8O74BLhqFp0W3+6dw9lDlb1WeFeby6pX4dpB6Xr1T/wcogHHDzZ4YQNrT nxjG9fMj02w5MmiRNfm9Jks8vfWFvbJO51vMeHjpdiLAcwhayeQWIC2nytG3 qkpBqvtQB0pVqsFJJwgoTxlOrJc0C05PnD4M9bLiSNwmRnk8KHfR3NSbQa89 UtNb257yn6FJiznTFKqpDv1Rp7HckGF1lSVcOJ1TvAqi2zRPklh244epXCB0 WDE0cqSW8HGLbG4wljgqhBlXFmSSKXd6C8uGA8IzEiAgjgtD2mcOBtsF6ZwW tpCV7qpyXcJ/5IKJJLWwubWzt7W50yRVU13SLis4NpXJeUT/FIpnpjuFcCg4 Gz5ltG0Jpm/0OtXCXFBo0cSOXqtPP1W6kX7Tile0zQeRmak40dKJQpgs2dyJ zS18mQsmEjifAN1Fa7jLQaTyWHF+Btn4yDv9Y/55/J9BpUqn/x7ruEL/d+Xu rZU0/7d696P+3wf529xq1nfrh0Gw+YQemptPD/eebP6hVtBaeXC8rywX8fvW 3u7D+iNRmy8wslTO6JOmimIvUGBCXiSw+5uHj0V93tSy/3XteW2r+WRvOwja /a5zLcJhvZIAGsYVNRuH21vu69eN5rNNaDIkoV0BAGwcbu7s4PvW49rWH7Re f+GkBSfRyhmqnC25z524ZZ5JHnOmxn1gB9uSFg2H/VieURRFfUwDlyPwmXIe 2t3OMT90sDzdjsSJQErICBlfzAOmjsIp8J2G6l8fYOoNOoKVI7k3afJ8Ohxg Hc4gHtaf1PC1cXjwdOuwefgEXw6/3q819+vbzUOelC2WyeKspC964bitCzTq j3Y3ndF/+HR3i4ZHrovglHCO11JN3HkwAhf9wvf2mH6SQZ9+RiiWHLbgtZgB rHVGn+m3F/V6GD0SflvAE/YwkvSI3vhjqzfIBAE8TIur7jvPJ+R+DfVfWqEa taC94Wg0hNFC3rsJnX89GF1u9OPAMTjZSIOXbCXlFbqMUNWEhw/ZvuOEI0ys Y8RbJH2n8agJ3xA6CWaEy1twoagN5N40x2fqhVYUFqAsBSfhul+wiFFDuVgQ 8ADhwgEx73YkV+4ilJyILTv8m+4Fp+rWmgRozHbtYX23Vni8+VWtKXBF0ilq pgCyjRGMENmePmgcFpzai+nF/4qjxwFj2k86f47yWOpJ4xF3ub77qEAxQb08 NNOHB18DdXqyX9+pFV7c0NEzcjCpZaEnlbPcSxghv6w6X+e1VVguqerK6q2S +vS8uK4wZ0AfmoAOTcndJJEW9n7md5hL6LqdhCn5eFJkTuxA7tZq281nQNLq f6wVdfcPao2nO4eFfgxcYDeJUsmMZR1a3ntPD/efHha0IV/xSqGYt//3XssJ Ew4hyfvbY66Q/1RXVyb2/zt3Psp/PsjfjU+UFQB58w/HlDJ7yDNHUnXWiWAb aJ1dQuZN8jGzpnbj8Ew9HHaiNpwC1b0TefpyMIwGlbBT6cEGGrXH96HIFnlK aq+hC4jV8vLtcvUOpIrnknaMUQACSFioQxavLaU3qlqprmK5L5aWq0vLt9Xy 6lr18zVAq+M/Rap2MVALcPQZDtnnHgqkkFRQcFCmtbhFnPTjYVvxjWZubQG/ 5tT3CvWFyn04JCVL36wdLS3dWFrHpyX8gVe1dIrvN/B5fZB/RdDOOicjuhwZ hKMz3NE28IWU6vBB6Lv9mlvQjwttOXHjHqRseg5VOmVJlBdV0ZatLJlMap3v NFWUhC2+nDH0/hOURDjwhLb4p/veaxhPZTMF5jt/cdvz/feqGybAZgw3Fn5v M15ZH5B/OxMLAsIUB0qlf6eO0VKOB7Ef8eYRkCRkwUANJpCVrhrxGuPjQfad /jz6L5z0+67jCvuvuysrd9P+H6q3Vj/S/w/x9yBMgPbWeSVxyL6NiT9aqOxG z3gdhVIdpxS9IG9lgomSwu8rI1LIa90NFoJKkBy+axjTFT4GqWyRB/cxyWuH AWrnoqYROwUvs76tpxzMcScl1CeLtoxDXo78FrBjaoGKAjDahFSoXmkuKY+8 OfmBszudVpjja4NKIHHJOMIsQ0AbCO1l61XlLC/hE52Qjel2B27UQ6Ueos4u ut5DLT0dEdwfJhm/CpO9PHsINB7bxsaftaj9cyhGbh4Jv/k6VulZEF9bIW+M GngL9ZQZNmnq6GD1aCGUcDynhEg+x50Y4O3/eBCgP0MGS6qY7LmONMI04G58 mnfHQ8eak3v4oCDX8rjxdy9TMWod1GEng1rPRWsftGM4trNWLYfocsWbzuQZ +fVoeBmQ0hpJS1HnDb2FuSjacnQ0jUJ3LOHAetxHdJgSoDp4okQNRKO9cXYs HrbZbbbM0Cs2rs2zAUh0iTOIXudJpb0dDR2V+X50Yayw2bM0TgzeL5DLQeXP mw0Dr2eMIwr18yOjCv86igbW0fQwouMz6qC28SpnZNerO30sB8ybUL527bhD dnxp/aGxFj5wWFpqnRdHlRw0HOctDfvE+tUc6SClQYdivgwjcwnpVsiKBOlb KcBSp1a2J0rIQikZkQa2hxukl8wXgh12o1atQCXtvJ5CSwhSEVilWD7xgjiS htblgDUTgBgsOe1lb3SCdA4IexVpwgsygudFH0d6+qqVAG2hyAIKg7o7PW5w sISvZGo5VLGsDqc5yZnyWoQ4K0Y9A4wVTSiFlbA3ejbiIQMK1A/TUFwAEqWb vxyIJoybQzQvyWYAOvYMf7XKDNE70ctBrGYoPfR7RwFqI9Z75mvDk4g8ySVy 50hLU1TDqP4VUrMGDJm44PDIN+Rcrag9Ut9kmjsypRhoXt+dkZohdK8sFE+i WPJFGrc1DfqW2wi9LeZZo5CetRIcm5To8Dukr8ubhlZ2hHXbGhubOgJ+u2JU hWThOsA4zGdHdL9FZ4pBmuBVBNcPOaqRGy0DLgc0eTwSQHP6uGjRoStudbZG zbR3daxJj27ywU4VoIjenTLmgTZ1ghM6BjWo84PYjAUA3YZFb3Lwnt42SxSV BAj5gJR8uIfgQo2GZc6ON/enkZiV6/ipJjgIbznSKa3jaNa2uAFGuZFyTW3w MlRTUY5AQP4idXNg247Fu76JWMNTTlEu2tpyxNA1ZzhboV4JJuhiKnbwluye PNeMy0kGt6YZtgYiLdMWEz/V7Jix4/Le4ZsUCSv7r7U9MekTe0wc8yUmvMHr PmyhZPDn+CQmNUCnVKCVRyxv57Bwx2SfpT3e9/SG6ZhpAeindKkbqgcxmryV nZgDxC+VDNq1xb4y1nGZ7eU06zUj9Wfra7W1tdH6/AvFHo02ynsr6PIaHrqD OOlcuEQzCPbImFkPpyjVymJ8BW3N68n2mtIRvVinUsirtvb3pc462drT3fKS llvubMvHxG8CIwCOEyqgPoG9voPGLpvD1lkHQxYhnczGhyz0+Hr2OmW+luJb I6ObXqSirxyQajpK0Evkg7obmvDIPjFCZgM57NBprMx0ZxjE547iA5MfmkfU zr7UehRsk+Zu+ELzKU4RqxEy6/rqK7xzyhscK0kQ2oQc23KxinI3/MDSRPbl bLmSdFc4cqkO2ssHGLaOhd1jynqp+PunH3iwZa9ZaEQdSi1LwTZugvISTaPa 4edVpZL3WGVNo3jonPFy4pNkDFxgB86FMg1TED+8eUXtafYRIR3I3H0wXCqp tZo6HP2m1KaRrqJEXUrvEFqR3DuZSOxAIsiBC4MMMZ0T7C76s512+n1wiY4c QlhzpfQ2f85mrM5Gb/YRxphOP3jlLHPYsvMAxEkBCpVndTq7LE3cmH7gnbOB YzsB2hSLsSnkdCARO84GWj47ho7cOVDOq3KZQWzQVFc8WqArNe4HMqqWs7k7 kmWJ9NNyloj3HQ3B9dmdsphtNUjvFY6dDbYVV5rX4JKHGzT2gAoBfhOdZz1E J1pLn/lJj/0ygcArwbbLcTEbRWPrcGeOuTK59qfT8SkF3OO6ZNH18ejX4TN2 xzHQ7Ztt167kbniJJ9BLZ8s05uG0ZUDnybBnyP2WozdNj+WdnA3VRgEMSIua QiLJWKNmpx1jVS7DnjnI88pQaN2l5R26fRgVQTeNTNfQqhzphg8aKR8v8Z6h O+70GOKiGSdWeCeDBD0dHEvBLP1Aol8DjR0NQ4PucEoan9CT7BnsAvua+E5V GTQ6qD2sP88jTOcjg99oPH2IH6E3+rCgHsoRZJI0WDZLOozHykuSbfV1gEPE 4T7S0vLD2ubh04Na3vBeozhwGl2SnUeymdC8ZMAW68boENveEeQQ5QlGPJXV BBzU8v7m1h82H9kG6BolPejweYzDIjMOnvbH5TDhsbrIq4JmlZ+rZ9A+YP34 CFpk3jywQg52qN6TRuBpxw5EntBJt8oZD4kDH2j0QTp+2u/8ORKJ4kNCcxlp yq2XY6o9Jf90ggsQlx8w/Ca2+HOl2S1LDy41/XL3Z/FLdeIompbM2tD1u9Xp 7kAHL8pSSbKxXT+gfgeUbOgPpztrm5Fb2xthxxv8RfNVcujHA+cMZk9LdIYc 3O+Yw17Z43R6fJAVsIKxIGMEULDA9l8Rm/1GJhAWntYAJ8/iZOQiZkB0E8/U JJB9ylMwUbURjSDXPh65481SAmD7RTqgkvBSIqfoRrPweESxG7B6aEuJDyAd RiYYb/yygcoqenIQXeGVgOiYi+Tw4AxNUSiKhsZ05vgDhqvZyFfJuH8rT9En QgSCkQVgcVJBOb6hC6iTTtRtm8PG/tMy6ihs7n5dbnzdOKw9gamVoA6e1DQZ H+ftmVRbqQml18FPCDTtooFXroP4qVFb9J2ttMu169aLTHA60IIjOtF54+mx lOzMptNtewLdURx35TCJxjjllj6qWLKPtCkw66Vc5uO5Ny1sKNaNJLiyxiuJ CUpSU0QpDE9HUWOJn2T2rq3BUtuuAVUim+J+wpIm3TnT9JSYp8GR2NQ2s4GT 24E7SlqgiXun8I3uXj15QmDROlQRWeJibioSdDHh3QtoQaueesggjD2ifhJk 1GkP3Ezat7aQCyUZcpNuQVi8/Yp3SdgB3UZ241iOKK94+1yiti559fOaJS9P Ej860LmBt52eF8PtDS2iiLOW4JXoGzbqhzCXWV5bTBCh2I1aG8l48ckr2MQA LCh3XCN6gUx61vBjD4Uh8ooDHyCuk9QWRuEFPJ92RnDB2q2LF7ixF7abP0f1 jbt0C9EZBeyjifY6wGOamDJOzMbD+k4tz0TkqUTvTrTowbmlIeQmmSWseixj BL1iUGwF03J1QGFlRpwX+QRjl5FnY9uEBhnz0ko20rvMSxpuNjGWnGufjCdh OMe9Xmiv1JwB8LgfPlfTZQTA+XbciUZ5fEpgCPr0+K0A3o45ZjjBN3Jj2Rp4 McuZmogV+fDCeMokWBBxKDCmdEcTUrgmcu7Cl1Il49lOAn25o1JARob0GlNC a+eEcEyRpM77Re5IMmwhD4/bPJfZ0Yg2/Tqh40hDFJS0m+ekLJ4ETWZHloi7 uqy3jXN7RH7izRG2xJGrbGrDK33tY+SVKVZHxpJWij+BrrCDpLQtNMxOxIoT N9wSzSHGsAaWQCIsadyofFTi+FB/2fr/77eOmfp/K8u3bq/embD/vLXyUf/j Q/w5+n/BDfWImGmHaZiheUHRCJlD0YoUsHBvSLww8gvqiTnl3lbTFhPSDfX6 UDfQi2hX/eKLlZL6YhX+uwX/3Yb/7swI/ouhr4IbAIV8tlhBh7a4mwh6h4Rs GjgAQ0yUGvcpjDj0xAYr5n17AGeiVGBGEyOvggOpmcS1IGw1cU/cwAfhypoi iLByO1Sn7F8a6ZFc3rlX5WsItc7XKKi5TITUTgbyTHAaM/TzBt3m2+/mqoLk 9Sw6CT2fNiW+37yh2mGCDtz4Kp7IPzl9Icc+lYDZ69293VpgWccNn68IKC6E dJKy0gGMnvpxk5FmAx77ULdJhj1rTCixEbhFRT7TzEoTmY2XNhqG/QRDwjWx lxtJ6QL+FzATsREgawf/8p4cyBGEygM+HscJfLxomjM7fbho2sM6JYhULr/w ndPPtyTWDZIpHxP6CoAwNSuDfMoHKHaUDKYwstp5PLDgKKc+AmcNnzBHG5WE otRnOM1AvYhjWV8BQahVU1qEF3d8kPSLSWo+iPEYaHMQQpuPGJlvouBJnA/w Qs5PRwF4FoKzJNagcSWAMy6qe24ET/iKTKGpEj8Gjce1nZ2Nhe/0sQFfy0Lc 3gLwJ+FFpzfuOSHo2VkVqkGMR+yHhw9ZJDbRN/EVXLm98KKJqU0qslFdCTAV tSc2SNEYXngdobYxsEU3jCQUspAOm5xFWYpCvmXYHBf4poTiBCLlsMq15b7K LUgVriZvBMTZftk4WjA1s1axaRW+4AGj0x/jvTJr24rKsS3DOsflxY3FovQB 2iU+n7x8rCWdT5ZelJth+c+b5T8ul794ubixtJR/xUrJHgRO0krKQN1axjEP uwnH8/EWWaU75NqQIuAYzzkAbrsTnvZRgQ+O7TGLATM7gb3gtQdNLU88mif9 IL9Fb9CkFLVdC98XHXjui/NsH80TjCc7gOJyurUwNDkET/CRknJ270k/yG+q hZRVGkikeNGCcJ7to3kyTaKsWS2yR04qMu3Ve1NHUNJJcJ7to3nSD/LLP34P 7a4i3XQOwoupdqUTUu/wmmqdl8F9cZ7to3nSD3oInZ0vaxyFhFOZyWf7aJ70 g/z6A6Ih8Gjo7WHRhe69uS/Os310hqUd6i5pSJn9YUFAWSDoN9NMESoL2bAL 83syrCC7ivKiLoYEgwreUAcRXaszN0InV+0iDYhcpy3E2Ah7KF/FM5RDKmlr lXY4pMpQqubLpaXT/CvfJuI7ZdxFMAFa47P9mgttDf3WUXMkgdqRU9X7n66s s4fN6rp6q23dpg5JunHlpSa2yCHqfDvSXPjO5n670Y/NNMjtCc+Cfnm3SZBS MAeStFFZ/KAT4uwdf80TMmWfxD/aKrUVjr/pXcKoyRfa+a6Y2rxdank7yfa+ m+fZsmTmPf2d382iNknem/viPNtHr7x+kF+fIrltYqrk3tIvptvtpEzm4RSH JJnEVCb/1XtzX1KQ7CfzpCme28IsqncK5yMsYX/5pyiLZe84iTEowjpdAspl JmTmBYFvTXjTSIEQ8RxIMNwH+TVQ4cDJvK/1hAe8qtTlCk9JCYWk33h/36WQ CD1UXEPHbAyMTsP66oz8OolzOL5zD42bZtbS2Vx6+lytVqoUc4OXwUjdu6dq ew+DpwhjzeHVXkhTXqoXeLp7KfflyZp6IcdckkPDyan1OkL31aTqA6cqOpJT yWDLNUvAa7IJsTevMt5wmcJogbfIuKkQjefE30Bkm3YMKHM/LovYwv1rs0xZ m3awn0CSaVAhEkeXlJZG+4W4oqNXWjm5UqnkjWiYimthR3YDPeGrEZCwVqgo 1lotwG0r3AVulvgkCQaOFXkqDqYirZw0WycHh5QLBmrq34uFCTnGS6rZXd41 U39mzRn11q6uWDvBdSsV9nq7fuBmhfU49FT0oALM8kJqwTMhl08yAcjNYNju oV3QDDiJAeSc7B1YWkl7FgwpyWA0F+a3B50xlsmEYuoEaq/zUHDWGLp3dzIC VqjgVGprZH/u5R7dAUVuPQZaNJLWp6QQAo8EY8wwvKfmt+KejLon19Dtdyq8 RuuBmzFTmIFLovpJ1zJGDpQ1iQzEkYY4gLbEq4nFd7cFUoYB+BIVDSMF4IQi SfTLp62WAebKXnRbWP7i9whTfSuDyfacxAxBBDWpIemRavMMAJBBEGKYXhH4 Z1Rw+MrLjofdXPC8A32sVF4KVctQ4EJCgPgjNMuxtojaZuURafRgeHpeFKYK QMjbNUEYEWOZRIwS3HYG4qIKDHKZklOJuWRWPbjXYhFn632s9TCYxPP5/cHT +s62U4UdO0QOo6ABNXHOF/Sz8XivcchjSiJZfPVa6oOhzy9IwyZqczGttbF5 8Kh2OKWYfHzBv1Kn1qKTACOsxMU90kdDrfnGf7K5ai0t/bGg94G0Xt0GusdQ E8kvNqAVL9UEnBeQTL48qIyrH6dL0EaileMy8gOToIv4TXaLOc116zCN9TXE 9Hha5TRRSGNleSaPE/pjplBKi80W0liVli4i4+QfwfgApgeRJotbblhPo9nQ XjMg3MMWncCWDc+LyPu94Jt+kF//VEEZ+DhBuLloitlH86SZePqcxb1bIkol pr16b+6LOUXwu300T/rB74VTEffFoeaLqaakE1Lv/qtzsOEU97PzbB/1GDkV Zo8UbRNSKv1sH82Tfkh3nIvqXvPes+iC9d7cF+fZPtrmc+GstvOeTSXSj+bJ b6Zk41bKlr/oAHBfnGfdGMk0pS3CAupSma/em/tippff7aN5muiJrsD0RvOg i6kmpBNS7/6rg2mc4n52np0x0dVkjovLpHHhmSnpBNsYk+a/em/uS6qkfTRP +kF+UwPsNVPG2OM4Fye7k5E2meSOsElNZ0u9+68TENzPzrN9NE9m2rxmZ80c s39ULP1onvSD/PKPP45SlgdQWMpFB6r74jzbR/OkH3QXpHxW2/snLGGxv7Pk NriVnwwcyc3JYAM9pgksIzH43pMfuG/ui/NsZolezRO3xd6FO0Ii+GxuwnX+ qQmpd7c2TvLe3Bfn2T6aJ9M+eynvNNE7o1CZ2SnpBNNMm+a/em/ui/PsAzFP +kF++cfHR7+xjJb+sWtxslMZaZNJzqq0qelsqXf/1XtLg3M+2kfzpB/04vCb n7VGHDFy+tE86Qf55R9/PD1JsCfgnXxxnu2jedIPugszpLP+kVDKz06aSDGj 6ySm3v3XdL9dzRTTf++oupjRsqxEZ6rd9MmsEynpBDt2nt7MrDEUyyoXzLSk iZSJZkNi6t1/zR5Dqc8fQzmqL2a0LCsxYwwxfTLrREo6IT2GUuesMfRlAh64 1Kd0G73PU7/MKjYlfXqRzNRp2TPSsrNOpPjZMCmVxX/NxgxfnyuFISlJzOKM cc/ADi/DjMKzi04tOKvYlELTi2QWmJY9I3M6KyZOZEsnpNdBSrcuaz18ixDo toRA+U/6QX75R7dLblYwLf1onvQDN0uU+hzOJHH0fiaf7aN50g/y66Ng4ukD JZ4OUNab++I8O0OfHNtMenCTGTpCvkSdC16RZOtyUtMJqXf/dQKC++I820fz 5BaV39SQ+q2XkfXvDRYz+pmV6I6rkz6ZdSIlnZAByc/ivbkvzrMPxHww0+z3 J3O2O3pmnIfU+OEXGbWO7Zn3aGrE1Mx6hkYskX40T/pBflOtGDpiBxHyLzrw 3Bfn2T6aJ9PW4VT5gb2h4jJTXr0398XOCr3bR/OkH+Q31Vdbn/TX3pgtplqU Tki9+68uvlCK+9l5to/myYyarTlr5FhWT2XSj+ZJP8gv//gjIGW59yL/X3Sg ui/Os300T/pBt1/KZ7X9DeYUnWwqNPlsH80Tg9Wq3M7GoC/YJWPq2T6aJ9ER 8dWRjCEUxdTONGXIZcjASfDPXedHO758DzJbaYvKfCiVLWnRe1LZEmhWZUsb HV9HZWtycNKN+0uqbJEYiBS2pNYpCltafGTnl97efYqx2Aed2J+iHPkBJ3bq dDiqkeWLmVpZF45k78IlC/b2jWZv2qv35r4YCn5hr4To0TzpB5+kWhsTIavO NeBiqinphNS7/+psKhfuddAFXwiZZ/uoabFj9pJFj50rRyk57d1/dZrDKe6L 82wfzZN+SA+drViPnb0NXUw3biIlneCNGKf5Wbw398V5to92OG0TssZzsXjF CmMqYRcYv2u0Jo038hgQn0MSrIfsRce16Zu0TMIg5MijC0AUKllEYaLBxrQ+ q8nGgQS3zaUCJr7exQKbgeXUJxvqAu2rrkmFWuSYjqLDuroH6CiM6iVHTv1I eAzrkmwmcRKTNHcbcYaRdgj2Rz/bTGd6qyXom7H+wTkslx1CCHCUmYsmEEKc g4kmU+zBYThQ+WFPlU+GNAjYoEV6akcnCT6RN4thVFlUixV6wyrIVRoZLyQa ZF5V1Yqq3kYTrId4zNZqmjCghFxr8GFZYcDrdjhEryLovfkGlCL9Q7rEYMPJ Fe4oa3kIciSQvso6rdp9IrqkobDvbGJPFvajEUaVuMVG5+K98Q/j4xiY0sMO 1Awf7/j+XysVa4BP/vdYNRQy3raeSRz/AG/YIYp1Tu2EeWRZQk5tqEscF5lI upe9c994AODwKyb9U4oCSS+37xsbSAQs8feOAlLB5VFy49ibVokrE2IodZsT RX5zAxtiWtCohIMVwsqyDhg6J84C6LHXXcQydMBbCQhzaFobI5hP8nnt3mCx eod3w6TdU2vdVmz6eIAWpZtoyP/tOKZyqIt46js7J4akF43CFhx1w9YIvaei lZxpXxOLGHs5eOHQHJZzIwLJFml/gTs32S7+Oi7YxGYup3KL3y/m5vHfF0cv jl4e/V9HN44Wjr45+vRo8ahwVDz67ujt0dHR90frR/eO7h/9/iXR8slRpfHz 01RexpSZVc35XqOgmQtrxcdk74ba3Wmo/riTYGx3sjPeIy1RdtmSkEeWLUTK sIs6pPSlomMHkBdPDtxOJcZ9qJctnsm3xQ0TrV47atH0giyQifyoqHJaUTub u482tlQB8lGE8MbWXrFCxOsCUXFnq/mk1mhsPqo1tIfrRDXiLmzHQAfOtJ/r sJ+gZ0MoAGy0tnpHN5rQuPwn2Nm4X95CaFvkLUpyHEPPXrNzWfIlRDSp4tCS 77B5nwGQtznYOzawr0xRpN3rdEKkqOeYsM77j1t+q7m5syMQvPL0ASHo8pSw Plle9z8biP7qQ9KpGeBoAEyX0uDoK/fLAUep67K7wmjqnalypsI3caedqL1G yj9v1D8dnSmyupdDz3btYYPddF20oqhdCXDDG55kbHgVNF7frD9XrcFAdeH8 n4jTdA5ZjzSYDEvJbiIh97MjhyijCUWIfAM6lqdQtkzD77sVYA0Eie4ixv3O t2NxQuT62BpGiFZvjHsi332rjARTbHLfWhKnNWLyajwRUawCZGPYH5pI3Tom VAZRV24EGyPy/u1p1yqJ1Q3ljZek81Bcv7LXThxVL74wV2TZGaiFk7Tif9Sm GHBkYjK8TPXRc5hvoh6L5zGc10E4JLNq4enj042FZUvTUJjl8kPx6ffMDd1c evHN0kv8b3Hh5k06HGoW0hZFTOcELJnjyL0GLtYpkkanTOCFNBoq6f/Sgj+6 Dl8qMCoIDxkAZgqyhqkfB85auhZ4u/AyAKYZlKs4ZHbrhw6jrK6103VWss5i iaVPPwq+4E8GVBgL+L8Mn7Yy/47f31oj85tHBZzno+ISTPVRFScb44QNoxMy 7Bh0O63OiLYd9OoWiRkM8kaexxHzOSbXFR6OO77FcpNDf7HA1+aZpxKnKIas ooyT7tCU/pJyfZZzB9cHNWFZkwV1MlNGBTzOwmhhIhtU4+Q4VUoYSjMuQ8E5 nd/zO0Bz1Y1DUit3PKQpvwhlrqQBBTYOZOBVZy2pbWV+VWz65WYMsAInwTDl jKd0GJlW8L5XEPclaGd0MdpooQsaciSBBJYVz4l0wGaiuZLyaUmV98RRsy+N w2zG+QoX28gvbO3vqwXt6z3PvDCx+Oj7Ymur3Gq9VeUWZOGKTVazu1UWuHnE xhMAdM7vlo5NXhKOwVkEsr/NALkgXuUnYS+g03upgbw3No0LRCaTb4iYNlvw iJ9lzLAi8mqDJjLwGOPMFiSGPMCH4kctmFVKqZZWSqtFWOCnw2igWsoeqcy0 4xkFDpd4KP4KXeuEqvHVwS0u0A3Rm1sZN/DwMlGnZ+GfO1+2ws6gMhyPTvGg EbXH4j6DmwAHc2lEugVIYpKlcn/por+kG3TRz2oRkfT+BqHBRj7I48NoIz+f d5cwZSkzrmxwjvSuYEActQQGYR6NYzi+aJIvGlmstMMbGmo2Czjq2kf4f3rp njBh6KAJEBmWlJMzvx+6IsmnkyV7MzljAiTZHDCAobyqie+lrk+vtvJ+qq1k VKsJiEfGbdHrSF+8HcvpoXUUjhVfY/gzJTLmHNUki5kNt19Cn+mDkzEZH2dl g2Tv4JyRB5lHMfAVX8twqEo7VKkYhjBUp3Fs+qwVOjAyD7tLx4AOcHDTtkiF EwraWCxBeWCZUY5mXWmFCQMLE+1WH+A8AB6VuHriBo+H8esIg4lA+U7fCdYh V2UJCpQal8lXinYvaVZJkREbKkToJMw27sM5gb44edFZ0AEw++nceABYmky6 xQCcD8dJW/Pd4gFXYVxeJVcxMBzlU3XSDU8RwkNpQHiSnCcuFA2i14Gtut/u UlCFPrk1RUKGp2nsAhIyAjBuHaeLjkiULUEacPBcAKfDeDxQOShwcpIDSJV0 aURpmHlE8H4UjxMUiIrN8PEln3XotFtxlpacbBCp+rBMHJEa9PpBY1s5Eyal cjmUttFuQLh/J0ivsdu3766p68FSKJPylrEEntRrGL7xrQ/lOBJhdX4hn/8u LxtSODrTRCRP59L8qyM55qY4Celmgfb9dtHvhKbi9YcNIETf4Y+afwsQkH3B INj8Af6FNHpeI2bGJ9booN/E9CZnR/EYrZvRXXkUY4yW8zN2MgXbGvsWTrrs Zg1trjF0AbCqKA9OtOG9FonhijdXmUvfV/D/S9/TSlj83i4XeZZkN8mirCQg Ctr7ULkaoKuzxsMqSQQbW3tqb/tQrVaWjeM4PCuc9+U60omsUDHFtyniHEVJ MiuMcQ8AoyVui07c8hHI1gjVR4GIoGdFA+XYxNnQkGWskTThaJ1qGpa0YnzU AM34ezcddoPSZ0IdBd2Jtq6hbxj6+OmnBhT+EY/QTga95HQCnsM4qJX7n1Yt fEKF+nMzUhSS8oyopk8UWxKhAhbTG3aYX+Hya/hDODov+2YK9TdyE83BbXPe 7JtqBV8wrLsOu8tRdfnRv/mWD4zxDv7ngoAKOxKhyZZMypl4XfHCFimjX8Q7 CcFQoeQagwWjHD8ejkqGICbd+Nxzf837Foc4ZDY/FCAInzBGKiZyzp7dWBxi 5BQlw9aTnIn8igsK0sBJAC8dbYC9V5LQjyrsnKR97UpUshsSM61N3uE7OlID NKuTGMlQZXJwLEdkD3DWDdsoZ4kkky7YDNAZtKahujO0W95CIaezJaETDjmb f/cmHJaBtr5FcWmd3GP0X4uP6s4QYLVQdMYlOKjyyHEkqYAzAaZ6JCHJJgh4 UyycSfCSSsNTiyS9zQcZZRtbB/X9Q68oJzklNbBsCNubh5teeUxw61Xlnrpz 61Y+yN4BdchP9rLmehxHNivsR1dvg3eqy842eDVA2gtvqH8fEyUjwh8k3Qjo TZVh450lYEZvIJJI7DUdXpHisqhaXBfC1PAaIed5sjq68fFxxL6mdTBYypVH vkTfQqIH9ifYghHgcXlHMEGa40srw9aIoziEyBpe9vA8uu5f7g264SW0oDNs q1PaLkxAux5wjdgfdupPZbEZheiUnLEiuzCMRuNhP5nIzqEYqEjevXZCh6V6 CRZJxlPAtYXXC8/VK9hmyjsjw7vbnrgjCWRbGRpOOieW0i2SQPG5fwt+A8eo 3WlrnlHvVE6lV9VJ1TBJ9ir7BGu7omyObqHwDzA9XdTr2AQc3Q/TkfqJ6ksA jF44QgZJBLWAQbT1h5qX7yZ0j4PSZ9i/zshxggHTOSlZpgA2+pJynXAi3hwD u8NhyhCxoD6UBId229eVqLDbCW3wylQUQKqftlBBQwOAGxRhSIwGBenQXlw4 pK/cOrVssN0cLT89ddPPjDybCD0cEpt+AhwcrhdzjTCSoJR8ayVdCbgfsIYo xKvTjUwFBHbPqWdzBbHOW+zwrRhoFARWjXFuzTCw09uPtxn2TMBiwASNw3T4 MOvHmD8nnwRbFADZiU2LdKT1OvPUSwoI9jrG37Muo0TopMXybGMCYh3IV69Z alOsDnSfkf6N2UfBpTrCzXahIiw/R8IlB1pwuIWZR/ERM9yVQPvWOKrtPWw2 atsOXU2idpCUjo7g//APsIrwslBaWCidBpJ5erO0Rk32Z9b2O3FreoX7vD96 WD8MaWqgHFE0SqKZOZ3WiqT0TQn96rpF38KYTht2YSNC2C9oMBfMFVnntB9z 4N1KukVsD3XtFh0t4Ch+55ee2SjcW2DAaOPox4y1dDMtYUwTG3N6onGTeJUj nmB6+xDrclewBAvfoafhMo7MWyT0iTripLfX4Anu3M3gCWZAJKaAQseMe71L LyedTPHJXJ+smHuTy5uVpc/KN5vNQROvTK5xikaxLgJjzUqqoIkcxU8+UeMS s+uK8IlXHNDFLhxrvuS2SKVAYQZ4/Obe58ldyQ2K1cmXtRiUDNkgHTU6h8kv qi/XVA3XOLtcy5lrVA7iDnUjQzyGJU/D8MobcGfVUR0rzjFOhMLUqlcTql66 wc6gIPjZI0r3pfqe4hrZ+d7Qpw74VW4TM+c1DTLvw+TZRIqcummZoNWwhdYO mzhYG/7diuRExdt0xhz96w5xjoXc2uENB5oIgq9qB4363u7GcqVaWba3QblX rbYRu+JqPQcCSTzNK37UvA4e6T22poI2NePkGuLf9BHQKKmYrO118tWU8+OK 5mSLJ7Y4cxMkdHc1BQDbCYnhDRUbtDeg3II85QjHrywngwXl5EnKBYEoEpJs nYbOSoj18E2X8iHTSlqILXICcTUFu1tdTQn30iDkHIOBJmmavCOJHBC08JfY /zOOmcM+EFFLA+cIGEk8lrhe9zRjdYLxGUoKlXlIGWIEDMyQz9Q8oajGgGrz /IYZOhStAWMSk09HYnncNmgDDuQZgWPg04N0yNqJFNU9ezxQzlHBFfcAC7a5 tbO3tbmzIQAwyVs11IGU3FGXyS0487lklERlbCdASQYBhsvs6qmWvl5jrlfu TJtrDePvZ7K1Cc+7z/bTwz0842xoENebb11qyoTrAX5fM4507BozvvrFjBkn GH9XM07U/UfNOG1yGsS1Z5w3yKkzTgP8vmac/UReY85vr8yYc4HydzXr4kHz R83749rmdu1gw4K59txLyemzL0P9PuYfEQm9pV1j9u/cnjL7BsbfzdzrHr37 zOO6re8+3NvQIK4166ZU9pybAb7GjNPfvGWSL5CBN+2r7zbq27Xmo929J7Xm 1t6TJ3u7zcODp7WNKd8ebu40ahv5G3nd1KkAMM8sGNS4eXsqEjamSQpGxKpb xkaeVCoTlEe0e4141QtRr0jhDV5GwXJdLbzO0VdUHwtS94GDy9FZrH+qldvm 6ZZ5WkU7gxuqhgHFJQgsS7gB6TE4pjbhiU9zpCEs0YXJQ7rrnZXlESiHqLin c3OxCA8IcWNhZfpaXZBMV6/Rz5fTFNqU1Rfo1zne7399+Hhv96ef6L1jMAP1 NIT9+jZMHnVD7bB1APvljmERDjvtyIQrrRh0nHYH3zlJMu7g8eITJwCr2jx8 nHEtr3OYq2FPb4hUVFk/WOsGT704xlH3rgCyOqxxSLJovSWR82ferkLP6JgM /3fB+KBzwcyx9y8J9ai7U5d9eCcbsjRUHBBuOLV38vv33yvdUoAUeNfCOg+c 2vtxWnc0Q7AGR+rKQHurFS2m02vsXp+v3vLlaVMA0TLBBjAhoKOyNBLVLvMB h6JCGTcOMfxUZId4sfwS9oVcNac4BqJJX6H0W7m1QLvvz91M0P33EtcBL6j1 Wtb3xjl1UxUQAEtiSx6wtdWXRZqj6dCuLK+NpD0kMP01cpqZkyAkNLoYRX3e S99lMm6tTkzGLIDOpGivoT/bpDghQN55Zlg3u92L2+PudUFOmSwZBzNZjlIE G1WZgBqodKy9Tbj+8yuVyl9mpd3+0Sstv1DgYSjSsPEE0Nf8z42xtz//qRgL nXMm+po9TE8zbQv4/2BKX0l/jBvGp4TkGp27k5bepCBIb2ZyDz3agaic8Qrw PrTsYN/MAr2Rm04BOAug3AY0EladJJhleHQ1hc2iIke56lE2HTnK3ToiSgJz OuheXe31aIgHzCMjPHXXhSehZnLl+s1E4T9c0AxTiWsCSsNsSMAXyzy6zfru 1s7T7RpxIFkTkUszC+75ZgaikrTajVy7zzjXk7jA10Dbz120vRLeuyKxLvh+ kHhwaQDOQF09VdkTvqRjJkOG62wcOY89/QQZVKQppiHXdd7yYnFxUW0haUPt FROKQ4gE5zfjTGoOl3AOuozHuPcEWFgfZMnqD07v3XhAGk3YcYlh5EAUtTYy PHw50/cCX9LRPTl6jixHKpcsfbO1tfFCzb9cPCpUFo+KS96swrf8UTW/NMjZ /Hv7h9ML4MeJEltbjcebB7XtWfVIjomyO9tXlTU5Jso29qaXgm82Pw6OO9XM RGTi9wYtWHfle8sZeXqzmmH0UmRgawuxDAcp9QGS8EtjL/2hsZez1IVNjiaB 8gCoo4UCwCk6BXbqu39IZ9fjhZZNRwtf5rSqEnUp+1iNLlBGMV3cIeJtUWCY YdyKkiS+hiT0i6rLDswGJkKxvT7qWVKcWn0zTbZeElfb3jBW/KMb5HEuMtuS YlYuvGy45qJsqGhzXPPEDyXeB53T4eNQL/CYbAdFRYRcQEDnyYSYAiyZJK2F ioOBPj5OoxFp6hi1UfLAIWbRmgKSWlhOm7TlWIyor+975MeCxyZnzd5qOYK7 x7O0Gz0/LKlWC9Jx5lh7kEI2jc6G8fj0TBLYvUaeTJCTaFgiGNiNP5Hyo+Rt DQZaS+j+pLWcXNCSvfoXq6sOJuWCG9pfVM7e6Dqp98IEah1Vzu4Hjcv+KLxQ NSTKdKWLC3R4Kcf/wWCyXk/N3HyNx6Nc8J0qEF7Q3DqIjdc6R7z2h5dHuSLZ +K1LZkkuoszzNpJirGcIhzHSfSi/Uflv1OJneeVWpTUj4GvuG9tCNjwcvT1a yL2aMM8CmBb71iZFEvhdtvOJPQtV7ZwISedhsqbz4uxMjhF9SnsIyMAehe5v teeJMox37poTfnv5r3nCb9/5OOGZE96Pu/FpLGTjOvN85+5f8zzfXf04z3ae ib2Goc3SRr1ekifPZdTBbZfNXvjdz5BzrHuzy/mHf9r42Wxj6kl/c7dRTwX6 uwbz8sXnqeN+Fphr3hdwmWYyarfetwZg5iqrLi+/2/4JLYO5xmXmpYXD03Qa 6QR6aSfdOKQV+hdalNXlavWvbVVmLJiJmfY0Ez/s4p1sS5ba46K9/1yYKJFy h6KthW9VLpRGAjLvJS6vHbW6KEHtRb3FEtmQULQ8YEdx0VSCa6HsyufviLIa FREIuSegRTgN83KMIep7HHma/Rw0t3WG0zHlntrQ3p8yxHhafIdhrje21Epl ubKi9JqcHOaTYRT96GG+dedHUoYfPczY3L+uQSarXQ7xWh92Lsq3YMBv45mK jMzLROnZBZncoI/7FAacbRXLYT/puG7JUr490q6E1t6Jcr8jg0TNJIIsmq31 xs7es9pBoVVUhXyYV/c2FD7D4Rh/4C3/53zR5D7ce7q/L7mdkr9X+c28+kwV 8KWsAE5RrSEAW/L53kEBsPAEChYKEVXwSeGkWMSLzMInkoIJxQDFdb0QBruA vlnxrbNOW2qhA0O1vK466p5auX0HHj77jMTKBYAOX9E+NcJsxZLuF75QHaN4 PBjwR7wXlY7wZxSDFVaK6wHJwwrLRdwXNAJP3Wbufq63GTSGy9pnMN1sNFbe kGS7isH+s+9K/MTCuaKrDx9k83jvZUdwXZdetZKGPhMn9+YpTmsCQsr+6Mpl l6WSfeTqZDcOt7earNbVUFXWx56pnpVcJkvnYQeYDzYZ7iRqf69Rf16pOs4R rmb1qtUJhZDrQX5H7u8yaSLM5tmH4QEBod+N0kOfkZgkKZbPDAWmnvShoHpW e14/bBxuHj5tmNlz0gpoONCEQUHaMAZiedqHfjipgAafAyWJ+m3UYtNA6w8R RG3bgtQpHkDn5VOgGreLagOIiAGniQ3SGnpJ1gNsvyp8mgBFSGDIDVxVSJDW OU2nlDVVXQ/WxWIW6dPbq2hHdcUcHEUYlkU+5JOhINdnJw3qTDKVf3n+0Vae vfteRStM+dkUw2R7V7rxePOrWrPxdaP5bLN+2Hzsko6PTno+Oun5IE56qtXb acXfj156Pnrp+eil56OXno9eej566fmr89IjVOWsTRT8pNUfdYGxQl7ffe7E LfOMt/HwOO7D3tyWNNh3+7E88xkBDQJo7ZxYO3quZ5ox/UyFfix39d67ggLi zLLvdkJbkJZ/mPPZSvXdJHHSp7+cnH1l5W9Bzs5TmTlveDjK/Uwi91nNQn3+ 7HPTbI8DAievAb2LowHaLkdDxJgNOiBZ1++46M1aDI9bgGqnZ50/ve72+vHg WyCC4zfnF5d/riyVb24+2NquPXz0uP7vf9h5sru3/x8HjcOnXz17/vUfm80m u4q/ytJ+wbRDDmbqSusJtkfySZS5dHAeRD6O9mtIheDI1uvEidAj9lGOL+YB U0fhz0albv9NUqnbf21U6s5HKvWRSv21UimHadK/PllKvQFThSRM5K7KkcEC Tg5+Lkr1xd8kpfrir4xSrS5/pFQfKdVfDaWa7YZNjnco/3JOe6hqfBzD4Z30 lGnhXMPAurq68kWGX7Z3qOLd6AxC+jA0ZnX11vu6U+Puu6k6xbvBAnZ3jKb1 PbU4GrzjrdTqrb/orRS292e4j6Jqf9RNlIlSOu0OinzivuPt02H9Sa35rH74 mK6g8O3Ku2u9IOzcUrQyd1XEerlcZ7XduZWx2q4F/JrrjGE1R70PtMrufPE+ Vtk11pMaDcr3R71mErXedW3dvfsXWVtmqDe4+R9qcdl6LaK8yxIz5bMXmPmM eGMqeIdV9qRZ373+CqOrp04b23f18pnQ9OWS11wbiHhNKvFhFsetd1Xt9RfH iadmc7UKMACkNFau+NE6gIVvvn/xTVj+82b5j83l8hcvizRiXtJ0FcGpSGvH 3t2HrpN9uh5hFnLbgtnYbb8rz0PHlWjNZYBAWXzORmihTKSTiD6hOqd9mAG+ 4LiO9Xr11qqr43QFuHdBfS77gXB/9f2oNFGTZT2g6hEnBDfGfffNqCdhYhMw vTtO8L8AnRnA6OW2cop0PgqLMoAFmMmSTiviW7HIP+sADvuZyl8swn/ruqpJ 3aXOO+5Kt9CtxF9gV3JmegO78KF2JbdeXCXvsCE5RQXRrjpZHdQOG/VHFJB4 Eoa4hxVxz8m43xKpNHtjO41GrXMMlE6DC7+n9Avf22P6SQaUG/6PPy14RdHO TGENVnKdlX03rXliCl9zHWPepi70gVby59ex91taRDUpdJMvVjejWMlkNYGl GB9r/Ww8U57Fg+hkjBE0TqJzxMBRTGu/RKd3qy+EFXQ7rRE7HcOQ6mbAYC3C MbQbn1eUWlzKNEODJu1pR1voH/+01Vphh/i4oE2tFDOVFrt22Mcgofgz8tfF Fetra1r45FufgkXQpXOKRodUFfUFg56M8FaffQxw8F8dcsRpA/vrTkZo9hsO Bt1LbkO6yym6g208hPrRS/gWer0gIwMedrwO77ACDBZmRxI8tKjb0huIGg81 E4ege45hJZEq8HDXdveAiUM3gujm0MJAswYTAQW1bNjWnszAz0hhaBQOKfoo gWk2dedhux32YOTJjVyHlEsoQISewRNpOVBdRhmD6KRFnv7YtJ9hnOLXaNMi pNsdMU2w34k4315efa8K5teV6nnLO0Om95cW3/n1TxfeXSG9IzB5DefHyO6o /pTwjij59wrIcn666C6v8tMld+8itaPaftQFg7PjtM5oD6HfXtRDbRv8bQ0u 8Qf9J7JhE/30Bu9rn7m9uvy3t8/cXr39cZ/5uM/8Y+0zt9+vIdPHfeYfdJ8J k6jFh5i+83xCUnJYQHErVKMWnHzC0Wj43naZz/8GTzO3v/h4mvm4y/xj7TJ3 qh9PMx93mXfdZQI0qGnCins9GF2iFP7h3sEf9g+/bu7UH2yk9yDJ9r62lju3 0rGW/ga2lju3ruMW4+PW8nFr+TvaWu5WP24tH7cWvbV4W0amU6WpBxpYlLiR oCnmGFa3MZI8jUeAQse4Abn2kgtuVXSVq7Q949QNSOeGasrdBQB6nZ3oi3Rc sEkohDKE6cfNN+FQtH/xU76Z19l/bHxSBLpggf/0rSwUe0nYxtF8En9yAb9w f5SSxOtsenev5bri72WHkcmc3GDMh3cjn3erP4/8J4VUPwMBTbdgCgkVJHVx lo18Z9NVhJp3wL8LZWWbZBNuakEIEJS/cIjMvMsNy8IRc2a0YcbfCWI479Iz k3A9pxlSnVanopJXx7aR5szSKiYfOqxpd97pJ50/X8cNz93baf48BYKQ4Fr0 4/Z1pP42FZipsoRxwA9ZCoPSBnW+zoYdheWSqq6s3iqpT8+BGX7HFXpn5T2r aQTUqOZpNGpKSzG00uvkw+jnTq0d9tesBWjXwZSCvC6kw1fi8m6ttt18hlHV /mhUA7PRl0ZiyiKlsE3DcKDyeVVVK6rq4hpbvet62YE3udhGTtozzme7eMqf yOaRUIiZ+MSiAIDAAUjIHXrc58NCwie4hJx4X2rfJhwNB55G51HU90BwhXyo M+nkp5udLUg8QNjV4LiH1bBRP9eTkAX8CcVki/sjQPfENBWjErB7gfMQ1gJs oK+jaFCidNTXZxN/1COO2nicGQEsgPbAOK8oOe2B6hNV0TGlxV9B4vgSwHFE VzvkuQWXPoKkhhnPh+QRRkeVhs59DQ3B8TntvIn8UT3DAKQEt0x++x/Wd2oq HlAABfEyg27kT06iIe7QtgXr2tMXQDk/E/TnHlAzznl3J28VifNRT0KnH5A7 du0RoRORG3ueS5pE22Uc+kedN+RM0G2s1X9sdxJ0OJBQfshXInrYjo7Hp6fi K4PrR1AytByuG+YZToYDPE2GoxH701DiGN72FgcYZ5MGsENR5ABQuQxtRwLs jNgwQhx16wv0GgBQcbcbn9NpE9ACMPx82Bn5niJc30DReZfOxsAwAZEbo8jh BrBQgGaRet2PzxECbIdIAsIhBlww3tcSOjKXKBYGDkyJkD46Oem0OtBHHIVG XBKkRU8zbl3cEO3EIclL5VjoaXc07Fygvwi8N8fWszciCZpJKytEmMeREz5T 3F50L0sUg7ONhRmjz4BzVMfk5yU94uJD8hyxH3XK9KRAu6ApBQBBlL5KarPk AedVAVmUQdiKNuBgtU5NFAsw/YGLvGIPOYsm+5F2bHMDA3+M8nYlUUABmM6h dABRNGy3JdCAKnAogjJnc91dCDjc4xJ1BH8cb+DoqCQj0Dbf5EuR3XyYwCPs dIWDdOSX8ggjn186zaU+fXN0VHjBesHL5S+aLxeR9/ISjo6KG0cU3eOouHR0 VN04WvgOfwDkSv7t0oBDupB3l9QwSC9N98n/TvTtuDNkj1Hk5I/GpB3TcNmh 8ToDLc1jS69qKLSTg5BA66CN0NIVaF/etg99z+jNjXAF90a8aANefIESmoQ8 5vukV1Fj8HfulkhHCcyNB22mroySTlYeLr3j8+f7bobAcVTDwGhb0QDHfVw3 IbvyyYDNzlwsD8D9lL027YDSbPP4NCRMjSqLarFCb8QWdaOwT8ATHfDGbNjs FCV3scDxfpA/v9jd263hEYeTNhCE7FISFSjgQJrkLSy6GBBhsTGDKgamk+gB dtLR2Qo/oYeWG2qzfymrnc6DsCq+IndXdNRM0FsNVzuKmWxzMF+9kbFHGlz1 QBdlYbbiLtDlIYbGIzyVrZi3TJyWfhS1OcBvnZzvDIVH4YJCltAhTwlJEebW +zvt48bL0cVCMuSoatDVihuQ9M0A6MJGfukbirJDHaKnjRffrL1cXFhq5x1e iqd9AWOz1x81xcmime3JCdyuPWxslLfpeCKFHuNIPhPHdNj6XGUpxyFimPNK VDeOXxtfYrhTeltiJVhTC995TdgwDAlneSsco+FB/BYHWd0Q9jDVNzmIfMJ+ +JIz3OqjfjQkp3QclXzUaZH4FgiOt49TSGjDWdLey97seCsZD5llkSIhOyES ZtQ6YgI23oIlP4W8S9Nmi/HqYpjeVwX8IVnw99/DCsaHct/zTivCpeq3r9aI u1tYllOJgG6yez/4siXxXxRMEO69cKBoj1tMUU32kuZDPUbGcC+Ugy3VzNR0 0eUZMYLE/8E8okCslTTHSXgabeSe4s9aegJeGC7mJT6Lz0V6BmQZvMzpaybm cQISCbLHuaMFkyxO5wxD9L3DHNln+2ie9IP88k/RoZ3ATvURw44sSj6u7eyU BV/eZg80QOnHZUEHeoY6xtQ1pt9IOt4fTN6d9OBRJyaf7aN50g/yyz9u71OT dWqWBuCKjjJuInGuVKqruneABcvSKpxGguw+yC//uDXSpGqkya17oBaLszJV 7R4t0g7IhBxzv8m0cUNopE23Ps20u7LURidOHEyIJkH1M+3OARigtRffqJeL S8AZvZpBKZHKyMk4kwLBytofAuPSAibmNCRXgccR4l3MW8CQZJwJCk9JpImV E79HHLNPPknInCzd/HLpyy+XgA9d+vKmfrp5erSw9OUpPMO/8JgsvUDG7tOb L5fod+kUhjDB3Del6JdYmp4w/83Tpbwrz8Em4Dn7aAs7saC3mwB2XxhHfEpu fknI/eXNBfq9eYpJHCMN0vhBEvf3TbI8yofnz80HeeQPD3XyQycR9yRIwh9O 2NnW2eRJkusPKA1+OMHhDCDdeePP5oufSNKYJvS2nwCl6jWROFOmrA9cCJY5 oCFk4gdOTExq4iZ3O8cSMBW+2Bf+CCxdyF/kSUBdJsSXMTTzIh9JQoG4EkkG L0FqjWHPc/J476ZhplEmUbsEoA/2hT/G3bb33XvX5U9iXZieOLkXytDwAyem nOzB11SKn4298zm5OMHPhC74nCz4yhn2N7f+sPmoBt/kiZO/qh006nu7kCxP nLy5tbO3tYk4L0+S/PRwDxc/psuj/fBk8w81+YCP9gMbf8onfuGPmK2++3AP PulH/tCoHTYFnH403axv15qPdveeIL/25MnebvPw4GmNu5z5aXrBh5s7jWkl 6ZuMHAU5xIGjB1k2Os4xrhT9rD9ZfDfPLigTvtXANClCLraQUGzxyx7N+Z6e 6AaOVmPPg2eIkffuZcEQjTYDvhmSxdRK6JG9EECiZN/gc0Akkmj9tI3gSHaC xqDLQh7vSJ/wQf0Y4yuj7LWtBp2oJQ5ugeYnpEOAYq1eSJEDe7haVH/cO47w brXXGSUYFxcOMLCpbHdO4RTYRXe3S+xI9/F++enzCm6OvfCiCQCbrV472fhi Gc7jT8KLTm/c08BgC2JxzYgdBbPPUtyS2OMpAiERWRXK7poymiemmKqY5zg6 pSwP6ehEtwF0HEjni/ptOgm6DYNiO1gghJ1oyK5YpwPowXG0SU3eWCMPTbp3 uVxwfoY7+4KXS66eXcNhaKsqn1K8VnNWJxagWqLrN/j+tr2u+Cqu3377bS61 Tbrb5oIMkHtWJ2DvXNxzdvuJeyloszkt9sfiJNSV+zL/7AamfRXpQfRj7nqj SwKYLLjCJzoRsd1iLnThtGZAEWfBGudeRRcDUQTCif1MVV/p74hvCzzAOglR y5aANyiQRrVXgb1Cu3oQ3J7ASsfT9cxVTx8lEeXfjQ17LqD3suE/c29nMpJE P7RWHomN4XhWMfkIGGK2csQGeiQxKstFxUoO0Jf9gII45+CciFlerMGe7PxW KpWXL+FkL+IZugroczBoKVHp9HMVc1yzVbH4cw3YeUlqdvquvzTK9T2zsTdJ TLF2k90tKX+is0usVRYxuzkzOJXw+sK3t9g458RAXd5sUwTU0Lg+VnxiKAGh GzT1MxJL7bGZaK93jVBhUAcs6SG6RO7TqRgSZhKSyyEfhThK7aLoEq+k+KqH 3ZgDSOQYK4xReHxxtHugA7q3Sy++WXqJ/y0uyCBZ19dckObWGX6tQOB9rziL WG4L5MKMibvt4yXLVjXBaTtwAHLvNfqZN0l6mcFzMxmfoNAtt2Q7Asm6H98c VZawAzlpwqbKVSpLORrhKMTIB9Z5dV8XFpgVU008SjY88JLDG63FmwD55ikN liFBfiMNMF76HhK7Z0pB5kpRCapsaE/waUKB0IRIONhksmM73HSnE1DQNJ/m eB2axKiLvvGlwETT/AHAqi30jH7o1YKoK8iPckcRpDvFsD1X1CV6kn51WeVS KzA9xsaJOA3yi6WFl9BAzxF5Kp/uhJfHr9jPq2v2xYl2sQR6a/SSrGCm0wf+ ZyM3TWZIEQX8dQtF9GxWFgnjfclibirB1LsAkzTg71Cwm6t2jo5Q3pdqU84l f5LX77JtD2RPNrJbSZc8N7+5mZ64pZs5+bZ2U01+PM3h2tIAFkwTkElONRQY 5VSKnFOHcgjgB060OAUf7It3iLPnN0jOuT3CfgI74fjDMbt3EUXDmuc56axz fIE0V7QY8E0qzA72TVhsVvMdoDI1SecTluPmNtXu5pOaesA/W+qrzZ2nNbWd w3AoEd1/04eO3K4PBqz2LYIfrcKL2waX7Gj39t0xXyEkkpXGni/1Ed3t/aZk 7aucUb7AGglcjll4Yo/bmxtEgQt0M3BUvCFPXAgf5UOecj/YyHMGSX3xDf7e PKreOFrhHFuQY5UftzfyQGq5aWO5dMyJ7xZsTY5Vn02skeNuiD7+6ayT1Wxq 8HhKg4+KBNhrHTVjbNp8VOSGMmRp5XgL72zpCdp7dMu0OJra4tgNkHKtRkfv 2ugIGr2Q0drItDaS0XXCG2rWUXxGSaiLT9xYF1cJI5XyYWzkjNzzGvxnZwYL KgA/MqFTmdDUvZYmScHEEe1kGJ7aN5ECa9ezH4S8Ixqkqet9t0kcxBFJphaC umphtFhcsYEtCnQrYT7ZCECiRK5ZB8MYA0myUggD0diJo4ASCb7QsslKbQIR pfvZtfcpaJ8GijSM1bhPqghtRbe67bjFWsaTYFITi51P602i/1hZXySyZ4H9 p0u478HrwquXNzERXzX1AXKyWf5jWP5z86U8aC0HtchqDjcJD9ubb4+q/PTA PG29PVrhp+23N08HABaf8Z+xeR3jPxG+UrNE1eLEb7Qz3/dTXUx1G3IH+nrU 2VzhKDboUkAYocBs3gQfKQCV4gKoO4eysCTEWDknFMstughZC8ko9yQ0p01S G2k29p4ebNV0aDIAMBhG7p6rFU34Gpavr+V8Rtu3o1SG4Xh0yF9EHGvOhXf0 jkKkRW49mTf5Wv4G/UsdNJuA6KbA9Dlu9xZvLi2qTxUwjnptPaAAQONBqgKt IO/eu9O5MmRRIHRKFhQpysK4eGia8DE37rZZtEhFWbDIkkToZAxH3dQkjmA/ FIHaGl/Vhi2RNYmn7Jaq+C19RXRef0Q6k6ioh+YScj9Nu0lf0mhP0fOB8aqM euTkiYvqzVH0WXPclbRy9C2q/tJhjCIorbMU6YZ6hkplepCiNklaUytYKI6h whVNtvMTRoJEpO/dQ9FvfnLLFBaZFhrKm7AabuHbb1PTmVWW69ziHTstI5vY Hu6nN4jU1NF+2Hvj5fK+Tu+ASEBTXWinu5BCk4kWEFXw24AZUxmyGHP6MJst uWL/PDMa17C+9KYG1OVayiBoHJLzyHVaJxvHP/U9a/gdbTLNP9kyrrbHhL6Y yd/B8Nets7B/GrVzWaLdM1fo8X7lVFaMcm1ZlSsp+dHyqmtKrN5JZiVCZdEk stJwHz/P3E+kOScnx6sv/K/mpC0x87lnImk0vujbA7gIQJn7in7LZwFH0V5m 8Ge9uK0+u8jUj7Kb82JaU0+U6Bb6cZP1TcR0BiueqrPi9wGbSCoQ0NNg7q/+ L7oYAKqUq5XlyvLS4LIs1hzvtY7q8jKauswRKi6nfpVaubt8R6m7yyu3b1fv wL9KVVeX767MqeX32oopf2O0RFZqDuNbzsp31fe/0b8bn1gFQKTwIsKxmIAK acfAQSKl2K4fvFT7X/OFChxvK3T+fsFrle+Ic+qlIVCcssH33KRsKYA2cM+i U2nVRE01tRSDeZ1tYSWYT846JyMMkClhMFmdqiimrlq57prtzeliDy5JvZxL EE/FrdR2Epq/Ts7IIvIYvkdDPMjh5iIw+AKWDCdoQzhGwxcKKql15oEVDrs6 sigpQipUKCHFPYDC9Mp2TPTJTN+cTmlVM1ilfkk+PtMsLNwAYrXsjL/eI3dj 2iESlpdh4xaWyZpoxSqtVSUQNUDSo4camlSipG1G3eEAvjUCtp36itA55uxx BIOEEr5jO8CiAWoxRSrIeU0lfaGNHMXg3FAscDbbtf8xTiokof9T3OkX8hpc vkSlimRLGQg6ImudCzo9kqXA9l2CwiUJzlaCOdfWa2j/hSO0ofL5/MIi/BMM hmhgl0dMkWnAI66gCWwvqNsMKJUnqY8W+UjYtwQVGQoEsrhGPVigLujrZDwz 6V6w0mgBn4toq4TfCjCeknJ/Q60Sa4KvL8qray8xkHy+MrjMA+h5NIrq9Mc8 TNxkNlSi24vLBA7bbWBoKyfdcXJWYIVD2+2K/HJd3OWc2cIWfh/QUamT8EmP 3D6Q53kehHuqWrldIssYjrIqIbp7aNEzJPpgpmHvLzwTqoAKsb0OMlw6fnlR /X3Oj6f9/D0cOH8Cn+Ht/+x9Zen97S78p27N3P/pxd//V1ZuL8+p2++7IVl/ /+D7vzf/YYv0HSu9W++1DuD/7ty6NW3+V6ord2+n5/8uzv9H/u8v/9fud5Wd dkfRfeLYL7mA5t8KAiy2FQ8uWWpc2Cqq6hdf3Crhv7fLn9PvF+rhMIpUIz4Z neM94UO0lCReoKTq/VaFYHgWyieYP5H8xBpMBUGFWWY27ovIClk02AASsQht QfOQMC+hIUcHCT9sVCiZLFFhEqfCJ32lBftI56TDzBkKAdFaB3aZUFwkAdXv tCIRlybR8A0aL9kuaON0MnHRdbW1BBZdWYmNKMcwRw6K7Uy4MbiFYnCmvaeH anP3a/Vs8+Bgc/fw65LmJDGWA3rqwB6OxA6hG56v6+YTlIi4Owx73oP9DTLB oMGuNiKT1ye1g63HAHPzQX2nfvg1dv1h/XC31mioh3sHapMg7G8eHNa3nu5s Hqj9pwf7e41aBVmA7VgEIxEZvRIPsEn48TrSnDJf4RqfT2TJOYpj1Ru3zoC3 RfVMZLPJNIUvjsmUjO3AxM7XRHLn4q1oiAbfFP38lK4dHhCrQXJvZDTgiI51 heq4g/fGgMLYWpidDuIpTw8fEOhxE6Pz1A+bWtW4ILWVhGEoqRf9uMwS7JfF INjcam7XHj7dLaQLloIX8O2g9h9P6we1Aj6j5rXWsICioiu98WKh+hLBNJ4+ aBwWJLUYiM40fF5xPktqkdpKggi6UycjaL6A0qbljuGUvQB91Wor0RkgO8Lz 9isWKL3iR+M+5URn823LDC8ODXrSeNSsHRzsHRReJDAtrchRQppswzr5B8iR iSBiPwlUcmLVR7dPMCTktwQZ+sKLhdWXpZKMbn231ny6+x9P9w5r23qASnia 5McczMkuWn0BBstsAayMojJ4WFQesehXcmyy6rsGCEGxU/ik2diEKf66ufW4 tvWHl6mvW83Ng0davf4lz9DD+vMnNXMLMxqOARNPgX0CRCUq1D9lgSBOS9hq huOLpjM1AdT4pN5o1HcZbkEU5kuazpbUggOmOJlfFOlLxh7pOiUIe4W2v46u U4Jlb1yGnY9cVUrr5JfIaBTtGSZKZCweLNVs1A5fFnHpkb0eWbHBGiDESsZD oaFIhtChUVtF/TedYcxGq3hYD/tk+O8tXHdaed0ictMrtLjwQgeimwoRmnND /ftYLkLhrBkkXTRDrQYTokgtHiW5KJFNtufWcllxwBGjSSv7AIC5Pj5mKYJR 3qZcebz21R6aUBzxBFswgvVX3hGLW2mOcx+HFrSaAIdICS976EJp3b/FG3TD S2hBZ9hWp3RoZz0UdIIQt6k/FGyJy2IzCtEpbcQPGtviPiaZyE4Xalwkn2hX HWw5aUhHkYQABTzjoLXwc/Wqm0B3Ril6NB5G3kjCeUeZAw/Jzg3Ne7HwchFF tLnnuZRYHEap3WmTbxDYsbQc3Kn2qlqpIhaGp6pDmvr8itLWW4AR4ruFve5N QNJ9MZ2pw4k06hCakrevqC0iGcAjuds8HsavIaFrJFfod+QsHAycMemcsH8O Ekj1W7D8XYk2qVXpexByDQH1kZ8wA8BUwj4ZWcuP2BO7bHT9Z6FFRgOAGwSs k1IN5AtC7U2mRXIlPFof00CiHsKQ7AxhBeb09Pk7E88iQgyHZJGB8glcKQ65 ELty8pEgzQ+47bB6iONwmv6yKHMe6CsTnLQVRDBvZcPXYqCx7YbaY/Qyng5S zUQXH5es2RK1Da8bd8n/6RnMksswkkjik4BJH7VPDxBsCq95G027KZLqDmqN pzuHhcsoIQoqDI9HmVExq6RkGyuheLS2dbh38HVRGNnI8LE9pDascQKNN45A rZCy4hFZt5YMIotIh8uQNHtWitqGPEpGPmkUQqXlN0SGzphhZtGJdo2nMOIZ vZEnAnLqINN8gmeEEvPCyDixh5RO4vhFISN2ecMMoj3TDVtoYcwz47ZBb7CI tXDeYSq2sOJIbNU9S6GUQ638AIFqoYoibYshMmXU5KJBH8iVW1hdkh0TBiw3 WUQ+Ej4YBnKhynun2kFbJ0j2rs9YUOcf68SomvcvNhry5tUHEPBmXYO9u/Bi pVJdYTbJy1RAlpfx6dlZlFL5McdL9PSgmQmgYYRt5KiDfQjIlZ60yD8nwukL aEOij1YJMocOcyo6pVSrVMH8tHjoMQdcmMxnUjMuvwFizPCSndMO8FLYurbI reX4mEY+NzKy0SVybilHiwLOcPtPD8kgcHN3u1HgO2lSiSrcu1e6f78IoDQv PAhHpGQFXxaq9++X1L17aFbNT5CVf0rBvXvmUhRy3r9/nYvRDNiog4kafUtH xd9XFjntCL4VZcSxMmgd1xj2mp1++2KjynqNPaPXyPDEVIwvclRGq5TWNZSv GkJu8d694v379oLCbTTfn3v5v9f61Ea7UF7shbo0f0GaTKCtdqFSuits8JTT 4DEtx4ZSeHlteo++gu2kvSjBaYEXlvDmZTHfrfRuQaJW3pITcLvNOEjOKigN 2X45x2svKdZshiTsgJuvBHYe8oRDcsuGw84iWUDWyZMtrE85NGg70IKurmhX 8YvJbC9hJQfzvLy364dwVtrcKWRYs5bE/R3egUP35xkF4aSnrXubZDBKR0tJ 2TDfVCoTlMf+kP+ThaoiTdjJQuW6WnidU6JMwIO+zSpl6Bum3+6gfIYO+ik6 pTvCVEoTRDLlLbokkk10i0jDF1YMaZacG/xIWTbyN/KaJuvPmOTkAOqLTfRm xm0W+nlp8g0ICvyxYbQn0j7ZKMgXfZPBP9XKbfN0yzytlvpx0TNx0tetn3ih XM0+4R1wgAmqDC7lElDu8E7jlz6alxQRJr6AEMvkjVfOPVreub3B4cPbC9kA Xyy/hLWbq+ZQrOSmr1D6rRxesvAWnruZLHU7x0tcB7wkaNcrx/Ikp26qAgJg XwMlD9ja6kveJadDu7J8/lVqbauXptv+Fmvts4uzBlYmjwR0zDFca4DFvvvn G2DHzcM7j/ISu06Qq7frgXyngZfRKfoqWyMyQBGNd5Yh6ntxoOR8Hw2txXvH d14JPtrnFwrcjyL1m0eQvub/UpjiowU0wBnN67bCGTY6uRqy5zXQSdUFiIrJ niIU6usne9sF+I+MOV6UGl8/ebC3Aw+bW0hny/WH5Yd7T3e3vZTdvUNOfflS eEA+yHRQoZyxxRENoINqUkhILnvHcRe5szedpHPMTqW4yf4xw2laWgTrEVuo fHDZhApdl+TVF/lm/iWw7dneyLPOLEZgufKy9OJlqQQPuH29LHp3zwCa+eBN KNz8CvZSvMB9Q/Uv2HaU1IsgBVC9wPPWhnstHoyGl2vBvCQsVIPoohUNRqpO CTU8/MBnXm2dUQFq5gxu4nIxcJ5zk/UA2IVqBQ4WL3kfdHQlyH8LKYdAjx5u N7e28AyjnwF7rG4JGZNldpV9arvu+GbkRe/XhK88a5ATZozy07wdae/WtnTe KX70KvfK9QbHENigxtkXJ8/ItJlaebTC+VXwGDBZkqb75fQeLMVu2WK3pBh3 IwgmuTXgYdp4akElIlYFkqsP9gNnFGX40EvOdHWsjmR02dXkgy96DAlBEw8P 9R0VHVHnYpUcippembzS2P+69rwGncQVxRzK9DWVQdkcbRDxTK3z2dUAjDZM HOdqCucsUVxeePuj2Q8yS2zkpu+VnGWAwRCOcLOSBLNhHV3NV2Ttt0e56lH2 jnuUu3VEey7M0aB7dbXX2209YN6Gywfa68LjXfsoV67fTBT+wwXNMJW4pqI2 Op/YmGkSUz5m0KY4a15yE8tE5BnOTpMCVQyycIku3jrs8YUki/tCZcX89wrM 0tlmYhYSDsk3A5/0+GXPwpK2R4YM1+F7clqrSGtho1G10xBfdO0LDxcXF9UW LmiUZCMJYVMwHhiRcmg4JPq8hIWPHpOBgARYWEuRsFg7ehN14wHHfIC+CrVx ILqqisKTiD44UeRXxkmu+MDd2tpgu012H+vNxxbawlbzS4Oczb+3fzi9AH6c KLG11Xi8eVDbnlWP5Jgou7N9VVmTY6JsY296Kfhm8+PguLP5apKCGYyjhTFj xfnLCI/AmAoDmVp6W1uIUzheqQ+QhF+ggakPjb2cXdHs52kSKI+FOlooAJyi UwD9PqWz66FTZdijXyy8/DIXuCt+a0vWnElBmKmkxl46xWvhlI/YGuZYf27l mb+DP0//SywH37cG4I/Q/4Pfj/p/H+Ive/7xlgD9Opy34bT8k+u4wv5D3V5N 23/cvrX60f7jg/zd+GRpnAzJBkQOGHBy6VIYC+daJe6Tb6geets/GQ0UiiIw oyhX3Zi3CKPujeHgc1/do9d42L4feFrfKOzXet8BsXmMgkoyLQbBCbDAg3gQ 9VdUISdQUUyPrFU4PH3zogoHr9wgVwxOKqiLBLmwojUFKQi+wgoaheVKFbNQ uARmm6k0MPCfqdxR/z2UZ0ZRK5XTNVJBwywW/xY2qOz1D3Nc7ibvY+3j3xXr v7p8ZzW1/m/dulP9uP4/xN97Wv+QiMb9pBiLi98UzVj9V616WI5YhyPM14u+ mF72R31UDnRT1nLOks2F/bh/2YvHScZqn7nYc+0YHs4uvzzv/DkctivxSSX+ sw/kqA+tvK+8+lptaDZk8xq+gsqGGcVm1N7lBotHgSqbqKBkQIOhIbqfKzEd KuoTZvdF+RYboPD3tWCerPxdu5YuyjbQNdIyBga7fefu519gPiZl3Rdr5epL pyXHl5HX7b8Jovbx79p/2fR/FHX70ajcGryXLeAq+n93ZYL/q96+/ZH+f4i/ TPov8RXeRKgiRGYUmvi7vijJixHbhDgOB25oBzKJ1daVwrhrqEQcW70aj6N+ K25HqtzLe3uJRr5whFd1dk/pxqedvmYs2/DAYCkm2RK0gLKgdgY+ZzGd0Mkw aXU612U/gfxxW661F2HrvN3naobzevzmqi1+AxqW8BXZANo+GCWB3RFu4Haw gP/cxy0B1TYMjFsvZS+5eAH0nSwUl/K8rWC+Cyb7VMSxkFSFixLqNaW2uKWb Cam1wroBEnGiyjA+6nvlTKizCzI4NNUFaFQNgyxxU0puG6HVU3e8/FE/7+xz a3d4mzuOYNjLdqM7dSaPdmPT0gtsqT+Nt9+pxltc4wb8mfrYdButVTVyVcKV 4yaaJN+5pQpdU57C6xaSIoLg5zzZh56a6X632bUTgtd8P36Lnk3/aQn+ZBpz Ff2/VZ2g/6vVOx/p/4f4y6T/6J0lZHVLIpGhR8GPLxXjx89E62fS9r9vmu6Q 4XA0i+pamvq+CezPSy4di/mfl27+vfx59F/UaCud/nutY7b9N+4AKxP239XV j/T/Q/wZ3et/QNz/+DfB/+ELa7VVWu+tjtnr/87KnYn1v3r39sf7nw/yd0PU eNQ97TX4fmDScqyBg+6vbb6w2y2Lrhdmhi8n5J+WlcW2a1+ZgPcmBQ58aBEF UKJ+u3MSTOZo7h9+/fy5W2Iwunz+PBcEwdIiMgVkYYEMHJoOwS6PPm/R2gde OoOoovKdfr6k8sAY5MlMJx8Nh3nSgoHCAzh9jiIxEkT2RYf6Zh+4IZmpk7Ic nFKBvSVOkWFi8WF0IoXZWEzrzHAryEcDA7qUeO/EYlS4NQjANohACST0OkEx qdlEzYdKjDeW9SEjpzKts/j92PjjD8mZ0bKOoH4esgPXzmkftQHFxSwZg9ID Vh4nEY1mUlH1Eyyd73Uu8qiXWxV70+N4dOYGHZde+E3HktIWYqyII6fGIlwF MF2Q3Ha0w8JybvsVWtBV1D6x7SfxEN1GsAJUX8Lbo+LVG2Cyk4immV8Lq8Wi KpfLMnJk4RV2McQ92oUSI7z8kp19YnBRXfMIXWv00QKNzKFDtVxRB2LsXK4S T0qR5NH9RQg41GZHweUVsRDGgSsU5VtF7aHt6XkniTyL6UGnrQerBXx0mxTV 7ZiscOeszSLK65147uRf+5KC2IesSNSDRwoUwyd3pd1NyQRzkHs2PZIOdqHO xaUADfI6LWxQE83KO1C4iV1o8iEJ7wIWO330IQ0PAEyeoF381ENdNzTUHaEu 01AtkuqdPHM6DfXLYvAda95RTQM+ASCEyD6eLMN5qqROqvyzAj/r+iRQwLGB U8AKusWDg0MBW6kKJ8tFOPzIc7VY5PyktTsjm31e0UWwiqiovgvmW11cAFAE 8AM+Ou9V772a+l6V77qxn2BjESCC15lWpJCfxgXfBvOMJIBN3Ki3PGR4ukKE KzhtHeBglKt/NS2uui2mBhIkfOr0DVDAJewMNgyLc9SfVIXLFjiWBqSzxZHK bCjqyNTyupdvp3SMZno4pPd5xGSEuMIQqQsG6nzWGLwlyNOG/JpDmh4+WQ+2 alwOSPdgv+y0ouY5LDfnddiG0t5ndIfIYg1jdAxn3b3ms4O93Z2vi372YXta 9oNtnV3auqw700F/lNjG9njg9JtXmkn3KnHAVDUYnE0Xjh6v6XDOh1eN54qe Gj2zMHMMXQ+0pgk0qQIKc022QxoyoyVX48CHWHaSNG28J1qtt0gmz0iSORWF +9Wiu3YFI5fX5+fnlxbRzdUbdD2CTqTIWgc2jbeW26PI9xLoE3k04wgnGcVd 3K9x0+92jlvl25VblVt3rJMRZMX6Wvf4LHyDFzG4/2J5crI9Qnt/8jOF/ljF aYk4mKQdkVxe6N0Y+ER2m3gy7rcIbIFCffbjfhkdlmgAlJjE3XDYSYoVtQus UDsKJXA7uhggRk17T9HVs8mZ9rWPY6B3TlyouJTQOT9vl2EvhGyyPy6GSRea qXdENAbWOyGloKv4Fy9hOaZYYJ4Rd2MdlNTit3av1JUI+NHo8rTTFrnaaDhu jdAJESDw4unQbhqFUyQUp9HoFH2Wowx0dJkDNgkwcPfpzg4sCYaDmYbl+6fD pgHK68J81vQemQ7ci4BR/3aYjMZvzi8u/xwet9qozr44WFeDzz4j3KaOYjAB mO1CqrPAp6lVHAQowObBhW8RpNVMIIgnCPLbdfWtgMT6rwK7QmC/dQhEgUfO UECEwKTv2UFJLReLzsY6LxSlH2NibXevtnuo6Yaz8aW3jexGYXPwzk3lR3mk NK2z+NzUD3My7qDwUU9lkbOgbx3J0mjWD542DoB3gadn9unRwT5lps4ROszo 2ye2b7ShhmY0+GHdfNCQ6FcnA2q1BoDoiMclGvziuj8ey/j+1u6dDJZyXTUs g7xLXi1FkgmQ8V8PUqP/1luLQgvSa9Euv1KlUtFLMGMhDTTC026lF/anOten ko0WsmDKBBOUAJGDI0dhQEtFWDccdFrT6CihXF2bKEUflteCyZGjW5DmCBtC 1WMaxjgjhIFnILuNaISIg8elJGLfh11xrAFQ0Pv0iGhc/038mk9VyRjJGO/t cWvUFdgldVjf22psHaLXwQIPW1FVbV+d0S+UaV+HfXIFdpY2Ypj3mvq6oje9 k7a6T4y8s7mZjlk8shiQgaYZRZ2W0SziNkWChnneyj7xdiuXiL+JOxQ1rkmH ozhh7DlpI57ATmc2usOtR7XDzcPDA5fO6jKw6STciB5sEjAfhU8xCUalpDTW Y4J74hi1YOGHo9GQR4gK0CJdNli1rlvwoPrFyvKyftvbOtjdIThYptJqxifd 8FR9uqH+rwLwcFtIHSgP1HbDOtBO56Ws61og42TpWnC1rcd7AK2+tbm7t4sP jfoj6YNk7tjMdV0nN/Orw/qTmpu11XpBabjiq6ZinftJfTedGZL8vFPqbRwe 1Pe5Yh07sHC4+WAb2Fm8+3eSVot2Q/QHROkCgOyccX5ixDDdtAWwqt1J2O8Q ipaAWxoZ881vGmuIZJntrT/f27WDtF1vbG0ebKe7LsnY/ZXbtycGq7a3s5Iu gmkz8mdkn5Z7Z7f2/DCdnxKnlTio7R/UdyfKSPK0Uo2njf10EUyblv9Z7WCz MYFSnJouQ5laibvEDrcam9sHm/VdvdpsBS6t8Je7ML2esAT3hiZGrBo27X7j i0qYei7yLvwuQhK7L6Er/3WHXXzx+bLIRIwgxSVQmhOXtN1abbv5DF26/LHm kqzzTp/iOgEbMIanU4z5lZzhHfl50hzG5+tZ6a24m5l+MehcRNmfLuUT80dQ q0uLUm2Rr2beDBE9x0F1aCi8axI6YAkPDETRbvxmr+6WiKuFicYibtVXlCt6 DXGlLRObtiPpwBN7POIJm5ctVYN8WN/bfVDfg6ZAFtzlWBBieC4RbNh3xBls pN6AYbDoONp1tsiBu0V6u9eyloNlnfr4g3vws1suITlNC4psm6QA/h1SObx8 T4BTQx+7GB4QDkclbWNOMcP5MHYeI1P4mozWE/RX2cEv6EcQHa+FCXlS67fw 2BaPT89wXek7gIPa5nazcbhdOzhQ1YlU9Ii8YtcBNofbbpCO0skr3Do2mOS9 xxFwQUnC/vUYK50atx4/3f1DE9eGqt5Z/fwWjyPlQlzLgr/YDkdh5gc4Lsat yD+B2TFc7EcXo2nf8IgNQ79uxp7v35rx8Z9Qe8WSBFghTJ34/gHYKNle6BA6 HtmviE7+ZxgZ+cye8+Ar/FuuunmO0bmgBhLRPQEen/8cDSlaKX0WEQAWIcfY rXjc1xWP4hFwmhjyI2GRv2QUUgU8mZYp8N1GSgqus2u6SPEP17k15DFVh0T0 8uFK0XCTaNyOiQ+m9SP5Jkc8QrhQ4NtxNIYZxEk1/oztXQVe8RBKAd6TazdI oBLTAeMl4ugdQRsvrgY2ogJiOJJwqYORYP9yj3CCXKu5TfAxZhF+AaEge43T udS63sGA5J2HwzZ8P4Ra+KPNfEhrS292ukq1aDLsRuek0JlRcUvvYKmqYWSi 7oksAHhC0jaRpWj7t1t7NpEBiKfXRoeNZpAu16x3TfxSvg/NQ+edHrUr2J4V FbfOP0kSTjb1GSO7u7Lbs1tDs3tDi1rl+xjzjpskMCjNaTW84zqdyIQyUi8X 4slELhR0CmdAdW0ogWeFM1J0w9utIJHO7XRxwJIl2FIGXJ6WzWcq+5CO4kUW SEjOki+JQOkEySBZsGEyLcvBcHFgTvlpOMt37tyZVZRCApimY0Zp64Z/UJQO 4sH7PpTU+zJuqTgO52FnhN8kD56NceKkEinIw6XxaJgpG3VQhc6OBjHR+zyQ yQzsJhzTKDIFnabuEFb210KRjEbq9axOB/OvUXJq+gintcPawRONLC5Wt7jn DhAhsUVnyHVSSuAHX5jaKZTyQcK3NNwouBuU7/N+R6d9eJPN0UjtNG8Hn5BA 0jzDM6Kdlnlz9U5ZlntLsiex3r98EvUAS3eYEBTTC9lMBbrXwUv+KZNTmqRa 6o27qB1isqHe0NMEwfHz3Z/IppeivHryqwxaO4wGw5+ETLTEj8cnL1Zu33lJ 4q0Xq/pa9Tq4lJBB2AmxyyWVCxO6vL7ZbedKwI0CB1BUnN+7ek2VKrwmtYpi TjKZz9Aw+HyPeyedG477dNGgd/uj3M3K6nLC3msShQqv3Yv7uRLjibIYqlNg PPDqwcVd6Mzqsvq9ymHwN7WmcqY4NlAedXd8rnj/skG2C82HsHHzI7XbQzMa ZW93ajbbcavZJNl+zkQHwPt3VGMF4sp5FXc6ya1bbRgDh7ymFd4UVQH+wUlq UmFAvtRO6GDQtB1dbQQZPAQ5f4KjD5cTYJhrucQHYaiTTmfC8eTcmcqVMMdo 0CQXp5onkq0jhbLFEmc9DpNOy4WoK4JvHbxccT4V2hGjdjwsTlBYgafprS7C iDXut4oEmfKwSaPOIQK3VB4thtO5ksxcSSpXqzfgHGkSI63TBEfnx9WcKoBJ kpvW+uSwhElT4lZkfkuib1H1O2tA4WsvHAwclr1wFiZnqU5hkvkOR8h+OLxM ZUE1m4xO2HGxY7IM523nP58ZdBYGMbnAJ1P4jDWlo7bR/hL3Iw4ciFtg4qip 0F5r9sVmPzonpLmCPUOxD/6OCLu/yzi94Sb0wh4HtdZJ3z0IZuzKjhBi8mtR 9YQV0EsinUdLMcxu6Ik5puWGLREPjLwD40FGpzJtcI7GtJY2+NRBsi/ea20/ XQ4a897bYJ4JpmUYteIhe5ni8yLeFch2zTu87Msi7xgQqxkjk0XXNWl9hilF C6lTtD9ouOfD4NCNk2EV+F/5bJkAYR9wRzNThh37hEeJ2V16dHgXbE66pZyJ ORj+bst5Ehctnn9rKfeTzeeFi9IlEuwL3HMK8Ph7hc9r+Fy0Geu7TsZ7kxkn DyLazmEapmcIKkoGhVOsAmp7oyOv0RuL6ahhgpNZkmO84axP2kj3CI0oRiM2 BB5ku5e7uWWHO1xfp9EevamM3kDRlqAIv49twsPt5h9rB3uw/Qjsopco9ehL I/e0pPlIyNyoHepvcEB0AOF37BDMiSr0S8ocrLRikHuwygBIKm5XAOQzGACE FYOOAxEBYZsngcl5pBqH9Z0d1FZAgkYSBAp7JQoFIg5o5xNzEUcAPv2UT3RZ jUJRqDswGW2iIyY3iWPLkNgGm6ejhIiOK8fPOUFFVC2gwHYMtQQT2qN1fobM KCKqFfroKN2OjG0PUS9sJFcI3SDMA7xeBqz+dPRGz+QQEH7Zv0kcyqdPhpIu ZkITE2Xv8WFU6o3sycIr+qxdoqUnreRKG7MQbEo1PpLNrobyOuJLXc0nvB6z emklBpm1e5PPd/h0qGXCIBk88jivx5uhTugtzBPClTdo/OeJQH8mL0wE5I2J 3rympzTBfhfSZJGJyPosFSKHwrGr+4nd4DhsvWYahk/EiJayT8epgughkQvC QSB7y1+EU/9it6QuuO0XFGy4336BJwdUSCAhsrQLa0eBWeJEYtOLiYTf2Bho WXhZgsTuiQmExKcFzRnz5mclyDicpmOwJqRqPHThwPOrzUASGCzXtYBgLUop CxIT7m+Y83Qw7+eXdJdeOwPPR6AEt6RUGkZl+eyzImPBYoKnkAurUwlD/ZqG 7LU+50AzTjG04omExqBYwK9ejfs4WPn8lIEiaK89zkA3qTyRZjullXAIQ5Fl 6A14bOGbHcHPAHIZG1ZSjCE8dq/pgvgIkN4UNdwG+drUgwzI+FpWPeH463Wt qGLQZ5kRB1EDaS+FnyE6H/XpwkOHMQsVnw06CWwGWgTPwhKLDb7UwOKjlt+S GYP4AtVSZA7plI2BmYjAI+Kgg4unWZgxOTeZqJExIYkz7u44vttcm9b6OkCa tXq6i44hC3A8+Q7OQUdGBoX8XJFThF/EFMNMC1u97pTAd78EpljOUKRcpgT2 W3OWRVPM5TV1iXQRZFDdAsJt6ibhF0sw+dqFeEJm7aeyhFaetKjelLggE1H7 RVla6Z6PbIbxNYSS12Ar1+2V0Uz+8i/EVv4tcJDvzK7h2JB7ehvhTH+KKUoc rZiOw22aK6Z3Z/OWs/k7/P3EYP07Mnt+4X9Ezu8qcTrm9UTqgCcaMZIINhC0 VNJmWNgJWIpR2EswuiQF1qVp5/mHyU/QfIgEBXqvpYYVtPjgUyYCcgZxxt4E sHc3WqHJIjIIkdsKiRuiaT5HVW3TVgzLx1IEGguiASmWlFlGlj6EFAWQwmtd RjCcUF7n8kQS85pSaAEE8q68BcB0FA2Pu2H5nnnnEsFsQfJJGF3dQ6SNogiM vGRJ/YmK45z9idaP+hOg9/7l4RjtphpYEZeBD6KkPK83Xs3jToo8jIR5M9Hy 5cU3xZJNZ8CUBkQXGZX5+WuB0S17FI3qhKBM7P9UnIQ+PavR8CXm0iDEPL/e E/nCvCgI82B3RQs4NZ6a5bgvR0McH9OOrbiP3iwKsFONAUSG3H2z3+bGGrUY w6cRPNaZRqn/GKbrMy0Kwjqa27Wtg9pDYCuKhGGDYTxCOqe9kyZrjE5ZN1Pm MGV4EAvZMFE2yZycdIKMyfKkovj76bvm9Ce676D8TxsB525uPutiLmvFlb36 zaBkL0PBkx91xnSZv3qj+exx/bCG7F8B/0EPV0ejPAbG068qX/TvbRYXyctV Uy6LmnSxXPC0UDybjcVFGJVFx4Sxn+JUiJ6L+ooxghDueGDawOzAZ59xwdBq ezlSUNqGV4p44SdiYZn9lOiYp+mq3G67KIGduBT0qGHzcG8bmEahiawRe1Lf +qSLi72i5atV3RdZCY502KF3a2KvB5Dwzv9oWav2T6mRq7Q7C6Ra2hzKl/AF jJa0x9tEudajvK5WWykAsRwgG1MkjZw2cDYjbB0OStga8YWK2yqYHNj44N9P Ngic37B3hppqXu79Ni+XZ/qZmgFd2xHWZgYUqzyD2cstvDrKHR3loGa0JeMS 8zMbdJRqkB4Sl5YRbX8hDuXQ/08m3BUf7j2MiAtL7X66ghSR9OqTXz200tsF 6iw/v4JnqCU+ftOJxwnacIV9sn+mmLLaOiyEBY/Rr9FCHZhuDEBlK2fCFGaa tkjYMT240jZ/q/upmHKkMWViXIMfO6h0qNIj+m7zbVfA26zW3sfG2qGXx0/s 4z37+Kl9XLCP0DHzvG4fC/axaB+/s49vf9JMpyY6Nc9cw4aeCJ889XE+qsL2 joaXHMSstvvVV5sHG1g5M640ei4uOfAzhtNilq3x7eSmF3ob3n59v7aK8T7q e7vNJ/XnsFyq2R8f7Oxt/QE+r2R/5hNR8+nu4d7Trce17fn5W9kZUcUc7esA 1OdmH50igiAhBZuiedupyCLw0jfuJ9fXY+GdN7E7ZtbGnWTpTet93Lny/IQO LvPZG29qA4Ut9RZOoWyIOXKUl5zlKIms13LlFr+R+YXZZSGBLBs9LbWWc2Oc 6u3UW2MvX3r7b2XdHGeWuL6uoNWemTWerq0ch2z6NBtdzAWsqcTq26VNKT7V lx3m4G0UAnEC4F999Wu3nynVp9F6VjMm3V9MNARGeeXdGwHr8qfXW51S73fv BulTLQdZnoCXVgCTW6PTeBRrxforJptoTJEaxEKiDX0xYcmgfUt8RSta6BFH NryqiCgnZtsvpHTpzofhoClOHx25p9b4MwnoBsbn83Uv6VZ80a4GrVs8i14x gcOz3Cx0VN9nDKBDovYvN4enzf1wmER0PIfxgFaWVC75PlmjPuVwSjVV/VRT 1Ey1RP1R++XQTKGkl1T+OF+Uc0lMVmpZbZtSdOAU/X4jmwakaaC3P+g+xC6J blFj9y9rw2GzEY3wOFwjgQ/pl7Wa9T0KhTnNbtSo8Lma663iVXiy8vMjCpCM n44bKx+R4/0jx+rPjxzvjgmrHzHhvWICWtsZc6hr48OEGnd0DRSwhlnXmPC9 TzprbttyaaMZeMf/WLo2Mf0zGdPIURN3NninbfuXGNqThIzwuBv3U1b5kjhj XE8j5OZRfPkXHtQrRnHNNCRzBH/CyJmhqPdHJN7dwSVe0GLbWUiHbSLrlZ9/ aKAZH2hg0jYGV6AOE9e/ghGSpvzFRinDKMGz1Zk6TqwzcNUAzdIIeCNbWWI3 sR81jrS5dR1VAW94XRuIjOspbuRyseiTfnvzhXQfB5woP8wL62hBsTEFvq2u SauitvKMGqZtEtFUm8UpLXvHmXXuu++pZQpXwTey7oX1jL5+FXbHprO7sfYe yffBFfUUnXoSK1AoqkE0PAsHye+ndvZN9iWUKuRyzr7rX3zSulL3RYFtY9rA VN2Nm7mMboa+V7mq7t8nva6hYQEYdVuwhN6QdT/qKltDUOccbu/VGHsSjSV6 2vByU9/Kpy5CJa/sZ/rS7I2WEb47pq2saTUsbZOORtVRb4C+tyYlj2+vGg9S +bLDS8wKedpxtt+E32V6/CtdlBQVZ44r55Ohda8O+W57crSRZPtD3aUWYvpm woT8ijpnzCX3woeP9OJPWn9i6l184lzEO6TFR44JPE342ltuaH0U+BGUBuZ/ RDtE1I0oQaNBKHiRmyEczsLQn7HBBnOvaPrbWVOdZE31d8FE039Uyw1R5wby PgZIQj2aSu+sptLMhvzIg8WbK7bjptDqa7MtWsPG7uecnSmsr+F0Zc0oB37P NbPS09SaRWP9pzJpaYVuy0mQiu/wetxacmON2jPtqAS5PhV9VX+KLYJLf67Y 5gnxEdJ6Jsr91LNrJts8nLRSXUTuFAaOrTbJbVH6BsZ8/U67CMC3daa6OOah 8emjs5Kd63eazuYa9UePn+7nyPgcHjhzCT/jp/ruIX/S3qLsp/94Wpdv+JQu t7Mj5XZ2Up82HxxIOXxKfXy4X+Nv8JD69AcD8w+TQBu1R1/xR3xKfUTRBX/E p3Rzdg6eSHPgKfURrfFzxi7f+Ygqls7UvrVaJkat5FMz4Msv10krEGfGUTAh /RqcIbyjTHzFS53dRZxcbsZCFTcBP3WhTvj8ZrcL15SBXXncola+74NW+h5k BuctKxQaw25sYO3i6ovQHTt6QZq66wwMBbH+GD4VXyK2FYOfTiQQzLP6Q8C4 3c2d2jaOAFVinYCghwByLTafss3nLrH9PsZEEOS62aZwfzDqzxCJAbIBSs5M HQozkaE4Y3M3Y8kW9rN6U3teP3T7YjKnaeEzzNk43Dx82rC5zbn1OjPa7pA6 KrvN6sdDvKO91Ceh7NunJ9HoLG5vRycazXqUkCChlOXyXU5vPHZXhPPR25J8 xf1Vf3Q263QW4R7SOemSz+bUl0VWkD3xdcX7vDLxfdX7vup+10vQUg33a0oi OSFBdfO6gjdfJJjOxTIoVzI2CUfLYNISIicnEt23ZI1O1uWdfmfUlLhxBUyZ lH/0gC6LAl2PjjnNOhR6QuFy4IQspaFWf+YFXfjsxrmRhd/uYE093qiDnyv2 mBf/R4eAec8BwK6I/3V39dbtdPyfavVj/N8P8re0qJxZryj1KOpHaFzQVuF4 FPeQqpFHdHJfxlnHw6jCgXIwC8cCgpLoVxfAbbPuUIfjzpARwL3kMllCH0yV s/vsyb2TqP29Rv15pcr2cCOM3scwboytg/nG143ms836YfOxC3oUq1ewVeWx DgJNTgoRdjuOElT2Yv0lDx7xIi6UMBHzCFYpFu8sss1xgKChOAQGJowoggfw oHaInNzXwANO6TaC39xt1NWW4kGi4EOJBwUOTVvkkaV20MiAg3F0kvAEAzHr AEwUg4e7jXEmodco+b4nLx5w9LfbfFY/fEwDSR55J6oY+rDaUasbYkBPbdrV 8yE+adZ3fWjt7I4b3/zWMX9qct3oARaI6+M/5SnUlvf8m84YfVKpCk0LJhFs c2dnb2tzFgjtJnQ6DLcfU4DADtQ6b8+A8ah2uPVsexYItKU8G84A8aT2ZOvx wVUgeoMrQDzZvwrEYNZgIIj9mWMBIHrxm2g2jCd7X82cWFGAmwmjUTucBWIY kZueGTAOas2tvdnjMYxOrwTy6CogeFseJtHsuWkcHmxtNmpXzI9cvM8GMxtL EEQy6F8Bo7G/ewUQVBecCWP76VVdEY+ls4DUDg72rurOCRK32WAeZhNHD0z/ WpO0e71ZunqarjFPV07T1bOEHpxmgzic2QrryH46FOs9fwageyet/qiLW5Cz V2YQ263dwx2fHZiAdDocXAnn0cH+FVDIk/OVcOp7W1e2h01rrwTVqO3Utg6v gjVqd+KrQR1u1/euhtTtHF8H1E79wZWw8BR9DVgH9d1HV8ECboSMO68GB2wI rP/dK3sKEK+HXQjxOhiGEK+HHwjxWjgCEK+LJwDyeriCMGFxXg8irNBrwBNX 49cCifKf+l7jOlCF+7waJHK014N3DdQWgFdit3vEuBoinAiu02d9HroS4OQB aALedWflejNyvb5ep5/jfgfIzJWgnu7WgcwIrF0UHsJJbBC2XoenLte/v7n1 h81HvE1/BYczPFOIh8TM/F/Bmaq+t/uPGNb92n+e/CdsaVnAe63jqvjvK8tp +c/K3TvLH+U/H+Lvr+IA/3MPwj/wX0b898rg8v3Ffse/q+S/d1arafnv8t2P 8t8P8vf/3v1PwX/9/z79nGb8n+C/5Dn88wP8/5dzr+fm/ggPv55rz82dzM21 fzH3/5qb+19zc1//8RdzP3w51/7lXPSLuZNfzLV/ZT78cu6H2lz71/rDP5kP v5pr/2auUfgt1vAb+IevmqjWX8z9ci75/81RTT/8k1SDFc9jFfgM1f1OasEa /hVrwOdfzf3w36SSP0LZ/4514PM/zf3wb3Pt39Lzb+Z++B9z7X+m59/O/fA/ 59rz9PzPcz/k59oBPc/P/bA81/4Xeg7mflida/+Onv9l7oc7c+3/RM+/m/vh i7n2f6bn/zT3w8Zc+7/Q83+eO2gU/hVav9vCjvxq7rdzyV3sDDTiN3OAMqNf zHV+Off9L+b+F/w7N9eE9N9S4m/wtfNPc//rF5T+WxzmRuEXCKrwzzhOOB3h YNC9THDY5HrJGb3k15hheJrQA97QJ1h6kPwL/OtcelFxeS78ErOa/AbC/Jym BbD8E6y+2aQrMWgv5frVL/73X1APf409XJij+fkhcHoInfk1zjp09X+Dvjac 7vxmencQNrl7TvVBt+x6DdZQ5ueSX1Jjoam/4qaWsakwe/9pelPfAlL957nv /Tb/dnqb/0Vqk+vWaU2n12HhV9kdoI+pbgQaMEm+fqdH/n+mR/5f5374rz95 5DGV7p5/2tAbMP/qjD0vheT/wMb+t7kf/u/Y2A7heedXiPBuE6mCdMPoLjnV MMpv0yabQYX+m9cMRAMaVqAOP/xv7hJD0nMlxJPuODn775MQ/zNC/Le5H/4P JFfcGcyy2yGoV4LGWekk4Wh0+W8e7F8h7P8TYf+PuR/+T2/Q2kRAnKpoTILJ 0ZuyoGa255+lDNpa/w9vCVGLkEwD5fxBzZ3Ozb0FavzJ3MUT/BcaFT+Y+8UP OQ8TgWrLorqBi+p38b9AlgXEzkYfevnDTXxE8vdLRIVffPt/m/vFM+rXr2gI qaHcud/qx+G1aAb+26XBBWyPgNj5S48BcSa///NO/5P/ydP7q1/M/+I3cwGQ vX+B/7VwIP4JB+P/g4ORn/uhgO2HAfjTr+bif4VeFXEMoOv/z1/OUS8X5y56 c/Dv97RB/unXc/ERpH5G77+m90/hvYTvo1/NjX6NWwGO32/x8/+iofnfYaz7 NyBXJSMX7yiS69uiHsN/smP4b9Tx6PUaBtcetlFly6j0VglTO7j78maDo3Z+ hgEFaLlYqwL6Ep+cYOBZHM9u1L8Wvvlj7wBxapok4tjevJ6Af4X//WYO//30 lymisjz3Q/WdiApWZVRK3mVtYPIo6naXp5C31bkfbr1TS34rLRl03mmN4nhC kVXTjF9SIzTBuDP3w12vGYwfv3Ba8k/plvyOarL6OOn1hAXoW2onMOmpJv4L w9Pg7jhNlcVzB5v6xdwPa3MXRVoJv8Dn4f8garE+N/oltZzYou+JijS+/S9z z9L09TeaLIxkNV9nW8sgBqNMYhBoAEQNvuCl8atf/G5uPj31G3M/3H+nqf+x tLlJMUKazQ09ooX/gpldNs3C9pkIZzzsvmq2Nmcn8jYBnyKalWkWg8bG9JSn Bs9rPG2LGRshM7O/nkv+HzzOv/7dr+g//b9//t28PP2aGk757cnhv+JMfDn3 w6Y9ORwItqQ48s25Hx5M4ci3fgpHbhr1YRjyTcuQM+K4H7MG2bTvS40+dtxX UwNZm/vh4ZUD+XDuh0dTBvLxeznarH6YkXz4riNpG1jTQ5mxyp0TmkUNWzQL MNb++18yqfndL//7vX/Dgh/iz5f/drtlFtQn71MEfIX8Z2VS/rt6q7ryUf7z If7cINLmqveG1jWzl8SpaNzeLbOXnW6ns3PL5a+bXa6Np+dvZBRInBLOR31p 7ENx7ogdOM4dswMpU2POLyU3lU6qSaEIeAgkfVs5BYLkn4TjRCUPJgE+yIR4 nOrJxDWdU5Fc72VmZ70Im5l1KTKzupedqQbNqsG5bPZLyVV1ZiF9KW9L6Av9 qXVMFnH1ADLwh1U/0whk7iZtRnOrmT1Jcl/r1yu3vdNHRF/op8ZEqwRkFtSK BbaMVkqYWs9kEVeXIRuDzKWxg0Pmwnk6amQU8zUITNGfmwh+/Pv49/Hv49/H v49/H/8+/v0D/f3/AT7+tmIASAMA ---1463809789-1804289383-945201226=:30024-- From edwardam at home.com Wed Dec 1 21:28:16 1999 From: edwardam at home.com (Edward Muller) Date: Wed, 01 Dec 1999 21:28:16 -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> Message-ID: <3845D940.6048E8EF@home.com> 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... Fredrik Lundh wrote: > 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 mahboob_h at yahoo.com Tue Dec 14 10:58:08 1999 From: mahboob_h at yahoo.com (Mahboob Hussain) Date: Tue, 14 Dec 1999 10:58:08 -0500 Subject: newbie : books on python Message-ID: <3856690F.172ABB0C@yahoo.com> I program in C/C++/Java/Perl and want to learn Python. Could you suggest a few good books / sites to get me started ? Thanks in advance Mahboob From Alex.Martelli at think3.com Mon Dec 27 03:56:13 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Mon, 27 Dec 1999 09:56:13 +0100 Subject: "sins" (aka, acknowledged language problems) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D83@pces.cadlab.it> John Skaller writes: > Secondly, the reader has to find the class, > and try to understand it, and remember its name. > I think people remember patterns (idioms) better > than names. > I guess that's the crux of our disagreement -- a mixed philosophical and ergonomical issue. As I see things (and I know I'm not the only one, since Gamma et al, Coplien, Martin, have all made this point in print in the past), a good part of the idea behind the "design pattern" movement of recent years is just about this -- NAMING patterns, because, when a name is attached to a pattern, [some] people have a MUCH easier time remembering the pattern and the various "forces" issues attached to it. I suspect it may have to do with some people's brains' preference for "verbal" modes of reasoning, versus others' leaning for "pattern-recognition" modes. I _know_ I'm an exceedingly verbal person myself, and I _suspect_ people with verbal orientation may tend to be over-represented among the authors of books and articles, for clear self-selection reasons:-). > > > (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). > > Yeah -- even if it works, you get an uneasy > feeling that it make the code a bit harder to read? > 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:-)]. Seriously, now -- I _know_ that wrapping a pattern up in a "keyword" *would* make it harder to read *unless* the "keyword" itself was familiar to the reader. E.g., I used singletons before Gamma et al. published their landmark work (as did many, many others, of course -- that's why it IS a common design pattern, after all!-) but I didn't "name" them as such -- partly, because that was not my name for this "idiom" (as I then called it), of course. 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 don't need C++ to provide me with an _actual_ keyword for it, mind you. Indeed, I think C++ would be a WORSE language if it had a keyword such as "singleton", despite the fact that, e.g., placing in my header files a construct such as: "singleton MyClass;" might be marginally more readable than using: inline MyClass& get_MyClass() { static MyClass singleton; return singleton; } or other, more long-winded forms. When boilerplate is just a few lines, not needing much repetition, such as here, I don't really mind it as much as I'd mind an extra few (or MANY:-) keywords in the language (I guess I would not be using C++ if I was _really_ allergic to even modest amounts of boilerplate, hm?-) 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. > Python's scopes are NOT simple. > The idea that 'exactly two scopes' is simpler > that 'stack of scopes' is a misconception, > and it doesn't even work in Python: > there are at least two places where it fails: > (a) the __builtins__ hack, to make builtin > OK, _three_ namespaces. "Nobody expects...". > functions available, and (b) in except clauses, > to make the exception available. > *blink* isn't that what sys.exc_info() is for...? 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. 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. > > What are the drawbacks of supplying the needed > > wrappers, rather than adding new syntax...? > > For a start, efficiency. And, as above, > readability. > If the wrappers are standardized, readability is no problem. 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: ??? As long as the kv_enum (or other name for it) is a built-in, this would seem just as easy. And it does not break older programs using "ifor" as a variable name, etc (having context-dependent keyword status, the way PL/I tried to do, has, I hope, been decisively proved to be a BAD idea, unless you're the kind of person that *likes* IF IF = THEN THEN THEN = ELSE ELSE ELSE = IF and other such endearing PL/I constructs:-). > > > > 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. > > I'm not sure. I also have no candidate syntax > for defining the labels. Labelled breaks give me > an uneasy feeling. > I've used them with much happiness in both Rexx and Java in the past, and I've never seen anything bad happen, that could be in any way related to them (I'll tactfully omit mentioning I also used them in Perl, of course:-). > > > > 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:-). > > 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. > 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? > for example, to loop thru two lists I can write: > > for x,y in zip(l1, l2): .. > > which is something like: > > for x,y in map(None, l1, l2): > > although I can never figure map(None, ..) out. > So maybe "zip" should be promoted to official status as a synonym of "map(None.". I'm not a _total_ minimalist, you know:-) -- maybe it could have better optimized semantics specially for use in for loops (just return one element at a time at __getitem__, rather than actually building the list in memory -- yep, I _am_ a lazy-evaluation fanatic:-). > But somehow, this is wrapping the structure TOO much. > Guido noted something like > > for x in l1; for y in l2: > > at the last conference, which is a bit ugly, > but it _exhibits_ the intended structure better > than functional wrapping: here I can see a > pattern, rather than remember a name. > To me, this suggests nested loops -- noticing the subtle difference of a ";" rather than ":" after I1 seems just like the kind of visual challenge I can perfectly well do without. Alex From junkster at nospam.rochester.rr.com Thu Dec 16 22:09:56 1999 From: junkster at nospam.rochester.rr.com (Benjamin Schollnick) Date: Fri, 17 Dec 1999 03:09:56 GMT Subject: Help?? Struct packing of Date time not has stopped working??!?! References: <835mvi$62t$1@nnrp1.deja.com> <38579924@194.120.211.23> <3858d6a1@194.120.211.23> Message-ID: On Thu, 16 Dec 1999 12:10:05, "Klaus Baldermann" wrote: > >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 Of course! The Telnet library is filtering the data, looking for telnet related command sequences.... I never though about using a *PURE* socket for this, I was looking for something relative "fast" in development time. Hmmmm.... Thanks for the suggestion, and clearing my head alittle! - Benjamin From ngps at madcap.dyn.ml.org Thu Dec 23 09:45:07 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 23 Dec 99 14:45:07 GMT Subject: Which grid widget? Message-ID: <38623573.0@news.cyberway.com.sg> Hi, It seems that wxPython, pyFLTK and FXpy are all being actively developed. I am looking for a good grid widget. Which of the above toolkits should I look at? (Yeah, I know, _all_ of them! In my copious spare time I will. ;-) TIA. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From ivanlan at callware.com Tue Dec 14 11:15:42 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 14 Dec 1999 09:15:42 -0700 Subject: Newbie Variable Definition Question References: <38566A51.A1DFD2F6@coastalnet.com> Message-ID: <38566D2E.1916DABD@callware.com> Hi All-- "Andrew N. McGuire" wrote: > > Hey all, > > I am a python newbie and am picking up on it very quickly. > Python seems to be a remarkably simple language to learn, however > I have one question.. > > This is primarily oriented towards the *nix guys out there.... > In Bourne / Korn / Bash shells there is the syntax... > > if [ $variable = "" ]; then > commands > fi > > This tests if a variable is defined, and if not, execute commands. > Also there is the following statement as well.... > > variable=${variable:=value} > > This checks if variable is defined and if not, it assigns it a value > of "value". > 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. > > Any help is greatly appreciated, and thanks in advance. > > Regards, > > Andrew N. McGuire > UNIX System Administrator > > -- > http://www.python.org/mailman/listinfo/python-list try: x=variable except NameError: variable="default value" x=variable print x -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 wtanksle at hawking.armored.net Fri Dec 3 20:51:07 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 4 Dec 1999 01:51:07 GMT Subject: indentation References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> <829dlk$12p$1@news.wrc.xerox.com> Message-ID: On 3 Dec 1999 21:45:24 GMT, Mark Jackson wrote: >"Fred L. Drake, Jr." writes: >> 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. Please may I forget it? :-) GW_Basic, then x86 assembly, then Forth, then branched out to a LOT of languages. I only discovered Python recently, and I'd rather use it than anything except Forth. Someone wrote an indentation-based Forth, BTW :-). >Mark Jackson - http://www.alumni.caltech.edu/~mjackson -- -William "Billy" Tanksley, in hoc signo hack From quinn at ngwee.ugcs.caltech.edu Fri Dec 10 12:03:04 1999 From: quinn at ngwee.ugcs.caltech.edu (Quinn Dunkan) Date: 10 Dec 1999 17:03:04 GMT Subject: some random reflections of a "Python newbie": (2) language issues References: <001e01bf42bd$4da0cfe0$60a2143f@tim> <82qoq8$nbd$1@nnrp1.deja.com> Message-ID: On Fri, 10 Dec 1999 11:39:52 GMT, alex at magenta.com wrote: >In article <001e01bf42bd$4da0cfe0$60a2143f at tim>, >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!-). I don't believe these 'coincidences' are really coincidences. Obviously Guido implemented your idea, but has a way to avoid giving you credit. He does have a time machine, you know. From aei at ic.vrn.ru Wed Dec 15 08:48:36 1999 From: aei at ic.vrn.ru (Eugene Akovantsev) Date: Wed, 15 Dec 1999 16:48:36 +0300 Subject: Calling C functions (libs) from Python Message-ID: <83861d$com$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 aahz at netcom.com Wed Dec 8 16:41:36 1999 From: aahz at netcom.com (Aahz Maruch) Date: 8 Dec 1999 21:41:36 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> Message-ID: <82mjag$7oh$1@nntp2.atl.mindspring.net> In article <14411.53378.154350.793014 at weyr.cnri.reston.va.us>, Fred L. Drake, Jr. wrote: >Mark Jackson writes: >> >> And Fortran. Don't forget Fortran. > > I guess I got lucky; having never learned Fortran, I don't have to >forget it. ;-) 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. -- --- 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 skaller at maxtal.com.au Wed Dec 15 15:32:32 1999 From: skaller at maxtal.com.au (skaller) Date: Thu, 16 Dec 1999 07:32:32 +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> Message-ID: <3857FAE0.427FE0FC@maxtal.com.au> Alex Martelli wrote: > 3. "dictionary locking" in lieu of declarations > > Some of us are into the "bondage and discipline" > style of programming -- > One idea I came up with, which could help > matters a bit, I think, and appears to be more > in the spirit of Python, than "declarations": > what if I could *LOCK* a dictionary, any > dictionary, including, of course, those where > variable names are kept for the various scopes; > so that any attempt to _add a new entry_ to the > dictionary would raise an exception. Hmmm. I'm currently creating a new version of Python called Viper. in this implementation, scopes can be _bound_: what happens is that named lookup in a dictionary is replaced by indexed lookup in an array -- this is much more efficient, (10% speed increase in pystone), and it is what CPython already does for local variables in functions. The notion of binding is part of what is required for a compiler -- removing dynamic name lookup, which is slow and error prone. The array lookup is done transparently in entities called 'environments' which basically consist of a dictionary and an array. Unlike CPython 1.5.2, binding is currently done manually (you have to call a function to do the binding), but it is also available for modules as well as function locals (and is planned for classes and instances as well). At present, if a new name comes in after a module/function is bound, it is just added to the dictionary (it gets a slot in the array if you bind the thing again). No error. What you're asking for is an error, right? This is easy for me to do -- in fact, it is much easier than maintaining the dictionary and array in parallel. And it is necessary anyhow, to get good performance in the compiler (that is, _completely_ eliminate the dictionary when possible). While this has been an issue of performance and compatibility for me, I hadn't really thought too much on the safety advantages of binding; but I believe I agree with you, particularly for class instances. There are in fact several related issues: what syntax should be used? Can you 'unlock' a dictionary? What should be locked? Just the key set? What about read only attributes? On a per key basis? Every such extension costs in complexity, both that of the implementation, and that of client code. It may reduce efficiency, or it may (in compiled code) actually increase it. A similar argument can be put for typing: you'd like to fix the types of some things, so you cannot bind a varible to some other type. (This has potential for optimisation as well as client code checking). And, underlying it all, there is the question: is it OK to violate these constraints and then catch an exception? This is the last thing we want in a compiler -- we want to refuse to compile the program. > The way I envision this -- if X chooses to > implement a method __enum__, then, There is a problem in CPython (not in Viper) that all these extra methods require a larger and larger vtable (in extension objects) and (in Viper too) more and more complex semantics, resulting in slower execution, and harder to understand code. In addition, the more things that are overloaded, the harder it is to detect errors, and the more difficult it is to optimise. Viper, for example, doesn't bother overloading math operators (although I will have to overload + and * since they're used for sequence concatenation :-(. > This one, I cannot see (being a newbie) > 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 will only work on YOUR instance, and will fail if x is something else (like an integer). -- 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 gerrit.holl at pobox.com Wed Dec 22 09:51:58 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 22 Dec 1999 15:51:58 +0100 Subject: Bad programming style? In-Reply-To: ; from sposhua@my.pc on Wed, Dec 22, 1999 at 02:01:57PM +0000 References: Message-ID: <19991222155158.A10874@stopcontact.palga.uucp> Sposhua wrote: > 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... Why do you need it? > 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' exec c[0] + '=' + '"ff"' the 'exec' statement takes a string and executes it. In this case, the string is: 'r="ff"' I don't know if you already know this construction: '%s="ff"' % d regards, Gerrit. -- "However, complexity is not always the enemy." -- Larry Wall (Open Sources, 1999 O'Reilly and Associates) 3:49pm up 4:44, 16 users, load average: 0.02, 0.01, 0.00 From akuchlin at mems-exchange.org Thu Dec 30 17:23:16 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 30 Dec 1999 17:23:16 -0500 Subject: RPM-interface/module References: <386B3CDB.FF843280@bibsyst.no> <386BCE53.A8D93A67@es.co.nz> Message-ID: <3daemsrru3.fsf@amarok.cnri.reston.va.us> > 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...) >>> import rpm >>> dir(rpm) ['RPMFILE_CONFIG', 'RPMFILE_DOC', ...] >>> db=rpm.opendb() Unfortunately, there are no docstrings, so you're going to have to grab the source RPM for the module and read through the source. (If you do this, consider writing some docs and contributing them to the www.rpm.org site.) -- A.M. Kuchling http://starship.python.net/crew/amk/ I'm not a metaphysical man. I'm a minister. That's my job. -- The minister in THE MYSTERY PLAY From alex at magenta.com Sun Dec 26 03:19:13 1999 From: alex at magenta.com (Alex Martelli) Date: Sun, 26 Dec 1999 09:19:13 +0100 Subject: Python suitability References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> <113901bf470c$cb236f60$0100a8c0@rochester.rr.com> <38654F5C.378F8338@maxtal.com.au> Message-ID: <005801bf4f7a$059ddf20$bf2b2bc1@martelli> John Skaller writes: > > 6. Many of the things you do in C++ are to over come it's own > > limitations. > > The main limitation of C++ wrt python is the ugly syntax, > and the quantity of it that is required to do something which is > simple in Python. After all, Python is written in a subset of C++. > Python simply 'pre-makes' some design decisions for you. An interesting way to put it. But, actually, it's an _extended_ subset, because it makes use of some things that (alas!) are not in standard C++: things such as deploying separately compiled modules, and accessing certain elementary OS functionality (such as getting a list of files). Standard C++ refuses to provide a standard model for dynamically loaded, aka 'shared', libraries; similarly, it refuses to model such elementary system services as obtaining a list of files, or meta-data (size, time, etc) about files; any sort of communication with networks or databases; etc. Further, even for things which _are_ fully implementable in standard C++, such as regular expressions, part of the point about Python is that it has, not just 'pre-designed' them for me, but, also, _implemented_ and _tested_ them; when I use such functionality, I'm re-using very substantial amounts of implementation work, as well as the design decisions behind it. The 'subset' relationship probably does hold for JPython, since Java is not as shy as C++ about offering standard and portable models for these issues (and others, such as threading); so, for that case, the 'pre-made design decisions in a language subset' model may be closer to fact. The extreme richness of functionality provided in the Java standard library, versus the spartan spareness of C++'s, also points the same way. > This is an advantage if these decisions suit your application, > and a hassle if they don't, and you have to work around them. Probably a fair point about any 'higher-level language' whatsoever (including C++ versus assembly). The key issues here would seem to be, how wide is the range of applicability of the 'pre-made design decisions' (how often are they limiting rather than empowering), and how much of a hassle is it to work around them when need does arise. I think Python (and C++, when scored against machine language) does very well on both scores, while other "higher-level" languages may not be as suitable. Alex From gerrit.holl at pobox.com Mon Dec 27 08:35:47 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 27 Dec 1999 14:35:47 +0100 Subject: Speed issues Message-ID: <19991227143547.A3500@stopcontact.palga.uucp> Hello, is an assigment slower than appending to a list? If I've got this function: def f(s): o=[] for c in s: o.append(chr(ord(c)/2)) return string.join(o, '') or: def f(s): o='' for c in s: o = o + chr(ord(c)/2) return o What is faster? What do you prefer? regards, Gerrit. -- "However, complexity is not always the enemy." -- Larry Wall (Open Sources, 1999 O'Reilly and Associates) 2:25pm up 4:51, 12 users, load average: 0.23, 0.11, 0.03 From torppa at polykoira.megabaud.fi Sun Dec 26 16:23:22 1999 From: torppa at polykoira.megabaud.fi (Jarkko Torppa) Date: 26 Dec 1999 21:23:22 GMT Subject: removing environment variables patch Message-ID: <84610a$k8j$1@news.kolumbus.fi> I did not find a way to remove environment variables from the environment, here is a patch that adds unsetenv to posixmodule and teaches os.py's environ to call it when it is available. This is against cvs version (1.5.2+) This patch is in publicdomain and as far as I am aware it does not have any patent issues. Index: configure.in =================================================================== RCS file: /projects/cvsroot/python/dist/src/configure.in,v retrieving revision 1.114 diff -u -r1.114 configure.in --- configure.in 1999/12/20 21:27:22 1.114 +++ configure.in 1999/12/26 20:25:05 @@ -750,7 +750,7 @@ flock fork fsync fdatasync fpathconf ftime ftruncate \ getgroups getlogin getpeername getpgrp getpid getpwent gettimeofday getwd \ kill link lstat mkfifo mktime nice pathconf pause plock pthread_init \ - putenv readlink \ + putenv unsetenv readlink \ select setgid setlocale setuid setsid setpgid setpgrp setvbuf \ sigaction siginterrupt sigrelse strftime strptime symlink sysconf \ tcgetpgrp tcsetpgrp tempnam timegm times tmpfile tmpnam tmpnam_r \ Index: config.h.in =================================================================== RCS file: /projects/cvsroot/python/dist/src/config.h.in,v retrieving revision 2.51 diff -u -r2.51 config.h.in --- config.h.in 1999/12/20 21:25:59 2.51 +++ config.h.in 1999/12/26 20:25:06 @@ -341,6 +341,9 @@ /* Define if you have the putenv function. */ #undef HAVE_PUTENV +/* Define if you have the unsetenv function. */ +#undef HAVE_UNSETENV + /* Define if you have the readlink function. */ #undef HAVE_READLINK Index: Modules/posixmodule.c =================================================================== RCS file: /projects/cvsroot/python/dist/src/Modules/posixmodule.c,v retrieving revision 2.121 diff -u -r2.121 posixmodule.c --- posixmodule.c 1999/12/15 18:31:10 2.121 +++ posixmodule.c 1999/12/26 20:25:09 @@ -2962,6 +2962,28 @@ } #endif /* putenv */ +#ifdef HAVE_UNSETENV +static char posix_unsetenv__doc__[] = +"unsetenv(key) -> None\n\ +Remove an environment variable."; +static PyObject * +posix_unsetenv(self, args) + PyObject *self; + PyObject *args; +{ + char *s1; + + if(!PyArg_ParseTuple(args, "s:unsetenv", &s1)) { + return NULL; + } + + unsetenv(s1); + Py_INCREF(Py_None); + return Py_None; +} +#endif + + #ifdef HAVE_STRERROR static char posix_strerror__doc__[] = "strerror(code) -> string\n\ @@ -4523,6 +4545,9 @@ #endif #ifdef HAVE_PUTENV {"putenv", posix_putenv, METH_VARARGS, posix_putenv__doc__}, +#endif +#ifdef HAVE_UNSETENV + {"unsetenv", posix_unsetenv, METH_VARARGS, posix_unsetenv__doc__}, #endif #ifdef HAVE_STRERROR {"strerror", posix_strerror, METH_VARARGS, posix_strerror__doc__}, Index: Lib/os.py =================================================================== RCS file: /projects/cvsroot/python/dist/src/Lib/os.py,v retrieving revision 1.28 diff -u -r1.28 os.py --- os.py 1999/11/02 20:44:07 1.28 +++ os.py 1999/12/26 20:25:10 @@ -235,6 +235,13 @@ exc, arg = error, (errno, msg) raise exc, arg +def _exists(name): + try: + eval(name) + return 1 + except NameError: + return 0 + # Change environ to automatically call putenv() if it exists try: # This will fail if there's no putenv @@ -271,6 +278,10 @@ def __setitem__(self, key, item): putenv(key, item) self.data[key] = item + if _exists('unsetenv'): + def __delitem__(self, key): + unsetenv(key) + del self.data[key] environ = _Environ(environ) @@ -279,13 +290,6 @@ The optional second argument can specify an alternative default.""" return environ.get(key, default) - -def _exists(name): - try: - eval(name) - return 1 - except NameError: - return 0 # Supply spawn*() (probably only for Unix) if _exists("fork") and not _exists("spawnv") and _exists("execv"): From landauer at apple.com Thu Dec 23 13:09:36 1999 From: landauer at apple.com (Doug Landauer) Date: Thu, 23 Dec 1999 10:09:36 -0800 Subject: Offtopic: millenium References: <199912222000.PAA17264@eric.cnri.reston.va.us> <19991222215733.A2783@stopcontact.palga.uucp> <83ri56$58q$1@nntp3.atl.mindspring.net> <38615206.636B50C@callware.com> Message-ID: > Me, I think if the Pope sez the millennium is 1/1/2000, it's as close > as anyone is going to get to an authoritative answer. Except for those who put more credence in what Douglas Adams says than in what any Pope might say... http://www.douglasadams.com/dna/pedants.html -- Doug Landauer landauer at apple.com (work) landauer at scruznet.com (not-work) From ngps at madcap.dyn.ml.org Tue Dec 7 10:05:01 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 7 Dec 99 15:05:01 GMT Subject: browser interface? References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> <384D1F58.1459835F@horvath.com> Message-ID: <384d221d.0@news.cyberway.com.sg> According to Bob Horvath : > 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. Work through the Zope Content Manager's Guide. It should give you a feel of Zope's Zen. Have fun! -- Ng Pheng Siong * http://www.post1.com/home/ngps From sragsdale at my-deja.com Fri Dec 17 13:38:47 1999 From: sragsdale at my-deja.com (sragsdale at my-deja.com) Date: Fri, 17 Dec 1999 18:38:47 GMT Subject: Python locks up X Message-ID: <83dvvn$4d7$1@nnrp1.deja.com> 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? ==================================================================== #!/usr/local/bin/python from Tkinter import * from Dialog import Dialog import os def myQuit(): ans = Dialog(window, title="Quitting...", text="Hit OK to lock X.", bitmap='questhead', default=0, strings=('OK','Cancel')) if ans.num == 0: window.quit() root = Tk() window = Frame(root) # launch a non-terminating child process if not os.fork(): os.system("cat") lbl = Button(window,text="Click to lock X",command=myQuit) window.pack() lbl.pack() window.mainloop() Sent via Deja.com http://www.deja.com/ Before you buy. From ivanlan at callware.com Thu Dec 30 15:37:56 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 30 Dec 1999 13:37:56 -0700 Subject: [OT] OpenSource Python Books? References: <84g70v$tcq$1@nnrp1.deja.com> Message-ID: <386BC2A4.628D9C9A@callware.com> Hi All-- Cameron Laird wrote: > > In article <84g70v$tcq$1 at nnrp1.deja.com>, wrote: > >Hello, > > > >I know this is off topic but I represent LinuxPorts.Com and I have been > >approached by a printer to help them publish OpenSource books. What we > >were wondering is if there is a desire for the Python documentation in > >printed form? We would also include a CD with the Python binary > Yes. Guido will probably be in touch with you > to say that he's asked this every N megaseconds. I was under the impression that the words "The toExcel Bookstore offers printed copies of the Python Library Reference, Language Reference and Tutorial. Royalties go to the PSA" on http://www.python.org/doc/ (the documentation main page) meant that we already had, or could obtain, the Python documentation in printed form. Perhaps LinuxPorts.com might be adding value, but that's not clear from the note above. And, except for a few glitches (such as mailbox.py), I thought Dave Beazley's book served the purpose well, especially since its type is small enough to make a nice, compact package that is easily handled. Perhaps we do need a better copy of the actual, official Python documentation, but I'm a little leery. ... Python has few enough books that new ones are welcomed with open arms, but I would like to see more *good* books, myself. I think all the books we have now are good (contrary to Alex Martelli's oft-voiced opinion, I think Mark Lutz' _Programming Python_ an excellent book--it's just not good for Alex), with the possible exception of the new _Programming with Python_ by Altom & Chapman (they misspelled *Scaliger* for goodness' sake!), and even that seems to be at least passable. 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. ... Books that merely *duplicate* what we already have are counter-productive. Books that fill holes are better. Round books in square holes aren't so good. ... > >distributions on it and any extra Python software that we can. > I'm a bit touchy about those words. While it > might surprise an outsider to Python, there > would be a GREAT difference in the quality of > the product that results from these two sample > processes: > 1. LinuxPorts.Com workers copy Python- > looking stuff from whichever Linux > distribution looks most recent; and As Cameron already pointed out, this is not a good plan. We already have as much of this as we want with Redhat's distros, etc. > 2. A domain expert compiles a list of > Pythonesque stuff that should be > CD-ROMed, and reviews his selections > with other Python heavyweights. > One less labor-intensive way to do this would be to take a CD snapshot of the Vaults of Parnassus from time to time, tracking down all the links and putting the packages, with their documentation, onto a CD. That would be an easy sell, I should think. > > > >We have also decided that if we print these books that we will be giving > >a portion of the Gross profits back to the OpenSource community > >and would like to know "who" that community is when it comes to > >Python... > The Python Consortium and Python Software Activity > are the two canonical choices. I trust Guido will > tell you that, too. > > > >Please go to http://www.linuxports.com/ and cast your vote for the > >Python book if you are interested. > My answers to your questions do not constitute an > endorsement of your project. My allegiance is to > Python; *Python: The complete reference* could be > a benefit, but I'm not yet convinced. > Yup. Basically, the idea here is that Python books should be written by people who know and understand Python (or even, *gasp*, love Python), and who are part of the community. Blind cut-and-paste has given programmers *thousands* of bad books over the years. For the next couple of years, it will probably be possible for any publisher to sell any book with Python as its subject matter. After that, only decent books will survive (who is going to write _The Python Programming Language_ that dates as well as K&R 20-odd years on?), and the ones we refer to day in and day out will be very few. Maybe _Python: The Complete Reference_ could be one of these classics, but as Herodotus was known to say more often than not, "I do not believe it." -ly y'rs, Ivan (and I'll have a lot of customers, too);-) ---------------------------------------------- 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 timmuddletin at news.vex.net Wed Dec 15 09:14:35 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 15 Dec 1999 14:14:35 GMT Subject: "sins" (aka, acknowledged language problems) References: <837usr$6vg$1@serv1.iunet.it> Message-ID: <8387ob$1h63$1@news.tht.net> On Wed, 15 Dec 1999 12:43:59 +0100, Alex Martelli wrote: >Thanks for any pointers, Bunch of stuff here http://www.python.org/doc/Comparisons.html maybe something of use to you. From gerrit.holl at pobox.com Thu Dec 16 14:31:50 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 16 Dec 1999 20:31:50 +0100 Subject: knee.py Message-ID: <19991216203150.A6293@stopcontact.palga.uucp> Hello, knee.py says: This code is intended to be read, not executed. However, it does work -- all you need to do to enable it is "import knee". So why is it in the module library? I think the Demo/ dir. should be a better place, why isn't it there? regards, Gerrit. -- "Nature abhors a Vacuum" -- Brian Behlendorf on OSS (Open Sources, 1999 O'Reilly and Associates) 8:20pm up 5:57, 17 users, load average: 0.02, 0.01, 0.00 From dfan at harmonixmusic.com Fri Dec 10 10:42:17 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 10 Dec 1999 10:42:17 -0500 Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <82o0to$6eq$1@serv1.iunet.it> <82pcm0$p6t$1@nnrp1.deja.com> Message-ID: My two cents on Python books: I'm not sure I would use as strong language as Preston, but I also didn't find Programming Python to be a very good introduction to the language. There's plenty of good material in there, but the order of presentation isn't good for a learner. I remember getting to a big discussion of the subtleties of the three namespaces very early on, and thinking, "Geez, and I thought Python was supposed to be easy!" I don't feel too bad for picking on Mark Lutz for Programming Python, because his other book (cowritten with David Ascher), Learning Python, is excellent. It's everything that an intro book should be. I skimmed through The Quick Python Book when a version was on the web and it looked very good. I especially liked the fact that it has overview chapters on various advanced topics, such as COM and embedding/extending. Python Essential Reference is totally fine. Good organization and index. Not much more to say about that. I have to admit to being a little disappointed by the eff-bot book; I was expecting more extensive scripts that were solutions to more interesting problems, instead of tiny demos of each module. But there is some good information there, especially at the beginning. I am looking forward to taking a look at Python Annotated Archives. -- Dan Schmidt | http://www.dfan.org From gerrit.holl at pobox.com Fri Dec 24 11:23:32 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 24 Dec 1999 17:23:32 +0100 Subject: [Tutor] Python In-Reply-To: <001201bf4e27$421dbf00$1aea5e18@mmcable.com>; from SLEFLORE@mmcable.com on Fri, Dec 24, 1999 at 09:55:10AM -0600 References: <001201bf4e27$421dbf00$1aea5e18@mmcable.com> Message-ID: <19991224172332.A5304@stopcontact.palga.uucp> Sam LeFlore wrote: > I would like to have recommendations on which version of Linux to purchase. I recommend Suse. > I would like to learn the Python Language and would like the opportunity to > read open source code but I am unfamiliar with any other operating system > except windows. Thanks Sam LeFlore Have you already bought Learning Python? regards, Gerrit. -- "Calling EMACS an editor is like calling the Earth a hunk of dirt." -- Chris DiBona on Dirt (Open Sources, 1999 O'Reilly and Associates) 5:21pm up 5:56, 16 users, load average: 0.48, 0.16, 0.06 From c.kotsokalis at noc.ntua.gr Fri Dec 17 12:10:02 1999 From: c.kotsokalis at noc.ntua.gr (Constantinos A. Kotsokalis) Date: 17 Dec 1999 17:10:02 GMT Subject: multiple threads & environment Message-ID: Hello ppl, 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). Thank you! Costas -- Constantinos A. Kotsokalis || c.kotsokalis at noc.ntua.gr National Technical University of Athens Network Management Center Tel. No: +30 1 7721861 From bgkloss at my-deja.com Wed Dec 1 09:38:23 1999 From: bgkloss at my-deja.com (bgkloss at my-deja.com) Date: Wed, 01 Dec 1999 14:38:23 GMT Subject: Problems with SWIG and nested structure pointers Message-ID: <823bso$d10$1@nnrp1.deja.com> Hi - I've been using SWIG with Python quite successfully, but one problem remains: Memory allocation with pointers to structures. I need to wrap structures of the form: struct A { int x; }; struct B { struct A* a; int y; }; after setting up SWIG constructors and destructors I can write (in python) a = A() b = B() b.a = a a = None # - but this calls the destructor The last line is problematic, since Python has just lost the reference count to the A object, while I still have a pointer to it in my B structure. For a quick and dirty wrap I probably wouldn't care, but in this case it's essential that I avoid memory leaks in all circumstances - preferrably without imposing too much overhead on the python programmer. Any suggestions? Sent via Deja.com http://www.deja.com/ Before you buy. From fdrake at acm.org Mon Dec 6 17:46:11 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Mon, 6 Dec 1999 17:46:11 -0500 (EST) Subject: X display visual In-Reply-To: <384C39EE.6B5921EC@callware.com> References: <384C39EE.6B5921EC@callware.com> Message-ID: <14412.15539.879016.832154@weyr.cnri.reston.va.us> Ivan Van Laningham writes: > What say the Tkinter experts? Tk (properly) used the visual configured to be the default visual. This is (I think) a poor standard configuration from Sun, but it is the "stock" configuration. The proper solution is to start the X server with flags to specify that the default visual should be 24 bits. (Streeeetcch..... digging up arcane Sun X lore....) The way I do this is to change a line in the file /usr/dt/config/Xservers; change the line: :0 Local local_uid at console root /usr/openwin/bin/Xsun :0 -nobanner to something like: :0 Local local_uid at console root /usr/openwin/bin/Xsun :0 -nobanner -dev /dev/fbs/ffb0 defdepth 24 Make sure he checks the -dev parameter with the installed hardware; this is for a Creator framebuffer. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From JamesL at Lugoj.Com Thu Dec 16 01:56:48 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Wed, 15 Dec 1999 22:56:48 -0800 Subject: C++ (was RE: Python suitability) References: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it> Message-ID: <38588D30.E60A30D2@Lugoj.Com> Alex Martelli attempts to ignite a flame war: > 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. This would explain why the syntax of Perl and C++ suck equally and yet so differently. But Stroustrup at least had a glimmer of a philosophy. Wall had none. > One key difference is that, in C++, you _can_ design and > maintain huge and flexible projects -- the language does not > hinder, and gives you almost all the tools you need for that > ("almost": it misses language-level, standard support for such > key packaging/deployment issues such as packaging into > separate "libraries", threading and IPC issues, network > access, GUIs, DBs -- you have to turn to other standards > for these; on the plus side, C++, having no built-in idea of > how any of those should work, will never hinder you from > integrating with any other existing architecture you may need). > > C++ does not _constrain_ you to do your homework, and > design (and design _well_) -- it does not even really make > any serious attempts at so constraining -- letting you do > just about anything means giving you by far "enough rope > to shoot yourself in the foot". This means most developers > are NOT suited for the language (or vice-versa:-), because > they lack the professional discipline, or the skill to apply it > successfully, for the kind of projects for which C++ makes > sense (either HUGE ones, or ones with really, TRULY tight > constraints of performance, where every microsecond > does matter). I'm sorry, but drop the "++" and you could have made these same arguments two decades ago about C. You sure you didn't cut and paste this from something 20 years old and add some plus signs? From nickb at earth.ox.ac.uk Fri Dec 3 11:43:48 1999 From: nickb at earth.ox.ac.uk (Nick Belshaw) Date: Fri, 03 Dec 1999 16:43:48 +0000 Subject: split this newsgroup? References: <5650A1190E4FD111BC7E0000F8034D26A0F17A@huina.oceanic.com> Message-ID: <3847F344.EA1A9FA5@earth.ox.ac.uk> 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 > I would propose a further - c.l.py.tim - maybe that would distract him !!!!!!!!! Nick/Oxford From matthewm at es.co.nz Thu Dec 9 19:21:28 1999 From: matthewm at es.co.nz (Matthew Miller) Date: Fri, 10 Dec 1999 13:21:28 +1300 Subject: newbie needs help on dictionary Message-ID: <38504788.86E9C885@es.co.nz> hi all, i've created a list of 20 dictionaries thus... turret = [{}] * 20 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 pretty inelegant really - hopefully there is abetter way. thanking you all. matthew. From gmcm at hypernet.com Wed Dec 1 15:35:52 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 1 Dec 1999 15:35:52 -0500 Subject: Python meta object question In-Reply-To: <3844C056.A1E7FF9@linux-france.org> Message-ID: <1268041933-41414503@hypernet.com> Mickael Remond wrote: > 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. [snip] > I did not find any clue on how to leverage these features. Are > they out of date ? Byte is not referring to anything fancy, like metaclasses, or changing the base class(es). They are simply alluding to the fact that changing an attribute in a class object, will (unless hidden by an instance attribute of the same name) be seen by all instances (or derived-class instances). class X: pass class Y(X): pass y = Y() X.a = 42 assert y.a == 42 Trying to swap out X or Y in y's structure is a far more difficult and dangerous task. - Gordon From thor at localhost.localdomain Sat Dec 11 18:13:57 1999 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 11 Dec 1999 23:13:57 GMT Subject: pytags ????? References: Message-ID: On Sat, 11 Dec 1999 00:31:40 -0800, 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. I use this script ( TAGS for emacs ): etags --lang=none --regex='/[ \t]*\(def\|class\)[ \t]+\([^ :(\t]+\)/\2 /' *.py It's all in the same line! -- From kuncej at mail.conservation.state.mo.us Mon Dec 27 18:26:16 1999 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Mon, 27 Dec 1999 17:26:16 -0600 Subject: Anyone know of a simple socket proxy in python? References: Message-ID: > 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: The proxy code in urllib.py might give you some ideas. --Jeff From skip at mojam.com Fri Dec 3 12:24:06 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 3 Dec 1999 11:24:06 -0600 (CST) Subject: Be gentle with me.... In-Reply-To: <828s7g$d4f$1@mach.vub.ac.be> References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: <14407.64694.493050.310503@dolphin.mojam.com> Thomas> The use of indentation is IMO indeed a (very) weak point of Thomas> python. Many people however who use python like it. I've been Thomas> using python for one year now and I still deeply dislike Thomas> it. As has been stated in c.l.py numerous times, Python does support block delimiters: if 0 is None: #{ print "hi there!" #} <0.2 wink> 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 python-list at teleo.net Mon Dec 6 18:23:21 1999 From: python-list at teleo.net (Patrick Phalen) Date: Mon, 6 Dec 1999 15:23:21 -0800 Subject: A Date With Tim Peters... In-Reply-To: <199912020003.TAA13009@eric.cnri.reston.va.us> References: <199912020003.TAA13009@eric.cnri.reston.va.us> Message-ID: <9912061528510A.02072@quadra.teleo.net> [Guido van Rossum, on Wed, 01 Dec 1999] :: 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. I've heard a nasty rumour that the Tim Peters has no intention of showing up. Instead, Guido plans to have a Tim Peters name tag printed and will hire one of those professional Tim Peters look-alikes. From kc5tja at garnet.armored.net Sun Dec 19 01:00:14 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 19 Dec 1999 06:00:14 GMT Subject: The Official Naughty Or Nice List References: <199912190039.TAA30901@peterjh.goshen.edu> Message-ID: In article , Robin Becker wrote: >Interestingly my spell checker insists that satan be spelled with a >capital. That's because Satan is a proper name, and not a generic noun. In English, proper nouns and names are capitalized. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From skip at mojam.com Thu Dec 16 12:06:25 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 16 Dec 1999 11:06:25 -0600 (CST) Subject: RFC: Implementing ECS in Python In-Reply-To: <14425.4385.984935.767038@cmpu.net> References: <14425.4385.984935.767038@cmpu.net> Message-ID: <14425.7185.392402.195200@dolphin.mojam.com> Kendall> Kendall> With ECS you can programmatically build XML, HTML4 and RTF Kendall> structured documents in an OOP way. Looks an awful lot like Joel Shprentz' htmlDoc module. Am I the only person still using it to any degree? I don't know if Joel is still maintaining/using it, and if so, where it might be. I use a version dated 1995. 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 roy at popmail.med.nyu.edu Fri Dec 31 09:10:17 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Fri, 31 Dec 1999 09:10:17 -0500 Subject: Splitting up classes between files Message-ID: I've got a top-level class, a, and a bunch of sub-classes, a1, a2, a3, etc. To make it easier to manage the code, I'd like to put each in a separate file, but still have the user be able to import the whole bunch with a single import, i.e. not have to do "import a, a1, a2, a3, etc". Can I just put "import a1, a2, a3, etc" in the bottom of my "a.py" file? It seems like it should work fine, but are there any hidden gotchas? -- Roy Smith New York University School of Medicine From robert at leftfieldcorp.com Wed Dec 15 16:35:12 1999 From: robert at leftfieldcorp.com (Robert Leftwich) Date: Thu, 16 Dec 1999 08:35:12 +1100 Subject: Zope project management? In-Reply-To: <19991215200006.790F71CE91@dinsdale.python.org> Message-ID: Greg Wilson wrote: > Hello. Has anyone used Zope (or other Python software) to build a project > management platform? I'm looking for something like Microsoft Project, but > (a) cross-platform, (b) web-enabled, and (c) Python friendly. Have a look at the Xen project management system written in Zope http://bits.netizen.com.au/Xen/. Robert Leftwich From greg.ewing at compaq.com Wed Dec 15 03:36:44 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 15 Dec 1999 21:36:44 +1300 Subject: Python complaints References: <000201bf3bd4$2bda5e20$542d153f@tim> <38553B8B.822488D3@callware.com> Message-ID: <3857531C.FED5DE60@compaq.com> Ivan Van Laningham wrote: > > 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;-) They wouldn't. They're a replacement for map with a lambda argument, not lambdas in general. > 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 can always replace a lambda with a nested function definition, with no loss of functionality. In your example, for j in range(lim): ne = (10 * i) + j def callback(m=elements[ne]): setimage(m) tm.add_command(label=elements[ne], command=callback) The only thing lambdas buy you is less lines of code, if the function body happens to be a single expression. (Some would say at the expense of clarity.) Greg From philh at vision25.demon.co.uk Wed Dec 15 18:57:43 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Wed, 15 Dec 99 23:57:43 GMT Subject: XML parsing References: <945048362snz@vision25.demon.co.uk> <945132645snz@vision25.demon.co.uk> <99121415380907.00954@quadra.teleo.net> Message-ID: <945302263snz@vision25.demon.co.uk> In article <99121415380907.00954 at quadra.teleo.net> python-list at teleo.net "Patrick Phalen" writes: > [Phil Hunt, on Mon, 13 Dec 1999] > :: In article > :: mgushee at havenrock.com "Matt Gushee" writes: > :: > 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 > > That would be Tony Smith, the Managing Editor. > > Why not just tell him his output is non-standard and ask him to change > the output to 'version="1.0"'? You know, I had never thought of that! Duh! Still, I have got it working now. -- Phil Hunt - - - phil at comuno.com "Software is like sex, it's better when it's free" -- Linus Torvalds From jpb at technologist.com Mon Dec 13 22:01:21 1999 From: jpb at technologist.com (jpb) Date: Tue, 14 Dec 1999 03:01:21 GMT Subject: Need information om Python byte-code References: <8345m3$27t$1@hyperion.nitco.com> Message-ID: In article <8345m3$27t$1 at hyperion.nitco.com>, "Nick Maxwell" wrote: >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 FYI, there is a mud written entirely in Python - look for poo on Joe Strout's website (www.strout.net). jpb -- Joe Block It isn't that unix isn't a user friendly operating system, it's just choosy about who it wants to be friends with. From cgw at fnal.gov Thu Dec 9 15:27:55 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Thu, 9 Dec 1999 14:27:55 -0600 (CST) Subject: tail -f with Python/Tkinter In-Reply-To: <82mpj9$vq8$1@nnrp1.deja.com> References: <82mpj9$vq8$1@nnrp1.deja.com> Message-ID: <14416.4299.177581.835224@buffalo.fnal.gov> pstmarie at my-deja.com writes: > Hi, > I'm quite new to Python and have not been able to > find the answer to this in my books or on the web. > How do I tail -f a log file using a Tkinter > widget? It's on a Linux system.. I'm not sure if you mean you really want to run "tail -f" as a child process and collect its output, or just do the equivalent thing in Python. The latter is much simpler - "tail" is a very simple program and it's easier to just do the equivalent thing in Python, rather than opening a pipe to a child process. Here's a simple script which may do what you need: #!/usr/bin/env python import sys,os import time from Tkinter import * from ScrolledText import ScrolledText class LogViewer(Frame): def __init__(self, parent, filename): Frame.__init__(self,parent) self.filename = filename self.file = open(filename, 'r') self.text = ScrolledText(parent) self.text.pack(fill=BOTH) data = self.file.read() self.size = len(data) self.text.insert(END, data) self.after(100, self.poll) def poll(self): if os.path.getsize(self.filename) > self.size: data = self.file.read() self.size = self.size + len(data) self.text.insert(END, data) self.after(100,self.poll) if __name__ == "__main__": root = Tk() viewer = LogViewer(root, sys.argv[1]) viewer.mainloop() From wzab at ise.pw.edu.pl Thu Dec 9 09:56:50 1999 From: wzab at ise.pw.edu.pl (Wojciech Zabolotny) Date: Thu, 9 Dec 1999 15:56:50 +0100 Subject: How to add element to the list in C extension module? Message-ID: Hi All, I need to dynamically build the complex python data structure in my C extension. I'd like to build a list of structures (lists or dictionaries), where the amount of items is not known a priori. I tried to do something like this: PyObject * ob; int count=0; //There is the loop where I add items while(!loop_end_condition) { // here key1, val1 ,key2, val2 are calculated // ... // if(!count) { ob=Py_BuildValue("{s:i,s:i}",key1,val1,key2,val2); } else { ob=Py_BuildValue("O{s:i,s:i}",key1,val1,key2,val2); } } But what I get is eg.: (({'bc': 5, 'as': 3}, {'bc': 5, 'as': 3}), {'bc': 5, 'as': 3}) instead of: ({'bc': 5, 'as': 3}, {'bc': 5, 'as': 3}, {'bc': 5, 'as': 3}) How to do it correctly? By the way. Does Py_BuildValue increases the reference count of the created object? What format ("O" or "N") should I use to nest such object in another object created by Py_BuildValue? -- Wojciech M. Zabolotny http://www.ise.pw.edu.pl/~wzab <--> wzab at ise.pw.edu.pl http://www.freedos.org Free DOS for free people! From peter.stoehr at weihenstephan.org Mon Dec 27 17:08:03 1999 From: peter.stoehr at weihenstephan.org (Dr. Peter Stoehr) Date: Mon, 27 Dec 1999 23:08:03 +0100 Subject: Why doesn't this work? References: Message-ID: <3867E343.D41E8111@weihenstephan.org> Hi Matt, the following code works perfectly for me ... import httplib h=httplib.HTTP("www.weihenstephan.org") h.putrequest('GET', '/~petestoe/index.html') h.putheader('Accept', 'text/html') h.putheader('Accept', 'text/plain') h.endheaders() errcode, errmsg, headers = h.getreply() print errcode # Should be 200 f = h.getfile() data = f.read() # Get the raw HTML f.close() so it seems to me that your problem is at some other place of your code. Greetings from Erding/Bavaria/Germany/Europe/World Peter "Matt Mencel > > When I try and run this code snippet I get this error in the f.read line. > > <> > -1 > Traceback (innermost last): > File "net.py", line 10, in ? > data = f.read() # Get the raw HTML > TypeError: not enough arguments > > <> > import httplib > h=httplib.HTTP(www.somewebsite.com) > h.putrequest('GET', '/somepage.html') > h.putheader('Accept', 'text/html') > h.putheader('Accept', 'text/plain') > h.endheaders() > errcode, errmsg, headers = h.getreply() > print errcode # Should be 200 > f = h.getfile() > data = f.read() # Get the raw HTML > f.close() -- --------------------------------------------------------------------------- Dr. Peter Stoehr --- Teisenbergweg 6 --- 85435 Erding --- 08122/47232 http://www.weihenstephan.org/home/ak/support/team/jpg/peter.jpg --------------------------------------------------------------------------- I'm the terror that flaps through the night From mhammond at skippinet.com.au Thu Dec 9 06:12:44 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 09 Dec 1999 11:12:44 GMT Subject: Newbie -- pyd files ?? References: <3.0.32.19991209163018.00729338@mailhost.krdl.org.sg> Message-ID: Annapoorna Nayak Pangal wrote in message <3.0.32.19991209163018.00729338 at mailhost.krdl.org.sg>... >I donot find any file by name "_LinearAlgebraModule.py" on my system but >there is a file by name "_LinearAlgebraModule.pyd" ! >So, would like to know more on this "pyd" files. It is a DLL, built by a C compiler. The source code is in C (and Im afraid I cant tell you where you might find that - should be easy to come across.) The are renamed to .pyd files simply to differentiate them from "regular" windows DLLs. Mark. From thamelry at vub.ac.be Fri Dec 3 04:44:27 1999 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 3 Dec 1999 09:44:27 GMT Subject: python 3D graphics References: <38475965.E80E77FB@trojanslair.zzn.com> Message-ID: <8283dr$sg6$1@mach.vub.ac.be> Black Mantis (themantis at trojanslair.zzn.com) wrote: : I am wondering if anybody has any useful information on programing in 3D : in python. i would appreciate it very much Python has excellent OpenGL bindings: http://starship.python.net:9673/crew/da/Code/PyOpenGL You can use these bindings in combination with Tkinter, but that GUI toolkit is IMO becoming obsolete. An attractive alternative is FOX, which comes with a standard GLViewer widget (featuring quaternion rotation, picking, lighting, etc.). You can find more info about Fox at: http://www.cfdrc.com/FOX/fox.html http://home.HiWAAY.net/~johnson2/FXPy/ I don't know whether wxPython has an OpenGL canvas (I'd appreciate more info on this myself). Cheers & happy hacking, ------------------------------------------------ Thomas Hamelryck//Free University Brussels (VUB) Intitute for Molecular Biology// ULTR Department Paardestraat 65//1640 Sint-Gensius-Rode//Belgium ------------------------------------------------ From fredrik at pythonware.com Fri Dec 10 10:18:33 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 10 Dec 1999 16:18:33 +0100 Subject: Error confusing a newbie References: <19991210100320.B18389@dmcom.net> Message-ID: <008e01bf4321$d3705780$f29b12c2@secret.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 From shae at tripoint.org Thu Dec 23 10:28:31 1999 From: shae at tripoint.org (Shae Erisson) Date: Thu, 23 Dec 1999 15:28:31 GMT Subject: Jpython woes, please help References: Message-ID: <38623E3C.51E8D39E@tripoint.org> Kevin Howe wrote: > All is well until it starts "Tracking Java Dependencies", where it produces: > Atribute Error: java package 'org.python.modules' has no attibute > '__path__' > > Can anyone enlighten me as to what's happenning here? > > Much Thanks, > kh if you look through the jpython mailing list archives, there's a patched main.py attached to one of the messages for jpythonc in jpy1.1beta4 that will fix that problem. -- Shae Matijs Erisson - shae at lapland.fi Programmeur-savant - Python, Java, JPython From roth at teleport.com Thu Dec 30 13:02:14 1999 From: roth at teleport.com (tony roth) Date: Thu, 30 Dec 1999 10:02:14 -0800 Subject: newbie unicode pickle question Message-ID: Given the following code import win32net,win32netcon,pickle,win32api,win32con dm=win32net.NetServerEnum('',100,win32netcon.SV_TYPE_NT,'xyzdomain',0,4096) pickle.dumps(dm) I get the following errors: Traceback (innermost last): File "F:\apps\Python\Pythonwin\pywin\framework\scriptutils.py", line 313, in RunScript exec codeObject in __main__.__dict__ File "F:\apps\Python\test.py", line 4, in ? pickle.dumps(dm) File "F:\apps\Python\Lib\pickle.py", line 822, in dumps Pickler(file, bin).dump(object) File "F:\apps\Python\Lib\pickle.py", line 97, in dump self.save(object) File "F:\apps\Python\Lib\pickle.py", line 198, in save f(self, object) File "F:\apps\Python\Lib\pickle.py", line 288, in save_tuple save(element) File "F:\apps\Python\Lib\pickle.py", line 198, in save f(self, object) File "F:\apps\Python\Lib\pickle.py", line 328, in save_list save(element) File "F:\apps\Python\Lib\pickle.py", line 198, in save f(self, object) File "F:\apps\Python\Lib\pickle.py", line 361, in save_dict save(value) File "F:\apps\Python\Lib\pickle.py", line 159, in save raise PicklingError, \ pickle.PicklingError: can't pickle 'PyUnicode' objects I guess my main questions is how do I pickle unicode objects? tia tr From JoeSmith at bogusaddress.com Sun Dec 19 06:46:04 1999 From: JoeSmith at bogusaddress.com (Joe Smith) Date: Sun, 19 Dec 1999 11:46:04 GMT Subject: win32 binary data manipulation in ASP Message-ID: <385CC64E.25E91136@bogusaddress.com> I am trying to write a server side ASP script in python. buffer = os.read(fd, numBytes) Response.BinaryWrite(buffer) I notice that I am getting exactly double the number of bytes on output. I suspect that the string returned from os.read() is getting converted to unicode. I am looking for a way to convert the string to an array of bytes, not an array of unicode characters. From mgushee at havenrock.com Mon Dec 13 10:51:43 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 13 Dec 1999 10:51:43 -0500 Subject: GTK choking on wxPython Message-ID: Hello, all-- Well, I thought I'd try out Sean McGrath's cool new XML tool, C3. So I finally broke down and installed wxWindows and wxPython. But when I try to run c3.py (or the wxPython demo), I get the following errors: GLib-WARNING **: getpwuid_r(): failed due to: No such user 500. Gdk-ERROR **: an x io error occurred aborting... Or, if I run it as root, I get only the second error. Either way, it crashes and burns. Platform: Red Hat Linux 5.2 (kernel 2.0.36, glibc 2.0.7) GTK: 1.2.1 Python: 1.5.2 wxWindows: wxGTK 2.1.11 wxPython: 2.1.11 The problem seems to be wxPython specific, since all the wxGTK demos run fine. Has anybody seen this before? Please don't tell me I have to upgrade GTK (unless it's true ;-). I hate upgrading GTK. Thanks for any tips. -- Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ From ovazquez at sprint.ca Sun Dec 26 20:43:03 1999 From: ovazquez at sprint.ca (Orlando Vazquez) Date: Sun, 26 Dec 1999 17:43:03 -0800 Subject: pound bang (#!) problem... Message-ID: <3866C427.C4124694@sprint.ca> Hi guys, I'm working on an html preprocessor for a site and I came across a problem. I want to have a special extension on files that will be executed by the server. (say .pyhtml) 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 python rules! 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.. How can I make this idea work? Thanks a great deal! -- Orlando Vazquez From themantis at trojanslair.zzn.com Sun Dec 5 16:13:40 1999 From: themantis at trojanslair.zzn.com (Black Mantis) Date: Sun, 05 Dec 1999 13:13:40 -0800 Subject: Tkinter Tutorial Message-ID: <384AD57E.54147EF4@trojanslair.zzn.com> I woul like to learn to program with thinkter from python. I was wondering if there was a tutorial somewhere online From akuchlin at mems-exchange.org Wed Dec 22 14:17:34 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 22 Dec 1999 14:17:34 -0500 Subject: Sydney scoreboard? References: <385DB48C.7A7A52D6@bby.com.au> <8On74.6414$Dh3.85256@ozemail.com.au> Message-ID: <3dk8m6zsxd.fsf@amarok.cnri.reston.va.us> Timothy Docker writes: > Does that include setting the scoreboard on fire ? :-) I remember this > happening sometime last season. > Presumably this was not a software failure, but it brings a more > concrete meaning to software "crash and burn". Now, now, let's not flame Mark over this... Perhaps this resulted from burning too many cycles in unoptimized code. Or simply using 'signed char'? --amk From tholap at compuserve.com Sun Dec 12 16:59:58 1999 From: tholap at compuserve.com (Olaf Appelt) Date: Sun, 12 Dec 1999 22:59:58 +0100 Subject: Suitability of Python for a Big Application? References: <830vic$r2t$1@nnrp1.deja.com> Message-ID: <83181a$n90$1@ssauraab-i-1.production.compuserve.com> 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 From cfelling at iae.nl Mon Dec 20 17:32:19 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 20 Dec 1999 23:32:19 +0100 Subject: help with negative numbers please References: <83jd7t$mi1$1@hardcore.ivn.net> Message-ID: <83mapj$ck$1@vvs.superst.iae.nl> Jim Mace wrote: > If I have an equation like this: y = z - x. How can I get y to equal either > a negative or positive number. in expressions Python uses == rather then =, and abs() does the rest: >>> [ abs(y) == abs(z-x) ] == [ (y == z-x) or (-y == z-x)] 1 -- groetjes, carel From gmcm at hypernet.com Wed Dec 15 09:15:17 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 15 Dec 1999 09:15:17 -0500 Subject: C++ (was RE: Python suitability) In-Reply-To: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it> Message-ID: <1266856018-8846450@hypernet.com> 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. > Or, to put it another way: you have to DESIGN, rather than > just start hacking. Hackers hack, designers design, no matter what the language, (you actually come close to saying this later). > Specifically, if you follow the advice of Scott Meyers, in his > excellent "Effective C++" (CD Edition): never inherit from a > concrete class. Never make a rule of thumb into a religeous dogma. There are excellent reasons, at times, for violating this "rule". Take a look at scxx on my starship pages. While I would *never* give that out as an example to someone learning C++, it's a case where a single "virtual" would break the entire thing. > One key difference is that, in C++, you _can_ design and > maintain huge and flexible projects -- the language does not > hinder, and gives you almost all the tools you need for that If C++ (or Java) gave you those tools, there would be no "need" for UML. UML "works" (for some definition of "works" ) because it hides language complexity. It also lacks expressiveness. Look at "Design Patterns". Most of those patterns are directly expressible in Python. So much so, that if you translate the UML into Python and use that, the result will be needlessly complex and stilted. What the UML actually expresses is how to get around language barriers. There are useful diagrams in UML, (eg, the state and transition diagrams). Unfortunately, the one most tools use to generate code (and draw from reverse engineering) has everything to do with language structure, and nothing to do with what actually happens at runtime. To put it bluntly: people spend most of their time designing the wrong thing. Worse, they get it wrong, but it's carved in stone now; so the final system is either needlessly complex and marginally functional, or bears no resemblance to the "design". The secret to good performance is to prototype and prototype, then code the bottlenecks in a faster language. The secret to large systems is to prototype and prototype, until you've got clean separation of the system into managable pieces, then code in whatever language most suits the need of each piece. This is contrary to the advice of a lot of the gurus you mention; but they have a large vested interest in the process. - Gordon From schorsch at schorsch.com Fri Dec 3 07:53:30 1999 From: schorsch at schorsch.com (Georg Mischler) Date: Fri, 03 Dec 1999 12:53:30 GMT Subject: Email address check function References: <19991202163334.A3934@stopcontact.palga.uucp> <3846C48A.F793423A@inka.de> Message-ID: <828ega$2a8$1@nnrp1.deja.com> Michael Stroeder wrote: > 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? Partly. For the right hand side of the @ you might want to check rfc1035 (DNS) as well: - There must be at least one "." - There must be a "name" on each side of the each "." (obviously...) - "Names" are case insensitive (fold to lowercase internally). - Every "name" must be at least two, and at most 32 characters long. - The last (toplevel) "name" must be two or three characters long. - Every "name" must start with one of [a-z]. - Every "name" may only contain [-a-z0-9] (many nameservers also allow the "_", so you may want to accept that as well). This seems to cover the most common formal errors in SMTP based mail addresses. Note that this right hand side of the address *dosen't* necessarily describe a physical host on the internet. The DNS system may give you any number of hosts when you request the MX record by this name, all of which may have arbitrary other names, if any. You basically can't make any assumptions on the left hand side of the "@", since that is in the hands of the possibly proprietary mail system processing the mail on arrival at the target host. > 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(?). If you don't mind your visitor to wait up to three minutes or five minutes for the result page, go ahead. :) > You could send some access code via email for further access to > your system. This is what most decent mailing list software does and is highly reccomended if you care for collecting operative mail addresses. You need to consider if your application is worth the extra effort required by the user though. Have fun! -schorsch -- Georg Mischler -- simulation developper -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From r at dslsubc13.ultracom.net Fri Dec 24 13:48:36 1999 From: r at dslsubc13.ultracom.net (r at dslsubc13.ultracom.net) Date: Fri, 24 Dec 1999 18:48:36 GMT Subject: \s doesn't match Message-ID: I did this: a = 'a b' if match(r'\s',a): print 'error' and it didn't match. a = ' b' and it did match. Documentation seems to imply that \s matches whitespace anywhere in the string, what gives? -- - Andrei From fdrake at acm.org Wed Dec 1 13:33:16 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 1 Dec 1999 13:33:16 -0500 (EST) Subject: wish: multiline comments In-Reply-To: <823ldf$su4$1@news.ycc.yale.edu> References: <000b01bf3c10$4faf3910$3acbd9c2@peridot.optichrome.com> <018801bf3c12$d9722e80$f29b12c2@secret.pythonware.com> <009901bf3c15$6d5c5290$4500a8c0@thomasnotebook> <823l8h$shm$1@news.ycc.yale.edu> <823ldf$su4$1@news.ycc.yale.edu> Message-ID: <14405.27116.445187.462848@weyr.cnri.reston.va.us> Paul M writes: > Whoops, I sent that off without finishing... > > After importing foo2 there is a *.pyc file of ~ 2.6MB. Less than the > original *.py file of 2.8MB but quite large still. Paul, You created a file with a very long docstring, which is retained. Try creating a file that starts: """A really short string.""" ""And now a really, really long one.... ... """ *That* should produce the small .pyc with only the first string saved. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From grant at nowhere. Wed Dec 22 09:51:39 1999 From: grant at nowhere. (Grant Edwards) Date: Wed, 22 Dec 1999 14:51:39 GMT Subject: os.popen() vs os.system() References: Message-ID: In article , Sposhua wrote: >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 & Under Unix both start a new process. The important difference (as I understand it) is popen lets you interact with the program by reading and writing pipes while it's running. system() is more of a batch mode thing, the program runs to completion, then you get the return status. >??? If so, what's the use of os.system()? If you just want to run a shell command and don't need to provide any stdin and don't care about stdout/stderr. For example, if you just want to copy a directory tree from one place to another: status = os.system("cp -r srcdir /some/where/else") If you want to start a program, send it input and/or watch its output as it runs, then use popen(). -- Grant Edwards grante Yow! I just heard the at SEVENTIES were over!! And visi.com I was just getting in touch with my LEISURE SUIT!! From warrenk at midwest.net Wed Dec 15 09:21:26 1999 From: warrenk at midwest.net (Warren Kirk) Date: Wed, 15 Dec 1999 08:21:26 -0600 Subject: Python Imaging Library - Install Question References: Message-ID: Colleen & Brian Smith wrote: >If I try to run some of the example code in the manual, I get the following >stack trace: > >>>> im=Image.open("C:\\Image Files\\b-29.jpg") >>>> im.show() >Traceback (innermost last): [snip some traceback] > File "c:\Python\PIL\Image.py", line 40, in __getattr__ > raise ImportError, "The _imaging C module is not installed" >ImportError: The _imaging C module is not installed >>>> > >I've installed PIL (95/NT 1.52 compatible version) in C:\Python\PIL and the >_imaging.dll is installed there, C:\Windows\System and in C:\Python\DLLs. >I've set the same $PYTHONPATH in my autoexec.bat as in the registry. > >SET >$PYTHONPATH="C:\Python\Lib\plat-win;C:\Python\Lib;C:\Python\DLLs;C:\Python\L >ib\lib-tk;c:\Python\PIL" > >What am I overlooking? I don't know much about how dynamic libraries work, but on my Linux box I had the same problem. Try to import _imaging directly and see if that gives you an error from another library. The PIL code delays reporting the _imaging import error until _imaging is needed. (Look at the beginning of Image.py.) If import _imaging failed because of another library not being available, that information is lost. >>> import _imaging Traceback (innermost last): File "", line 1, in ? ImportError: /usr/lib/libtk8.0.so: undefined symbol: XFreePixmap >>> Anyway, if I import Tkinter, then everything works. Warren From fdrake at acm.org Fri Dec 10 10:46:36 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 10 Dec 1999 10:46:36 -0500 (EST) Subject: some random reflections of a "Python newbie": (2) language issues In-Reply-To: <001e01bf42bd$4da0cfe0$60a2143f@tim> References: <82od57$i7n$1@serv1.iunet.it> <001e01bf42bd$4da0cfe0$60a2143f@tim> Message-ID: <14417.8284.737237.696450@weyr.cnri.reston.va.us> Tim Peters writes: > "if a in X:" currently works only if X is a list, tuple or string. In > Python 1.6 it's supposed to work too if X is an instance of a class that > supports the special __contains__ method; see the 1.6 docs, preferably after > they're written . Send me a doc patch, and maybe we can tell Guido he has to implement it because that's how it's documented. ;-) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From donb at tensilica.com Thu Dec 30 12:15:05 1999 From: donb at tensilica.com (Donald Beaudry) Date: Thu, 30 Dec 1999 12:15:05 -0500 Subject: The Don Beaudry/Jim Fulton hack References: <9GHa4.1682$wG6.149869@ndnws01.ne.mediaone.net> <84g13m$p03$1@nnrp1.deja.com> Message-ID: <199912301715.MAA21012@zippy.hq.tensilica.com> > Now I'm trying to get MESS to compile and have run into a couple of > seemingly insurmountable obstacles: parts of the Python API used to > implement MESS seem to be missing (?!). They are: > PyAccess_Check > PyAccess_AsValue > PyAccess_SetValue > PyAccess_SetOwner > > Does anybody have a clue where these bits can be found (or explained - > I'd happily adjust the MESS code if I had a clue what it was doing)? In theory ;) all you have do is get rid of any code that deals with PyAccess_*. The whole access object concept has been purged from the language. The MESS is sadly out of date. The last time I played with it was nearly two years ago. It is, IMO, full of some really great ideas but is a bit overwhelming. It's goal was to provide "structure objects" and to make those structures appear no different from other builtin types. As a side effect, it got well into the idea of subclassing from built in types both from Python and C. Rather than consider it a failure, I like to think of it as a idea well before it's time. The "super tuple" discussion has got me to thinking that it might be time to start playing with it again. If what you are interested in is really the idea of subclassing from built-in types or playing with metaclass protocols, you might do better to take a look at my objectmodule extension. It's likely to be out of date too, but overall it is much more recent and an awful lot smaller. -- Donald Beaudry Tensilica, Inc. MTS 447 Moody Street donb at tensilica.com Waltham, MA 02453 ...Will hack for sushi... From mspal at sangria.harvard.edu Mon Dec 27 09:43:24 1999 From: mspal at sangria.harvard.edu (Michael Spalinski) Date: 27 Dec 1999 09:43:24 -0500 Subject: Python Considered Harmful References: Message-ID: As far as extracting the interface specification goes you will find doc.py invaluable (yes, I can see your future). You will find doc.py at http://starship.skyport.net/~lemburg/ BTW. doc.py will also provide you with documentation if you bothered to put in doc strings. M. From rumjuggler at home.com Tue Dec 7 20:29:15 1999 From: rumjuggler at home.com (Ben Wolfson) Date: Wed, 08 Dec 1999 01:29:15 GMT Subject: jaffo Message-ID: jaffo. -- Jaffo Liberty is commonly thought of not as a constant, but as something which must be made to expand indefinitely, lest it become boring. -- The Flummery Digest From bowman at montana.com Sat Dec 25 12:04:10 1999 From: bowman at montana.com (bowman) Date: Sat, 25 Dec 1999 17:04:10 GMT Subject: calling functions from Tk References: <842ma7$u2u$1@nnrp1.deja.com> Message-ID: scoobysnax5336 at my-deja.com wrote: >b=Button(root, text="Call test('blah')", width=12, command=test('blah')) Welcome to the world of lambda. 'command' only takes the address of the callback function, not a function and its parameters. Try command= lambda : test('blah') This is covered in the sidebar on page 113 of Learning Python, BTW. From tjreedy at udel.edu Sun Dec 19 21:05:11 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 20 Dec 1999 02:05:11 GMT Subject: help with negative numbers please References: <83jd7t$mi1$1@hardcore.ivn.net> Message-ID: <83k2sn$aji$1@news.udel.edu> In article <83jd7t$mi1$1 at hardcore.ivn.net>, jmace at ior.com says... > >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. Put the equation in your code as you wrote it. If this does not answer your question, rephrase it. From wware-nospam at world.std.com Sat Dec 4 19:00:56 1999 From: wware-nospam at world.std.com (Will Ware) Date: Sun, 5 Dec 1999 00:00:56 GMT Subject: map versus the 'for' loop References: <000101bf3ea4$a0206720$df2d153f@tim> Message-ID: 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 "" 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 "" object? -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From mdfranz at my-deja.com Mon Dec 13 01:06:20 1999 From: mdfranz at my-deja.com (mdfranz at my-deja.com) Date: Mon, 13 Dec 1999 06:06:20 GMT Subject: Extracting list of keys from 2-key dictionary Message-ID: <8322cq$idd$1@nnrp1.deja.com> I'm porting a script from perl that uses: dict[a,b] instead of $hash{$a}{$b} My goal is to get a unique list of the second keys for a value, when a=x In perl, this can be done with: @list = keys %{$hash{x}} Is there a quicker/easier way in python than the snippet below to do this? for a,b in dict.keys(): if dict.has_key(x,b): if b not in list: list.append(b) TIA, -matt Sent via Deja.com http://www.deja.com/ Before you buy. From fredrik at pythonware.com Tue Dec 21 05:54:17 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 21 Dec 1999 11:54:17 +0100 Subject: SystemError in Learning Python Example References: <385F1132.3DD500EB@worldnet.att.net> Message-ID: <001301bf4ba1$bba0d200$f29b12c2@secret.pythonware.com> 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 aa8vb at yahoo.com Wed Dec 29 12:31:57 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 29 Dec 1999 12:31:57 -0500 Subject: Returning list of arrays from C In-Reply-To: <3863F58C.DFED78BF@be-research.ucsd.edu> References: <3863F58C.DFED78BF@be-research.ucsd.edu> Message-ID: <19991229123157.B692238@vislab.epa.gov> Curtis Jensen: |I need to return a list of arrays from a CAPI. I'm using the Numeric |module to create some C extensions. Though, I need to return several |arrays to Python. How can I do this? You can start with something like this: target = PyList_New( verts->length ); for ( i = 0; i < vertes->length; i++ ) PyList_SetItem( target, i, PyFloat_FromDouble( (double) verts->vertices[i] ) ); Add error checking, and modify to taste using the C API reference guide: http://www.python.org/doc/current/api/api.html -- Randall Hopper aa8vb at yahoo.com From tim_one at email.msn.com Thu Dec 9 22:18:58 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 9 Dec 1999 22:18:58 -0500 Subject: some random reflections of a "Python newbie": (1) books, and free sites In-Reply-To: <82o0to$6eq$1@serv1.iunet.it> Message-ID: <001d01bf42bd$4c9d69a0$60a2143f@tim> [Alex Martelli] > ... > 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)...? Join the PSA (see http://www.python.org/) and you'll get a free account on the Starship. there's-cheap-and-then-there's-pathetic-ly y'rs - tim From tim_one at email.msn.com Thu Dec 16 20:16:48 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 16 Dec 1999 20:16:48 -0500 Subject: FORTRAN (was Re: indentation) In-Reply-To: <3dd7sfd9qt.fsf@amarok.cnri.reston.va.us> Message-ID: <000001bf482c$64aa3360$63a2143f@tim> [Andrew M. Kuchling, on template metaprogramming in C++] > The idea that C++ compilers are Turing complete blew me away. > (Hours of fun ... if you're Tim Peters.) Applying the wrong tool to the right job is indeed hours of fun, but hardly to be recommended . > 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. And that no compile-time computation is going to do well (whether via abusing C++ templates, or via systems that were actually intended for this purpose (like Lisp's comprehensive code-synthesis subsystems)). See http://www.fftw.org/ for the state of the art in FFT synthesis: modern architectures are so complex that you can't get peak speed anymore without feeding actual timings back into the synthesis. Alas, someone with a bad case of template fever probably won't even feel ashamed when they trick their templates into doing compile-time trial runs and I/O . every-generation-has-to-learn-to-get-sick-of-its-reinvention- of-m4-ly y'rs - tim From mark at intrepid.net Thu Dec 16 18:17:01 1999 From: mark at intrepid.net (Mark Conway Wirt) Date: Thu, 16 Dec 1999 23:17:01 GMT Subject: Python Image Lib Problems Message-ID: 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() Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 694, in show _showxv(self, title, command) File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 974, in _showxv file = self._dump(format=format) File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 311, in _dump file = file + "." + format TypeError: illegal argument type for built-in operation ..or... >>> import Image, ImageDraw >>> im = Image.open("lena.ppm") >>> draw = ImageDraw.Draw(im) >>> draw.line((0,0), im.size, fill=128) Traceback (innermost last): File "", line 1, in ? TypeError: keyword parameter redefined >>> Am I missing something obvious? I'm new to python programming, and finding these errors a bit confusing. Thanks in advance. I'm using 1.5.2 on a FreeBSD 3 box, if that's important. --Mark From b2blink at hotmail.com Tue Dec 21 14:07:22 1999 From: b2blink at hotmail.com (Ulf Engstrøm) Date: Tue, 21 Dec 1999 14:07:22 CET Subject: Tkinter variables Message-ID: <19991221130722.94537.qmail@hotmail.com> Hello again :) I'm creating an app in Tkinter and I got stuck where I wanted to add a number of checkbuttons. I want them to be like: c0 = Checkbutton(root,text=name0,onvalue=name0,offvalue='',variable=var) c0.grid(row=0) c1 = Checkbutton(root,text=name1,onvalue=name1,offvalue='',variable=var) c1.grid(row=1) for any number of names that I get from a database, how do I get the "c0", "c1" and so on for this? Text and values are no problems. what came to mind was the eval from JavaScript, is there such a function? for name, num in myClass.names,range(len(myClass.names)): eval("c"+num) = Anyone has any good hints? Regards Ulf Engstr?m http://www.b2b-link.com ulf.engstrom at b2b-link.com ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From gp.ciceri at acm.org Mon Dec 20 08:02:59 1999 From: gp.ciceri at acm.org (g.p.ciceri) Date: Mon, 20 Dec 1999 14:02:59 +0100 Subject: Retrieving value of serial after insert into Informix Message-ID: <385E2903.1A725BC1@acm.org> Hello all, I am using Informix and informixdb1.3 . I am doing an insert into a table that contains a serial column. How can I retrieve the value of the serial column that was associated with the insert? (it should be in the sqlerr return message, but I'm not able to query the connection to ask for it) Any helps is welcome. /gp -- "If one advances confidently in the direction of his dreams, and endeavors to live the life which he has imagined, he will meet with a success unexpected in common hours." (Thoreau, "Walden") Gian Paolo Ciceri Via B.Diotti 45 - 20153 Milano MI ITALY mobile : ++39 347 4106213 eMail : gp.ciceri at acm.org webSite: http://www.tialabs.com -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 1844 bytes Desc: S/MIME Cryptographic Signature URL: From amcguire at coastalnet.com Tue Dec 21 09:04:24 1999 From: amcguire at coastalnet.com (Andrew N. McGuire) Date: Tue, 21 Dec 1999 08:04:24 -0600 Subject: Newbie Getopts Question References: <385951E7.4394EDEC@coastalnet.com> Message-ID: <385F88E8.B0C5C17C@coastalnet.com> Hey all, Thank you Justin et al. It is good to hear from you all, as you all provided some good insight, hopefully I will have many good years of hacking with python in the future.. But I am taking baby steps right now... Needless to say once more that all the help is appreciated. Oops I guess it wasnt needless cause I said it ;^). Tankuverimutch, Andrew Justin Sheehy wrote: > "Andrew N. McGuire" writes: > > > this seems like a somewhat ineffecient way of handling options. > > There are certainly some things you can do to make your code cleaner > here. However, you are not alone in your judgement of the standard > getopt module. It works quite well, but is not as feature-rich as > many people would like. > > Those people don't seem to agree on exactly how it should be better, > though. Thus, several people have written their own getopt modules. > > I've seen one or two private in-house implementations, and a number of > people have posted their own getopt replacements here. I have also > done this, though to suit a specific need: I wrote a getopt-like > module that was designed to mimic the functionality of the argument > parsing in the suites of user commands for manipulating the Andrew > File System. If anyone wants such a beast, feel free to ask me for it. > > With that diversion out of the way, I'll see if I can offer any useful > suggestions about the code here... > > > arglist = sys.argv[1:] > > This isn't necessary. It could even be confusing, since you use that > name for something else afterward. You can omit this and just > replace the following line: > > > optlist, arglist = getopt.getopt(arglist, 'f:n:i:o:c:') > > With: > > optlist, arglist = getopt.getopt(sys.argv[1:], 'f:n:i:o:c:') > > > list = [] > > > > for opt in optlist: > > list.append(opt[0]) > > Just because of all of the bad press map and lambda have had lately ;->, > I'll mention that this whole snippet can be done as follows, among > other ways: > > list = map(lambda x: x[0], optlist) > > > for opt in optlist: > > I recommend something more like: > > for opt, value in optlist: > > Then you can replace all following uses of `opt[0]' and `opt[1]' with > `opt' and `value', respectively. Tuple unpacking in this sort of > context is a wonderful feature that I use frequently. > > I'm sure that as you continue to familiarize yourself with Python, you > will find many more ways to improve your code. > > -Justin > > From dirk.engelmann at iwr.uni-heidelberg.de Fri Dec 10 19:08:29 1999 From: dirk.engelmann at iwr.uni-heidelberg.de (Dirk Engelmann) Date: Fri, 10 Dec 1999 19:08:29 -0500 Subject: httplib problem Message-ID: <385195FD.D4E81815@iwr.uni-heidelberg.de> Hi! I want to transfer data by http betweeen a http-server (cgi-script) and a client (httplib). I tried this using httplib on the client side and transfering data to a cgi-script, but it failed. I appended a litele sample - which didn?t work and I can?t find a solution. Is there another easier way to do this ? Thanks for any help! Cheers, Dirk Engelmann #------------- http-client ------------------- import httplib from string import joinfields # sample data which should be transfered to the cgi-script port.py data = "testdata" # header: hdr = [] part = [] hdr.append('Content-Disposition: form-data; name="data"') hdr.append('Content-Type: application/octet-stream') hdr.append('Content-Length: %d' % len(data)) part.append("%s\n\n%s" % (joinfields(hdr,'\n'), data)) # st contains header and data st = joinfields(part, '') # open httplib and execute cgi-script port.py h = httplib.HTTP('localhost') boundary= '%s%s_%s_%s' % \ ('-----', int(time()), os.getpid(), randint(1,10000)) contentType = 'multipart/form-data; boundary=%s' % boundary h.putrequest('POST', '/cgi-bin/port.py') h.putheader('Accept', '*/*') h.putheader('Content-Type', contentType) h.putheader('Content-Length', str(len(st))) # transfer the data to cgi-script port.py h.endheaders() h.send(st) errcode, errmsg, headers = h.getreply() data = h.getfile().read() # Get the raw HTML print data #--------------- port.py : cgi-script on server ----------------- import cgi form = cgi.FieldStorage() print form['data'] From ionel at psy.uva.nl Fri Dec 3 04:35:15 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Fri, 3 Dec 1999 10:35:15 +0100 Subject: split this newsgroup? References: Message-ID: <8282v6$8b5@mail.psy.uva.nl> Max M. Stalnaker wrote in message news:LHG14.143$0l4.2672 at typ21.nn.bcandid.com... | The volume on this newgroup might justify splitting the newgroup. Comments? The volume itself is not a reason enough. This newsgroup is the agora: the place were everybody come to discuss or take note to latest developments. Or just ask a question when there is no way to get the answer elsewhere. If one feels a need to focus, there are the SIGs, each with its own mailing list. But this meeting place is naturally going to stay heterogeneous and large. Maybe it would be a good idea, however, to move (or duplicate) the SIG forums on the news format, thus opening them up to a larger audience. This may cast out a more accurate representation of the activity going on in the Python community. (And clutter less some mailboxes.) Moreover, because SIGs typically carry more elaborate contributions, a move to NNTP will serve the image of Python better. (On c.l.py there is no month without less than 2 loong holy wars leaving scars and bloody threads behind... :-) If SIG specific newsgroups are introduced, than messages would flow more naturally to their right audience. ionel From phd at phd.russ.ru Wed Dec 22 12:19:10 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 22 Dec 1999 17:19:10 +0000 (GMT) Subject: Patch: httplib.py default timeout In-Reply-To: <83r0lh$mj6$1@nntp6.atl.mindspring.net> Message-ID: 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... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From pisecky at tttech.com Mon Dec 27 04:23:53 1999 From: pisecky at tttech.com (Manfred Pisecky) Date: Mon, 27 Dec 1999 09:23:53 GMT Subject: Memory leaks and reference counter of an object Message-ID: <38672f18.3391606@news.atnet.at> Hi folks! Is there a way to get the value of the reference counter of an arbitrary object from within Python code - of course immutable? The reason is my need to detect a memory leak and I want to track some objects and therefore I need to check their reference counter at the time they should be released. If you know a better resolution of memory leak detection I am glad, too! Thanks in advance Dipl.Ing. Manfred Pisecky pisecky at tttech.com TTTech Computertechnik GmbH, Schoenbrunnerstrasse 7, A-1040 Vienna, Austria Voice: +43 1 5853434-15, Fax: +43 1 5853434-90, http://www.tttech.com/ Next TTP Technology Seminar 31 January - 1 February 2000, Vienna, Austria Next TTP Technology Workshop 2-3 February 2000, Vienna, Austria 4th TTPforum 8 March 2000, Detroit, USA From DOUGS at oceanic.com Sat Dec 4 13:45:55 1999 From: DOUGS at oceanic.com (Doug Stanfield) Date: Sat, 4 Dec 1999 08:45:55 -1000 Subject: Tutorial for a NEWBIE Message-ID: <5650A1190E4FD111BC7E0000F8034D26A0F187@huina.oceanic.com> I just checked and found no 4.92. I'd also suggest this FAQ should be in the "1.General Info" section. -Doug- > -----Original Message----- > From: Thomas A. Bryan [mailto:tbryan at python.net] > Sent: Saturday, December 04, 1999 6:22 AM > To: python-list at python.org > Subject: Re: Tutorial for a NEWBIE > > > "Thomas A. Bryan" wrote: > > > > Nasshi wrote: > > > > > > I'm a newbie, and I need a tutorial. > > The answer to this question is now in the FAQ (4.92) > since it seems to come up often. Pointing new programmers > to the FAQ when they ask for a tutorial will hopefully also > remind them to check the FAQ when they want to convert a string > to a number, for example (question 4.44). > > ---Tom > > -- > http://www.python.org/mailman/listinfo/python-list > From cornelhughes at netscape.net Wed Dec 29 20:46:43 1999 From: cornelhughes at netscape.net (cornelhughes at netscape.net) Date: Thu, 30 Dec 1999 01:46:43 GMT Subject: pull data from a web page as text Message-ID: <84ecvh$mh2$1@nnrp1.deja.com> Is there a way in python to pull data from a web page as text. A method that would exclude html code and bring back text? Sent via Deja.com http://www.deja.com/ Before you buy. From phil at river-bank.demon.co.uk Sun Dec 19 10:04:57 1999 From: phil at river-bank.demon.co.uk (Phil Thompson) Date: Sun, 19 Dec 1999 15:04:57 +0000 Subject: ANNOUNCE: PyQt/PyKDE v0.10 (Python Bindings for Qt and KDE) Message-ID: <945616037.1224942994@news.demon.co.uk> I've put v0.10 of my Python bindings for Qt (v1.x) and KDE (v1.1x) in the usual place at: http://www.river-bank.demon.co.uk/software Changes since v0.9 are mostly under the covers, but include: PyQt should now compile under NT QString and QByteArray now implemented as regular classes Addition of KAccel The next version will include Qt v2.x support. Phil From mhammond at skippinet.com.au Thu Dec 9 23:51:44 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 10 Dec 1999 04:51:44 GMT Subject: LinuxCom References: <002f01bf42ba$12d40ba0$01ffffc0@worldnet.att.net> Message-ID: portran pobol p p++ Visual Pasic Emile van Sebille wrote in message <002f01bf42ba$12d40ba0$01ffffc0 at worldnet.att.net>... >postscript >pascal >pbasic >pcl From skip at mojam.com Mon Dec 13 12:42:28 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 13 Dec 1999 11:42:28 -0600 (CST) Subject: Multiple interpreters and the global lock In-Reply-To: <832pti$7u2$1@mailusr.wdf.sap-ag.de> References: <832pti$7u2$1@mailusr.wdf.sap-ag.de> Message-ID: <14421.12292.965385.716690@dolphin.mojam.com> Daniel> While searching DejaNews for the topic, I found that GvR is not Daniel> opposed to removing the lock, provided that there is no negative Daniel> impact on stability and performance. Daniel> What I hope to get as answers: Daniel> - is it possible? yes Daniel> - would patches be accepted, welcomed, frenetically applauded? yes Daniel> - what would be the smoothest path to completition, breaking Daniel> the least code? Start with Greg Stein's patches which were generated against (I think) 1.4. I'm not sure where they live these days. You may have to ask Greg (gstein at lyra.org). GvR is familiar with these patches (and with the problem in general), so if you start from there you'll probably have an easier time getting free threading patches incorporated into the core distribution. 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 JamesL at Lugoj.Com Fri Dec 10 00:44:08 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Thu, 09 Dec 1999 21:44:08 -0800 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: <38509328.B0844DD6@Lugoj.Com> "John W. Baxter" wrote: > I'm at the other end of the scale: I only briefly used a FORTRAN version > with a number in the name: the number was II. Most of my FORTRAN was the > unnumbered sort (before FORTRAN II). > > Source code for that (three-character identifiers) included in the comment > describing one of the two subroutines: > > MAN CALLS DOG TO .... > > --John (who once refereed a basketball game with Vannevar Bush as my partner) > > -- > John W. Baxter Port Ludlow, WA USA jwb at olympus.net Wow! THE Vannevar Bush? Speaking only for myself, I am duly impressed by your name-dropping. And yes, I do know who he is and I'm not kidding about being impressed. Jim (who once started to argue with Marvin Minsky without knowing who he was) From cjensen at be-research.ucsd.edu Thu Dec 23 16:51:02 1999 From: cjensen at be-research.ucsd.edu (Curtis Jensen) Date: Thu, 23 Dec 1999 13:51:02 -0800 Subject: embedding Python in C References: <1266214583-27560533@hypernet.com> Message-ID: <38629946.55E9569F@be-research.ucsd.edu> Gordon McMillan wrote: > > Curtis Jensen asks: > > > From a C file, how can I get values from a Python Class? > > For Example: > > > > File: Test.py > > class Klass: > > def __init__(self): > > self.a = 1 > > self.b = 2 > > self.c = 3 > > > > How can I get the values of a,b, and c from within a C function? > > Thanks > > Assuming you mean "from an instance of Klass", the answer > is the same way you would in Python. Well, in dynamic > Python. The equivalent of getattr(obj, name) is > PyObject_GetAttrString(o, name). > > - Gordon Suppose I have an instance of Klass called foo. In the C code I have: int tmp; PyObject *value; PyObject *pmod; pmod = PyImport_ImportModule ("foo"); value = PyObject_GetAttrString (pmod, "a"); PyArg_ParseTuple(value, "i", &tmp); printf("Value = %d\n",tmp); I should get "Value = 1" outputed to the screen right? I don't; I get some realy big number. I'm not sure what is wrong. I've tried several different combinations of variables and pointers and I can't get it. What's wrong with the code? Thanks. -- Curtis Jensen cjensen at be-research.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From skip at mojam.com Fri Dec 10 01:20:28 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 10 Dec 1999 00:20:28 -0600 Subject: DB-API-oriented example scripts? Message-ID: <199912100620.AAA22933@dolphin.mojam.com> I'm gearing up to try and replace a lot of homegrown database code with MySQL using the MySQLdb module. I'm not much of a relational database person, however, so I'm fairly unfamiliar with the computational model expected by the Python DB API. I can muddle my way through SQL. The MySQLdb module comes with no example code as far as I could tell however, and relies heavily on the 2.0 version of the Python DB API spec for docs, which contains no examples. Are there any good examples of how to use this API available? I saw a reference to a Linux Journal article on the db sig's page which I will take a look at. I saw nothing that looked like pointers to example code in the Vaults of Parnassus. Any suggestions? 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 schorsch at schorsch.com Wed Dec 1 08:08:39 1999 From: schorsch at schorsch.com (Georg Mischler) Date: Wed, 01 Dec 1999 13:08:39 GMT Subject: What's the canonical vi setting for Python indentation References: <38445B6A.A1283D2E@cs.mu.oz.au> <19991201111751.A1277@Ridcully.home> Message-ID: <8236kl$929$1@nnrp1.deja.com> Quinn Dunkan wrote: > Malcolm Tredinnick wrote: > >On Tue, Nov 30, 1999 at 11:46:10PM +0000, Sean Blakey wrote: > >> I don't know about canonical, but I have the following in my .vimrc > >> set expandtab "Turn's tabs into spaces > >> set hardtabs=4 "Make tabs 4 spaces wide > >> set tabstop=4 > >> set shiftwidth=4 "For use with << and >> > > > >I tend to avoid 'set expandtab' to save typing. If I want to > >back out from one indentation level to the previous one, it > >takes a single BackSpace to do so. If I am using the 'expandtab' > >setting, it takes four keystrokes (these things matter to me). > >Of course, I am also using the 'autoindent' setting (but, then > >again, doesn't everybody in vim?). > > Note that in vim5, you can set softtabstop=4 to take out > expanded tabs with a single backspace. Here's my config: Note that with *any* vi implementation you can use ^D to step back for whatever space sw= is set to. This even works in some of the situations where backspace wouldn't do anything. Have fun! -schorsch -- Georg Mischler -- simulation developper -- schorsch at schorsch.com +schorsch.com+ -- lighting design tools -- http://www.schorsch.com/ Sent via Deja.com http://www.deja.com/ Before you buy. From sdossett at metaphoria.net Wed Dec 1 15:53:39 1999 From: sdossett at metaphoria.net (sdossett at metaphoria.net) Date: Wed, 01 Dec 99 20:53:39 GMT Subject: Java 1.2 and JPython Message-ID: 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 71351.356 at compuserve.com Sat Dec 4 23:13:29 1999 From: 71351.356 at compuserve.com (T. C. Mits) Date: Sat, 4 Dec 1999 23:13:29 -0500 Subject: Unreal Tournament>>To Use Python?! References: <384808f3.3299668@news.telus.net> Message-ID: <82cp29$lmr$1@ssauraaa-i-1.production.compuserve.com> The announcement quote is: "Python: I don't know anything about this language but will look into it and get ideas. " BTW, the same page has a rant about how 'old' most languages are in terms of their underlying technology, for example, C++ and Java use 20+ year old techniques. I quote again: I'd like to end this update with a rant, based on the observation that mainstream programming languages, C++ and Java, are dismally far behind the state-of-the-art. The theoretical underpinnings of these languages were all set in stone in the late 1960's, before I was even born! Compare this state of affairs too advances in microprocessor technology, where time-to-market is under 5 years; or games and 3D hardware, where there is less than 24 months of lag between "great new idea" and "product on store shelves". Yet with programming languages, the lag in widespread adoption of new theory-level advances seems to be 20-30 years. (Note: I know the C++ and Java designs are much newer than that; what I'm looking at is the invention of the underlying concepts they're based, on such as object-orientation and polymorphism. In this view, C++ and Java could have been available in 1970, because all their theoretical underpinnings were complete by then.) Would Python fall under the same critique? guppy wrote in message news:384808f3.3299668 at news.telus.net... > > Python is being considered for use as the new and improved Unreal > Tournament scripting language. > > http://unreal.epicgames.com/ > > In the announcements listing. Now, I'm thinking it'd be right good to help > ol' Tim Sweeney make the right choice, so howzabout the true Gurus get some > EMail to him helping him understand that he's on the right track! > > The likely scenario is that the scripting language he creates could be > *based* on Python in significant ways. > > That's bound to help grow our community. > From wlfraed at ix.netcom.com Wed Dec 8 22:49:31 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Wed, 08 Dec 1999 19:49:31 -0800 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: <=CNPOJoL=1A0AudQdqJsHw5LCpzM@4ax.com> 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). -- > ============================================================== < > 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 AriHola at jabbos.com Fri Dec 10 00:04:47 1999 From: AriHola at jabbos.com (Ari Hola) Date: Fri, 10 Dec 1999 05:04:47 GMT Subject: 3 Month Free Trial - ACT NOW! Message-ID: <8e98.65.73@AriHola> Prepare yourself for a new revolution in men's sites. Do you want to become eligible to participate in our invitation only preview scheduled for early 2000? Enter your information below and you may qualify for a free 3 Month membership*. * Must be of legal age to qualify. http://www.jabbos.com Make Your Vote Count! From neelk at brick.cswv.com Wed Dec 1 18:08:28 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 1 Dec 1999 23:08:28 GMT Subject: predicate classes References: <81uo0t$2rr$1@nnrp1.deja.com> Message-ID: Mark C Favas wrote: >neelk at brick.cswv.com (Neel Krishnaswami) writes: > >>Here's a quick, rather kludged-together example: > > [...] > >Ummm, not for me - with 1.5.2 from CVS I get: [...] Er, it looks like I made a booboo. Try this instead; class Foo: x = 4 class Bar: def __init__(self): self.__class__.predicate = 1 self.__class__.__bases__ = (Foo,) def __setattr__(self, name, value): if name == 'predicate': self.__class__.predicate = value if value: self.__class__.__bases__ = (Foo,) else: self.__class__.__bases__ = () This works in my 1.5.2. The error appears to be that when __bases__ is defined as a class initialization statement it gets stuffed into the class __dict__ without updating the __bases__ attribute. (At least that's what a cursory examination of classobject.c suggests.) Funky. Neel From gerrit.holl at pobox.com Sat Dec 4 10:18:14 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 4 Dec 1999 16:18:14 +0100 Subject: "%(a)s ... %(b)s" % {'a': foo, 'b': '%(b)s'} Message-ID: <19991204161814.A5289@stopcontact.palga.uucp> Hello, I'm facing the following problem. I set __version__ and now I set a string like this: 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? regards, Gerrit. -- "The move was on to 'Free the Lizard'" -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates) 4:16pm up 4:36, 16 users, load average: 1.48, 1.05, 0.91 From tim_one at email.msn.com Thu Dec 16 21:59:12 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 16 Dec 1999 21:59:12 -0500 Subject: "sins" (aka, acknowledged language problems) In-Reply-To: <837usr$6vg$1@serv1.iunet.it> Message-ID: <000f01bf483a$b2e33140$63a2143f@tim> [Alex Martelli] > Browsing on the Perl sites recently, I came upon: > > http://www.perl.com/pub/1999/11/sins.html > > which is a very interesting acknowledgment of > some of the problems with Perl, including how some > of them used to be there but are now fixed (or in > the process of being fixed) while others are there > to stay. Yup, it's a very good article! So is its predecessor (Tom Christiansen's "The Seven Deadly Sins of Perl"). > I wonder if there is some analogous URL, on the > Python sites, that I could quote right next to this > one when I'm providing people with reasons they > might want to consider switching from Perl to > Python. There is not. A couple years ago I started a thread (see DejaNews) called "Why Python Stinks", hoping to uncover enough suppressed outrage to write a similar article about Python (my motivation was much like yours below). People were kind enough to whine about their pet peeves, but there was no consensus! For example, a few whined about whitespace, but that's a minority complaint. I personally would nominate 7 / 2 returning 3 instead of 3.5, but I think that's a minority view too (although, in this case, that doesn't matter because Guido shares it ). Another of mine is that: try: whatever except NameError, OverflowError: # this is the line something does something totally unexpected (unless you expect what it does ...). Nobody defended that, but it's also not a *common* mistake (trying to catch N exceptions is unusual for 1 < N < infinity). So while it's a sin, it's barely worth mentioning. Many complaints were isolated gripes about "missing features" from other languages (e.g., no lazy evaluation). While such things are disappointments to the complainers, they rarely have significant constituency. Other complaints were about the features that *can* have surprising consequences, and that lots of people seem to bump into once or twice before they "get it". Mutable default arguments are the clearest example of that. Yawn . The lack of "real GC" is shared by Perl, and that didn't make Perl's "deadly sins" list, so it shouldn't make Python's either (besides which, many people here *like* the relative predictability of refcounting! just as they do in Perl-land). Lexical closures (or, rather, the lack of them) has been the subject of many flamewars here over the years. There's no consensus on that either. Note that the Perl list comprises things that almost all Perl programmers agree about, and even after years of Perl programming (e.g., the confusing reference syntax). That's why I keep mentioning "consensus" above. The fact appears to be that Python has only one "deadly sin" by that criterion: the split between "types" and "classes". But you can program productively in Python for years before even *noticing* that! It's a "deadly sin" to some old-timers, and to many extension (in C) writers, but not to the majority of Pythoneers (bless their ignorant little hearts ). > After all, saying "here you will find, on > the Perl site, documentation on Perl defects, that > Python does not share -- Python, on the other > hand, is absolutely perfect" (:-) would not exactly > carry much strength... it would no doubt convince > the recipient that Pythonistas are fanatics, unable > to own up to their problems, while Perlites, while > labouring under many hard language problems, are > at least aware of them. OK: Build a web page that says Python's "lambda" sucks Only about 50% of Python programmers would dispute that one <0.5 wink>. if-individual-peeves-were-deadly-sins-we-could-overflow- hell-ly y'rs - tim From scarblac-spamtrap at pino.selwerd.cx Tue Dec 7 19:56:48 1999 From: scarblac-spamtrap at pino.selwerd.cx (Remco Gerlich) Date: 8 Dec 1999 00:56:48 GMT Subject: tiny python References: <19991207174430.7096.qmail@burton-krahn.com> Message-ID: Fran?ois Pinard wrote: > > Is it possible to build a python interpreter which just reads byte code? > > To spare lexing/scanning sources? Contest rules should tell what input > format is acceptable. It could be real sources, `.pyc' as produced by C > Python, or maybe some other representation (like a Scheme-readable tree), > but the representation could be chosen to convey part of the interpreter: > I'm not sure where cheating would begin. > > Just thinking loud. Do not read this message :-) [Only now he says it?] I'd say, it doesn't matter what you do, as long as you can use an arbitary high level language (C or up, .pyc code counts as up), and as long as it's *very* *small* *in total*. That's how I read his post, anyway. No clue how to do that, though. -- Remco Gerlich, scarblac at pino.selwerd.cx Murphy's Rules, "This is a job for Grandma Moses!": In Marvel Super Heroes (TSR), a hero runs at a top speed of 1.2 mph. From wtanksle at hawking.armored.net Sat Dec 4 20:41:14 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 5 Dec 1999 01:41:14 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: On 3 Dec 1999 16:47:44 GMT, Thomas Hamelryck wrote: >The use of indentation is IMO indeed a (very) weak point of python. That's a very strong statement. Can you support it, or should it be rephrased as "I very strongly dislike Python's indentation."? >Many >people however who use python like it. I've been using python for one >year now and I still deeply dislike it. 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... >However, the language is so nicely >crafted that its advantages easily outweigh the use of indentation. Hey, >no language is perfect! You might even start to like as many python users >do... One of the main reasons I use Python is the clean syntax, including the indentation. Otherwise I'd be using Perl -- it's not that bad either, so long as you limit your style and never look at anyone else's code. >Thomas Hamelryck//Free University Brussels (VUB) -- -William "Billy" Tanksley, in hoc signo hack From gerrit.holl at pobox.com Wed Dec 22 15:57:33 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 22 Dec 1999 21:57:33 +0100 Subject: Offtopic: millenium In-Reply-To: <199912222000.PAA17264@eric.cnri.reston.va.us>; from guido@CNRI.Reston.VA.US on Wed, Dec 22, 1999 at 03:00:19PM -0500 References: <199912222000.PAA17264@eric.cnri.reston.va.us> Message-ID: <19991222215733.A2783@stopcontact.palga.uucp> Hi all, > We know that the Python conference isn't until the next millennium. Hmm, we've already had a discussion on this, haven't we? regards, Gerrit. -- "Nature abhors a Vacuum" -- Brian Behlendorf on OSS (Open Sources, 1999 O'Reilly and Associates) 9:56pm up 1:22, 4 users, load average: 0.00, 0.02, 0.02 From timmuddletin at news.vex.net Fri Dec 10 19:49:23 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 11 Dec 1999 00:49:23 GMT Subject: some not so random reflections of a "Python newbie" voyeur References: <82o0to$6eq$1@serv1.iunet.it> <82s6fj$1e4e$1@news.tht.net> Message-ID: <82s72j$1eii$1@news.tht.net> alex at magenta.com (Alex Martelli) wrote: >Books matter -- a lot. I just got the "Top 10 of >1999" list of computer books Oh, one more thing that may be of general interest to readers (and perhaps to writers too!)... the extent of which might not have been realised before (it was a bit of a surprise to me---the magnitude), but the python tutorials out there are *really* popular. As Vaults of Parnassus gate keeper i've been watching with interest what items are viewed the most... and by far the tutorials as a class are the most regularly requested resource from the database... so a tip of the hat to all the great tutorial writers out there! Your work seems extremely appreciated. (Though one may also consider the stats skewed in that a lot of the long time afficionados already know where everything is--- and even seem to be able to spit out complete URLs to the most obscure resources in bot-like fashion (not mentioning any names, or even any single letters occuring in the english alphabet between E and G!) from their encyclopaedic brains, before lesser mere mortals can even think of pronouncing "VoP"---so one may theorise that a higher proportion of newbies are searching/browsing the database---to some extent perhaps). The most popular of all (and has been consistantly so since day one---again surprising to me) is the venerable "Python / Perl Phrase Book" page. People can't seem to get enough of this site. Must be a lot of Perl defectors looking for a helping hand (certainly not the other way around). Just a hint.. maybe someone (like Jak) should do some more updates and have it published! ... From 55555 at dakotacom.net Tue Dec 7 19:53:03 1999 From: 55555 at dakotacom.net (55555) Date: 7 Dec 1999 18:53:03 -0600 Subject: browser interface? References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> Message-ID: <384dabef_4@news5.newsfeeds.com> On Tue, 7 Dec 1999 08:30:04 -0800, Patrick Phalen wrote: > [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. > 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. -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==---------- http://www.newsfeeds.com The Largest Usenet Servers in the World! ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==----- From bernhard at alpha1.csd.uwm.edu Mon Dec 20 16:43:44 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 20 Dec 1999 21:43:44 GMT Subject: Hi to all! References: <83m513$n9r$1@pegasus.tiscalinet.it> Message-ID: Hi Luca, welcome to the Pythodome. On 20 Dec 1999 20:53:55 GMT, Luca Giuranna wrote: >I would like to say hello to this group. I'm new to Python but i think i'll >use it a lot! >Now i go to read the faq and other docs... then i'll come back with some >questions... wait for me :-) We are out here. 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 hartmut at oberon.noris.de Thu Dec 30 11:22:58 1999 From: hartmut at oberon.noris.de (hartmut Goebel) Date: Thu, 30 Dec 1999 17:22:58 +0100 Subject: RPM-interface/module References: <386B3CDB.FF843280@bibsyst.no> Message-ID: <16600370@oberon.noris.de> Thomas Weholt (thomas at bibsyst.no) schrieb: >Is there a RedHat package interface/module available for Python?? I've been looking for that just some days ago, without result yet. You may check "anaconda", RedHat's (graphical) installation program. This seams to be written in Python and contains a rpmmodules.so. Have a look at .../cdrom/instimages/usr/bin/anaconda and .../cdrom/instimages/usr/lib/python1.5/site-packages/ . I hav'nt found any source for anaconda :-( Please let my know what you've found out! +++hartmut From python-list at teleo.net Tue Dec 14 11:37:57 1999 From: python-list at teleo.net (Patrick Phalen) Date: Tue, 14 Dec 1999 08:37:57 -0800 Subject: newbie : books on python In-Reply-To: <3856690F.172ABB0C@yahoo.com> References: <3856690F.172ABB0C@yahoo.com> Message-ID: <99121408395302.00921@quadra.teleo.net> [Mahboob Hussain, on Tue, 14 Dec 1999] :: I program in C/C++/Java/Perl and want to learn Python. Could you suggest :: :: a few good books / sites to get me started ? http://www.python.org/doc/ http://www.python.org/psa/bookstore/ From cgw at fnal.gov Wed Dec 22 14:02:50 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Wed, 22 Dec 1999 13:02:50 -0600 (CST) Subject: Sorting large files In-Reply-To: <38611D77.68DFD3C0@erols.com> References: <38611D77.68DFD3C0@erols.com> Message-ID: <14433.8282.321495.794332@buffalo.fnal.gov> Edward C. Jones writes: > A Python program of mine generates a large number of tuples of > ten integers each. I need to sort this collection of tuples. If > there weren't so many tuples, I could make a Python list of these > tuples and use sort(). Currently I write the tuples out to a file > in ASCII and use the UNIX sort command. Is there a faster way to > sort these tuples? Sort them in blocks using Python then merge > using the UNIX sort? Are there any faster sort programs (perhaps > in database systems)? The list.sort method in Python uses quicksort (AFAIR) so it's just as efficient as using UNIX sort. What's your reason for not just doing exactly what you suggest, making a big Python list and sorting it? Total memory consumption? From mail at mikemccandless.com Sat Dec 4 13:05:46 1999 From: mail at mikemccandless.com (Michael McCandless) Date: Sat, 04 Dec 1999 13:05:46 -0500 Subject: including column information when an exception occurs Message-ID: <384957FA.164010A6@mikemccandless.com> Hi, When a Python exception occurs, the interpreter shows you the stack traceback to the line where the error occurred. Why, when it gets down to the actual line, does it not also report, eg, the column or subexpression in which the error occurs? This would be useful when you have lines that have a fair number of operations such that the exception could have come from more than one sub-expression. EG, in the following program: def test0(tup, i0, i1): test1(tup, i0, i1) def test1(tup, i0, i1): return tup[i0] + tup[i1] test0((1, 2, 3), 2, 4) This exception is generated: Traceback (innermost last): File "test2.py", line 7, in ? test0((1, 2, 3), 2, 4) File "test2.py", line 2, in test0 test1(tup, i0, i1) File "test2.py", line 5, in test1 return tup[i0] + tup[i1] IndexError: tuple index out of range But, it's unclear which tuple reference caused the IndexError... Mike From m.faassen at vet.uu.nl Fri Dec 3 16:01:50 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Dec 1999 21:01:50 GMT 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> <3847F117.3E2D1545@murl.com> Message-ID: <829b3u$mq6$1@newshost.accu.uu.nl> jim kraai wrote: > To add nothing of value to this discussion: > Hey, I'm Dutch, can I join? Sure, just join the list. :) Gerrit posted about how to join it. I seem to be alone on it so far.. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mlh at vier.idi.ntnu.no Sat Dec 25 17:37:26 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 25 Dec 1999 23:37:26 +0100 Subject: JNumPy? Message-ID: Has anyone thought of making a JPython version of NumPy (i.e. implemented in Java)? Has anyone implemented it? -- Magnus Lie Hetland From charliehubbard at my-deja.com Wed Dec 22 14:50:29 1999 From: charliehubbard at my-deja.com (charliehubbard at my-deja.com) Date: Wed, 22 Dec 1999 19:50:29 GMT Subject: socket.send() returns Message-ID: <83ra23$3t6$1@nnrp1.deja.com> # Echo server program Here is some code from the ftplib module. I'm trying to write a server that is similiar to an FTP daemon. I also need to send binary files and text files over a socket connection. In the following procedure the return of send is tested to break out of the infinite loop. When would this condition be satisfied? When would the socket.send() ever return ''? thanks charlie #---code def retrbinary(self, cmd, callback, blocksize=8192): '''Retrieve data in binary mode. The argument is a RETR command. The callback function is called for each block. This creates a new port for you''' self.voidcmd('TYPE I') conn = self.transfercmd(cmd) while 1: data = conn.recv(blocksize) if not data: break callback(data) conn.close() return self.voidresp() Sent via Deja.com http://www.deja.com/ Before you buy. From claird at starbase.neosoft.com Wed Dec 22 09:32:40 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 22 Dec 1999 14:32:40 GMT Subject: Is there a Python equivalent of Tcl's auto_execok? References: <83pf6u$q57$1@nnrp1.deja.com> Message-ID: <02CD1B3C026B41C1.AA67173007592BE4.82A69C8F06BE415B@lp.airnews.net> In article <83pf6u$q57$1 at nnrp1.deja.com>, wrote: > > >Is there a Python equivalent of Tcl's auto_execok? . . . No, to the best of my knowledge. Pythoneers must import os, string for pth in string.split(os.environ['PATH']): fnm = os.path.join(pth, exe) if os.path.exists(fnm): break for themselves, I believe. Credit Gordon McMillan for this coding. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From andy at robanal.demon.co.uk Mon Dec 27 16:09:46 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Mon, 27 Dec 1999 21:09:46 GMT Subject: How do I make a Python .bat executable file? References: <38670537.FDBC1785@postoffice.pacbell.net> Message-ID: <3867d58c.43060868@news.demon.co.uk> Robert Shockley wrote: >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~ Windows does not use the pound-bang trick nor the idea of executable permissions. Instead, it looks at file extensions of anything other than CON, EXE and BAT and figures out what app to run them with. On NT, by default the .py extension is associated with Python during installation of Python, so you can execute 'myscript.py' directly from a command prompt, or a double-click in an explorer window. You may go a step further and edit the PATHEXT environment variable in Control Panel / System / Environment (type 'set' in a dos box to see its current settings) and adding '.PY' to the list; then you can just type 'myscript' to execute 'myscript.py'. On 95/98, I tend to create one line batch files which call the python script with 'python.exe myscript.py %1 %2 %3...' etc. Regards, Andy From arcege at shore.net Thu Dec 9 07:30:05 1999 From: arcege at shore.net (Michael P. Reilly) Date: Thu, 09 Dec 1999 12:30:05 GMT Subject: Looking for a Unix alike tar tool written in Python References: <82h1ts$pus$1@nnrp1.deja.com> Message-ID: szhao at my-deja.com wrote: : Hello, everyone: : I noticed that there is a gzip module in python 1.5.2, is there a : tar module written in python? : Thanks. You can look at preliminary module I built a while ago. It only reads tarfiles and I never got to do much testing on it, but it worked for the cases I needed. -Arcege From robin at alldunn.com Wed Dec 22 00:06:42 1999 From: robin at alldunn.com (Robin Dunn) Date: Tue, 21 Dec 1999 21:06:42 -0800 Subject: Microsoft Python product? References: <38603196.4EA438BD@golgotha.net> Message-ID: "Randy Edwards" wrote in message news:38603196.4EA438BD at 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. Here is the gossip as I heard it: Commerce Server was written in Python with some C extensions when MS aquired (assimilated) the company that built it. The 1.0 release under the MS name was practically the same code. Later releases phased out Python modules bit by bit. About a year or so ago I remember reading comments from somebody who had just installed CS and was surprised to find some .py files and apparently a 1.4 level Python interpreter still there. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From fdrake at acm.org Fri Dec 3 12:49:49 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 3 Dec 1999 12:49:49 -0500 (EST) Subject: Be gentle with me.... In-Reply-To: <14407.64694.493050.310503@dolphin.mojam.com> References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> <14407.64694.493050.310503@dolphin.mojam.com> Message-ID: <14408.701.638639.893307@weyr.cnri.reston.va.us> Skip Montanaro writes: > As has been stated in c.l.py numerous times, Python does support block > delimiters: > > if 0 is None: > #{ > print "hi there!" > #} And they're powerful enough that you can have religious wars about placement, just like those other brace supporting-languages! Everyone knows that the right way to place block delimiters is: if 0 is None: #{ print "hi there, yourself!" #} ;-) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From paul at prescod.net Wed Dec 29 11:49:32 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 29 Dec 1999 11:49:32 -0500 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <38693062.E31E65E@connection.com> Message-ID: <386A3B9C.96442073@prescod.net> "Colin J. Williams" wrote: > > > This seems to be the PL1/Pascal record idea. I like it. I think you're the first one. :) > 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 Sure. There is no reason to disallow this. Pau Prescod From emile at fenx.com Fri Dec 3 22:33:24 1999 From: emile at fenx.com (Emile van Sebille) Date: Fri, 3 Dec 1999 19:33:24 -0800 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: <015a01bf3e08$53e46240$01ffffc0@worldnet.att.net> Z80 assembler? Its-probably-safe-to-toss-the-ithica-compiler-now-ly y'rs Emile van Sebille emile at fenx.com ------------------- ----- Original Message ----- From: Fred L. Drake, Jr. To: Cc: Sent: Friday, December 03, 1999 1:22 PM Subject: Re: indentation > > 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 > > -- > http://www.python.org/mailman/listinfo/python-list > > From ivanlan at callware.com Wed Dec 8 16:01:17 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 08 Dec 1999 14:01:17 -0700 Subject: X display visual 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> Message-ID: <384EC71D.E7AACCC0@callware.com> Hi All-- Randall Hopper wrote: > > Ivan Van Laningham: [snip] > | > |1) I don't follow the logic in solution 1, above: it looks like you're > |forcing the depth to 24 regardless of whatever you find out. > > That's what was asked for ;-) I left the sensing in there for hysterical > purposes, in case someone was interested. > I see. That makes more sense (ouch). > |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. -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 hei at adtranzsig.de Wed Dec 22 10:34:17 1999 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Wed, 22 Dec 1999 16:34:17 +0100 Subject: Need a recursion lesson References: <83pdbe$5fj$1@news07.btx.dtag.de> Message-ID: <945879868.137850@news.adtranzsig.de> >"Eide" writes: > >> Hello, >> I would like to do a search for file types, and I figure a good way to do it >> would be with recursion... compare a sliced 'file[:-6]' of each item in >> list from a directory. And if there is another directory in that list to do >> a listdir on it and .... My head is spinning already. >> I have no clue what I'm doing. Does anyone have any pointers to about how to >> walk through something like this? Any help would be a lot. os.path.walk() should do the recursion for you. Grep for "walk" in Lib/*.py of your Python tree. -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From jbauer at rubic.com Fri Dec 31 10:28:01 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Fri, 31 Dec 1999 09:28:01 -0600 Subject: MySQLdb problems References: <84ftnd$fpi$1@news06.btx.dtag.de> <84hotf$nni$1@snipp.uninett.no> Message-ID: <386CCB81.43B8B57E@rubic.com> CORRECTION: I sent Asle an email suggesting that he download mysql-python151-win32.zip. This was an error on my part. I then sent him another followup, correcting my first email. Asle's repost may be confusing. Do not download mysql-python151-win32.zip. I have removed it. To use Python and MySQL on Win32, it is only necessary to download the following files from starship.python.net, ftp directory /pub/crew/jbauer: MySQL.pyd libmySQL.dll Place these files in your Python home directory. Please ignore the earlier post(s) on this subject. Best regards and warm wishes for a peaceful new year, Jeff Bauer Rubicon Research From apederse at siving.hia.no Mon Dec 27 09:22:46 1999 From: apederse at siving.hia.no (Asle Pedersen) Date: Mon, 27 Dec 1999 15:22:46 +0100 Subject: mySQL <> Python Message-ID: <847sms$pfc$1@snipp.uninett.no> Any suggestions to where I can get a compiled version (win32) of a Python interface for MySQL, e.g. MySQLdb. I will eventually move the python code to a machine running Linux, but for now I want to test it on a machine running win2000. I know there have been similar questions to the group previously but I couldn't find any good answers. Why aren't the developers of the mySQL python modules supplying compiled code in the first place? In the unix world I know this isn't a problem, but on my win2k machine the only C compiler I have is VC++ which I'm not very familiar with. -Asle Pedersen From felixt at dicksonstreet.com Sun Dec 19 23:30:37 1999 From: felixt at dicksonstreet.com (Felix Thibault) Date: Sun, 19 Dec 1999 22:30:37 -0600 Subject: defining a method inside of another method In-Reply-To: <3859E3E0.5D07E242@yifan.net> References: <3.0.5.32.19991215020846.008825e0@mail.dicksonstreet.com> Message-ID: <3.0.5.32.19991219223037.008ad100@mail.dicksonstreet.com> At 07:21 12/17/99 GMT, dj trombley wrote: > > >Felix Thibault wrote: >> >> This is probably a trivial question, but it's driving me crazy: >> >> I have a class that has methods that look like this: >> >> class Eggs: >> def keep(self, inlist): >> keepers = filter(self.choose, inlist) >> mn = {} >> for name, stuff, idont, careabout in keepers: >> mn[name] = () >> def mystacks(dict = mn): >> return dict.copy() >> self.stacker = mystacks >> return keepers >Any time you call a method as an attribute of another object, the object >is applied as the first >argument to that method. For example, I could define the following: > >class foo: > def __init__(self): > self.bar = 5 > def add_my_bar(x,y): > return (x.bar + y) > >f = foo() >foo.add = f.add_my_bar > >And then calling "f.add(6)" will return 11, for example. However, a >function does not >have this behavior when it is called in the same way. Simply assigning >the object to >an object attribute does not make it a method of that object. > >The essential difference here is in what namespace the assignment >occurs. >If you use the variable passed as thefirst argument to a method, >(typically called "self") >then this assignment is to the dictionary of the instance. If you use >the class object >itself, then functions assigned become methods and behave in the >expected way; as if they >has been defined along with the class. > >You can refer to the class being defined from within the class >definition by simply using >its name. > >-dj > >Dave Trombley > >-- >http://www.python.org/mailman/listinfo/python-list > > OK, I think I get it now: If I define a function in a class's scope, it is called the way methods are called, with the instance being passed in as the first argument. If I define a function in a method's scope and then bind it to an instance variable, it's just an attribute which happens to be a function, and not a method. To make stacker act like a method I would have to do something like: .... def mystacks(dict=mn, self=self): try: self.stackcount = self.stackcount + 1 except AttributeError: self.stackcount = 1 return dict.copy() ... right? Thanks! Felix From tim_one at email.msn.com Wed Dec 15 01:21:13 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 15 Dec 1999 01:21:13 -0500 Subject: Tkinter/IDLE crash In-Reply-To: Message-ID: <000a01bf46c4$96498c40$05a0143f@tim> [dg, running Python 1.5.2 on an NT box; Tkinter._test() yields ...] > 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. Post the exact text of the error msgs, and tell us where init_tcl *is* installed. > I've checked the registry entries for Python and they appear to be > ok according to what is published at python.org. The msg about init_tcl is coming from Tcl, not Python. > Any ideas where to look next? See above. Your Tcl installation is damaged; there's not enough info here to say exactly how; the usual cause is that some previous of installation of Tcl is confusing the new Tcl installation; since it's a Tcl problem, there's not much Python can do about it. Here's something to try: 1. Uninstall Tcl. 2. Do a dir/s from the root of every drive on your machine, looking for tcl*.dll and tk*.dll. Destroy every one you find (or just rename them, if you're chicken ). 3. Reinstall Tcl. hasn't-failed-in-two-consecutive-tries-ly y'rs - tim From python-list at teleo.net Tue Dec 14 18:29:03 1999 From: python-list at teleo.net (Patrick Phalen) Date: Tue, 14 Dec 1999 15:29:03 -0800 Subject: XML parsing In-Reply-To: <945132645snz@vision25.demon.co.uk> References: <945048362snz@vision25.demon.co.uk> <945132645snz@vision25.demon.co.uk> Message-ID: <99121415380907.00954@quadra.teleo.net> [Phil Hunt, on Mon, 13 Dec 1999] :: In article :: mgushee at havenrock.com "Matt Gushee" writes: :: > 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 That would be Tony Smith, the Managing Editor. Why not just tell him his output is non-standard and ask him to change the output to 'version="1.0"'? From allen at rrsg.ee.uct.ac.za Wed Dec 22 07:05:35 1999 From: allen at rrsg.ee.uct.ac.za (Allen Wallis) Date: Wed, 22 Dec 1999 14:05:35 +0200 Subject: embedding jpython in java Message-ID: <83qejb$ae5$1@news.adamastor.ac.za> hi, I'm trying to embed some jpython in a java app, but I can't seem to find more than one example. I would like to use the jpython interpreter to create some objects for me, then I would like to retrieve those objects later. The problem is that using the PythonInterpreter.get(String) method returns a PyObject. I would ideally like to get back to the actual instance rather than the PyObject delegate. I've found the Py.tojava(PyObject, Class) method that works, except that it is apparently deprecated. If someone can tell me a better way of doing this conversion I would appreciate it, or in fact if this kind of conversion is frowned upon, then please tell me why. thanks Allen From anonymouse at trilidun.org Sat Dec 18 19:39:11 1999 From: anonymouse at trilidun.org (Santa's Little Helper) Date: Sat, 18 Dec 1999 19:39:11 -0500 Subject: The Official Naughty Or Nice List Message-ID: <199912190039.TAA30901@peterjh.goshen.edu> Ho, Ho, Ho, python-list at python.org, You've been lucky enough to have a little friend up north of the border. That's right! Santa's Official Naughty Or Nice List[1] now has you on it. Be sure to check it twice at http://www.trilidun.org/santa/. You're username is: python-list at python.org You're password is: pyBjtzaI --Santa [1] Brought to you by the boys at trilidun (http://www.trilidun.org) and superfly (http://superfly.trilidun.org). The Official Naughty Or Nice List is an artistic project and, as such, is not intended to solicit profits or collect hard feelings from her recipients. For an official manifesto visit http://www.trilidun.org/santa/manifesto.php3. From pinard at iro.umontreal.ca Mon Dec 27 15:00:49 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 27 Dec 1999 15:00:49 -0500 Subject: "sins" (aka, acknowledged language problems) In-Reply-To: neelk@brick.cswv.com's message of "26 Dec 1999 01:14:50 GMT" References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <38656610.E4DA287B@maxtal.com.au> Message-ID: neelk at brick.cswv.com (Neel Krishnaswami) writes: > As a general rule, syntax is a bad thing, to be avoided whenever > possible. Calls for additional syntax are typically a sign that > one of the basic operations of the semantics needs generalization. I might not go that far. Features come through syntax or libraries: Perl or LISP, to name some extremes. A good thing which often comes with syntax is that, when used intelligently, it forces some redundancy in the language which a compiler can later check. Programmers might grumble and moan somewhat, but they win in the long run. When everything generalizes, the compiler stops being our friend, at some point. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From thantos at chancel.org Wed Dec 22 19:38:35 1999 From: thantos at chancel.org (Alexander Williams) Date: Thu, 23 Dec 1999 00:38:35 GMT Subject: How to read lines from end of a file? References: <4rhfhazoj4.fsf@colargol.tihlde.hist.no> Message-ID: Two things, really: > maxLen:: max number of bytes to read This can be really, really problematic, especially if you don't know a good value for it. Luckily, you trap for whether or not it is longer than the whole file below, but unless you have a good idea how long individual lines might be, it can be hard to ballpark a good number. > # Dump the first line > # It might be chopped off > lines=fp.readlines()[1:] So might the last line, especially if you catch it in the midst of a non-atomic line write (say its constructed piecemeal then a CR added). Somewhat rarer, but not impossible. Testing to see if the last Char is a CR might be in order. -- 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 gerrit.holl at pobox.com Fri Dec 17 15:08:56 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 17 Dec 1999 21:08:56 +0100 Subject: ****lib.****.__del__(self)... Message-ID: <19991217210856.A10094@stopcontact.palga.uucp> Hello, I've got a suggestion: What about making a __del__ attribute in the HTTP, SMTP, NNTP and FTP classes which disconnects? regards, Gerrit. -- "If a machine couldn't run a free operating system, we got rid of it." -- Richard Stallman (Open Sources, 1999 O'Reilly and Associates) 9:08pm up 9:59, 17 users, load average: 0.00, 0.00, 0.00 From Alex.Martelli at think3.com Wed Dec 15 11:39:38 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Wed, 15 Dec 1999 17:39:38 +0100 Subject: Mutable parameters to functions Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D46@pces.cadlab.it> Alwyn writes: > def multiple(x,y): > x = 2 > y = [3,4] > return x, y > > X = 1 > L = [1, 2] > X, L = multiple (X, L) > X, L > > result is then (2, [3, 4]) > Now, the question is whether the statement y = [3, 4] constitutes > an inplace change of the global variable L? > No, it just rebinds the local variable y. > would X = multiple(X,L) yield the same results? > Same results as X, L = multiple(X,L)? No, it would place a tuple in X (rather than a number) and leave L to the [1,2] list (rather than bind it to [3,4]). Alex From fdrake at acm.org Mon Dec 20 16:19:17 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Mon, 20 Dec 1999 16:19:17 -0500 (EST) Subject: Why can pyhton deal with a big project? In-Reply-To: <83m5i2$3qk$1@news3.dti.ne.jp> References: <83lutn$sfn$1@news3.dti.ne.jp> <19991220142820.A25651@quark.emich.edu> <83m5i2$3qk$1@news3.dti.ne.jp> Message-ID: <14430.40277.76485.132029@weyr.cnri.reston.va.us> Hirofumi Furusawa writes: > Now I understand Tcl lacks namespace management. Actually, Tcl now has support for namespaces, though I've not used them since I've not used Tcl for several years. Perhaps someone could summarize the Tcl approach? I'd be interested in hearing the 5-minute overview. > Also I don't know very much about Perl for larger project. Can you say perl > lacks namespace ability same as Tcl? There's some namespace support, but I don't know how well-used it it. My own thought on Perl is simply that it's hard to read, so others may (legitimately) say otherwise. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From aj10 at my-deja.com Wed Dec 1 19:07:44 1999 From: aj10 at my-deja.com (aj10 at my-deja.com) Date: Thu, 02 Dec 1999 00:07:44 GMT Subject: RMI in JPython ??? Message-ID: <824d8c$6su$1@nnrp1.deja.com> I was curious as to how one writes RMI apps using jpython. And at what stage does one invoke rmic ? Are their example rmi apps in the distribution? I am sure someone would have experimented with it. Would be grateful for any guidance. Thanks aj Sent via Deja.com http://www.deja.com/ Before you buy. From thamelry at vub.ac.be Fri Dec 3 16:39:17 1999 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 3 Dec 1999 21:39:17 GMT Subject: indentation References: <828n3e$8kp$1@nnrp1.deja.com> <14408.13481.279705.753821@weyr.cnri.reston.va.us> Message-ID: <829da5$s4d$2@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 ------------------------------------------------ From tony at lsl.co.uk Tue Dec 14 05:02:24 1999 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Tue, 14 Dec 1999 10:02:24 -0000 Subject: Python and regexp efficiency.. again.. :) In-Reply-To: <3854FBC5.758C2C15@lemburg.com> Message-ID: <000801bf461a$52256660$f0c809c0@lslp7o.lsl.co.uk> Marc-Andre Lemburg suggested that Markus Stenberg use mxTextTools. Markus replied that "the tagging language seemed to be somewhat limited compared to regexps". Marc-Andre explained his view on why this is not so, which I've snipped. Personally, I'm biassed because I don't like regular expressions, except for *very* simple tasks. My view is that mxTextTools provides something much closer to a programming language for handling text matching, with several of the traditional control structures that one finds in programming languages built in - that's why the metalanguage *looks like* a programming language. I think that the comparison of mxTextTools and regular expressions is somewhat similar to that of Python and Perl - one is a general tool, rather more verbose but definitely more elegant, and the other is more specialised, provides more shortcuts "built in", and is ever so much easier to write in an obfuscated manner. It also depends what you want to do. I use mxTextTools rather than work my way round traditional parsers and having to deal with parse trees (an inability to work with references (to references (to references...)) in languages like C without lots of little diagrams has given me a 'fear' of tree structures which is not really appropriate in Python!) and it's neat stuff. Tibs -- 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 kc5tja at garnet.armored.net Sat Dec 4 22:23:38 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 5 Dec 1999 03:23:38 GMT Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD81@gandalf.digicool.com> Message-ID: In article , Bernhard Reiter wrote: >Well AFAI understand it COM also is an interoperability standard, >but I might just miss the point here. A component model relies on an interoperability standard, but the reverse isn't necessarily the case. There are services which must be layered on top of CORBA to allow it to serve as a component standard, and even then, it works (primarily) only for distributed components. Local components are supported, but are slower to use with CORBA than through COM. >>Um -- that's true for COM+, but COM doesn't need it to operate. >Well if you don't want distributed computing... Yes, you can do distributed computing without COM+. Remember, DCOM predates COM+ by at least two years, and didn't include a shread of transactioning support. Who says that MTS is the end-all and be-all of distributed components via COM? >I do not habe much experience about it, I admit, but technically they >also seem to have the same complexity. I just do not believe that >COM is easier to code. >Well this is, what the articles support, too. I have experience with CORBA. It's a nightmare. COM and DCOM are at least three orders of magnitudes easier to UNDERSTAND, and hence, easier to work with. I'm perfectly happy writing more code if I understand the overall system much better than if things are abstracted to hell and back. Please understand -- I'm not "dissing" CORBA. I just don't think it can compete with COM because COM addresses developers' needs better. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From bruce_dodson.nospam at bigfoot.com Mon Dec 13 00:07:31 1999 From: bruce_dodson.nospam at bigfoot.com (Bruce Dodson) Date: Mon, 13 Dec 1999 01:07:31 -0400 Subject: Suitability of Python for a Big Application? References: <830vic$r2t$1@nnrp1.deja.com> Message-ID: Python is a good tool for this type of situation. It allows you to compartmentalize your functionality and do collaborative development. But it is not a magic bullet. If your development process is flawed, Python will not solve any of your woes, much less all of them. Take a close look at the VB attempt, and evaluate whether that failed because of VB, or whether VB is just the scapegoat. Sometimes this is a difficult thing to do, but you must do it; if you don't, a year from now I could very well find a message in the Perl newsgroup saying "we tried VB and Python with miserable results." I suggest delaying the decision of language(s) until after the requirements phase. And I suggest in the requirements phase, you think about what is really important. For example, does the front end really need to be cross-platform, or is it all (~99%) Win32. Also think about, of the things that will need to be in the final system, which need to be in the final system. If you go with a mixed-language system, it is important that there be a "master language" which drives things, and that you implement things in that language unless there is a strong justification to use something else. Otherwise you get the "code smear" effect where no one knows where exactly a given piece of functionality is implemented, or worse, it _isn't_ implemented in any one place but is an emergent property of the system. This kind of thing happens all the time with Intranet development, because there are so many languages and protocols involved. That is my sermon for today, Bruce bobyu5 at mailcity.com wrote in message <830vic$r2t$1 at 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. >> >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. > From skaller at maxtal.com.au Sat Dec 25 17:48:13 1999 From: skaller at maxtal.com.au (skaller) Date: Sun, 26 Dec 1999 09:48:13 +1100 Subject: Viper- Dec 1999 progress report Message-ID: <386549AD.DD177D2A@maxtal.com.au> posted to caml-list at inria.fr and comp.lang.python Viper - an python interpreter/compiler project written in ocaml and C, for python and ocaml enthusiasts, and those concerned with high performance computing with python. --------------------------------------------------------------- Here's a brief progress report on the Viper project. Viper 2.0 alpha 1 is (temporarily) available from ftp://ftp.cs.usyd.edu.au/jskaller/viper_2_0_a1.tar.gz I don't recommend you download this version unless you are serious about contributing or testing, or just extremely curious. :-) Ocaml (http://caml.inria.fr), CPython (http://www.python.org) and Un*x is required to build it (use the 'maker' script). The current (temporary) licence permits redistribution of the unmodified tarball; you can also modify the sources, distribute the mods as patches, but NOT redistribute modified sources as a whole (this is to stop some big well funded corporation cashing in on my work without negotiation) ---------------------------------------------------------- Verion 2.0 alpha 2 features. Note: alpha 2 is NOT yet available. Too much code is 'unfinished'. Let me know which bits you'd like to see finished first. A list of alpha 1 features is given below. COMPILER and CPYTHON run time access. ===================================== Alpha 2 now links against the CPython run time, it is possible to run CPython from within Viper, including loading CPython extension modules, and letting CPython run scripts instead of Viper. There is proof of principle support for both converting between Viper and CPython representations, and wrapping them as opaque objects (in both directions). I'm working on a C code generator function that takes a Viper imported module, and creates a text file which can be compiled with a C compiler, then loaded into CPython as an extension module. OPTIONAL TYPE DECLARATIONS ========================== Viper now supports type declarations in two ways: The expression: expr ! typeexpr is evaluated as expr if the type of expr is typeexpr, otherwise a TypeError exception is raised. Function parameters may be declared like: def f(param:typeexpr) and matching arguments are checked at the point of call. [Adapted from a suggestion of Greg Stein] WITH/DO STATEMENT ================== New syntax is introduced. The With/Do statement is written like: with: x = 1 y = 2 do: z = x + y The with block is evaluated, and new symbols (x,y) created in a temporary dictionary. Then the do block is executed, with the temporary dictionary available read only, write-bypass, so that z ends up in the global scope. Finally, the temporary dictionary is deleted. The code above is equivalent to x = 1 y = 2 z = x + y del x,y except that there is no risk of a clash for the temporary names, and you don't have to remember to 'del' them. [Adapted from ML's let .. in construction] RENAMING EXTENSION IN IMPORT STATEMENTS ======================================== Import statements now allow a suffix to import an object with a new name. For example: import x as y from m import a as b, d as e This saves having to write code like _x = x from m import x new_x = x x = _x del x to resolve name clashes. C STYLE ASSIGNMENT OPERATORS AS STATEMENTS ========================================== All the C assignment operators (+= etc) plus pre and post increment and decrement are available in single assignment statements for example: x++ x+=1 Note that these cannot be used in expressions or multiple assignments. NESTABLE C STYLE COMMENTS ========================= C style /* comments */ can be used an nested. INTERNATIONAL CHARACTERS IN IDENTIFIERS ======================================= Any letter can be used in an identifier. The only encoding supported is UTF-8 encoded ISO-10646. In particular, Latin-1 encoded non-Ascii characters will be rejected. The full set of letters allowed is detailed in: ISO Standard C++, Appendix E. The source for that was: ISO/IEC PDTR 10176, produced by ISO/IEC JTC1/SC22/WG20 (internationalisation). AFAIK, this set agrees with Unicode. All the supported letters are from the Basic Multilingual Plane (Unicode). RAW OBJECTS =========== New raw objects can be constructed, and any object set as the type object. A demo of showing how to construct a checked list-of-int is provided. It remains to be seen if this is enough to provide generic containers. BUILTIN GRAPHICS USER INTERFACE =============================== Viper provides a builtin GUI, currently using Gtk as the basic C toolkit. Most widget constructors are implemented (but only a few of the other methods). LIBRARY MODULES =============== Most of the socket module is now implemented. The thread module is implemented. The interpreter, however, is not yet thread safe. Yet to do: operator, array, NumPy, and some others, finish other partially implemented modules including re. Finish implementing mapping/dictionary methods. Finish providing support for special class methods. Good news: ocaml 3.00 will probably support finalisers, so __del__ methods can be made to work. ALPHA 1 FEATURES ================ Underscores in numeric literals like 1_223_444. Sane radices for numeric literals: 0x - hex 0o - octal 0d - decimal 0b - binary Full ISO-10646 support for string literals, using UTF-8 encoding, and \u and \U escapes. Builtin support for arbitrary precision rational numbers. Strides in slices are fully implemented. Name binding is available for functions and modules. (names are translated to indexes into an array like CPython does for locals in functions) Functions and classes are lexically scoped. For example: def f (x): def g(y): return x + y return g(1) print f(2) will print 3. Any object can act as a type object in Viper, type objects are consulted for attributes if normal attribute lookup fails (including methods). -- 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 a.eyre at optichrome.com Wed Dec 1 10:25:34 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Wed, 1 Dec 1999 15:25:34 -0000 Subject: wish: multiline comments In-Reply-To: Message-ID: <000b01bf3c10$4faf3910$3acbd9c2@peridot.optichrome.com> >> I would like to see multiline comments possible in some future >> version of Python. > Use multiline strings. Not quite the same is it? A docstring will be put in the .pyc. A comment won't. Imagine (extreme example): class A: # Okay. This is a 42 million line comment about what my class does # Yadda, yadda. . . . # The end pass # :-) class B: """Okay. This is a 42 million line docstring etc. . . . """ 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. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From tim_one at email.msn.com Thu Dec 30 01:09:11 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 30 Dec 1999 01:09:11 -0500 Subject: "sins" (aka, acknowledged language problems) In-Reply-To: <00d701bf50c2$1b9832a0$c02b2bc1@martelli> Message-ID: <000101bf528c$63c7c9c0$a02d153f@tim> [John Skaller] > 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 :-) [Alex Martelli] > You're right, I'm outmatched in the arrogance game...: > > >>> try: > ... raise IndexError, "hello" > ... except IndexError, x: > ... print x > ... > hello > >>> x > > >>> > > It seems to _me_, as a humble (:-) language newbie, that this x > is in no strange and magical scope, but, rather, exactly in > the scope I would have expected it to be (here, typing things > into the interactive interpreter, the global one). It's actually in the local namespace, although at module level (including __main__'s, to which you're typing in interactive mode) the global and local namespaces are the same. This is all spelled out in the "Code blocks, execution frames, and namespaces" section of the Lang Ref (currently section 4.1). It follows immediately from the general rule that binding targets are *always* in the local namespace, unless explictly declared to be in the global one. That John could assume otherwise just goes to show that he thinks Python's scheme is complicated because he's still trying to force some other languages' view(s) onto it. Forcing a bloated square peg into a slimly elegant round hole is indeed a complicated business . > ... > Or, is it an issue of striking a happy medium? I'm afraid The Amazing Criswell died before we got the chance to test this theory on his candy ass. suspecting-the-only-happy-mediums-are-fake-ones-ly y'rs - tim From aahz at netcom.com Tue Dec 28 16:36:12 1999 From: aahz at netcom.com (Aahz Maruch) Date: 28 Dec 1999 21:36:12 GMT Subject: newbie question... References: <3869229B.C06B94E5@earthlink.net> Message-ID: <84bagc$k8m$1@nntp6.atl.mindspring.net> In article <3869229B.C06B94E5 at earthlink.net>, Alexander Sendzimir wrote: > > all_the_lines_in_the_file = somefilehandle.readlines() The one disadvantage of this is that you consume memory proportionate to the total size of the file. If that's an issue, you have to use a while loop with readline; you can use the QIO module to speed that up to something closer to Perl. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 4 days and counting! From fredrik at pythonware.com Thu Dec 16 08:35:34 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 16 Dec 1999 14:35:34 +0100 Subject: Help?? Struct packing of Date time not has stopped working??!?! References: <835mvi$62t$1@nnrp1.deja.com> <01c401bf47c3$dfe75da0$f29b12c2@secret.pythonware.com> <3858e292@194.120.211.23> Message-ID: <020e01bf47ca$6ec085a0$f29b12c2@secret.pythonware.com> Klaus Baldermann wrote: > well, I guess the struct module (or at least its documentation) > would have to be changed then :-) > Native size and alignment are determined using the C compiler's sizeof > expression. This is always combined with native byte order. > > Standard size and alignment are as follows: no alignment is required for any > type (so you have to use pad bytes); > short is 2 bytes; int and long are 4 bytes. float and double are 32-bit and > 64-bit IEEE floating point numbers, respectively. umm. I had to read the code to understand what the documentation tries to say... but you're right; if you use the "<" and ">" prefixes, python uses "standard" sizes, so a "long" is 32 bits also on a 64-bit box... the eff-bot apologizes for the inconvenience. From python-list at teleo.net Tue Dec 7 00:35:59 1999 From: python-list at teleo.net (Patrick Phalen) Date: Mon, 6 Dec 1999 21:35:59 -0800 Subject: Is there a database in Zope? In-Reply-To: References: Message-ID: <99120622262301.02133@quadra.teleo.net> [NH, on Mon, 06 Dec 1999] :: I am new to Python and Zope, so please don't flame me. I'm afraid you'll have to commit some act more egregious than being new to get flamed here. ;) :: 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? Better for you? Don't know enough about your situation to comment. Zope has a steeper learning curve, but is much more powerful and flexible than probably *any* other solution available, free or otherwise. With Zope, you get a built-in web server, object store, security model, reporting language, through-the-web content management system, not to mention the ability to extend it easily with Python. It offers you much more "out of the box" than PHP. :: 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. ZODB provides long-term storage and is very easy to use; it could be perfect for your needs. Its object model is a better fit than the Relational or Object-Relational for a lot of web content. If you later feel you have a need to interact with a RDBMS, Zope has that ability too. :: 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. >From your description, I'd be surprised if you need anything other than ZODB to fulfill your needs. From coursesm at sbdhcp-4024.statenisland-ny.est.tcg.com Tue Dec 21 11:50:59 1999 From: coursesm at sbdhcp-4024.statenisland-ny.est.tcg.com (Stephen Coursen) Date: 21 Dec 1999 16:50:59 GMT Subject: shelve References: <14430.25553.576208.661666@dolphin.mojam.com> <19991221155108.A2087@stopcontact.palga.uucp> <14431.45563.398666.317256@dolphin.mojam.com> Message-ID: On Tue, 21 Dec 1999 10:59:39 -0600 (CST), Skip Montanaro wrote: > > 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. > There's that combined with the fact that shelves don't seem to support the values( ) method. At least not on my install (1.5.2 on linux2). Steve >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 skaller at maxtal.com.au Wed Dec 15 16:11:44 1999 From: skaller at maxtal.com.au (skaller) Date: Thu, 16 Dec 1999 08:11:44 +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> <82pe7b$q76$1@nnrp1.deja.com> Message-ID: <38580410.B29EC285@maxtal.com.au> 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] Secondly, a dictionary with locking is not a subtype of a dictionary. [But this is a common mistake] If it were, an algorithm accepting a dictionary would also accept a dictionary with locking -- and that is not the case, because the latter might be locked, and break the algorithm. It is in fact more likely to be completely the other way around: an algorithm which works with a dictionary that supports locking, and tests to see if the dictionary is locked, will work with one that does not permit it to be locked. (assuming that exceptions are counted as errors, and would be raised if one was attempting to add a key to a locked dictionary) The general rule for subtyping is: a subtype must be MORE CONSTRAINED than the super type. You can NOT add flexibility, only remove it. Example: a symmetric matrix is a subtype of a matrix _considered as a readonly value_. It turns out subtyping in OO is almost useless when the objects are mutable. This is because the mutators must be simultaneously covariant and contravariant -- which means they must be invariant, and the object is then isomorphic to the original, that is, it isn't a proper subtype at all, but the same type. [That is, it has the same behaviour] There's only one exception: when all the methods have invariant arguments (such as integers). In that case, variance on the object works. For example, device drivers (the invariant types are 'characters' the driver reads or writes). The types that cannot be OO'ified include numbers, and anything else that has to relate to some other OO'ified object. Which is almost everything else in the real world. Please note I'm not saying classes are useless, I'm saying subclassing is more or less useless. So the fact that Python objects can't be subclassed is no great loss: few python types could be sensibly subclassed anyhow. [The main exception, I think, is the file type, which could be usefully subclassed .. because it has invariant methods] Again, note that class __xxxx__ methods for sequences are useful -- but this is not subclassing, but signature based genericity. Unlike OO, that is supported by robust mathematical theory. -- 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 skaller at maxtal.com.au Wed Dec 1 09:51:57 1999 From: skaller at maxtal.com.au (skaller) Date: Thu, 02 Dec 1999 01:51:57 +1100 Subject: Python complaints References: <000001bf3bd4$26f10b20$542d153f@tim> Message-ID: <3845360D.B816DFE6@maxtal.com.au> Tim Peters wrote: > > [John Skaller] > > Integers are NOT objects in Python, they're values. > > Same for strings and tuples. We can pretend they're objects, > > and say they're 'immutable', but the truth is that they're > > just plain values. > > The implementation doesn't support this view -- e.g., intobject.c has every > bit as much "object hair" as listobject.c. I'm sure it does -- in CPython. But that is irrelevant, when considering the abstract language. Int in python is neither mutable, nor does it support polymorhpic methods: class instances are both mutable and support polymorphic methods (via inheritance, for example) by contrast. There is only one hint in the python language I can think of that integers are objects, and that is the builtin function 'id', and the corresponding 'is' operator. In CPython: id(1) != id(1) 1 is not 1 are true: they're distinct objects. But this is NOT the case in Viper; ints, strings and tuples are compared by value, _even_ by the 'is' operator, and the id's of equal values are identical. It's hard to say if this is compliant to 'python' since the existing 'specification' is somewhat implementation dependent; but I believe my implementation is reasonable. As for implementation details, in Viper, integers, strings, and tuples are in fact represented by 'values', not objects, at least in terms of the implementation languages terminology. Of course, underlying a representation of a value in memory, there is (almost) always an object in the C sense, but that isn't what I call an 'object' in the more abstract sense. >it's unclear what you're saying. Hope the above clears it up. > Perhaps that ints & strings etc don't support methods? > That's just historical accident, and in the current CVS snapshot most of the > string module's functionality has been reimplemented as methods of string > objects (very nice, btw! most people will like this). That is an issue of scoping and grammar and has no bearing at all on the 'objectness' of the entity. There is no semantic difference between non-polymophic methods called like: x.f() and a function call f(x) and this is in fact the case for python class 'methods': they are in fact ordinary functions, individually. However the dynamic lookup gives the impression of polymorphism, so I'd agree that they deserve the name 'methods' in the OO sense. > > My new Viper interpreter may support 'mutable' > > integers and strings as follows: you write: > > > > x := 1 > > x++ > > x+=1 > > > > This notation actually creates a reference (pointer) to the value, > > so x is a 'reference to an integer', and x++ actually means: [] > > Comments on this idea appreciated. > > I'm a long-time fan of augmented assignment (+= and friends), but prefer to > live without the pre- and post-increment gimmicks. Introducing references > isn't necessary to implement the former, so unless you've got some other > killer use in mind for references I'd recommend not doing it that way (extra > syntax, extra complications, & mainline Python will likely never do it that > way). OK. I implemented the following operators last night in Viper: += -= *= /= %= <<= >>= |= &= ^= := ++ -- (i.e. all the 'C' assignment operators, plus := which is the same as =) I didn't use references. [you are probably right about the extra complications] You can write: x += 1 but it is a _statement_, and no multiple occurences are permitted, that is, you cannot write: x += y += 1 since I think that would be confusing. So you can write: ++i but NOT x = y[i++] The semantics of lhs op= rhs are: evaluate the left and right hand sides, and apply the functional operation 'op' implied, then assign the result to the lhs. There is a deficiency in my implementation at present: x[ f() ] += 1 will call f() twice. > If/when Guido adds augmented assignment to Python (he's not oppposed to it), > > thing += thang > > will most likely compile to (pseudo-code): > > call thing.__addeq__(thang) # must return a result on the stack > bind "thing" to the result in thing's namespace > > It's then up to each object's __addeq__ method to decide whether to return > self (to effect a mutating +=) or to return a different object (to effect a > functional +=). It's likely that int.__addeq__ will do the latter and > list.__addeq__ the former, so that > > x = 42 > y = x > x += 1 > print x, y, x is y > > prints > > 43, 42, 0 > > while > > x = [1, 2, 3] > y = x > x += [4] > print x, y, x is y > > prints > > [1, 2, 3, 4], [1, 2, 3, 4], 1 > > when=-everything's-a-reference-nothing-isn't-ly y'rs - tim I appreciate this explanation. My current implementation is different, and what you suggest above is probably correct. in particular: x += y means the same as x = x + y in my implementation, so for a list, I get [1,2,3,4] [1,2,3] 0 BTW: In the current CPython object model, extension types have a 'vtable' and adding extra operators to the language makes that table larger (modulo extra indirections, as used to reduce the overhead at present). Viper has none of these problems, since methods of objects of a particular type are plain functions, exactly the same as for class instances [literally!] Instead of a table of methods, Viper methods are defined as ordinary class methods: you could define: class PyIntType: ... def __addeq__(self, value): ... if you wanted, or not: the 'table of methods' is a dictionary of arbitrary length, and the entries are accessed by name, not by slot number. This is inefficient, compared to the CPython mechanism. This is fixed in two ways: builtin types do not use this mechanism, the interpreter 'knows' the operations on them and just does them. The other mechanism is compilation. The first stage of that is called binding: replacing named lookup with indexing (same as CPython's fast-load for local variables). This can be done in the interpreter right now [manually] for modules and functions. [I have yet to implement the mechanism for classes and instances] -- 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 scherbi at bam.com Wed Dec 22 06:46:22 1999 From: scherbi at bam.com (Bill Scherer) Date: Wed, 22 Dec 1999 06:46:22 -0500 Subject: How to access Oracle? References: <945811978.70442@sj-nntpcache-4.cisco.com> Message-ID: <3860BA0E.87FAE4BA@bam.com> You want DCOracle: http://www.zope.org/Products/DCOracle If you have any problems getting it working, let me know... -- William K. Scherer Sr. Member of Applications Staff Bell Atlantic Mobile Gopal Kethineni wrote: > Hi > > I am new to Python. > > How do I connect to Oracle 7.3.4? > > Do I have complete solution (all compatible data types, > full set of JDBC/ODBC/OCI features)? > > Thanks > KG > > -- > http://www.python.org/mailman/listinfo/python-list -------------- 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 skip at mojam.com Tue Dec 28 17:43:27 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 28 Dec 1999 16:43:27 -0600 (CST) Subject: A couple MacPython questions... In-Reply-To: <846q65$g2n$1@ssauraaa-i-1.production.compuserve.com> References: <199912262151.PAA10719@dolphin.mojam.com> <846q65$g2n$1@ssauraaa-i-1.production.compuserve.com> Message-ID: <14441.15631.657120.854994@dolphin.mojam.com> >>>>> "Jason" == Jason Harper <76703.4222 at CompuServe.COM> writes: Jason> 1. The Mac's Desktop isn't really expressible in terms of a Jason> pathname - it's actually the union of the Desktop Folders on Jason> all mounted volumes (and you can't count on that name, you Jason> should use macfs.FindFolder() to get the proper, localized Jason> name). However, the code you posted should at least partially Jason> work, and indeed it does on my system - I suspect that your Jason> Desktop items are all on a different volume than 'Macintosh Jason> HD:', or that you don't actually have any files or folders on Jason> your desktop (disks, servers, and the Trash don't count). Since I only have a single disk on my machine I sort of assume all desktop items are on that volume. Right now I see five regular files (in the Unix sense), one folder and five alias that point to other files on the hard drive laying about on my desktop. That doesn't count the drive or Trash icons. I still see nothing when trying to list the contents of my desktop folder: >>> os.chdir("Macintosh HD:Desktop Folder:") >>> os.listdir(os.getcwd()) [] One thing that just occurred to me as a potential extra problem is that Jason> 3. If the file you're trying to turn into an applet is big, you Jason> may need to allocate more memory to BuildApplet - select it in Jason> the Finder, then choose Get Info from the File menu. The Jason> default is less than 2MB. Yes, this turned out to be the problem. I definitely need a PostIt note for this one... Jason> There is a MacPython mailing list at www.python.org that you Jason> might want to join for questions like these. Hmmm... I don't see anything mentioned on the Mailing Lists page. I do see the pythonmac-sig list. Perhaps it should be elevated to the status of a plain old mailing 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 ivanlan at callware.com Tue Dec 7 14:53:28 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 07 Dec 1999 12:53:28 -0700 Subject: lemmings References: <82j6o3$jc6$1@news.qub.ac.uk> <19991207171102.A8067@stopcontact.palga.uucp> Message-ID: <384D65B8.BF333D3D@callware.com> 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. -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 phd at phd.russ.ru Fri Dec 3 08:25:17 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 3 Dec 1999 13:25:17 +0000 (GMT) Subject: printable characters In-Reply-To: Message-ID: On 3 Dec 1999, Ralf Hildebrandt wrote: > How can I find out if a character is printable? > There seems to be no equivalent to isprint() of C. Module locale... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From calishar at my-deja.com Wed Dec 15 19:49:59 1999 From: calishar at my-deja.com (calishar at my-deja.com) Date: Thu, 16 Dec 1999 00:49:59 GMT Subject: Questions about frozen apps Message-ID: <839cvl$u3k$1@nnrp1.deja.com> Hi Folks (again) I just finished freezing a tkinter app, and tested it on my test system (python & tcl/tk not installed). Well, apart from needing the tcl and tk dll files, I also found I needed a few tcl files (init for tcl, and a bunch of tk ones). Is there any way around this, or is this just a result of using c/c++ to compile python accessing tcl through tk? Also, while I was looking through my code to see if I had a problem, I noticed that I had a few print statements left in it. Now I froze the program using -s windows so that I don't get the console, so I am just wondering what happens to the output from those print statements? Thanks to one and all for the great language, the help I have received (and probably will keep asking for) and all the neat little fiddly bits people have contributed. Calishar Sent via Deja.com http://www.deja.com/ Before you buy. From Alex.Martelli at think3.com Mon Dec 27 03:20:46 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Mon, 27 Dec 1999 09:20:46 +0100 Subject: pound bang (#!) problem... Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D82@pces.cadlab.it> Orlando Vazquez writes: > and my un processed file (index.pyhtml) looks like.. > #!./preprocessor.py > python rules! > > If my UNIX skills serve me correctly running: > ./index.pyhtml > should be the same as running: > ./preprocessor.py < index.pyhtml > I'm getting rusty on _my_ Unix skills, but isn't #! modernly implemented somewhat like: interpreterprogram /dev/fd/foobar where the argument "names" a magical already-opened file? If that is what happening on your Unix dialect, you might use the fileinput module in your interpreter program, and transparently process either standard-input or a named argument file -- handy. A further concern is that I'm not sure #! works with an interpreter-program that is identified by a _relative_ path; you may need to make the path explicit, or use such tricks as naming /usr/bin/env as the "interpreter" so that it will look along your PATH for the actual program. Alex From shouldbe at message.com Fri Dec 3 10:26:00 1999 From: shouldbe at message.com (Arinte) Date: Fri, 3 Dec 1999 10:26:00 -0500 Subject: Need help with Tuples Message-ID: <828n42$10ma$1@rtpnews.raleigh.ibm.com> I have an python class that I send to my c program, when I try to get values of the classes member variables the GetAttr is successful, but the Py_ParseTuple always fail. Has anyone ever experienced this problem? I on on windows python 1.5.2. Here is the problematic c code... tobj = PyObject_GetItem(pobj, Py_BuildValue("i",idx) ); vobj = PyObject_CallMethod(tobj,"getValue",NULL); Py_INCREF(vobj); val =PyObject_HasAttrString (tobj, "argvalue") ; // returns 1 val =PyObject_HasAttrString (tobj, "argname"); // returns 1 if(vobj==NULL){ // not null appcallback()->messageBox("Error 0"); } dummy = PyObject_Type(vobj); // not null so I guess it is successful Py_INCREF(dummy); // did I need to do this. I do decref later char *tchar = "argvalue"; nobj = PyObject_GetAttr(tobj,Py_BuildValue("s",tchar)); // nobj is not null seems good if(!PyArg_ParseTuple(nobj, "i", &val)){ // fails every stinking time. appcallback()->messageBox("not again"); } Here is the class I pass to it 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 TIA From thantos at chancel.org Mon Dec 20 22:44:24 1999 From: thantos at chancel.org (Alexander Williams) Date: Tue, 21 Dec 1999 03:44:24 GMT Subject: List comprehensions References: <38592275.BBA2B61A@maxtal.com.au> <385E045D.9EC36473@compaq.com> Message-ID: On 20 Dec 1999 16:29:24 GMT, Albert Hofkamp wrote: > print [ (x,y) | x <- xs, x>3, y <- xs, y>x ] Oooh, Haskell syntax. I'm feeling perfectly at home. :) >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. :) >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 function. >For example, how would you write an expression which calculates the sum >of all elements (or the sum of all elements which hold for some special >condition ?) sumGreaterThanFive(lst) = foldl(operator.plus, [e <- lst, e>5]) The fact you can pass iteration lists around is high fun. :) -- 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 mhammond at skippinet.com.au Fri Dec 17 22:36:24 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 18 Dec 1999 03:36:24 GMT Subject: pythoncom and MTS References: <83b5lq$5tr$1@nnrp1.deja.com> <83dgtf$orc$1@nnrp1.deja.com> Message-ID: We dont have any MTS examples, although someone has offered to write some. In general, it "just works" - the objects work as normal, and access to MTS features is obtained by using normal COM objects. I am the primary maintainer, although there is a pycom-dev mailing list and the sources are available via CVS - but I am not the only contributor. Mark. wrote in message news:83dgtf$orc$1 at nnrp1.deja.com... > Also Mark, I was just wondering, are you the sole developer on > pythoncom? Are there others? > > In article , > "Mark Hammond" wrote: > > wrote in message > > news:83b5lq$5tr$1 at nnrp1.deja.com... > > > Does anyone know if you can implement MTS (Microsoft Transaction > > > Server) complient/safe COM objects in python? > > > > 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? > > > > > -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. > > > > Mark. > > > > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From claird at starbase.neosoft.com Fri Dec 17 13:00:44 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 17 Dec 1999 18:00:44 GMT Subject: Python + JavaSpaces? References: Message-ID: At the beginning of November, while I was not thinking Python thoughts, Greg Wilson asked in article , >Has anyone built (or thought about building) a Python interfaces to >JavaSpaces? . . . Yes. My guess is it won't happen soon. Among all Linda's descendants, JavaSpaces most unequivocally comes out as object-oriented and language-specific. If you think of objects as attributes-plus-methods, JavaSpaces' exploitation of methods' mobility is quite deep. A crude interface that just transacts data attributes wouldn't be hard to do. It holds no interest for Java- Soft, in contrast to their default baseline enthusiasm for anything done externally. Of course, JPython can, in principle (that means, it oughta be easy, but I haven't done it), script JavaSpaces immediately. A good interface to the object model, though, will take what looks to me like deep thought. I'd sure like to do it. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From ivanlan at callware.com Thu Dec 2 22:38:54 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 02 Dec 1999 20:38:54 -0700 Subject: split this newsgroup? References: Message-ID: <38473B4E.9050DF4D@callware.com> Hi All-- "Max M. Stalnaker" wrote: > > The volume on this newgroup might justify splitting the newgroup. Comments? > No. -500-msgs-a-day>-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 BjoernGam at knuut.de Fri Dec 3 10:36:58 1999 From: BjoernGam at knuut.de (Bjoern Gam) Date: Fri, 03 Dec 1999 16:36:58 +0100 Subject: windows 9x exe References: <828lsd$rb4$2@news.qub.ac.uk> Message-ID: <3847E39A.5D8E7B98@knuut.de> stuart mcfadden wrote: > > Has anyone found a way to make python scripts windows executable?, I checked > the FAQ and it said there was no ideas as to how it would work. Hello Stuart, you must install a web-server under Windows 9x (I prefer the WebSite Server). If you prefer a other web-server, you must check, that the web-server could execute cgi-scripts. If you install WebSite you copy your python-script in the folder "/cgi-bin/" and "/cgi-dos/. At last you must only write a simple batch file like: python.exe c:\website\cgi-dos\name.py and save it for example as "py1.bat". Now you add a line like this in your html-document: Callcgi-script

Bjoern -- Jemand musste Josef K. verleumdet haben, denn ohne dass er etwas boeses getan hatte,wurde er eines Morgens verhaftet. -Franz Kafka- homepage: www.dgsit.de/bjoerngam/ email: bjoerngam at knuut.de From mhammond at skippinet.com.au Tue Dec 28 19:58:11 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 29 Dec 1999 00:58:11 GMT Subject: Sydney scoreboard? References: <385DB48C.7A7A52D6@bby.com.au> <8On74.6414$Dh3.85256@ozemail.com.au> <38601AF6.7D39F091@bby.com.au> Message-ID: "Sarah Burke" wrote in message news:38601AF6.7D39F091 at 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). Not many. We did create a python-au mailing list, but that is very quiet - http://starship.python.net/mailman/listinfo/python-au Some sort of social gathering would be good - although it would obviously need to be city-by-city. Melbourne and Sydney both have decent numbers of users... Mark. From Alex.Martelli at think3.com Tue Dec 28 04:01:08 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Tue, 28 Dec 1999 10:01:08 +0100 Subject: copy-and-paste (was RE: "sins" (aka, acknowledged language proble ms)) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D8A@pces.cadlab.it> William "Billy" Tanksley writes: > >The "cut and paste" style of "code re-use" is a > >blight (and I've done enough code inspections [snip] > The fact that it's so common implies something about it. > The "common" attribute holds for prostitution, drug and alcohol abuse, child molesting... -- what most would take as the key implication of all of these "commonalities" is that humans are a fallen race, or other less-theologically-expressed but analogous reflections on human nature. This lack of perfection need not imply a lack of perfectibility, though... > >If Java's "no hiding" rule really discourages it [snip] > I'm not sure that discouraging it is the right approach -- I think that > making it unneeded is better. OO gave a start at that; Aspect Orientation > Not mutually exclusive; reducing effective demand for goods and services which are deemed to be negative externalities can and should proceed along both tracks at once -- discourage _and_ provide alternatives (e.g, road-congestion-pricing goes perfectly well hand in hand with enhancements in public transportation). "Tough on copy-n-paste, tough on the CAUSES of copy-n-paste" is how Tony Blair might have chosen to express it, had he happened to address the issue:-). Alex From zigu50 at yahoo.com Mon Dec 20 04:09:56 1999 From: zigu50 at yahoo.com (zigu) Date: Mon, 20 Dec 1999 10:09:56 +0100 Subject: problems with python's shell Message-ID: <83krop$s5q$1@news1.sunrise.ch> Hi I'm working with python 1.52 and tkinter (I've installed Tcl/Tk 8.0.5) under windows NT4.0 I start a program from a tkinter window, I capture the output in a file to redirect it, but the python shell stays open anyway (obviously with no output..). Somebody knows how can I run a program direct from a tkinter window without opening the python shell? thanks From thomas at bibsyst.no Wed Dec 29 07:46:26 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Wed, 29 Dec 1999 13:46:26 +0100 Subject: Module-repository Message-ID: <386A02A2.5CB32ED9@bibsyst.no> Hi, 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. Ok, so www.python.org has a list of some resources, but that`s not the same. Best regards, Thomas Weholt From tim_one at email.msn.com Thu Dec 9 21:54:59 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 9 Dec 1999 21:54:59 -0500 Subject: Generating combinations (was RE: automatic "lotjes trekken") In-Reply-To: <000101bf3bd4$291af000$542d153f@tim> Message-ID: <000001bf42b9$f35e74e0$60a2143f@tim> [Fran?ois Pinard asks whether there's a std helper available to generate permutations or combinations. Tim sez not that he knows of, but he has a bunch of inconsistent code for stuff "like that"; notes that full polymorphism costs more than working only with lists; and says he expects to clean up his code some day & make it available] Which is a bigger project than I can make time for now, so here's a cleaned-up version of just one combinatorial family (combinations). I'm only going to post the module docstring here; mail me if you want a beta and I'll mail back the whole module (about 20Kb). Once I'm happy with the design, I'll upload it somewhere. It will be in the public domain. The main ideas so far are: 1) There's a tension between fast-but-limited lists of "canonical ints", and routines that work with any kind of sequence. This is resolved here by supplying both: class CombGenBasic for the former, and CombGen for the latter. 2) Lexicographic order, Gray code order, and random selection are all important in different apps. So each class supports all three, under method names .getlex(), .getgray() and .getrand(). 3) I've never before released code that relies on my doctest.py framework for testing, but it saves me so much time I'm ending that policy. In return, you can be certain that every example in every docstring behaves exactly as shown. But you won't be able to run the tests yourself without downloading the doctest framework (see Python FTP Contrib). 4) Let the user supply a different random number generator. I expect all 4 points will apply to other combinatorial families too, so before I push on I'd like interested people to try this interface and gripe about what they hate. or-gripe-about-what-they-love-sometimes-it's-hard-to-tell-ly y'rs - tim # Module combgen version 0.0.1 # Released to the public domain 09-Dec-1999, # by Tim Peters (tim_one at email.msn.com). # Provided as-is; use at your own risk; no warranty; no promises; enjoy! """\ CombGen(s, k) supplies methods for generating k-combinations from s. CombGenBasic(n, k) acts like CombGen(range(n), k) but is more efficient. s is of any sequence type such that s supports catenation (s1 + s2) and slicing (s[i:j]). For example, s can be a list, tuple or string. k is an integer such that 0 <= k <= len(s). A k-combination of s is a subsequence C of s where len(C) = k, and for some k integers i_0, i_1, ..., i_km1 (km1 = k-1) with 0 <= i_0 < i_1 < ... < i_km1 < len(s), C[0] is s[i_0] C[1] is s[i_1] ... C[k-1] is s[i_km1] Note that each k-combination is a sequence of the same type as s. Different methods generate k-combinations in lexicographic index order, a particular "Gray code" order, or at random. The constructor saves a reference to (not a copy of) s, so don't mutate s after calling CombGen. Also a bad idea to mix calls to getlex() with getgray() (they share internal state, but a call to one may not update the state used by the other). Module function comb(n, k) returns the number of combinations of n things taken k at a time; n >= k >= 0 required. The .reset() method can be used to start over. The .set_start(ivector) method can be used to force generation to begin at a particular combination. GETLEX -- LEXICOGRAPHIC GENERATION Each invocation of .getlex() returns a new k-combination of s. The combinations are generated in lexicographic index order (for CombGenBasic, the k-combinations themselves are in lexicographic order). That is, the first k-combination consists of s[0], s[1], ..., s[k-1] in that order; the next of s[0], s[1], ..., s[k] and so on until reaching s[len(s)-k], s[len(s)-k+1], ..., s[len(s)-1] After all k-combinations have been generated, .getlex() returns None. Examples: >>> g = CombGen("abc", 0).getlex >>> g(), g() ('', None) >>> g = CombGen("abc", 1).getlex >>> g(), g(), g(), g() ('a', 'b', 'c', None) >>> g = CombGenBasic(3, 2).getlex >>> g(), g(), g(), g() ([0, 1], [0, 2], [1, 2], None) >>> g = CombGen((0, 1, 2), 3).getlex >>> g(), g(), g() ((0, 1, 2), None, None) >>> p = CombGenBasic(4, 2) >>> g = p.getlex >>> g(), g(), g(), g(), g(), g(), g(), g() ([0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], None, None) >>> p.reset() >>> g(), g(), g(), g(), g(), g(), g(), g() ([0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], None, None) >>> GETGRAY -- GRAY CODE GENERATION Each invocation of .getgray() returns a triple C, tossed, added where C is the next k-combination of s tossed is the element of s removed from the last k-combination added is the element of s added to the last k-combination tossed and added are None for the first call. Consecutive combinations returned by .getgray() differ by two elements (one removed, one added). If you invoke getgray() more than comb(n,k) times, it "wraps around" and generates the same sequence again. Note that the last combination in the return sequence also differs by two elements from the first combination in the return sequence. Gray code ordering can be very useful when you're computing an expensive function on each combination: that exactly one element is added and exactly one removed can often be exploited to save recomputation for the k-2 common elements. >>> o = CombGen("abcd", 2) >>> for i in range(7): # note that this wraps around ... print o.getgray() ('ab', None, None) ('bd', 'a', 'd') ('bc', 'd', 'c') ('cd', 'b', 'd') ('ad', 'c', 'a') ('ac', 'd', 'c') ('ab', 'c', 'b') >>> GETRAND -- RANDOM GENERATION Each invocation of .getrand() returns a random k-combination. >>> o = CombGenBasic(1000, 6) >>> import random >>> random.seed(87654) >>> o.getrand() [69, 223, 437, 573, 722, 778] >>> o.getrand() [409, 542, 666, 703, 732, 847] >>> CombGenBasic(1000000, 4).getrand() [199449, 439831, 606885, 874530] >>> """ From python-list at teleo.net Mon Dec 27 14:18:35 1999 From: python-list at teleo.net (Patrick Phalen) Date: Mon, 27 Dec 1999 11:18:35 -0800 Subject: Python suitability In-Reply-To: <3867B700.924C18C@maxtal.com.au> References: <38549DEA.B0157D0@iqsoft.hu> <3867A2FE.C9FFC5B9@digicool.com> <3867B700.924C18C@maxtal.com.au> Message-ID: <99122711211805.01988@quadra.teleo.net> [skaller, on Mon, 27 Dec 1999] :: Jim Fulton wrote: :: > I predict that your prediction will be borne out. :: :: Did you intend 'will not be bourne out' here? I like Jim's version better; it's more thought provoking. ;) [sound of 10,000 Pythonistas scratching their heads] From bwarsaw at cnri.reston.va.us Mon Dec 27 11:04:41 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Mon, 27 Dec 1999 11:04:41 -0500 (EST) Subject: Python Considered Harmful References: <1265818153-51405123@hypernet.com> Message-ID: <14439.36377.630736.423556@anthem.cnri.reston.va.us> >>>>> "Gordo" == Gordon McMillan writes: Gordo> Practically, I often create "abstract" base classes which Gordo> specify interface and have "pass" (or "assert 1 == 0") as Gordo> method bodies. Alternatively, starting with Python 1.5.2 you can just let the body raise NotImplementedError. -Barry From ullrich at math.okstate.edu Fri Dec 31 13:38:03 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 31 Dec 1999 12:38:03 -0600 Subject: __rcall__??? References: <000601bf531b$42c51d60$3ca2143f@tim> Message-ID: <386CF80A.2A9630FF@math.okstate.edu> Tim Peters wrote: > [Tim] > [...]I don't grasp what's eating you. > > [...] sorry for the aggravation. > > > [[Dave]a rant about single-argument vs multiple-argument functions] > > My favorite non-Python language is Haskell, in which all functions are > curried (common jargon in the functional-language biz for "single > argument"), even addition (e.g. "+" is a function that takes (say) an > integer argument and returns a function mapping ints to ints; "- 1" is a > function that returns a function that subtracts one from its argument; "1 -" > is function that returns a function that subtracts its argument *from* 1; > etc.). > > You don't need to convince me that's an elegant & very useful view of the > world. It's simply not Python's view of the world. > > Still, as you discovered, it's quite possible to write Python code to fake > it! Python doesn't force you to write multiple-argument functions, and I'm > not even asking you to. My only interest here is in preventing a push for > *Python's* call implementation to treat single-argument functions in a > distinguished way (as would the hypothetical __rcall__ method of the subject > line); my attempts to explain why that's unnatural in *Python* appear to be > perceived as attacks against Mathematical Truth. They're not. Curried > functions in Python are as much a strain as representing ints as lambda > compositions in Python (which also can-- for that matter, has --been done). > > [still in sarcasm mode] > > the idea that different answers are appropriate in different > > contexts is just silly. > > What would be silly is the notion that a single programming language *can* > (let alone "should") support all modes of expression with equal fluidity. Right. I guess there was a minsunderstanding here. The aggravation was due to my impression that you were saying that just because Python did this and that it was wrong for me to do something else. It's clear (today) that that's not what you intended. The reason I took your comments that way is that I didn't know how else to take them; the idea that you were just trying to prevent a push for various changes in Python didn't occur to me (largely because of the _many_ times I'd said that I wasn't proposing any changes to Python.) > choices-have-consequences-and-python-made-some-ly y'rs - tim Indeed. I think they made some real good ones. I actually haven't said anything to the contrary. Dunno-why-I'm-posting-this-since-the-world-ends-at-midnight-ly, DU From gawron at obop.com.pl Mon Dec 13 04:55:10 1999 From: gawron at obop.com.pl (=?iso-8859-2?Q?Przemys=B3aw?= G. =?iso-8859-2?Q?Gawro=F1ski?=) Date: Mon, 13 Dec 1999 10:55:10 +0100 Subject: smtp & attachments Message-ID: <3854C27E.7E20FD3F@obop.com.pl> In my application I'm going to send reports in a email (using the smtp modul). Could some one show me the easyiest way to attach a file to a mail that I'll send using this module ? Thanks Przemek -- Przemyslaw G. Gawronski UIN:8358522 mailto:gawronskip at usa.net mailto:gawron at obop.com.pl From fdrake at acm.org Tue Dec 21 15:05:44 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 21 Dec 1999 15:05:44 -0500 (EST) Subject: Arg! (Makefile.pre.in) In-Reply-To: References: Message-ID: <14431.56728.357282.276777@weyr.cnri.reston.va.us> Magnus L. Hetland writes: > 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 Magnus, Perhaps you could tell us exactly the commands you entered and what Setup.in looked like? That would help a lot. Also, are you sure you're using Misc/Makefile.pre.in, not ./Makefile.pre.in, from the source distribution? -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From fdrake at acm.org Tue Dec 21 12:00:02 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 21 Dec 1999 12:00:02 -0500 (EST) Subject: Diffs In-Reply-To: <19991221160535.B2087@stopcontact.palga.uucp> References: <19991218223342.A11575@stopcontact.palga.uucp> <19991221160535.B2087@stopcontact.palga.uucp> Message-ID: <14431.45586.570289.61704@weyr.cnri.reston.va.us> 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!) 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. ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From mgushee at havenrock.com Mon Dec 13 21:55:54 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 13 Dec 1999 21:55:54 -0500 Subject: Need help with Tkinter References: <8342a8$1td$1@nnrp1.deja.com> Message-ID: rodzilla2000 at my-deja.com writes: > Change the "Hello World" button a "Add Exit Button" that would put > another button on the screen to allow exiting the program. > > =========START OF CODE > # Button test... > > import sys > from Tkinter import * > > #main routine > def main(): > root=Tk() > btnAddButton=Button(root) > btnAddButton['text']='Add Exit Button' > btnAddButton.pack() > > #start mainloop > root.mainloop > > def subAddButton(parent): > btnExitButton=Button(parent) > btnExitButton['text']='Exit Program' > btnExitButton['command']=subExit #see below > > def subExit(): > sys.exit(0) > > > #execute the main routine > main() > ==========END OF CODE > > When I run this code, the exit button is already displayed. The "Add Right, because in: > btnAddButton['command']=subAddButton(root) # See below ... evaluating this statement *calls the function subAddButton()*. So the button is created when main() is executed, and since subAddButton returns ... returns what? Maybe None -- I can't remember offhand, but anyway it's nothing useful to you. It's been a while since I did any Tkinter programming, but as far as I can recall you can't pass an argument to a button command, because you can't use any parentheses when you assign the command to the button. You could either make root a global variable -- ugly, but it works in a pinch -- or you could create an event binding like: btnAddButton.bind('', subAddButton) then subAddButton has an 'event' argument: def subAddButton(event=None): 'event' being an object that is automatically passed when the event binding is invoked -- it's __dict__ attribute contains all sorts of useful information, such as the widget that captured the event: caller = event.__dict__['widget'] This is, of course, the preferred object-oriented-type solution ... though it's less simple than we might wish, eh? Hope this helps a bit. -- Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ From greg.ewing at compaq.com Wed Dec 15 08:51:57 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 16 Dec 1999 02:51:57 +1300 Subject: Dot product? References: <3852B91D.6EE31805@math.okstate.edu> <3854CBFF.85A69AA@compaq.com> <3854F1EE.3CA02CD6@compaq.com> Message-ID: <38579CFD.13B9A8CE@compaq.com> "Magnus L. Hetland" wrote: > > 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. I don't think it would be a good idea to special-case the meaning of "and" like that. The expression (x and y) already has a well-defined meaning even when x and y are both lists, albeit not a particularly useful one. Changing it would be introducing an inconsistency of a different sort. Greg From skip at mojam.com Fri Dec 10 01:41:05 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 10 Dec 1999 00:41:05 -0600 (CST) Subject: string interpolation in doc strings... In-Reply-To: <14416.3969.90448.612046@anthem.cnri.reston.va.us> References: <14416.3969.90448.612046@anthem.cnri.reston.va.us> Message-ID: <14416.41089.649043.126089@dolphin.mojam.com> Getting a bit far afield from the original request, so I've trimmed the cc's and references and changed the subject. Barry wrote: Barry> def usage(code, msg=''): Barry> print __doc__ % globals() Barry> if msg: print msg Barry> sys.exit(code) Barry> Then you put all the script's --help text in the module Barry> docstring, with a few %(thingie)s sprinkled around it. Works Barry> really well! I imagine some of the active particpants in the doc sig will have some opinions about the use of format strings embedded in doc strings. It's not immediately obvious to me that it's good docstring stewardship. For example, in my PYTHONSTARTUP file I define the simple function: def help(x): try: print x.__doc__ except AttributeError: print "no docstring available" so I can type stuff like import string help(string.find) at the interpreter prompt. If string interpolation in doc strings becomes common practice, this simple approach becomes less useful because I don't know just what context to expect such strings to be evaluated. I could modify my help function to try and locate a dict to tack onto the print: from types import * def help(x): try: if type(x) == ModuleType: print x.__doc__ % x.__dict__ else: print x.__doc__ except AttributeError: print "no docstring available" but that seems like a very kludgy hack (that is, not at all general). 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 donn at u.washington.edu Thu Dec 2 17:41:04 1999 From: donn at u.washington.edu (Donn Cave) Date: 2 Dec 1999 22:41:04 GMT Subject: Environment variables References: Message-ID: <826si0$dr2$1@nntp6.u.washington.edu> Quoth "jeff" : | 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. I don't know about Windows, but you just can't do that on UNIX. The parent process (the shell) has its own environment data in its own process memory, where it's safe from your Python program. The way to communicate with the shell is "print" the data, and the shell can pick up the output and assign it to a variable - SPV=`python spv.py` export SPV Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From aa8vb at yahoo.com Wed Dec 8 14:18:39 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 8 Dec 1999 14:18:39 -0500 Subject: X display visual In-Reply-To: <384C39EE.6B5921EC@callware.com> References: <384C39EE.6B5921EC@callware.com> <14412.15539.879016.832154@weyr.cnri.reston.va.us> <384C39EE.6B5921EC@callware.com> Message-ID: <19991208141839.A3847@vislab.epa.gov> Ivan Van Laningham: |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: ... | 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? Yes. Frame and Toplevel widgets have visual and colormap resources which can be set. Here is some simple code that just deals with 8bpp pseudo and 24bpp true. --------------------------------------------------------------------------- root = Tk() root.wm_withdraw() # Determine the depth, if non specified if depth: assert depth in [ 8, 24 ] else: depth = root.winfo_depth() # Just force 24-bit depth = 24 if depth == 8: visual = "pseudocolor 8" else: visual = "truecolor 24" main = Toplevel( root, visual=visual ) --------------------------------------------------------------------------- Stack your widgets under 'main' rather than 'root'. To be more robust, pick a visual returned by: root.winfo_visualsavailable() As you suggested, selecting the proper visual is the best solution (as opposed to forcing the user to reconfigure the default depth of their X server). -- Randall Hopper aa8vb at yahoo.com From ivanlan at callware.com Thu Dec 2 08:52:04 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 02 Dec 1999 06:52:04 -0700 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: <38467984.B7A27ECC@callware.com> Hi All-- Well, since this question seems about to come to fisticuffs, I suggest everyone look at this little masterpiece: http://www.douglasadams.com/dna/pedants.html -ly y'rs, Ivan Robin Becker wrote: > > 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 > > -- > http://www.python.org/mailman/listinfo/python-list -- ---------------------------------------------- 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 fredrik at pythonware.com Thu Dec 16 06:21:22 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 16 Dec 1999 12:21:22 +0100 Subject: trying again: CgiHttpServer workalike for Win/NT and Win/98? References: <837o38$b65$1@serv1.iunet.it> Message-ID: <013101bf47b7$b88367b0$f29b12c2@secret.pythonware.com> Alex Martelli wrote: > 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...:-). medusa might be what you need: http://www.nightmare.com/medusa/index.html From mcalla at home.com Mon Dec 13 20:35:54 1999 From: mcalla at home.com (Mike Callahan) Date: Tue, 14 Dec 1999 01:35:54 GMT Subject: Tkinter/IDLE crash References: <82pkpk$3o0$1@mirv.unsw.edu.au> Message-ID: <_9h54.2876$t65.32097@news.rdc1.tn.home.com> > 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. > I am a newbie also but I found out that calling quit() does not work inside of IDLE since IDLE is also a Tk application. When you call quit, it REALLY quits. Use destroy(). Here is a simple script that works inside of IDLE. from Tkinter import * root = Tk() frame = Frame(root) frame.pack() button = Button(frame, text='Exit', command=root.destroy) button.pack() root.mainloop() An OOP programmer would shudder, (no classes) but I have used this script as a starting point. From mikael at isy.liu.se Wed Dec 1 08:36:24 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 01 Dec 1999 14:36:24 +0100 (MET) Subject: wish: multiline comments In-Reply-To: <8233mi$d5i@mail.psy.uva.nl> Message-ID: On 01-Dec-99 Ionel Simionescu wrote: > I would like to see multiline comments possible in some future version of > Python. Use multiline strings. """ This is a long comment about the fact that you alredy have the possibility you ask for. """ /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 01-Dec-99 Time: 14:34:16 This message was sent by XF-Mail. ----------------------------------------------------------------------- From jkraai at murl.com Thu Dec 23 15:52:08 1999 From: jkraai at murl.com (jim kraai) Date: Thu, 23 Dec 1999 14:52:08 -0600 Subject: httplib vs. urllib References: <3861C050.E8EAD05@murl.com> <19991223110911.A2110@stopcontact.palga.uucp> Message-ID: <38628B78.EB32463@murl.com> Thank you! Merry Christmas. --jim Gerrit Holl wrote: > > jim kraai wrote: > > Why is the output of: > > python httplib.py www.ni.dk > > > > so _vastly_ different than the output of: > > python urllib http://www.ni.dk > > > > This has me _completely_ stumped. > > Because of virtual hosts. > > Some servers have multiple "virtual hosts". For example, if you go to > ni.dk, you'll see something else than when you go to www.ni.dk. But it's > the same server. > > That's because your browser gives a 'host' header: > Host: www.ni.dk > > The server returns another page when you give that header. > httplib.py doesn't give that header, > urllib.py, which is on a higher level, does give that header. > > regards, > Gerrit. > > -- > "If a machine couldn't run a free operating system, we got rid of it." > > -- Richard Stallman (Open Sources, 1999 O'Reilly and Associates) > 11:07am up 25 min, 12 users, load average: 0.00, 0.03, 0.13 From tismer at appliedbiometrics.com Thu Dec 2 06:44:32 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 02 Dec 1999 12:44:32 +0100 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: <38465BA0.4F1A90A4@appliedbiometrics.com> 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. Another viewpoint: What is your first birthday? It is the day after your first year of life, which starts on your zeroth birthay which is your birth. years-are-interval-counts - ly 'yrs - 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 13:02:52 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 17 Dec 1999 05:02:52 +1100 Subject: Python complaints References: <38576B73.59C7BA85@udel.edu> <838o42$dsu$1@nnrp1.deja.com> Message-ID: <3859294C.7AF7DEDF@maxtal.com.au> 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. > 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, It is almost no work at all: Given a function sin, we can make sin_list, which works over any sequence, returning a list, by using map, by: def sin_list(arglist): return map(sin, arglist) We could also do: def sin_args(*arglist): return map(sin, arglist) which is slightly different. Now, go figure how easy it is to make a list of functions [f1, g1, k1, ...] and generate all the 'mapped' variants of them. -- 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 bitbucket at isomedia.com Tue Dec 28 02:22:52 1999 From: bitbucket at isomedia.com (Eugene Goodrich) Date: Tue, 28 Dec 1999 07:22:52 GMT Subject: python's for not like c++'s? References: <38A0267B@MailAndNews.com> Message-ID: <38686473.191986512@news.isomedia.com> >>> for i in range (3, 10, 3): print i, print for i in range (9, 0, -3): print i, <<< range () functionality is explained in the Python HTML documentation under "Library Reference -> 2.3 Built-in Functions". -Eugene On Tue, 28 Dec 1999 01:33:30 -0500, jerry smith wrote: >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. >------------------------------------------------------------ > import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==') From ttnttn at toad.scripps Tue Dec 14 13:19:09 1999 From: ttnttn at toad.scripps (Thien-Thi Nguyen) Date: 14 Dec 1999 10:19:09 -0800 Subject: Python complaints References: <000201bf3bd4$2bda5e20$542d153f@tim> <38562655.77A3B3DC@udel.edu> Message-ID: Charles Boncelet writes: > fx = [] > for a in x: > fx.append(a**2) > > Am I missing something? missing the final assignment: sq = fx thi From ivanlan at callware.com Thu Dec 2 16:55:41 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 02 Dec 1999 14:55:41 -0700 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <826dtd$bre$1@newshost.accu.uu.nl> <99120213381607.04234@quadra.teleo.net> Message-ID: <3846EADD.4AF2ED00@callware.com> Hi All-- Patrick Phalen wrote: > > [Martijn Faassen, on Thu, 02 Dec 1999] > > :: 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. > > Great idea. For purposes of announcing this to the news media, I propose > you call it The Y0K Bug. > -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 gmcm at hypernet.com Thu Dec 30 10:36:00 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 30 Dec 1999 10:36:00 -0500 Subject: No constructor calls???? In-Reply-To: <18Ka4.3688$9e3.188173@newsread1.prod.itd.earthlink.net> Message-ID: <1265555221-4520858@hypernet.com> Arinte writes: > When I have this code the constructor is called > > xpac=PossDevice.PossArg("12345678",21) > devlist.append( xpac ) > > but, this code doesn't seem to function > > devlist.append( PossDevice.PossArg("12345678",21) ) > > Is the second one invalid or something? How can I do the first > one in one call? If the first one works, so does the second. More likely you changed something else that broke it. - Gordon From gchiaramonte at ibl.bm Tue Dec 28 14:25:29 1999 From: gchiaramonte at ibl.bm (Gene Chiaramonte) Date: Tue, 28 Dec 1999 15:25:29 -0400 Subject: Array Module Question Message-ID: <84b2bq$264$1@ffx2nh5.news.uu.net> Is there a native sort() method available for the array module? Or has anyone extended it and added the sort? Thanks, Gene From aahz at netcom.com Sun Dec 26 19:46:38 1999 From: aahz at netcom.com (Aahz Maruch) Date: 27 Dec 1999 00:46:38 GMT Subject: Python newbie References: <38549DEA.B0157D0@iqsoft.hu> <38654F5C.378F8338@maxtal.com.au> <002601bf4f42$58e98cc0$49294b0c@amd> <000d01bf4ff5$e33d7220$5c2a4b0c@amd> Message-ID: <846cte$ac0$1@nntp5.atl.mindspring.net> In article <000d01bf4ff5$e33d7220$5c2a4b0c at amd>, 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. You don't put any C code into your application; you link to a library that happens to be written in C but could be written in FORTRAN for all you know. ;-) I haven't actually done any work in this area, but I seem to be the only one posting... With regard to Python extensions, you have two options. One is to directly call a library that can be written in any language (see SWIG for help here); the other is to use Pythonic C. >Are there Python variants that might be better suited, like this Viper >language I heard mentioned on the list? Viper is written in a langauge called Ocaml and is not yet ready for prime time. JPython is another alternative (Python written in Java). Given that your application core is already being written in C++, I'd suggest sticking to CPython. >If Python is a dynamically typed language, how does it handle sending >specific types to a native function call or from a native call into Python? As I alluded to above, you can either force Python to send binary types across the interface or you can use Pythonic C to use Python types (or use JPython and Java types). I assume you can also use a combination of the two, though I have no idea why you'd want to (within a single library, I mean, you might purchase a library that you want to interface to Python). Just to be clear, you can embed a Python interpreter in your application, make calls from Python into external libraries, or both (you could even have an embedded Python interpreter make callbacks into your application, though I hear that gets a bit tricky). One of Python's strengths is that it is a very good glue language. For more reassurance, take a look at http://www.python.org/psa/Users.html -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 6 days and counting! From matthewm at es.co.nz Thu Dec 30 16:27:47 1999 From: matthewm at es.co.nz (Matthew Miller) Date: Fri, 31 Dec 1999 10:27:47 +1300 Subject: RPM-interface/module References: <386B3CDB.FF843280@bibsyst.no> Message-ID: <386BCE53.A8D93A67@es.co.nz> http://andrich.net/python/ Thomas Weholt wrote: > Is there a RedHat package interface/module available for Python?? > > Thomas From milton at isomedia.com Tue Dec 21 13:17:26 1999 From: milton at isomedia.com (Stephen Milton) Date: Tue, 21 Dec 1999 10:17:26 -0800 Subject: Python and ADSI Message-ID: 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. TIA, Steve Milton From m.faassen at vet.uu.nl Tue Dec 14 10:52:38 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 14 Dec 1999 15:52:38 GMT Subject: Python suitability References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> Message-ID: <835p46$gr0$1@newshost.accu.uu.nl> Nemeth Miklos wrote: [snip] >> I do find Zope a bit slow - even when I browse a Zope database on a >> machine on my local network. > Again I am very sad! I wanted to start a new department in our company > developing ecommerce applications. I am on the point of selecting a > development environment. Untill now I would voted for Apache+SSL + Zope > 2.1, but I am also thinking of using Apache+SSL + PHP or ApacxheSSL + > mod_perl. > Do you not think Zope would be a good platform for our projects? Zope's fast enough to withstand slashdotting (www.technocrat.net has been slashdotted a couple of times). Zope's own site is quite heavily used (there were statistics posted to the Zope mailing list) and is in Zope. Boudewijn was comparing the management interface (over the network in a browser) with a native GUI interface. Any web interface is slower than a native GUI, of course. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From python-list at teleo.net Wed Dec 8 03:27:31 1999 From: python-list at teleo.net (Patrick Phalen) Date: Wed, 8 Dec 1999 00:27:31 -0800 Subject: browser interface? In-Reply-To: <19991208005503.CD6AC1CD0A@dinsdale.python.org> References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> <19991208005503.CD6AC1CD0A@dinsdale.python.org> Message-ID: <99120800562707.02363@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: Travis Oliphant Newsgroups: comp.lang.python Subject: Re: Converting data to little endian Date: Tue, 7 Dec 1999 16:35:33 -0600 Organization: Mayo Foundation Lines: 17 Message-ID: References: <82jjc6$ks1$1 at nnrp1.deja.com> NNTP-Posting-Host: us2.mayo.edu Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: tribune.mayo.edu 944606182 29759 129.176.201.54 (7 Dec 1999 22:36:22 GMT) X-Complaints-To: usenet at mayo.edu NNTP-Posting-Date: 7 Dec 1999 22:36:22 GMT To: victor_ng at my-deja.com In-Reply-To: <82jjc6$ks1$1 at nnrp1.deja.com> Path: news!uunet!ffx.uu.net!newsfeed1.nyc1.globix.net!news-out.cwix.com!newsfeed.cwix.com!logbridge.uoregon.edu!newshub.tc.umn.edu!mayonews.mayo.edu!us2.mayo.edu!olipt Xref: news comp.lang.python:77847 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 > 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). One possibility is to use the NumPy extensions and store your data in a multiarray object. There is a byteswapped method of the multiarray object that lets you byteswap your data. There is also a way to check the endianness of your machine (so you can determine whether or not to byteswap). Good luck, Travis From wtanksle at hawking.armored.net Wed Dec 1 13:27:33 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 1 Dec 1999 18:27:33 GMT Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD81@gandalf.digicool.com> Message-ID: 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. >Brian Lloyd brian at digicool.com Go Zope! -- -William "Billy" Tanksley, in hoc signo hack From andres at corrada.com Tue Dec 7 14:25:17 1999 From: andres at corrada.com (andres) Date: Tue, 07 Dec 1999 14:25:17 -0500 Subject: Need python mode for Jed References: Message-ID: <384D5F1D.C1F2CE6E@corrada.com> 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? Check the Editor Configuration HOWTO (http://www.python.org/doc/howto/editor) which has a section on jed. If this does not answer your question, let me know so I can improve the HOWTO. Andres Corrada From fdrake at acm.org Wed Dec 1 13:29:26 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 1 Dec 1999 13:29:26 -0500 (EST) Subject: python test frameworks In-Reply-To: <_Ob14.44147$oa2.324786@iad-read.news.verio.net> 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> <_Ob14.44147$oa2.324786@iad-read.news.verio.net> Message-ID: <14405.26886.771268.837229@weyr.cnri.reston.va.us> Tom Culliton writes: > Sounds like something you'd want to see a doctor about before doing > anything rash... ;-) ;-) ;-) As a father of young kids, my handling of the matter would only involve changing diapers, not suspecting that my daughter need be wary of the boys in that way... (Need to get her signed up for some self- defense classes soon! She's almost 6 months old! ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From mlh at vier.idi.ntnu.no Tue Dec 21 16:46:53 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 21 Dec 1999 22:46:53 +0100 Subject: Arg! [Long] References: <14431.56728.357282.276777@weyr.cnri.reston.va.us> <14431.58546.940849.802614@weyr.cnri.reston.va.us> <14431.60189.682411.792427@weyr.cnri.reston.va.us> <14431.61484.662532.436321@weyr.cnri.reston.va.us> <14431.62693.315102.327391@weyr.cnri.reston.va.us> Message-ID: "Fred L. Drake, Jr." writes: > Magnus L. Hetland writes: [...] > > I'm not sure what's going on here. If you don't get it after a bit > of sleep, send me your spludge.c and I'll take a look. OK. Thanks for the help :) (And to all you others - sorry for rambling on... :) > > > -Fred -- Magnus Lie Hetland From rjroy at takingcontrol.com Thu Dec 2 16:02:20 1999 From: rjroy at takingcontrol.com (Robert Roy) Date: Thu, 02 Dec 1999 21:02:20 GMT Subject: Python complaints References: <867lj85g4c.fsf@g.local> Message-ID: <3846db0f.26374828@news1.on.sympatico.ca> On 24 Nov 1999 10:38:27 +0000, Gareth McCaughan wrote: ... > - Method definitions have to be lexically contained in > class definitions. So suppose you write something that > parses a language and then does various things with > the parse tree; if you adopt an OO approach to the > parse tree (with things like "class IfStatement(ParseNode):") > then you can't separate out very different operations like > foo.print(), foo.compile() and foo.evaluate(). (That is, > you can't group all the print methods together, and group > all the compile methods together somewhere else, etc.) > You can, of course, split your code up by having the WhileLoop > and UntilLoop classes in different files, but this seems > less sensible to me. :-) (This particular gripe applies to > most OO languages.) > Unless I misunderstood your post, the following code would do the job nicely. bar.py def bar(self): print self.__class__.__name__ def bar2(self): print 'In bar 2', self.bar foo.py class foo: from bar import * if __name__ == '__main__': f = foo() f.bar() f.bar2() foo2.py class foo2: from bar import * if __name__ == '__main__': f = foo2() f.bar() f.bar2() of course this is just a slightly more akward way of writing bar.by class bar: def bar(self): print self.__class__.__name__ def bar2(self): print 'In bar 2', self.bar foo.py from bar import bar class foo(bar): pass .... >-- >Gareth McCaughan Gareth.McCaughan at pobox.com >sig under construction From mikl at linux-france.org Wed Dec 1 01:29:43 1999 From: mikl at linux-france.org (Mickael Remond) Date: Wed, 01 Dec 1999 06:29:43 +0000 Subject: Python meta object question References: <3842D025.3283C871@linux-france.org> Message-ID: <3844C056.A1E7FF9@linux-france.org> 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 ? Mickael Remond From henrik at ravn.com Mon Dec 20 04:50:04 1999 From: henrik at ravn.com (Henrik Ravn) Date: Mon, 20 Dec 1999 10:50:04 +0100 Subject: writing extension in C++ for MacPython Message-ID: <83ku75$9ts$1@news101.telia.com> Hi all, I'm trying to run an interpreter instance from a C++ program. Everything works fine on the PC, but on the Mac I get as far as Py_Initialize() and boink, program exit. The stand-alone Python interpreter works fine. The setup: MacOS 8.6 Python 1.5.2c1 Metrowerks 5 compiler The project links with: PythonCore, MSL C, MSL C++, MSL SIOUX, MSL Runtime, Interface, MathLib, GUSI_MSL. Any ideas? Henrik From R.Brodie at rl.ac.uk Mon Dec 13 10:09:53 1999 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Mon, 13 Dec 1999 15:09:53 -0000 Subject: What do we call ourselves? References: <3850734D.FD1D7A2C@callware.com> Message-ID: <833282$ovi@newton.cc.rl.ac.uk> Ivan Van Laningham wrote in message news:3850734D.FD1D7A2C at callware.com... > There's been some discussion over the last couple of years over the > matter of how to refer to those who write Python for love, money or the > greater glory of Monty. I kind of like "Rossum's robots" myself ;) "There is, however, another method more simple, flexible, and rapid, which has not yet occurred to nature at all. " -- Karel Capek (in translation) From thor at localhost.localdomain Tue Dec 7 16:23:49 1999 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 7 Dec 1999 21:23:49 GMT Subject: sites offering free webspace & Python scripting...? References: <82j8cc$qju$1@serv1.iunet.it> Message-ID: On Tue, 7 Dec 1999 16:17:07 +0100, Alex Martelli wrote: >I've looked in the FAQ's, but couldn't find this info...: > >are there sites offering free web space, _and_ the >ability for the site maintainer to write Python >server-side scripts for the web pages? > >(CGI would suffice, although, no doubt, faster ways >would be preferable). > >I know of quite a few suppliers of free webspace that >offer no scripting whatsoever, and a few that allow >Perl scripting, but I'd really like to do my scripting in Which one offers free web space and *free Perl scripting* ? -- From Dirk.Engelmann at IWR.Uni-Heidelberg.De Mon Dec 13 07:20:36 1999 From: Dirk.Engelmann at IWR.Uni-Heidelberg.De (Dirk Engelmann) Date: Mon, 13 Dec 1999 13:20:36 +0100 (CET) Subject: httplib problem In-Reply-To: <38514A19.F92328BD@roguewave.com> Message-ID: Hi! On Fri, 10 Dec 1999, bjorn wrote: > try > > print form['data'].value > > as the last line. The problem is, form['data'] is not initialized (adding .value doesn't helptherefore). Probably the header which is send by the httplib-programm: hdr.append('Content-Disposition: form-data; name="data"') is not well stated - I don't know how the naming of a field could be done in a python script using httplib. In a web-form it works by using this field and a submit (button) statement. Thanks for help! Cheers, Dirk > > Dirk Engelmann wrote: > > > Hi! > > > > I want to transfer data by http betweeen a http-server (cgi-script) and > > > > a client (httplib). > > I tried this using httplib on the client side and transfering data > > to a cgi-script, but it failed. > > I appended a litele sample - which didn?t work and I can?t find > > a solution. > > Is there another easier way to do this ? > > > > Thanks for any help! > > > > Cheers, > > Dirk Engelmann > > > > #------------- http-client ------------------- > > import httplib > > from string import joinfields > > # sample data which should be transfered to the cgi-script port.py > > data = "testdata" > > # header: > > hdr = [] > > part = [] > > hdr.append('Content-Disposition: form-data; name="data"') > > hdr.append('Content-Type: application/octet-stream') > > hdr.append('Content-Length: %d' % len(data)) > > part.append("%s\n\n%s" % (joinfields(hdr,'\n'), data)) > > > > # st contains header and data > > st = joinfields(part, '') > > > > # open httplib and execute cgi-script port.py > > h = httplib.HTTP('localhost') > > boundary= '%s%s_%s_%s' % \ > > ('-----', int(time()), os.getpid(), randint(1,10000)) > > contentType = 'multipart/form-data; boundary=%s' % boundary > > h.putrequest('POST', '/cgi-bin/port.py') > > h.putheader('Accept', '*/*') > > h.putheader('Content-Type', contentType) > > h.putheader('Content-Length', str(len(st))) > > > > # transfer the data to cgi-script port.py > > h.endheaders() > > h.send(st) > > errcode, errmsg, headers = h.getreply() > > data = h.getfile().read() # Get the raw HTML > > print data > > > > #--------------- port.py : cgi-script on server ----------------- > > import cgi > > form = cgi.FieldStorage() > > print form['data'] > > # or print form['data'].value > > -- > > http://www.python.org/mailman/listinfo/python-list > From wtanksle at hawking.armored.net Fri Dec 17 20:33:06 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 18 Dec 1999 01:33:06 GMT Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> Message-ID: On Fri, 17 Dec 1999 10:20:46 +0100, Alex Martelli wrote: >Tim Peters is kind enough to respond to my request >for an URL about acknowledged Python defects with >detailed considerations boiling down to: > lots of tiny pet peeves, but no consensus >which seems to be a very accurate assessment. No it's not -- if there was no consensus I wouldn't be agreeing with it. But I am agreeing, so there must be consensus. Therefore it can't be true. >So, maybe I can move down a notch and try fishing >for Python things which at least "annoy" a "vast" >(carefully vague term:-) number of Pythonistas, >without compensating advantages to "many" others. Okay. First, Python doesn't have any way to transfer control statically; the only control transfer statement is exceptions, which are not the right tool sometimes, because they get thrown dynamically. We could use named loop-breaks. Second, Python uses 'else' in some VERY bizarre ways. Here's a quick way to memorize the proper way to use the 'else' statement with 'for': "forget it." (FYI, 'else' clauses on 'for' execute only if the loop terminates normally, which only doesn't happen if a break executes.) >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!-) I mainly agree, although I suspect that's managable. Someday, perhaps; it's no concern to me so long as I've got a way to implement weak pointers. Of course, I haven't ever needed those, but if I do I seem to recall an implementation :-). >The type/class split has been mentioned (it does >not affect most people, it helps none, it hinders, >albeit slightly, most of those who are trying to >do certain advanced things). Shrug. Somewhat. It doesn't really matter to me, as long as it's not taken too far -- nothing like Java's 'final' keyword (which allowed a library programmer to declare that no users would ever want to subclass his code, and worst of all was advertised as a way to SPEED UP code, ugh). >Would this also apply, to a weaker but broader >extent, to the lack of assigning-operators, an >"expression" kind of assignment, increment and >decrement in particolar, or other issues of the >expression/statement split? Hmm... I've never really cared :-). Take a look at Ruby -- it doesn't really have an expression/statement split. At least not in the same sense. >Alex-the-Python-newbie -- -William "Billy" Tanksley, in hoc signo hack From gcash at magicnet.net Sat Dec 18 21:29:49 1999 From: gcash at magicnet.net (gcash) Date: 18 Dec 1999 21:29:49 -0500 Subject: TK tree control References: <82lap0$sa4$1@nnrp1.deja.com> <82mdir$3qsu2@news.mecasw.com> Message-ID: I have a tree control available on my page at http://www.magicnet.net/~gcash, which is based on the Tkinter canvas widget. I'm in the middle of adding drag'n'drop to it. -gc From tottinge at concentric.net Tue Dec 21 09:08:08 1999 From: tottinge at concentric.net (Tim Ottinger) Date: 21 Dec 1999 09:08:08 EST Subject: difference between invocation of python script on unix and microsoft? References: <000201bf3ff0$f34bdf40$3acbd9c2@peridot.optichrome.com> Message-ID: <385f8bb2.88606319@news.concentric.net> On Wed, 8 Dec 1999 17:46:51 +0100, Roberto Lupi wrote: >However, you can't invoke it with I/O redirection, like this: > cat < myfile.txt > cat myfile.txt | more > >although it looks like you should be able to (this is a limitation of >Windows NT). Your script can be in your path or you can provide a path to >the file. I've found this to be true also. I've taken to creating a .bat file to run my .py file, and that works just fine. I hate doing it, and would rather have it work correctly, though. Do the alternative command lines work better? Tim From tismer at appliedbiometrics.com Sun Dec 19 20:28:06 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Mon, 20 Dec 1999 02:28:06 +0100 Subject: LISTS: Extract every other element - SUMMARY References: <385D4DCD.2B081168@appliedbiometrics.com> Message-ID: <385D8626.C4DD2AC0@appliedbiometrics.com> Hi Mike, Hi List, I was nearly at home when it hit me: Why do we get so different timing results here? I think I got it: It is simply the frame allocation heuristics which its me. Frames are cached. Whenever a new frame is requested and the frame cache isn't empty, the topmost frame on the freelist is used. But: If the frame is too small for the local variables of the function to be called, a realloc takes place. This optimization is good in the average. In my case, it is the showstopper. My fast list creation uses 50 extra variables on the stack. That is quite unusual, and it is very likely that the topmost cached frame does not fit. A realloc takes place. Now, Mike runs his tests this way: 1) for function in [ forMult,forDiv, numReshape, numSlicing, chrisGiven, chrisInline]: avg = [] for x in range(5): t = clock() function( data ) avg.append( clock()-t ) print '%s %.4f'%(function, reduce( lambda x,y: x+y, avg )/len(avg)) The result value of function ( data ) is thrown away immediately. He runs my timing version this way: 2) for function in [ forMult,forDiv, numReshape, numSlicing, chrisGiven, chrisInline]: elapsed, result = timing( function, (data,), 1 ) print '%s %.4f'%(function, elapsed) That's very different: The result variable is kept alive! Why does this matter? Since my functions need to do a realloc due to the frame size, this will most likely eat the result variable which is freed in 1), and creating the next result variable will find a big hole which is too small, causing another expensive allocaiton. In 2), the result variable is alive before and after the function call, so it is much more likely that it will be reallocated in the second and following runs. Maybe this is no accurate analysis, but I'm very sure that we are testing malloc here and not algorithms. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From s323140 at student.uq.edu.au Tue Dec 21 11:22:24 1999 From: s323140 at student.uq.edu.au (Rob Hodges) Date: 22 Dec 1999 02:22:24 +1000 Subject: ugly python namespace bug References: <83nkpe$998$1@news1.tele.dk> Message-ID: "Jesper Hertel" writes: > As a suggestion, maybe Python could be changed to allow for "constant" > definitions or so. Like > > const def type(..): > ...something... > > or > > const a = 2 > > Variables (and functions) declared like this would then have a flag telling > that it is not allowed to change it, and an exception would be raised if > someone tried to do it. > > Built-in functions could then be declared like this. One problem by this is > the backwards compatibility. If someone redefines built-in functions in > existing programs, they would not be able to run these programs in new > versions of Python. And indeed they do all the time, because `str' is a great name for a string, and `dir' is a great name for a directory, and `esr' is a great name for Eric Raymond... uh, I guess he's not a built-in... you get my drift. 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 From fredrik at pythonware.com Tue Dec 14 06:38:11 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 14 Dec 1999 12:38:11 +0100 Subject: I need information about extending and embedding Python References: Message-ID: <036e01bf4627$b4af9d20$f29b12c2@secret.pythonware.com> Cesar Lopez wrote: > I need to make a library for python to update some external devices in > an embeded system with a little Hitachi microcontroller, so I need > information about How to do that, I must to define a method to define > librarys to control devices like, RS-232 port, Leds, Keyboards, > Speakers. > > Now I?ve defined a litle program in C++, its control a green Led > (on/off) and now I want to do that with the python interpreter, so I > need your help. here's an example (in plain old C): --- #include "Python.h" static PyObject * device_set(PyObject* self, PyObject* args) { int status; int value; if (!PyArg_ParseTuple(args, "i", &value)) return NULL; /* do something! */ status = whatever(value); return Py_BuildValue("i", status); } static PyMethodDef _functions[] = { {"set", device_set, 1}, {NULL, NULL} }; void #ifdef WIN32 __declspec(dllexport) #endif initdevice() { Py_InitModule("device", _functions); } --- import device device.set(1) # switch it on! --- for more info, see: "Extending and Embedding the Python Interpreter" http://www.python.org/doc/current/ext/ext.html "Python/C API Reference Manual" http://www.python.org/doc/current/api/api.html and all the existing modules in the standard library... From wzab at ise.pw.edu.pl Thu Dec 9 10:48:18 1999 From: wzab at ise.pw.edu.pl (Wojciech Zabolotny) Date: Thu, 9 Dec 1999 16:48:18 +0100 Subject: How to add element to the list in C extension module? In-Reply-To: References: Message-ID: On Thu, 9 Dec 1999, Wojciech Zabolotny wrote: > Anyway, what API function should I use to add a new element to the list > or tuple? I tried to use the PySequence_Concat (like below:) > ob = Py_BuildValue("[]"); > tmp = Py_BuildValue("{s:i,s:i}","as",3,"bc",5); > ob = PySequence_Concat(ob,tmp); > ... > > But I get the following error: > TypeError: illegal argument type for built-in operation Sorry for replaying my own post, but I've just found the solution. PyList_Append did the trick for lists. For tuples it seems to be necessary to use _PyTuple_Resize and PyTuple_SetItem, which is probably much less efficient :-(. Sorry for unnecessary mess. -- Wojciech M. Zabolotny http://www.ise.pw.edu.pl/~wzab <--> wzab at ise.pw.edu.pl http://www.debian.org Use Linux - an OS without "back doors" inside From Dan at Grassi.com Sun Dec 5 15:48:37 1999 From: Dan at Grassi.com (Dan Grassi) Date: Sun, 05 Dec 1999 15:48:37 -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> Message-ID: in article 87u2lxuooi.fsf at freddy.page.street, David N. Welton at davidw at prosa.it wrote on 12/5/99 3:18 PM: >> PHP3 > > Eeewwww. > > Why ever would you saddle yourself with a language that you can only > use on the web? True, but the reason is because it works very well on the web! That os my whole point. python is a great language but is not web-savy. >It's pretty new compared to python, as well. Well, if it is rather new that makes it even more interesting because it is used on over 1,000,000 sites! (http://www.php.net/usage.php3) Perhaps because it is easy to use on the web. I think that's my point! :-) > And - are you really talking about using php for cgi's? Yes, it can do the same things on the web that python can. Database access better than python, easy installation and integration with MySQL and Apache and a mod_php that really provides additional functionality, even allows php access to authentication info. >That kind of sucks compared to compiling it into the web browser... Huh? Dan From noel at burton-krahn.com Tue Dec 7 12:44:30 1999 From: noel at burton-krahn.com (Noel Burton-Krahn) Date: 7 Dec 1999 17:44:30 -0000 Subject: tiny python Message-ID: <19991207174430.7096.qmail@burton-krahn.com> 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. I am working on a tiny embeded Linux system where disk space is very restricted. I've found that compiled binaries are huge compared to their program text. Right now I write most of my system binaries in perl and use a stripped down (200K) perl4 interpreter. That may seem strange, but it saves me a lot of space. A perl4 source is about 10% the size of an equivalent compiled C program. However, I would prefer to use python since perl4 lacks data structures. Thanks --Noel From malcolmt at smart.net.au Mon Dec 27 07:55:13 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Mon, 27 Dec 1999 23:55:13 +1100 Subject: Py2K wishes In-Reply-To: <38675B72.18A139FF@prescod.net>; from Paul Prescod on Mon, Dec 27, 1999 at 07:28:34AM -0500 References: <38675B72.18A139FF@prescod.net> Message-ID: <19991227235513.A917@Ridcully.home> On Mon, Dec 27, 1999 at 07:28:34AM -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" > > "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!). Any changes of either of these pieces of syntax at this point would break almost any script in existence. The only way to accomodate them would be to introduce redundant keywords, which would be ... well ... just evil (or perl -- I always get those two muddled up). :-) To console yourself, just think, it could have been worse: Guido may have chosen Dutch keywords. :-) Cheers, Malcolm Tredinnick -- He who laughs last thinks slowest From balaji.yogesh at wipro.com Thu Dec 23 00:30:08 1999 From: balaji.yogesh at wipro.com (BALAJI YOGESH K.V.) Date: Thu, 23 Dec 1999 11:00:08 +0530 Subject: Anyone else making music with python? References: <386115AB.A0DD3F6@angelfire.com> Message-ID: <3861B360.5F891CF7@wipsys.soft.net> 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. regards, balaji 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... > > 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. > > -- > ................ 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 > -- > http://www.python.org/mailman/listinfo/python-list -- __________________________ __ /|___ Two | | | | / | wrongs | Balaji Yogesh K.V. | _| |_ \ ___| won't | balaji.yogesh at wipro.com | \ / \| make a | Wipro Technologies,India.| \ / ___|\ right. | +91 80 5539134. ext:148 | \/ | \ /-------------------------/ | |___ / \ 3 lefts will. \ _/ |/ `-------------------------- From reic0024 at ub.d.umn.edu Wed Dec 1 18:42:23 1999 From: reic0024 at ub.d.umn.edu (Aaron J Reichow) Date: Wed, 1 Dec 1999 17:42:23 -0600 Subject: Passing information to other processes/objects? Message-ID: I'm writing a little script to control some christmas lights using X10, with a CGI interface. The script would be calling bottlerocket with various parameters, using looping, to create, say, a fade in and out effect. What I need is the CGI script to pass the parameters to the program which control bottlerocket. How could I go about doing this? I thought about implementing a simple server which would listen on some port for the commands, but that seems like too much work. Or, the CGI script would kill the previous control script and run a new one with new parameters, but that seems like it'd be quite awkward and maybe a bit slow. Anyone have any ideas? Any way to pass variables to an already running process? Aaron From a.eyre at optichrome.com Fri Dec 17 11:04:54 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 17 Dec 1999 16:04:54 -0000 Subject: LISTS: Extract every other element - SUMMARY In-Reply-To: <19991217091256.A168025@vislab.epa.gov> Message-ID: <004801bf48a8$74d7ab60$3acbd9c2@peridot.optichrome.com> > I coded each of these up, working with the same list of 100,000 > integers. Here are the results. > > [snip] Did you try them all with the -O option? -------------------------------------------- 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 mhammond at skippinet.com.au Tue Dec 7 22:51:35 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 08 Dec 1999 03:51:35 GMT Subject: Python and ASP References: <_ji34.8719$523.343739@news.chello.at> Message-ID: Yes - the latest versions of IIS retain all whitespace in a script block (ie, it was an IIS bug, not a Python bug) Mark. Alexander Jerusalem wrote in message <_ji34.8719$523.343739 at news.chello.at>... >There was a problem some time ago with Python in ASP scripts. I believe it >had to do with indentation somehow. Does anybody know if this issue has been >completely solved meanwhile. > >Thanks, > > From fredrik at pythonware.com Tue Dec 28 04:36:32 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 28 Dec 1999 10:36:32 +0100 Subject: need help getting tk to work with python References: <3867FF5C.F56F4341@earthlink.net> Message-ID: <015e01bf5117$0788d990$f29b12c2@secret.pythonware.com> Gary Bankston wrote: > 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. here's some possible solutions: http://www.pythonware.com/people/fredrik/fyi/fyi02.htm hope this helps! From robin at alldunn.com Thu Dec 2 19:18:55 1999 From: robin at alldunn.com (Robin Dunn) Date: Thu, 2 Dec 1999 16:18:55 -0800 Subject: Using wxPython in COM server References: <3844dc35.143149908@news.mch.sni.de> Message-ID: Mark Hammond wrote in message news:zW914.12685$VA6.61396 at news-server.bigpond.net.au... > Nikolai Kirsebom wrote in message <3844dc35.143149908 at news.mch.sni.de>... > > > >I manage to get the dialog presented, but at the same time I get an > >application error in winword.exe (The instruction at "0x...." > >referenced memory at "0x0000000". The memory could not be "read".) > > > >When I select OK in the application error message box, my dialog is > >completely painted (static text and buttons), and I get e new message > >box from the runtime library of Microsoft Visual C++ (Runtime error! > >Program: C:\Program.....\Winword.exe abnormal program termination). > > Almost certainly a thread-state issue. wxPython probably doesnt release and > acquire the Python thread-lock as it crosses the boundary from Python to C > and back. This is almost always the end result of that support missing. Im > afraid I can personally offer no additional advice - you need to speak to > the wxPython guys and get thread support :-) > wxPython does handle the thread state properly (one final bug in that area was squashed in the last release,) but the problem in this case is that there is no wxApp object created. It is during the initialization of the wxApp object that wxPython initializes itself for proper thread state handling, among other things. At a minimum, you might try something like this: def RequestYesNo(self): from wxPython.wx import * class MyApp(wxApp): def OnInit(self): return true app = MyApp(0) win = wxDialog(NULL, -1, "HELLO", wxDefaultPosition, wxSize(350,200)) wxStaticText(win, -1, "This is a wxDialog", wxPoint(20, 20)) wxButton(win, wxID_OK, " OK ", wxPoint(75, 120),wxDefaultSize).SetDefault() wxButton(win, wxID_CANCEL, " Cancel ", wxPoint(200, 120),wxDefaultSize) val = win.ShowModal() win.Destroy() return val Although I am not sure what you might lose by not getting into the app.MainLoop... -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From aahz at netcom.com Mon Dec 27 11:18:06 1999 From: aahz at netcom.com (Aahz Maruch) Date: 27 Dec 1999 16:18:06 GMT Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> Message-ID: <8483fu$ook$1@nntp5.atl.mindspring.net> In article <386745A6.9B671DBF at prescod.net>, Paul Prescod wrote: > >I propose that in Python 1.6 tuples be given the demonstrated features: > >>>> time = (hour=24, minute=00, second=00 ) I think you're more likely to get somewhere with the "locking dict" idea that others have mentioned, essentially the immutable equivalent of a dict. Thus the syntax would be time = ( 'hour':24, 'minute':0, 'second':0 ) print time['minute'] time['foo'] = 'bar' ...and you get an exception -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Eighth Virtual Anniversary -- 4 days and counting! From jsight at mindspring.com Fri Dec 3 01:15:37 1999 From: jsight at mindspring.com (Jesse D. Sightler) Date: Fri, 03 Dec 1999 01:15:37 -0500 Subject: split this newsgroup? References: <38473B4E.9050DF4D@callware.com> Message-ID: <38476009.249D33ED@mindspring.com> Aaron J Reichow wrote: > > I second that no. IMO, it's not that much, and I can usually handle to > read it once a day. I third that no. Because-we'd-need-atleast-500-no-votes-to-even-consider-it-ly yours, Jess http://www.carbuyin.com/ From Alex.Martelli at think3.com Wed Dec 22 04:15:06 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Wed, 22 Dec 1999 10:15:06 +0100 Subject: how does one get aboard the Starship...? Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D71@pces.cadlab.it> 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, Alex From boud at rempt.xs4all.nl Sun Dec 12 15:56:19 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 12 Dec 1999 20:56:19 GMT Subject: Suitability of Python for a Big Application? References: <830vic$r2t$1@nnrp1.deja.com> Message-ID: <83125j$5d$1@news1.xs4all.nl> bobyu5 at mailcity.com wrote: > 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. If you really need to use a variety of databases, then you probably can't rely on stored procedures/packages to do the server-side work, because there isn't a database where those work in the same way. And even so, support for, say Oracle packages, is skimpy outside Oracles own tools. I'm going to install Oracle next week to try whether they can be accessed from Python, though. You really need some middle man, if you go the various databases route, and designing decent middleware is difficult, in my experience. > 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. Now that's recognizable... You aren't talking about the project I've been working on myself for the past year, are you ;-). <...> > 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. I don't think TK is really suitable - but if your application interface is simple enough a web interface should suffice - and those can be as slick as the graphics designer you hire can make it. Take a look at WxPython or PyQt (that also seems to run under Windows). > 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? Are you getting the data from the database? Then you want the processing on the same machine as the data - even so, getting that many rows out of a database will take a bit of time. A bit of experimentation with numpy should allow you to determine whether the concept is going to work. > 3) Heavy duty text processing using regexp (at least 40MB big)- I know > Perl is really fast in this regard; is Python as fast? I wouldn't know about this one. > 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. <...> > 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? I haven't ever seen Outlook, but a basic tree-to-the-left, data-on-the-right interface isn't too difficult to make. If you are prepared to get rid of the web interface, you could use WxPython, I suppose, though that doesn't impress me as being ready for the enterprise ;-). Also, remember that there are very few database-ready widgets - you will have to write the basics yourself. 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, and trusting a new tool to work miracles is a recipe for disaster. I'm quite convinced that even VB can produce good applications, in time, in budget ;-). I'd say, write a small proof-of-concept app - with three or four tables, a hundred meg of generated data and a crude interface, and determine whether the tool will allow you to do what you want. > 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? I've never seen C++ or Java used for large-scale database applications. Most projects I've seen use Oracle Forms, Visual Basic or Powerbuilder or things like that. But then, what's large? A large number of tables and screens, a large amount of data, or both? And then, what's the domain of the app? Transaction oriented, data warehousing, information serving? > Any anecdotes or recommendations would be heartily appreciated! I'm trying to build a small-to-mid-range multi-user database application using Python and PyKDE/PyQt as a gui. I figure people who want to use my application can afford buying another PC to serve out X11 applications to their legacy desktop systems (Windows and Mac). Besides, I want a read-only browser interface. The architecture I'm working on includes a database server, which I connect to using a DB-API II compliant interface, a SQL translation layer, an application object layer, an application server that dishes out XML-formatted data to the client gui or to the client special purpose http server, that serves the various browser clients. It's a hobby project, though. My bosses don't want another programming tool in the shop, after the debacle with VB 5.0. -- Boudewijn Rempt | http://denden.conlang.org From fredrik at pythonware.com Thu Dec 9 11:38:08 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 9 Dec 1999 17:38:08 +0100 Subject: Packaging packages? References: Message-ID: <035d01bf4263$c7272490$f29b12c2@secret.pythonware.com> 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? obviously :-) (we've fixed it in pythonworks too, of course) 1) http://www.lyra.org/greg/python/imputil.py From malraux at my-deja.com Tue Dec 28 12:02:07 1999 From: malraux at my-deja.com (Scott Anderson) Date: Tue, 28 Dec 1999 09:02:07 -0800 Subject: Question about map() and class methods Message-ID: Spam detection software, running on the system "albatross.python.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: My example was actually not representative of the problem. Here's the crux: if you have a list of class instances, and wish to call a method that *may* be overridden by a subclass, you have to use a lambda with map() (losing the speed gains of using map(), obviously): [...] Content analysis details: (6.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 4.2 MSGID_SPAM_CAPS Spam tool Message-Id: (caps variant) 2.0 FH_DATE_IS_19XX The date is not 19xx. -------------- next part -------------- An embedded message was scrubbed... From: "Scott Anderson" Subject: Re: Question about map() and class methods Date: Tue, 28 Dec 1999 09:02:07 -0800 Size: 3679 URL: From tim_one at email.msn.com Tue Dec 7 22:23:53 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 7 Dec 1999 22:23:53 -0500 Subject: A Date With Tim Peters... In-Reply-To: Message-ID: <000001bf412b$a7a87ee0$5aa2143f@tim> [Tim] >>> import math >>> zero = 0.0 >>> math.atan2(zero, zero) 0.0 >>> zero = -zero >>> math.atan2(zero, zero) -3.14159265359 > > That is, IEEE-754 mandates signed zeroes too, in part so that an > underflow "remembers which direction it came from". [Rob W. W. Hooft] >>> 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..... Of course not -- nothing having to do with floating point is portable, and won't be until C mandates something non-trivial about it. Even then, there are a dozen old & incompatible "add on" libm stds to contend with. It's in the spirit of the 754 std to return the results I showed; the domain error you got is historical baggage. > IIRC, on a VAX Using -0.0 would result in an "operand reserved to > digital" fault. You mean WinTel is the only platform that does this right ? if-the-pentium-didn't-do-this-all-by-itself-ms-would-get-it- wrong-too-ly y'rs - tim From mlh at vier.idi.ntnu.no Sun Dec 12 19:39:12 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 13 Dec 1999 01:39:12 +0100 Subject: List comprehension... Message-ID: Is list comprehension on its way into the language? Or is that just a rumour, based on Greg's patch? And - as allways, I can't leave the syntax alone without a suggestion of my own... Greg's patch works like this (among other things): [(i, s) for i in nums for s in strs] To me, this sounds a bit like [(i, s) for i in [nums for s in strs]] which I guess doesn't give much meaning. I think the syntax would be clearer (and more natural language-like) with an "and" instead of the "for"s, after the first one. The first ones marks that this is the list of (i, s) for all of the "i"s and all of the "s"s given. Thus: [(i, s) for i in nums and s in strs] -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From Marc_Battyani at csi.com Thu Dec 16 15:01:47 1999 From: Marc_Battyani at csi.com (Marc Battyani) Date: Thu, 16 Dec 1999 21:01:47 +0100 Subject: Declaring COM-interfaces in Python? References: <38562ebd.0@pandora.research.kpn.com> <3856bffe.121727274@judy> Message-ID: Reini Urban wrote in message news:3856bffe.121727274 at judy... > 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. Hi Reini, What Lisp are you using ? Don't forget to tell us about this in comp.lang.lisp when it works... Marc Battyani > Reini Urban > http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html From nyamatongwe at my-deja.com Thu Dec 30 22:54:12 1999 From: nyamatongwe at my-deja.com (nyamatongwe at my-deja.com) Date: Fri, 31 Dec 1999 03:54:12 GMT Subject: Pythonwin: any plans for COM+? References: <3863c163.8797109@judy> <84121d$um7$1@nnrp1.deja.com> <14443.36914.972940.98406@weyr.cnri.reston.va.us> Message-ID: <84h8mq$lcp$1@nnrp1.deja.com> > Neil, > Is Platt's "Understanding COM+" considered reasonable by "the > knowledgable"? It's not very technical, but I just wanted a high- > level overview. I can't claim to really still be one of "the knowledgable" as I dropped out of serious COM work 6 months ago. I haven't read this book. COM+ was still changing as recently as September when the In Memory DataBase and Component Load Balancing were dropped from the initial release so the book which was released in July is already out of date. Or before its time if these features do eventually turn up. A quick look around shows not too much positive or negative comment about it so it is probably OK. The DCOM mailing list is a good place to search for topics like this http://discuss.microsoft.com/archives/dcom.html Neil Hodgson Sent via Deja.com http://www.deja.com/ Before you buy. From tom.mcdavid at boeing.com Thu Dec 16 16:03:56 1999 From: tom.mcdavid at boeing.com (Tom McDavid) Date: Thu, 16 Dec 1999 21:03:56 GMT Subject: [Announce] Python Builder Developer Release 0.1 Message-ID: <385953BC.DB4E8559@yahoo.com> Spam detection software, running on the system "albatross.python.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This may be somewhat tangential, but have you looked at the visual tcl gui builder? (the free one from neuron.com) I found it to be quite powerful for building tk interfaces. It has a lot of features I would like to see in a python environment. [...] Content analysis details: (5.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.0 FH_DATE_IS_19XX The date is not 19xx. -0.0 NO_RELAYS Informational: message was not relayed via SMTP 3.2 FORGED_MSGID_YAHOO Message-ID is forged, (yahoo.com) -0.0 NO_RECEIVED Informational: message has no Received headers -------------- next part -------------- An embedded message was scrubbed... From: Tom McDavid Subject: Re: [Announce] Python Builder Developer Release 0.1 Date: Thu, 16 Dec 1999 21:03:56 GMT Size: 2212 URL: From bbosware at vic.bigpond.net.au Mon Dec 6 18:25:25 1999 From: bbosware at vic.bigpond.net.au (John Leach) Date: Mon, 06 Dec 1999 23:25:25 GMT Subject: simple question References: <384C106A.5BA89AF4@gmx.net> Message-ID: It could be just that you want to do import os os.system(cmd) eg os.system('ls') or os.fork(cmd) I asked question here on ssh a couple of weeks back and received a lot of interesting suggestions - you may like to go to Deja News and have a look at the thread. One suggestion was to use popen and I enclose the manual pages for that (I have not attempted this yet):- >From the Python Library Reference 8.14 popen2 -- Subprocesses with accessible standard I/O streams Availability: Unix, Windows. This module allows you to spawn processes and connect their input/output/error pipes and obtain their return codes. The primary interface offered by this module is a pair of factory functions: popen2 (cmd[, bufsize]) Executes cmd as a sub-process. If bufsize is specified, it specifies the buffer size for the I/O pipes. Returns (child_stdout, child_stdin). popen3 (cmd[, bufsize]) Executes cmd as a sub-process. If bufsize is specified, it specifies the buffer size for the I/O pipes. Returns (child_stdout, child_stdin, child_stderr). The class defining the objects returned by the factory functions is also available: Popen3 (cmd[, capturestderr[, bufsize]]) This class represents a child process. Normally, Popen3 instances are created using the factory functions described above. If not using one off the helper functions to create Popen3 objects, the parameter cmd is the shell command to execute in a sub-process. The capturestderr flag, if true, specifies that the object should capture standard error output of the child process. The default is false. If the bufsize parameter is specified, it specifies the size of the I/O buffers to/from the child process. ---------------------------------------------------------------------------- ---- Python Library Reference ---------------------------------------------------------------------------- ---- 8.14.1 Popen3 Objects Instances of the Popen3 class have the following methods: poll () Returns -1 if child process hasn't completed yet, or its return code otherwise. wait () Waits for and returns the return code of the child process. The following attributes of Popen3 objects are also available: fromchild A file object that provides output from the child process. tochild A file object that provides input to the child process. childerr Where the standard error from the child process goes is capturestderr was true for the constructor, or None. ---------------------------------------------------------------------------- ---- Python Library Reference ---------------------------------------------------------------------------- ---- Markus Weimer wrote in message <384C106A.5BA89AF4 at gmx.net>... >Hi! > >I'm starting to learn python and would like to write a small gtk-based >wrapper for ssh. I've got a simple gui and now I want the gui to start >ssh. I build a string for the commandline. So, how do I parse this to >the os? Iwould look at www.python.org, but it's down. So please help me. > >Thanks in advance > > >Markus Weimer > >-- >Markus Weimer >markus.weimer at gmx.net >www.av.wh.tu-darmstadt.de/homes/markus > > > From fdrake at acm.org Thu Dec 23 14:17:59 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 23 Dec 1999 14:17:59 -0500 (EST) Subject: __init__ keyword param for sub-class? In-Reply-To: References: Message-ID: <14434.30055.405044.204758@weyr.cnri.reston.va.us> Grant Edwards writes: > 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 Grant, That's what I've always done. There is at least one proposal to extend the call syntax to make the apply() unnecessary, but it's not in the core (though I seem to recall a patch to actually implement it). I think your example would become: ------------------------------------------------------------------------ class execWindow(Pmw.ScrolledText): def __init__(self, *posArgs, **keyArgs): if keyArgs.has_key('myoption'): self.__myoption = keyArgs['myoption'] del keyArgs['myoption'] return Pmw.ScrolledText.__init__(self, *posArgs, **keyArgs) ------------------------------------------------------------------------ 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 don't expect anyone would actually want to overload ':' like that, and I don't really care what character is used, but this functionality would be *very* nice to have; I've had to do the dictionary whacking just often enough that I think it's really a fragile way to do it. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From aa126 at NO-SPAM.fan.nb.ca Fri Dec 10 15:57:33 1999 From: aa126 at NO-SPAM.fan.nb.ca (William Burrow) Date: 10 Dec 1999 20:57:33 GMT 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: 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? -- William Burrow -- New Brunswick, Canada A 'box' is something that accomplishes a task -- you feed in input and out comes the output, just as God and Larry Wall intended. -- brian moore From lefebvre at medz.mcgill.ca Wed Dec 15 09:03:30 1999 From: lefebvre at medz.mcgill.ca (Luc Lefebvre) Date: Wed, 15 Dec 1999 14:03:30 GMT Subject: Timing in MacPython? References: Message-ID: In article , ventrego at yahoo.com wrote: > 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 If TKinter is like Tk you would use "update" inside your loop. -- *** Luc Lefebvre NOTE: if your reply via email please remove the z from my return address *** From thantos at chancel.org Wed Dec 22 23:41:37 1999 From: thantos at chancel.org (Alexander Williams) Date: Thu, 23 Dec 1999 04:41:37 GMT Subject: How to read lines from end of a file? References: <4rhfhazoj4.fsf@colargol.tihlde.hist.no> Message-ID: On Wed, 22 Dec 1999 21:02:04 -0500, Darrell wrote: >Maybe maxLen should be sys.maxint by default. Then paranoid or performance >concerned, can tone it down from there. Crunchy, and interesting if you have 4gb log files, but since most folks trim their logs more often than I, it shouldn't be much of an issue. :) -- 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 bernhard at alpha1.csd.uwm.edu Mon Dec 20 16:47:30 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 20 Dec 1999 21:47:30 GMT Subject: Is there an easy way to do it again? References: <83jvjd$k0r$1@news05.btx.dtag.de> Message-ID: Eide: It depends on your program of course. There is no universal answer for this question. Creating a function is always a good idea, if the task can be seperated enough. If you are running a resonalble shell, people will just call a little python script several times from the shell. Bernhard On Mon, 20 Dec 1999 02:09:15 +0100, 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? -- 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 b2blink at hotmail.com Fri Dec 17 08:56:37 1999 From: b2blink at hotmail.com (Ulf Engstrøm) Date: Fri, 17 Dec 1999 08:56:37 CET Subject: The gifthingy Message-ID: <19991217075637.56400.qmail@hotmail.com> Skip, Thanx for your reply, it helped me eventhough I've used the same code. I was really laughing at myself this morning. I read your mail and it was exxactly the same, I just couldn't get it. When I compared it to my code I realize what I've done, my function would show the code before the encoding with img.readlines() thus putting the pointer to the end of the file, and I didn't put it back to the beginning again, so it didn't read anything. That kind of things is so annoying when you can't see it. Anyway, finally all is working at least :) Thank you all for all your pythonposts, very helpful:) Regards Ulf ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From kaleissin at nvg.org Mon Dec 20 16:17:27 1999 From: kaleissin at nvg.org (Kaleissin) Date: 20 Dec 1999 21:17:27 GMT Subject: Lists of lists traversal References: <83m3fn$sb6$1@cronkite.cc.uga.edu> Message-ID: In article <83m3fn$sb6$1 at cronkite.cc.uga.edu>, Benjamin Dixon wrote: >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. If I understand you correctly... you want to 'compress' the inner lists and replace them with their sums? If that is the case... Summing a list: result = reduce(lambda x, y: x+y, list_to_sum) What I would do in your case: listpos = 0 while listpos < len(list_of_lists): list_of_lists[listpos] = reduce(lambda x, y: x+y, list_of_lists[listpos]) listpos = listpos + 1 This destroys the original lists btw. To keep them, append the resulting sum to some other list instead of replacing the list with it as above. You could use a for instead of the while too, in that case. It might not be very effective but it looks nice... list comprehension version, anyone? kal. -- Teflon Brain 2000(tm) - Excuse of the Future! From jam at quark.emich.edu Thu Dec 16 07:05:56 1999 From: jam at quark.emich.edu (Jeff) Date: Thu, 16 Dec 1999 07:05:56 -0500 Subject: updates to 'asyncore' and 'asynchat' Message-ID: <19991216070556.E2015@quark.emich.edu> greetings, I recently upgraded one of my machines to RH 6.1, and discovered that the version of (at least) asyncore.py shipped is (quite) out of date. specifically, the 'log_info' method does not exist, but there are several other changes as well. at the least these changes are utilized by the 1999-09-02 distribution of medusa, which is why I noticed. I'm not certain if this is an issue with the python distribution as shipped by redhat, or if something may need to be updated in the main python core itself. does anyone have suggestions regarding how to get this issue resolved properly? I've solved it locally by simply copying the 'asyncore.py' module from medusa, but this may not be obvious to new medusa and/or python users. regards, J -- || visit gfd || psa member -- || New Image Systems & Services, Inc. From krnylund at my-deja.com Tue Dec 21 08:55:11 1999 From: krnylund at my-deja.com (krnylund at my-deja.com) Date: Tue, 21 Dec 1999 13:55:11 GMT Subject: DCOracle problems Message-ID: <83o0ru$o4a$1@nnrp1.deja.com> Hello I'm having some trouble with the DCOracle extension to Python. When trying to connect I get: >>> import DCOracle >>> dbc=DCOracle.Connect("myusername/mypass at sid") Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/DCOracle/ocidb.py", line 76, in __init__ sc=oci_8.Logon(u,p,s) OracleError: ('ORA-12571: TNS:packet writer failure\012', 12571) >>> Connecting with sqlplus works perfectly. The client is a RedHat 6.0 box with the Oracle client v. 8.0.5 and the database is on a HP-UX 10.20 with Oracle Server v. 7.1.6.2 Any help would be greatly appreciated. Thanks, Kristian Sent via Deja.com http://www.deja.com/ Before you buy. From lugh at interaccess.com Sat Dec 4 18:09:36 1999 From: lugh at interaccess.com (Clyde Davidson) Date: Sat, 04 Dec 1999 17:09:36 -0600 Subject: Tkinter 1.5.2 ?? Message-ID: <38499F30.54313C44@interaccess.com> I am starting to get into Python. So, I bought "Learning Python" and updated the Python that came with my Red Hat 6.0. I found 1.5.2 in RPM. However the Python-Tkinter wouldn't install because it conflicted with my regular Tkinter-1.5.1, or so my RPM package told me. I have tried to find version 1.5.2 of the regular Tkinter, but haven't had any luck. Where can I find Tkinter 1.5.2 for Linux? I would prefer an RPM. Thanks, Clyde From amber at exelixis.com Wed Dec 15 17:43:33 1999 From: amber at exelixis.com (Amber Shao) Date: Wed, 15 Dec 1999 14:43:33 -0800 Subject: Perl to Python Message-ID: <38581995.91AC5AA8@exelixis.com> Hi, Does anyone know if there is a way to call Python module from a Perl script? thanks amber From skaller at maxtal.com.au Fri Dec 3 15:57:29 1999 From: skaller at maxtal.com.au (skaller) Date: Sat, 04 Dec 1999 07:57:29 +1100 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> <38466D02.BAC4A1F6@compaq.com> <14406.62038.707967.348914@dolphin.mojam.com> <14407.64245.424116.159879@goon.cnri.reston.va.us> Message-ID: <38482EB9.76AA5046@maxtal.com.au> Jeremy Hylton wrote: > 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. This suggestion makes sense at one level: what you describe seems close to 'signature matching', which is the basis of structure typing in some languages. One problem I have with this, is that the optimisations that I perceive don't come from such high level dynamic safety checks on user defined classes, but on knowing that something is an 'int' so I can generate code that doesn't do any dynamic lookup of an __add__ method, but just generates the equiavelant of, say x = y + 42; in C. So it is actually the basic types like int, float, string, list, tuple, that need typing most, from an optimisation perspective: at best, requiring an object have an '__len__' method would allow it to be cached (lookedup once), but it still has to be called .. by interpreting some python code. This is so expensive anyhow, that the caching is probably irrelevant. But maybe not -- if the method itself is compiled. Hmmm. -- 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 hgg9140 at skewer.ca.boeing.com Wed Dec 8 10:01:32 1999 From: hgg9140 at skewer.ca.boeing.com (Harry G. George) Date: Wed, 8 Dec 1999 15:01:32 GMT Subject: exchanging data btwn Python and lesser languages References: <82jau6$e72$1@nnrp1.deja.com> <1267538634-27138233@hypernet.com> <14413.33938.300484.712295@dolphin.mojam.com> Message-ID: What's the relationship between XML-RPC and Microsoft's SOAP? Skip Montanaro writes: > > >> I'm looking for a quick-n-dirty way to exchange data between > >> Python and other languages, especially P*rl. > > Gordon> Skip Montanaro did something along these lines. > > As I mentioned to Preston in private email, I stopped working on/looking for > a solution once I discovered XML-RPC. Works fine for our needs. Relevant > URLs include > > http://www.xmlrpc.com/ (XML-RPC home page) > http://www.pythonware.com/products/xmlrpc/index.htm (xmlrpclib) > http://www.pythonware.com/madscientist/ (sgmlop - C-based SGML/XML parser) > > Skip Montanaro | http://www.mojam.com/ > skip at mojam.com | http://www.musi-cal.com/ > 847-971-7098 | Python: Programming the way Guido indented... > -- --- IMPORT StandardDisclaimer; Harry George harry.g.george at boeing.com Renton: (425) 237-6915 Everett: (425) 266-3149 Page: (425) 631-8803 From skaller at maxtal.com.au Fri Dec 3 16:21:01 1999 From: skaller at maxtal.com.au (skaller) Date: Sat, 04 Dec 1999 08:21:01 +1100 Subject: Method objects question References: <000801bf388a$4b2c4ce0$742d153f@tim> Message-ID: <3848343D.31A42D17@maxtal.com.au> Tim Peters wrote: > > [Ben Caradoc-Davies] > > ... > > But the point is, why should functions found in a class namespace be > > converted into methods, but functions found in an instance namespace > > not converted? > > Both behaviors are useful, depending on the application. Guido picked the > behaviors for each mechanism that he judged would be most useful most often. Twaddle. It is a hack, plain and simple. > > In a nutshell, I don't see any fundamental reason why the search- > > instance-namespace then search-class-namespace attribute resolution > > order couldn't be used to allow method overriding on an > > instance-by-instance basis. > > There is no "fundamental" reason. Yes, there is: if every callable object (or, just functions) were bound, then no callable objects (or, just functions) could be instance attributes, since they'd be bound when you didn't want them to be. This is already true for classes, and it is a pain. The correct solution, IMHO, is to have two dictionaries, or perhaps a flag, to distinguish attributes and methods. Another is to redesign the language, so x.y() causes binding, but x.y does not. Another solution is a separate operator, say: x -> y # binding done x . y # no binding Viper uses the same mechanism as Python here, unfortunately: if an attribute is callable, it is automatically bound to an object when fetched. My implementation of classes actually has two dictionaries, one for methods, and one for non-methods -- but I don't use the method dictionary, because I couldn't figure out how to retain python compatibility if I did. -- 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 bwarsaw at cnri.reston.va.us Wed Dec 8 00:07:20 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Wed, 8 Dec 1999 00:07:20 -0500 (EST) Subject: Linux.Com References: <384DC8F1.9A1F135F@easystreet.com> Message-ID: <14413.59272.858902.938397@anthem.cnri.reston.va.us> >>>>> "AC" == Al Christians writes: AC> Python is running a healthy 4th in the Linux.Com scripting AC> languages poll. Looks like your message has rallied the troops! It's now running a distant second behind the 4-letter word of scripting languages :) Perl 42.65% (633) Python 16.31% (242) PHP 15.84% (235) Hmm... anybody think we need more `P' languages? -Barry From mitch.chapman at mciworld.com Sun Dec 5 15:08:58 1999 From: mitch.chapman at mciworld.com (Mitch Chapman) Date: Sun, 05 Dec 1999 20:08:58 GMT Subject: Very useful message -- Hah! References: <82do53$2rhr$1@hub.org><384A9BE0.B345509@inka.de> Message-ID: <384AC725.5AC1AA27@mciworld.com> Dan Grassi wrote: > > in article 384A9BE0.B345509 at inka.de, Michael Str?der at > michael.stroeder at inka.de wrote on 12/5/99 12:07 PM: > > > This message is produces by the web server, not Python. > > Because python did not respond with an error message. Actually, it did. Given the Python script from your earlier post, Python should have output the following to stderr: File "", line 10 print "ax" ^ SyntaxError: invalid syntax The web server should have written all of this to its error log. You're right, this is inconvenient for testing, because it makes you check elsewhere to find out what went wrong. This can be especially frustrating if the web server caches its error log output -- like, for instance, the web server that comes w. Solaris 2.6. > >> I wrap all my CGIs in try/except clauses so that > >> I can see the syntax error in the browser > > For debuging purposes I do not see a problem with a message that states > there was a syntax error on line x. Or at a minimum python could return an > error message of the user's choice. Zope provides this behavior. Last time I used Zope it could be configured to return error messages to the browser. But it encoded them as HTML comments, instead of displaying them directly in the page. The user-visible page showed some sort of generic error message, which, IIRC, you could customize. To see the specific traceback, you just needed to "View->Page Source" in Netscape. Maybe you should have a look at Zope: http://www.zope.org. > But, all of this is just making excuses for the failings of python as a cgi > language. It would be more accurate to say that cgilib.py doesn't meet your expectations. I think Zope would be a better fit. -- Mitch Chapman mitch.chapman at mciworld.com From paulb at infercor.no Fri Dec 10 10:43:31 1999 From: paulb at infercor.no (Paul Boddie) Date: Fri, 10 Dec 1999 16:43:31 +0100 Subject: sites offering free webspace & Python scripting...? References: <82j8cc$qju$1@serv1.iunet.it> <82p1ak$fuu$1@nnrp1.deja.com> Message-ID: <38511FA3.D945E11F@infercor.no> alex at magenta.com wrote: > > In article , > irmina at ctv.es wrote: > > > > Which one offers free web space and *free Perl scripting* ? [...] > http://www.virtualave.net > http://www.webhosting.com > http://www.prohosting.com > http://www.webjump.com > > 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. > Maybe if we all now started lobbying them to suggest they > support Python too...:-) Well, CGIPython might be a start. However, ProHosting runs BSD/OS and I don't remember a binary being available for that on the CGIPython site. Perhaps someone running BSD/OS (or BSDI as it's also known, apparently) would consider contributing a CGIPython binary... Paul From gstein at lyra.org Wed Dec 22 15:11:43 1999 From: gstein at lyra.org (Greg Stein) Date: Wed, 22 Dec 1999 12:11:43 -0800 (PST) Subject: Please test new dynamic load behavior Message-ID: 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). For people with CVS access, I'd like to ask that you grab an updated copy and shake out the new code. There have been updates to the "configure" process, so you'll need to run configure again. Make sure that you alter your Modules/Setup to build some shared modules, and then try it out. Here are some of the platforms that I believe need specific testing: - NetBSD, FreeBSD, OpenBSD, ... - AIX - HP/UX - BeOS - NeXT - Mac - OS/2 - Win16 I believe it should work for most people, but we may be looking for the wrong "init" symbol on some platforms. We might even be selecting the wrong import mechanism (or missing it altogether!) on some platforms. If you get a chance to test this, then please drop me a note with your platform and whether it succeeded or failed (and how it failed). Thanx! -g p.s. you can tell if dynamic loading is missing by watching for DYNLOADFILE in the configure process and seeing if it used dynload_stub. alternatively, you can import the "imp" module and see if "load_dynamic" is missing. -- Greg Stein, http://www.lyra.org/ From wtopa at dmcom.net Fri Dec 10 10:03:20 1999 From: wtopa at dmcom.net (Wayne Topa) Date: Fri, 10 Dec 1999 10:03:20 -0500 Subject: Error confusing a newbie Message-ID: <19991210100320.B18389@dmcom.net> 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')' Here is the script --------------------------------------------- #!/usr/bin/env python import string,sys from DateTime import * input = open('/var/log/totalppp', 'r') times=input.readlines() input.close() diff=y=z=0 test=0 while (1): on = DateTimeFrom(times[z]) out = DateTimeFrom(times[z+1]) diff = diff + TimeDeltaFrom(out - on) if test: print 'Time on was %s' % on print 'Time off was %s ' % out this = TimeDeltaFrom(out - on) print ' This connection - %2i:%2i:%2i' %(this.hour, this.minute, this.second) print 'Current total = %s\n' %diff z = z + 2 if z > (len(times)-1): break print '\nCurrent Totals \n%03d Hours %2i Minutes %2i Seconds \n' % (diff.hour, diff.minute, diff.second) --------------------------------------- I must be missing something. Why does the X server error occur in a script that uses the console? Why (What) is looking for /var/spool/mail/DateTime? What is causing the open to fail when run as an excutable script? I am suspect that I must not be doing something required by DateTime, but I can't find and solution in the docs. Any pointers to 'required' reading would be appreciated. TIA Wayne -- Computers can never replace human stupidity. _______________________________________________________ From Alex.Martelli at think3.com Mon Dec 27 03:06:02 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Mon, 27 Dec 1999 09:06:02 +0100 Subject: arrays & pickling Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D80@pces.cadlab.it> Namsagga writes: > What is the most compact way to save an array to a file? > Perhaps the tofile method of an array object? I think you will also need to write the typecode value and array length (I'm not sure how you recover the length given an array object -- does the builtin function len work on them? I am but an egg...). Alex From fdrake at acm.org Thu Dec 16 11:53:06 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 16 Dec 1999 11:53:06 -0500 (EST) Subject: Python complaints In-Reply-To: <385917D3.5E3A6413@callware.com> References: <3858C226.949FC9C6@udel.edu> <3858FEA3.E593F38C@callware.com> <83b45s$lp4$1@nntp1.atl.mindspring.net> <385917D3.5E3A6413@callware.com> Message-ID: <14425.6386.305057.668327@weyr.cnri.reston.va.us> Ivan Van Laningham writes: > I really don't see the problem here. While it might be slightly > convenient to sink cmath into math, it _is_ documented on the math > module page that cmath exists and what it is for. Ah, but way down at the bottom. Nobody ever looks there. I've added material to the top in the next version of the documentation so it's easier for people to learn about. > As to _why_ you should need to know this, I submit that if you're using > complex numbers in your programs, you really ought to know about the > cmath module and when/how you should use it. I think it more like this: If you aren't using complex numbers and get one by accident (by passing a negative number to something that normally only takes non-negative numbers, for example!), then you are probably failing to detect an error in the input data. I suspect this is the more common problem. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From vbman at pcpros.net Thu Dec 30 07:33:18 1999 From: vbman at pcpros.net (Cliff Baeseman) Date: Thu, 30 Dec 1999 06:33:18 -0600 Subject: [ANNOUNCE] Pygasm IDE wxWindows Linux Developer Release Message-ID: <386B510D.3EC3B9DB@pcpros.net> Hi all, I would just like to announce that I have tweaked the Pygasm IDE Developer release code to run under linux and wxGTK. Pygasm is a wxWindows GUI assembler with a delphi look and feel. It sports a Source Editor, Object inspector, WYSIWYG forms designer, documentor. The original author Riaan Boysen is on vacation at the moment, in the mean time I have placed up a little website with a bunch of screen shots and the code at http://www.pcpros.net/~vbman There have also been user reports that it is running well under NT also. Thanx Cliff Baeseman From skaller at maxtal.com.au Sat Dec 25 19:16:41 1999 From: skaller at maxtal.com.au (skaller) Date: Sun, 26 Dec 1999 11:16:41 +1100 Subject: "sins" (aka, acknowledged language problems) References: <837usr$6vg$1@serv1.iunet.it> <000f01bf483a$b2e33140$63a2143f@tim> <19991217151111.A1413@Ridcully.home> Message-ID: <38655E69.498D7454@maxtal.com.au> Malcolm Tredinnick wrote: > Everybody has their pet gripes, but few seem to stop using Python because of > it (Perl's almost built in obfuscation was actually discouraging me from using > it, to give an example of the other side of this coin). I have, at least for many purposes. I'll outline what I think are the key gripes -- and what I'm doing about it. First, I like Python, mainly because it has a simple syntax which can be both written quickly _and_ read afterwards. This is unusual for a programming language. What I don't like are: it lacks the constructions and concepts of modularity required for larger projects, to provide early error diagnosis, and to make its paucity of data structures comprehensible in the context of intended use. It performs well at certain jobs, but is much too slow at others. Extension in C is non-trivial, and building these extensions highly non-portable. There's no decent standard GUI. Finally, trying to convince Guido to fix some of these problems is just too hard. What that means to me is that a larger project like my interscript tool, just grinds to a halt as I lose track of how the parts interrelate, and the client (also me, mainly) loses interest as the performance drops to multi-hour runs, or speed-up extensions fail to build correctly. My solution is not to abandon Python, however, but to fix it. First, to abandon the C base as the implementation language, in favour of something with better structure. I chose ocaml. Secondly, to reimplement Python from that base, so I could control the language myself -- much easier than arguing. This is how Viper arose: it aims to preserve the clean syntax of Python, but add extensions where I think they're needed. It aims to provide compilation, to improve performance where I think it is needed without resorting to C. It aims to provide a superior implementation language, when I want to extend it. And finally, it retains compatibility with both Guido Python, the language, and CPython extensions (although, I had not expected this would be as easy as it turns out to be). So I haven't abandoned Python but embraced it: it is the standard distribution I have abandoned. It just isn't progressing in the directions I want it to go anywhere near as fast as I want. But an actual implementation of something demonstrably better is more likely to encourage change in the standard distribution than any amount of argument. -- 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 hajo.friedrich at t-online.de Thu Dec 30 11:29:08 1999 From: hajo.friedrich at t-online.de (Dominik Friedrich) Date: Thu, 30 Dec 1999 16:29:08 -0000 Subject: MySQLdb problems Message-ID: <84ftnd$fpi$1@news06.btx.dtag.de> i wanted to have a direct interface from python to mysql on WinNT without an odbc driver, so i got the mysqldb package. when i tried to compile it i got 9 warnings and the linker stoped with an internal error but the _mysql.pyd was created. i copied this to the python dlls directory. when i try to import it i get the error message: ImportError: DLL load failed with error code 193 what does it mean? can somebody help me to compile it correctly or give me a compiled version for win32? Dominik Friedrich From wtanksle at hawking.armored.net Wed Dec 8 01:20:56 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 8 Dec 1999 06:20:56 GMT Subject: browser interface? References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> <384D1F58.1459835F@horvath.com> <99120708514400.02363@quadra.teleo.net> <384DE40B.52CB0FAE@horvath.com> Message-ID: On Wed, 08 Dec 1999 04:52:27 +0000, Bob Horvath wrote: >OK, I see your point. I have been looking at Zope and have not been able to get off of >the ground with it, so I thought suggesting it to someone that is still trying to >figure out CGI might be a little ambitious.... Personally, when I started with Zope, not only did I not know any CGI, I didn't even know much HTML. I consider Zope one of the greatest possible ways to learn HTML while building a working webpage. Especially when you have an experienced webmonger providing things like stylesheets. (Sam did the main HTML coding, I did the research to learn Zope, and we each learned from the other's mistakes.) The problem with Zope is that there's so little coherent documentation. You have to be kind of adventurous. Fortunately, Zope favors the brave with unlimited arbitrary undo. Someday someone will write a book on learning HTML using Zope. It will succeed. I have forseen it. -- -William "Billy" Tanksley, in hoc signo hack From milton at isomedia.com Mon Dec 20 14:59:59 1999 From: milton at isomedia.com (Stephen Milton) Date: Mon, 20 Dec 1999 11:59:59 -0800 Subject: pythoncom and MTS References: <4D0A23B3F74DD111ACCD00805F31D8101D8BCB5A@RED-MSG-50> Message-ID: 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? > > > From claird at starbase.neosoft.com Thu Dec 9 10:48:55 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 9 Dec 1999 15:48:55 GMT Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <82o0to$6eq$1@serv1.iunet.it> Message-ID: In article <82o0to$6eq$1 at serv1.iunet.it>, Alex Martelli wrote: . . . >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. . . . How free? Like Geocities? On an individual basis, if you personally just want to put up a few examples that showcase Python, I'm sure one of us would contribute space on one of our business machines. You can join PSA for $50 a year, and have space on Starship (is that the current arrangement? Have I *still* not renewed my membership?!?). If you have a favorite local Users Group or Freenet, point them our way, and perhaps we can help them see how much they want to make Python available on their servers. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From: Gary Pennington Newsgroups: comp.lang.python Subject: Re: Weird threading problem under Solaris Date: Thu, 09 Dec 1999 11:29:42 +0000 Organization: Sun Microsystems Lines: 31 Message-ID: <384F92A6.E6D5282B at uk.sun.com> References: <82mi4u$nda$1 at metro.ucc.usyd.edu.au> NNTP-Posting-Host: sale-isdn-8.uk.sun.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (WinNT; I) X-Accept-Language: en To: Stephen Norris Path: news!uunet!ffx.uu.net!news5-gui.server.ntli.net!ntli.net!btnet-peer!btnet-feed2!btnet!carbon.eu.sun.com!new-usenet.uk.sun.com!not-for-mail Xref: news comp.lang.python:77960 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 Hi, Stephen Norris wrote: > Are there any Solaris experts out there who know what this means? Anyone > got any idea how to stop it? Python is masking signals and the OS can't deliver signals to the appropriate LWP(thread)(s) (man _signotifywait for the full story). 32 is the SIGWAITING signal. So, Python is masking out all signals (for some reason) and the SIGWAITING notifications are being discarded, 0 as the first parameter to lwp_sigredirect means discard the signal. What you really need is a Python expert who can explain to you why signals are being masked for such a long period. I'm no expert, but I would guess that signals are masked to allow the use of unintteruptable library calls within Python. At some point, when Python considers it safe to do so, the masking is removed and signals handled - which allows your accept to work. > > Any hints or vague suggestions would be appreciated, I've been after this > one for about a week now :( > Yours, Gary From: Wojciech Zabolotny Newsgroups: comp.lang.python Subject: Re: How to add element to the list in C extension module? Date: Thu, 9 Dec 1999 16:35:57 +0100 Organization: http://news.icm.edu.pl/ Lines: 23 Message-ID: References: NNTP-Posting-Host: ipebio15.ise.pw.edu.pl Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sunsite.icm.edu.pl 944753765 15157 148.81.29.49 (9 Dec 1999 15:36:05 GMT) X-Complaints-To: abuse at news.icm.edu.pl NNTP-Posting-Date: 9 Dec 1999 15:36:05 GMT To: Darrell In-Reply-To: Path: news!uunet!ffx.uu.net!newsfeed.mathworks.com!newsfeed.tli.de!news-fra.pop.de!news-fra1.dfn.de!news.man.poznan.pl!news.icm.edu.pl!not-for-mail Xref: news comp.lang.python:77979 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 On Thu, 9 Dec 1999, Darrell wrote: > If you can use C++, then make your like easy. > http://starship.python.net/crew/gmcm/scxx.html I'd rather prefere to do it in the pure C, due to the portability reasons. Anyway, what API function should I use to add a new element to the list or tuple? I tried to use the PySequence_Concat (like below:) ob = Py_BuildValue("[]"); tmp = Py_BuildValue("{s:i,s:i}","as",3,"bc",5); ob = PySequence_Concat(ob,tmp); ... But I get the following error: TypeError: illegal argument type for built-in operation -- TIA Wojciech M. Zabolotny http://www.ise.pw.edu.pl/~wzab <--> wzab at ise.pw.edu.pl http://www.freedos.org Free DOS for free people! From andres at corrada.com Sun Dec 5 01:30:34 1999 From: andres at corrada.com (Andres Corrada) Date: Sun, 05 Dec 1999 01:30:34 -0500 Subject: Python mode for Alpha References: Message-ID: <384A068A.FEB83515@corrada.com> Brad Chapman wrote: > > Hello! I was just looking through the python how-tos and came across your > info on editor configuration for python. I was very excited to see mention > of a python mode for Alpha on the Mac, maintained by Tom Fetherston. > However, you don't make mention of a contact/web page I could go to to get > this mode (ie. the installation section is blank). Would you mind sending > me that info, if you have it, so that I could get the mode installed. > Thanks much for any help you can provide! > > Brad > chapmanb at arches.uga.edu I believe this mode is no longer being maintained by Tom Fetherston, although copies of his mode are floating around. A better choice at this time is to try the Alpha mode maintained by Howard Oakley (howard at quercus.demon.co.uk). Try a search on the mac-python list with "Alpha mode" to get links to a copy. Someone (it might be me!) should upload Oakley's version to the Python site. Oakley has mentioned that he sent a copy to Jack Jansen, the maintainer of the Mac port of Python. He also sent a copy to the author of Alpha. Since I don't regularly use a Mac for my work, I have not checked whether either the latest Alpha or MacPython distribution has a copy of the mode. If you do find a copy on either distribution, let me know so that the pointer can be included in the next update of the HowTo. I would also be grateful for installation instructions to improve the Alpha section on the HowTo, if you can spare the time and effort. ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------ From mark at chem.uwa.edu.au Wed Dec 1 02:21:04 1999 From: mark at chem.uwa.edu.au (Mark C Favas) Date: 1 Dec 99 07:21:04 GMT Subject: predicate classes References: <81uo0t$2rr$1@nnrp1.deja.com> Message-ID: neelk at brick.cswv.com (Neel Krishnaswami) writes: >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 Ummm, not for me - with 1.5.2 from CVS I get: >>> s = Bar() >>> isinstance(s, Foo) 0 >>> s.__bases__ (,) >>> s.x Traceback (innermost last): File "", line 1, in ? AttributeError: x >>> s <__main__.Bar instance at 1400e19d0> 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 nhv at cape.com Thu Dec 16 10:31:41 1999 From: nhv at cape.com (Norman Vine) Date: Thu, 16 Dec 1999 10:31:41 -0500 Subject: Python and Cygwin Message-ID: <83b0n3$doj$1@newsie2.cent.net> For those who may not have noticed the latest Cygwin 'snapshot' releases are much more Python friendly :) Now if we had a pthread guru //// in src / Python / thread_pthread.h #ifdef __CYGWIN32__ !!!! need appropriate defines for pthread_cond_XXX #endif Norman Vine From pkoren at hex.zap-this.net Fri Dec 3 21:27:38 1999 From: pkoren at hex.zap-this.net (Pete. Koren) Date: Fri, 03 Dec 1999 20:27:38 -0600 Subject: errrata for Python Essential Reference? Message-ID: <38487C1A.1D81578B@hex.zap-this.net> Does an errata list exist for Beazley's new book? It's a great book, but it has some errors and I'd like to see an errata list. Regards, Peter Koren From greybria at direct.ca Wed Dec 15 23:07:50 1999 From: greybria at direct.ca (Colleen & Brian Smith) Date: Wed, 15 Dec 1999 20:07:50 -0800 Subject: Python Imaging Library - Install Question References: <007a01bf46e2$36d5aeb0$f29b12c2@secret.pythonware.com> Message-ID: Thanks guys. I tweaked the PYTHONPATH to get rid of $ and the quotes to no avail, but the addition of import Tkinter before import Image solved the problem (at least for the first script - the thumbnail example). -- Brian Smith greybria at direct.ca http://mypage.direct.ca/g/greybria From ckrohn at my-deja.com Tue Dec 28 15:15:51 1999 From: ckrohn at my-deja.com (ckrohn at my-deja.com) Date: Tue, 28 Dec 1999 20:15:51 GMT Subject: Problem with open() Message-ID: <84b5b0$ebp$1@nnrp1.deja.com> I'm just starting out with Python and I'm having a strange problem. I'm trying to open a modem device so that I can talk to it, but the following line just seems to hang: modem = open('/dev/ttyS1', 'w+') print "Modem opened!" I never get to the modem opened line. Now I know the modem works because I can use minicom, diald, etc and they work fine. The open function also seems to work fine if I point it to a port that doesn't actually have a modem on it ('/dev/ttyS0' for example). Can anyone tell me what I'm doing wrong? Sent via Deja.com http://www.deja.com/ Before you buy. From bkenniso at postoffice.worldnet.att.net Thu Dec 2 15:00:04 1999 From: bkenniso at postoffice.worldnet.att.net (Brian Kennison) Date: Thu, 02 Dec 1999 15:00:04 -0500 Subject: Compiling with Pthreads Message-ID: <826j58$oeb$1@bgtnsc02.worldnet.att.net> 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. gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -c thread.c -o thread.o In file included from thread.c:150: thread_pthread.h:113: parse error before `pthread_cond_t' thread_pthread.h:113: warning: no semicolon at end of struct or union thread_pthread.h:114: warning: data definition has no type or storage class thread_pthread.h:115: warning: data definition has no type or storage class thread_pthread.h: In function `PyThread_start_new_thread': thread_pthread.h:155: `pthread_t' undeclared (first use this function) thread_pthread.h:155: (Each undeclared identifier is reported only once thread_pthread.h:155: for each function it appears in.) thread_pthread.h:155: parse error before `th' thread_pthread.h:161: `th' undeclared (first use this function) thread_pthread.h:175: `pthread_attr_t' undeclared (first use this function) thread_pthread.h:175: parse error before `)' thread_pthread.h: In function `PyThread_get_thread_ident': thread_pthread.h:193: syntax error before `threadid' thread_pthread.h:197: `threadid' undeclared (first use this function) thread_pthread.h: In function `PyThread_allocate_lock': thread_pthread.h:249: `lock' undeclared (first use this function) thread_pthread.h:250: parse error before `int' thread_pthread.h:256: parse error before `)' thread_pthread.h:261: `status' undeclared (first use this function) thread_pthread.h:262: `pthread_mutexattr_t' undeclared (first use this function) thread_pthread.h:262: parse error before `)' thread_pthread.h:263: `error' undeclared (first use this function) thread_pthread.h:266: `pthread_condattr_t' undeclared (first use this function) thread_pthread.h:266: parse error before `)' thread_pthread.h: In function `PyThread_free_lock': thread_pthread.h:281: `thelock' undeclared (first use this function) thread_pthread.h:281: parse error before `)' thread_pthread.h: In function `PyThread_acquire_lock': thread_pthread.h:298: `thelock' undeclared (first use this function) thread_pthread.h:298: parse error before `)' thread_pthread.h: In function `PyThread_release_lock': thread_pthread.h:334: `thelock' undeclared (first use this function) thread_pthread.h:334: parse error before `)' thread_pthread.h: At top level: thread_pthread.h:357: parse error before `pthread_mutex_t' thread_pthread.h:357: warning: no semicolon at end of struct or union thread_pthread.h:358: warning: data definition has no type or storage class thread_pthread.h:360: parse error before `}' thread_pthread.h: In function `PyThread_allocate_sema': thread_pthread.h:371: sizeof applied to an incomplete type thread_pthread.h:373: dereferencing pointer to incomplete type thread_pthread.h:374: dereferencing pointer to incomplete type thread_pthread.h:375: `pthread_mutexattr_t' undeclared (first use this function) thread_pthread.h:375: parse error before `)' thread_pthread.h:377: dereferencing pointer to incomplete type thread_pthread.h:378: `pthread_condattr_t' undeclared (first use this function) thread_pthread.h:378: parse error before `)' thread_pthread.h: In function `PyThread_free_sema': thread_pthread.h:395: dereferencing pointer to incomplete type thread_pthread.h:397: dereferencing pointer to incomplete type thread_pthread.h: In function `PyThread_down_sema': thread_pthread.h:408: dereferencing pointer to incomplete type thread_pthread.h:411: dereferencing pointer to incomplete type thread_pthread.h:412: dereferencing pointer to incomplete type thread_pthread.h:413: dereferencing pointer to incomplete type thread_pthread.h:419: dereferencing pointer to incomplete type thread_pthread.h:420: dereferencing pointer to incomplete type thread_pthread.h:425: dereferencing pointer to incomplete type thread_pthread.h: In function `PyThread_up_sema': thread_pthread.h:437: dereferencing pointer to incomplete type thread_pthread.h:439: dereferencing pointer to incomplete type thread_pthread.h:440: dereferencing pointer to incomplete type thread_pthread.h:442: dereferencing pointer to incomplete type make[1]: *** [thread.o] Error 1 make[1]: Leaving directory `/usr/local/Src/Python-1.5.2/Python' make: *** [Python] Error 2 thread_pthread.h looks like this: 110 typedef struct { 111 char locked; /* 0=unlocked, 1=locked */ 112 /* a pair to handle an acquire of a locked lock */ 113 pthread_cond_t lock_released; 114 pthread_mutex_t mut; 115 }; pthread_lock; Any help would be appreciated. Brian Kennison From mhammond at skippinet.com.au Thu Dec 16 20:53:59 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 17 Dec 1999 01:53:59 GMT Subject: pythoncom and MTS References: <83b5lq$5tr$1@nnrp1.deja.com> Message-ID: wrote in message news:83b5lq$5tr$1 at nnrp1.deja.com... > Does anyone know if you can implement MTS (Microsoft Transaction > Server) complient/safe COM objects in python? 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? > -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. Mark. From tismer at appliedbiometrics.com Mon Dec 20 13:19:24 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Mon, 20 Dec 1999 19:19:24 +0100 Subject: LISTS: Extract every other element 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> <19991220121716.A5107@vislab.epa.gov> Message-ID: <385E732C.FA0CCCE5@appliedbiometrics.com> Randall Hopper wrote: > > 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. 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 also assume that you do one test after the other, many times? If not, I loose! :-)) This is since I use an unusual stack size which causes reallocs of stack frames, which in turn causes reallocs of result variables which no longer fit the hole. I'm working on a malloc scheme for Python which does not suffer from this. Mallocs will be cahced with the code location. > APPROACH #8 | 33.29% (0.696691 sec) | 34.40% (0.686397 sec) * > APPROACH #9 | 31.34% (0.656048 sec) | 34.14% (0.681241 sec) > APPROACH #8 - Christian's 100 element walker > APPROACH #9 - lst2 = mxTools.extract( lst, mxTools.trange( 0, len(lst), 2 ) ) This is unbelievable. Marc has the extra overhead of creating the trange object, I have the overhead of the three interpreted machine instructions. But we are both stopped by the C API, which always goes through the general object protocol. Let's see how fast we can get: try: from slice2 import everyother except: everyother = None if everyother: data = range(1000000) print timing(chrisInline, data, 10)[0] print timing(everyother, data, 10)[0] 25.54 3.02 This tells us that we can be 8 times faster. :-) Here your module: -------- slice2.c -------- /* very quick hack for randall Hopper to show how fast slicing can be, and to give him a fast module with thanks for the nice race Chris Tismer, 991220 */ /* start: 6:40 pm */ #include "python.h" PyObject * everyother(self, args) PyObject *self, *args; { PyObject *inlist, *outlist, *thing; int p, p2; int insize, outsize; if (PyTuple_GET_SIZE(args) != 1 || !(PyList_Check(PyTuple_GET_ITEM(args, 0))) ) { PyErr_SetString(PyExc_TypeError, "everyother needs exactly one list argument"); return NULL; } inlist = PyTuple_GET_ITEM(args, 0); insize = PyList_GET_SIZE(inlist); outsize = insize / 2; outlist = PyList_New(outsize); if (!outlist) /* must be mem error */ return NULL; for ( p=1, p2=0 ; p2 < outsize ; p+=2, p2++) { thing = PyList_GET_ITEM(inlist, p); Py_INCREF(thing); PyList_SET_ITEM(outlist, p2, thing); } return outlist; } static PyMethodDef slice2_methods[] = { {"everyother", (PyCFunction)everyother, 1}, {NULL, NULL} /* sentinel */ }; #ifdef _MSC_VER _declspec(dllexport) #endif void initslice2() { PyObject *m; m = Py_InitModule("slice2", slice2_methods); } /* finished 7:00 pm */ /* finished testing & debugging: 7:20 pm */ ------ end of slice2.c ------- ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From peche at dial.pipex.com Sun Dec 26 13:59:32 1999 From: peche at dial.pipex.com (Keith White) Date: Sun, 26 Dec 1999 18:59:32 +0000 Subject: tutorial questions (examples fail). References: <386625AE.C88C4992@dial.pipex.com> <19991226181026.A4648@stopcontact.palga.uucp> Message-ID: <38666594.3ED85477@dial.pipex.com> Thanks... I have it working now,its amazing just how strict python is over this indentation stuff. I have downloaded the emacs python mode,and this seems to know the indentation far better than i. 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. Thanks again. -- Keith From tim_one at email.msn.com Mon Dec 13 05:05:24 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Dec 1999 05:05:24 -0500 Subject: Python and regexp efficiency.. again.. :) In-Reply-To: Message-ID: <000a01bf4551$92f8a720$9e2d153f@tim> [Markus Stenberg, with a series of too-vague descriptions of a difficult problem] Try posting the actual pattern and some actual data -- when you're getting into regexp nano-tuning, no amount of talking around the data is going to yield a good enough approach. > ... > 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 ... Python's engine does a backtracking search, trying each alternative one at a time; lots of alternatives in a rarely-matching pattern means lots of backtracking. Factoring out a common prefix is a fine idea that saves many redundant comparisions. A "traditional DFA" engine is enormously better suited to this task speedwise, because it does no backtracking. I don't know of a TDFA engine available from Python (maybe pregex (search for it) -- can't remember). > ... > Hmm.. actually, I'm not sure if re.match('^.*(foo|bar|baz)') is as > fast as re.search('(foo|bar|baz)'). It's impossible to say without seeing the pattern and typical data. A leading .* initially matches the entire string, then backs off one character at a time trying the rest of the pattern all over again; .search without .* moves *forward* one character at a time instead. So it depends on (at least) which end of your strings is more likely to contain a hit. Best general hint: try to find a *simple* regexp R such that if R doesn't match, neither can your full-blown regexp. If R is much cheaper to run, the "extra" time to weed out false positives can be an unboundedly huge bargain. Also, if the (conceptual) fields in the lines are separated by some character, string.split() the lines and throw the uniniteresting fields away rather than waste time matching them away in the regexp. the-fastest-regexp-is-the-empty-regexp-ly y'rs - tim From fredrik at pythonware.com Wed Dec 1 14:40:10 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 1 Dec 1999 20:40:10 +0100 Subject: [Tutor] TKinter References: <003301bf3ab5$13138080$0c5bdfc8@the-user> <38431229.7B60A603@worldnet.att.net> <384314A8.6929482C@callware.com> <38454E1D.167E@austin.ibm.com> Message-ID: <007a01bf3c33$e2107030$f29b12c2@secret.pythonware.com> Tom Smith wrote: [ http://www.pythonware.com/library.htm ] > Not Found > > The requested URL /library.htm was not found on this server. the URL is correct, and the server is working just fine. try "reload". From claird at starbase.neosoft.com Mon Dec 20 17:19:07 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 20 Dec 1999 22:19:07 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> <14430.40277.76485.132029@weyr.cnri.reston.va.us> Message-ID: <8C08570AD452AA72.AF39C8F4DB6CAA63.8C37591560ADCDB7@lp.airnews.net> In article <14430.40277.76485.132029 at weyr.cnri.reston.va.us>, Fred L. Drake, Jr. wrote: . . . > There's some namespace support, but I don't know how well-used it >it. My own thought on Perl is simply that it's hard to read, so >others may (legitimately) say otherwise. . . . As you know, people write endlessly on the virtues and vices of languages other people use. I'll add as little to that volume as I can. Perl has nice enough mechanisms that there are whole books such as Damian Conway's valuable *Object-Oriented Perl*. It is absolutely possible for individuals to write Perl for big projects. The problem is that Perl so much observes its TMTOWTDI mantra that it also seems easiest for individuals to write stuff that only they can read--or, more to the point, that is a poor fit for large-scale modularity and namespacing in particular. My own wildly speculative estimate is that under 1% of the people who advertise themselves as Perl programmers use pack- ages and namespaces "well". That doesn't necessarily reflect on the language, of course ... -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From a.eyre at optichrome.com Fri Dec 17 05:54:15 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 17 Dec 1999 10:54:15 -0000 Subject: building string for __import__() In-Reply-To: Message-ID: <003301bf487d$0f75e640$3acbd9c2@peridot.optichrome.com> > my problem was that the variable that I built up with: > > [snip] > > would give me the import error but just typing it manually into the > interpreter would work fine. I'll try the . notation. If it works by hand, try somthing like: dirdata = { 'somewhere': '0', 'foo': '1', 'flub': '2' } filename = "/mnt/somewhere" + dirdata['somewhere'] + \ "/foo" + dirdata['foo'] \ "/flub" + dirdata['flub'] \ "/TARGET" expected_filename = "/typing/in/the/path/by/hand/did/it/TARGET" if filename != expected_filename: raise "Pah, I've screwed up somewhere" c = __import__(filename) Using the import notation will also have different behaviour depending on the current working directory when you run the script. Python adds . to the PYTHONPATH IIRC. > I'm happy enough with execfile and was just curious about what I was > doing wrong with __import__ Be aware that execfile is slightly different in that is runs the script in the __main__ namespace, rather than importing it. -------------------------------------------- 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 wclodius at lanl.gov Fri Dec 10 12:19:15 1999 From: wclodius at lanl.gov (William B. Clodius) Date: Fri, 10 Dec 1999 10:19:15 -0700 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: <38513612.7190FB6A@lanl.gov> Dennis Lee Bieber wrote: > > > 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). > Manipulations involving character*(*), i.e., character indexing and concatenation, are easy to implement on a stack or a heap, but I believe cannot be implemented statically without either a system dependent maximum size of character entities or a detailed interprocedural data-flow analysis. From jagui at _removeme_bigfoot.com Mon Dec 20 15:53:55 1999 From: jagui at _removeme_bigfoot.com (Luca Giuranna) Date: 20 Dec 1999 20:53:55 GMT Subject: Hi to all! Message-ID: <83m513$n9r$1@pegasus.tiscalinet.it> I would like to say hello to this group. I'm new to Python but i think i'll use it a lot! Now i go to read the faq and other docs... then i'll come back with some questions... wait for me :-) - Luca Giuranna - From ullrich at math.okstate.edu Mon Dec 13 13:45:53 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 13 Dec 1999 12:45:53 -0600 Subject: Dot product? References: Message-ID: <38553EE1.F654AD8F@math.okstate.edu> Mike Fletcher wrote: > (Prying dang tongue from cheek for a few seconds, blighter keeps getting > caught in there)... [explanation of what was so rebellious (EOWWSR) snipped] Thanks, that clarifies things (TTCT). DU From glandrum at my-deja.com Sat Dec 18 09:37:17 1999 From: glandrum at my-deja.com (Greg Landrum) Date: Sat, 18 Dec 1999 14:37:17 GMT Subject: tkinter on AIX References: <385AA5EE.6B31BDA1@austin.ibm.com> Message-ID: <83g66u$itf$1@nnrp1.deja.com> Oops, I forgot to mention that I am not sure that python actually works with version 8.2 of Tk/Tcl. In fact, I think I remember reading that it does not. good luck, -greg Sent via Deja.com http://www.deja.com/ Before you buy. From nick at spam_me_notvideosystem.co.uk Fri Dec 3 06:28:52 1999 From: nick at spam_me_notvideosystem.co.uk (Nick Trout) Date: Fri, 3 Dec 1999 11:28:52 -0000 Subject: python 3D graphics References: <38475965.E80E77FB@trojanslair.zzn.com> Message-ID: <3847a634@news.xtml.co.uk> wxPython has an OpenGL API and a good windowing system to support it. See: www.alldunn.com/wxPython Have a look at www.python.org and "Modules". The graphics sections contains links to 3d visualisation packages, GUIs etc... N "Black Mantis" wrote in message news:38475965.E80E77FB at trojanslair.zzn.com... | Hi | | I am wondering if anybody has any useful information on programing in 3D | in python. i would appreciate it very much | From bowman at montana.com Sun Dec 26 21:34:30 1999 From: bowman at montana.com (bowman) Date: Mon, 27 Dec 1999 02:34:30 GMT Subject: Tkinter config on RH 5.2 References: <38664B8A.6AEA7758@altern.org> Message-ID: 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. From alex at magenta.com Wed Dec 15 19:07:11 1999 From: alex at magenta.com (Alex Martelli) Date: Thu, 16 Dec 1999 01:07:11 +0100 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> Message-ID: <007f01bf4759$f741a880$c02b2bc1@martelli> 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. Fortunately, I hear that __contains__ will be in a forthcoming version, making me a very happy camper indeed:-). Alex From antje_in_potsdam at my-deja.com Fri Dec 3 08:10:13 1999 From: antje_in_potsdam at my-deja.com (antje_in_potsdam at my-deja.com) Date: Fri, 03 Dec 1999 13:10:13 GMT Subject: Newbie: can't install mysqldb Message-ID: <828ffk$32f$1@nnrp1.deja.com> I want use MyQSL with Python 1.5, but don't now how to do it. I try to install mysqldb: "make -f Makefile.pre.in boot" run without error but "make" give an error message: /usr/i486-linux/bin/ld: cannot open -lmysqlclient: No such file or directory The installation of MySQL, i think, its ok. Sent via Deja.com http://www.deja.com/ Before you buy. From gerrit.holl at pobox.com Wed Dec 29 14:57:26 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 29 Dec 1999 20:57:26 +0100 Subject: why? In-Reply-To: <3869F143.90051270@prism.co.za>; from alwyns@prism.co.za on Wed, Dec 29, 1999 at 01:32:19PM +0200 References: <386986aa.238773@news.isomedia.com> <3869F143.90051270@prism.co.za> Message-ID: <19991229205726.A2794@stopcontact.palga.uucp> Alwyn Schoeman wrote on 946470739: > Could someone please port those to KDE and GNOME? :) Use the ico2xpm package or grab a GIF from the web... regards, Gerrit. -- "The move was on to 'Free the Lizard'" -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates) 8:38pm up 4 min, 11 users, load average: 4.08, 1.46, 0.54 From ivanlan at callware.com Wed Dec 22 17:34:46 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 22 Dec 1999 15:34:46 -0700 Subject: Offtopic: millenium References: <199912222000.PAA17264@eric.cnri.reston.va.us> <19991222215733.A2783@stopcontact.palga.uucp> <83ri56$58q$1@nntp3.atl.mindspring.net> Message-ID: <38615206.636B50C@callware.com> Hi All-- Aahz Maruch wrote: > > In article <19991222215733.A2783 at stopcontact.palga.uucp>, > Gerrit Holl wrote: > >> > >> We know that the Python conference isn't until the next millennium. > > > >Hmm, we've already had a discussion on this, haven't we? > > To quote my partner: milleNNium milleNNium milleNNium milleNNium > > ;-) > > (Don't worry about it, Gerrit, I've misspelled it, too.) > Have a look at http://www.magnet.ch/serendipity/hermetic/cal_stud/newmill.htm Peter Meyer is a regular contributor to the CALNDR-L mailing list, and is, except for the occassional foray into the fringes of New Agery, a fairly reliable resource in matters calendrical. Me, I think if the Pope sez the millennium is 1/1/2000, it's as close as anyone is going to get to an authoritative answer. -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 piers at cs.su.oz.au Wed Dec 8 16:28:23 1999 From: piers at cs.su.oz.au (Piers Lauder) Date: Thu, 09 Dec 1999 08:28:23 +1100 Subject: X display visual Message-ID: <944690214.197.926615478@cs.usyd.edu.au> Randall Hopper wrote: > > To be more robust, pick a visual returned by: > > root.winfo_visualsavailable() Just for the record, this particular Tkinter method doesn't work on either my Linux or Solaris boxes: : linux ; python impPython 1.5.2 (#8, May 4 1999, 18:16:39) [GCC 2.7.2.3] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam o>>> import Tkinter >>> r=Tkinter.Tk() >>> r.withdraw() '' >>> r.winfo_visualsavailable() Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 428, in winfo_visualsavailable return map(parseitem, data) File "/usr/lib/python1.5/lib-tk/Tkinter.py", line 427, in parseitem return x[:1] + tuple(map(getint, x[1:])) TypeError: illegal argument type for built-in operation # solaris ; python Python 1.5.2 (#10, May 11 1999, 15:32:03) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import Tkinter >>> r=Tkinter.Tk() >>> r.withdraw() '' >>> r.winfo_visualsavailable() Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 428, in winfo_visualsavailable return map(parseitem, data) File "/usr/local/lib/python1.5/lib-tk/Tkinter.py", line 427, in parseitem return x[:1] + tuple(map(getint, x[1:])) TypeError: illegal argument type for built-in operation To track doesn what exactly *is* being returned, I tried: >>> r.tk.call('winfo', 'visualsavailable', r._w, None) '{truecolor 24}' >>> r.tk.split('{truecolor 24}') 'truecolor 24' >>> def parseitem(x): ... return x[:1] + map(int, x[1:]) ... >>> map(parseitem, 'truecolor 24') Traceback (innermost last): File "", line 1, in ? File "", line 2, in parseitem TypeError: illegal argument type for built-in operation From alex at somewhere.round.here Thu Dec 30 13:02:36 1999 From: alex at somewhere.round.here (Alex) Date: 30 Dec 1999 13:02:36 -0500 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> <84g50u$rtf$1@nnrp1.deja.com> Message-ID: > 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 :) I did something similar, recently. I found it much easier for my purposes to subclass sgmllib.SGMLParser, and add start_* and end_* methods. Alex. From tim_one at email.msn.com Thu Dec 9 22:01:31 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 9 Dec 1999 22:01:31 -0500 Subject: Numeric Conversion In-Reply-To: <384F6823.E66085F1@cc.huji.ac.il> Message-ID: <001c01bf42ba$dc33dd40$60a2143f@tim> [Iddo Friedberg] > A small one: atoi &c. recognize the tokens '+' and '-' by themselves as > a numeric value; i.e. > > >>> m=string.atoi('+') > >>> print m > 0 This bug was fixed quite some time ago, in the Python 1.5.2 release. upgrade-advising-ly y'rs - tim From paul at prescod.net Wed Dec 29 11:49:34 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 29 Dec 1999 11:49:34 -0500 Subject: Py2K wishes References: Message-ID: <386A3B9E.63C0D36B@prescod.net> John Mitchell wrote: > > Isnt this the same as Fulton's __of__ code developed for Zope? That is, a > semi-automatic delegation to another instance instead of up the class > hierarchy -- aka acquisition. Acquisition does a little more than I am asking for. Acquisition sets up the fallback path based upon the path you used to get to the object. Paul Prescod From andres at corrada.com Tue Dec 7 16:44:40 1999 From: andres at corrada.com (andres) Date: Tue, 07 Dec 1999 16:44:40 -0500 Subject: Need python mode for Jed References: <384D5F1D.C1F2CE6E@corrada.com> Message-ID: <384D7FC8.5409433A@corrada.com> Grant Edwards wrote: > > 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. I seem to remember someone (Tim Peters?) posting recently that there is an option at deja.com that allows postings to be presented in their original usenet format. Help anyone? Andres Corrada From chapman at bioreason.com Wed Dec 15 17:13:37 1999 From: chapman at bioreason.com (Mitch Chapman) Date: Wed, 15 Dec 1999 22:13:37 +0000 Subject: C++ (was RE: Python suitability) References: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it> <838uvo$sc7$1@news1.xs4all.nl> Message-ID: <38581291.AF077013@bioreason.com> Boudewijn Rempt wrote: > > Alex Martelli wrote: > ... > > Specifically, if you follow the advice of Scott Meyers, in his > > excellent "Effective C++" (CD Edition): never inherit from a > > concrete class. > > That makes C++ about as powerful as Visual Basic - in essence, > no inheritance at all, just interfaces... Having just done a > large project in Visual Basic, I've learnt how painfult that > limitation can be - and I was kind of surprised when I read > in Design Patterns that composition should be favoured over > inheritance. There are no doubt good reasons, but not one > I can think of. Composition can help keep the interface of any single class relatively small. Composition, in Python, reduces the likelihood of namespace collisions (e.g. you write over a method or instance variable defined in a base class, without knowing it). Guido has recommended composition over inheritance, when specializing Tkinter widgets. IIRC he used both namespace collisions and huge namespaces (resulting from subclassing, resulting *in* huge attribute dictionaries w. poor performance) as his reasons. I can't say why, but I've had better luck w. projects when I design in terms of interacting components than when I design in terms of interacting sub-/super-classes. But perhaps my experience would have been different if I'd used a language in which all instance variables are private, i.e. in which there's no temptation for a subclass to fiddle w. its base class member variables? -- Mitch Chapman chapman at bioreason.com From Dom.Mitchell at palmerharvey.co.uk Fri Dec 10 12:24:57 1999 From: Dom.Mitchell at palmerharvey.co.uk (Dominic Mitchell) Date: 10 Dec 1999 17:24:57 +0000 Subject: Enviroment References: Message-ID: Robert Milkowski writes: > So how can I inform system directly from python to make use of this > directory while searching libs? Make sure you're using the latest version of python. It's only with 1.5.something that os.environ changes actually got reflected back into the environment of spawned children. -- Dom Mitchell -- Palmer & Harvey McLane -- Unix Systems Administrator "EDLIN comes free with MS-DOS, and is expensive at the price." From neelk at cswcasa.com Mon Dec 27 16:13:33 1999 From: neelk at cswcasa.com (neelk at cswcasa.com) Date: Mon, 27 Dec 1999 16:13:33 -0500 Subject: "sins" (aka, acknowledged language problems) Message-ID: Fran?ois Pinard [mailto:pinard at iro.umontreal.ca] wrote: >neelk at brick.cswv.com (Neel Krishnaswami) writes: > >> As a general rule, syntax is a bad thing, to be avoided whenever >> possible. Calls for additional syntax are typically a sign that >> one of the basic operations of the semantics needs generalization. > >I might not go that far. Features come through syntax or >libraries: Perl or LISP, to name some extremes. A good thing >which often comes with syntax is that, when used intelligently, >it forces some redundancy in the language which a compiler can >later check. Programmers might grumble and moan somewhat, but >they win in the long run. When everything generalizes, the >compiler stops being our friend, at some point. I was specifically thinking of Lisp, as a matter of fact. Its extremely minimalistic syntax permits the creation of a macro system that allows real syntactic abstraction. (Call it transformational programming if the word "macro" gives you flashbacks to C preprocessor hacks. :]) An example: I am currently playing with Screamer, which is a package that seamlessly adds Prolog-style nondeterminism and constraint programming to Common Lisp. It's fast, too, because the package is able to compile the expressions you write into CPS form and optimize them. More, once installed the extension is every bit a part of the language as (say) CLOS is. Doing a similar thing for Python would not be a task for the faint of heart. -- Neel Krishnaswami neelk at alum.mit.edu From aahz at netcom.com Fri Dec 31 10:47:46 1999 From: aahz at netcom.com (Aahz Maruch) Date: 31 Dec 1999 15:47:46 GMT Subject: "sins" (aka, acknowledged language problems) References: <000101bf528c$63c7c9c0$a02d153f@tim> Message-ID: <84ij72$ems$1@nntp8.atl.mindspring.net> In article , Neel Krishnaswami wrote: >Tim Peters wrote: >> >> That John could assume otherwise just goes to show that he thinks Python's >> scheme is complicated because he's still trying to force some other >> languages' view(s) onto it. Forcing a bloated square peg into a slimly >> elegant round hole is indeed a complicated business . > >I think that in light of Viper, John can no longer be said to be >*trying to use* a different scoping model in Python, because he >has *succeeded*. :) I should let the Timbot speak for itself, but I think Tim's point is that with a different scoping model, it isn't Python any more. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Eighth Virtual Anniversary -- today! From sragsdale at my-deja.com Thu Dec 2 14:52:16 1999 From: sragsdale at my-deja.com (sragsdale at my-deja.com) Date: Thu, 02 Dec 1999 19:52:16 GMT Subject: Inappropriate Packing Message-ID: <826ikn$orm$1@nnrp1.deja.com> I must be misunderstanding something about the arguments given to pack(). I'm trying to create an application where there's a menu bar at the top, a tool bar at the bottom, and a frame in the middle that takes up all remaining space. When the following app is resized, the middle panel doesn't take up as much as it should and the bottom menu bar consumes too much. What's going on? ################################################################## inter import * class App(Frame): def __init__(self,parent): Frame.__init__(self,parent) self.makeMenuBar() mf = Frame(self,relief=RAISED,bd=2) mf.pack(expand=YES,fill=BOTH) Label(mf,text="top of frame").pack(side=TOP) Label(mf,text="bottom of frame").pack(side=TOP) self.makeToolBar() # make the menu bar (above) def makeMenuBar(self): self.menubar = Frame(self, relief=RAISED, bd=2) self.menubar.pack(side=TOP, fill=X) mbutton = Menubutton(self.menubar, text='File', underline=0) mbutton.pack(side=LEFT) menu = Menu(mbutton) menu.add_command(label="Save", command=None) mbutton['menu']=menu def makeToolBar(self): toolbar = Frame(self, relief=SUNKEN, bd=2) toolbar.pack(side=BOTTOM, expand=YES, fill=X) Button(toolbar, text='Quit', command=self.quit).pack(side=RIGHT) self.message = Label(toolbar) self.message.pack(side=LEFT) bob = App(None) bob.pack(expand=YES,fill=BOTH) bob.mainloop() Sent via Deja.com http://www.deja.com/ Before you buy. From bob at horvath.com Tue Dec 7 23:52:27 1999 From: bob at horvath.com (Bob Horvath) Date: Wed, 08 Dec 1999 04:52:27 +0000 Subject: browser interface? References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> <384D1F58.1459835F@horvath.com> <99120708514400.02363@quadra.teleo.net> Message-ID: <384DE40B.52CB0FAE@horvath.com> Patrick Phalen wrote: > [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. > OK, I see your point. I have been looking at Zope and have not been able to get off of the ground with it, so I thought suggesting it to someone that is still trying to figure out CGI might be a little ambitious.... > > 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. I have not tried in a while, so I will definitely check out the links. Thanks. From donn at u.washington.edu Wed Dec 15 14:51:44 1999 From: donn at u.washington.edu (Donn Cave) Date: 15 Dec 1999 19:51:44 GMT Subject: running and managing background shell commands References: <3857D3D1.C651BB88@shfj.cea.fr> Message-ID: <838rgg$jpu$1@nntp6.u.washington.edu> Quoth Dimitri Papadopoulos : | I am translating this shell function to Python: | | _new_browser() { | # start Netscape in the background | # this will always return 0, even in the face of a failure... | netscape "$*" & | # ... so wait a few seconds, and check that Netscape is still alive | i=3 | while [ $i -gt 0 ] | do | sleep 1 | ps -p $! > /dev/null || return 1 | i=`expr $i - 1` | done | return 0 | } | | How can I rewrite this function? As far as I know: | 1) commands.getstatus cannot start a background command | 2) os.system does start a background command | 3) but $! is not available | Do I have to fork and then execv - which is probably what the shell does anyway? You don't have to fork and execv, though for me that would be the more straightforward way to approach it. Try something like this - fp = os.popen('exec 2>&1 \n netscape & \n echo $!', 'r') pidline = fp.readline() fp.close() if pidline: try: pid = string.atoi(pidline) except ValueError: raise browser_error, pidline else: raise browser_error, 'shell abort' i = 0 while i < timeout: try: os.kill(pid, 0) except os.error: raise browser_error, ' The "exec 2>&1" line redirects the diagnostics and errors to the pipe along with normal output. I used \n instead of ; because of a weakness in the shell's grammatical ideas about &. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From fdrake at acm.org Thu Dec 30 13:00:09 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 30 Dec 1999 13:00:09 -0500 (EST) Subject: newbie question... In-Reply-To: <3868C1D2.614DA917@earthlink.net> References: <3868C1D2.614DA917@earthlink.net> Message-ID: <14443.40361.173274.782578@weyr.cnri.reston.va.us> Alexander Sendzimir writes: > According to David Beazley's invaluable book, mailbox.py is an undocumented > module. However, since 1.5.1 of python this module has been modified. Does Alexander, It is documented in the current version of the documentation. See: http://www.python.org/doc/current/lib/module-mailbox.html -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From hinsen at cnrs-orleans.fr Fri Dec 3 05:29:13 1999 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 03 Dec 1999 11:29:13 +0100 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: m.faassen at vet.uu.nl (Martijn Faassen) writes: > 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. That convention is already used in some communities, for example among astronomers, because it facilitates calculations substantially. And there is no risk of getting confused with dates in historical documents, because the AD counting system wasn't invented before 532 AD (which was commonly called year 247 of the reign of emperor Diocletian at the time) by an abbot who published a table of the dates of Easter for the next 19 years, and didn't want to put the name of Diocletian on it, because this emperor hadn't been too friendly to Christians. He thus figured out the year of the birth of Christ (and appearantly got it wrong) and decided to call the following year 1 AD. So if you ever see a document marked with an AD date before 532, it's a fake, and even much later dates are not likely to be genuine because the AD scheme didn't become widespread before the 10th century or so. All this confusion gives a unique opportunity to those who'd like to celebrate the new millenium several times, because there are so many justifiable dates: 1/ 1/2000: first year starting with a 2 1/ 1/2001: first year of the third period of 1000 years in our current year counting scheme 30/12/2000: 2000 years after 1 AD (don't forget that 1 AD was defined in the Julian calendar!) 14/ 1/2000: start of the third millenium according to the Julian calendar counted from the "common era" (that's AD but counted from zero); this combination is popular in astronomy for its relative simplicity. 14/ 1/2001: start of the third millenium according to the calendar that was used when the AD scheme was introduced (i.e. the Julian calendar) And if that's not enough, just add all the non-Christian calendars. All this is way off-topic... so in order to introduce a Python-related content, I herewith propose formally to start the 9th Python conference the 14th of January 2001 ;-) -- ------------------------------------------------------------------------------- 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 aa8vb at yahoo.com Fri Dec 17 09:12:56 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Fri, 17 Dec 1999 09:12:56 -0500 Subject: LISTS: Extract every other element - SUMMARY In-Reply-To: <14425.16338.583342.648548@buffalo.fnal.gov> References: <19991216131341.A153923@vislab.epa.gov> <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> Message-ID: <19991217091256.A168025@vislab.epa.gov> Thanks for the suggestions. Many of these are really novel ideas I hadn't thought of. I coded each of these up, working with the same list of 100,000 integers. Here are the results. To my amazement, the simple for loop approach is pretty decent, as Mike mentioned. Numeric will get you a little improvement (30-35%) if you use the shape-change column-selection approach Mike suggested. RESULTS: Using range() Using xrange() ----------------------------------------------------------- APPROACH #1 | 100.00% (2.13357 sec) | 100.00% (2.03318 sec) * APPROACH #1b | 96.91% (2.0677 sec) | 98.20% (1.9965 sec) * APPROACH #2 | 690.97% (14.7423 sec) | 719.24% (14.6235 sec) * APPROACH #3 | 121.29% (2.58789 sec) | 122.02% (2.48094 sec) * APPROACH #4 | 308.55% (6.58309 sec) | 323.81% (6.58367 sec) APPROACH #4b | 705.80% (15.0587 sec) | 740.94% (15.0646 sec) APPROACH #5 | 104.58% (2.23128 sec) | 105.42% (2.14335 sec) * APPROACH #6 | 66.42% (1.41702 sec) | 70.39% (1.43119 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 #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] ) ----------------------------------------------------------------------------- -- Randall Hopper aa8vb at yahoo.com From wtanksle at hawking.armored.net Tue Dec 7 22:38:23 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 8 Dec 1999 03:38:23 GMT Subject: Widget set for curses? References: Message-ID: On Tue, 07 Dec 1999 21:49:54 GMT, Grant Edwards wrote: >Are there any python widget sets that use curses (or slang)? I think Redhat uses one called 'newt'. It's not extremely functional or anything. There's a Curses port of wxWindows which works with 1.something; if you used that, you'd have a good chance of working with graphical displays as well, when possible. >Simple stuff like radio buttons, entry fields, buttons... >I was hoping for something like the newt or cdk libraries. CDK is just about the neatest thing I've seen for curses. A Python port would be tres cool. And then also a more sophisticated OO Python port. >Grant Edwards -- -William "Billy" Tanksley, in hoc signo hack From greg.ewing at compaq.com Mon Dec 6 10:04:24 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 07 Dec 1999 04:04:24 +1300 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: <384BD078.ABD73AB6@compaq.com> Dennis Lee Bieber wrote: > > I have one question... How was that imaginary year the C > programmers lived between 1BC and AD1? It was great fun! Especially that huge argument we had over whether to call it 0BC or AD0... Greg > > -- > > ============================================================== < > > 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 aahz at netcom.com Thu Dec 23 14:03:20 1999 From: aahz at netcom.com (Aahz Maruch) Date: 23 Dec 1999 19:03:20 GMT Subject: Super-rexex? References: <19991223151828.A3636@stopcontact.palga.uucp> <1266159968-30845431@hypernet.com> Message-ID: <83trlo$8ka$1@nntp9.atl.mindspring.net> In article <1266159968-30845431 at hypernet.com>, Gordon McMillan wrote: >Fred L. Drake, Jr. wrote: >> >> 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: >> >> 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. > >Isn't that the kind of parsing that shlex is good at? I'm inclined to >think that John's (highly capable, wonderful, etc. etc.) tools are bit >more than is required here. Uh-oh. Are we headed for TMTOWTDI? -- --- 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 gmcm at hypernet.com Tue Dec 28 17: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: Message-ID: <1265702487-58362302@hypernet.com> > 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 - Gordon From tiddlerdeja at my-deja.com Sun Dec 12 13:29:31 1999 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Sun, 12 Dec 1999 18:29:31 GMT Subject: win32com: subclass a com object? Message-ID: <830pi6$n4k$1@nnrp1.deja.com> I'm fairly new to python and am currently using it to script COM objects. 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). I'm no COM expert either by the way. Any help would be greatly appreciated. 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? Thanks again. Kieran Sent via Deja.com http://www.deja.com/ Before you buy. From af137 at torfree.net Tue Dec 21 07:04:03 1999 From: af137 at torfree.net (Al Aab) Date: Tue, 21 Dec 1999 12:04:03 GMT Subject: . pythondx References: <199912200716.HAA03056@dionysus.fw.cuci.nl> Message-ID: Hans, thanx, the ^D works. thought it was a UNIXism. still the cursor is stuck in whatever column it so likes. the exact column differs from python invocation to python invocation. have to type cursorlessly. & am guilty of TSRism, but have plenty of conventional ram left over (about 630 000 bytes) a friend, with less tsr's has no problem with the cursor. but other aps (including pythondx lite) i use have no problem with the cursor under dos 6.22 Hans Nowak (hnowak at cuci.nl) wrote: : On 19 Dec 99, at 9:17, Al Aab wrote: : > for native dos : : > : > any1 knows how to : > exit, control-z suspend, leaving 49 k in ram. : Try Ctrl-D. Ctrl-Z is a Windows-ism. :) : > another problem : : > the pythondx full version, has a static cursor : > (the lite-version's cursor is ok. ) : Hmm... What do you mean by a 'static cursor'? : Veel liefs, : --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. -- =-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- al aab, ex seders moderator sed u soon it is not zat we do not see the s o l u t i o n -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+ From tim_one at email.msn.com Mon Dec 13 03:43:15 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Dec 1999 03:43:15 -0500 Subject: Extracting list of keys from 2-key dictionary In-Reply-To: <831vjl$goe$1@nnrp1.deja.com> Message-ID: <000801bf4546$18966540$9e2d153f@tim> [mdfranz at my-deja.com] > I'm porting a script from perl that uses: > > dict[a,b] instead of $hash{$a}{$b} > > My goal is to get a unique list of the second keys for a > value, when a=x > > In perl, this can be done with: > > @list = keys %{$hash{x}} > No, it can't (see below before yelling at me ). > Is there a quicker/easier way in python than the snippet below to do > this? > > for a,b in dict.keys(): > if dict.has_key(x,b): > if b not in list: > list.append(b) You used a 2-level hash in your Perl, but a 1-level dict in your Python. Perl similar to your Python would use $hash{$a, $b} relying on Perl's $SUBSCRIPT_SEPARATOR to make "$a$;$b" the key to a one-level hash (while your Python dict[a, b] uses the 2-tuple (a, b) as the key to a one-level dict). You can also use a 2-level dict of dicts in Python. Then extraction is the (very close to your Perl) one-liner: list = hash[x].keys() Doing this operation with a 1-level hash/dict using compound keys is clumsy in both languages. dict-is-short-for-dictator-cuz-gui-was-already-in-use-ly y'rs - tim From fredrik at pythonware.com Tue Dec 14 09:21:02 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 14 Dec 1999 15:21:02 +0100 Subject: __getattr__, hasattr References: <835crr$fjl@mail.psy.uva.nl> Message-ID: <002301bf463e$743b6730$f29b12c2@secret.pythonware.com> Ionel Simionescu wrote: > It seems that since one defines __getattr__, > hasattr(obj, name) will happily answer 'yes' irrespective of the attribute > name. only if you define a __getattr__ that always succeeds... > This does not appear very sound to me. why not? if __getattr__ doesn't complain, why should hasattr? > Do I overlook anything? probably ;-) see the description of "hasattr" for more info: http://www.python.org/doc/current/lib/built-in-funcs.html From chu at chipotle.physics.uvm.edu Sun Dec 19 17:13:32 1999 From: chu at chipotle.physics.uvm.edu (Kelvin Chu) Date: 19 Dec 1999 17:13:32 -0500 Subject: How to cite Python and Numerical Python in papers? Message-ID: Hello, Python gurus; I'd like to cite both Python and the Numerical Python extensions in the references for a paper that I'm writing. Are there preferred references to give for each set of code? Thanks very much. KC -- kelvin.chu at uvm.nospam.edu (802) 656-0064 http://www.uvm.nospam..edu/~kchu/ FAX: (802) 656-0817 From DOUGS at oceanic.com Wed Dec 29 13:11:20 1999 From: DOUGS at oceanic.com (Doug Stanfield) Date: Wed, 29 Dec 1999 08:11:20 -1000 Subject: Looking for pysnmp Message-ID: <5650A1190E4FD111BC7E0000F8034D26A0F205@huina.oceanic.com> Cameron Laird has a page with links to SNMP related Python info including SNMPy and the link Ilya gave you for his new pysnmp work. http://starbase.neosoft.com/~claird/comp.lang.python/snmpy.html -Doug- > -----Original Message----- > From: Oliver Andrich [mailto:oli at rz-online.net] > Sent: Tuesday, December 28, 1999 8:36 PM > To: python-list at python.org > Subject: Looking for pysnmp > > > 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 -- http://www.python.org/mailman/listinfo/python-list From tim_one at email.msn.com Wed Dec 1 03:14:54 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 1 Dec 1999 03:14:54 -0500 Subject: Python complaints In-Reply-To: <3843D685.C8C13355@maxtal.com.au> Message-ID: <000001bf3bd4$26f10b20$542d153f@tim> [John Skaller] > Integers are NOT objects in Python, they're values. > Same for strings and tuples. We can pretend they're objects, > and say they're 'immutable', but the truth is that they're > just plain values. The implementation doesn't support this view -- e.g., intobject.c has every bit as much "object hair" as listobject.c. There's no sense in which ints are exempted from any of the general object machinery. So it's unclear what you're saying. Perhaps that ints & strings etc don't support methods? That's just historical accident, and in the current CVS snapshot most of the string module's functionality has been reimplemented as methods of string objects (very nice, btw! most people will like this). > My new Viper interpreter may support 'mutable' > integers and strings as follows: you write: > > x := 1 > x++ > x+=1 > > This notation actually creates a reference (pointer) to the value, > so x is a 'reference to an integer', and x++ actually means: > > x := x + 1 > > To see the difference consider: > > a = 1 > x := a > x++ > print a,x > > and you will get 1,2. The integer value a is bound to is still > immutable and cannot be changed. x++, on the other hand, > does not increment what x refers to, rather it replaces what > x refers to by the old value plus 1. > > References in 'rvalue' contexts convert automatically to the > designated value, but when used on the LHS the distinction > between a reference to a value, and a value is preserved. > [References can be used with any type, but they're not > quite as useful with tuples (since there is a mutable list > already) or with class instance objects (since they're > already mutable). > > Comments on this idea appreciated. I'm a long-time fan of augmented assignment (+= and friends), but prefer to live without the pre- and post-increment gimmicks. Introducing references isn't necessary to implement the former, so unless you've got some other killer use in mind for references I'd recommend not doing it that way (extra syntax, extra complications, & mainline Python will likely never do it that way). If/when Guido adds augmented assignment to Python (he's not oppposed to it), thing += thang will most likely compile to (pseudo-code): call thing.__addeq__(thang) # must return a result on the stack bind "thing" to the result in thing's namespace It's then up to each object's __addeq__ method to decide whether to return self (to effect a mutating +=) or to return a different object (to effect a functional +=). It's likely that int.__addeq__ will do the latter and list.__addeq__ the former, so that x = 42 y = x x += 1 print x, y, x is y prints 43, 42, 0 while x = [1, 2, 3] y = x x += [4] print x, y, x is y prints [1, 2, 3, 4], [1, 2, 3, 4], 1 when=-everything's-a-reference-nothing-isn't-ly y'rs - tim From smst at bigfoot.com Fri Dec 3 05:20:32 1999 From: smst at bigfoot.com (Steve Tregidgo) Date: Fri, 03 Dec 1999 10:20:32 GMT Subject: Compiling with Pthreads References: <826j58$oeb$1@bgtnsc02.worldnet.att.net> Message-ID: <8285he$skj$1@nnrp1.deja.com> In article <826j58$oeb$1 at bgtnsc02.worldnet.att.net>, "Brian Kennison" wrote: > thread_pthread.h looks like this: > > 110 typedef struct { > 111 char locked; /* 0=unlocked, 1=locked */ > 112 /* a pair to handle an acquire of a locked lock */ > 113 pthread_cond_t lock_released; > 114 pthread_mutex_t mut; > 115 }; pthread_lock; > It's been a while since I programmed regularly in C, but you appear to have one too many semicolons in that code -- I would say that line 115 should look like: } pthread_lock; ...ie without that first semicolon. (Granted, the error message suggests that you're _missing_ a semi-colon, but what the hell.) never-did-trust-C-error-messages-anyway-ly yrs, Steve -- -- Steve Tregidgo -- Developer for Business Collaborator www.enviros.com/bc Sent via Deja.com http://www.deja.com/ Before you buy. From jody at sccsi.com Wed Dec 29 20:24:40 1999 From: jody at sccsi.com (Jody Winston) Date: 29 Dec 1999 19:24:40 -0600 Subject: Before I go with python ... References: <385C20B4.87FACEED@esoterica.pt> <386A9D6C.29B5D541@starmedia.net> Message-ID: You also can use Medusa (http://www.nightmare.com/medusa/index.html) which implements the Half-Sync/Half-Async design pattern (http://www.cs.wustl.edu/~schmidt/patterns-ace.html) that is used in ACE (http://www.cs.wustl.edu/~schmidt/ACE.html) and TAO (http://www.cs.wustl.edu/~schmidt/TAO.html) -- Jody Winston From gmcm at hypernet.com Fri Dec 17 11:05:31 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 17 Dec 1999 11:05:31 -0500 Subject: NT Desktop question In-Reply-To: <816010E2456BD111A48700805FBBE2EEFDF925@ex-quebec-u1.baan.com> Message-ID: <1266676654-4898790@hypernet.com> Gaetan Corneau writes, > > 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. What works today is: create a bat file: python.exe d:\path\to\myscript.py "%1" Put a shortcut to the bat file on the desktop. You can also use the bat file as a target in the "Send to" menu item of Explorer's context menu, or as an action in a file type association. - Gordon From charliehubbard at my-deja.com Wed Dec 22 10:47:43 1999 From: charliehubbard at my-deja.com (charliehubbard at my-deja.com) Date: Wed, 22 Dec 1999 15:47:43 GMT Subject: os.popen() vs os.system() References: Message-ID: <83qrqt$ook$1@nnrp1.deja.com> In article , NULL at my.pc wrote: > 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()? os.system is a standard call to the C standard function call system(). It doesn't allow you to catch the output of the program like os.popen does. os.popen is piped open so that you can capture in your python scripts what the program outputs. os.system simply calls the outside program and sends it's contents to stdout which can be redirected to a file in your shell. Call os.system if your python program doesn't need to capture anything from your outside program. charlie Sent via Deja.com http://www.deja.com/ Before you buy. From jhefferon at my-deja.com Wed Dec 15 12:28:07 1999 From: jhefferon at my-deja.com (jhefferon at my-deja.com) Date: Wed, 15 Dec 1999 17:28:07 GMT Subject: newbie : books on python References: <6D8A17398E28D3119F860090274DD7DB4B3D37@pces.cadlab.it> Message-ID: <838j2u$9qn$1@nnrp1.deja.com> In article <6D8A17398E28D3119F860090274DD7DB4B3D37 at pces.cadlab.it>, Alex Martelli wrote: ... talking about _Programming Python_ (the O'Reilly book) > OTOH, I'd give a miss, if I were you -- I found it chaotic to the > point that it turned me off Python for a while, and when I mentioned > the fact recently on this list/newsgroup, most respondents seemed > to agree with this evaluation. I also find this book enraging, not so much to read (although the incessant Python pom-pom waving *is* tedious) as to refer to. The editor who allowed an author to start in the middle --- the Tutorial is an appendix at the back of the book --- should be slapped silly. And material isn't necessarily located near other material to which it relates. And the index is ... disappointing. Etc. However, it *is* comprehensive, in the sense that you would have to be quite advanced before you got beyond this book. I do find that when I'm stuck it is the book in which I eventually find the answer. Jim Hefferon Sent via Deja.com http://www.deja.com/ Before you buy. From aycock at valdes.UVic.CA Mon Dec 20 16:42:10 1999 From: aycock at valdes.UVic.CA (John Aycock) Date: 20 Dec 1999 21:42:10 GMT Subject: ANN: decompyle pre-alpha-2 Message-ID: <83m7ri$4f7c$1@uvaix7e1.comp.UVic.CA> "Decompyle" attempts to reconstruct Python source from the bytecode in a code object. The latest version (pre-alpha-2) is available at http://csr.uvic.ca/~aycock/python New in this release: support for subscripts, slices, dictionary-building, comparison, exec, del, pass, and simple forms of try/except/finally. No more extraneous commas in the output, either. John From chu at chipotle.physics.nospam.uvm.edu Fri Dec 24 15:47:56 1999 From: chu at chipotle.physics.nospam.uvm.edu (Kelvin Chu) Date: 24 Dec 1999 20:47:56 GMT Subject: Python mode on Macintosh Alpha editor? Message-ID: <840m5s$4fq0$1@swen.emba.uvm.edu> Hello, all. I am looking for Python-mode for the (Macintosh) Alpha editor. There is an existance blurb about it in the FAQ, but I haven't been able to find the code anywhere. Any help you could offer on the subject would be greatly appreciated! Cheers, happy holidays, -kc -- kelvin.chu at nospam.uvm.edu (802) 656-0064 http://www.nospam.uvm.edu/~kchu/ FAX: (802) 656-0817 From wilsher at my-deja.com Wed Dec 8 22:12:35 1999 From: wilsher at my-deja.com (wilsher at my-deja.com) Date: Thu, 09 Dec 1999 03:12:35 GMT Subject: Exposing COM via XML-RPC or Something Else References: <1267780385-12582932@hypernet.com> Message-ID: <82n6n0$8qv$1@nnrp1.deja.com> > Do you have any references or resources which I could use to aid in the > creation of an open source alternative to UDT? What would such an interface > set be called? Open Data Transfer is my personal suggestion. :) I don't know about UDT, it seems that for general COM info you probably want to check out the Mozilla XPCOM project if you haven't already: http://www.mozilla.org/projects/xpcom where XP means "cross-platform". That's right, Netscape is going to use their own implementation of COM to glue Mozilla together, on all platforms. And it is open source... --Thomas > > -- > KC5TJA/6, DM13, QRP-L #1447 > Samuel A. Falvo II > Oceanside, CA > Sent via Deja.com http://www.deja.com/ Before you buy. From evan at tokenexchange.com Wed Dec 8 11:52:46 1999 From: evan at tokenexchange.com (Evan Simpson) Date: Wed, 8 Dec 1999 10:52:46 -0600 Subject: tiny python References: <19991207174430.7096.qmail@burton-krahn.com> Message-ID: Remco Gerlich wrote in message news:slrn84rej0.uq5.scarblac-spamtrap at flits104-37.flits.rug.nl... > I'd say, it doesn't matter what you do, as long as you can use an arbitary > high level language (C or up, .pyc code counts as up), and as long as it's > *very* *small* *in total*. That's how I read his post, anyway. > > No clue how to do that, though. Forth. (that's up, right? ) Cheers, Evan @ 4-am From ionel at psy.uva.nl Fri Dec 17 11:08:10 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Fri, 17 Dec 1999 17:08:10 +0100 Subject: getattr function References: <385A1D7D.19262C62@prism.co.za> Message-ID: <83dn3r$ab1@mail.psy.uva.nl> Alwyn Schoeman wrote in message news:385A1D7D.19262C62 at 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) | Hi Alwyn, X.attr_name is simply a reference for an arbitrary object that is normally mapped by the __dict__ held by the object named X, under the name "attr_name". So, when obj is needed, the object named X is queried (by the interpreter). First, the dictionary X.__dict__ is inspected. 1. If this dict would map the string "attr_name" to any object, that object is returned as the result of the query. 2. If X.__dict__ does not have a key "attr_name", but X defines the method __getattr__, then this method is passed the attribute name, and its returned value is considered. So, the general form of __getattr__ is: def __getattr__(self, attr_name): if attr_name == 'some_name': # ... return some_value elif attr_name == 'some_other_name': # ... return some_other_value elif ... else: raise NameError, attr_name --- Note the last line. Without it, your instance will return None for any attribute name for which no proper object is defined. (Thanks to Friederich Lundh for pointing this to me.) --- In respect with your specific example, I am afraid that __getattr__ is only as smart to return the right object as you design it. __getattr__ does not know its context, it does not even assume anything the object, that you will pass it as first argument. Therefore, __getattr__ cannot know to return a sort method for your specialized class when you ask for an attribute called "sort". ionel From greg.ewing at compaq.com Tue Dec 21 10:18:11 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Wed, 22 Dec 1999 04:18:11 +1300 Subject: writing extension in C++ for MacPython References: <83ku75$9ts$1@news101.telia.com> Message-ID: <385F9A33.2C379EBA@compaq.com> Henrik Ravn wrote: > > Hi all, > > I'm trying to run an interpreter instance from a C++ program. Everything > works fine on the PC, but on the Mac I get as far as Py_Initialize() and > boink, program exit. The stand-alone Python interpreter works fine. I seem to remember having a problem like that once. I can't remember all the details, but it turned out that Py_Initialize wasn't doing everything necessary to initialise the Mac version of the interpreter. I think it had something to do with getting hold of the reference number of the application's resource fork and stashing it where the interpreter can find it. Take a look at the source of the main program for the stand-alone interpreter and find out what it does to fire up the PythonCore, then do likewise in your program. Someone should probably report this to the maintainer of Mac Python as a bug. Greg From robin at jessikat.demon.co.uk Sat Dec 18 06:35:01 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sat, 18 Dec 1999 11:35:01 +0000 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: Can someone explain in simple terms what the real advantages of XML as an intermediate language are? I understand that it's a data description language, but aren't there other more compact languages for data description? Almost all modern programming languages have some means for describing data items or objects or classes or whatever. Why don't we have a derivative of C++ or python or whatever for data description? I'm also a bit suspicious of something which M$ seems really enthusiastic about. -- Robin Becker From gmcm at hypernet.com Tue Dec 7 09:50:59 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Tue, 7 Dec 1999 09:50:59 -0500 Subject: C++ calling a Python extension module In-Reply-To: <384c396b_1@news2.one.net> Message-ID: <1267544681-26774157@hypernet.com> Jeremy Black wrote: > Is there a limitation or bug in the NT version of Python that > disallows importing python extension modules from C++? No. > I am having difficulty importing a python module from C++ that > imports a python extension module written in C. I'd guess that there's a problem in the way you've built your app. For example, you won't be able to load C extensions if you've statically linked Python to your app - you have to leave Python in a dll. You have to be very careful to get consistent settings for libraries and _DEBUG etc across all pieces. This can be a real pain, because _DEBUG will automatically cause a link to python15_d.lib (python15_d.dll) and then all C extensions will also need to be *_d.dll/pyd (and you'll need to build your own python15_d.dll and *_d.dll/pyd). With a bit of trickery, you can get your stuff built with debug, but still link to non-debug Python (so you need to use the non- debug c runtime dll). This is usually good enough. [snipped code, which is not where the problem is...] - Gordon From fredrik at pythonware.com Wed Dec 15 08:46:15 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 15 Dec 1999 14:46:15 +0100 Subject: problem with an infinite loop References: <8381in$de3@mail.psy.uva.nl> Message-ID: <007001bf4702$c2376460$f29b12c2@secret.pythonware.com> Ionel Simionescu wrote: > The code below represents an erroneous snippet that crashes Python > (1.5.2/WinNT) in a very reproductible manner. http://www.python.org/doc/FAQ.html#4.48 > Maybe this kind of error can be intercepted by the interpreter and raise an > exception. the interpreter tries, but it doesn't succeed on all platforms. if you run your sample on Linux, you get: ... long traceback snipped ... RuntimeError: Maximum recursion depth exceeded From MSteed at altiris.com Wed Dec 8 17:01:47 1999 From: MSteed at altiris.com (Mike Steed) Date: Wed, 8 Dec 1999 15:01:47 -0700 Subject: FORTRAN (was Re: indentation) Message-ID: <65118AEEFF5AD3118E8300508B124877073CC6@webmail.altiris.com> > From: aahz at netcom.com [mailto:aahz at netcom.com] > Sent: Wednesday, December 08, 1999 2:42 PM > To: python-list at python.org > Subject: FORTRAN (was Re: indentation) > > > In article <14411.53378.154350.793014 at weyr.cnri.reston.va.us>, > Fred L. Drake, Jr. wrote: > >Mark Jackson writes: > >> > >> And Fortran. Don't forget Fortran. > > > > I guess I got lucky; having never learned Fortran, I don't have to > >forget it. ;-) > > 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. -- M. From paul at prescod.net Tue Dec 28 03:38:31 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 28 Dec 1999 03:38:31 -0500 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> Message-ID: <38687707.1541614C@prescod.net> "Magnus L. Hetland" wrote: > > 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 is the *unpacking* that is much, much cleaner. > > * 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? In my experience, mathematical texts refer to the elements of a tuple by symbolic names, not by numeric index: "A datatype is defined as a 3-tuple, consisting of a) a set of distinct values, called its value space, b) a set of lexical representations, called its lexical space, and c) a set of facets that characterize properties of the value space, individual values or lexical items." (not exactly a mathematical text but there aren't many of them on the web) "In this specification, a datatype is defined as a 3-tuple, consisting of a) a set of distinct values, called its value space, b) a set of lexical representations, called its lexical space, and c) a set of facets that characterize properties of the value space, individual values or lexical items. " http://www.non.com/news.answers/larch-faq.html Any author that says: "referring back to the 8th element in our tuple and its relationship to the 9th (as per our discussion of the 7th)" should be shot. > Immutable object instances? Doesn't that go against some quite basic > tenets of object oriented programming? Immutability is another interesting issue. I think that the immutability of tuples is something of a bug. If I want to change the minute in my second tuple, I should be able to do it easily. If I want to make an immutable *list* I should also be able to do that easily. Immutability should be orthogonal to data structure type. Paul Prescod From hildeb at www.stahl.bau.tu-bs.de Fri Dec 3 16:50:17 1999 From: hildeb at www.stahl.bau.tu-bs.de (Ralf Hildebrandt) Date: 3 Dec 1999 21:50:17 GMT Subject: indentation References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> <19991203211232.A11045@stopcontact.palga.uucp> Message-ID: On Fri, 3 Dec 1999 21:12:32 +0100, Gerrit Holl wrote: >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. Nothing a good editor (emacs) couldn't fix :) >For me, it's the largest reason to use Python over P**l. For me too. From bitbucket at isomedia.com Wed Dec 29 14:26:51 1999 From: bitbucket at isomedia.com (Eugene Goodrich) Date: Wed, 29 Dec 1999 19:26:51 GMT Subject: Super Tuples - foo.py (1/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: <386a607b.56004069@mail.isomedia.com> begin 644 foo.py M:6UP;W)T('1Y<&5S#0H-"F-L87-S('1U<&QI2!H=7)T(&5Y97,@;VX@=&AI%TI#0H)"69&=6YC M("AS96QF+"!U;FM.97=686PI#0H)"7)E='5R;B`H=6YK3F5W5F%L*0T*"61E M9B!?7W-T7!E("AU;FM686PI(#T] M('1Y<&5S+DEN=%1Y<&4Z#0H)"75N:U9A;"`]('5N:U9A;"`J(#,N,30U#0H) M96QS93H-"@D)=6YK5F%L(#T@=6YK5F%L("L@)R$G#0H);R!;:4-O=6YT97)= M(#T@=6YK5F%L#0IP <007a01bf46e2$36d5aeb0$f29b12c2@secret.pythonware.com> Message-ID: <3857BD75.E39F1880@interet.com> Fredrik Lundh wrote: > what happens if you try to import the _imaging module > from the interpreter prompt: > > >>> import _imaging PIL requires the presence of several other DLL's, namely tcl80.dll, tclpip80.dll and tk80.dll. Be sure you have those. Jim Ahlstrom From af137 at torfree.net Sun Dec 19 04:17:28 1999 From: af137 at torfree.net (Al Aab) Date: Sun, 19 Dec 1999 09:17:28 GMT Subject: . pythondx Message-ID: for native dos : any1 knows how to exit, control-z suspend, leaving 49 k in ram. another problem : the pythondx full version, has a static cursor (the lite-version's cursor is ok. ) -- =-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- al aab, ex seders moderator sed u soon it is not zat we do not see the s o l u t i o n -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+ From tvn at om.od.ua Thu Dec 16 17:26:58 1999 From: tvn at om.od.ua (Vladimir Trosin) Date: Fri, 17 Dec 1999 01:26:58 +0300 Subject: We work for you to have a rest!!! Message-ID: <38596732.36D189D1@om.od.ua> --------------------New! New! New!-------------------- Visit our site "The Pearl of the Black Sea coast"! Here you can get the full information about your trip to Ukraine, Odessa where you can have a wonderful rest and enjoy your time to the fullest as well as to meet ere your second half, a woman of your dream. We work for you to have a rest!!! Visit our site http://www.pearl.od.ua mailto:tvn at om.od.ua mailto:info at pearl.od.ua ------------------------------------------------------ From cfollett at gac.edu Mon Dec 13 22:15:59 1999 From: cfollett at gac.edu (Charles Follett) Date: Mon, 13 Dec 1999 21:15:59 -0600 Subject: socket.makefile() question Message-ID: <199912140315.VAA14303@giant-curled.mcs.gac.edu> 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 #!/usr/bin/python import sys from socket import * from threading import * HOST = '' #localhost PORT = 5555 class server: def __init__(self): self.lastmsg = 'generic message\n' self.msgsp = Semaphore() s = socket(AF_INET, SOCK_STREAM) s.bind(HOST, PORT) s.listen(5) #buffer up to 5 connections print 'server bound and listening..' self.loop(s) def loop(self, s): conn, addr = s.accept() print addr, 'connected..' client_thread = Thread(None,self.service,None,(conn,s),{}) client_thread.start() print 'starting', client_thread.getName() self.loop(s) def service(self, conn, s): wf = s.makefile('wb') rf = s.makefile('rb') wf.write(self.lastmsg) wf.flush() data = rf.read() self.msgsp.acquire() self.lastmsg = data self.msgsp.release() conn.close() if __name__=='__main__': try: s = server() except KeyboardInterrupt: sys.exit() From fstajano at uk.research.att.com Tue Dec 7 15:05:19 1999 From: fstajano at uk.research.att.com (Frank Stajano) Date: Tue, 07 Dec 1999 20:05:19 +0000 Subject: IPC8 tutorials material In-Reply-To: <14404.12876.847116.288848@anthem.cnri.reston.va.us> Message-ID: <4.2.0.58.19991207195935.00c02d10@mailhost.uk.research.att.com> 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 wording on the web site, or at least be generous with the print runs so that a similar "remainders sale" can be run this year too. Frank (http://i.am/filologo.disneyano/) http://www.uk.research.att.com/~fms/ From aahz at netcom.com Wed Dec 29 14:09:40 1999 From: aahz at netcom.com (Aahz Maruch) Date: 29 Dec 1999 19:09:40 GMT Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <38693e89.14008172@news.isomedia.com> <386A1037.C6D458B3@prescod.net> <386a43e3.48679477@news.isomedia.com> Message-ID: <84dm9k$9aj$1@nntp6.atl.mindspring.net> In article <386a43e3.48679477 at news.isomedia.com>, 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) That's probably a good idea, but you skipped the __getslice__ method. (As mentioned in another post in this thread.) -- --- 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 boncelet at udel.edu Thu Dec 16 05:42:46 1999 From: boncelet at udel.edu (Charles Boncelet) Date: Thu, 16 Dec 1999 10:42:46 +0000 Subject: Python complaints References: Message-ID: <3858C226.949FC9C6@udel.edu> Previously, I suggested "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?)" And many people rightly beat me up on this (especially on my suggestion that "len" should change--I didn't really mean it should undergo a non-backward-compatible change, but my argument wasn't worded as precisely as it should have been.) However, let me clarify further (as I have only been using Python for a few months, my thoughts and impressions are still forming): I am having a hard time figuring out the philosophy behind types and typing in Python. Even though I can't declare the type returned by a function or the type of its arguments, Python is very picky about the types involved. If I call a function with the wrong type arguments, I (usually) get a failure of one sort or another. E.g., len(5), math.sin([1,2,3]) both fail, although I think both should succeed. Numeric.sin([1,2,3]) succeeds. However there is nothing in the function declaration that specifies the type of its arguments. In many cases, the way one finds out what types are allowed is by experimentation: call the function and see if you get an error. E.g., the doc string for math.sin is "sin(x) return the sine of x". Nowhere does it tell me that "x" should be a number, not a list. What kind of number is allowed? Can x be an integer, a float, complex, long, hex? There is no way to know, without doing the experiment. BTW, experimentation indicates that it fails if x is complex and works for the others. sin seems to be promoting its argument to a float and taking the sine. However, sin(complex) is a perfectly good mathematical operation. It should work. (I am using math.sin(x) as an example of the confusion, not because I need this specific function. Numeric.sin(x) is clearly better written than math.sin(x).) If Python is a typeless language, then shouldn't all functions make a reasonable effort at promotion to try to do something reasonable? (E.g., the Numeric ufuncs generally do this correctly.) 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)? Sorry for the length, but I'm just trying to figure this stuff out. -- Charles Boncelet University of Delaware Newark DE 19716 USA http://www.eecis.udel.edu/~boncelet/ From quinn at pyro.ugcs.caltech.edu Fri Dec 3 22:37:07 1999 From: quinn at pyro.ugcs.caltech.edu (Quinn Dunkan) Date: 4 Dec 1999 03:37:07 GMT Subject: object defaults Message-ID: I'm trying to set up a system where objects can initialize their attributes via one of three methods: explicitly at instantiation: sphere.texture.pigment = Pigment(color=red) otherwise via an Xresource-like preferences database: defaults['Sphere.Texture.Pigment.color'] = red s = Sphere() otherwise via the class's default, in its __init__ method. The tricky bit is the second one, since if a Pigment is initializing itself it has to figure out that it's the Pigment of a Texture of a Sphere, and not pick up defaults for Plane.Texture.Pigment.* What I did was write a function that works its way up the stack, picking out methods, and then joins together the __class__.__name__ attrs of the self args of those methods. This works, but not that well: Apparently there's no way to figure out if something is a From claird at starbase.neosoft.com Thu Dec 2 09:00:02 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 2 Dec 1999 14:00:02 GMT Subject: russian e-zine seeks a python co-editor References: <3845DB79.531EAAE7@kawo2.rwth-aachen.de> Message-ID: <119470ED02B7AC92.ABE39277F0475D2A.CA827DBFBB748AB8@lp.airnews.net> In article <3845DB79.531EAAE7 at kawo2.rwth-aachen.de>, Alex Farber wrote: >If you don't speak Russian, please skip this posting. > >Do you regularly read comp.lang.python? Do you like the idea >of a non-commercial Russian-language e-zine for developers? >The "Pref News" e-zine, located at http://simplex.ru/news/ >is dedicated to Perl, UNIX and database programming. Currently >maintained by two people it provides links to articles and >tutorials, interesting code snippets found in newsgroups. > >We are looking for some Python enthusiast, who would post >interesting links and maybe digests from this newsgroup. > >It won't take you much time - already 20 minutes a week >would be a helpful contribution. Please contact me. . . . 1. I used to know enough Russian to get around the streets of Leningrad--oops! I guess you can tell how long ago that was. I've never read it successfully on-line; I suppose I'd have to diddle my code base (?) or somesuch to display cyrillic. 2. I'd like to help. 3. My calendar is jammed, already. 4. I manage "Python-URL!" . At the very least, I'd think your e-zine would want to link to and/or translate these weekly digests. -- Cameron Laird http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From jcw at equi4.com Thu Dec 23 11:01:06 1999 From: jcw at equi4.com (Jean-Claude Wippler) Date: Thu, 23 Dec 1999 17:01:06 +0100 Subject: Multi-User non Client/Server database References: <7DE1F51DE6EF8DE2.FEF18A6AB6E94830.57F6A00E6C02B0D3@lp.airnews.net> Message-ID: <3862473B.E8133933@equi4.com> piet at cs.uu.nl wrote: > > >>>>> claird at starbase.neosoft.com (Cameron Laird) (CL) writes: > CL> You'll want to read the recent MetaKit announcement > CL> . MetaKit > CL> plays 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. Those two statements are not mutually-exclusive. At the file-locking level, locking works fine. -jcw From thomas at bibsyst.no Tue Dec 21 11:34:53 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Tue, 21 Dec 1999 17:34:53 +0100 Subject: Very Stupid Newbie Question Regarding Databases References: <83jr9s$tco$1@nnrp1.deja.com> Message-ID: <385FAC2D.F8CF4A1@bibsyst.no> 55wgm_guy at my-deja.com wrote: > > Okay, Im obviously new to the Python world, but I have a project Im > working on that will require databases. In particular, I want to store > multiple records in the format: > > Name: > Email: > Phone Number: > (etc) > > Im starting to look at the gdbm, dbm, and anydbm modules. However, it > seems to me that to store records in the above format would require > some sort of key to retrieve a particular record. How can the *dbm > modules do this? > > Sent via Deja.com http://www.deja.com/ > Before you buy. You could create an object too, like this : class person_record(name, email, phone): def __init__(self, name, email, phone): self.name = name self.email = email self.phone = phone to store them in a database, use shelve: import shelve db = shelve.open('database','cw') person = person_record("thomas","thomas at bibsyst.no","1-800-Python") to store by a persons name : db["thomas"] = person or by phone : db["1-800-python"] person db.close() From gerrit.holl at pobox.com Sat Dec 11 03:33:54 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 11 Dec 1999 09:33:54 +0100 Subject: some random reflections of a "Python newbie": (1) books, and free sites In-Reply-To: ; from grant@nowhere.pobox.com on Fri, Dec 10, 1999 at 02:52:37PM +0000 References: <82o0to$6eq$1@serv1.iunet.it> <82pcm0$p6t$1@nnrp1.deja.com> Message-ID: <19991211093354.A1583@stopcontact.palga.uucp> Grant Edwards wrote: > In article <82pcm0$p6t$1 at nnrp1.deja.com>, Preston Landers wrote: > >"Programming Python" indeed sucks. I agree. But what about "Internet programming with Python"? regards, Gerrit. -- "The world is beating a path to our door" -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates) 9:33am up 25 min, 3 users, load average: 0.00, 0.02, 0.09 From invalid.address at do.not.email Fri Dec 3 13:19:48 1999 From: invalid.address at do.not.email (guppy) Date: Fri, 03 Dec 1999 18:19:48 GMT Subject: Unreal Tournament>>To Use Python?! Message-ID: <384808f3.3299668@news.telus.net> Python is being considered for use as the new and improved Unreal Tournament scripting language. http://unreal.epicgames.com/ In the announcements listing. Now, I'm thinking it'd be right good to help ol' Tim Sweeney make the right choice, so howzabout the true Gurus get some EMail to him helping him understand that he's on the right track! The likely scenario is that the scripting language he creates could be *based* on Python in significant ways. That's bound to help grow our community. From tescoil at rtpro.net Mon Dec 13 02:27:47 1999 From: tescoil at rtpro.net (Tesla Coil) Date: Mon, 13 Dec 1999 08:27:47 +0100 Subject: time.time and again. Message-ID: <38549FF3.6AC95592@rtpro.net> Very new to Python and wondering if there's a function like UN*X at(1) hidden away in a module, or if it would need written from scratch. I know there's time.sleep(), but looking for something more like "do this at 13:45." From gmcm at hypernet.com Wed Dec 22 09:54:48 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Wed, 22 Dec 1999 09:54:48 -0500 Subject: Bad programming style? In-Reply-To: Message-ID: <1266248895-25496517@hypernet.com> Sposhua wrote: > 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. You can do it and you probably shouldn't. The problem is referencing it. How do you know what name to reference? If it hasn't been created, you'll get a NameError. You probably should use a dictionary (namespaces in Python are dictionaries anyway(*)). That gives you syntax for looking for a non-existant name without taking a NameError, and an easy way to list out all the names you've created. myvars = {} if myvars.has_key('spam'): ... value = myvars.get('spam', None) #None if doesn't exist for var in myvars.keys(): ... (*) The "locals" namespace is conceptually a dictionary, but gets optimized into something else. You can use a dummy class for syntactic sugar: class Dummy: pass myvars = Dummy() myvars.spam = 'eggs' if hasattr(myvars, 'spam'): ... for var in dir(myvars): Be wary of "trying" too hard to do something dynamic. Python usually has a very direct way of doing it. - Gordon From nt_me at my-deja.com Wed Dec 1 14:29:48 1999 From: nt_me at my-deja.com (nt_me at my-deja.com) Date: Wed, 01 Dec 1999 19:29:48 GMT Subject: FITS file question Message-ID: <823sv5$qm3$1@nnrp1.deja.com> How can FITS file images be displayed using Python? For example can it be done using image or PhotoImage? Thanks ahead. Sent via Deja.com http://www.deja.com/ Before you buy. From gerrit.holl at pobox.com Thu Dec 23 05:09:11 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 23 Dec 1999 11:09:11 +0100 Subject: httplib vs. urllib In-Reply-To: <3861C050.E8EAD05@murl.com>; from jkraai@murl.com on Thu, Dec 23, 1999 at 12:25:20AM -0600 References: <3861C050.E8EAD05@murl.com> Message-ID: <19991223110911.A2110@stopcontact.palga.uucp> jim kraai wrote: > Why is the output of: > python httplib.py www.ni.dk > > so _vastly_ different than the output of: > python urllib http://www.ni.dk > > This has me _completely_ stumped. Because of virtual hosts. Some servers have multiple "virtual hosts". For example, if you go to ni.dk, you'll see something else than when you go to www.ni.dk. But it's the same server. That's because your browser gives a 'host' header: Host: www.ni.dk The server returns another page when you give that header. httplib.py doesn't give that header, urllib.py, which is on a higher level, does give that header. regards, Gerrit. -- "If a machine couldn't run a free operating system, we got rid of it." -- Richard Stallman (Open Sources, 1999 O'Reilly and Associates) 11:07am up 25 min, 12 users, load average: 0.00, 0.03, 0.13 From mgushee at havenrock.com Wed Dec 22 20:55:29 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 22 Dec 1999 20:55:29 -0500 Subject: First Tkinter application. Comments please? References: <19991220220520.A7846@stopcontact.palga.uucp> Message-ID: Gerrit Holl writes: > I just created my first Tkinter.Canvas application. Hey, that's fun! Next you can do a Python version of the classic Breakout game :-) > class App: ... > def __init__(self, root): ... > self.root = root My preference would be subclass App from Tk, but I'm not sure it's necessarily better. There are probably arguments on both sides. > self.root.mainloop() Usually not a good idea to do this in your __init__ method. See below. > # What's better: this, or binding and ignoring everything > # that's not a keycode of one of these? One or the other, depending on what you're trying to do ;-) You seem to have mixed the two approaches, so that you're recognizing each keystroke twice -- once to invoke the bindings, and again within move_it(). Which is better in any given application depends on a number of factors, such as: * How many keystrokes you use, and how you use them (e.g. if you were making a text editor, you would want your keybindings to be as specific as possible, to avoid invoking event handlers when you're just typing text -- whereas in, say, a game, you can assume that any keypress is intended to execute some code) * How much code is shared between the different keystroke actions. Of course, as you probably know, in a program of this size it really doesn't make much difference. > def move_it(self, *args): A conventional way of doing this is def move_it(self, event=None): AFAIK you will only ever get one argument other than self, which is the event info object. And calling it 'event' makes the code easier to understand. Continuing: if event is not None: if event.keycode == UP: self.draw.move("it", 0, -1) elif event.keycode == DOWN: self.draw.move("it", 0, 1) elif event.keycode == RIGHT: self.draw.move("it", 1, 0) elif event.keycode == LEFT: self.draw.move("it", -1, 0) > App(Tk()) Have you noticed how many Python modules (the well-structured ones) have a section at the end like: if __name__ == '__main__': spam = DeadParrot() siss(boom(bah())) ? My version of your app would have: if __name__ == 'main': ## detects that this module is being run as a ## stand-alone script. spam = App() ## App being a subclass of Tk spam.mainloop() This way, you have a portable class definition which can be imported into another app without trying to mainloop() itself -- because main windows should normally be created at the application level -- or you can import it into the Python shell and experiment with the window interactively -- but when you run this file as a script, it gives you a nice little demo. Hope that's not too much criticism. I like your concepts a lot! -- Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ From hat at se-46.wpa.wtb.tue.nl Mon Dec 20 11:29:24 1999 From: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) Date: 20 Dec 1999 16:29:24 GMT Subject: List comprehensions References: <38592275.BBA2B61A@maxtal.com.au> <385E045D.9EC36473@compaq.com> Message-ID: On 20 Dec 1999 15:28:28 +0100, Magnus L. Hetland wrote: >Greg Ewing writes: > >> 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 While on this subject, we introduced these things in our specification language a few years back, and it was a huge success. We even decided to drop support for the `normal' map & filter functions. It might be nice to show our approach here. We use [ res-expr | iter-list ] with iter-list :== iter-expr | iter-list , iter-expr iter-expr :== bool-expr | var <- expr where res-expr is some expression (and the resulting type of the entire comprehension is a list of the type of that expression), bool-expr is a boolean expression, var <- expr is a mathematical-like notation for the 'for' construct Semantics are defined (I can send you a definition if you like). In tis forum, they are best explained with an example: xs := [ 1,2,3,4,5 ] print [ (x,y) | x <- xs, x>3, y <- xs, y>x ] means result = [] for x in xs: if x>3: for y in xs: if y>x: result=result+[ (x,y) ] print result in other words, iter-expressions are nested in each other. Our experience is that it is quite easy to explain what it means, and it gets used quite a lot (unlike those map() and filter() functions, which most of our users did not understand). For sets, we have a similar notation (the surrounding [ and ] become { and }, and all lists (eg xs and ys) must be sets). The latter restriction is mainly to force users to think about the structure of their data rather than just construct something without thinking. >Have you looked into adding separators (like "and") between the >iterators yet? (You *did* see that as a possibility, didn't you?) We considered that as well, but we decided against it. Reason is mainly how the line looked in ASCII. The word 'and' was considered too distracting. >After all, that is what is done in math, more or less... (Either using >a logical and or a comma.) > > (Quasi-LaTeX) > P = {(x,y) | x \in X \and y \in Y} The element-sign was also considered against '<-'. The reason for not choosing the first was that you may want to test the existence of an element in a set as a boolean expression, like in [ x | x <- xs, x in yr ] (for all x from xs, test whether the element is in yr (yr is a set), and put those elements in the resulting list) If you would use 'in' for both, then there is no way to differentiate between both uses. Also, the '<-' more or less looks like pulling data from the thing at the right, so it has a nice intuitive meaning. (but our language is much more oriented towards mathematical notation than Python). [ As a side-note, if you use 'and' as seperator, then you run into similar trouble, although much more subtle. Is 'x>5 and y<4' one expression, or 2 seperated by 'and' ? Here, you won't get bitten, because the meaning of and corresponds with the meaning of the seperator. ] >Hm... Do the iterators work in parallel? Or would I end up with a 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. Also, I'd like to get rid of fold(). For example, how would you write an expression which calculates the sum of all elements (or the sum of all elements which hold for some special condition ?) The same problem exists with finding the maximum element in a list. >could the version with "and" mean, then? Since it is a bit more I'd rather write that in a single for loop, like for (x,y) in (X,Y): (but this means something completely different :-) ) >(Or am I just confused here?) Not imho. Albert --- Look ma, windows without Windows !! From paul at prescod.net Thu Dec 30 04:44:28 1999 From: paul at prescod.net (Paul Prescod) Date: Thu, 30 Dec 1999 04:44:28 -0500 Subject: Super Tuples - foo.py (1/1) References: <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <386A1037.C6D458B3@prescod.net> <386a43e3.48679477@news.isomedia.com> <386a607b.56004069@mail.isomedia.com> Message-ID: <386B297C.B152C01A@prescod.net> Eugene Goodrich wrote: > > import types > > class tuplish: > def __init__ (self): > .... Here's a hint: if you think you need exec to handle a problem, there is probably a Python feature that will do the same thing without exec. In this case I think you are looking for setattr and getattr. You should also know that Python has no problem with inline function definitions. Paul Prescod From worldwin at liii.com Fri Dec 17 01:31:18 1999 From: worldwin at liii.com (dj trombley) Date: Fri, 17 Dec 1999 06:31:18 GMT Subject: Help finding Matt Conyway's tutorial References: <38436A58.98FEA03@pivot.net> Message-ID: <3859D837.EF7AAE81@liii.com> Wayne wrote: > > Hi, > I'm trying to find an address for Matt Conway. I understand he has > a tutorial called "A Tkinter Life Preserver" that I would like to > down load. If there is any other tutorial out there that someone > can point me to I be happy for the info. > TIA. > Wayne http://python.org/doc/life-preserver/index.html -dj From kclark at ntlug.org Thu Dec 16 11:19:45 1999 From: kclark at ntlug.org (Kendall Clark) Date: Thu, 16 Dec 1999 10:19:45 -0600 (CST) Subject: RFC: Implementing ECS in Python Message-ID: <14425.4385.984935.767038@cmpu.net> All, I'm planning a free software implementation of Apache's ECS (Element Construction Set) in Python. You can find ECS at With ECS you can programmatically build XML, HTML4 and RTF structured documents in an OOP way. There isn't really anything in Python that is similarly comprehensive or up-to-date. HTMLgen is nice, but it's getting a bit dated and it has some bugs in spots (and it's just HTML, not XML or RTF). If you're interested in working on this project, please send me an email at kclark at ntlug.org. I will start a mailing list and a Web page if enough people are interested in working on this. Best, Kendall Clark -- For a man cannot expect to make money out of the community and to receive honor as well. --Aristotle, Nicomachean Ethics From grant at nowhere. Tue Dec 7 16:35:46 1999 From: grant at nowhere. (Grant Edwards) Date: Tue, 07 Dec 1999 21:35:46 GMT Subject: Need python mode for Jed References: <384D5F1D.C1F2CE6E@corrada.com> <384D7FC8.5409433A@corrada.com> Message-ID: In article <384D7FC8.5409433A at corrada.com>, andres wrote: >Grant Edwards wrote: > >> 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. > >I seem to remember someone (Tim Peters?) posting recently that there is >an option at deja.com that allows postings to be presented in their >original usenet format. Help anyone? I tried switchingto "original usenet mode" before saving -- there were still a bunch of lines that were wrapped, and I think there were problems involving curly braces also, but I didn't spend a lot of time trying to fix up the file. -- Grant Edwards grante Yow! Then, it's off to at RED CHINA!! visi.com From cfelling at iae.nl Mon Dec 27 18:21:56 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 28 Dec 1999 00:21:56 +0100 Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> <19991227235513.A917@Ridcully.home> Message-ID: <848sak$1a2$1@vvs.superst.iae.nl> 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 From jamarijr at hotmail.com Fri Dec 31 08:37:18 1999 From: jamarijr at hotmail.com (Arinte) Date: Fri, 31 Dec 1999 13:37:18 GMT Subject: No constructor calls? Message-ID: <84iasi$bdd$1@nnrp1.deja.com> When I have this code the constructor is called xpac=PossDevice.PossArg("12345678",21) devlist.append( xpac ) but, this code doesn't seem to function devlist.append( PossDevice.PossArg("12345678",21) ) Is the second one invalid or something? How can I do the first one in one call? TIA Sent via Deja.com http://www.deja.com/ Before you buy. From thantos at chancel.org Tue Dec 21 22:58:16 1999 From: thantos at chancel.org (Alexander Williams) Date: Wed, 22 Dec 1999 03:58:16 GMT Subject: List comprehensions References: <38592275.BBA2B61A@maxtal.com.au> <385E045D.9EC36473@compaq.com> Message-ID: On 21 Dec 1999 17:21:27 GMT, Albert Hofkamp wrote: >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 > > Hmmm, am I to assume that the *[] syntax causes it to return a curried function that takes a list of things as its argument and returns a list of things as its result? If so, then your while example in Python there is a bit flawed ... >>> def transformer(x): >>> if x==0: >>> return None >>> elif x<0: >>> return x+2 >>> else return x-3 >>> >>> filter(None, >>> map(transformer, inputList)) Note that I put in the filter to catch the cases when transformer() returns None when x is 0. Its not really as pretty as your syntax, no, but that's why List Comprehensions are so appealing to the Pythonic crowd: we're pretty-obsessive. :) Now, if only we could get automatic currying ... :) >and parallel, you get > [ (1,3), (2,4) ] Oooh, you want to zip them together; that's a different thing altogether (and not really something I see Comprehensions as being necessary for). In the case above you'd have: >>> zip(xs, ys) ... and get exactly the list you wanted; once you have zipped lists together, you can then feed them to a Comprehension. (And, if you wanted to do it without adding anything to Python, you can do: >>> map(None, xs, ys) ... which is a perfectly valid use for map (and a good reason to keep it around).) >> 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. Works in Python, though (or it will, once we have Comprehensions in place ... wonder if I can push for infinite lists, too? ...) :) >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. We can lay this at the feet of the rather kludgy lambda abstractionin Python; much as I love lambda, sometimes you need more *power*. Secondary to that thought, however, is the idea that a wholly seperate function can make the intent of that piece of code clearer. > [ x+3 | y <- ys, z <- zs, y>z, x <- xs, y+z >and define separate functions for each level. >(anyone care to do this with map and filter ?) Let's see ... Not really easily with map and filter, because quite honestly they're intended to be soley parallel iterators (fulfilling what you asked for above), but in basic Python, you have: >>> xs = range(1, 11) >>> ys = range(1, 11) >>> zs = range(1, 11) >>> >>> retList = [] >>> >>> for x in xs: >>> for y in ys: >>> for z in zs: >>> if (y>z) and ((y+z)>> retList.append(x+3) I needed to give myself some xs and ys to work on, and the fact that Python and Haskell's range(n, m) and [n..m] iterators function differently at the end of the range threw me for a bit. Hard to get brains to shift gears. Does the List Comprehension version look nicer? Undoubtedly. Interestingly, though, with a wee bit of juggling, its structure looks very similar, like so: Haskell: >>> retList = [x+3 | y <- ys, >>> z <- zs, y>z, >>> x <- xs, y+z>> for y in ys: >>> for z in zs: >>> if y>z: >>> for x in xs: >>> if (y+z)>> retList.append(x+3) Interestingly, they have the same structure in both the list expansions and the tests. My own intuitive feeling is that a List Comprehension should return a /list/ (even if its an empty list or a singleton list), while if you want a single value to emerge, you need a function. Now, this begs the question of those times a list /is/ the value and when its a list of values ... -- 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 alex at magenta.com Thu Dec 30 03:04:54 1999 From: alex at magenta.com (Alex Martelli) Date: Thu, 30 Dec 1999 09:04:54 +0100 Subject: Before I go with python ... References: <385C20B4.87FACEED@esoterica.pt> <386A9D6C.29B5D541@starmedia.net> Message-ID: <005b01bf529d$34b84d60$c02b2bc1@martelli> Andrew Csillag writes: > > Is it possible to have assynchronous I/O, > > for example continuing a program while > > another task is wainting on a socket? > > > > How is taht achieved? Multithread? Just > > a call after the socket has data? > > > Your choice. Python can do threads, and if you are on Unix (maybe > windows, but I don't know) you can also use the select module. With the Python threads do work on Windows (with the standard distribution), and select too, but the latter, I believe, only on sockets (not files &c). 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). Alex From fdrake at acm.org Thu Dec 16 11:27:21 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 16 Dec 1999 11:27:21 -0500 (EST) Subject: Python complaints In-Reply-To: <3858C226.949FC9C6@udel.edu> References: <3858C226.949FC9C6@udel.edu> Message-ID: <14425.4841.291880.269618@weyr.cnri.reston.va.us> Charles Boncelet writes: > If I call a function with the wrong type arguments, I (usually) get > a failure of one sort or another. E.g., len(5), math.sin([1,2,3]) > both fail, although I think both should succeed. Numeric.sin([1,2,3]) > succeeds. Charles, Unless a programmer is specifically intersted in numeric processing, why should math.sin() work on a list? In the general case, there's *nothing* to indicate that a list should be processed as a mathematical construct. This is a specialized interpretation, and it makes sense to use a specialized function to handle it (which is an important aspect of why NumPy exists). > What kind of number is allowed? Can x be an integer, a float, complex, > long, hex? There is no way to know, without doing the experiment. > BTW, experimentation indicates that it fails if x is complex and works > for the others. sin seems to be promoting its argument to a float and > taking the sine. However, sin(complex) is a perfectly good mathematical > operation. It should work. The issue with complex numbers and the math module is real, and the documentation isn't terribly clear. There is some discussion in the documentation for the cmath module regarding the behavior; I've added a bit of explanation to the math module documentation as well to make it easier to find the explanation. This will appear in the next documentation release. > If Python is a typeless language, then shouldn't all functions make a > reasonable effort at promotion to try to do something reasonable? (E.g., > the Numeric ufuncs generally do this correctly.) What is reasonable is in many cases domain specific, as with the case of sin([1, 2, 3]). That's why there are at least three versions available; you can choose the one that makes sense for what you're doing. > 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)? As someone else pointed out using the buffer object as an example, this doesn't always make sense. In some cases it does, and there are definately cases in which the documentation can be improved. (For the later, I always welcome specific suggestions and patches; send email python-docs at python.org!) Where it doesn't make sense, the issues range from the introduction of new types that can be interchanged with existing types in interesting way (like the buffer type) to implementing algorithms that accept a high degree of polymorphism from the input objects. For Python, that's a strength we don't want to lose! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From js at ac-copy.net Fri Dec 3 08:24:28 1999 From: js at ac-copy.net (Joachim Schmitz) Date: Fri, 3 Dec 1999 14:24:28 +0100 (CET) Subject: Python conference accomodations Message-ID: Hi, I planning to attend the conference, are there alternative (cheaper) hotels, within walking distance to the conference hotel ? Or could some give an german resident a hint, where to look ? Our travelagents here are not that familiar with the Arlington localities :-) 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 aussiepenguin at yahoo.com Thu Dec 30 22:05:32 1999 From: aussiepenguin at yahoo.com (Jeremy Lunn) Date: Fri, 31 Dec 1999 14:05:32 +1100 Subject: problem with subracting from number that I get with cgi module Message-ID: <19991231140532.A8331@dark.net> Hi, I am trying to get a number with the cgi modules like: form = cgi.FieldStorage() num = urlargs["num"].value But I can't subtract from it, when I try to do that like: newnum = num-1 I get an error like this: Traceback (innermost last): File "./numtest.py", line 9, in ? numtwo = num-1 TypeError: bad operand type(s) for - Would this mean that the number I am getting isn't really a number or what? Anyone have any ideas how I could get this to work? Thanks Jeremy -- Jeremy Lunn Melbourne, Australia ICQ: 19255837 From petro at bounty.org Mon Dec 27 11:53:51 1999 From: petro at bounty.org (Crass A. Hole) Date: 27 Dec 1999 11:53:51 EST Subject: Problem Compiling Python on OpenBSD. Message-ID: <271219990853502764%petro@bounty.org> I am trying to compile and install Python 1.5.2 from source on an OpenBSD 2.5 (uname -a= "OpenBSD loki.mysoapbox.org 2.5 GENERIC#243 i386") machine. I have installed GCC 2.95.1 and am using that as the compiler. Most of the peices parts compile just fine, but longs of things break if I try to compile the modules as shared (which is ok, I just compile them statically), and the big problem is that the socketmodule fails on "make test". It gives me a: 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... Do I also need to install the newest glibc in order for things to work properly, or is glibc just a Linux thing (most of my "Unix" experience is on Linux, with some Solaris. I've just got this one BSD box for variety and security). Is the problem with OpenBSD, or GCC? I know it isn't Python, since in builds fine on Solaris and Linux. From grant at nowhere. Thu Dec 9 11:54:52 1999 From: grant at nowhere. (Grant Edwards) Date: Thu, 09 Dec 1999 16:54:52 GMT Subject: Class definition example question References: <19991209232342.51448@nms.otc.telstra.com.au> Message-ID: In article <19991209232342.51448 at nms.otc.telstra.com.au>, Greg McFarlane wrote: >I think you could turn stdoutHandler() into a normal (private) >method and then pass it into createfilehandler, like this: > >class execWindow(Pmw.ScrolledText): > > def run(self,progPath): > ... > Tkinter.tkinter.createfilehandler(self.__child.fromchild, > Tkinter.tkinter.READABLE, > self._stdoutHandler) > > def _stdoutHandler(self, file, mask): > ... > >Or am I missing something? Nope, you're not missing something -- that works fine. For some reason the difference between the definition def stdoutHandler(self, file, mask) and the example prototype for a file handler handler(file, mask) prevented me from thinking of that (though it's the obvious thing to do now that you point it out). Thanks! I knew I was missing an obviously better way of doing that. -- Grant Edwards grante Yow! I need to discuss at BUY-BACK PROVISIONS visi.com with at least six studio SLEAZEBALLS!! From gerrit.holl at pobox.com Fri Dec 10 10:42:51 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 10 Dec 1999 16:42:51 +0100 Subject: stdout to file In-Reply-To: <82qm35$dt7$1@phys-ma.sol.co.uk>; from NULL@my.pc on Fri, Dec 10, 1999 at 10:54:34AM -0000 References: <82qm35$dt7$1@phys-ma.sol.co.uk> Message-ID: <19991210164251.A4161@stopcontact.palga.uucp> 16:39:35:1/501:gerrit at stopcontact:~$ python /usr/doc/packages/python/Tools/world/world pc Where in the world is pc? Sposhua wrote: > Right, useless newbie question here... Never useless! *you* can learn from it! > Is there any point to using: > > file = open("inquisition.txt","w") > file.write("Nobody expected it.\n") > file.close() > > ...when this seems more efficient and closer to the shell: > > import sys > sys.stout = open("inquisition.txt","w") > print "Nobody expected it.\n" > > Are there occasions to use one instead of the other? Is #2 really more > efficient? I don't think #2 is more efficient, but it's IMHO less readable. If you use #2, and one skims the code quickly, it sees "print ..." and wonders: "Why don't I see it?", but when one sees 'file.write("...")', it's much more clear. I far prefer #1. > Also, in #2, do you have to "close" stdout (and if so how, > sys.stout.close()?) and how do you reset stdout to the screen (.close() > again?). >>> sys.stdout = sys.__stdout__ You can use sys.__stdout__ for it. You can also copy sys.__stdout__, I don't know difference, a copy function for a fp is in os or os.path. > PS, I'm sending this in Outlook, which I don't know very well. Does it look > ok in Pine and other text-only mailers? Do the lines wrap at 70(ish) > characters? The lines wrap OK. regards, Gerrit. -- "The move was on to 'Free the Lizard'" -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates) 4:40pm up 1:07, 16 users, load average: 1.25, 1.26, 1.26 From ivanlan at callware.com Thu Dec 30 17:12:34 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 30 Dec 1999 15:12:34 -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> Message-ID: <386BD8D2.9B82143E@callware.com> Hi All-- "Fred L. Drake, Jr." wrote: > [snip] > > there, too), higher math with Python, Astronomy with Python, Python & > > Com, and on and on and on. ... > > I understand that calendrical calculations are big as well; is > anyone planning to write a Python book on that topic? > I could easily be persuaded. ... Having just finished Teach Yourself Python, I find myself with *oodles* of time on my hands (at least, that is, according to my wife, who is convinced that software engineers sit around in their cubes all day eating bonbons and playing mah jongg solitaire. ...), and since it's a passion of mine it might be said that I'd be the logical one. > > As Cameron already pointed out, this is not a good plan. We already > > have as much of this as we want with Redhat's distros, etc. > > 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. ... > > -ly (Note that the spelling of "curmudgeon" has been corrected.) > > y'rs, > > Ivan (and I'll have a lot of customers, too);-) > > Add "humbug!" and you'll have another! > You got it;-) Maybe I'll call it "snake-in-the-grass" ;-) -ly y'rs, Ivan * As my mother used to say, "Whatever it is I'm agin it." ---------------------------------------------- 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 tim_one at email.msn.com Wed Dec 15 05:47:54 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 15 Dec 1999 05:47:54 -0500 Subject: Tkinter/IDLE crash In-Reply-To: <007001bf46e1$535aaaa0$f29b12c2@secret.pythonware.com> Message-ID: <001101bf46e9$d7fd76e0$05a0143f@tim> [/F] > 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... I have: it's the same old thing: Tcl is confused for the same old reasons, and we trot out the same old delicate workarounds . IIRC, the "init_tcl" msg is produced by a Tcl script that lives in Tcl's static C string data and is eval'ed by Tcl at startup! It means *some* Tcl got found and is even starting, but can't find its libraries (specifially bin/tcl8.0/init.tcl). scriptics-should-study-python-for-a-day-ly y'rs - tim From hat at se-46.wpa.wtb.tue.nl Wed Dec 22 05:28:52 1999 From: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) Date: 22 Dec 1999 10:28:52 GMT Subject: List comprehensions References: Message-ID: On Wed, 22 Dec 1999 04:06:40 GMT, Alexander Williams wrote: > >>> 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. I see. It appears I have a lot of Python to learn :-) If it is that easy to construct a list of tuples, then I'd think to drop parallel iteration if only to prevent cluttering of the semantics of the list comprehension. >> [ x>6, x>5 ] >> >Easy, a two element list consisting of two Boolean values dependent on >whether or not the pre-defined value x makes said statement true. :) ROFL ! Does this lead to the conclusion that there are some syntactical problems with list comprehension ? Another matter is scoping. I hope that code like i := 30 ys := [ 4 ] xs := [ i ] + [ i+15, for i in ys ] + [ i+1 ] is well-defined. I'd like to have xs == [ 30, 19, 31 ] at the end, but I am too new to Python to say anything useful about scoping. Is this what you'd expect, and is it feasible ? Albert --- Look ma, windows without Windows !! From gvwilson at nevex.com Wed Dec 15 13:15:33 1999 From: gvwilson at nevex.com (Greg Wilson) Date: Wed, 15 Dec 1999 13:15:33 -0500 Subject: Zope project management? Message-ID: Hello. Has anyone used Zope (or other Python software) to build a project management platform? I'm looking for something like Microsoft Project, but (a) cross-platform, (b) web-enabled, and (c) Python friendly. Thanks, Greg gvwilson at nevex.com From fredrik at pythonware.com Fri Dec 17 03:36:17 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 17 Dec 1999 09:36:17 +0100 Subject: whrandom seed question References: <81eu22$411al$1@umbc7.umbc.edu> <83blvv$huh$1@nnrp1.deja.com> Message-ID: <013701bf4869$ca48fc50$f29b12c2@secret.pythonware.com> Preston Landers wrote: > 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. the source says: if 0 == x == y == z: so no matter what the official docs say, the code looks for three zeros. From darius at connect.com.au Sat Dec 25 21:22:21 1999 From: darius at connect.com.au (darius at connect.com.au) Date: 26 Dec 1999 02:22:21 GMT Subject: non-dictionary namespace? Message-ID: <843u4t$rrl$1@perki.connect.com.au> Hey all, So I'm playing around with building methods and objects and things on the fly, and I'm wondering: Why is it that I _have_ to pass a dictionary into new.function and eval as their global namespace? Why can't I pass a dictionary-like object (something that defines __getitem__ and etc calls) in, so I can trap attempts to write to the namespace and do funky things with them (like actually copy them out to somewhere permanent rather than the transient space that's built for eval() commands at the moment...)? I had a look at the sourcecode for newmodule.c and for funcobject.c, and it's all so beautifully abstracted that I can't tell off-hand whether there's a good reason for this restriction or not *grin* Anyone more knowledgeable than me in these things can help me out? TIA, KevinL --------------- qnevhf at obsu.arg.nh --------------- Kevin Littlejohn, Technical Architect, Connect.com.au Don't let the Govt censor our access to the 'net - http://www.efa.org.au/Campaigns/stop.html ---------- telnet mud.bofh.net.au 5000 ----------- From 55555 at dakotacom.net Mon Dec 13 02:07:33 1999 From: 55555 at dakotacom.net (55555) Date: 13 Dec 1999 01:07:33 -0600 Subject: Tkinter/IDLE crash References: <82pkpk$3o0$1@mirv.unsw.edu.au> <82qvui$s5t$1@nnrp1.deja.com> Message-ID: <38549b35_4@news5.newsfeeds.com> On 13 Dec 1999 01:24:36 GMT, simon at george.maths.unsw.edu.au (Simon Evans) wrote: > : 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. > ================================================================= I'm also having the same problems with tkinter and IDLE. Until they're fixed, can anyone recommend a way to catch the program before it takes the whole computer down. Rebooting every ten minutes gets pretty tiresome. I've tried encapsulating the whole program with an exception and it might help a little, but it's hard to tell. -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==---------- http://www.newsfeeds.com The Largest Usenet Servers in the World! ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==----- From mlh at vier.idi.ntnu.no Sat Dec 11 16:30:30 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 11 Dec 1999 22:30:30 +0100 Subject: lemmings References: <82j6o3$jc6$1@news.qub.ac.uk> <385113A4.1B1005F2@excite.co.uk> Message-ID: stuart mcfadden writes: > "Magnus L. Hetland" wrote: > > another interseting result is > snazzy hetland > ..... > LOL - how cool :) -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From smead at amplepower.com Sat Dec 4 14:49:03 1999 From: smead at amplepower.com (David Smead) Date: Sat, 04 Dec 99 19:49:03 GMT Subject: os.system Message-ID: 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 TIA David Smead http://www.amplepower.com. http://www.ampletech.com. From kcazabon at home.com Sat Dec 11 13:51:01 1999 From: kcazabon at home.com (Kevin Cazabon) Date: Sat, 11 Dec 1999 18:51:01 GMT Subject: How to get C and python functions into the same namespace? References: Message-ID: How about wrapping it into a class as such: class MyClass: import cmymodule, mymodule def info (self): mymodule.import() def encrypt(self): mymodule.encrypt() def open(self): cmymodule.open() ........ ?? Would that suffice? "Wojciech Zabolotny" wrote in message news:Pine.LNX.3.96.991211120613.7565A-100000 at ipebio15.ise.pw.edu.pl... > Hi All, > > I'm preparing a python extension module which is partially implemented as > in "C" (cmymodule.c), and partially in python (mymodule.py). > I'd like to have functions defined in both files in the same namespace. > Let's assume, that the functions are defined as follows: > cmymodule.c: > open, read, write, close > mymodule.py: > info, encrypt > > If I import both extensions into the user program, the functions should be > called as cmy.open(), cmy.read(),... but my.info(), my.encrypt(). > If I include the "import cmy" into mymodule.py, then syntax will be even > worse: my.cmy.open() and so on. > Due to performace reasons I don't want to add the python "wrappers" > in mymodule.py for C functions. > > How can I locate both C and python functions in the same namespace? > Please Cc the answer to my e-mail (given below). > -- > TIA > Wojciech Zabolotny > wzab at ise.pw.edu.pl > http://www.ise.pw.edu.pl/~wzab > > http://www.freedos.org Free DOS for free people! > > From michael.stroeder at inka.de Mon Dec 6 07:15:31 1999 From: michael.stroeder at inka.de (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Mon, 06 Dec 1999 13:15:31 +0100 Subject: Very useful message -- Hah! References: <82do53$2rhr$1@hub.org><384A9BE0.B345509@inka.de> <384ABC57.DDC3B61E@inka.de> <384AC1E9.F2FA90AC@mindspring.com> Message-ID: <384BA8E3.5D0A858E@inka.de> Dan Grassi wrote: > > I wish I could but some db accesses can not be made other than from the > server. http://www.zope.org/ Ciao, Michael. From news at dorb.com Wed Dec 22 21:02:04 1999 From: news at dorb.com (Darrell) Date: Wed, 22 Dec 1999 21:02:04 -0500 Subject: How to read lines from end of a file? References: <4rhfhazoj4.fsf@colargol.tihlde.hist.no> Message-ID: "Alexander Williams" in message news:slrn862rtb.732.thantos at chancel.org was concerned about maxLen and half written lines. Good idea the test for a trailing CR, added that. Maybe maxLen should be sys.maxint by default. Then paranoid or performance concerned, can tone it down from there. import sys def readLinesFromEnd(fn, maxLen=sys.maxint): """ Read lines from the end of a file up to a max number of bytes. fn:: file name to read from maxLen:: max number of bytes to read """ fp=open(fn) # seek to the end fp.seek(0,2) # seek back from the end fp.seek(-min(maxLen,fp.tell()),2) # Dump the first line # It might be chopped off lines=fp.readlines()[1:] if lines[-1][-1] != '\012': # The last line might be half written. lines=lines[:-1] return lines def main(): print readLinesFromEnd(sys.argv[1]) -- --Darrell From guido at cnri.reston.va.us Mon Dec 6 11:16:10 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 06 Dec 1999 11:16:10 -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: <5l4sdwcaet.fsf@eric.cnri.reston.va.us> Dan Grassi writes: > Well I would rather use python else I would not be here. But that has to be > balanced against it's problems when used with Apache. Dan, Perhaps I missed, it, but there is at least one systematic approach in Python that minimizes the kind of bug you ran into that made you start this thread. Python programs can be split into several modules. The trick is to have a minimal "driver" script that never changes and which imports the workhorse module; it can catch exceptions caused by syntax errors in the workhorse module just like runtime errors. See the slides for a Python/CGI course I gave at SD'99 in DC last month, at http://www.python.org/doc/essays/ppt/sd99east/. (Unfortunately the website is down at the moment with a hardware problem. We're doing our darndest to get it back up.) --Guido van Rossum (home page: http://www.python.org/~guido/) From alex at magenta.com Fri Dec 10 06:39:52 1999 From: alex at magenta.com (alex at magenta.com) Date: Fri, 10 Dec 1999 11:39:52 GMT Subject: some random reflections of a "Python newbie": (2) language issues References: <001e01bf42bd$4da0cfe0$60a2143f@tim> Message-ID: <82qoq8$nbd$1@nnrp1.deja.com> In article <001e01bf42bd$4da0cfe0$60a2143f at tim>, "Tim Peters" wrote: > [Alex Martelli] > > ... > > 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. > > "for a in X:" also works fine if X is an instance of a class that > supports the special __getitem__ method; see the docs; Doesn't __len__ need to be implemented, too? OK, I had mis-read the docs, sorry. I thought both __getitem__ and __len__ needed to be implemented, so a potentially unbound "stream" thingy couldn't really support "for a in X:"... Python's reality is indeed better than that!-) > you are not required to look at __getitem__'s index argument, and, 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. Sigh -- but, this language _is_ cool...!-) If an object, like this "rabbits", "is-an" enumerator (in the sense I think of as "being an enumerator":-), things are, indeed, fine. 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. If the object "can give out an enumerator" to itself, rather than keeping state itself for the enumeration, it would be more general/cleaner. 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): 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...?], 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...? 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...? > "if a in X:" currently works only if X is a list, tuple or string. In > Python 1.6 it's supposed to work too if X is an instance of a class > that supports the special __contains__ method; see the 1.6 docs, 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!-). My US$50 are on their way, despite the parlous situation of the Euro vis a vis the dollar...!-) Alex-the-Python-newbie Sent via Deja.com http://www.deja.com/ Before you buy. From gerrit.holl at pobox.com Thu Dec 2 14:59:32 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 2 Dec 1999 20:59:32 +0100 Subject: Email address check function In-Reply-To: <3dyabd2n9a.fsf@amarok.cnri.reston.va.us>; from akuchlin@mems-exchange.org on Thu, Dec 02, 1999 at 01:47:29PM -0500 References: <19991202163334.A3934@stopcontact.palga.uucp> <3dyabd2n9a.fsf@amarok.cnri.reston.va.us> Message-ID: <19991202205932.B8481@stopcontact.palga.uucp> Andrew M. Kuchling wrote: > Gerrit Holl writes: > > 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 '@'. > > Definitely. In _Mastering Regular Expressions_, Jeffrey Frield > derives a regular expression for matching valid RFC-822 email > addresses. Perl versions can be downloaded from > http://public.yahoo.com/~jfriedl/regex/code.html. Perl :-(... Well, I'll play with re.compile(). > The version in the PCRE test suite begins: > > /[\040\t]* # Nab whitespace. > (?: > \( # ( > [^\\\x80-\xff\n\015()] * # normal* > (?: # ( [cut] > > ... and so on, lasting for 593 lines in all. 593 lines!? I think I'll be happy with the input some faster then, the server it runs on has only 90 mHZ... > But of course you can't > verify an address like foo at bar.com without actually sending e-mail to > it and seeing if it bounces. Of course not. But people entering a wrong adres, just won't get answer. But mail with an address not matching the above, sometimes bounces. regards, Gerrit. -- "People get annoyed when you try to debug them." -- Larry Wall (Open Sources, 1999 O'Reilly and Associates) 8:57pm up 7:30, 14 users, load average: 1.30, 1.23, 1.11 From arcege at shore.net Mon Dec 6 19:10:17 1999 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 07 Dec 1999 00:10:17 GMT Subject: PyRun_File crash my application References: <82er9c$hd2$1@newsource.ihug.co.nz> Message-ID: Bing Chen wrote: : 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 ); If you didn't initialize the Python system then you could get an assertion (Fatal Python error: PyThreadState_Get: no current thread). Insert a call to "Py_Initialize();" before you call any Python/C API functions. (Also, I assume the "#..." comment is not part of your C code ;) -Arcege http://www.python.org/doc/current/api/initialization.html From sposhua at my.pc Mon Dec 20 08:58:39 1999 From: sposhua at my.pc (Sposhua) Date: Mon, 20 Dec 1999 13:58:39 +0000 Subject: Redirecting stderror to a browser Message-ID: Newbie here, slowly consuming a large book but I need to know this now... Using Python 4 CGI, I'd like to redirect the errors to the browser window, so I get meaningfull errors rather than the typical "500 Internal server error". I guess I could redirect it to a file, but seing immediately on the browser would be much faster to work with. Cheers From Alex.Martelli at think3.com Wed Dec 15 11:36:14 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Wed, 15 Dec 1999 17:36:14 +0100 Subject: Python complaints Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D45@pces.cadlab.it> > Mike Fletcher 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?) Consider, > Isn't "len" one such "obvious reason"...? > >>> 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. > But what about len([1, "hello", 2, "foo", 3])? I want it to return 5, as it does now. If it gives me [0. 5. 0. 3. 0] (or however else it encodes the "length" of a scalar number) how do I find out that it just gave me 5 elements, which is all I care about? Do I hear a suggestion to call len on the result...?-) Alex From fdrake at acm.org Tue Dec 21 15:36:02 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 21 Dec 1999 15:36:02 -0500 (EST) Subject: Arg! (Makefile.pre.in) In-Reply-To: References: <14431.56728.357282.276777@weyr.cnri.reston.va.us> Message-ID: <14431.58546.940849.802614@weyr.cnri.reston.va.us> Magnus L. Hetland writes: > Setup.in contains: > > *shared* > spam spamodule.c Should that be spammodule.c? (Note the second "m".) > make: *** No rule to make target `spamodule.c', needed by `spamodule.o'. Stop This sounds like what appears to the typo I noted above. > Browsing the Makefile.pre.in it seems that it has the wrong value for, > among other things, the installdir. So, I try: 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. > make spammodule > > I get all kinds of errors about undefined symbols (suggesting some > linking problem): > > gcc -g -O2 -I/store/include/python1.5 -I/store/include/python1.5 > -DHAVE_CONFIG_H spammodule.c -o spammodule > Undefined first referenced > symbol in file > Py_InitModule4 /var/tmp/cczDaaxu1.o > Py_BuildValue /var/tmp/cczDaaxu1.o > PyArg_ParseTuple /var/tmp/cczDaaxu1.o > main /store/lib/gcc-lib/sparc-sun-solaris2/2.8.1/crt1.o > ld: fatal: Symbol referencing errors. No output written to spammodule The gcc command line is not good. There should be a "-c" on there somewhere; 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!). > I *do* include Python.h... The doesn't seem to have any relation to the source code; it's all build control. > Well - it is always difficult to provide information when one has no > clue as to what the problem might be, as one does not know what is > relevant... 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". ;) > 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 -- Fred L. Drake, Jr. Corporation for National Research Initiatives From mhammond at skippinet.com.au Tue Dec 21 19:07:20 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 22 Dec 1999 00:07:20 GMT Subject: Sydney scoreboard? References: <385DB48C.7A7A52D6@bby.com.au> <8On74.6414$Dh3.85256@ozemail.com.au> Message-ID: "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 wtopa at dmcom.net Fri Dec 10 21:21:28 1999 From: wtopa at dmcom.net (Wayne Topa) Date: Fri, 10 Dec 1999 21:21:28 -0500 Subject: Error confusing a newbie In-Reply-To: <385134EA.7D3281BB@lemburg.com>; from M.-A. Lemburg on Fri, Dec 10, 1999 at 06:14:18PM +0100 References: <19991210100320.B18389@dmcom.net> <385134EA.7D3281BB@lemburg.com> Message-ID: <19991210212128.D17533@dmcom.net> Subject: Re: Error confusing a newbie Date: Fri, Dec 10, 1999 at 06:14:18PM +0100 In reply to:M.-A. Lemburg Quoting M.-A. Lemburg(mal at lemburg.com): >| >| 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, No, I don't think taht is it. I have converted other p__l scripts using the same "#!/usr/bin/env python" and they all work as expected. That is why I think is has something to do with DateTime, but I camn't think of what it could be? 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 >>> Thanks fot the tip tho. Wayne -- "... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs." -- Robert Firth _______________________________________________________ From gerrit.holl at pobox.com Wed Dec 22 09:27:53 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 22 Dec 1999 15:27:53 +0100 Subject: os.popen() vs os.system() In-Reply-To: ; from sposhua@my.pc on Wed, Dec 22, 1999 at 01:41:39PM +0000 References: <19991222120612.B3554@stopcontact.palga.uucp> Message-ID: <19991222152753.A10549@stopcontact.palga.uucp> Sposhua wrote: > On Wed, 22 Dec 1999, Gerrit Holl wrote: > > > Sposhua wrote: > > > a) popen automatically starts a new process while system only does it if you > > > include an & > > > > Not true: > > >>> os.getpid() > > 3264 > > >>> os.system("echo $$") > > 3658 > > !? You are replying to a newbie here ;-) Didn't quite understand the answer... Sorry. A process has a unique process ID, pid. If one starts a new process, that process gets a new process id. "echo $$" is a shell command to echo the process id to stdout. So if 'os.system("echo $$")' differs from os.getpid(), you can conclude that it's not the same process. Understood? regards, Gerrit. -- "The IETF motto is 'rough consensus and running code'" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 3:26pm up 4:21, 16 users, load average: 0.07, 0.04, 0.05 From news at dorb.com Thu Dec 9 10:24:57 1999 From: news at dorb.com (Darrell) Date: Thu, 9 Dec 1999 10:24:57 -0500 Subject: How to add element to the list in C extension module? References: Message-ID: If you can use C++, then make your like easy. http://starship.python.net/crew/gmcm/scxx.html -- --Darrell "Wojciech Zabolotny" wrote in message news:Pine.LNX.3.96.991209154347.4297A-100000 at ipebio15.ise.pw.edu.pl... > Hi All, > > I need to dynamically build the complex python data structure in my > C extension. > I'd like to build a list of structures (lists or dictionaries), where the > amount of items is not known a priori. > I tried to do something like this: > > PyObject * ob; > int count=0; > > file://There is the loop where I add items > while(!loop_end_condition) > { > // here key1, val1 ,key2, val2 are calculated > // ... > // > if(!count) > { > ob=Py_BuildValue("{s:i,s:i}",key1,val1,key2,val2); > } > else > { > ob=Py_BuildValue("O{s:i,s:i}",key1,val1,key2,val2); > } > } > > But what I get is eg.: > (({'bc': 5, 'as': 3}, {'bc': 5, 'as': 3}), {'bc': 5, 'as': 3}) > instead of: > ({'bc': 5, 'as': 3}, {'bc': 5, 'as': 3}, {'bc': 5, 'as': 3}) > > How to do it correctly? > > By the way. Does Py_BuildValue increases the reference count of the > created object? What format ("O" or "N") should I use to nest such object > in another object created by Py_BuildValue? > > -- > Wojciech M. Zabolotny > http://www.ise.pw.edu.pl/~wzab <--> wzab at ise.pw.edu.pl > > http://www.freedos.org Free DOS for free people! > > -- > http://www.python.org/mailman/listinfo/python-list From paul at prescod.net Fri Dec 31 14:41:55 1999 From: paul at prescod.net (Paul Prescod) Date: Fri, 31 Dec 1999 14:41:55 -0500 Subject: JPython Projects Message-ID: <386D0703.EB0807AA@prescod.net> Here are some interesting JPython projects for someone with a time on their hands: 1. Use the new GJC to compile JPython and CPython into the same binary. 2. Set up a way of calling Python modules written for JPython (with Java library dependencies) from CPython and Python modules with C dependencies from JPython. Some things might work a little odd because of the two interpreters but I think most things would work...but I'm just guessing. 3. Figure out how to cut one interpreter out of the loop. Get CPython to be able to directly call Java stuff or JPython to directly call C-coded modules. The former would probably be easier but the latter would allow us to leverage more of the JVM and JIT work that is being done. I think that GJC is an important step in integrating the (thus far incompatible) C and JVM worlds and Python is the natural glue language for the new integrated environment. Paul Prescod From ivanlan at callware.com Thu Dec 16 11:48:19 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 16 Dec 1999 09:48:19 -0700 Subject: Python complaints References: <3858C226.949FC9C6@udel.edu> <3858FEA3.E593F38C@callware.com> <83b45s$lp4$1@nntp1.atl.mindspring.net> Message-ID: <385917D3.5E3A6413@callware.com> Hi All-- Aahz Maruch wrote: > > In article <3858FEA3.E593F38C at callware.com>, > Ivan Van Laningham wrote: > >Charles Boncelet wrote: > >> [snip] > > > >Use > > import cmath > > > >and > > s=cmath.sin(c) > > > >All of the standard math functions that live in math.py have > >correspondent functions in cmath.py. > > That's precisely the problem Charles was complaining about -- how the > heck are you supposed to know this? And why should you need to know > this? (I actually know the answer to the latter question, but I figure > the Timbot has nothing better to do.... ;-) > I really don't see the problem here. While it might be slightly convenient to sink cmath into math, it _is_ documented on the math module page that cmath exists and what it is for. As to _why_ you should need to know this, I submit that if you're using complex numbers in your programs, you really ought to know about the cmath module and when/how you should use it. I look forward to the timbot's scholarly explanation. -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 wtanksle at hawking.armored.net Tue Dec 7 23:10:25 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 8 Dec 1999 04:10:25 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: On 8 Dec 1999 03:14:33 GMT, Samuel A. Falvo II wrote: >In article , Neel Krishnaswami wrote: >>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.... :) >Lisp and Forth are indeed diabolical opposites. I'm pretty sure that Sam meant "diametrical", but one has to admit that the image conjured up by his accidental choice is as meaningful as it is amusing. Lisp and Forth, the gruesome twosome. >What I find ironic is that >it is the opposite nature of the two languages which makes them immensely >similar to each other. For instance, because Forth environments generally >don't have garbage collection (some do have conservative collectors), you >tend to write your code to be more memory concious(sp?) than you would under >Lisp. What takes almost no memory to do in Forth would take up triple the >memory normally used in Lisp, and vice versa. Um... Sam's saying that Forth code is very memory-efficient. True. It's also notable that Forth code very rarely explicitly calls any memory management functions; it achives through brute simplicity what Lisp achieved through brute force. >Trivia: The creator of Forth studied under the creator of Lisp, and are >reportedly very good friends. I also find it interesting to see the people >in comp.lang.lisp throw their noses up at almost any language on the planet. >Yet, when one person says they're familiar with Forth, they welcome them >with warm hearts. Agreed. I like Lisp. >Samuel A. Falvo II -- -William "Billy" Tanksley, in hoc signo hack From insanik at hotmail.com Fri Dec 24 15:57:09 1999 From: insanik at hotmail.com (Nick Henderson) Date: Fri, 24 Dec 1999 12:57:09 -0800 Subject: Looking for Zope/Python suggestions Message-ID: Hello, I am new to python and zope. I want to make a dynamic data-base oriented website. I am wondering where I should start. Should I learn python first? I've already ordered "Learning Python." Then go on to zope? Also, I have been looking into Zope lately and have had some problems (the main one is that I do not know python :). What is the best way to deal with data in Zope. Is it better to use persistent data in the ZODB or connect to a relational database? And what is easier to learn? I must sound really silly asking these questions, but I'd really appreciate any help. Thank you all, Nick Henderson Merry Christmas From artymiak at safenet.pl Mon Dec 20 14:03:57 1999 From: artymiak at safenet.pl (Jacek Artymiak) Date: Mon, 20 Dec 1999 19:03:57 GMT Subject: Python Users Counter -- Update References: Message-ID: <385E469A.688FC480@safenet.pl> Hi Everybody! First of all I want to thank all those (currently over 50) Python users who registered on my Python Users Counter. Today I added a proper counter page (its displayed after you register at http://www.wszechnica.safenet.pl/cgi-bin/pythonuserscounter.py ) and a check-without-incrementing link and page (located at http://www.wszechnica.safenet.pl/cgi-bin/checkpythonuserscounter.py ). Enjoy! Jacek Artymiak ------------------------------------------------------------------ Register at the Python Users Counter! http://www.wszechnica.safenet.pl/cgi-bin/pythonuserscounter.py ------------------------------------------------------------------ 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 paul at prescod.net Tue Dec 28 17:10:13 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 28 Dec 1999 17:10:13 -0500 Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> <38687D6A.D525D91F@prescod.net> <14440.49939.489193.842560@dolphin.mojam.com> Message-ID: <38693545.894CE515@prescod.net> Skip Montanaro wrote: > > ... > Please explain for those of us with small brains. When you can't find something in the current function namespace, Python "falls back" to the global namespace. When it can't find something there, it "falls back" to the __builtins__ namespace. When Python can't find something in an object instance it "falls back" to the object's class object. When it can't find something there it "falls back" to the class's base class. And so forth. 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__. I'm saying that we could expose the fallback mechanism so that an object could be instructed to fallback to another object. Paul Prescod From grant at nowhere. Wed Dec 8 11:00:34 1999 From: grant at nowhere. (Grant Edwards) Date: Wed, 08 Dec 1999 16:00:34 GMT Subject: Widget set for curses? References: Message-ID: In article , William Tanksley wrote: >>Are there any python widget sets that use curses (or slang)? > >I think Redhat uses one called 'newt'. It's not extremely >functional or anything. I'll have to try that -- IIRC, newt is what the text-mode RedHat install utility uses, so that should be fine for what I want to do. >There's a Curses port of wxWindows which works with >1.something; if you used that, you'd have a good chance of >working with graphical displays as well, when possible. That's probably overkill. I expect that what I'll end up with is a limited UI for text-mode version, and a more flexible one with a Pmw UI if X is running. (There are two distince groups of end-users for the program.) >>Simple stuff like radio buttons, entry fields, buttons... I was >>hoping for something like the newt or cdk libraries. >CDK is just about the neatest thing I've seen for curses. A >Python port would be tres cool. And then also a more >sophisticated OO Python port. I worked on a CDK-based project (in C) for a while during the summer, and it has potential. I had a mostly complete generalized screen traversal engine that worked, but I'd only added the required support methods to a handful of the widgets. Most of the widgets didn't work right when they didn't have a border, and I hadn't gotten all of those fixed either. Then I changed jobs... CDK is partially object oriented already, and that needs to be extended to more of the widget functionality. -- Grant Edwards grante Yow! My uncle Murray at conquered Egypt in 53 visi.com B.C. And I can prove it too!! From bparsia at email.unc.edu Sun Dec 26 18:37:43 1999 From: bparsia at email.unc.edu (Bijan Parsia) Date: Sun, 26 Dec 1999 18:37:43 -0500 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <38656610.E4DA287B@maxtal.com.au> Message-ID: <1e3fmue.16ma9l51g0ppvkN%bparsia@email.unc.edu> skaller wrote: [snip] > > Unfortunately, new control structures are easy to introduce, > but we don't want to litter the language with TOO many. > 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: [snip] NewtonScript just uses 'foreach' (replace "frame" with "dict" in the following: > foreach [slot,] value [deeply] in {frame | array} > {collect | do} expression > Using the foreach iterator is one way you can access data stored in frames > or arrays. This iterator executes once for each element in an array or > frame allowing you to either iterate an expression over each value stored > in an array or frame, or to collect data during each iteration. In an > array, iteration begins with the first element of the array, element 0. In > a frame the starting point and subsequent order of iteration is > unpredictable since frame slots are not stored in any particular order. (I take it, upon reflection, that 'foreach' is the NS spelling of 'for x in y' So, you could just use 'for' with the added notion that providing two variables gives you the index in the first one. As I recall, this didn't lead to any confusion in NS. I don't know if this conflicts with already legal Python. But it seems much preferable than a different keyword. Cheers, Bijan Parsia. From neelk at brick.cswv.com Tue Dec 28 21:53:41 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 29 Dec 1999 02:53:41 GMT Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <38656610.E4DA287B@maxtal.com.au> Message-ID: 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. Neel From malcolmt at smart.net.au Wed Dec 22 18:46:34 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Thu, 23 Dec 1999 10:46:34 +1100 Subject: strptime on Unix systems In-Reply-To: ; from Justin Sheehy on Wed, Dec 22, 1999 at 04:46:27PM -0500 References: <19991222110107.A972@Ridcully.home> Message-ID: <19991223104634.A766@Ridcully.home> 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()) > ^ > (I assume that you meant `tt', and not `t'... > > > timestring = time.strftime(format, tt) # Works OK > > timetuple = time.strptime(tt, format) # Throws ValueError > > > Really? > > I would expect it to break regardless of the value of `format'. You > are passing a tuple as the first argument to time.strptime, which is > expecting a string. > > However, there does seem to be a linux problem here. > > Under FreeBSD and Solaris, at least, the time module works fine with > the above format string: Aargh! I should apologise to everybody here and stop posting messages after Christmas Parties :( My typing was terrible and I should have just cut-and-paste. The last line was meant to be timetuple = time.strptime(timestring, format) which breaks on Linux because of a library problem. But I thought it was such a short segment, I could just retype it. Grrr. I was even a bit slow catching the error because one of the earlier posters confirmed the ValueError, but that was probably due to passing tt, rather than timestring to time.strptime. My conclusions from this (and private emails a few have sent me): (1) The problem is with the Linux library (2) Everybody should, in future, just ignore me (play it safe ... set up a kill filter). Sorry. Malcolm Tredinnick <-- Going to hide in the freezer for a while. From aahz at netcom.com Mon Dec 20 10:52:18 1999 From: aahz at netcom.com (Aahz Maruch) Date: 20 Dec 1999 15:52:18 GMT Subject: MultiProcessor and Win32 threads References: <83droq$ocp$1@news.wrc.xerox.com> Message-ID: <83ljbi$juj$1@nntp1.atl.mindspring.net> In article <83droq$ocp$1 at news.wrc.xerox.com>, Jos? Manuel Esteve G?mez wrote: > >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 ??? Just to be very, very clear: there is nothing win32 specific in your questions. (I cut the part where you said this application is only going to run on win32, but I want to make sure nobody in the Python community thinks this is an issue.) The global interpreter lock applies strictly to Python code; generally speaking, calls to thread-safe C code (or any other external functions) can run in parallel. Therefore, for example, an I/O-bound process profits very well from threading (because I/O depends on C function calls). What you need to do to take advantage of threading to increase CPU usage is find ways to get outside the Python interpreter lock. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 12 days and counting! From: "Eric Johnson" Newsgroups: comp.software.config-mgmt,comp.lang.python Subject: ANNOUNCE - Proteus - A Python based make utility Lines: 989 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: Date: Sat, 18 Dec 1999 02:25:37 GMT NNTP-Posting-Host: 24.228.25.98 X-Complaints-To: abuse at home.net X-Trace: news.rdc1.ct.home.com 945483937 24.228.25.98 (Fri, 17 Dec 1999 18:25:37 PST) NNTP-Posting-Date: Fri, 17 Dec 1999 18:25:37 PST Organization: @Home Network Path: news!uunet!ffx.uu.net!newsfeed.mathworks.com!enews.sgi.com!newshub1.home.com!news.home.com!news.rdc1.ct.home.com.POSTED!not-for-mail Xref: news comp.software.config-mgmt:21325 comp.lang.python:78699 To: python-list at python.org Sender: python-list-admin at python.org Errors-To: python-list-admin at python.org X-BeenThere: python-list at python.org X-Mailman-Version: 1.2 (experimental) Precedence: bulk List-Id: General discussion list for the Python programming language Proteus is yet another non-traditional answer to make. Proteus is a Python based framework for building a make utility in Python. Proteus supports a multi-threaded build process, abstracts out the nature of the dependency relationships, and offers better control over the relationship with the shell. Included the tar'd/gziped file is documentation and three small examples. The documentation starts off with a theoretical critique of make, most of which won't be new to folks here, but it offers a basis for what I was specifically trying to "fix" in make. I'm curious to any thoughts or observations that folks have about Proteus. -Eric Johnson begin 666 proteus.tar.gz M'XL("-('5S@""W!R;W1E=7,N=&%R`.P\:7A4^63"0N8#^,EXJF-F&L at _/XE=G0OG'CQ at QDZ*L]\-]^R6QL;]_8V=[>M:$3W[NZNCHA MTP47OL[WU[B]__;_M>,G!\_Y'!WM[=W=W7'[W[6^NZ.;]K^SJ[M]?4?WADP& M.VS8")D+NW/^OQ[:5Y>ZN:IO$^_Z//PU'A4`$G]J8!3@*#[4PJB HP)D"D83 M<#0!D+MCL MUJ/U(%^$7 5H]3 D(%?I5C2 ? UR54Y%M5NQ`.2[D*L!;0%7U+H5C2 ;12[% MT"P$>;G(S>/)TFZ+)I!7BEP=E\YW2Q>!/"QR]: MX@$;W(IFD!,BMP"T9JYH M="L6 at WQ Y!8Z%4UNQ1*07Q>Y17"T!>0SPL/&4I#/BEPS@[8, M-PD&*X"^DV ,X!LB5+; 2>RP%*:YQ33^)& Z":>2(/KTS2"7 at 1!"+N?Z2L+_ M*0%"K@"S"HHI?+H([@70Y^-3!LQJ&P:A"SB"F]G;FL!I]AF5^%W4QC4]I^FF486O$^.YK*D9U51S*%L:UDR#2*O at M3+2]&[5]9K9P5&C MAL;B%^Q)8P[WZX=*V4%MO\YCFB,E+9LS*FCRJ;S96A$Q]YPF)/:RH^?V,Y02\"8CZ5)4266XF^#2(E4P@*11^>3)" !QO=H M5ZX`V>I0.KYV$R'3,YZG:VURIB.UETB9GO%4[;>IF0[6`:)D>L:SU6L3,QVO MPT3(IZT3UF?3\M$:D+>"3<=XU&X#I./3UFG+VM1,ITT#I.33UE%[WJ9G.FTO M`-+R:3YP!WM;&VBS!Q-(7DFH!N-I6DPK'@,F*X!^!'HUF$DB,:2B8A,2S57T M at FMMH?I*T.NPK(V(RWJ7:YV^"/0Z,&L at 7\L$)MNIU$Q1]1;9P37SK)I.& ;N M at K"N=YX1U at W.,S*'+L(I/=<#DVF2(,_3-ACTAU?"5&OLRXYI3$*&5AAB$C$L MDN *ZE?0=(/(>FCWA#YHYHLZD\#08:8!MXR&V%?4+4(UKBM.Z#D>83[3[=C4 M]H)-:@;39';P^$2^I#$-#O=G_94EK:!E#2U$L$V^]SV:KI6R/#F!5[@NK^=N MSIHC/*:Q4QO*3A1,*N#5>VOTENU?55G43V>ROS^OY\W^_E8PEC#9IY'DFQ)I M_%_'WVG^9D*A7^.[P&0N-X+).Y1G^IA!)7).T> MI5FUTPPI9K-27N.4(\EOX9):?D6JWZHT2SG-\ 1>L>AB-E MP7$],99>1831N9O01_7BI-[*N]I@'UQ70* 0\AW=!?ZCJ[08R1K]H]I)#_-U MU%0S%4*Q1A\\X>M;ZPJUO#[,;SN*>B[/.TW49UCM%!;!P'OS*(W*/LW.]-=: M2T[B^5TJ%N/O"K$0G_$4V_LY2ONY%^0-ZG[>&+F?M#TW\<95\_:$=O4CA'ZS M5BF6^Y3M48Y>>7L1BT#[P+C O74J[L!_D MS;9&AVQSVE+:%*15^"")Y1X$8G:&)P=!GE+/,X",B4&98%690L#Q)C;ZW ,POI 'CDC MPOP`G V^TA:^W#'ZPNCB4W,KR*/EGYJ@#%8."X$\[E9%K,>K+'\%ZG&Y55E! MTK+GR(9 ]5W>SCH4PVYQWF,)*+8C2[T#IBZG"I2B^%QJ8?WJH[8>A7S84LK% M\5;HTTDS_YA2I: BX6K*K37.NLR3XQJKC056,RJ=(N99-^4-\Y#3P. &/L[A MJ2<>!B,T4F]H:XRR\#;/PILSPVT.VVP1::@5RQ*!\Y(%.>#9*LK.)UUSP ]_ M2*%*A#7I\J&=;QT;9;RLLL]UD") ?XB#HCDFAVB?<\+1C &:V3 ?)OLJ7V$) MWQ$P*UE+=MJXPC>OZ$:57KTE?(_YREJ(3D:)/)QA"SR'K2B-.=HQD$E%Q/9V MA9 ZEZ;)6F6PBMS?[G("]WO(A,>/-B,MZG M*WT@#='>)&;0YCD%T]CR$@MWIV&ZBA'+5I'0LUCV"9XM-=ML]\')%2 _R34K M0TOOTY>"_!3[A3[-3=+D->#Q!1PA$CK^."+G?ICZK(+1^Z%T-^/DESR<8#E1 M3 ZG_ Q#E9X-JE]FJ#X[&U2_PE#]:@Q4SR7ZY.=A:@LAA4#Z/)36`>'LUWCR M.H4F"&%(,?+7&9NKJ&RF!H[O2?;)!WG3T6Q\B :903OQ89AZ2%GIPU#Z%*_T M$8:#S\8,FHV/PO0\@HF63'Z.+Y C!?OSH7N,*^NI<+`D"C745UQY)0 MO!H'^#)/TQ@\&D^!U5+%.(U208,R\$^K[.$K,)V"XE7X]%6'"UC[(+_&XR\, MC*\_AE6_J8 VA.]?A^DT at Y:PAGK&&:K!&NI9'JHI.%0K5GTC,.LWHV>EIM]V MFBZRFC['39N#"/@.+V^-M;SO*JQ,[\6"WX:I;8!_/3YH"5V:X'L\X.+@@+_# M8[3Q&,<_5XF'Y7=5!OE[WEB67K2$3=!%KH.AIX<]C&B/9%HO,ZY4C5.6N4ZM M<4E%[7 MZ:TX-)3)9BPS*C-4+.&T08<)/AG&OMBA/ CX53N1+4R@*93+3.;-D;QNC[T& MEU3,C&7UDYG2!$_M.9^-&][WX%DC4]*.3V@&UADK8X>;S.;YA1;*?G?6=(H3 M9G'(=7-;/N*,3,3(S3!M,T&:,U M?H_(HLSDC0R23\9"U.KR&CM+L$C.+/+:KBJWK]U^4VQ[;#F at T9L]3V;@9":K M%\T1K61O2.M:QY QR>]_5'\08MX!V!A M?R&GAAY"L0C%W*!1!E#%#1DZL_L%/9,]:,H$8B2U'/35+)XT-6C(6= M?9-9W>S5QK,XAV:7LP*.DYS0=B!0INW.'LM..?T:+)#=\1AL6IO=("*:8L=L MK'I6L9%\?%$D0LBQ8EXWZ. at -6%C8/V'N']KI&X>A&=I%%&_OM.*3.C7P'B"C9;%KGN*G/[-HD'4)1I%0Z).K$K4H_W5A"WH_XI$+?]OP#:K MQ&ILVY18):JP9Y58SBVIW'DGRVVI6(A]K%[U-"[672Z68%D&QUR)[RDL799H M$ WV?_HE>!8DJJ 9GQK)=>EZ(PBQ\GD.;7E&']NX9^%N<([C\[;Q!MX\9.') M%SALYO,NLXPXZPD)^KRQ?< @)FB^X$S;2M3F"\B$O/2SL*9X#UW8(1;!:8,N MH#!O"OHT at L9ZA#DYI#@;@MY1W)%T&^I,1M7U;BMJ\H<=M7O;CMP=[62C=F6DDQT^MI MH)= _CZ[<:PXZ46H$OZ!YT>W8O04,R6SAWTU?^BK)<,EZ*OADQT=K534,!^Q MA ."YRM0^)(5/$OB6;TH$0 at +O@SRCT)AP3^."0O^B3\L^*&!_TNV5= _K7MDCW%M'W,CV$_A&$V M%/2VGX-P0#7SFX]DS<&15\)^;>;PK_(A/V\<_E67PU>\1):D$E613#) MUT'^38!)_NVL3/+O_G\SR==G89)O@/S[$)/\AQ at F^8]^)OE/,4SR^S%,\I_] M3/)?8ICDO\8PR1]$,DD_^5Q at D/UOE,D at WP3Y;S^[#/)-A4$F\.0BU(\1U&^! M?!NF3!MPBDB]#:4<4!;&O\/);2#_PPYC6,$8*P5@,;O._M.AWE#-#UEY[]-; M0/X(*LQJ.);B%$7R"/\(=#SO1XXW0I_\+V<$)FS_($&.4!L*='O4X$5WJ$/1 ML-JA\ER..DQ(VM]KV5?G-HKD*,9O.11$1A(E'BX5\\0"2 >%U3O,;/W""LZ= ML'K'%5:5Z at SN^!_.^ =/J?6:73_X:DD_RQG2%CQ\]1)$BL+522`G\#&.D21%"P"1$MV!+")]B2 M(EJP58AA<(19I? )LRH1+FN2;B\A)C/C5BT2%BI`%:J70N=).1CS=S+2MF7BX59:V<4(.*M M6)0;>UTB*!^2 at WU+Q=3GF%DY07\LH= N/BRC\Y"OQM;+[8DM1DB3KJ"A M*/QO!_LOXO=Z]_UB%:C,;$!=X@)U_&X4["O5CJNX(^/ :GRI,!O at 7F%Q4&;9 MO!&%XB"YJZT`!,57*,P2"HY=&FJYKYBQ'C.[N;$5TVI=X)C\<\WI=@(,\SW2 MQ#-I:B4]AB^P,WB?>RS5@$,@(!)61XB2*,3E)"@J8SCB-^SD"^DP=>PBMUHP M$JS3$+&"*%CGRDY4]#<*WA'*?UPHFMG].R_1B'K.0F0P#;9#N)[-^>7:,XKA5PM/-6B0WBJ18^G6LC- MPC.(MPKOAL^R#7COCKFYH42F at A(/TK=&MJ!:DNVE#>*NB\BXQ=VA7(N/<0--V?- M9K7 at 29/V=0?WR@,G2S\#O.^RT]-NZ"_G*1$G72]\J5NNCK-!*5>5FBZE7+76 MNX4U++WBYFQ4FM4ZS9 J-BGEJN)S=5#!F><$LUW2G at L.TY8FL=/7-\S:XO=Z M3GOJ*C"A:<]*A^D0=@+\$OO;UF#H0IT71>H1=(0#422_VG+N[YSY(K0](A1W MXFS;S4)N$6?*MO50?S:FGQI.VBRBDY*W"GF-B$VR9'L&)847A V"%0 at 3QI/YI\7 M*;Y?R)O%7#/%"^QP/"WF+8A8<4F7M3)[!&$WN M_&O/M_ at 8EZXS.?(=?9_YHC,[<'Z,S?RQ29P[M M_8=&;SX2HS>[(:'O\]T;(0?$U -*2&A E.YCA]&@.#D`,B?B0D*:B L)#0FS MVK[I;Q5/.PXBUX>%%C5+!>8Z=<9[@IPRL#I)# M3P_Q'B_3UW5!48E%0G..0T5RPA!7#7B+0DPV&*HJG/-0559PNID:JEIE!ZM6 ME.5B/0O6'3J/AX7C8$VD:XT6U9:^-"P\:E8]T>E1<[U%(JX1\A[1>3-Q%/$O]6;B'1![S2W32 at 7FRIL M#NHRZ%\05%;%U[SH_1/<)>GOXN?I]PFW+%?!9 at V9*9^T8WU8Q!> [L"R3PN; MGU?8X0SN_XM*_TJW__U.?_MZ%=VC_(P3/^1K1)8`.I7P;"!.7.*[%[$$%+S+ MLVL.C3-Y_41QU+LBD2GJ&2OD2_=K-LUE)"00[X(&=O9NS2B75=@O''O?(E;< MJ*[[8"P at .CAA)_E&?N13M UQ9F,A[E0R0&Y2OL5M?9X+K_+,[KK ZN:8.G^/ M(P at 7BT4H`AOPMUDT)9KY;SF"T!MJ#J)P5OXVX1.+? 4-&^;U;"%&)'(J] -" M/JB(Q(<5D?BD$N!X2H13H?WB\4$A'_HY$X\/QHC'AX5\)$8\/AHC'K\0(QX? MBQ&/7_2+Q\=CQ..78L3C$Y'B,98F/C2B\>%8"T?U*3\IY)?%N4RTBG:;/.F2 ME_M9?\=H^J>$?#I:,G_%I at J.FW^57RIL4\8GT>370M(:[$_P"9LYUNW(*+*P M)8]FB;LU935S;@U>9EB^Q#F)(#>3S","^VLY$'L at 7[ @8MD03K!U(N,/V%]W%^.J.Q9(7^+J*1(-Z._(4QA M4XJ0WQ3N)U/LD=\24_R1DV3G?TN4ZMC._S9Y5/<<7X_6]G,D,/9<+[_#(U0[ MGRDI(C^LSZ4(Y?,?G12,0QZ1J"D8_FN<)#P&)THE[Q:=>Q^9CN54]*4[3]2(?:W+'2>=!U_ at PRR9$]HI>[;)[SG27>,_=-62 MVAR\J8CD&)&?$LI)B;IX&7E]-OISKR(OTBH9B1&W8@(YX*$LNI F&4J^"/@V MPSK![)9M_)VF0]_DVGZOFM^9&6Q2T7 MMRQ--S4GF]>T9%I6MBRBRX\__<]_'C''/MC/?^[NVM#>L=[Z_.>NC>N[-W;R MYS]OW'#A\Y\_B*\MN.&%S-1803=Z3FQ=.5'2>XS!$6TL:[2-Y0=+1:,X9+8- M%L=Z3HP55M:EK(;%V1H6AX;R at YK]S^TR64:7R6(IYW;(F=AC(I_KV=&Y>T-' M>T=[6W?7=>O;.CIR'6W;.Z_>W=;>OGU[>_N.C at V;-G4ZO;:N'#'-\9YUZR8G M)]=.KE];+ VO.W1PW<%=.]IHG1O:5UY3EZI+;1E!'HI/6_ T9S/4I4U#47)B MZXXB\A/=;*/ 96;0>MFZTM2FS'74?W-F<"1;0J5CZR1J(,5)HZVCL^O_V+OV M)K=M)/_WI2K?@=%5;>Y22PT)OAG/U(YG[-AW?IU'B:LN3FU1$C7BFA)9)#7. M[-5]C?N\APOI_G3 MGV"GAK?!9+6 *;9D&LL;1$55;S.^". at YP2J]^WWDW4.#MOD1WUM^$> @=XE, MGXB^Q0IPX)A=#H:9IO\=&=/X`OWKP^PAY!_[Y(?(??#S/A'GI^BS at 0K#^NGL&*8([P++ SKD".A6Z4 M>&Z,,E#.]2J9!]'5B\B;"/\1S)?0I7MVD9/30B-W$?K0[N>U4J2TR!LG3FK> M166EA3_"'L70:;P"*#]/9;4%B>./O(5[9>&:\B15%1XNW.F5;%FF*!FBK(TD MS0:J+4G_G=69E4D?NX'#>?J(!:4)/P)L2<\>R?*I6NZ:@<0EOM)U24)9))6U"HHY',O=*+Y2#)T\2]'24L\?H1]P9>H:,%$! MDLP:ZBUA0I'QHR21MR=R[B,GG,=7AD8:E1,JU7_RDOE="$?B^$K5 at 51J")6; M/OD;I"+0K"$P`.Y71D$B=U$GF_F!DPRN+$L"`$CEMF(>WKR^+966)85P%&9E75K3 M\F<72-N>_? [='V\V1^B>+5.([]B(:!LE8!HK[RI>Q>Z/C0,]^2[T06=]4OD M+!9.XDT5 5P?" M[9LW:?#CSQ ';"D_N_\@1N?S=1CZD$WXL*5;)W$^ MYY;[<_:B^//;ZW>_7K\9WKX?#:YP(TI594VXC1PX!MW_$GG35T'D_1..!HZ/ M= $2H?0KFA FZ/FUY:KO^@V)SF33F\JETO= T7\+_7=O&;\,(JHX&;4NUC:= ME+F2UC4[+5/?ZOJ7E$JDK\ +!HDW]GPO><1$K 2?].=0#]SHXPJ-=#G]91 D M2S@&OG$>@U7RQOOB?OID%MEWLR[OVO?OER!G#]WT,OCY_A/_0[T5S'F2W M80E<$JE?RJX+3BL1L:2I546'M#B56:3S\+&+GX27D(\"-$]HX0$O=_YT\?UW M?YM!JCB#9O3[[_[E?]+$PO,?;>2@/#@_0W+H+(/8%65;$BI_*!^:$A$_F3I( M=D[%)XQY$Y%^;_S5BV/FL5D002-BX^. at F(S02R9S^\&)/,0])BN&G'*25>3: M2MH4&3;F?]=U:#!:Q,+'Q7+0?Y^B8.$L#]&G3U#$\<("TR>M89_ NCXYJR1H MWW))`+JI*IJJZ;AB$ (,N"+JB"(FCP7U4`@MJ' MQ#7JBJP;%H">5LI"73.LC7C\`KV31;"002.C?-FBA<.WRB2J/.H+FPHQ=!!:X;V`'=[@06.3)4I99)T>8(;!Y<(P0 M67OFH>CF=W":]A$)QZ!:0VU)R,&YS')@"2>Z]N!Y,'T41O GQ0 at Q"4);!GDG M"!$.IO.$SR.]5-1W9T7)]4R#6:XXAIW](CHSZ.;;SD/@Y6R PROT1%WXP@?7 MMV66R[+>FLT5 at 9\$?A#9<$+RB%*^BS:]B3'Q=&Q1'@*MJ &_Z(L;H:,I;5EE MWO_5Q=Q98DG#W 9-N;U1[# 'YJ0""I7^^ JVE=X*6\N,''9FH](;&WMDF,(R MS-H!PS+!JV&+VDJ76=:L4>2*TM.:C%;&1 >YK/;$14OQ/7-5[=.(XL8FD;., MD6=FKT(X3YXXL236R**F"C" M>I*YC0Q?T8RLQ-?("6TG0M]KREG.'#]U(_1;.G?N!QL9U'X2&/O\Q7Y MVFMD_F>13CW0C-#*DBC-+0E+9,Q(1[FJ2H^!R&.H$/<8>?M?7P+TEQ6.Y[B+ M-OE8 at LQO40L^2@![6:(F9//,,5YV@:Q2XO,D1UP;>ZK]ZT=ACI4>]&.PA4[FEG+ M1L.+]OJV9)5\VRKII'I*M/PXFY7HLA M6VA-SLV"H#!R1 at J3/O/+-U5_2!:H_[=6>4LY`G7N;; SMG=Z=J32+5QS at DA) M=:V2ZEIEU;5:J:[:7'65_?CKUK&O)C6?R8\#?UI],>M%;6',7R^G[I]R)@]9 M*I4&DL2RT&$JS#'30ZV)G?9(#*R8E>ZT?),X8]CC((QMW$1A"NMRIP* MM!; MEA5=.T9%9R "#$2 A0CT")%5TM">5M.>&!P*`X?"PJ$\*3BL8UR*+Y!0&214 M%@GU]) X00 at T!@*-A4 [0[ '"'0&`IV%0.=_N,-Y at IS72?EZ[W*_HB?D5',C M=,S0GQ?OU[I!6$]VR#$8B T68N/P$&OZ&>(M(389B$T68MYR2N\@ZFI'$+> MZP2^_&.(1L$DGRB1WRD\*%&,@'^J[O1O1G?Y2B/OJ[48L5C#5,$A!S8XCOO9MMY"IX1D)OD.L)'5!B M;/2A5)T4/KFX"V13"O9G*-=<;?QIX3_/"O=Y1GG/LX.''75SFSD#VE&Z!1"/)>T0 M?W1G+G2 R1;7NEV>D Q5BVY_[I]F,9SIP!2OH.;1]:1^8,=JS$Q3L]>A,U+> MK1;C=.!LWUZ<%T\\EE5X$,DC1(MGF6RJ&>B$F(W-J(3S42]XL9SNDOLA50?M MJ3.D5.+/'5@,[&Q;1S!^^"5:1!SU[R*W!`8=WI^0FTY1"MNM= M9.Z"F=)/Q/GF72%F[]8H_=BCY+/<;?9_;-K.M7Z2U>%;S[YFVG7;W]M&QF=R MB([TRR20_$YE#R5V91#XAC??$-K))A2"5%V>[6 E#N[_(_X_7_FP$ U/1J% M(B0N5"B[`4;%3MSM46(G#*#9C('8D#BQ?5D2\$856?!G at 2P_#1B)'TS#F%$H M&-#)64*%141A4E#VA(@^E7E"1 M.=.#$T5%I5%1&534O:'2D\=0O.CT<=%H7#0&%VUON/0%RQ/SY$#5E0,<7ZXF MZ!>?ODU*#'IW!XRS5]<)4J4*J<*!5-D_I!O&K#.D=9"J54A5#J3J(2 ]3[ZZ M8:I5,=4XF/:Y)[,&V=J/:X"WJ;^OPU<*D'4:8X4=<%$)(6_(?L*MST>J'/=G MEV)M`E17, !G"6.=]T)*G(3W\E26G90J:@H'-67_J.W"07DJJ*E5U%0.:NHA M4 -G9:N#3:O"IG%@TPX!VQFUTA=8=+=4_O&5)++OKBC%QRC]'LN-@=>:?WP% MI5AYO*Q4T]`&YG0UD'G,8#3N,"IQT`N#-N%&YWJW%"3Q>+=(I6 M1N "A:>3G)/FZAU)RSCPH>_2UG=!'6H&:9WV7KRZ"X1Z/!0[$^I;)\D%FOQ. MA?D67T7;:N8#6AQU;O9\$=3&!8+:0\:;`MV!PXZ-+D#_JY!M9WKU"$%&),18 M(@YC?^7F?9ZZDR B_5M!NXJ*%IDYQ8XA]-"6X K0O>*).^74\3+P_>"K.RWJ M"E=1Z&]1F[OH=3<9=\VFNJNL4JS^N/;L#MNW3IC+-$W*1+N@];.MOW1SS=)Y MV/IFH.+RTN9"BMGPW \F7_YK%21.OEVW3$)L8&FEG27.PH5JCDH(>9%!J[&+ MYW at H-0=$\==!BM*=5JN8BX0L]-?R(B%9$C)3O?>;A$[83V+EZJ47I3M+N/2J M(.*,!M(HX()\F>3)[7K)!#6G!'&\*M#N"%BE at 0O%.8""EMX7&OIK+[V;[\$J M[:!B)9 at JASK>J"#F9F>EP&$N at I[ORM(YZB =YY&8=7NR."J!KF;G: 0A5Q4" MT9OH`RI74H?<7^O;D \[;#%I)_][\N;:W at B3?1?X3]L&D=KYEL=M MI84WOB$%R/TLX=%)!&>1YF%)<@64S9]BD (MSE4\GZIYT%,U"5[%JMG12<1)H+)VQ8?P\OUT2F&%4P52,+D&)YA[C"@1547*<];@+AJ,#A!$ M,>.Y6!2$3#(R2IUP]'+V>H=H at 5,_DIV"I'<9.V%NX&4RZ@*_6S4CQ6^-F' 3 ;4$[ M\.2/BU?7>04!(/--J%0!;XUODH);ZYNTAI;R3;"&[=XU>=J:"TG,`)>G,VA3 M0AVX[):VILO&>[KT94P+/!Z$BS)/:OI+X0M_LE#%64P]R>T/1]V M%W&E!NAI0:_/*(E6QT[D.Q&J!>9(-UWJ5.W='TQ!D-C^^ E3:JT]GR"3$:/C MG:^&XU"2WL^^Q1>,Y#:32F&MRI) ,'%M%; MOEC [L1>S.-E6D3(RM1$1=2%F18'-=<.G1CLXH2?PL&MT!#P)2*WR<4!3^N\ MW>I!4*51=? MZY.$B56GDB*M5Z$UNI/OUV6!X&SC;:$IZL9CD-LBL/;(\9VRG=$+5B/6ZD*] M$M2P?'>R?YJ,)Z>SL%+/T#(8*&(M&J3,YD&$/A*&-XCPCXS9>A#9!J']XL&H M`TUBT5BK&BD8FX:)-5@,\RJP/D.3&FP MY at ZFL#?X?RVGL*#K%%8")-*U_2R6%'G8.-%=!OB_XMB-O:F[><)[[W:=ZV)0 MF25$>A:LFD.ES2F,YI$'AI&I<*YT3.0H2\A4;UW,*-:^;@&CY3B?[6]_:KS= ML]%JH'YRJX%M8S\1>",&_!&+_&@M[/7QGF6;O$6P0;<;62F QRZ!-DE64:EWV&^L<27 T+LWIL.$GO5KWO-EG MIYM]/KH0GN7U=!JY<8R!+5$0O R)9U9)`2$M,=AAH-8QW"_)XZB<<_3.G:!6 MTS<RDM%J.5YHNQS^Y74I2";!B%L<2*+!JYW(95"VG M7UOD8C0$_]X%&"8NK+WP0/Z7US)0K&D29Q at 4P+"+A$8R0;CTI 5QON M_VCN,^Y at K^/6$:L;+AD%IS%,-MAQA#_VW:&;M>-)Y(6\-38J=\,7/FR_(L>+ M77OC%=XC5MA')4D?K17S4:V,UY_U7!IY>)K2[2 4SDI57=$-451''V[1_Y$J M"M$TWG]*H_9)J%RSS<.C]S=Y]$+^&TL]27!%_OT-3Y at S>4?9H'-,@]XYID$[ MD3W at D.]_0R.)D+HZ..XJ#KL/DM?8J\O]M,+P((_BN5?SWF>>[\07) M&\Z3Q>#?A3E@*VSPR PT8B H,Q!4&*@T%)K4,W9IS1BGU)FGU)AGWHL.M=![-3V?"L>01^)F]>;%YE M4>=:K-0R5FH%*ZT35K)N]@$6W_SM%"SM:,'2RF!I%;#T0QGVYI#H[2'1.T.B M[Q at 2O0R)C at H(%S\).,[@UIUY2P_18^&G"X at 5OIO/ES*W#B5%;VJ+@(X%$Y/' M$!W;N0B+`X<)W84D)W'A([$MDF$]?:--8L?R%Z,4=-"<"$XMX*P\?PVF(P?? M_JE$2QTZQJ4G6<18BF$0XZ[8:&*S;CF:.E*Z:*%<[K.L`0T8DF%UZ;IF*H:B M*HI)U\#E0=IXM(SF))S.85X4$]?NS,A+^.Z],WFD[15-Y][^P10 at 7XJD]3<+ M<7D,RCP&NJ'KBBPI51[/'\>1-ZWGL6GJ.E!-2Q?@.RS3D)3TAYS_T+IET0WF M0I9S?UAA41WW.5$U12U*A2T6,#1#,=7V;!%E&1BJIII )1W232O]8L%YN#J6A_=58YYEW9PMG+!)ZUB;65=M0Q3U>0N4.BJ+BE IZVM M]LU;6[W"8V!*B@%')JD#CX%JR*:BZ1)=0TZH*C2QLF)J M[8:I1B6M,O!S#S)PEZ)4$GD*GBS.7*1 ](FB1+JFP8'18W- VRV-"5G:YMR-I)^H.R M7F6U82 at Z4$S0P?'63,DTH3ZH at BBK<,H(-4.7!-& OHD!@&7VR&_]1/E-F at UJ MUK05;LT-NG-KUG2'.15DV_[L_&2-ZN(_WCA>PRVY+;=("12O,DGOIN1S4Y%/ MP9 VV*1?>R@%W]FKX%MU]'@>-XT5V#=6X*EB!7:.E;)WO;H^ZU5'K-2]ZY7^ M1+&2=HZ5MF^L:IV9$UJ'4-?#DKI2M9A47"T:$/T,R'$!0BU^GA%ICP at 3!NXN MW0>GCL_@[#KW/<2S,YA%+'QC](5OIU$F73#O MN*K6C]J$-C' '_#G&)VGX3O+^\L7[\1?[]#="U\NQ_[*%1[PSW 5A;XK8,Y< M_HA$PD.'ECPX/OZL\R-YR]1[$":^$\>7V5["@IX^2N\$9BX83G/,575]]_1VXWK;B^F&@`Y";'[(5Z% M81 E+Q9A\OC!B9SXCZN_+,=Q^'/.Z2L(5GB%X$#_AH=O^0>RC47X/^$:?Q^Z M#L,H<"9S810(;YTO;M[("XA:I;GD%(@MNU^\&9TBD'6^/'C7[P.NV:O=_+-9 MXWW:N6>!5&.%-NY@]?B9KHJ3A=^=TZ\_BG?74&3&T???37S7B2X=W\]Z77OP M&7X/II.0!Z)0A/3C_[?W9CV27%F:F"?)8I'1%=U=W=4]ZE%K9 RB*B)(#X\] MDAEDY'1D)EE,-PDE9"E2G95"JM]?+2_-5V%EEL3I!PKL7>G60J86?;'#"R23_P ME-^%#9I;KUQ6.[P`^G5"_(T?2!6=EXLP%J[=UH>L'@;*'K.^5 M#)Q9GHNN%P_A2-6R$&G87A=6K!,I%;Q+PDA7=<*(\R#09?1E"A(*]EK1=ZNW M)^<$#]5.F,*L;*_>_KVCNZ,G9/IBFE9F]W:AOBXO3>_MPD130CN7V#?GX?&O MW__T_0^<'!$@Z2VTHAB at 6;4G"Z[H7"J?2NR7/FG;SYC:9PB[HT.47&]OO7-O MZ^ZM]X]OWOK at UIWCN^]O;[]S]YV=K:WCXZVMO3O'M[;N;,$G>KTC?]_G/_L? MP+^]K:T#^'NPN[6U"^]W#ZQ_^!GNW=V'?^_P/WR]MRF/+A7/Y^^[YT]2T-N9 MQ+3IEF_&"7OBS--S-2_$R=.&4TX=FIF%F?6ME9)!%@4&X=7'SMT(],R.%P] M)A%A]9FRF at DV6//L"^39MVJ>7?/L:3S[5LVS7Q">?6NK`L]^D";(J^^Y0$2? M*I\F+^Y[PYIQ7QW&?6NK9MPS)VWGNC)N8-J[6S7C?E$8]W8%QGUO'$ /.\X] M-53H7.F,'72?\BS6W/L*<>_MFGO/G+3=Z\R]MVON_:)P[YT*W!N=<;ZO?.=. MZOE=YZX[=-N>[R6>BFO>?85X]T[-NV=.VMYUYMT[->]^47CW;@7>_:BO?-^Y M&PZ at 4]W8.8Z4+BNS47K[GX-"Z^6W/Q%X6+[U5R M5O[FX?'C#YVD[R;.YV'TI&;95XEE[]4L>^:D[5]GEKU7L^P7A67O5V#9""AQ MO-AQG8_"-!X[#Z/P)'('`RP']I' .VLF?H68^'[-Q&=.VLWKS,3W:R;^')CX MV>)*+O3(.*AP9&CX^.-1^+SY2'TR7.#)<%"?##,G[9WK?#(WZS MJS^+49"7\,>:6U\A;GVSYM8UMY[&K6_6W/I%X=;O5.#6=]S8ZZ 7= B30X'' MM>'ERC#L.CJS9MA3&78=G?G",.PJT9F?X>S$B1M@\A$GZ2OGL1N=J,2YBT^K MV?<58M]UH.;L2;MUG=EW':CY at K!O6)QSL6\=^5-S\*O&P8$R:@X^.]3^6H9L M'G"X9AVR^>*P\"HAFX^&JN.Y/GS5+3+O.NSG2K'O.F1S#OO>O\[LNX[9?&'8 M]\X9V;=M.JEY]Y7BW77(YAS>?7"=>7<=LWDM48<'6[MG01U".ZI&LERAPZ&. M!)US.-R\SH=#'0KZP at CV54)!'Z>P>S"_/99<^%#Y?H@!H7ZW%NNO$.>N`T)K MSCV=<]<1H9?(N<]4YR(WD%Q9I at LJ[%-7ROE15,K9NUU/\OP*->>:XGW^OK^- MLE3@#M31"I^<>[=NW=S91R8!];>S+B]Z=VG_;ZW*BE;D+%)\S"+=]P)N^/'P)[/R3VLLFLV`^Q& MX;#C#C?P[U!UW[5^V^@!^:J-/I?=VY4BFO8%H\@='KH1B(WY&]V at TP^CC5,5 MP5!=_Q!%CQ.XME]V%?SSO at -:A^NH,E,ZX-)E?>6=]).-*/75H7KJ=A)_G+L= M#RJG^HWK>R?!$181)&$@B;BF M7M)U3OFG)!Q:%V4[@\NJ825$++6F/T?893-5CJ._MRH+ZJ^H<.$N*P7T3+WD M>KW_6JFA6;&)`H7Y;UH at 3VS+,W%>9/(.]W9:>[J&X6(XHY)%'LH4T64WCX_LUI3!P;$T9.$E$2`8?%RKJ'L.E4U'%CEJ?HQ\CU M8F6JI#W,BSI.ET/$W\`9K93+IE,8)RX6M^>6^-(\\=@:8+2--,*OHF+-F=*(4'5BXRM1RTE?05MA+ M1G T.5TLZQD.<<&<811V5!RW[,6:^;C?JH0>N+SD^B"GXO,":"]R5!"F)_W% M&_HXC!/=%17%T%[0=>(PC3K 1L(NZ IN`$=@!'-$F5-38 4.]K\?IC&6PG- MI/:&"8P7;N3A>W!,)R$,]=M4J>\432P"Z+HJ]B+5==JJ[YYZ8;1X+^^DR?(2 M=#)PW!X>:-07Q.5!=^*TTX>'.VX4J\#UF[F)/8%].(R=`2RI(]5R'@<)VK0*A-D#0$][N,);J&^/^R&L/67RZL#,]V!HU+%..!CZ MZBET6W*D`R4L+\GDG+J1!S1CT4 at G;$.789;"$P57+$ /1K!ZOYMV8/PPS #D M06N:W+:FME/W!)ZHS.+D!@LT")W%WKD."",T;T-87Z"*Q:GR..95SW;+\E(; MV"-2W2AN6D]E:G)ZKN?3],=P`"C:,1V4&*';L(M/X-@"RFO#UQNNU\6^#8>^ M1Q,$FR[V`EI7K!8RFRX_[P,=XM.!RR"G`4&,ZA(3=_/=TS"*A4X4=A)X1X<% M1=@6'HB^O; #ZP2TU4$Y[=M4`V![:4#RJTLL#N8/!'OLVV>!]U1:^_4GG_&[ MY:5[WHD'9]J'OAR/LCO0, MMC!V.%(]&!V3-?3+]U'./E6ZBT"?20KS$"O@(L#ML8.+K_)<%A &_ACH"AB: M\R0(1T#1)[PY8)21 at NE#GN?%O%^060=*X>I"?U,#,J:N`W$F(2 at 4*!\P&XJL M$C$SNKR\E.\S4 `P17JF%Y<-`+.I`B_ ,13D*RW.R4>6YB:EK>4EZSN6XVZ* MG%4FE97)(5JONPO[QX/U`\UN9?5V0DB/Y:5#PT62[>SM3O9VU_DO%C.*7,)8 M#_9;%S#4&!/;`D5R9>BK-)B=%W4P%V7,, at S@?N",PJ at KW-[>K at X>2&X"!Q"Q M]3AT-AQXN!N ]&&(&+DLW8@#=/HD?'E=I<^L7'NPG45$[6+B8Q0(EI,%I^$1U*S"2][$0MNGM#_D>`.-*2/3L*C@\!J!T M@&PWADYWTB@&_HMREA_*.>U*W^@@`)G2'W^'7WM)OLW^5: M#7N8?B1%EG>T5DJM/%%1@#]L9W6B\Y8MN\+R&6Q;6?%E8X.>9D L&K"F&:KV MIABJ=F^]\\ZV_FUY:<(*9 JFS3 C22ME!OA2@]/>_-)JE at 5LIHWI,4GR*,G& MN"6C[HA.<+ at L!8:!,K?'@M\`I-:P2Z0K&P`6$(1QT(E"_(WH.T?>BTL=]V', M)U1?"#0:$@7H^4K$B&ROTW[*^ EH5BCP=:'+P!5Z( @B%:8!](_4T%X4#IP1 MB0>P(Y%B$WVJ]&%DU:$U=YSWOMK6.[VUZMQ=?R\_[A=$"44RV-X=I(S-L1UH4UU(2 M-),2GZS>JYG'V@=AQ)I!UXM!&8BA-Z(JY!@T2=\PKQTLKM+E,4[CYHOW[''H M#*$1#\;7(Z>1/Q;:2F,5Y^AVVL.:0N-DAP'^>PH=&WAP3Q7)_RZT!8H< 1VSI9, at ISAHI$N8-J*KAR'H<@2/<)/Y",9J?;K:W)1Z.,.$E3A at BK],S#.^?TBS1HV-MH M!!R",!RG$1DUU)BV&?V,YZ$+(EK>&(-FF*%BKN7\BV-#,T"MR'?@0J''".4` M&6?/*U!!JZ()0_5Z.#?4'!I>:#=X9!3JN&A152AQRPS"3DSE7%1/0:HFTS89 M#N28!WHF>9LXB*:LV13Y$1UXL3LNK!M-*0S/@Q.H*V05X!KO0V>)'&'+S%_9 MA2;BF(RXH!HEV6[TO7;DPFC0HIQM3%E*O:^]Q.S)&(U5I2;1Q1D\GG(QGBLX M0C9>PJ" ")J./V6:X$N8TD1("7T',$L/.DF(]K7M]T"SO!TGT'R*2T#;!)W) M9FUB8L+E_ =9`>F1&@+=XG-VM^A!29\?M/B 'YB^ M+B]MYQMI3MEIS&Y4K/517 =9E:[JH*Z*IOY(:8,WC8QWF'OB>D%,PFI,LA?: M&8,3%5?@Z at MPUX%T#AH'*218Q(*;VY+V.ACA.G>VTL'!1CR at -Q3NX0`+T/WA M=RLPM/L)SJ1?H9D[<'"<>*N+N!K+2VTEC2<5I&:V.+<5G2--62/H MG)$X+'&B26S)6)EPR/CT20IP; (07Y/3`_W$R?0.W!1:@M&&*!J69A.HCCF5 MW*FD5+HH.G5 at FZ3H1+4[;YZPO$24RWRE._OD6U25/-9^@SCT4QP3G;A$#2 C MP$0,Y,"&:?)ZXZ)8UV..GS$6G at J;5I>7)HAUX46&1X]0U15Q@>PYG>>@(Q"@P3^$WEM$.R\`.0JK^.A0+8X\W\$ MLB+<#%N/F23O0)2#A)ZT!%@\J9$7C/'P1R-H*-(GV1!DGFDG([L`JNV[0YD; MWTL2$.>L!_SSN^[8\];W- M]NT<<58XCS7PP.DB$Z3GHEY,?)$>&"11R.2OW?R:]'D`H#Z?PS)@]&=HLP,C M0*VM39;5Z?/C^B=A!&QY0#N!>&,;KH6)ZFMC4"_T8B9DD /[H==!KYYP,FUX MB)K91^-P=F*R.VEYG._-V- TR^G^#,OISBS+Z?:BEM.=A2VG^PO6-E_4?'H< M`*6C>6J#O=QR,!K#`V^KNXA*N/OVVY;X`0..TS9Z0Q.TRPN!HK*C7-3BR$;8 MS;H8)U':0<=NA7/EDW!2A<^,GWB^D*4-MK3+2!%RT"=*F%Q ]JAJ2L9OQ>L, MVAKZPVTT4!Z3T"QLK+#7(]V5;='.0.'V1= D]@\V&DB R/"@CVPH+NWE//X2 MA:'IC7VZH6G!1<8J1P9U39VZ/A;=C%GDP>_(2KLXV at A;0?Z'I\(0WM#!" ?8 M4$45IY7P`%X$VY;:D4X#$8R#!,VG'9YJDAYE?-7[>R^-R.+'AW]?JSYL5O#' M))E&BHTS;-I%D\E ZKN 'X`%*PWEV[!_189%=Z3=C,EN"A MTXX0=90X)<;A.:[,,**-!EN3UAMU;79B-BU\3Y+;A=@1X%0(:2 3-5^54H=B M//]$6#,K5=E.`-NPR9;3'W!C.'*V(=8"B-.E.8<5Y^VJ!1W/GCA0'8A&TL!' M"P^>542$2.3]T)\83X7S$)4Q/FAQS-.;U$R&I 2T"*981 at NT>O+?>M1WG'>7 M>:?!GRV^'=(86ANI'^!P))@N&Q^,7D(G9Y&6D"N';%/O>R=]0K.)2UJK?I:> ME5O$F8J4'D31PH%4%;,5)R1^&Z"?V)I 9BSE,TB6,9R_"@@M8.1A1%8WE at Z- ME8]%X+8J+IX-76-D#ZT*G&FB;Y 2G%GF at 5Y9.X:#24=&J5/8X[=##R::#&[0E!&VB*;K//YFI8^LA M"K6]-"))%3L15SL at Q=J,SP/%72PXM(]./5A\6&I;MB*4;%O9``XG.U[(>Y3$ MYA! 2=GUB#EP(W$5U'$DK at O>ATAUI&73TSW4(;IIAR5%/I/@-^5[P#,M,4>O M3V<\7\YI4_I\UID]VXF>"2(BRH.\A\Q8/065@ 0WPE>#W'H2T3Q4I-S/^^-, M30))A_4DV0DJ.\O%:V;FNP*Y?1(*N^#)%# M(C?PM639T1=G4XNLNAK1&=$$8;"!,+)0`-+?B8V5`.NJBZX&%%D\ZYN*# W: MA>U/_,M#X_QW8XM5S5?%#F:H8KNS5+&=156QW855L8/5VPA'\WWE.W=(C+F+ ML&YA;)45L=@&92-D-Y/S87?A5J;5[FJ\9!P ;E(;@KC4)A7)C4:50*.Z8>".]IUX_%.4A+^ 25:SQ=QD&G M'X4!;#]<7.QR=J?8]&- MJ3>#1P+W$39]XH=MM ET8(%:SHQ-S5MN;WH(Y:W=14(HI9G5VX\(CX- 5>AD M[!S#B.X'0%/?(I-VCAFG4V5+:O6?+(Z"F-+ZOP&'$_)1&TQ8 at -*0()XPK>X4 M$4&V59ZV4AX?:B%/*YS6GZ%4DJ1X]!HDCND=V06*_/&7HRR;AH`2'A*#"AF"+'@ M?,J.;5,1VI*J*>'W+6D5"!*]2%T1\BA\+=K `]&C2!_&E$R2.J[-G?%W: 0- ME$4L1?)"3TC,IU"L`]BT at 0L^D at G(`7FYNX'!/Q0S at R;M:(&=^*EE&23"$ MV8_<'HM3&VF5.;D9/]&&@+?%U)AGJVQ&0GF*1V (2%.K8\D+\Z7?=V9(O_NS MI-^]1:7?_86EWW=6083XSU=V=4<_,!")[0)`T)S,SFR^R:@,.<9L?4D!(R@(:>; M:=@H@:/HX8S#E,Q*T"CP4,$4Z/'@8>>?DCTF*C&NWH%I>O(OTC"A\_ C-TZF MQ?7?FA[67Q8"DX_AVN3.?\WL+HS&FW'4*4U?-)DN+?_*(-3B,0"AP8+VD2WU MA1KE)I#S]$1-Y0W-22!GSX.6%V7/()9)+%Q&;'/;L/GG.6CPPFFQ3]N7M?2. M^;()8APP)@]#N#)O4,G:,D?0<2#FRAS>96$+S^P!<^#6`N%>A7C%DN&16S4A M,10Q/&+6=+*4",9HA2Q:`Q[/,*ICS)40:)9U*>/+Z-E:/G(0880WK6"&`#.\ MG+7+2,F)5Z12-+$4H]WG`N";%/9H829(%4#)E1T8?$X7#X\F<5QMT\R%-<%( M'+8]R[D3/HFMD"L*M\03[OGQT32.-M4W83^(PV"3!D7;:7Y0[//M(#'!A2)W MK?5-+-0LB,NP$SI]TJ/T8B%=&:DI'STC:ESLDA%0'%],DB)O4/;_LTE:.7\V MB=(Q*P'=D$@./O92OZ1;37M7&Z^(9F)&I$DJ!:>D/%2AB<1!U\^Y$5E4SM3+/.&(?DG!>F6B M-"IN*$ZS-&VMK!AU$7MIX,\$'0SCV&M70M>$Y.8;D#V#%ICSSUCF@[P^3ER5 M,P8Y,>ACG!M&@!4Z9I$I5I#[.J&%#72$:49L(8^F!%LX1[)'PV^D$M;"/ FO M(-.0EN\Y\M4 at H3"'TEE=$X^M[2!J%FLS=J18 at FGD"_CL2Q&Z>F'8ZDO/FI0CNW:F92+>K1,\7Q TWLIY3!>G-WFTT9A36F[9-.TRTBH6"Y]G6 MHJ3[RTLS)RJ;IXM>\_Q$-=$AYJ===2F+8M-7)9D[C9MT1.I=#UMERF3 D"^H M at RSIH2&8.0Q')B"#]WS-9BYK$RZV\.<;:W&'S/.%$+.#HSH94R#:D]+MD3M' M!+UOG?>VT))YABKX].;LSL))38<*B]\F.N*RZ3K#R1 at C+3^9+:QCB>"UN'DE ML0VE#>5JOYN@"@M"7+,X#RA*H>U+HE.HNT1805C6G;DZ/YJ5),Y\ZEFNMXHB MEFG.2-;&C9%!:,420+%;0]^52%L20<:(I:<(_$"[#0LCKG;@ZKQ_!M$M`4[2 MX:X>`L)D4.G$WG3-PR=$YB TL'OJF_2YY,Z)T5:@_ <8K46GCQ'+4- L[YQT M(4\1,&NR$0W8,%)80F%>H!+-F3;WCC71D7W(T('$(FK/)3]/3ZEKHS87H_Q) M")L=398)X59K#L&,]"(V;?I!M#1-%#F'2I>QHM9 FU#0EY:[&]4%B6E2;%= M:P!M_20+$F?7KTLQ>?UP4,6W:G)1T(H(;D\KB,$3\-RX2I3:'LV3>&:D,/5R^M>CE$8L*LGD1L/FS )"6J< M0H,2V7.JQ at 02XG,`E][8W8V21)R&G>R at U&4Q>Q6SI5CJA;V3)KD?)RPD8++I MCIN/_YEA#S)IZ0OIQRB56&N?2FHLF/\,F;QZJC!Q';Z%%7;PQ(>_BUE49O># M4_%ZY-6S.[:(F?H+BU#CKQ8QZEQ\FK3'9[%;BR" V1CF3;N1(24AC3%7G=PJ5?6)LXJY572$QK$]IUC9U+,0S4(ZZ1F1JT'7S1P,#2:0<[H[N7@:X09X3GZS-G'IHP-3;";0CV:EX#6P#+D<^!3A]& 6'G1_43SHP<)XT%NKG"^ 8/P?A6D\=AY:,-F/!"9; M%2'Z.:%8TD%,M4PR#(S)+M71U:EBD\&,D<223U\G9 C;L8I.*Z8M.#8@;=Q9 M=,C9$%-F%\19"65\)6+&%A.J<.P6S8?SU?U MFE:*1APO--QU$="!$IE=FMK!"XF;*0`FQ*LL-P;DW.XN*>G$3JA (-L>RHDP;> M(H%09G-]3&XX(G8;QI0A]BD9OHX:Y[RWP,N[BUC\VUX$RP'4^5 *4PE[:$.' M at TQR)C<`6K$,\ZFP5>\GQ>8$*T^P$2LQL!7"H4M:2>*#+IE7"[O#JRKUVM9L MWDIC2F4NWC$J*448[FQJ32(FT.(:&`%KD:#-=,KD+R"6 at .9VU"*E? M7G!BU<%T#$>HWE%1,=^;:E>AR>X%29"[9Q_$.0#]1S#.KO2GKYT^D#>VTS]2UC&`WO at V^<8^,/( M&WB4M/G!@X=F(?^!NR#Y^8:A/QZ$T1#DB<$"`]5,XR/HR@?D[3A3O13\!G-; M%4R"Y844%Z$)],QDDY,S]&%7BV6';7'\T7C0#OW5V__KI.'KD*H$.B5ED-EB MN/A_#>WB]=L785N#(PNFPG4C"VB1\;ZD!]2_\"9B2H\$B5T^^YK+4; MK1U:K:GK@@4&RHCVQ5N7ZJN3VV&/.!!8*@U2(%V1#_X@\6X"DB(FP(*C at A44? Y:F>%4 M%"M2Q>1?8IH!B;%$?)+8#=@@<<^35!P\9H';<65(Z!0/NZI)3S+R4,"QMI&? MA"8.F1-*F=3'U!DMYF+0(R7ML RFRNW/Z/ 7AE:_JX?7?%I?1G*%JTM7:RJ+DE=EZ0NE*2>)!3=ORK$,KM0 MM6ZQW,Q;M5#UW1]7H6JE2^CI=#%H66(=7G-1/$[3CGG'TNX\$64ZTZ%A+AABL[4@!M$=Z?6B^*L< MB/#DQ)@:&N&?( M#<;E8ZSY&2A*9N$Z^8.(8G'Y!'+)"(\YD%0`VU at U<9 at _6-YLN9+:0()0E+A( M$BGIUB2U6VSE=H/+*%-/S/,F/J"%7$X3Z:XX@%.7Z.UC,!*%M&4`Y:R@;VMN MIJ2;,S(EO;-XIJ2;J[?O4(:]NR:MU.(I&W)U<&7!$'O**?NL#%<,/&RK$R^0 M\I?SJ^;RO!#$,E)QEG]:#O?M5ET>MRZ/^V*6Q]4[I$Q#W=EJ;>_KDR^/YKH< M[MLP3;266P<])%A>7EV0*^Y-+#]A #C?(V`=(';N">Z$[HS,?YYS98?M M\P79!:NI$@M*B5E& M8*H#736TAI +5$ :FU%Y*LK5E+9J>0JS0VK M=#\6[F"ZH&*K5,074TM at E67R^H:%;:+G.D-J$7X#9F"R>C);-+"6)-55^P*DR67=4J&"2/,\VLI?46A#,X]_Q^8RLY.\SU.<(TYW at Q"'( M"M<)BS#HG (P"S #0Q@\6X^YJ+F%N:',S%STB__>?F+(P!8[!Q0)P MLVJV1.LA1L\\3HVLKK3CBZHIE&&X*!X)"PLI7/SECX8 MGY3M'SM+],(K<2\CN"Q7#C$J./(TUI9K8N at 0ABR%NH;WIE'$^B+V<38980XW M at 0:>>G'*ZK"N19:MLJM;DR)M.K.S"?Q$@QFF?T-R[W):;J<,[J;SQ9VY/E.& MAK,77(@!]Z+K)4:.Z_0YAQ+W7$HQ4!(4G838RF58#5.G*;^P_$8GQS([%)W( MNT at 0PR9/LH;;Q:F*3?!0S!$O6&# ;5?:P'I3D%R$5G'$O\9VSA('TW1B&2LJ M11KD:82L^T5D#MWI(V) 1WH60'Y3E&TZ`1RIFI5IWE:A'%["#3/WA8 at 8("$9 M#\N=DDB'T%ITJ$B CV!+B^:6HN'_+.3%Q$H)O'/PU;'\$*E/>B=&?:@6XO;@]Y9O?U9CK*H]B$OW5WLYN(ILV%KZ,FP M%4J%]A^8 MY2/P)"4=&=FM`BVH2D%U`G at T,]6%1(_VF#R-*RW"ARZ[PT&(7#D-Z84%9T.*Z1<,P5B9N.%I.;DHZV MBX+M>M,23SMC2S;(5#S1BX-\&MNY*0^X*9^KE/(88MN?Z&:=SZIQ+)Q/D%)P MME7?TU-FMV7.4P\HZ(0J'YN%<"DA"A>E,S$J;J_G^1Z)*TFL_)XVI:,/LTEV M;#Q9"-@&49*Q=B'PD Z#`HK!U!NN%B#U at 9RO[ ]W(Z(F/4PKU1%& M2'&XO)Y91%]1R6DK>1N,5E(^#F'_<'4^A*:;8URKMA'*_,-("K5 at EKX0V&]@ MYV#+X/&+U10H*KG"@TMFFN:H;2)I%3$N=Z8P:9EF@"([J,_,G!:G9*+0XH=[% M/+XZH4)^'\IAJ]Q36$V/,^:.W*@;YY)>2,)HG9O>U)8A: ]5[Y+X851%*X)4 M&8SJ at TR3> /.HS_QEJ);IL(3<=:ZZG(#T,4OP4R?I1Q4MORJ+/(M>V" M*;K(?,;IK6JLM at W)[79M;5FKL547[/&$K4A,)ESC at VN"&PNPMG+I:;&*G(G^ M87=@(8Y )&O,.D at DI14@="P=BI-_+ID-K2-.-:'QP=>F$&)QYNLC49069 ME$Y=TPBRHI,IS at 4^8/ 1]VJ/2Y+#4K9OHU>(?M+,M`':F`3J'!X2#Y/]NP=@/!!Z" M9KT3 at K@@"R\L;WEN&D2KLY* MQ4LR^>VOO_8"+_GZZ[7X$SA^F\Y;O0]D^.MF?#.Q'-,311"961$_67!X!5K] M;1ZN0'GG/91;64#B1$ELEF+%V18F=)ENZZ$+PCEP5X#,@$H&:9V]L27RGZV8 M!T7;A4.."Z-B0DCCH at HT,>:QC]_"_>ABO>@Q]D5ZS/WMM at 0/)SN\$_H^B,OJ M4+^1W `O-(P*EW.S-7`;J0<_=31YA%3$>,S8\X M_I0G?CY$[ 4:U)P`:RS9$BD*T^^HO)2$[0DFB07$Q#Y(%\;)_1 at 7^J-L+UVM MQ4:&9^Q'1LIW;'&2M2 O-K+R55YHFY5>CY76QCC:V9$23)WD6>?X5= MA.Q"Y](V5YH<2@[3J\;MX[3-]5X(U'[O#) EDG1M0W0Y(]$49J,KQ#B-J:#% M/,VFZ+.AKB\^FN3'K-LP'TO4VKE5F4\5E[6T?=UFX2S-L&(R`[)-] @_G9#S M'X\:-VNL%E'/S\$^"RC;U-5B6E@?'6U!D\@\;!"UQV \H'T\.D.$Y6#-1 OGFN$-M1^)#1U7?-4%WGC%9%.C7E!@![M?T #K4+XC ML[VO_HX&\>?*+BWZ=C!3+Z9PIZ6=8-]G$_M^S$):K(6TF/Z<6U1[I,34?$[Y M3+1"`RKV(L?W>CJAZ?)2RG+%HE#Q'.!+(SE=QM<7HAR<;JC9N\:KL(D;M10" MQ6)U\&%$" WK\6?P_7 at QYU*C>M`COZ1F `QO1X*;[PXPGH!)7DIJ16:/"P\),E?:ZV M"VPW`[MNS&"E%DI;S4E5?JG.!IG>>\8K:Y&!<4)8UK+:QW Y4D%4^QBNAX_A MQ38]Y\S'8C,VBT6LD at KS%$(C.'#="^:5RIB1"F*UM at 5>C)C)Y(4PA[4X>W\Q M,(=82YT6_.!\Z%:3")1 .:Y&0"PO2='8:7#.ONIK Q*_!09GQ.C(>4-X7&9%_92^&<>J[SGNOT014^6GFSW.*V M,L42AS:Z*[-3[D!##X$;K/GXWXLY>HO'$1TKN#4\!#9;Y51T96&!-90%1Q40 M<'B+)##!J%Q#L,0!%R>\>]FA* %&RTMT+.:RR^"D at IXJ,7LGJ:3R682AGNTP M[V!\+YW1]A1P#@*N8^'KB("K>N*"V'9/]5R0.X at JX\NC2BT at 8O0+/3!/F+K6 MBY>3DSIV;6VI%<2TT#9^4^&*26Y!"S&%5\F5L<)S\_77+%]RS#N_7[N I3-R MZZ24R\O75R"1%^19CE;78=RY*SC=F3[0['PZBWNQ,)*(4%1H(1G#;N1<-Q%' MNBTOP9%QMF,P&YVDN)R0#(N)EJIQ&"(E2AEC@@?CLP15G+E$`L at L4S/[SLP1 MOV.GB-^93!%/#4_)$;_=FA"ASIH"/DOU;NR5(A=.T<7XM,*?;(/$E9WJG6;=RYUF3!&81S+D\P8? ML42+(D2F18*HD4=H:QL-JD:694=G1'T6KKG8-C I\%8$ M^>2#=*HE3QV%L)EBAN"X03S"[$0(SBZ<\SIQHU5K- CUBDMMKL1]H@)*DU*@ MEXE;I5!NX5:N:6W)-!1%JPMHU%15O=-V^IVD5 NA#;^\)"H%9B&+O"YL>US% M2-EYM]ICX at N84:=M\]]3!#::QSG<%YX &E=(VWC#/SE(>SBS&&* T];"X9C:4L:TR*I2UJW')#,^!0R\PY:$Z6&]]\1%_K["@G][?V& M#2F at -!6+(=8+GF@"S:>5<84KDC-O7$@[@2'M%=U[F._F"98V08,75_&1C8C; M/%!H-7 C#XWS'L\#^7U1H*(J7!BAGW;Z5;52-DY8]=Y%2:4$-MBNQW777*I6 M'Q%.Q*7:G6TR?9%%%WL1C3F0@[N%J8G0=T7=&V=I0P3SCU7KVA$FJ!HH! A@ M65BX^P%(+[_Y^)$CKC.=REK:6G.C=;SJL\![.C^/WJVI>?0.MK86SZ-WJRR/ MGC'P5DVE5Y+M1G+D45%C#ZMF"3F;''JPAV%OH@>Q8EJIXC,HGY.=2]9DM'(M M;U SRWO5!>G5TZ8%E8R4I,=!\0/3AI,)E,0:;&B81B"3T,;(9[2IBGTX]D,[ M(UO.464GGD/S:59PO0)HU,KHG,N2GLL>C[ .R8Q.M#@M-?H":-(BP]$,SP;' MFIP^$REW2S/59W at 0JV.S$\F4YXFG[9RS%67>#TK];_+MM26',R),B+]5M59C M"B2F%[V$EJC8;1:SO+'"P at F*)]1*BXPKVLS*L_ +'=OB>395`Y<88Y?X<4!% M>EAS-6%/A3LPDS<6H.2][+S7O at V[[+W-]FVY4D(I5<"Y%$]=V/B4-EGR\**0 M8U)N`B6FL:HVSK""0YLS%ZJ"BR3/Q^84YZA8T5WW$1-MQB2(:/Q?18B^MO#,P<8NYELO MHL9_X_K0+6^@'B7N8,C4J0QP/[(0"9<%VV?+6(W:OP:H_2N-R\_VRE5?S5R^ MCJN]IL >7\#5],ZUH%:1&AG.^=IS)FOP.'4LQOE%QV&D.-1[;C*_RP&=2-(G$'=G\H[F4\T7PS F MC0(+:>WW$VT*RX4LN1->Q&K2H09,LOO$JG^*TRWYIXN&Z58M<-4"5RUP98&0 M5S?7VL1R"MP4&V3F,#WQ8AW\>@47/9=]<:3L7.UF* M@*(E40WLV O.55,^@57SEI/\U<':'"1&63D%K>90%JL%K at O@V.F5S$1VOVA& M+BC V.RD-=G+V>"O\CF=V1BN\+)C"CJ[Z"^/RKL]>^&O]+JK* JCJR:861FH M0A7K%>7FLFJUD2*"P/H20<>E'!+J*9XRC">*, O:9("SY*3,F52YKJ_'!.8% M!,O N]G04,MWYQ=21FZ0/!(#SF.:U0N4]*)4E7CFL_ at _`;M.KFR52NI(<",/ MD5 >)LOF1_= M$R'^N 40R^M\FWJ=)TVVA\F<4=U"K"6(HS1!_&&OYU!-78$(Z[J),:>F:(;@&W] M4!(R6 at FJ/M'K'+():%V at EXP]+ F375XR<;)7) 1RWOS)[%UL'@E:]VA:,HE\ M$>?D"H4%RXAD8U[$KC1:< %(JMJ+(C$9R,"M!D]\+O/ MQ!MJQ=Y'IU+)%/'&<"Y8 at ..$D.P:*%T1@%S$YWX8CC">B:,!T.5H\B+I0U,[ M.J%/%3.$G82N;Q+@%_!S!I6YO#32TE29J2T'YB30'\,W402U\)OBEHTJ,2*: M7HH at BN&A7L)UA)HYU+$.D;=PU)'2Z+_NP@@_SB2=0?S. at HO,&0*X9&'V%)-Q MJQS>JF?G3)EZ2;;1$4ZYPH-65AI.8J)C*TXQW@&C)KJZ]B[2JM=)$?5?!.N; M;-L(WZR"$Z4,R(RJ?EIL%6.:QEF'=)7*'NYND,L[Y+4W0$WLPIPU=#:%P7T,01G BQ$UD"PSV5:.LXH;#A92Y>UR*F!@7I7]O MCV6"DXACE/0RY0)![%K&8V!1A,T/M,6L5 %8F.$5T2Q(@83LU]0'-Y]SN@=.W@%4J)D4T^9(<9H0U=5!.9TTCG.!CU-BH&YM MS8B!VEXX!NK6%@B]5F!G(?I)+1[_I+>9%"JFB!L at 93MJM,"QV,PW4$KH@[(I M`DL8A('@X'7TJ/L$J>=4^9BDI(*2^B'+V_K '><=3C]F<0VE3RMAV\4$-]@E MO77-7Q T%@OQF at R $D0;K'%6RC#'FG1"MBR at OG)DY3&.KLEW=Y(<8PXTZ;AJKK$L.]\CAL#I[%IPX3*,.:\ E'<:IG;B#9BS?8 at JR>DBASASQ) *T at 5%XL' 4H]'G:E"M*V;-EJ,=)?)`DN5-2'] M,*.L+5C L\DBD*URYD,&=4RHU'6!'< MN105.E7)`C9U0G)\Y=DK#,C)C4>$ MI&*^$Q(2>!2P#X G&OD at C1'K/#>*EW:T'@BSMW.08,G*LY:%4&F,J6=-FP.J M$S5T^JF*,.BZ4S'O:S>C[:*]2M=,(JT<0^F!!G30K3G:<(;44PKW/M&4$U>B M/=K?W$"1SHF+4LD)-Y? 7-.2B2!WRPQNAC#=Q-XJU=3B^V)PD1GHN9X/9R<' M$DN7=#QT[)QZL4<,E*(I"\(!:%GQQZ at 4-_,1W%9,K;9\Y**J.R9-+NO4%=2# M1Y at DQ39EJ9BGTY:;I5$E""Z23,!B*CP ,!-VI**G$W M5''P0R*YA60JT.8E)ZG>/SSIO M4E30I2++BQ M^9Q(R,\_G^TJIKQ-L$W1)E1*BT #(N*8D^V;E%3G(,:<=)2"&YF7-MGQR/ZI$@>A*T:2&9+OM+RX&&-&]C6%%_P]$#2 M/[N&:] '")('4ABYOE @VX8I8V0N*Z_9J0,W3HP0CIGNL;85"9^:C/41",/A M=L0->R6RKHNIY7$^$^PYC3EY6[]FVRA;9#G7F=F?*0L1AQZRB8=8`4J>`4+Q M4!8?^G"7TP_]KIC(70>G<8CK3PS(;)VX8FDJHSLCE;'@Q39R,V 3L0A:PF1TH:=-MXF+AE(Y,4E)PHLN\. M822Q@#'SF8%,INFK8XJ]F*T+,HZ"8P1VD>W=U$5;@!)%D9J8_HHYOP.".)QZ M(>:K$?FRH\P:FFJ!Q?H'6N9#@"[O&#*AL% UOP_Y3G"$W>33::03I%)PMW9# MD@:)UBH<41_!.>/;&>ORT]BPP104M>:-L8 M(%1S-OI%"IB@')&/IJQ>@H?$1 DX+8_8(S?+T1,3&Q"1( M+"1VH7+1H>6E^:$,K;>^;,&3I(?:2*1'*D7(."$N658(09VW(C?AKC@=$+?H MX9 at BK?3EKW.,\X=43ZK)`">^F5[L!\P/2#3S_:^H>NRNW+X+IQS*K8AN5WG= M8=I=>RNW'Z?HWP$AZ1^<8^=#Y?NA\WD8H9AB-V#Q$9Q;Q5E_#[M1..RXPPW\ M.U3==ZW?-GH1/&ZC3^M_N&MEK-(7C")W>. at 2%\G=Z :=?AAMG"I$K+C^(6+V M at 74,^V57P3_O.\RJZ!]B`DL_'02YRS -;VMK7V@""/6DGVQ$L *'0'P(L,I= M[7N!PK4_W%VUHP!G!?_Q`.'-J7[#,2[(?&9$]&07%2)A3.)@_9DS!^^:RN!L/Z*&-XNQ[#D8F9O,.]G=:>GD_K^ZF3 M.D$DNJ;O#$(Y"YGPW"Q&*C,)1?>O"K%,84?[-^=7,>9:`'#N!S&BD0Y3F*0( MA1UZ&/T8N5ZL#C?V>64_T>:!J1%.\MCICYS2\MGBC&8>R;?#$4HE at NO"K'.D M@%&VR4R 0F2+PX8QH]YIJ-O'9:31/Y MU!5[(IJS.Y@(G55_FX4PG MH5T+&$_, at 4LI1LW@!?TG at 3P,WX3I%DP@@EM8^?10=#7@%I2$0(7C_*M\ZF5: M9YSV>E['(_1$C\PD#/7V!)V(S8UFG,]# M'2Y_%JD,M1XB?!?9(Q>]!0!,.&!Z%&,,[(#GF5INJ:#-.Y M:R+N)/H#1/!??0L:V;M]$@I'*!3R%W;2X"HF.G1<#BATA-(OP#:[+I/+1T(/ M5)M42DQ0(!2>^>C^0)!LML_(8N^2>0.=7B#/#%K79:(X#K%OE3&DVI)$F:IK M0$<<\Y(K_=I6<7)=9FF(1B*OH\X3$*+E$XX'08@?G.CC,"6 @95%[[K,*=;! MB"NAAGX+DV7"E07EPL664/YDBV(FA;I8R0B-AM=F1 at G4CDX6$;O##N4_%%M[ M+3U<*7FRGR3#P\W-T6C4&J@$6$<8^G$+]L4FXS:2>'-8RXU7<)>O==:=[5NW M;C6=;-V7E]9DL?\J3PSKU6;EXHNJW<["KQR[>!D9UX'//W%/2*[(4E<0HHV2 MM X$->()P,7X#T:N*)-N((7IE$_Y+1S[GH?PVXM00NP2J("'Z5RK#2YC#J_7 M<-%BM%+ at A(T>32&0Z97/HUL902"QH$X;B(:H)!*@%R M<6IJJ:GE&LL:ER5[W_X$)V7$T0#=4H2H1DTR(D(B=)>7NN,`>DIRKT9=VB&Q M'9UH0M?LM<+LJY1 )E,;6MF@)QARI4"B-GARC $AF&Q78:Z+\Z!;[\L0?02, M^F,=J(S>AS'T7"=L&5#T9!K#@E=+DV#@*-)YA*P2U%/I! WP\#>]H..GF.^# M@)Q_]_<,2)*2$07S42 at -9Q4+*7[&2\X:,N,E6=1+X'4H MF-D`@7&Z:; 8L>H&W5Y*\\*QD1S82,D>@&'VW6$L$R8)OU1B)X^AM*Z(X*T2 M=C(>N6/&='& I>=[5*,>EPE#PA0'-PM"]S0+Q4;AX+K,DW6$5 FT^R1,E([&P7!VP>/#\;&:.SZ >2R^ MQ7\;IM<&VN!F"1C=+OFN/$R7KO-#TOE(M0KL,S(,3OG4OB8>COA#.EL>,G4= M1:HE8OD:H][^I3[_I*_6OOB>.-W6QNW6E^]O<[?-.&V^^NU2'LND?9S MW.IL>XU98,Q0PX19(N"7R*\9-P69C[,C4X15/L4:E>F(X[#C46 M26=N+FU* ME71!$Q&)=HJ![#'+2R:64#,>-Q+J6:?6X.8@\#\+BK'-!'*LR LM_R,*U$GAW0 M>_HN2&JLY5QZ]VIA\/H(@U;")COF7"HXXA[C&BAF\TCDYUO7R !_AI0+^33M M5D+\$N.%!+CJ[%C795*)@BI,*84$HKKJ45YL+63;9P$5UR$9NY(YA@*CK\NT M:S*,V;9#";&@+R!/EUC4 at O&D-6VQM%.<.N6Z3"I&`"08J84I/SH82DVEUW7$ MVZ""0<>/PV8)BW C=7W at V!W7QPH`"6M]G)(03ZF.FYPID8 7J"P6$-/(9%&" MUV52.S")F*@G'*A^.+HFJ/:NZAE^]XCXV#UK4ZU%NEB+7:#E\)KHQ'-3;?X^ MX^8Q3]X18]!:$?X=KH5Q"\N0M>*A[V&,MI[/%OSC=UQX:/V+K:_6WV:S`WI8 M^5T]S1/3K.?/[79-0BN-3V^5IC1)<3ZZROU_-;=&#W>*YP M`H]"F$ S>4R0$?^I)VYRXD 4C#^B++Z!8\UB"P.G*+G$6LTV)Z=M(L-FXK8W M*&G at X?8J7FA=.SC*6W5;E+9GC6:]ILAS3:W7<]8&;QQ]$L),UE1:>2J=?!*7 MV8W^_NPGV:!%_ORU[?7K>YA=EI_B..AR,1_MJ]#IJPNNBD"*/V3EVJKK6CDO M at ZG8IFV,4JR+_1EG]36 at P6PQ.WN6=;^KU #5R5GU]K(\OI+/=$JADHGU/F,6 MMVME:':-E4YH at 2NW85%)( C"8$Y?)L=:)43>$)SGVEB7K.R[:P11!7FLU1>_ MT?KB6U3@">CT2EP$H'6>X$RJ*$+4&(*7? PAH=HSDG:)T)[7QUJ .3QHS,=$ MK9F%8$HYUZ;_($T>].X!G697U%+&I)2A+0C61'ZQ]55KLDJQ4\_=Q-R! MS7G$"FK'=S8[SF808HGZY:7-#T+^_NTIYA>QO#ARE:Q$/.!;QU9K1^30C0X/FW=O97)=8),5^II.,U[,_QSY)Z6?$/&F, MCGJJZ]FK#6BU`:TVH-4&M*OF,OD(583N=67XEX7:>O.D^J%3L4FUI,&B&5N?(Z7B))1FR=?/)!Q6S5::PS5':I+A2H^U19*T9T MEU6'MUK]9(JV06O?"64#BC&32@>45B\>H&D at C25E#(?+6E5A!I$P_5!4L(YH0VO&CZ at IHY;T3=?)*A.XF%,'"Y;%IA+5 M%")WVJKCXO2@=52Y,86+F=U289;1:HWVL&N3_-3QO23QL1(VT2KLY2<^O1XZ\_?GS_X_>_JF?\ M?"%#RTLFFM6+C]M8";*3P#37I'P9`43.1/R0`@$N<%;381*B9K):3_NY.,AV MQD$RD'#-/BI,MWK:4?#H?721UVS at 7/2HMW>8)F&OWM^E\^GUG&0'$RHG MVS6UU=1VV>S-CU5-9A="9M=-9KELUT<_'&5E`]!B799 =-6.O'VG0J[2ZQR2 M2U.J\\"9"F*V$Z N at S)1!N5Z5N*Z'L.$M67UZ$CGJG!%]>>O)<$V7':M<@41 ML1O+DYD;+\!,'JJ+*:3SN3QX=LP>D1C*B;0>UXRH\ME0\I-:9S at Y9W$A4WG! MR^4\'ZD?L **&Z14/@C+Q, 1!]= M_*%;2I $#"#"1550;>CKYXZ\3A.U*!I ML/CHZG6ZZ%.S:A?582ZU9%5+5C,D*[O89]L+OLR*\^&GNN;GA+'\]W7AS^LD MG=)^*,BGB/#(R:9%H2L+9+I.PNJ#]C=GE5>!QUQO>148[9FF3QCT]9X\:X^6 MB/OVO%[W"2F06:T`U?)R+2\O)O?E!>9"N7,JQ,J5I>+K) (N*C"7U;.NA>8K M+PXN)C=G\DLN#^3Z=9RKW'']:U.O<&UZ08UK)2#/(ZB\.'P=RIYJ8:H%P MH?FP,ZLP&GY&Q\;A8^*,1L8NS7XZ!3+VYR M7C"LYXAUQ*DZ,"<:HR#8A^.D3]7NT90UC%2"6<>HFJ3"7% H\I($"Q9D6047K/Z98G*N!&LL)\$8\.4E:L9^!M;1=JBZ)7<:`^9/(G<@%9_M*'4/ M';K0C+^\Y+O!2>J>5$@A^3DFIO.2)G4&7;^1BOON4-' ,+M=2(6HLWKUT(^. MBCDX-?$P!1MPLKZ*A HY0Y[KPW1V];4Z*+R ZR6^$'+%P=*TRY0"&R M(,K#-5B ,J$0;QF]18&;7>^4WTTAKIT*,+I?PUX>A$%7:+'GPG3&R4:.^AY[ M`^@M_'-RRFQ5-]NP M1>5M/QGX\+91OZ[?2S343:VI#L<7_XSMK:V#@P.GX>!KJ_#7V3O8OWG3<6YN M[>P?;.UN[VS!=S=O;NTUG'IU+O_UICF43T%<<#:6E-^'_CG/L#%(_\3:2/B=R<=H@>J.T1&>N0I4%\X<, M?3 at E*9V%OA$SRG3#3HI?DL[?U%E8,"]PFH21Y_KP-E:*T-TCU79B#Q0=NKN? M),/#S6Z7 ?J99][AOSL1,.Q^9#I,S;,,[N M`*:>?<+H.'S F\Y=.*HBG#"$I0^P0#:G4.4GQ(A4=]%_(6(&GN:GE%K!== E MNKQT\O7 ??I8KCYRMKE9+&[.B5H&<&S!B=X'.]T*;!85;VXC?"?' MY94T$]-UT- *);5=D>M?A[/UY.O@,LZ89X`4R/L*+ZO"4PE]$ZG'S=.2W['M?G&)4.AA[CK@*94F\?LS"2BCOV MNCH3LO[J,%NT?$H?>"TOL33,E\H8<3V__MH+O.3KK]=BY?=@.V)@:--YJ_>! M4 @NVNOX6RO.JLL_KU M6+O1/-V$K9J'YS="R^U\FWJ1PKE_W:;_+^CZKXZPFO'"W-)@NRW]@ 7N+4YZV4I,/C!;C;+GF5\G'V=/;\FMUL^S M[K468>KR3-YN%JGLP?K'DMFU%[)LN-;O^FZ)"C.-9*NO]SW=:Q:]R%-L:M;\ M"_.?37"55M^-OWZBI"O%$MPV,YNX]8NR6[XZ6DV#)T$X"E:+3\ZSK2H/SM\Y MY;D9#X7#MNN1GT"/GNQ;ZFC!(3##*Y]7:[_;"\4/R%8IME>IR;^>8;&>XY0M MNMP\M at I3AM,SQ:U#DU5R=)1MSY8[Q.^LLR,W^U8G>0DL'J9G:O)8RM[G-ERA M,>J87OA"&[E.9*D2N \97SLL.Y?,V]S#\XU,/KODKAQBBAX]M!)3V:.W^*6> M4.O27(N:P7&#/G&KPXQ at UU#T7>.OCXY(#FY]Y,7)8WB7HTTJ"XZ748)R?&/_ M6C@/=:=BFSD6Q:SR6WSK%ED/B]'*BN1&,7GLTN]&<,,_;SKD:=&2$$BW,=&_ M#M]M.<[GGN\[RB,+6UN!TJ$PNA=_[*YB#1[_/ZIZZ=4% AV6J:TG)C#09PQ M<8'MF+,"6<_4DR7'CLPMLC>GS/3\H4=N,+.K\W:N&42^PD.1B^+:PW3`%3)'MH!8C5TQ=$@A at VLW UZ M* $U8F>(1=P3FT1-'\2X01K060<,^]<:\\@-DD?2(6Y]K3&B3N*1_NBDYP1)GU4PB"Z ME/"6[%_XN":PGI#-;U%*BW)Q"V!9I?+_F;115=N!_)^\P6KJ$Z:9KW at K/\(M M:Q6$`J;00P\BV1RS.5M!;SY-V$JKU7*Z>!Y at M3PLI7>9>_/H:&MB@!>W],"= M(O5MJF+X[<*6O735+V3%IRWXPHO]GX4P>*I_1JQ;V_JT(3XC@^*2\G+DRP?E M6>"BNW+D>O0!FYUVOC7+6$'[2'.6;V 4!;GI`Y17T#D]ZGLXL$"A_3S*)YF' M)[8C]F-G*"C[W"FIOE4X>BAE&PN*1UMGIWNQ/>0)2X3+POZ02X]6:3U7)Q8_ MUZ7M:3=G":MP%LS76 at 4Y_Q8;P5;Z9>R<<1-I:\@$Q98.]^@5JKN%=0:@0U/ M4JTS1S04097[7]:?!=A/>34Z+?#DE)D)=5%/E$V=A[D?7R\H2TS>^086D:1( MT_:PDL/(898W3]TM%RIFK>K$]C C.YI`)[!"XW,-BH63R at T49&ZSR9( M9^C&I8?I>VMB>\DH]-(6#?>Z*HEH#O-^F<0MF41QFG;6.+P-PLG=#W M50<%E3H+*F;*?F-"*;?OOZ&=R"A1'7 M[L$?OWO0,E#SAOS833K]Z9Z/PEZWF ,UBC MK;G"50(-7 )#L,0!:2/GV,N/+T>R!9.)3C%/M[X]5Z[1HJ/E%EWL1AZB]4TA M-[LEU)0]I#CILQXXDV%N:889J1/U=%B4B&P^BG(,A8-H5M9%N/[015@[!E_ MDO)=4>HS\O$8)6;VHKF^"<]P1F'J=UDD9)=D&*B$ V&7-[ M&(5"W)@Q?W"9W6%T?*KHE.-GG"CTI7A>%_DMFYTX;(8Q\7)OQECMMM:R(?_8 MV"M32J0L7ABIEH3MKIV9$>=FY\JRXB^^0A/.O3!8!5)GT1\;D2C&0:O5JF4T M9X+ 6 at .^+[>HO/?[RA_")!IT[@08-X9=_'$8)Y9%C[8CEK14BCRS]% WPA7$ M1M'&Y8<=6H,$ETL,AH6-H3E%(DND6.)F^V1(.9R6]#* M!Q1U!1)A0B(?J+WTBRX%R at +?$S6&2^_WF._T7,^GD#E2#='5.'+])S'YA3./ M-@=-L160.R:3;_J,308:L\$I0,. at HZBG>M3X.)R5)HJVLOKXY<#M(NH#*XPB MU'U WD^^!1_++N_ 96>I%F]1+.4%?,C?6)X3IZL\PC8W,U?V7"**8 M+>RQ[$H-TB%N,O)P(7TZK) N#%G A/"%[.^0]0WR,X=^)!6OV>=,5MOI8WL/ M%B>5?'+3)E;:6"^]ME5 KN7;GWJ+):9,O6/.8A6-;9>T8-3W\D6;W<'I??LD M=&0%/Z#N99[UTLD at O#[73?NT49;=7UF^ ML6Z=(^+X,T4W"/<^R\&2/6G1.\_&W/-=KQG\CX3!7[(%L(B]JF($G'6O M+4GF*._P$$>405R,M*N!]6M3FI^+6+X(VZ-?9GN<,LYG-T01C:28&EXQ" M5+F<3M]%^5E%:!7HQ,P!"0Q2MP`;SI=+W[BK'73_GJ3M?B$O3QT M"2:)(:1,>RRN8RI=W^+P<8D71WV=X<=\$V>1(7.!TT\':*N CB=-QA"@TIX; M#M]D,]UCAY*G2B>I'7HX-MJG/L83C=CWWZSVPTPS#!(P9CRS,CA,">H$W5Y3[S M'.RL.^QE5[:=@GJ$W\'"H$D##3#:Z"LMQ90ORME .ZX;=7W,3!/V\K_B`W;7 MV2P3RU,8K6'U at ZNA,./31]GTE.$Y8C[/T99KZ)*/M^G#J8^Z%_JH*UAL;2QO M9()NYJ8KR''CJ;0P(XZKR.2M6$O+RI2W'"Y^/BS:([:?9K at DVK[,80IQ#,6C M8Q$[7G9)6:J^\W0;%C3#B%7JJ2"@UJW at L-(+2O&Z,V%WI4I+[LC//\@^=//@ MU+5I/3(HQ,,RN6D&5'$"KY>_9]H.7K-V!,F$=INRD>#,Q? ?]$QF5C%]9'14 M`"V&0!3KH/#;, M\7$>JAB]3N2@:+(O`4MPA0':\"+,:1*(C(;>@58+L[?]0 at CS7=G M_03)(^F/,,T?0G?T;@I VA]P"!MZ,T"V8Q?TWKI8>&/M4-&H3(3Y&7"ZR2 at B M)'$%#OKRH=2'_(]$GUW0_KTPGC2(3$@6#T]>A]>,I906% MQ]E'*#?PM)EO<&6EY.'&Z_7"Y/_36=^N at 7O_GN_ZF9M EY_]T MG)VM;<2_],+.G[:5N=3]O[N]M4/[?W=_;_=@&\Z" M[=V]G7K_/Y/7?_?)\M+_\;__WS=IB5^&?[&ZT6A\#_]_N?&DT?@=O'FE\>1& MXWO-+[_1:/[,KW_2>/[ M?]I0C88'=[W2^%MHX:>-[_]C^N:U1O%4W\8>-[W^EO_RI_O*/ M&M^O-M3/J-T_Y';7].<_XL_K#;7<\/X8OZ7/F_JYT/++U,C/&]]O-=3/&]Z? M--1+?-&VONBG^J(_;7R_TU!_:E^TUSB!&?A%X_O]1O>UQJ\__/Z AOAG#?4+ MFHD_;W1?;SQ:0][7>:GQ4N,&S'S\1_ )IOC[G^+,_OI#F.I':R_!=Y_$?PG_ MU:60M(_++DZ_AFM'U\8_A?^(OA?_#-[;JFG\!_"%M:OC?VJU.UEBZ=5&C$V^ M?*/S2N,5JXNP8DL37?Q#'(J4R^,:!=RI5XJ=PCY8NO-D)W^!7Y1$;$_T?CE[ M)!?.>GU*AX%ZEB@Z5UZ3Y?D6=S-GYENFJ7'V8.=\_V?83ZMG#/TW#">0WJ3:UN8P])1T33FHUYI`C.P M[U_ IZD>!;J=1IM]A6MN9UFD;F1A+#395 at W;^!7J-\SZS_4/=A5;(L="9=OX M-?A.6[2R+IC2:/&?%[J0A3U0[^PR:I,D^BI\P68<6 at 2I_T.$-$$HP/8;_QR( ML0E_?W;C]9=^]C+\[[6?O?HG-_[LQA^_^F?PS9_A._S?J_ at 7_KWT^HW7;M1G MZ-64_U#VOPCM;[[^M[VS1_+?WM;>[L[V`7ZQ>[!;RW\ODOYW&GI=UN]8U=,* MWGURI>$OHM_5*MT5VO_]9U#_!1G /N__G8.#[7W:_UL[V_7^?Q:O;%^_6V_< M>O^7VW\N=?]O;^^CS9?K/^WLWD3[_^[N5KW_G\WY[Q0H(+?PSH;S"&LA$I(W MRS. ^IT:A+ITE,!3[PJLAI$P7"VHG]E_N6B0W,+X6&PD0'TMX8!=;(4!L3T% MB at HF'9:(XL at -8I_A7F[6#REL2) A*6%(V)3'%A0',2]M96-^-!39I>)+"($Q M-; 08X,-#*G08D<1WD8Y)R$\()1 at 9)DG at N>&#N:M"1*N- MFM_"[](AU&M]);$>Z&[6^;#T%J3:HEBAD1,S4)9.4*HUZ,FNEJ61P54*8=$- M%:M\F5)7II7)FEC3RF9Q=2SS(:+*6]B'S]5J) !H*M,Z\ 9>YXFV)O1"+)2% MG_1R2]_BJB,UQI2M/.9"6XBSZD18)1037-J6/L)L M4W!YAG2/7*VA?'&[_;VKC5^NKM M]94F7'9_W9H'_#^%['>=;AJ9+ "C at L+8A'Y:+ C$ M"$N,XNQ-/AJSF5IK*.PP5+3CL?TDHDPPD>I at Z0#D$Y at OE!-F.,ZQ'X?-R4%) MY@&XR?4[*:?- at R[3O.$D=US)@I#-O.KUO ZQ,$IS:N"+V$X'[L/$>^% ]<.1 MI"Z8;K7+BK*5X*%BOOZ(&4 KPK_#M3!N831<*X8C)E%/$]W$!((8D[>\O8+; M;$7BN^7"7 T47<1R"D*/N] LV at TU3*G'O^--1[!K`W/#BLFY3)%/'V$Q0\1I M9M>WD$EC$(>52&!PE-\@.J$'WFX7HAAP'ME\6H'JHQNT3H!$AFO;ZZ4#-/O- M-62LMQWF[@E7#_ J88$:0VYE'8/\Q91_$Z6F7>- MF"%,5*O/_&D]8U!*ZB'Z0!F4RA'QTA1-XU,":1V1HKFGT%S.%#RW]E]S5L)7 M38?6S4!;)6 VP=[',(<#Z-_12L=W-CO.9A#ZX4GH;'X0KKP]A5K?7G%6WI8' M<2L"!;M+X\"1KC1SOP_&/:(ZV Y,>?)4H9/XB"\P9*91:Y26="W+9COUPM>Y M![$-R)M/#7BB5J(&D>%RU `DM8K)6P)FI)AVY0P4@:>WH8?,$7!68M"K>\=# M.+J*CU96K%0AN:S?)0F_L]O,N[=G)L-&BBC2$\DCFIR 7G1+SX at BA"0_PGGM MYI]OG\UTDNFSCXY#/#%C*L9J$T2NDN1 =6 %O1B/JL\9:2Z4$;A4\!2/FDRO M0'Z%8N)@:$6)&80[9D93;DS'H:G+#@W?P=3P7M+G[#UP?B08*N at E)H at .GX)T MB9DGL=T4NOGQO7UX\DE V at 4G#*)3CBNFPVKWO6Z7!0+B77Q88W(TU1WK:O4! MQ0VX'3B:.4*&2KCBY+PAH-0"`S94&DV W9-MG70^V3'OLL!9^%*'S>8)S(X5 M^0)_;SUZ_/7'C^]__/Y7UMF29;(Q6>KR%>0$BU.L5?4Z=,L\MSQ I?2AA7C7 M/*+:REAO,+K)SNUD>]YU=JQ*28<-N=+RQ 7M(9^.A83S20UB>M3)[,UH/SAWW^,>MG&*6M%.4$X7:5!&6=J<-;*2J;>?-.OB0J?. MLE!3U-#W^B0]QK?M-3**9>DZ&4_PC*6BZ<@)5.O%NUM3ZC9.%_W-ZLQXO%F+ MXL/M.\_TZ.6E7-TTS$LDI]L(2/\JV87EDHC3X.&M'0B)0TJ,FKI;] M=_>YX;]W:OSW"['^&&GL;SZ?]=^!=_7ZOPCKSQ9&X(B7Z?_=W67\_Q9L>_;_ MW#S8K_T_S^+5"TG:H%-8O_F.W]234^__"_$"S_'_'@#GU_$_-P]VWL MU/O_N?A_2Q;>V7"..?*_ZW1 +H\PLX-4[1B+5^[8-N at 8!VV*F9XLGV]6ON/4 MC3PW2+17$\TO.@,2?AY102 N&4+IF-$V(SW 0%53'0C)>A_RD2013.N9"P]J]1:[D-V4N\QF\C*:`V_A)%#2(MK3\:/A^K2UWF(Y M\4WG?9<+M$K'8@;'I%% Z6X(HT/>];P'^0%U?V$/,FWF#QCVXY!/9,4H)ROD MHRWSPF+%U-DN9VIS_8OMK]:/CMC#;!O(W2KVQL6>Q*[L:6;)DB>W[%2\*RN+ M7-1J??FE'-5??CGMCD)ZW'S+I2YHM[0^ZSRB+0E9H]7$;3,%OD%'0XE3,B,R M83%<=B:KW8 R`E! -W>:8&Y"8FK=+F<=,>Y)P6Q%'M9BM1.[VW;:,E0('X#H M' T5(T(8JN&=*F"RIU[L:69E'T_0T at -$B[#?<^@P.L2+;?0(=OV#-$()9!!& MF->R:RK]D%]+Q[3,!.7&G.?F>!PCE$SOKU=G1)].: MG,'69EPWG;/E;ZK.W'+WR]4_3MC,*C4.W1BFR;.$T%CTJBNT?$[I92>3SS+G M(A7FC?R.R2=(G,(^JH%SK'Z]\-@<4*7C.!UH`9W7C>4R at QR.TPZHY=FWO5/P at BV\* ZZ.LB M`%Z5L59E8+ 9L"HFMU_+T2W9$ LD-UD4/Z/&Y,W%Y+UU^?B[Q3!5DW:X,Z'8\B;?:N at UMF06AIFKCKO2>NO+^9X&/%!O(ZZ?1?)S31W*5E^F<)3(V'FL]]6X/7ZM?S]_\+:5\``JQZ_M>= M_;T:__6"K/_Y$6#5\5][NSMU_I\:_U6_7H3]#Q1ROCQ \_?_EN"_MO9O,OYS M[^9>O?^?Q6MSTY3%(74)E$B"CM0S4^]_WO_GSP,X/__?OM[_!UN4_V]OJS[_ MGQ'^T^3Z(SZ_8F7_LS("6EP"$Y-P.GB3#7!Y25N!=NL$@%=P_W]WV?M_>UO+ M_]L[-^O]_USVO[7;]?;^SFQOD^ZSEP9U'8?K)_]?\OZ_N:/C/[;W6?_?VJ_S M_[U Y_]"]5]L/F'E_7NC9A at _ZOU__@BP,\1_W3S8JO?_,]G_=?Q7'?]5QW_5 M\5]U_%<=_U7'?]7Q7W7\5QW_5<=_U?%?=?Q7'?]5QW_5\5]U_%<=_U7'?]7Q M7W7\5QW_5<=_U?%?=?Q7'?]5QW_5\5_UZTK[_W>>6_[W/<[_?K.._WJ^ZW]^ MW->B^*^=78/_.#C at _.][-?[S^>$_R^J_;VXZ5"+2=?R0+!AP# _(.('"_#A, MWS@?2JP&B;UH^__\<1^+X[]E_\,1L+]/^W_W9IW_^P7:_UF5^-(M+)NWWJ]7 M;?_W+^09<^,_]PZR_4_Q'SM;.P?U_G\6K^QVJ;:>ST at 3F?8!OIL*G]Q3#$"*WHL?>=N)$1\AJ%)Y$[0(@XJ&6Q\VWJP:,& M;N">( I>2LEK!S)TP.#:I,X]X<="."#"(0P>(6 at N5>+%^2=L-SR)/"F!.XS[ M(2'Y'@12AIX`QPA4(]B9*;1+8%.&TR/"C1(/^+YW at J(VXY;>$! =Q J"I=V1EW+:3DXF@*:GH;F'DS# M;9XQ+0,S9D<,\7!'KFA[Z;D?3&J-A8L9'F=Z^6"CEF615$:\\#0.L;W at .B-_JHYL%_%T< M(_T?U/C/Y[?^ M8KCK)X/+QW]L[]S<*:[_SM[^S=K_^RQ>[\$:^\[3 at 1_$AZ='*R"G',:=OAJX M\<; ZT1A'/:2#3A/#D\'/K!SOC"<=6'8ZWD=)7_,+:,%;AF%45??<+1B.?A& MNZTP.ME\_.GFI^_?W< >[VVMD,.)SE!X]]Y )2[Y!#?4MZEW>G0W!,DF2#8> MCX=H3*(/1RMH[-W$^]\E7&H,1RDT0YN5H!<3 9,6)AUYWX#X]6MG=NKFWLHE-;>*-[[WQ!7JA>E]M M;-!W,O/PMAUVQX[O!B='[W^R\=DC4MV/VGZJG%-Z.TPCT.+YVJYWROZ+HU7H MU8;RR2]_R QG%0?:W^$KAT['=^/XZ.,X9(,V]@`&]$:<#M%9^OY at F(P?NI$; M?W7[5T$['KYK>G@;1CB\_=XF_W?([6W"HV?VH1?"!'(?>CL35[8IM=EA$ ;J M77Z_D83#PSCTO:[#1(34Y;1N[@^3=X>8M"4X.=QM;8$6N at 6*G/Q;G1C2T7W@*="48"3QT VRBQ^Z)^J3 M=-#&&_ 74!M*!H+W;K35"3[NO4V\3MKABU?P8OC<45$:@$H^5O'*[=_+A0^/ M?_V^8U]=TG2L0+=%CIPU+W\LSB?]*^OZMKG\@L<,#Y_9I?-19F\Z:=Y3:/YQ M[J9Q$@Z\[TA1/!OE/1?2>T:[W![G_NPK(SCZW[6^V1A%[A"F@/X";:,S/O>[ M&W3Z8;1QJC /INL#62.-GL#5_;+KX)_W'8 at 3<.4`U&LOR%WDJUYRB!&K*GIW M>^M87SC-_V%2(#-J+45R 8N)A13&8YH=2I'>7[N-%@/8ZVZ).L#GSJ MTPZ$-Z?ZC>L##1WQ8TGZ2.@/_.TZI_PCH at +X'791SYPT2IV#A=8DL$&X!?J& M`A'DVW:8`)'F+J3Q"HG \RZ']J#A"=H[^]IC>[/6O^+J%YNS*:#B^L_B:OB8 MJ8S-69"7(XLVK96Q=(NX3G2N_R#9!,M;_(6K9JWJT?JE=O_\;\( MQ6T]'?B7'_^YN[53L/_O;FW5^1^>C?W_J3'_5[#JBQ49K=!DA/[PTQ(C]*9< M95TQC-2IIT:MT:!7]G/F=BK[U29*RRY=K^'%^_^L=;K\^.]MROF2]_\=U/D? MGLWK1N/U1N/E__-&H_%*HT7?_ +^_>K5/VK\L\9_ at - >^^]E+__:U?WSU3^'=__O2Y$/NAFGD at 3S[B1HU\$F-QL8-_OO2C1L- MONM_^P]\\7][`__[RE\U5HXCS_6=.PCF-7?=H*>]_M+?_,W?O+0,[W:6&C<^ M??D&_=IH_..K__8UI[$KUV#S^AG97?^$[GK_Y94;KUEW28"J\W;C+QJKC?\( M_JTVWFS\O+$L5Z^^9#_C'QI_2;.%O]R%%JVG'^, at G>,A;"B$ISX.G8_=)PI: M:L&_'6CU%OS=I/;_ at O[[*_CW?^K<_F3ZRE^$__ZSQ4_CO MG[^"H9>PE7N/&?O/I&X]\W7FI\_9/_Y>5_9ZZ#!38S^S+] M_?=P/?Y=O8%KSW/WO9>_^![GNY4;V[F6YXQ48%W_W7[Z6O?N] M7/=*(WOWBMSQD\9/Y+I_\UKV[K^7ZW[2R-[]I/%RS9[J5_VJ7_6K?M6O^E6_ KZE?]JE_UJW[5K_I5O^I7_:I?]:M^U:_Z5;_J5_VJ7Q5>_S]30.#Q```%```` ` end From Alex.Martelli at think3.com Thu Dec 16 11:14:00 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Thu, 16 Dec 1999 17:14:00 +0100 Subject: C++ (was RE: Python suitability) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D4E@pces.cadlab.it> James Logajan writes: > Alex Martelli attempts to ignite a flame war: > Actually, if a flamewar is going on in this thread, I'm not participating in it (the flamewar, not the thread:-). > > 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 [snip] > This would explain why the syntax of Perl and C++ suck equally and yet so > differently. But Stroustrup at least had a glimmer of a philosophy. Wall > had > none. > Now _that_ is inflammatory, my friend. And quite false, too. One example: both C++ and Perl deliberately set out to mimic certain aspects of C's syntax -- C++ more closely, aiming for almost-but-not-quite-compatibility in fact -- in both cases, not due to any real liking for that syntax (who could possibly _like_ it?-), but in the belief that finding a somewhat familiar syntax would lower new programmers' barriers to acceptance. (In Perl's case, other languages that could be presumed familiar to the intended initial target audience, such as Unix shell languages, were also kept just as firmly in sight). They both apparently succeeded, judging from the huge usage bases of C++ and Perl today. Java deliberately adopted this same aspect later, of course -- striving to give superficially familiar syntax (hiding perhaps very different semantics). I find it sad that this philosophical stance worked, not "per se", but because it does suggest that programmers pay far more attention to surface issues such as that of vaguely-familiar syntax, that I think it would be wise for them to (and perhaps less attention than they should to deeper issues such as elegance and cleanliness). Oh well, so much for my optimism about human nature!-) Another example of commonality is the whole-hearted embrace of "multi-paradigmaticity", just to coin (?) a hi-falutin' word. Wall and Stroustrup moved from a very overt philosophical stance of, "it's not my job to _guide_ the programmer in any real way, but rather provide multifarious possibilites, among which the programmer, being a great designer and architect, will choose optimally". That is in sharp contrast with the language-design philosophy of many other languages, which _do_ attempt to guide to a much larger extent. (Incidentally, my newbie's impression of things is that Python strikes a happy medium in this respect -- but maybe that's just the happy blush of blossoming love:-) -- not going out of its way to provide many different/redundant approaches, but neither actively hampering what some consider 'bad' things...:-). > > One key difference is that, in C++, you _can_ design and > > maintain huge and flexible projects -- the language does not [snip] > > constraints of performance, where every microsecond > > does matter). > > I'm sorry, but drop the "++" and you could have made these same arguments > two decades ago about C. You sure you didn't cut and paste this from > something 20 years old and add some plus signs? > If, indeed, the philosophy and practice of C++ are so close to those of C in its heyday, I'm not sure why you should be sorry -- since that was exactly Stroustrup's guding philosophy!-) Alex From tbryan at python.net Sat Dec 4 11:22:24 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Sat, 04 Dec 1999 11:22:24 -0500 Subject: Tutorial for a NEWBIE References: <38486B60.FD8E97E4@python.net> Message-ID: <38493FC0.CA7E85E4@python.net> "Thomas A. Bryan" wrote: > > Nasshi wrote: > > > > I'm a newbie, and I need a tutorial. The answer to this question is now in the FAQ (4.92) since it seems to come up often. Pointing new programmers to the FAQ when they ask for a tutorial will hopefully also remind them to check the FAQ when they want to convert a string to a number, for example (question 4.44). ---Tom From kopecjc at worldnet.att.net Tue Dec 21 00:33:38 1999 From: kopecjc at worldnet.att.net (kopecjc) Date: Tue, 21 Dec 1999 00:33:38 -0500 Subject: SystemError in Learning Python Example Message-ID: <385F1132.3DD500EB@worldnet.att.net> I have been trying to run the example, contained in Chapter 10 of Lutz and Ascher's Learning Python (pp. 288-293), entitled "A Tkinter-Based GUI Editor for Managing Form Data", but have been experiencing problems -- basically, the Tkinter widget appears on the screen, with labels but without any of the information that was supposed to be displayed in the listbox, and I get a message to the output window that includes the statement "SystemError: Failed to import class FeedbackData from module __main__". (The full output message, as well as the full code, is set forth below should anyone care to take a look.) I realize there were several typos and bugs in the book (which were reflected on the "Errata" web page), and I have corrected in them my version. I have also made several other tweaks to the code, but I do not think my tweaks were the problem. 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__? I have tried tracking this down with the debug feature in IDLE without any luck. Am I missing an "import" statement in module FormEditor? I have also tried out a variety of from/imports, but again no luck. Any thoughts or suggestions would be much appreciated. Thanks in advance. ********************* The output window reads as follows: Traceback (innermost last): File "/usr/lib/python1.5/site-packages/idle/ScriptBinding.py", line 131, in run_module_event execfile(filename, mod.__dict__) File "/usr/lib/python1.5/feedbackeditor.py", line 6, in ? FormEditor("Feedback Editor", FeedbackData, r"/usr/local/apache/logs/feedback") File "/usr/lib/python1.5/FormEditor.py", line 37, in __init__ self.load_data() File "/usr/lib/python1.5/FormEditor.py", line 55, in load_data item = pickle.load(open(os.path.join(self.storagedir, filename), 'r')) File "/var/tmp/python-root/usr/lib/python1.5/pickle.py", line 826, in load return Unpickler(file).load() File "/var/tmp/python-root/usr/lib/python1.5/pickle.py", line 495, in load dispatch[key](self) File "/var/tmp/python-root/usr/lib/python1.5/pickle.py", line 612, in load_inst klass = self.find_class(module, name) File "/var/tmp/python-root/usr/lib/python1.5/pickle.py", line 669, in find_class raise SystemError, \ SystemError: Failed to import class FeedbackData from module __main__ *********************** The feedbackeditor module reads as follows: # file feedbackeditor.py (Tkinter) from FormEditor import FormEditor from feedback import FeedbackData, FormData from Tkinter import mainloop FormEditor("Feedback Editor", FeedbackData, r"/usr/local/apache/logs/feedback") mainloop() ********************** The FormEditor module reads as follows: # file FormEditor from Tkinter import * import string, os, pickle class FormEditor: def __init__(self, name, dataclass, storagedir): self.storagedir = storagedir # stash away some references self.dataclass = dataclass self.row = 0 self.current = None self.root = root = Tk() # create window and size it root.minsize(300,200) root.rowconfigure(0, weight=1) # define how columns and rows scale root.columnconfigure(0, weight=1) # when the window is resized root.columnconfigure(1, weight=2) # create the title Label Label(root, text=name, font='bold').grid(columnspan=2) self.row = self.row + 1 # create the main listbox and configure it self.listbox = Listbox(root, selectmode=SINGLE) self.listbox.grid(columnspan=2,sticky=E+W+N+S) self.listbox.bind('', self.select) self.row = self.row + 1 # call self.add_variable once per variable in the class's fieldnames var for fieldname in dataclass.fieldnames: setattr(self, fieldname, self.add_variable(root, fieldname)) # create a couple of buttons, with assigned commands self.add_button(self.root, self.row, 0, 'Delete Entry', self.delentry) self.add_button(self.root, self.row, 1, 'Reload', self.load_data) self.load_data() def add_variable(self, root, varname): Label(root, text=varname).grid(row=self.row, column=0, sticky=E) value = Label(root, text='', background='gray90', relief=SUNKEN, anchor=W, justify=LEFT) value.grid(row=self.row, column=1, sticky=E+W) self.row = self.row + 1 return value def add_button(self, root, row, column, text, command): button = Button(root, text=text, command=command) button.grid(row=row, column=column, sticky=E+W, padx=5, pady=5) def load_data(self): self.listbox.delete(0,END) self.items = [] for filename in os.listdir(self.storagedir): item = pickle.load(open(os.path.join(self.storagedir, filename), 'r')) item._filename = filename self.items.append(item) self.listbox.insert('end', `item`) self.listbox.select_set(0) self.select(None) def select(self, event): selection = self.listbox.curselection() self.selection = self.items[int(selection[0])] for fieldname in self.dataclass.fieldnames: label = getattr(self, fieldname) # GUI field labelstr = getattr(self.selection, fieldname) # instance attribute #labelstr = string.replace(labelstr,'\r', '') label.config(text=labelstr) def delentry(self): os.remove(os.path.join(self.storagedir,self.selection._filename)) self.load_data() ********************* The feedback module reads as follows: #!/usr/bin/python import cgi, os, sys, string def gush(data): print "Content-type: text/html\n" print "

Thanks, %(name)s!

" % vars(data) print "Our customer's comments are always appreciated." def whimper(data): print "Content-type: text/html\n" print "

Sorry, %(name)s!

" % vars(data) print "We're very sorry to read that you had a complaint." def bail(): print "Content-type: text/html\n" print "

Error filling out form!

" print "Please fill in all the fields in the form.

" print '' print 'Go back to the form!' sys.exit() class FormData: """ A repository for information gleaned from a CGI form. """ def __init__(self, formdict): for fieldname in self.fieldnames: if not form.has_key(fieldname) or form[fieldname].value == "": bail() else: setattr(self, fieldname, form[fieldname].value) class FeedbackData(FormData): """ A FormData generated by the hello2.html form. """ fieldnames = ('name', 'address', 'email', 'type', 'text') def __repr__(self): return "%(type)s from %(name)s on %(time)s" % vars(self) DIRECTORY = r'/usr/local/apache/logs/feedback' if __name__ == '__main__': sys.stderr = sys.stdout form = cgi.FieldStorage() data = FeedbackData(form) if data.type == 'comment': gush(data) else: whimper(data) # save the data to file import tempfile, pickle, time tempfile.tempdir = DIRECTORY data.time = time.asctime(time.localtime(time.time())) pickle.dump(data, open(tempfile.mktemp(), 'w')) ********************* From skip at mojam.com Wed Dec 29 12:19:28 1999 From: skip at mojam.com (Skip Montanaro) Date: Wed, 29 Dec 1999 11:19:28 -0600 (CST) Subject: Py2K wishes In-Reply-To: <386A0DC1.471874F2@prescod.net> References: <1265702489-58362226@hypernet.com> <386A0DC1.471874F2@prescod.net> Message-ID: <14442.17056.773002.697499@dolphin.mojam.com> Paul> Gordon McMillan wrote: >> If you're catching specific methods, why not subclass? Paul> You cannot subclass objects that are passed to you. 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__): def __init__(self, o): self.__dict__ = copy.copy(o.__dict__) def othermethod(self,...): pass o = sub(o) o.othermethod(...) ... 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 dave.rose at wcom.com Wed Dec 1 17:21:50 1999 From: dave.rose at wcom.com (Dave Rose) Date: Wed, 01 Dec 1999 22:21:50 GMT Subject: Scoping for Tkinter Variables. References: Message-ID: <2ch14.162$OH2.29732@pm02news> It appears that this is caused by multiple calls to Tk within the same application. Sorry to have wasted your time with this newbie type question. Dave Rose Dave Rose wrote in message news:ing14.156$OH2.29150 at pm02news... > 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 tim_one at email.msn.com Sat Dec 4 22:29:22 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 4 Dec 1999 22:29:22 -0500 Subject: map versus the 'for' loop In-Reply-To: Message-ID: <000901bf3ed0$ec6317a0$3a2d153f@tim> [Tim] > 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 ... [Will Ware] > Pardon my density: I can easily see how to do this with "len", since > I can type "len" at the prompt and get a "" > 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. A lambda is much slower, but I didn't say that's bad -- it is bad, but for other reasons . > How do I obtain a "" object? >>> import operator >>> operator.add >>> Curiously, this one illustrates the "it depends on the precise operation" clause in the original reply. For obscure implementation reasons, operator.add isn't as fast as infix "+" when applied to ints, but operator.div is about as fast as infix "/". worry-about-speed-and-you'll-never-sleep-again-ly y'rs - tim From phd at phd.russ.ru Mon Dec 20 04:32:20 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Mon, 20 Dec 1999 09:32:20 +0000 (GMT) Subject: time, strptime, daylight saving Message-ID: Hello! While writing and debugging programs to dump/load netscape history files, I found a problem. I reduced it to the following program: ---------- import time def test(dtime): t = time.strptime(dtime, "%Y-%m-%d %T") m = time.mktime(t) print "[DEBUG]", m, t print time.strftime("%Y-%m-%d %T (localtime)", time.localtime(m)) print time.strftime("%Y-%m-%d %T (GMT)", time.gmtime(m)) test("1999-09-21 21:44:33") test("1999-11-21 21:44:33") ---------- On linux the program prints ----- [DEBUG] 937935873.0 (1999, 9, 21, 21, 44, 33, 6, 1, 0) 1999-09-21 21:44:33 (localtime) 1999-09-21 17:44:33 (GMT) [DEBUG] 943209873.0 (1999, 11, 21, 21, 44, 33, 6, 1, 0) 1999-11-21 21:44:33 (localtime) 1999-11-21 18:44:33 (GMT) ----- what seems pretty good. But soon I found the program prints incorrect results on Solaris and FreeBSD. It prints ----- 1999-09-21 22:44:33 (localtime) ----- certailnly wrong. Deeper investigation shows that the problem is in daylight saving. The following variant prints correct result on all platforms: ---------- import time def test(dtime, x=0): t = list(time.strptime(dtime, "%Y-%m-%d %T")) t[8] = x m = time.mktime(t) print "[DEBUG]", m, t print time.strftime("%Y-%m-%d %T (localtime)", time.localtime(m)) print time.strftime("%Y-%m-%d %T (GMT)", time.gmtime(m)) test("1999-09-21 21:44:33", 1) test("1999-11-21 21:44:33") ---------- Well, this show that on Solaris and FreeBSD mktime() correctly uses is_dst flag; linux ignores it (but produces correct result). In some sense FreeBSD and Solaris are doing more correct job. The question is simple - how can I ask time module whether any given date is under daylight saving rule or not? How can I get the value for x (in my second variant of the program)? Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From tekhir at yahoo.com Thu Dec 9 14:19:57 1999 From: tekhir at yahoo.com (Tekhir) Date: Thu, 09 Dec 1999 14:19:57 -0500 Subject: Passing variable to python from a url Message-ID: <385000DD.EE770B2D@yahoo.com> I think I'm pretty good with python now, not a master but i can do most of the stuff I want without looking for help now. But one thing I do need help on is passing a variable in a url like so "script.py?variable=1" Is there a way to do this in python and can someone point me to an example or the library needed for this. Thanks, Jeremy "Tekhir" Misavage From skip at mojam.com Tue Dec 28 16:37:31 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 28 Dec 1999 15:37:31 -0600 (CST) Subject: newbie question... In-Reply-To: <3869229B.C06B94E5@earthlink.net> References: <3869229B.C06B94E5@earthlink.net> Message-ID: <14441.11675.805867.339604@dolphin.mojam.com> abs> I'm wondering what the accepted method of handling a text file's abs> contents are in Python. For example, the following Perl construct abs> is pretty standard. abs> while ( ) abs> { abs> # process each line as if comes off the file handle... abs> } abs> is typical. abs> The equivalent Python appears to be abs> somefilehandle = open( "some/file/name.text" ) abs> all_the_lines_in_the_file = somefilehandle.readlines() abs> somefilehandle.close() abs> # now process the lines in the all_the_lines_... list abs> # using some prefered method (there's more than abs> # one way of doing this, of course ;-) abs> THE BIG QUESTION: Am I understanding Python's philosophy properly? Yeah, that's a pretty typical idiom for small files. For larger files something like somefilehandle = open( "some/file/name.text" ) line = somefilehandle.readline() while line: dofunstuff(line) line = somefilehandle.readline() somefilehandle.close() Before you run off and compare that with the equivalent Perl and find it lacking in performance, I'll interject that Python does nothing fancy with its I/O. It's just built on top of stdio. For larger files you *can* chunk the input using something like sizehint = 10**6 somefilehandle = open( "some/file/name.text" ) lines = somefilehandle.readlines(sizehint) while lines: for line in lines: dofunstuff(line) lines = somefilehandle.readlines(sizehint) somefilehandle.close() It's not as succinct as the simpler idioms, but somewhat more efficient. 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 sklassen at nospam_cncx.com Wed Dec 8 11:39:55 1999 From: sklassen at nospam_cncx.com (Stephen Klassen) Date: 08 Dec 1999 11:39:55 EST Subject: help with opening html files References: <384261c4.8540090@122.0.0.250> Message-ID: <384E89B6.E57B0E31@nospam_cncx.com> That would depend on what you want to do with it... check out urllib, httplib, and open(). volumeregeling wrote: > Hi, > > Can anyone tell me how to open a html file from within python in > windows. > > thanks From kuncej at mail.conservation.state.mo.us Thu Dec 16 10:30:04 1999 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Thu, 16 Dec 1999 09:30:04 -0600 Subject: download web page with python References: <83a3m4$diq$1@nnrp1.deja.com> Message-ID: > Does anyone have any ideas how I can get by the form, and retrieve the > page that I want. Once I get the page I will have no problems parsing > it. I have an example script that might help you. See urlpost.py at http://starship.python.net/crew/jjkunce/ --Jeff From Gareth.McCaughan at pobox.com Thu Dec 2 17:29:37 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 02 Dec 1999 22:29:37 +0000 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <3846db0f.26374828@news1.on.sympatico.ca> Message-ID: <86ogc9q8mm.fsf@g.local> Robert Roy wrote: [I said:] >> - Method definitions have to be lexically contained in >> class definitions. So suppose you write something that >> parses a language and then does various things with >> the parse tree; if you adopt an OO approach to the >> parse tree (with things like "class IfStatement(ParseNode):") >> then you can't separate out very different operations like >> foo.print(), foo.compile() and foo.evaluate(). (That is, >> you can't group all the print methods together, and group >> all the compile methods together somewhere else, etc.) >> You can, of course, split your code up by having the WhileLoop >> and UntilLoop classes in different files, but this seems >> less sensible to me. :-) (This particular gripe applies to >> most OO languages.) >> > > Unless I misunderstood your post, the following code would do the job > nicely. > > bar.py > def bar(self): > print self.__class__.__name__ > > def bar2(self): > print 'In bar 2', > self.bar > > foo.py > class foo: > from bar import * [etc] That allows me to split up a class's methods into several different files, true. On the other hand, they can't then be grouped in some other way. What it would be nice to be able to do is to have, say, class ParseNode class WhileNode(ParseNode) class IfNode(ParseNode) class BlockNode(ParseNode) with methods in file compile.py: WhileNode::compile() IfNode::compile() BlockNode::compile() in file evaluate.py: WhileNode::evaluate() IfNode::evaluate() BlockNode::evaluate() and so on. (You can sort of get around this by using what's called "the Visitor pattern", but that (1) involves structuring everything rather differently and (2) makes the code less efficient. It might still be the best thing to do.) -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From egibson at connect.com.au Mon Dec 6 23:41:46 1999 From: egibson at connect.com.au (Evan Gibson) Date: Tue, 7 Dec 1999 15:41:46 +1100 Subject: Python/cgi Was: Very useful message -- Hah! In-Reply-To: ; from Dan Grassi on Sun, Dec 05, 1999 at 03:55:13PM -0500 References: <82do53$2rhr$1@hub.org><384A9BE0.B345509@inka.de> <384ABC57.DDC3B61E@inka.de> <87u2lxuooi.fsf@freddy.page.street> Message-ID: <19991207154146.47600@connect.com.au> On Sun, Dec 05, 1999 at 03:55:13PM -0500, Dan Grassi wrote: > There is a solution albeit rather nasty. Fork python and add a few simple > web-friendly features. Is that the best solution? Perhaps it is the only > one considering everyone's adamant stand that "if python is hard to use > python on the web that is the way things are, get used to it or go > elsewhere." > I just don't get it. It seems that the concept should be to make python > attractive to use, to build the user base. The problem is that none of the rest of us seem to consider python's behaviour weird or problematic. The first time I did web scripting with python I got that message all the time. It was due to missing the \n's in the headers (print "Content-type: text/plain\n\n") or not flushing the buffers properly, all things that are in the FAQs, all things that other people have mentioned here. Once someone showed me where to find my error messages in the logs (I'd never done cgi before at all) it was simple and the python error messages were much nicer than the perl ones I kept seeing in there from the other people using the box. Since the error message you were getting was an apache error and you _knew_ that, your vilification of python is quite misplaced. But, anyway, I've moved to Zope now so don't have to do much normal cgi anymore. You should try and find the old Bobo docs. If you don't need all of Zope then just use it's template stuff and go back to it's roots. > Oh well! > Dan -- Evan ~ThunderFoot~ Gibson ~ nihil mutatem, omni deletum ~ May the machines watch over you with loving grace. From tony.mcdonald at ncl.ac.uk Fri Dec 3 07:16:13 1999 From: tony.mcdonald at ncl.ac.uk (Tony McDonald) Date: Fri, 03 Dec 1999 12:16:13 +0000 Subject: Is there a proxy-enabled version of httplib.py anywhere? Message-ID: Hi, 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! :( Any pointers gratefully received... cheers, tone. From anders.eriksson at morateknikutveckling.se Fri Dec 17 05:35:57 1999 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Fri, 17 Dec 1999 11:35:57 +0100 Subject: Multi-User non Client/Server database References: Message-ID: On Thu, 16 Dec 1999 18:21:33 +0000, Sposhua wrote: >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.) >Don't know what xBase is, but try the shelve library for databases. I think it >also does all the file locking for you. xBase is like dBASE and Clipper, and Foxpro etc... About Shelves. I haven't used them (.I a beginner.) but the documentations says that: "The shelve module does not support concurrent read/write access to shelved objects". Which will make it unusefull for my purpose. It alse mention that using Unix filelocking this could be solved, but (feel free to correct me) then you get locking on file level not on record level So to recap: I need a database that must be Multi-user with record locking, but NOT Client/Server. ANYONE? // Anders From fredrik at pythonware.com Wed Dec 15 09:40:15 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 15 Dec 1999 15:40:15 +0100 Subject: Timing in MacPython? References: Message-ID: <00b701bf470a$4e4baa90$f29b12c2@secret.pythonware.com> ventrego at yahoo.com wrote: > 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. widget.update_idletasks() (but in this case, using "after" is a much better idea. see below). > 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. widget.bell() > 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. :) widget.after(time, callback) see: http://www.pythonware.com/library/tkinter/introduction/basic-widget-methods.htm => "event processing" and "alarm handlers" for more info. From skip at mojam.com Tue Dec 28 08:36:55 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 28 Dec 1999 07:36:55 -0600 (CST) Subject: Patch: httplib.py default timeout In-Reply-To: <840anc$9j8$1@nntp8.atl.mindspring.net> References: <840anc$9j8$1@nntp8.atl.mindspring.net> Message-ID: <14440.48375.677822.934000@dolphin.mojam.com> ... Aahz> defaultTimeout = 60 * 1000 # Sixty seconds ... def connect(self, host, port = 0, timeout = None): ... Aahz> if timeout is None: Aahz> self.sock.setsockopt ( socket.SOL_SOCKET, socket.SO_RCVTIMEO, defaultTimeout ) Aahz> elif timeout > 0: Aahz> self.sock.setsockopt ( socket.SOL_SOCKET, socket.SO_RCVTIMEO, timeout ) I understand the motivation for the timeout, but shouldn't the default be to not timeout at all: defaultTimeout = 0 # wait forever ... def connect(self, host, port = 0, timeout = defaultTimeout): ? Although timeouts are very useful, they are hardly the norm. Your change would break code that nominally works now because exceptions could get raised where none are expected. 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 nemeth at iqsoft.hu Mon Dec 13 16:25:30 1999 From: nemeth at iqsoft.hu (Nemeth Miklos) Date: Mon, 13 Dec 1999 22:25:30 +0100 Subject: Python suitability References: <38549DEA.B0157D0@iqsoft.hu> Message-ID: <38556449.903DA931@iqsoft.hu> > From: > bobyu5 at mailcity.com > 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? > I was involved in Java projects, and it was common to rewrite twice or more times the entire source code to circumvent bugs, and extremelly poor performance. Using C++ was a bit better than Java but some important OO features are poorly or not implemented in several C++ compilers. I cannot imagine slower program than a Java GUI application, and I cannot imagine slower development process than writing C++ applications. > From: > boud at rempt.xs4all.nl (Boudewijn Rempt) > > If you really need to use a variety of databases, then you probably > can't rely on stored procedures/packages to do the server-side work, > because there isn't a database where those work in the same way. And > even so, support for, say Oracle packages, is skimpy outside Oracles > own tools. I'm going to install Oracle next week to try whether they > can be accessed from Python, though. > > You really need some middle man, if you go the various databases > route, and designing decent middleware is difficult, in my experience. > Do you have a more precise idea? I am also interested in using middlemen (middleware). I evaluated Fnorb and found it perfect. > > I don't think TK is really suitable - I am very sad! Then why there are any effort to support TK by Python? > but if your application interface > is simple enough a web interface should suffice - and those can be as > slick as the graphics designer you hire can make it. Take a look at > WxPython or PyQt (that also seems to run under Windows). I used Qt (but not PyQt) and it is a fantastic library, not only GUI but general purpose C++ object library (or rather framework). I would go for it. > > I do find Zope a bit slow - even when I browse a Zope database on a > machine on my local network. > Again I am very sad! I wanted to start a new department in our company developing ecommerce applications. I am on the point of selecting a development environment. Untill now I would voted for Apache+SSL + Zope 2.1, but I am also thinking of using Apache+SSL + PHP or ApacxheSSL + mod_perl. Do you not think Zope would be a good platform for our projects? > > I haven't ever seen Outlook, but a basic tree-to-the-left, > data-on-the-right interface isn't too difficult to make. If you are > prepared to get rid of the web interface, you could use WxPython, I > suppose, though that doesn't impress me as being ready for the > enterprise > ;-). Also, remember that there are very few database-ready widgets - > you will have to write the basics yourself. > Do you have more arguments for not taking WxPython enterprise-ready? The lack of database-ready widgets does not bother me, as I access databases through CORBA (Fnorb) servers. > > 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? > and trusting a new tool to work miracles > is a recipe for disaster. I'm quite convinced that even VB can produce > good applications, in time, in budget ;-). We have at our company a department using Microsoft tools. They produce loss for five years. I am a bit afraid of using any Microsoft tool. However, our department uses no Microsoft development tools at all: we produce outstanding revenues for five years. Microsoft tools create revenue only for Microsoft! > > I've never seen C++ or Java used for large-scale database applications. > Most projects I've seen use Oracle Forms, Visual Basic or Powerbuilder > or things like that. I was also involved several of this kind of projects: never again! I would never use again any proprietary language or development tool. > But then, what's large? A large number of tables > and screens, a large amount of data, or both? And then, what's the > domain of the app? Transaction oriented, data warehousing, information > serving? > > > Any anecdotes or recommendations would be heartily appreciated! > > I'm trying to build a small-to-mid-range multi-user database application > > using Python and PyKDE/PyQt as a gui. This sounds interesting! I am also interested in PyQt. > I figure people who want to use my > > application can afford buying another PC to serve out X11 applications > to their legacy desktop systems (Windows and Mac). Besides, I want a > read-only browser interface. The architecture I'm working on includes > a database server, which I connect to using a DB-API II compliant > interface, a SQL translation layer, an application object layer, an > application server that dishes out XML-formatted data to the client gui > or to the client special purpose http server, that serves the various > browser clients. It's a hobby project, though. This is quite serious to be only a hobby project. Several corporations would pay a lot of money having a programmer being capable of designing and implementing an application using this architecture. I guess yoiu have to create VB programs during work hours! Poor man, I would not do that! You should change your employer! > My bosses don't want > another programming tool in the shop, after the debacle with VB 5.0. Your bosses may be complete idiots! VB5 and any other VB are rubish! I am also a boss of my company, and we always seek new technologies and tools to be able to create better applications within budget. And we always seeking new talented guys to be able to create outstanding software. A company using VB would not be a competitor for us. I am sure we are not the only company focusing on leading edge technology. Miklos Nemeth IQSOFT From fredrik at pythonware.com Fri Dec 3 08:32:05 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 3 Dec 1999 14:32:05 +0100 Subject: printable characters References: Message-ID: <00f801bf3d92$cce78df0$f29b12c2@secret.pythonware.com> Ralf Hildebrandt wrote: > How can I find out if a character is printable? > There seems to be no equivalent to isprint() of C. that's probably because "isprint" is completely brain- dead: after all, whether a character is "printable" or not depends on the output device... > Right now I use: > > def isprint(char): > return (ord(char) in range(32, 127)) def isprint(char, lo=chr(32), hi=chr(126)): return lo <= char <= hi From r-stadhe at online.no Fri Dec 17 20:11:27 1999 From: r-stadhe at online.no (Rolf C Stadheim) Date: Sat, 18 Dec 1999 02:11:27 +0100 Subject: Python15.Dll & Borland C++ Builder 3 References: <835ic8$g8e$1@ffx2nh5.news.uu.net> Message-ID: <385ADF3F.D9C909C6@online.no> I think this has to do with the different standards Microsoft and Borland has for DLL's. The way to go is to make a Borland compatible DLL of the Python15.dll, which is built for Visual C++. This excellent link on the topic should enable you to fix it: http://www.bcbdev.com/articles/vcdll.htm Regards, Rolf C Stadheim Gene Chiaramonte wrote: > I'm using C++ Builder 3 and tried including Python.h to see if I could use > the Python15.dll. > > Here's a snippet of what happens: > > #include "Python.h" // this is fine > > PyObject *t; // this is fine > > Py_Initialize(); // !!! this causes the following Link Error > > [LinkerError] Unresolved external '_Py_Initialize' referenced from C:\MY > DOCUMENTS\DEV\CPP3\IPORT\UNIT2.OBJ. > > Any idea why this happens and how to fix it? > > Thanks, > > Gene From paul at prescod.net Sat Dec 18 14:03:22 1999 From: paul at prescod.net (Paul Prescod) Date: Sat, 18 Dec 1999 13:03:22 -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: <385BDA7A.5486A796@prescod.net> Robin Becker wrote: > > Almost all modern programming languages have some means for describing > data items or objects or classes or whatever. Why don't we have a > derivative of C++ or python or whatever for data description? Just because nobody standardized the right langauge and a schema language for the right language at the right time. Instead, XML was coming on-stream as a document markup language at the time that we needed a standardized data description language to make this B2B stuff "work". A minimalist might argue that having one language for describing human readable and computer processable information is the Right Thing. A syntax purist might argue that the XML syntax is not really optimized for data description. A pragmatist might argue that it is easier to go along because we all know that syntax is irrelevant and fighting about it is only appropriate on the types-sig. -- 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 bitbucket at isomedia.com Wed Dec 29 13:41:54 1999 From: bitbucket at isomedia.com (Eugene Goodrich) Date: Wed, 29 Dec 1999 18:41:54 GMT Subject: newbie question... References: <3869229B.C06B94E5@earthlink.net> <3869298b.8634305@news.isomedia.com> <00a901bf51f3$499c8340$f29b12c2@secret.pythonware.com> Message-ID: <386a5461.52901207@news.isomedia.com> How did you know I learned my Python while at Microsoft? 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. 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 am I making enemies of you all with my silly variable names (the trashed-hungarian notation)? That comes from 2 years (I wish it had been less) of being forced to do ASP with VBScript. I didn't feel I could trust the VBScript interpreter to do a thing right for me with the types. 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. -Eugene On Wed, 29 Dec 1999 12:53:12 +0100, "Fredrik Lundh" wrote: >Eugene Goodrich wrote: >> The example Justin Sheehy gave is certainly better most of the time, >> but if you feel you _must_ do it like that Perl code (say, you've got >> a 100 MB file you don't feel like putting into memory all at once), >> you can do this: >> >> oFile = open ('delme.txt', 'r') >> sStr = oFile.readline() >> while (sStr): >> # do something with sStr >> sStr = oFile.readline () >> oFile.close() > >is that microsoft python? ;-) > >fwiw, the standard pydiom (at least as long >as we're talking 1.5.2) is: > > f = open('delme.txt') # rt is default > while 1: > s = f.readline() > if not s: > break > # do something > >> Someone please correct me if this does not have the reduced memory >> requirements for large files that I believe it does. > >for a better speed/memory tradeoff, you >can use "readlines" in the following way: > > f = open('delme.txt') > while 1: > lines = f.readlines(100000) > if not lines: > break > for s in lines: > # do something > >also see the fileinput module. > > > > > > "Get into a rut early: Do the same processes the > same way. Accumulate idioms. Standardize. The > only difference between Shakespeare and you > was the size of his idiom list - not the size of his > vocabulary." -- Alan Perlis > > import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==') From gmcm at hypernet.com Thu Dec 30 23:16:41 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 30 Dec 1999 23:16:41 -0500 Subject: Super Tuples In-Reply-To: <84h6b5$da1$1@news01.cit.cornell.edu> Message-ID: <1265509579-7266741@hypernet.com> Cliff Crawford wrote: > Pada 30 Dec 1999 15:49:45 +0100, Magnus L. Hetland bilang: > | > | I guess these things in Python have a lot to do with the > underlying | C-implementation, since tuples in many circumstances > are quite | efficient, and one-element tuples may be used to be > consistent | sometimes. > > I thought that lists and tuples had the same underlying > implementation (C arrays). The only difference is that lists are > mutable while tuples aren't. Tuples take one allocation, lists take a minimum of two. > Actually, this has always bugged > me--you'd think that "lists" would be similar to lists in Lisp > (i.e. constant time insertions and deletions), but they're not. > It seems to me it would make more sense to implement mutable > sequences using a linked list rather than an array. Linked lists only work well when the link(s) are part of the objects. An intelligently realloced array will beat the pants off a (obj *, next *) linked list, and for most operations, will beat embedded links, too. - Gordon From bowman at montana.com Sun Dec 26 11:22:41 1999 From: bowman at montana.com (bowman) Date: Sun, 26 Dec 1999 16:22:41 GMT Subject: tutorial questions (examples fail). References: <386625AE.C88C4992@dial.pipex.com> Message-ID: Keith White wrote: >>>> def fib(n): # write Fibonacci series up to n >... "Print a Fibonacci series up to n" If this is literally what you are typing in, you are missing the required indentation. Try >>> def fib(n): ... print "in fib" ^ this is the indentation, which may be a tab or space(s), but must be consistent from line to line. From alexander.jerusalem at chello.at Tue Dec 7 20:16:42 1999 From: alexander.jerusalem at chello.at (Alexander Jerusalem) Date: Wed, 08 Dec 1999 01:16:42 GMT Subject: Python and ASP Message-ID: <_ji34.8719$523.343739@news.chello.at> There was a problem some time ago with Python in ASP scripts. I believe it had to do with indentation somehow. Does anybody know if this issue has been completely solved meanwhile. Thanks, From bob at horvath.com Tue Dec 7 09:53:12 1999 From: bob at horvath.com (Bob Horvath) Date: Tue, 07 Dec 1999 14:53:12 +0000 Subject: browser interface? References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> Message-ID: <384D1F58.1459835F@horvath.com> 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. From poet at linuxports.com Thu Dec 30 13:18:36 1999 From: poet at linuxports.com (poet at linuxports.com) Date: Thu, 30 Dec 1999 18:18:36 GMT Subject: [OT] OpenSource Python Books? Message-ID: <84g70v$tcq$1@nnrp1.deja.com> Hello, I know this is off topic but I represent LinuxPorts.Com and I have been approached by a printer to help them publish OpenSource books. What we were wondering is if there is a desire for the Python documentation in printed form? We would also include a CD with the Python binary distributions on it and any extra Python software that we can. We have also decided that if we print these books that we will be giving a portion of the Gross profits back to the OpenSource community and would like to know "who" that community is when it comes to Python... Please go to http://www.linuxports.com/ and cast your vote for the Python book if you are interested. Thanks, Joshua Drake -- LinuxPorts - http://www.linuxports.com LDP - http://www.linuxdoc.org Sent via Deja.com http://www.deja.com/ Before you buy. From gang.li at compuware.com Mon Dec 13 16:23:41 1999 From: gang.li at compuware.com (Gang Li) Date: Mon, 13 Dec 1999 14:23:41 -0700 Subject: Parsing functions(?) References: <82p3ll$iqf$1@news.ycc.yale.edu> Message-ID: <3855521f@199.186.16.51> def record(self, fname, *args, **kw): self.flist.append((fname, args, kw)) def call_by_i(self, i): ff = self.flist[i] return apply(ff[0], ff[1], ff[2]) "Paul M" wrote in message news:82p3ll$iqf$1 at news.ycc.yale.edu... > > 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 mfletch at tpresence.com Tue Dec 21 11:05:57 1999 From: mfletch at tpresence.com (Mike Fletcher) Date: Tue, 21 Dec 1999 11:05:57 -0500 Subject: List comprehensions Message-ID: How about: comprehension := "[" headclause forclause+ ] headclause := expression ","? forclause := "for" expression "in" expression ","? So: [ (x*2,x/2,x**y), for x in somelist, for y in someotherlist, ] or [ (x*2,x/2,x**y) for x in somelist for y in someotherlist ] or even [ x*2,x/2,x.__pow__(y) for x in somelist for y in someotherlist ] Which seems to take care of most of the problems, it's got a decent sound (especially with the commas present), is unambiguous as far as I can see, and provides for parallel iteration. While I prefer the explicit syntax of the first example, (commas everywhere), allowing the syntax to be flexible seems the best approach. Just a thought... Mike From fredrik at pythonware.com Thu Dec 16 07:48:36 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 16 Dec 1999 13:48:36 +0100 Subject: Help?? Struct packing of Date time not has stopped working??!?! References: <835mvi$62t$1@nnrp1.deja.com> Message-ID: <01c401bf47c3$dfe75da0$f29b12c2@secret.pythonware.com> quickbbs at my-deja.com wrote: > I suspect that STRUCT isn't handling the packing of the long correctly, > as far as the manual's go, it looks AOK, but..... well, telnet is not a binary protocol, and using "!L" to unpack a 32-bit integer is a lousy idea -- what if you're running on a 64-bit platform? try this one instead: # socket-example-1.py (from the eff-bot guide) import socket import time # server HOST = "www.python.org" PORT = 37 # reference time (in seconds since 1900-01-01 00:00:00) TIME1970 = 2208988800L # 1970-01-01 00:00:00 # connect to server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) # read 4 bytes, and convert to time value t = s.recv(4) t = ord(t[3]) + (ord(t[2])<<8) + (ord(t[1])<<16) + (ord(t[0])<<24L) t = int(t - TIME1970) s.close() # print results print "server time is", time.ctime(t) print "local clock is", int(time.time()) - t, "seconds off" ## sample output: ## server time is Sat Oct 09 16:42:36 1999 ## local clock is 8 seconds off From andres at corrada.com Fri Dec 3 05:44:23 1999 From: andres at corrada.com (andres) Date: Fri, 03 Dec 1999 05:44:23 -0500 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <825nbt$p50@mail.psy.uva.nl> Message-ID: <38479F07.110BAC47@corrada.com> Ionel Simionescu wrote: > > 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. > Speech recognition technology is presently not able to transcribe natural speech of unknown speakers. This would only work by having audio recorded and webcast. Andres Corrada From jody at sccsi.com Thu Dec 23 09:22:21 1999 From: jody at sccsi.com (Jody Winston) Date: 23 Dec 1999 08:22:21 -0600 Subject: Python & Corba References: <83se6d$n8t$1@news.netvision.net.il> Message-ID: "jaakovb" writes: > 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 > > Python ORBs include ILU, FNORB, and OmniORB. I've used ILU in several large projects that include operating with other ORBs. -- Jody Winston From skaller at maxtal.com.au Wed Dec 15 18:55:37 1999 From: skaller at maxtal.com.au (skaller) Date: Thu, 16 Dec 1999 10:55:37 +1100 Subject: C++ (was RE: Python suitability) References: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it> Message-ID: <38582A79.42BFA46D@maxtal.com.au> Alex Martelli wrote: > 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. Hopefully, Viperc (the viper python compiler) will allow you develop in Python, and still get code that runs reasonably fast (probably, not 'extremely', but it depends on the application). I.e. the idea is that Python is a good language, and performance need not be such a barrier to developing applications as it is now. (where you have to resort to plain old C to write extension modules to get speed in critical areas) -- 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 sp00fD at yahoo.com Fri Dec 10 09:16:22 1999 From: sp00fD at yahoo.com (sp00fD) Date: Fri, 10 Dec 1999 14:16:22 GMT Subject: DB-API-oriented example scripts? References: <199912100620.AAA22933@dolphin.mojam.com> Message-ID: <82r1vg$tt3$1@nnrp1.deja.com> In article <199912100620.AAA22933 at dolphin.mojam.com>, skip at mojam.com (Skip Montanaro) wrote: > > I'm gearing up to try and replace a lot of homegrown database code with > MySQL using the MySQLdb module. I'm not much of a relational database > person, however, so I'm fairly unfamiliar with the computational model > expected by the Python DB API. I can muddle my way through SQL. The > MySQLdb module comes with no example code as far as I could tell however, > and relies heavily on the 2.0 version of the Python DB API spec for docs, > which contains no examples. > > Are there any good examples of how to use this API available? I saw a > reference to a Linux Journal article on the db sig's page which I will take > a look at. I saw nothing that looked like pointers to example code in the > Vaults of Parnassus. > > Any suggestions? > > 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... > > I had the same problem, I wish the Python documentation was a little better as a whole. Anyway, here's the basics: import MySQLdb foo = MySQLdb.connect(host=localhost,db=Mydb,user=user,passwd=passwd) bar = foo.cursor() sql = "SELECT * from Mytable" bar.execute(sql) rs = bar.fetchall() # returns a list foo.close() Sent via Deja.com http://www.deja.com/ Before you buy. From teyc at bigfoot.com Fri Dec 31 05:55:03 1999 From: teyc at bigfoot.com (Chui Tey) Date: Fri, 31 Dec 1999 20:55:03 +1000 Subject: Python not a Very High-Level Language? References: <84i4bn$rqh$1@clematis.singnet.com.sg> Message-ID: <84kmgt$g2h$1@bunyip.cc.uq.edu.au> I have been musing on this point lately. Thinking about MSWord's automatic outline facility, how about an IDE which can "summarize" a lengthly piece of source code by stripping away very long function parameters, leaving comments and very legible filtered source..., probably not as necessary in python as in C where complicated parameters for WinAPI calls can obscure the overall intent of a program. Ajith Prasad wrote in message news:84i4bn$rqh$1 at 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 news at dorb.com Thu Dec 2 09:43:09 1999 From: news at dorb.com (Darrell) Date: Thu, 2 Dec 1999 09:43:09 -0500 Subject: Newbie: switch question in Python References: <384605BC.56EAB34E@wjk.mv.com> Message-ID: Instead of saving strings in the dictionary I'd save functions. I'll demonstrate with an over the top example. More than you wanted, I bet. import string def namelist(instance): """ Stolen from: John Aycock http://www.csr.uvic.ca/~aycock/python/ Return a list of methods for instance """ namelist, classlist = [], [instance.__class__] dic={} for c in classlist: for b in c.__bases__: classlist.append(b) for i in dir(c): if not dic.has_key(i): dic[i]=1 namelist.append(i) for k,v in instance.__dict__.items(): if type(v)==types.FunctionType or type(v)==types.MethodType: namelist.append(k) return namelist class Switch: """ Derived classes should have methods that begin with "case_" and have a trailing digit. e.g. "case_55" These methods will be searched by the __call__ method. For a match on the trailing digit with val passed into __call__ """ def __init__(self, prefix='case_'): names=namelist(self) swDic={} for n in names: if string.find(n, prefix) != -1: s=string.split(n,'_') try: key=string.atoi(s[-1]) except ValueError: raise 'Method name error. Try "case_2"' swDic[key]=getattr(self,n) self._switch=swDic def __call__(self, val): try: self._switch[val]() except KeyError: self.default(val) class MySwitch(Switch): def __init__(self): Switch.__init__(self) def case_1(self): print 'Case_1' def case_2(self): print 'Case_2' def case_3(self): print 'Case_3' def default(self, val): print 'Key"%d" was found here!'%val def test1(): mySwtich=MySwitch() for x in range(5): mySwtich(x) test1() """ Key"0" was found here! Case_1 Case_2 Case_3 Key"4" was found here! """ -- --Darrell "William J. King" wrote in message news:384605BC.56EAB34E at wjk.mv.com... > Hi again! I was reading a tutorial that said > there was no switch statement in Python...and > that I could use a 'conditional' if else etc. > -- so I wrote a switch and would like to know if > its ok to do this or if you have any other better > ideas... Thanks to all for their help in learning > Python in the past 2 weekends.... From aa8vb at yahoo.com Fri Dec 31 08:38:35 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Fri, 31 Dec 1999 08:38:35 -0500 Subject: [ANNOUNCE] Pygasm IDE wxWindows Linux Developer Release In-Reply-To: References: <386B510D.3EC3B9DB@pcpros.net> <19991230070826.B778039@vislab.epa.gov> <19991230161952.A7052@vislab.epa.gov> Message-ID: <19991231083835.A8218@vislab.epa.gov> Jody Winston: |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. I noticed something similar when I ran. Not a core dump, but no images and the image buttons were 3 pixels wide. It would load the images only when the current directory was the Pygasm directory. -- Randall Hopper aa8vb at yahoo.com From achrist at easystreet.com Mon Dec 27 16:14:39 1999 From: achrist at easystreet.com (Al Christians) Date: Mon, 27 Dec 1999 13:14:39 -0800 Subject: Python Considered Harmful References: Message-ID: <3867D6BF.AB29E5B3@easystreet.com> Eric Lee Green wrote: > > a bit of a troll ... > Python works great for me about 90% of the time. The other 10%, usually when working on larger programs, I have problems similar to what you describe. These problems are usually symptoms of coding before thinking, which is easy in Python, or of coding after thinking not too good, which, somewhat surprisingly, happens in any language. These problem programs are characterized by classes that are under-designed with grievously sordid interfaces. When I realize that I've made a mess and have to start over on these 10% of projects, I will implement the new version in a different language, not Python. It might be that some other languages are better suited to certain problems, that other languages somehow prompt me to think more clearly where I've previously come up short, or that it is just easier to blame a language and not myself. I can always find another language, but I've never found another self. Meanwhile, the 90% (YMMV +/- 2.5%) success rate of cybermaniacal clueless coding in Python is very nice. Al From boud at rempt.xs4all.nl Fri Dec 31 09:36:20 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 31 Dec 1999 14:36:20 GMT Subject: [OT] OpenSource Python Books? References: <84g70v$tcq$1@nnrp1.deja.com> <386BC2A4.628D9C9A@callware.com> <3d7lhwrq05.fsf@amarok.cnri.reston.va.us> Message-ID: <84if14$dg6$1@news1.xs4all.nl> Andrew M. Kuchling wrote: > 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. 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 the time to start writing, since it will then probably be out together with KDE 2, but the contours are already clear enough to be able to write and test code. > 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. Even an introductory appendix would be great. But while there's quite a bit of Python activity in both areas, neither is quite visible. I think PyKDE should be a part of the KDE libraries installation, obviously... > And who's going to write "Python for Dummies"? Not me ;-). While I have nothing against clearly written, well-structured texts that deal with the basics of a certain topic, I detest any inclination to invite people to think of themselves as dumb. -- Boudewijn Rempt | http://denden.conlang.org From aj10 at my-deja.com Wed Dec 15 18:13:55 1999 From: aj10 at my-deja.com (aj10 at my-deja.com) Date: Wed, 15 Dec 1999 23:13:55 GMT Subject: Zope project management? References: <3857EE39.B9DEAC7C@mdlink.de> Message-ID: <8397bf$q0s$1@nnrp1.deja.com> Is there an english version of the site? Thanks Amit In article <3857EE39.B9DEAC7C at mdlink.de>, Helge Hess wrote: > Hi Greg, > > Greg Wilson wrote: > > Hello. Has anyone used Zope (or other Python software) to build a project > > management platform? I'm looking for something like Microsoft Project, but > > (a) cross-platform, (b) web-enabled, and (c) Python friendly. > > You might want to take a look at our SKYRIX application server. It's not > written with Zope but is (a) portable across Unixes, (b) completly web > based and (c) scriptable via Python. In release 3.2, which will be made > available at CeBIT 2000 (starting in February), a project management app > will be included (some stuff is already available in 3.1, but it needs > to be completed to be truly called a 'project management' app). > > A pre-release version of SKYRIX 3.1 is available on every SuSE 6.2 and > SuSE 6.3 CD, the released version is available from our ftp server on > request. > > best regards > Helge Hess > -- > SKYRIX-OS Web Application Environment - http://www.skyrix.com > SKYRIX-IAS Groupware Application Suite - http://www.skyrix.com > Sent via Deja.com http://www.deja.com/ Before you buy. From mfletch at tpresence.com Sat Dec 11 16:20:29 1999 From: mfletch at tpresence.com (Mike Fletcher) Date: Sat, 11 Dec 1999 16:20:29 -0500 Subject: Dot product? Message-ID: 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... 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 ) ... >>> Transpose( a, b ) [(2, 3), (3, 4), (4, 5)] >>> Transpose( a, b, () ) [(2, 3, None), (3, 4, None), (4, 5, None)] >>> Enjoy, Mike -----Original Message----- From: David C. Ullrich [mailto:ullrich at math.okstate.edu] Sent: Saturday, December 11, 1999 3:51 PM To: python-list at python.org Subject: Dot product? Ok, so I'm dense. How do I take the traditional "dot product" of two vectors? In a nice Pythonic sort of way, I mean. Say the vectors are represented as sequences of numerics - then of course I can say just def Dot(X, Y): res = 0 for j in range(len(X)): res = res + X[j] * Y[j] return res and that gives the right answer, but it doesn't look right - seems like the Python way would involve a "for x in X" instead of that "for j in range(len(X))". For example if Transpose returns the transpose of a sequence of sequences (ie Transpose(s)[j][k] = s[k][j]) I can say def Dot(X, Y): res = 0 for (x,y) in Transpose((X,Y)): res = res + x * y return res and that looks "right". For that matter once I have a Transpose I could just use reduce. But when I write a Transpose routine I have the same complaints with the way it looks, only more so. Is there a keen way to do this sort of thing, or do I just have to use the index as above? (Come to think of it I think what I really want is a nice Transpose - that's been coming up a lot, Dot is just one place.) DU -- http://www.python.org/mailman/listinfo/python-list From jam at quark.emich.edu Tue Dec 7 11:04:40 1999 From: jam at quark.emich.edu (Jeff) Date: Tue, 7 Dec 1999 11:04:40 -0500 Subject: Python type checking? In-Reply-To: <82j9u8$da7$1@nnrp1.deja.com> References: <82j9u8$da7$1@nnrp1.deja.com> Message-ID: <19991207110440.A8505@quark.emich.edu> On Tue, Dec 07, 1999 at 03:43:06PM +0000, Arinte wrote: > 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 > [~] [11:01am] [jam at quark-pts/5] % python 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 >>> a = "1" >>> print int(a) 1 >>> a = 1 >>> print int(a) 1 >>> a = "1" >>> print long(a) 1L >>> a = 1 >>> print long(a) 1L this works just fine, though you still might want to wrap the code into a try/except in case the string *isn't* a value that the 'int' or 'long' functions can handle. hope that helps. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From guido at cnri.reston.va.us Mon Dec 6 16:44:09 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 06 Dec 1999 16:44:09 -0500 Subject: Python.org is down! References: <001701bf3ffc$499d0940$f29b12c2@secret.pythonware.com> Message-ID: <5lvh6bbv86.fsf@eric.cnri.reston.va.us> "eff-bot" writes: > it's been dead for quite a while now (and so has > all mailing python.org mailing lists). does anyone > know what's going on? The Python website is back on-line and mail is flowing again (still catching up). Our apologies for the long downtime. Thank you for your patience! --Guido van Rossum (home page: http://www.python.org/~guido/) From python at verbal.nildram.co.uk Mon Dec 27 07:51:29 1999 From: python at verbal.nildram.co.uk (Dave Corrie) Date: Mon, 27 Dec 1999 12:51:29 +0000 Subject: Problems compiling mxDateTime on Linux Message-ID: <386760D1.3251596@verbal.nildram.co.uk> I would like to use the mxDateTime module ( from http://starship.skyport.net/~lemburg/mxDateTime.html ), but I'm having a little trouble building it on my RedHat 6.0 system (Python 1.5.1). My python path is: -------- $ python -c 'import sys; print sys.path' ['', '/usr/lib/python1.5/', '/usr/lib/python1.5/test', '/usr/lib/python1.5/plat-linux-i386', '/usr/lib/python1.5/lib-tk', '/usr/lib/python1.5/lib-dynload', '/usr/lib/python1.5/site-packages'] -------- Following the installation instructions which came with the mxDateTime module, I have copied the files from the DateTime\mxDateTime directory (contained in the mxDateTime-1.3.0.zip distribution) into /usr/lib/python1.5/site-packages. The next step: "make -f Makefile.pre.in boot", does not succeed: -------- $ 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 `/usr/lib/python1.5/site-packages' make[1]: *** No rule to make target `/usr/lib/python1.5/config/Makefile', needed by `sedscript'. Stop. make[1]: Leaving directory `/usr/lib/python1.5/site-packages' make: *** [boot] Error 2 -------- I'd really appreciate it if someone could tell me where I'm going wrong! Many thanks, Dave From warlock at eskimo.com Fri Dec 10 15:45:46 1999 From: warlock at eskimo.com (Jim Richardson) Date: Fri, 10 Dec 1999 12:45:46 -0800 Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <6D8A17398E28D3119F860090274DD7DB4B3D04@pces.cadlab.it> <384F8E63.95B75B21@corrada.com> Message-ID: On Thu, 9 Dec 1999 15:29:04 +0000, Robin Becker, in the persona of , brought forth the following words...: >In article <384F8E63.95B75B21 at corrada.com>, Andres Corrada > writes >>Alex Martelli wrote: >>> >>> *THANKS* for this excellent piece of news, then!!! I'll be >>> watching the news like a hawk (but my feed is flaky, so >>> if there's any way I could get an email reminder when the >>> time is right...). >> >>I'll keep you posted. >> >>------------------------------------------------------ >>Andres Corrada-Emmanuel Email: andres at corrada.com >>Owner http://www.corrada.com/mamey >>Mamey Phone: (413) 587-9595 >>------------------------------------------------------ >> > >how do people support 'free' sites? Via advertising? >-- That's one method, also by tracking where you go (market research, the "evil twin" of advertising :) Or they give away a basic service and hope to tempt you to buy the "full" service pack. Or basic service is free, but any extras cost money. -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From da at ski.org Mon Dec 6 19:10:39 1999 From: da at ski.org (David Ascher) Date: Mon, 6 Dec 1999 16:10:39 -0800 (Pacific Standard Time) Subject: Tkinter 1.5.2 ?? In-Reply-To: <3849F4A6.E6E4D52D@interaccess.com> Message-ID: Between the "discussion" between grassi and /F-bot and messages like: On Sat, 4 Dec 1999, Clyde Davidson wrote: > OK, if that's what's there. But where is the this? > > Clyde boy am I glad to see that python.org is back up! --da From moonseeker at my-deja.com Wed Dec 15 09:30:31 1999 From: moonseeker at my-deja.com (moonseeker at my-deja.com) Date: Wed, 15 Dec 1999 14:30:31 GMT Subject: exceptions? Message-ID: <8388m7$1ii$1@nnrp1.deja.com> Hi! Could anyone please point me to a good explanation how exceptions can be handled, new created and used, how I can check for a special exception and so on...? Thanks, Mike Sent via Deja.com http://www.deja.com/ Before you buy. From rasta at aegir.vision.auc.dk Fri Dec 10 13:34:57 1999 From: rasta at aegir.vision.auc.dk (Rasmus Agerholm) Date: Fri, 10 Dec 1999 18:34:57 GMT Subject: thread priority workaround Message-ID: Hi Is there no method whatsoever to 'prioritize' threads in a multi-threaded application??? I have made a multi-threaded application which includes a GUI (made with Pmw & Tkinter) and it seems that the GUI-thread is getting all the attention from the scheduler. How can I solve this problem??? /Rasmus -- Teamwork is essential... it gives the enemy other people to shoot at! From irv at ellijay.com Tue Dec 7 14:24:50 1999 From: irv at ellijay.com (Irv Mullins) Date: Tue, 7 Dec 1999 14:24:50 -0500 Subject: Very useful message -- Hah! References: Message-ID: <384d5ef2.0@news3.paonline.com> Nathan Clegg wrote in message news:XFMail.991206090623.nathan at islanddata.com... > > On 04-Dec-99 Dan Grassi wrote: > > It seems that by design python, by design, is not to be used as a cgi > > scripting language -- otherwise why would it produce this very > > meaningful > > message at the slightest syntax error: > > > > > > Internal Server Error Pardon me for interrupting, but: I have never written a single line of Python. I have written a grand total of 2 very simple CGI's (in Euphoria/Linux.) After the first 4 or 5 minutes, I figured out what "Internal Server Error" meant, and what to do to prevent it. I'd like to say something smart-alecky here, but instead I'll just suggest that perhaps programming just isn't Mr. Grassi's strong suit. He seems to be better at trolling :P Irv From donn at u.washington.edu Wed Dec 1 13:32:52 1999 From: donn at u.washington.edu (Donn Cave) Date: 1 Dec 1999 18:32:52 GMT Subject: Looking for sshlib.py References: <19991130180435.A1935602@vislab.epa.gov> <19991130080326.A1376@quark.emich.edu> <19991130173837.A2365@quark.emich.edu> Message-ID: <823pkk$1450$1@nntp6.u.washington.edu> ||On Tue, Nov 30, 1999 at 09:47:05PM +0000, John Leach wrote: ||> I'm looking to write a Python frontend for character-based applications ||> accessed via the internet. ||> telnet works well but I'd like something with more security (telnet sends ||> its password unencrypted I believe). ||> I'll try calling ssh from within Python and see if that helps. ... | I second the ssh/scp recommendation, however that telnet clients do not | encrypt passwords is an overgeneralization. Some telnet clients support | password encryption (e.g. via Kerberos or SRP). No comment on how | secure/insure their encryption methods are, but it's better than | plaintext. ;-) Just to pick a nit, Kerberos doesn't really send your password on the net, even encrypted, it uses the password in the cryptography but not in the actual encrypted data. Anyway, it would be a interesting project to get that into telnetlib.py (not to be ironic, it would be interesting.) Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From fredrik at pythonware.com Tue Dec 7 08:43:55 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 7 Dec 1999 14:43:55 +0100 Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <82g4bl$42g$1@nnrp1.deja.com> <82j1l0$6vn$1@nnrp1.deja.com> Message-ID: <023401bf40b9$1c0c0360$f29b12c2@secret.pythonware.com> ajmayo at my-deja.com wrote: > > begin > if something then > begin > more code with more nested blocks... > end > end if > end that's not python. this is python: > if something: > more code with more nested blocks... > 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. what packet size are you using on your internet? From boud at rempt.xs4all.nl Thu Dec 23 14:57:12 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 23 Dec 1999 19:57:12 GMT Subject: Which grid widget? References: <38623573.0@news.cyberway.com.sg> Message-ID: <83tuqo$csb$1@news1.xs4all.nl> Ng Pheng Siong wrote: > Hi, > It seems that wxPython, pyFLTK and FXpy are all being actively > developed. 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/ Qt includes a grid widget, but it is only fair to midling. If you need something like the Visual Basic vsflexgrid (full editing, comboboxes, outlining and a bag of other goodies), then you will be disappointed. But from my cursory examination, no Python gui toolkit offers a grid with that much functionality. It's not too difficult to overlay the grid with editboxes or comboboxes, anyway. There are spreadsheet-like Qt grids available, but you'll probably have to wrap them yourself. > I am looking for a good grid widget. Which of the above toolkits > should I look at? (Yeah, I know, _all_ of them! In my copious > spare time I will. ;-) I've taken a look myself, but wxWindows doesn't offer a fully editable, spreadsheet-like grid either, and last time I took a look at FXpy, it didn't have one either. I think you will either have to look hard for a third-party module, or write one yourself. *) The 0.10 means that there've already been ten releases, the count went from 0.9 to 0.10 - some people thing 0.10 is the first alpha release, while the stuff is now almost as stable as the pyramid of Gizeh, in fact. -- Boudewijn Rempt | http://denden.conlang.org From gerrit.holl at pobox.com Tue Dec 14 11:51:40 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 14 Dec 1999 17:51:40 +0100 Subject: Newbie Variable Definition Question In-Reply-To: <38566D2E.1916DABD@callware.com>; from ivanlan@callware.com on Tue, Dec 14, 1999 at 09:15:42AM -0700 References: <38566A51.A1DFD2F6@coastalnet.com> <38566D2E.1916DABD@callware.com> Message-ID: <19991214175140.A507@stopcontact.palga.uucp> Ivan Van Laningham wrote: > Hi All-- > > try: > x=variable > except NameError: > variable="default value" > x=variable > > print x 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 From ngps at madcap.dyn.ml.org Wed Dec 22 09:48:58 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 22 Dec 99 14:48:58 GMT Subject: Module urllib References: <3860C639.17CF1185@digitalmap.hi.bosch.de> Message-ID: <3860e4da.0@news.cyberway.com.sg> According to Michael Husmann : > What is to be done to open an url when I fist have to pass a firewall? Depends on the sort of firewall in your way. ;-) If you are using a web proxy, it suffices to have environmental variables like these: http_proxy=http://proxy.mydomain.com:8080/ ftp_proxy=http://proxy.mydomain.com:8080/ > I would like to use the function urlopen, but I don't > know how to pass my User ID and my Password. Several possible interpretations of the above here: 1. You are accessing a URL that demands http basic authentication. Speak your url thusly: http://username:password at www.what.ever.com/what/ever/path 2. You are accessing a URL that is a form with username and password entry fields to be filled in. You'll need to find out the form's action: GET or POST. See the recent thread of how to GET/POST to a URL. 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. If you don't want this, you'll need to have your own local proxy that accepts the username/password upon startup, caches it in memory, then sends it on to the upstream proxy everytime it does its business for you. Look around Parnassus: Several people have written ad/cookie-junking proxies. Try them out. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From ron at graburn.com Wed Dec 8 21:27:45 1999 From: ron at graburn.com (Ronald Hiller) Date: Wed, 08 Dec 1999 21:27:45 -0500 Subject: Inconsistent socket.gethostbyname exceptions Message-ID: <384F13A1.B9A9C675@graburn.com> 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? Thanks, Ron From michael.stroeder at inka.de Wed Dec 22 05:44:37 1999 From: michael.stroeder at inka.de (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 22 Dec 1999 11:44:37 +0100 Subject: strptime on Unix systems References: <19991222110107.A972@Ridcully.home> Message-ID: <3860AB95.A93A4A0@inka.de> Malcolm Tredinnick wrote: > > Two questions: > (1) What is the story on other Unix systems? Is this a general problem (I > hope not)? I had various problems with time.strptime() and someone mentioned here a couple of months ago that strptime() in some glibc versions is broken. Ciao, Michael. From TheBlueWizard at pressroom.com Tue Dec 28 22:36:13 1999 From: TheBlueWizard at pressroom.com (The Blue Wizard) Date: Wed, 29 Dec 1999 03:36:13 GMT Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> Message-ID: <01bf51ad$b5aa6b60$069508d1@TheBlueWizard> Paul Prescod wrote in article <3869337E.996B9BAE at 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. Um...I believe it is possible to "extend" the tuples to incorporate some notion of OO programming. The ColdC has something called frobs, which serves as lightweight OO programming....see http://www.cold.org for some info Cheers! The Blue Wizard From apederse at siving.hia.no Wed Dec 15 06:39:09 1999 From: apederse at siving.hia.no (Asle Pedersen) Date: Wed, 15 Dec 1999 12:39:09 +0100 Subject: smtp and the From header field Message-ID: <837uk2$2jp$1@snipp.uninett.no> While testing the smtp library I have not been able to figure out how to use the different formats of the FROM header. It is usuall to place in addition to the email-address also the name of the person holding the address in the FROM field. Do anyone have experience in using the SMPT libray to place such information in the From field? Investigating the library it seems that it checks the from field for conformity with RFC822 but I don't think there is anything wrong syntactically in the data I'm placing there. Asle Pedersen From gemodek at t-online.de Wed Dec 22 03:40:52 1999 From: gemodek at t-online.de (Stephane) Date: Wed, 22 Dec 1999 09:40:52 +0100 Subject: C++ Source documentation ? Message-ID: <38608E94.D37C2B0D@t-online.de> Hi, 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?? Thanks Stephane From idfx at netzero.net Tue Dec 21 23:29:01 1999 From: idfx at netzero.net (idfx at netzero.net) Date: Wed, 22 Dec 1999 04:29:01 GMT Subject: newbie : books on python Message-ID: <83pk29$tc4$1@nnrp1.deja.com> Grant Edwards wrote in message news:slrn85d01i.3i1.grant at grante.comtrol.com... > Alex Martelli wrote: > >Mahboob Hussain writes: > > > >> I program in C/C++/Java/Perl and want to learn Python. Could you suggest > >> a few good books / sites to get me started I'm also from a 'C-family' background and I sympathize. Augmenting publishing is kinda sparse. I figure the best way to learn it is to play with it. See if you can figure parallels to what you already know. Python _is_ based on C/C++ anyways, and if you look hard enough, you can see some of the C bases of the Python implementation. > > NB: _Programming_Python_ (O'Reilly) and _Programming_with_Python_ >(Prima) are two different books. I've got the latter > Two other books I've seen recommended for experienced programmers are > _The_Quick_Python_Book_ and _Python_Essential_Reference_. > -- > Grant Edwards grante Yow! DIDI... is that a > at MARTIAN name, or, are we > visi.com in ISRAEL? O'Reilly also prints a "Python Pocket Reference" which I find really helpful because it only has the basic syntax stuff, which is what I always forget. Y'know, the language's 'grammar'. It's only about 70 pgs and $6, and it comes in handy. Particularly for someone (like you and like me) who's migrating _to_ Python and just needs some help in translation. yrs, in_sanity, idfx Sent via Deja.com http://www.deja.com/ Before you buy. From kno at jtan.com Wed Dec 8 14:20:46 1999 From: kno at jtan.com (Matt Dunford) Date: Wed, 8 Dec 1999 19:20:46 GMT Subject: fixing the ForkingTCPServer? Message-ID: The default ForkingTCPServer didn't seem to be cleaning up its children properly. The only way I could get it to clean up after itself and therefore get rid of zombie processes was by overridding the serve_forever and collect_children methods in the ForkingTCPServer class. If what I did safe? #!/usr/local/bin/python HOST = '' PORT = 4115 from SocketServer import * from string import strip import posix class MyServer(ForkingTCPServer): # override serve_forever def def serve_forever( self ): while 1: self.handle_request() self.collect_children() # override collect_children # because the default doesn't work def collect_children(self): """Internal routine to wait for died children.""" while self.active_children: pid, status = posix.waitpid(0, posix.WNOHANG) if not pid: continue self.active_children.remove(pid) class echohandler(StreamRequestHandler): # put whatever you want the session to # do in the handle def, in this case # it echos input back to output def handle(self): while 1: str = self.rfile.readline( 16384 ) if strip(str) == 'quit': break self.wfile.write(str) if __name__ == '__main__': from socket import * server = MyServer((HOST, PORT), echohandler ) server.serve_forever() -- From bwarsaw at cnri.reston.va.us Wed Dec 22 15:13:51 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Wed, 22 Dec 1999 15:13:51 -0500 (EST) Subject: Anyone else making music with python? References: <386115AB.A0DD3F6@angelfire.com> Message-ID: <14433.12543.958345.675192@anthem.cnri.reston.va.us> >>>>> "PW" == Paul Winkler writes: PW> Am I the only one crazy enough to make music directly in PW> python scripts? i.e. not with an application but by PW> programming the composition... Well, not exactly, but come to the Python conference in January and maybe you'll get to hear my Python Powered bass :) -Barry From tim_one at email.msn.com Wed Dec 1 03:15:04 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 1 Dec 1999 03:15:04 -0500 Subject: Python complaints In-Reply-To: Message-ID: <000201bf3bd4$2bda5e20$542d153f@tim> [Fran?ois Pinard] > ... > By the way, I find `map' rather useful, even if I read recently that > Guido somewhat regretted having introduced it in Python. I guess one > could write his/her own `map' function, it is just simpler for the > community that the order and meaning of arguments is decided once and > for all in the library. It's not the functionality of "map" that's objectionable, it's the politics. Whoever contributed the implementation for map, filter and reduce did an excellent job on them! They were perfectly designed (modulo the goofy "None padding" of "short" arguments), and work great. 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 doesn't want Python to evolve in Lispish directions, and before those things were added very few people pushed in those directions. Ever since, it's been common. One of the only times in my life I've seen a "slippery slope" argument that actually turned out to have merit <0.9 wink>. 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] In the bowels of DejaNews you'll find some fully fleshed-out proposals for adding that, and for generalizing "for" to march over multiple sequences in lockstep (nice to have in general, and needed to replace multi-argument map with equal clarity); Greg Ewing has already implemented part of that. map-by-any-other-name-wouldn't-be-"map"-ly y'rs - tim From marc.saric at mpi-dortmund.mpg.de Fri Dec 10 05:28:13 1999 From: marc.saric at mpi-dortmund.mpg.de (Marc Saric) Date: Fri, 10 Dec 1999 11:28:13 +0100 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: <3850D5BD.A190CA8D@mpi-dortmund.mpg.de> Phil Austin schrieb: > 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: Unfortunately there is much ancient f77-code around, especially in the sientific (physics, math) field. And much is still written in Fortran (even f77) nowadays. I had to work with a molecular dynamics program written in Fortran 77 (the sources where from 1996...) during my diploma and my boss at this time only knew Fortan and Basic. This mess was the reason why I started to use Python... :-) It does not help that there are more modern Fortran versions out there if everybody uses the old standard "for compatibility reasons". > 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 This might be ok -especially if you have something working written in f77 and only want to wrap it up or process the input/output with Python. That really works great. -- Bye, Marc Saric Max-Planck-Institut f?r molekulare Physiologie Otto-Hahn-Strasse 11 44227 Dortmund phone: +49 231 133 2168 From skaller at maxtal.com.au Sun Dec 26 11:41:09 1999 From: skaller at maxtal.com.au (skaller) Date: Mon, 27 Dec 1999 03:41:09 +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> Message-ID: <38664525.1D26C3D4@maxtal.com.au> Alex Martelli wrote: > > John Skaller writes: > > > > 6. Many of the things you do in C++ are to over come it's own > > > limitations. > > > > The main limitation of C++ wrt python is the ugly syntax, > > and the quantity of it that is required to do something which is > > simple in Python. After all, Python is written in a subset of C++. > > Python simply 'pre-makes' some design decisions for you. > > An interesting way to put it. But, actually, it's an _extended_ > subset, because it makes use of some things that (alas!) are > not in standard C++: things such as deploying separately > compiled modules, and accessing certain elementary OS > functionality (such as getting a list of files). To back this argument up: Python refuses to standardise a GUI, in Viper it is standardised, I guess for much the same reasons you give. > The 'subset' relationship probably does hold for JPython, since > Java is not as shy as C++ about offering standard and > portable models for these issues (and others, such as > threading); Yeah. > > This is an advantage if these decisions suit your application, > > and a hassle if they don't, and you have to work around them. > > Probably a fair point about any 'higher-level language' > whatsoever (including C++ versus assembly). The key > issues here would seem to be, how wide is the range of > applicability of the 'pre-made design decisions' (how often > are they limiting rather than empowering), and how > much of a hassle is it to work around them when need > does arise. I think Python (and C++, when scored against > machine language) does very well on both scores, while > other "higher-level" languages may not be as suitable. 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. I think this is because better support for abstraction and modularity ends up being more important than more application oriented support. To put this another way, by example: having a built-in FTP/HTML library may make small web jobs easier in Python than C++, but once you get to a bigger job the amount of work that would be required to design and implement those components becomes relatively smaller, and the problems integrating components -- in general -- becomes more dominant. To give an idea what I mean: compare Python 1.4 to python 1.5.2: the latter has packages. Packages allow much larger jobs to be done with python. [Interscript is strongly package based, and would be unworkable without them] Now, consider what the Types-SIG is doing, allowing some form of optional static typing -- this again will allow python to 'scale up' to larger jobs. The real problem is that such 'ad hoc' enrichments are necessary to allow scaling up, and also end up destroying the essential simplicity of the system. What is needed is something _intrinsically_ scalable, from the ground up. And we know what that is in theory; but not how to apply it yet: we _know_ that the fundamental concepts of computing are based on ideas of abstraction, and we _have_ a known scalable theory of abstraction (category theory). But we don't know how to apply it to computing, and we're not yet willing to put our efforts behind it: today's income stands in the way of tomorrow's advance. (which is probably the way it should be, since theories often break when one tries to apply them :-) -- 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 maytagrepairman at yahoo.com Fri Dec 24 02:57:45 1999 From: maytagrepairman at yahoo.com (Maytag Repairman) Date: Fri, 24 Dec 1999 07:57:45 GMT Subject: Is there a Python equivalent of Tcl's auto_execok? References: <83pf6u$q57$1@nnrp1.deja.com> <02CD1B3C026B41C1.AA67173007592BE4.82A69C8F06BE415B@lp.airnews.net> Message-ID: <83v8uc$q6g$1@nnrp1.deja.com> Thanks. Just in case there wasn't, I had written something similar (which I fear Deja will garble) just after posting my question. #----------------------------------------------------------------------- ------ # # fullPath # # Search $PATH for the first occurrence of a file. Return the full path name # if found. Otherwise, return None. # #----------------------------------------------------------------------- ------- def fullPath(file): if os.path.isabs(file) and os.path.isfile(file): # already have it! return file else: for path in string.splitfields(os.environ['PATH'],os.pathsep): full_path = os.path.join(path,file) if os.path.isfile(full_path): if path == '.': # don't return './file' return os.path.abspath(full_path) else: return full_path return None In article <02CD1B3C026B41C1.AA67173007592BE4.82A69C8F06BE415B at lp.airnews.net>, claird at starbase.neosoft.com (Cameron Laird) wrote: > > In article <83pf6u$q57$1 at nnrp1.deja.com>, wrote: > > > > > >Is there a Python equivalent of Tcl's auto_execok? > . > . > . > No, to the best of my knowledge. Pythoneers must > import os, string > for pth in string.split(os.environ['PATH']): > fnm = os.path.join(pth, exe) > if os.path.exists(fnm): > break > for themselves, I believe. > > Credit Gordon McMillan for this coding. > -- > > Cameron Laird > Business: http://www.Phaseit.net > Personal: http://starbase.neosoft.com/~claird/home.html > -- Rob Cupples Sent via Deja.com http://www.deja.com/ Before you buy. From robin at alldunn.com Thu Dec 30 16:43:50 1999 From: robin at alldunn.com (Robin Dunn) Date: Thu, 30 Dec 1999 13:43:50 -0800 Subject: [wxPython] wxPython glcanvas build on SGI a no-go References: <19991230160723.A6725@vislab.epa.gov> Message-ID: <017d01bf530e$f78a0b50$1a25d2d1@jenkondev.com> > > wxPython glcanvas build on SGI a no-go > Yep, this is known. The problem is that I just blindly made wrappers for everything in my local copy of GL.h. There was a set of patches sent to the list a while back from somebody else building on SGI. http://starship.python.net/pipermail/wxpython-users/1999-November/001131.html A better solution though is to remove all non-wx-GL stuff from the glcanvas module and use DA's PyOpenGL package instead. http://starship.python.net:9673/crew/da/Code/PyOpenGL/ This is what I have done for the next release. You can pull the new glcanvas.i, .cpp, and .py files from CVS if you want. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From ullrich at math.okstate.edu Mon Dec 13 13:42:32 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 13 Dec 1999 12:42:32 -0600 Subject: Dot product? References: <3852B91D.6EE31805@math.okstate.edu> <3854CBFF.85A69AA@compaq.com> Message-ID: <38553E18.9FAD88AE@math.okstate.edu> Greg Ewing wrote: > "David C. Ullrich" wrote: > > > > but it doesn't look right - > > seems like the Python way would involve a "for x in X" > > instead of that "for j in range(len(X))". > > Sadly, that *is* the current Python idiom for doing parallel > iteration without incurring the overhead of constructing an > intermediate object. Right. > List comprehensions won't change this, unless whatever flavour > of them we get includes a syntax for parallel iteration -- in > which case the normal "for" loop will probably get it as well. As long as I'm asking stupid questions, what would "list comprehension" be? > My preferred backward-compatible candidate for this is: > > for x and y in list1, list2: > ... > > Greg From hei at adtranzsig.de Wed Dec 22 05:44:18 1999 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Wed, 22 Dec 1999 11:44:18 +0100 Subject: eval vs. atof References: Message-ID: <945862470.147537@news.adtranzsig.de> 1. eval() means a call to the Python parser. That's slower than having a specialized number parsing routine. 2. If you want the user to input a number, but parse his input with eval(), a user knowing about that (or suspecting it) might try to crash or spy out your system by entering arbitrary Python expressions. -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net Sposhua schrieb in Nachricht ... >Newbie... > >Why do string.ato[f/i/l] exist when you can use eval()? There must be a reason >for these things... > From jh at cddk.dk Mon Dec 20 12:08:18 1999 From: jh at cddk.dk (Jesper Hertel) Date: Mon, 20 Dec 1999 18:08:18 +0100 Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> Message-ID: <83lnq7$c9d$1@news1.tele.dk> I hope this was a joke. That kind of constructions is impossible to read for other programmers, making the program hard to maintain. I like maxm's function much better, because you can easily understand what the meaning is. Jesper Hertel Alex Martelli wrote in message news:6D8A17398E28D3119F860090274DD7DB4B3D62 at 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 t.middleton at news.vex.net Sat Dec 4 23:24:58 1999 From: t.middleton at news.vex.net (t. middleton) Date: 5 Dec 1999 04:24:58 GMT Subject: "%(a)s ... %(b)s" % {'a': foo, 'b': '%(b)s'} References: <000801bf3ece$671e7e60$3a2d153f@tim> Message-ID: <82cpeq$thi$1@hub.org> >Can't Python automatticaly detect there's no B so leave it blank? >Why doesn't Python do this? Of course, you can easily hack this behavior yourself, if you really, really, really want to. The following will output 'aaaaa, None' .... but do you really, really, really, really want to? import UserDict class NoneInsteadOfBang(UserDict.UserDict): def __getitem__(self, key): try: return self.data[key] except KeyError: return None print '%(a)s, %(b)s' % NoneInsteadOfBang({'a':'aaaaa'}) ... From pinard at iro.umontreal.ca Wed Dec 22 21:03:37 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 22 Dec 1999 21:03:37 -0500 Subject: Matching a constant string at beginning Message-ID: Hello, people. Some have a nice idiom for the following? I first wrote, a few months ago by now, I guess: if re.match('Simonsen', line): and to later speed up things a little, for some little while: if line[:8] == 'Simonsen': Yet, computing that `8' index is tedious, and writing: if line[:len('Simonsen')] == 'Simonsen': 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. I also tried: if string.find(line, 'Simonsen') == 0: but this scans the whole line for nothing, this is not better. So, do I have no choice then write that very small function? :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From alex at magenta.com Wed Dec 15 06:43:59 1999 From: alex at magenta.com (Alex Martelli) Date: Wed, 15 Dec 1999 12:43:59 +0100 Subject: "sins" (aka, acknowledged language problems) Message-ID: <837usr$6vg$1@serv1.iunet.it> Browsing on the Perl sites recently, I came upon: http://www.perl.com/pub/1999/11/sins.html which is a very interesting acknowledgment of some of the problems with Perl, including how some of them used to be there but are now fixed (or in the process of being fixed) while others are there to stay. I wonder if there is some analogous URL, on the Python sites, that I could quote right next to this one when I'm providing people with reasons they might want to consider switching from Perl to Python. After all, saying "here you will find, on the Perl site, documentation on Perl defects, that Python does not share -- Python, on the other hand, is absolutely perfect" (:-) would not exactly carry much strength... it would no doubt convince the recipient that Pythonistas are fanatics, unable to own up to their problems, while Perlites, while labouring under many hard language problems, are at least aware of them. I'm fully convinced that Python's "here-to-stay" problems are much lesser than Perl's, but having them clearly acknowledged, in a way similar to what is done at the above URL, would help a lot. Thanks for any pointers, Alex From tim_one at email.msn.com Thu Dec 9 22:19:00 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 9 Dec 1999 22:19:00 -0500 Subject: some random reflections of a "Python newbie": (2) language issues In-Reply-To: <82od57$i7n$1@serv1.iunet.it> Message-ID: <001e01bf42bd$4da0cfe0$60a2143f@tim> [Alex Martelli] > ... > 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. "for a in X:" also works fine if X is an instance of a class that supports the special __getitem__ method; see the docs; you are not required to look at __getitem__'s index argument, and, indeed, it seems I don't more often than I do. "if a in X:" currently works only if X is a list, tuple or string. In Python 1.6 it's supposed to work too if X is an instance of a class that supports the special __contains__ method; see the 1.6 docs, preferably after they're written . > ... > The way I envision this -- if X chooses to > implement a method __contains__, ... Yup -- that's The Plan. postcognitively y'rs - tim From s.schwarzer at ndh.net Mon Dec 27 10:20:41 1999 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Mon, 27 Dec 1999 16:20:41 +0100 Subject: "Message file not found" References: <3865594C.1AB35459@ndh.net> <847nak$16ph$1@thoth.cts.com> Message-ID: <386783C9.8836E073@ndh.net> 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. :-) Could you please post (or send a mail with) the contents of errno.errorcode on your system? Possibly the setting for your libpath could also be helpful, because my errno.errorcode is accessible but contains the wrong information. It might be that the mapping stems from another DLL. (?) Stefan From achrist at easystreet.com Tue Dec 7 21:56:49 1999 From: achrist at easystreet.com (Al Christians) Date: Tue, 07 Dec 1999 18:56:49 -0800 Subject: Linux.Com Message-ID: <384DC8F1.9A1F135F@easystreet.com> Python is running a healthy 4th in the Linux.Com scripting languages poll. From paul at prescod.net Thu Dec 30 04:43:32 1999 From: paul at prescod.net (Paul Prescod) Date: Thu, 30 Dec 1999 04:43:32 -0500 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <386A1037.C6D458B3@prescod.net> Message-ID: <386B2944.91611CCA@prescod.net> Justin Sheehy wrote: > > Paul Prescod writes: > > > I agree that tuples in Python are often used merely as immutable lists. > > This bothers me > > What else are they used as? Er. Tuples. Python tuples are often used as tuples in the global sense. They are sometimes also used as lists in the global sense. > It really sounds like what you are asking for is a lot more like a > dictionary than a tuple. It sounds like you should be lobbying for a > new mapping type, not a change to the existing (and very useful) tuple. Everyone wants to tell me what I want. :) I don't want a new type. I don't want enums, or read-only dictionaries. I want 30 lines of C code and a grammar change that will make tuples less error-prone and ugly to use. A new type wouldn't simplify my proposal, it would complicate it. > I see no benefit in removing any of their simplicity. I don't see how allowing keyword assignment and attribute access "destroys" the simplicity of tuples. Paul Prescod From alex at magenta.com Sun Dec 5 18:53:00 1999 From: alex at magenta.com (Alex Martelli) Date: Mon, 6 Dec 1999 00:53:00 +0100 Subject: A new Python page (in italian) Message-ID: <82etuu$ab9$1@nslave1.tin.it> It's under http://aleax.supereva.it/. For now, it only has my translations of two of M. Hetland's articles (thanks to Mr Hetland for allowing me to perform the translation), but I do plan to put more stuff on it eventually. I'll appreciate correspondence on this (alex at magenta.com), such as feedback or info on any other relevant Italian page. My newsfeed's flaky, so I might miss posted responses (pls cc my email if you should respond -- thanks!). Alex From a.eyre at optichrome.com Fri Dec 3 09:24:03 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 3 Dec 1999 14:24:03 -0000 Subject: emulating `` shell operator in Python? In-Reply-To: <3847CB4D.8690D7E7@ina.fr> Message-ID: <001101bf3d9a$0cb2b700$3acbd9c2@peridot.optichrome.com> > - 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 -------------------------------------------- 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 mdfranz at my-deja.com Mon Dec 13 00:18:47 1999 From: mdfranz at my-deja.com (mdfranz at my-deja.com) Date: Mon, 13 Dec 1999 05:18:47 GMT Subject: Extracting list of keys from 2-key dictionary Message-ID: <831vjl$goe$1@nnrp1.deja.com> I'm porting a script from perl that uses: dict[a,b] instead of $hash{$a}{$b} My goal is to get a unique list of the second keys for a value, when a=x In perl, this can be done with: @list = keys %{$hash{x}} Is there a quicker/easier way in python than the snippet below to do this? for a,b in dict.keys(): if dict.has_key(x,b): if b not in list: list.append(b) TIA, -matt Sent via Deja.com http://www.deja.com/ Before you buy. From jamarijr at hotmail.com Fri Dec 31 12:23:30 1999 From: jamarijr at hotmail.com (Arinte) Date: Fri, 31 Dec 1999 17:23:30 GMT Subject: Executing a script. Message-ID: <84io2q$ki2$1@nnrp1.deja.com> I am trying to run a .py file, but for some reason I keep getting a null pointer exception??? I get this exception when I use PyRun_AnyFile like so: FILE* fname; Py_Initialize(); fname = fopen(name,"r"); Py_InitModule("poss", Exposem); cout< Message-ID: In article <000001bf412b$a7a87ee0$5aa2143f at tim>, Tim Peters wrote: >[Tim] >You mean WinTel is the only platform that does this right ? Works with 1.5.2 on Linux/x86 (glibc); 1.5.1 gives 0.0 for both atan2() calls. > >if-the-pentium-didn't-do-this-all-by-itself-ms-would-get-it- > wrong-too-ly y'rs - tim Besides-I-was-talking-about-negative-INTEGER-zero'ly Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From tim_one at email.msn.com Thu Dec 30 18:11:52 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 30 Dec 1999 18:11:52 -0500 Subject: __rcall__??? In-Reply-To: <386BA662.112B4C19@math.okstate.edu> Message-ID: <000601bf531b$42c51d60$3ca2143f@tim> [Tim] >> No, there's no info in the manual about [__rpow__] 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. [David C. Ullrich, irked] > No, it doesn't matter a bit. I was assuming that your reply > had at least _some_ relevance to the question I'd asked - I believed it did. > 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. I read your original question as being more about __pow__ and __rpow__ behavior than about their history. If the history is indeed-- as it *seemed* to me from the start --something that really "doesn't matter a bit" to you, I don't grasp what's eating you. >> 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. My fault: I was away from the computer on vacation for somewhat over a week. Replying to your last __rcall__ msg was the last thing I did before I left. Your reply to that was one of the first of the 1,000+ msgs waiting in my inbox when I returned, and I answered it before reading all the pending msgs. I see now that it was unnecessary; sorry for the aggravation. > [a rant about single-argument vs multiple-argument functions] My favorite non-Python language is Haskell, in which all functions are curried (common jargon in the functional-language biz for "single argument"), even addition (e.g. "+" is a function that takes (say) an integer argument and returns a function mapping ints to ints; "- 1" is a function that returns a function that subtracts one from its argument; "1 -" is function that returns a function that subtracts its argument *from* 1; etc.). You don't need to convince me that's an elegant & very useful view of the world. It's simply not Python's view of the world. Still, as you discovered, it's quite possible to write Python code to fake it! Python doesn't force you to write multiple-argument functions, and I'm not even asking you to. My only interest here is in preventing a push for *Python's* call implementation to treat single-argument functions in a distinguished way (as would the hypothetical __rcall__ method of the subject line); my attempts to explain why that's unnatural in *Python* appear to be perceived as attacks against Mathematical Truth. They're not. Curried functions in Python are as much a strain as representing ints as lambda compositions in Python (which also can-- for that matter, has --been done). [still in sarcasm mode] > the idea that different answers are appropriate in different > contexts is just silly. What would be silly is the notion that a single programming language *can* (let alone "should") support all modes of expression with equal fluidity. choices-have-consequences-and-python-made-some-ly y'rs - tim From badzen at yifan.net Sat Dec 18 00:28:33 1999 From: badzen at yifan.net (dj trombley) Date: Sat, 18 Dec 1999 05:28:33 GMT Subject: circular references? References: Message-ID: <385B1AE9.DD4F8ED3@yifan.net> Roy Smith wrote: > > Let's say I've got: > > class a: > pass > > class b: > def __init__ (self, x): > self.x = x > > and then I do: > > foo = a() > foo.b = b(foo) > > I've now got two objects that contain references to each other. Is this > bad? Introspection: That all depends on what one views as 'bad'. =) What it _does_ actually do is prevent the garbage collector from cleaning up the memory, because there will always be a valid reference chain. If this is the behavior you want, or if you are aware of it and will break the chain as needed (usually best done in the __del__ method), then it is not needingly bad. For more information on object creation and collection, see Chapter 3 of the Python Language Reference. (http://www.python.org/doc/ref) -dj Dave Trombley From alex at magenta.com Sat Dec 11 12:18:15 1999 From: alex at magenta.com (Alex Martelli) Date: Sat, 11 Dec 1999 18:18:15 +0100 Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <82o0to$6eq$1@serv1.iunet.it> <82pcm0$p6t$1@nnrp1.deja.com> <19991211093354.A1583@stopcontact.palga.uucp> Message-ID: <82u156$go$1@nslave2.tin.it> Gerrit Holl wrote in message 19991211093354.A1583 at stopcontact.palga.uucp... > Grant Edwards wrote: > > In article <82pcm0$p6t$1 at nnrp1.deja.com>, Preston Landers wrote: > > >"Programming Python" indeed sucks. > > I agree. But what about "Internet programming with Python"? Me, I've gulped it down, then re-read it right back, and just love it. The only wrong thing about it is the title -- it gives the impression of being "about the internet", which is maybe 20% of the subject matter, if that... it's really about Python, and an excellent introduction. Alex From greg at quokka.demon.co.uk Sun Dec 26 19:28:59 1999 From: greg at quokka.demon.co.uk (greg at quokka.demon.co.uk) Date: Mon, 27 Dec 1999 00:28:59 GMT Subject: JPython - Problems using "re" References: <82lh78$12h$1@rairidh.dcs.ed.ac.uk> Message-ID: <3866b2c7.419318125@news.demon.co.uk> > Hillary Clinton Hilary with one 'l' I think does inclusion of this kind of list force reading of the message by a person? or are "THEY" clever enough to use computers to determine context and do some pre-screening? From aa8vb at yahoo.com Thu Dec 30 16:19:52 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 30 Dec 1999 16:19:52 -0500 Subject: [ANNOUNCE] Pygasm IDE wxWindows Linux Developer Release In-Reply-To: References: <386B510D.3EC3B9DB@pcpros.net> <19991230070826.B778039@vislab.epa.gov> Message-ID: <19991230161952.A7052@vislab.epa.gov> Robin Dunn: |> I pulled it and ran 'python Pygasm.py'. Here's what I got: | |You need to build the html module in wxPython/modules/html. Ouch. Rebuilding wxPython took a bit of time, but Pygasm loads and runs now. I wonder if html shouldn't be built/installed by default... Thanks for the tip. -- Randall Hopper aa8vb at yahoo.com From maytagrepairman at yahoo.com Tue Dec 21 22:06:09 1999 From: maytagrepairman at yahoo.com (maytagrepairman at yahoo.com) Date: Wed, 22 Dec 1999 03:06:09 GMT Subject: Is there a Python equivalent of Tcl's auto_execok? Message-ID: <83pf6u$q57$1@nnrp1.deja.com> Is there a Python equivalent of Tcl's auto_execok? Sent via Deja.com http://www.deja.com/ Before you buy. From tholap at compuserve.com Wed Dec 8 21:52:25 1999 From: tholap at compuserve.com (Olaf Appelt) Date: Thu, 9 Dec 1999 03:52:25 +0100 Subject: Embedding questions Message-ID: <82n5ec$e2a$1@ssauraab-i-1.production.compuserve.com> Hi, I'm maintaining a proprietary half-baked interpreter environment within a large commercial application (written in C++), that looks mostly like Basic with some important properties added. It basically allows people who are no experts in programming to produce financial software. GUI and DB access is automatic. Within this environment the 'programmer' mostly just does some calculations with a lot of ifs and the occasional for loop. I would like to replace that beast with Python. Perhaps just using the interpreter with a simple translation from our Pseudo-BASIC to Python, perhaps even Python as a language. After looking at Python for a few hours it looks sane enough to be digestible for the non-expert programmer (unlike another popular freeware scripting language ;-) ). 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 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. That is fine for most temporary variables used during calculations, but at the end all results have to end up in a set of variables with particular names, that also have particular type information. 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 One way to solve this problem is to keep our Basic dialect and simply translate it (in a primitive compile step) to Python, but I would prefer to not maintain this language just to keep assignment looking good. 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? Any comments are appreciated. Olaf From htrd90 at zepler.org Wed Dec 1 15:33:37 1999 From: htrd90 at zepler.org (Toby Dickenson) Date: Wed, 01 Dec 1999 20:33:37 +0000 Subject: WinNT and python as text filter... References: <3842f32d.30322451@news.concentric.net> Message-ID: "Mark Hammond" wrote: >How are you executing the code? Are you just typing: > >c:\>myscript.py > out > >If so, there is a bug in the NT command prompt - you need to specify the >full path to Python.exe on the command line, and it will work... As a point of good news, this is fixed in Windows 2000. (so I might upgrade after all ;-) Toby Dickenson htrd90 at zepler.org From BgPorter at NOacmSPAM.org Fri Dec 10 11:58:28 1999 From: BgPorter at NOacmSPAM.org (Brett g Porter) Date: Fri, 10 Dec 1999 16:58:28 GMT Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <82o0to$6eq$1@serv1.iunet.it> <82pcm0$p6t$1@nnrp1.deja.com> Message-ID: "Grant Edwards" wrote in message news:slrn8524tl.jcd.grant at grante.comtrol.com... > What I'd like is a good intermediate level book written for an > audience that already knows the basics of programming and > language theory. Hear, hear. I'm on my second go-through of "Programming Python," and continue to shake my head -- I've been programming professionally for close to 10 years now, and this book has the rare ability to make me feel that I know less after reading it than I did before. Also, I already own all the scripts to Python (Monty), and don't need to get them in a programming text. I was looking for a 'little' language and almost bought a Perl book instead (before I looked at enough Perl code to realize that it looks like the bastard stepchild of awk & Basic). I wasn't expecting the depth that I'm finding in Python. What I'd _really_ like is the Python equivalent of Bruce Eckel's "Thinking in..." series -- I know that Bruce is going to throw a Python seminar soon, so maybe... From parish at ikb.mavt.ethz.ch Tue Dec 21 06:43:35 1999 From: parish at ikb.mavt.ethz.ch (Yoav I H Parish) Date: Tue, 21 Dec 1999 12:43:35 +0100 Subject: Question about a regular expression Message-ID: <385F67E7.B5E4E83@ikb.mavt.ethz.ch> Hello, 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 would like to extract the parameters within the parantheses. The values ought to be separated. What kind of regular expression for re.split could I use? I have tried several, but can't seem to get it right... thanx for any help y.parish From stuarty at excite.co.uk Tue Dec 7 09:48:35 1999 From: stuarty at excite.co.uk (stuart mcfadden) Date: 7 Dec 1999 14:48:35 GMT Subject: lemmings Message-ID: <82j6o3$jc6$1@news.qub.ac.uk> 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 ? From wzab at ise.pw.edu.pl Wed Dec 8 12:10:08 1999 From: wzab at ise.pw.edu.pl (Wojciech Zabolotny) Date: Wed, 8 Dec 1999 18:10:08 +0100 Subject: How to build the Python Numeric double array in a C extension module? Message-ID: Hi All, I have to write a C extension module for DSP with Python. One of its function will be to read the signal samples from DAQ system or from disk file. To do it efficiently, I have to be able to build an float or double Python Numeric array in my C function. The Py_BuildValue function does not seem to be able to do it, or the format specifiers given in my /usr/doc/python/html/ext/buildValue.html are not complete. In the Python Numeric doc I couldn't find anything about writing C extensions working with this module. How to solve my problem, or where to find the more detailed info about interfacing the Python Numeric module? Please Cc the answers to wzab at ise.pw.edu.pl -- TIA Wojciech Zabolotny wzab at ise.pw.edu.pl http://www.ise.pw.edu.pl/~wzab Build your free Data Acquisition System: http://www.ise.pw.edu.pl/~wzab/picadc/picadc.html From amitp at Xenon.Stanford.EDU Tue Dec 28 22:08:35 1999 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 29 Dec 1999 03:08:35 GMT Subject: newbie question... References: <3869229B.C06B94E5@earthlink.net> Message-ID: <84btvj$mfi$1@nntp.Stanford.EDU> Alexander Sendzimir wrote: | As a developer new to the Python language and experienced with the Perl language | (and quite a few others ;-), I'm wondering what the accepted method of handling | a text file's contents are in Python. For example, the following Perl construct | is pretty standard. | | while ( ) | { | # process each line as if comes off the file handle... | } | | is typical. | | 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 | # using some prefered method (there's more than | # one way of doing this, of course ;-) | I tend to use: import fileinput for line in fileinput.input(): # do something with the line I'm not sure if you can use this for a file handle; it may only work for filenames. :-( - Amit From bkc at murkworks.com Mon Dec 27 17:04:25 1999 From: bkc at murkworks.com (Brad Clements) Date: Mon, 27 Dec 1999 17:04:25 -0500 Subject: [PSA MEMBERS] Re: Please test new dynamic load behavior In-Reply-To: References: <38620B04.7CC64485@trema.com> Message-ID: <199912272204.RAA26173@anvil.murkworks.com> On 23 Dec 99, at 10:26, Greg Stein wrote: > > > 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). FYI, I downloaded the import stuff from CVS and used it in my port of Python to NetWare. Good timing, as I was just tackling dynamic loading on NetWare when I saw your message. The new scheme is much better, and works for me. Though I do need to add some special "un-import" code similar to what BEOS does. Brad Clements, bkc at murkworks.com (315)268-1000 http://www.murkworks.com (315)268-9812 Fax netmeeting: ils://ils.murkworks.com AOL-IM: BKClements From anders.eriksson at morateknikutveckling.se Tue Dec 21 04:39:00 1999 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Tue, 21 Dec 1999 10:39:00 +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: On Mon, 20 Dec 1999 11:25:07 -0600 (CST), Skip Montanaro 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? // Anders From james.cooley at jcp.co.uk Thu Dec 9 07:22:10 1999 From: james.cooley at jcp.co.uk (James Cooley) Date: Thu, 09 Dec 1999 12:22:10 +0000 Subject: Win32 and the clipboard References: <82niqp$gml$1@nnrp1.deja.com> Message-ID: <384F9EF2.395B80FB@jcp.co.uk> Just an idea but I used the clipboard and "drag and drop" on Win32 (or any OS with a JVM) using JPython and Java 1.1. You can get a start with http://www.javaworld.com/javatips/jw-javatip61.html Rgds, James Greg Landrum wrote: > > 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. -- James Cooley [+44 (0)171-6896924] JCP Computer Services, 16 St Johns Lane, London, EC1M 4BS, UK. PGP Key ID : 0x28CA7769 fingerprint: A39D 1357 89EF 3707 2D62 050B 6AA1 4D03 28CA 7769 From fdrake at acm.org Tue Dec 21 17:36:06 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 21 Dec 1999 17:36:06 -0500 (EST) Subject: Is there a debugger tutorial? In-Reply-To: <385E90AB.B1296AA8@callware.com> References: <385E90AB.B1296AA8@callware.com> Message-ID: <14432.214.127328.923615@weyr.cnri.reston.va.us> Ivan Van Laningham writes: > 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. There's a chapter in the Library Reference. And you're certainly welcome to suggest revisions, or just send me patches. ;-) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From bsb at winnegan.de Fri Dec 31 13:07:54 1999 From: bsb at winnegan.de (Siggy Brentrup) Date: 31 Dec 1999 19:07:54 +0100 Subject: No constructor calls? In-Reply-To: Arinte's message of "Fri, 31 Dec 1999 13:37:18 GMT" References: <84iasi$bdd$1@nnrp1.deja.com> Message-ID: <87ogb7asqt.fsf@baal.winnegan.de> Hi Arinte, you posted this very message already on Thursday and IIRC Gordon McMillan answered. You should give us more information. Arinte writes: > When I have this code the constructor is called > xpac=PossDevice.PossArg("12345678",21) > devlist.append( xpac ) > but, this code doesn't seem to function > devlist.append( PossDevice.PossArg("12345678",21) ) > Is the second one invalid or something? How can I do the first one > in one call? The only difference I see is an additional reference in the 1st variant. As a blind shot I assume some Extension code written in C is involved and does incorrect reference counting. Siggy -- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From hartmut at oberon.noris.de Sat Dec 25 06:07:24 1999 From: hartmut at oberon.noris.de (hartmut Goebel) Date: Sat, 25 Dec 1999 12:07:24 +0100 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: <16600359@oberon.noris.de> Fred L. Drake, Jr. (fdrake at acm.org) schrieb: > 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. The Oberon-2 language uses self^.method() to call the super classes method "method". > -Fred +++hartmut From mlh at vier.idi.ntnu.no Thu Dec 30 09:49:45 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 30 Dec 1999 15:49:45 +0100 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <386A1037.C6D458B3@prescod.net> Message-ID: Paul Prescod writes: > Eugene Goodrich wrote: > > > > When I started in Python, my PyMentor described tuples as immutable > > lists. When they start acting like much more than that, isn't it time > > to use an object? > > I agree that tuples in Python are often used merely as immutable lists. > This bothers me for several reasons: > > * that isn't what "tuple" means in mathematics. In most mathematics > EVERYTHING is immutable. Tuples and lists are still distinct Yes. More about definitions below. > * it is because of this abuse that the "one-item tuple" problem arises > so often. There is no such problem in mathematics because a one-item > tuple does not make sense. A common definition of an ordered set or tuple is like this: - The ordered pair (x, y) is defined as the set {{x},{x,y}} - An n-tuple (a,b,...,z) is defined as ((a,b,...,y),z) This definition obviously doesn't define tuples of length 1. I'm not sure that means that they are meaningless, though. It would be simple to extend the definition if you needed it, as for instance: (x) = {x} The difference between tuples and lists are that lists (or sequences) often are defined as partial functions with domain N0; for instance: s = Then s(0) = a, s(1) = b etc. They may be used in different contexts, but really, they aren't all that different. > In Python world we most often use tuples as mathematicians do. > Really, a tuple is supposed to be a collection of things where the > sender and the recieiver have agreed on the number of items in > advance, and every item has a special "meaning." The time library is > a perfect example of this: Yes - I guess that is the most common use. (As in cartesian points... Even though the dimentions may not be all that different, they are at least defined by their position...) > The primary weakness with the time library is that you have to index > daylight savings flag by (for example) [9] instead of .daylight . Well - the way this is done in mathematics is usually (in my experience) something like this: We have a graph G=(V,E) where V is the set of vertices and E is the set of edges... The elements of the tuple G are not named - it is unpacked, just like in Python: We have a graph (V,E)=G where V is the (e.g.) list of vertices, and E is the (e.g.) dictionary of edges. Or something. > If you use tuples as mathematicians do then single-item tuples can > never arise because senders and recievers would never agree on a > "protocol" (used loosely) that involves 1 length tuples (why use a > tuple!). I guess these things in Python have a lot to do with the underlying C-implementation, since tuples in many circumstances are quite efficient, and one-element tuples may be used to be consistent sometimes. > > Paul Prescod > -- Magnus Lie Hetland From hartmut at oberon.noris.de Thu Dec 9 18:00:55 1999 From: hartmut at oberon.noris.de (hartmut Goebel) Date: Fri, 10 Dec 1999 00:00:55 +0100 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: <16600266@oberon.noris.de> Jeremy Hylton (jeremy at cnri.reston.va.us) schrieb: >>>>>> "SM" == Skip Montanaro writes: > SM> "a %(x)s b %(y)s" % locals() > "a %(x)s b %(y)s" % obj.__dict__ How efficient is this? +++hartmut | hartmut Goebel | hartmut at oberon.noris.de // | | | Essich at irc \X/ | PGP fingerprint = BF DD D6 75 7C 03 21 52 47 65 50 7F 54 47 06 C7 From joeyGibson at mindspring.com Tue Dec 14 23:04:29 1999 From: joeyGibson at mindspring.com (Joey Gibson) Date: Tue, 14 Dec 1999 23:04:29 -0500 Subject: Java 1.2 and JPython References: <199912011207.HAA04934@python.org> <384B0A7F.B685E594@mincom.com> Message-ID: On Mon, 06 Dec 1999 10:59:43 +1000, John Farrell wrote: ||| sdossett at metaphoria.net wrote: ||| > 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. ||| ||| Scott, anything on the CLASSPATH is available, so it's a fair bet that ||| JPython works with JDK1.3 as well. I've been using it with 1.3 for quite some time and have had no problems. I use it just about every day and have had no complaints. Joey -- -- Sun Certified Programmer for the Java2 Platform -- -- "Then slew they the goats, YEA! And placed they the bits, -- in little pots." From bernhard at alpha1.csd.uwm.edu Wed Dec 1 15:44:40 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 1 Dec 1999 20:44:40 GMT Subject: how to get methods from COM objects References: <38453eff.5789544@122.0.0.250> Message-ID: On Wed, 01 Dec 1999 15:31:25 GMT, volumeregeling wrote: >Can anybody tell me how to extract methods from a COM object. >For instance i?d like to know what methods internet explorer exposes, >so i can direct IE from within python. Look into the COM browser and the makepy script. (Both directly available in PythpnWin.) 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 aahz at netcom.com Mon Dec 27 12:28:59 1999 From: aahz at netcom.com (Aahz Maruch) Date: 27 Dec 1999 17:28:59 GMT Subject: Python suitability References: <38549DEA.B0157D0@iqsoft.hu> <005801bf4f7a$059ddf20$bf2b2bc1@martelli> <38664525.1D26C3D4@maxtal.com.au> <3867A2FE.C9FFC5B9@digicool.com> Message-ID: <8487kr$v4t$1@nntp2.atl.mindspring.net> In article <3867A2FE.C9FFC5B9 at digicool.com>, 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 drop a "not" there? -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Eighth Virtual Anniversary -- 4 days and counting! From Alex.Martelli at think3.com Fri Dec 17 08:23:45 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Fri, 17 Dec 1999 14:23:45 +0100 Subject: iteration (was RE: "sins" (aka, acknowledged language problems)) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D53@pces.cadlab.it> Fredrik Lundh writes: > > def copy(regex, dict, inp=sys.stdin, oup=sys.stdout): > > def repl(match,dict=dict): > > return eval(match.group(1),dict) > > while 1: > > line = inp.readline() > > if not line: > > break [snip] > hmm. by some reason, my brain treats that > while/if/break stuff as one large "glyph". am > I the only one here who has a brain equipped > with a 2D pattern matcher? ;-) > No, I think that's pretty common -- why, some people are even rumored to live in a 3D world:-). Similarly, in languages having nothing except IF and GOTO as flow-control constructs, one eventually learns to recognize such idioms as LOOP: IF not condition GOTO OUT statements GOTO LOOP OUT: as equivalent to what would be WHILE condition statements in a better-equipped language. Do you consider that this amazing pattern recognition ability of the human brain is some argument against introducing more explicit and concise constructs for extremely usual patterns, such as IF/GOTO/GOTO?-) > > But why can't I change those 4 lines to, say: > > while line := inp.readline(): > > how about: > > import fileinput > for line in fileinput.input(): > Wouldn't that tie me to using sys.stdin, rather than giving the caller the option of supplying some other file object (or other object implementing readline) in its stead (so that the caller would need to muck with sys.argv to make me read other files, and be out of luck for other customizations)? Wouldn't it further break on "MS-DOS 8+3 filesystems", at least according to the 1.5.2 docs? Seems a high-ish price to pay to get better syntax. Maybe it would be better in this case to change the argument default inp=sys.stdin to inp=fileinput and the loop to for line in inp.input() which gets me the good syntax and is just about as easy for the caller to customize. I was about to add that "of course, this doesn't help in other similar cases of iteration" when I realized that in a sense it does -- the Python answer to "how do I make a decent looking loop rather than using a 4-line glyph" could be "beg, borrow or steal an iterator object that doles out items one at a time so you can use it in a for loop" -- which takes me very close to a recent post of mine to this list/newsgroup, the 2nd part of the "random reflections" post, where my thirst for elegant generalizations brought me a (very mild & courteous) reproach by Tim. Partially-undaunted, I now ask...: Given the "4-line glyph": > while 1: > item = mynextitem('foo') > if not is_still_ok(item,'bar'): > break > I would like to translate this to something like: for item in iter(mynextitem,('foo',),is_still_ok,('bar',)): (actually, I would dearly LOVE to translate it to while is_still_ok(item:=mynextitem('foo'),'bar'): but let's assume there IS no ':=' operator:-). Of course, I'd have reasonable defaults, e.g. is_still_ok would default to normal truth-testing unless explicitly specified, etc. Is it reasonable for me to try to design a "class iter" for such uses, or am I again shooting for misplaced and excessive generality, and/or likely to meet serious performance trouble, etc...? Offhand, I'd write something like (capitalizing on Tim's earlier suggestion to ignore the "key" passed to __getitem__): class iter: def __init__(self,next,na=(),test=None,ta=()): self.next=next self.na=na self.test=test self.ta=[None]+map(None,ta) del __getitem__(self,key): item = apply(self.next,self.na) if self.test: self.ta[0] = item if not apply(self.test,self.ta): pass # do what, here...? else if not item: pass # do what, here...? return item 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...? TIA once more to all you helping this newbie in his discovery of this great language... Alex From see at my.sig Tue Dec 14 13:46:30 1999 From: see at my.sig (dg) Date: Tue, 14 Dec 1999 10:46:30 -0800 Subject: Tkinter/IDLE crash References: <000c01bf4553$5e739b20$9e2d153f@tim> Message-ID: In article <000c01bf4553$5e739b20$9e2d153f at tim>, tim_one at email.msn.com spoke thusly: > [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. 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. -- Don Groves (dgroves_ccwebster_net) Replace underscores to get my email address. From tim_one at email.msn.com Mon Dec 20 17:18:58 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 20 Dec 1999 17:18:58 -0500 Subject: __rcall__??? In-Reply-To: <385E70D1.236ED0BB@math.okstate.edu> Message-ID: <000a01bf4b38$35da1640$b3a0143f@tim> [Tim] > That is, AFAIK nobody ever asked for it before, and it's not > screamingly natural (you're not really *surprised* at the lack > of __rcall__, right?). [David C. Ullrich] > No, it doesn't seem screamingly natural, and I'm not really > surprised at the lack of it. Well, it doesn't seem so natural > in most contexts; it actually does seem fairly natural (and it > _is_ very useful, putting-each-bit-of-code-where-it-belongs- > wise) in this thing I'm doing. Oh yes! I appreciate that. It's the thing you're doing that's unnatural . > But I wasn't actually expecting anyone to add it to Python for > me, I just thought I'd ask (mainly because the other day when > I asked about Transpose it turned out that there _was_ a Transpose > built in, just spelled funny. Coulda been there _was_ a misspelled > __rcall__ already there as well. I gather not.) You gather correctly. > 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__. > 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, 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__. 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 tholap at compuserve.com Thu Dec 9 07:06:41 1999 From: tholap at compuserve.com (Olaf Appelt) Date: Thu, 9 Dec 1999 13:06:41 +0100 Subject: Embedding questions References: <82n5ec$e2a$1@ssauraab-i-1.production.compuserve.com> <00a401bf422a$28ae6280$f29b12c2@secret.pythonware.com> Message-ID: <82o7ru$gsf$2@ssauraac-i-1.production.compuserve.com> Hi Fredrik, thank you very much. I'll look into this. Olaf Fredrik Lundh wrote in message news:00a401bf422a$28ae6280$f29b12c2 at secret.pythonware.com... > Olaf Appelt wrote: > > 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? > > Greg Stein's imputil.py [1] allows you to modify the > import statement so it can pick up code from any > data source. > > an example (assuming "db" is a database object which > works pretty much like a code string dictionary). > > ... > > class DatabaseImporter(Importer): > > def __init__(self, db): > self.__db = db > > def get_code(self, parent, modname, fqname): > # is it a module? > try: > code = marshal.loads(self.__db[fqname]) > return 0, code > except KeyError: > pass > # is it a package? > try: > fqname = fqname + ".__init__" > code = marshal.loads(self.__db[fqname]) > return 1, code > except KeyError: > pass > return None # not found in this database > > # prepends the database to the import chain > DatabaseImporter(mydb).install() > > ... > > to compile python source code into code strings, use: > > string = marshal.dumps(compile(source, filename, "exec")) > > ... > > hope this helps! > > > > 1) http://www.lyra.org/greg/python/imputil.py From phd at phd.russ.ru Fri Dec 10 08:26:24 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Fri, 10 Dec 1999 13:26:24 +0000 (GMT) Subject: Any web automation modules? In-Reply-To: Message-ID: On 10 Dec 1999, John Doe wrote: > Is there any modules for getting web pages? urllib Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From skip at mojam.com Tue Dec 7 17:05:06 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 7 Dec 1999 16:05:06 -0600 (CST) Subject: exchanging data btwn Python and lesser languages In-Reply-To: <1267538634-27138233@hypernet.com> References: <82jau6$e72$1@nnrp1.deja.com> <1267538634-27138233@hypernet.com> Message-ID: <14413.33938.300484.712295@dolphin.mojam.com> >> I'm looking for a quick-n-dirty way to exchange data between >> Python and other languages, especially P*rl. Gordon> Skip Montanaro did something along these lines. As I mentioned to Preston in private email, I stopped working on/looking for a solution once I discovered XML-RPC. Works fine for our needs. Relevant URLs include http://www.xmlrpc.com/ (XML-RPC home page) http://www.pythonware.com/products/xmlrpc/index.htm (xmlrpclib) http://www.pythonware.com/madscientist/ (sgmlop - C-based SGML/XML parser) 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 darrell at dorb.com Sat Dec 4 14:05:07 1999 From: darrell at dorb.com (Darrell) Date: Sat, 4 Dec 1999 14:05:07 -0500 Subject: "%(a)s ... %(b)s" % {'a': foo, 'b': '%(b)s'} References: <19991204161814.A5289@stopcontact.palga.uucp> Message-ID: <045b01bf3e8a$7b69bf40$0100a8c0@rochester.rr.com> import re MAIL = '''From: someone <%(email)s> Subject: test this is feedback.py %(version)s ''' dic={'version': "1.1"} def format(fmt, dic): converted=[] nonConverted=[] def func(mo, dic=dic, conv=converted, nonConv=nonConverted): k,t=mo.groups() if dic.has_key(k): conv.append(k) return mo.group(0)%dic nonConv.append(k) return mo.group(0) return re.compile('%\((.*?)\)(\w)').sub(func,fmt), converted, nonConverted result=format(MAIL, dic) print result[0] print 'Converted:', result[1] print 'Not converted:', result[2] ######### output From: someone <%(email)s> Subject: test this is feedback.py 1.1 Converted: ['version'] Not converted: ['email'] --Darrell ----- Original Message ----- From: "Gerrit Holl" > > 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? > From robin at alldunn.com Thu Dec 30 13:55:19 1999 From: robin at alldunn.com (Robin Dunn) Date: Thu, 30 Dec 1999 10:55:19 -0800 Subject: [ANNOUNCE] Pygasm IDE wxWindows Linux Developer Release References: <386B510D.3EC3B9DB@pcpros.net> <19991230070826.B778039@vislab.epa.gov> Message-ID: > I pulled it and ran 'python Pygasm.py'. Here's what I got: > > > python Pygasm.py > importing wxPython... > imported wxPython > Traceback (innermost last): > File "Pygasm.py", line 7, in ? > import Editor > File "Editor.py", line 7, in ? > from EditorViews import * > File "EditorViews.py", line 3, in ? > from wxPython.html import * > ImportError: No module named html > You need to build the html module in wxPython/modules/html. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From fredrik at pythonware.com Thu Dec 9 06:26:13 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 9 Dec 1999 12:26:13 +0100 Subject: Numeric Conversion References: <384F6823.E66085F1@cc.huji.ac.il> Message-ID: <01be01bf4238$346f62a0$f29b12c2@secret.pythonware.com> Iddo Friedberg wrote: > A small one: atoi &c. recognize the tokens '+' and '-' by themselves as > a numeric value; i.e. > > >>> m=string.atoi('+') > >>> print m > 0 what version are you using? I'm pretty sure this was fixed in 1.5.1 or 1.5.2... From bsb at winnegan.de Sun Dec 19 03:13:02 1999 From: bsb at winnegan.de (Siggy Brentrup) Date: 19 Dec 1999 09:13:02 +0100 Subject: sockets In-Reply-To: "sameer chowdhury"'s message of "Sun, 19 Dec 1999 23:00:19 -0500" References: <001101bf4a9e$bc716720$aa72d03f@sameer2> Message-ID: <87ln6rgxgx.fsf@baal.winnegan.de> "sameer chowdhury" writes: > 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. > > Error: > > Traceback (innermost last): > File "client_stuff.py", line 6, in ? > s.connect(HOST, PORT) > File "", line 1, in connect > socket.error: (10061, 'winsock error') Your code works perfectly on my Linux box too, maybe you forgot to restart the server before connecting again? I'm attaching slightly modified versions, with te server running continuously. HIH Siggy -------------- next part -------------- A non-text attachment was scrubbed... Name: server.py Type: application/octet-stream Size: 427 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: client.py Type: application/octet-stream Size: 213 bytes Desc: not available URL: -------------- next part -------------- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From skaller at maxtal.com.au Fri Dec 3 16:04:44 1999 From: skaller at maxtal.com.au (skaller) Date: Sat, 04 Dec 1999 08:04:44 +1100 Subject: Python complaints References: <867lj85g4c.fsf@g.local> <3846db0f.26374828@news1.on.sympatico.ca> <86ogc9q8mm.fsf@g.local> Message-ID: <3848306C.A5C23C6@maxtal.com.au> Gareth McCaughan wrote: > > Robert Roy wrote: > > [I said:] > >> - Method definitions have to be lexically contained in > >> class definitions. So suppose you write something that > >> parses a language and then does various things with > >> the parse tree; if you adopt an OO approach to the > >> parse tree (with things like "class IfStatement(ParseNode):") > >> then you can't separate out very different operations like > >> foo.print(), foo.compile() and foo.evaluate(). (That is, > >> you can't group all the print methods together, and group > >> all the compile methods together somewhere else, etc.) > >> You can, of course, split your code up by having the WhileLoop > >> and UntilLoop classes in different files, but this seems > >> less sensible to me. :-) (This particular gripe applies to > >> most OO languages.) > >> > > > > Unless I misunderstood your post, the following code would do the job > > nicely. > > > > bar.py > > def bar(self): > > print self.__class__.__name__ > > > > def bar2(self): > > print 'In bar 2', > > self.bar > > > > foo.py > > class foo: > > from bar import * > [etc] > > That allows me to split up a class's methods into several > different files, true. On the other hand, they can't then > be grouped in some other way. Yes, they can. It is a common technique, to make various tables of functions. You can build objects like class foo in python using 'exec', if necessary. This requires more than 'from bar import *', but using that doesn't _exclude_ other groupings. -- 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 dante at oz.net Wed Dec 22 21:02:29 1999 From: dante at oz.net (Michael Esveldt) Date: 23 Dec 1999 02:02:29 GMT Subject: playing well with others (newbie question) Message-ID: <83rvrl$heu$0@216.39.162.232> I'm stuck with the following problem with python 1.5.2c1 on MacOS 8.6: while 1: pass grinds my system to a halt. In other languages there are commands that give away cycles to the rest of the system and thus "playing well with others." Is there some similar command in python? Something to replace that pass with that allows me to do other things with my system? Michael Esveldt From m.faassen at vet.uu.nl Wed Dec 1 06:01:06 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Dec 1999 11:01:06 GMT Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> Message-ID: <822v5j$oe0$1@newshost.accu.uu.nl> Will Ware wrote: [snip] > 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()". But this would be a method of the 'i' reference (and currently references can't have methods, only that which is referenced). After all, the current behavior is this: i = 3 j = i i = i + 1 print i, j # prints 4, 3 The behavior of an 'incr()' method to an integer would mean this: i = 3 j = i i.incr() print i, j # prints 4, 4 (!) Therefore your behavior should be somekind of 'reference method'. Interesting concept in its own right perhaps (I just started thinking about it in this post), but currently not part of Python. This would be a work around: i = 3 j = i i = i.incr() print i, j # prints 4, 3 But i = i + 1 is just as easy to type. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From andrew at fc.hp.com Fri Dec 3 18:57:30 1999 From: andrew at fc.hp.com (Andrew Patterson) Date: Fri, 03 Dec 1999 16:57:30 -0700 Subject: How do i get output from pope3 while process is running? Message-ID: <384858EA.A9C9D2B7@fc.hp.com> 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: for line in proc.fromchild.readlines(): 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 From fredrik at pythonware.com Thu Dec 23 07:07:34 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 23 Dec 1999 13:07:34 +0100 Subject: Next Version 1.6 or 2.0 References: <38620257.6DD1B4@gmx.de> Message-ID: <00d701bf4d3e$4d2c6750$f29b12c2@secret.pythonware.com> stephane wrote: > I have only one little question: > > -will the next Python version be 1.6 or 2.0?? 1.6 > -at what time will it appear some time next year... From kuncej at mail.conservation.state.mo.us Thu Dec 16 10:38:49 1999 From: kuncej at mail.conservation.state.mo.us (Jeff Kunce) Date: Thu, 16 Dec 1999 09:38:49 -0600 Subject: Control chars and special chars References: <3858EA4E.37666179@bibsyst.no> Message-ID: > 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? You can make your own table: for i in range(255): print i, chr(i) Be warned that different fonts and character sets may produce different results --Jeff From lellinghaus at bellsouthips.com Thu Dec 30 15:45:13 1999 From: lellinghaus at bellsouthips.com (Lance Ellinghaus) Date: Thu, 30 Dec 1999 15:45:13 -0500 (EST) Subject: Radius module Message-ID: <15337897.1989@bellsouthips.com> Has anyone created a module to talk to a radius server for user validation? Thanks! Lance Ellinghaus -- Lance Ellinghaus From kc5tja at garnet.armored.net Sat Dec 4 22:45:16 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 5 Dec 1999 03:45:16 GMT Subject: how to get methods from COM objects References: Message-ID: In article , Jeffrey Kunce wrote: >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"! I am willing to assist in this. Come December 18th or so, we should have a cable modem setup. My box runs Zope, and I'd be willing to set up a few permissions to let people develop the site with. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From skip at mojam.com Mon Dec 13 16:49:40 1999 From: skip at mojam.com (Skip Montanaro) Date: Mon, 13 Dec 1999 15:49:40 -0600 (CST) Subject: Parsing strings from files. In-Reply-To: <19991213222349.A4593@stopcontact.palga.uucp> References: <19991213222349.A4593@stopcontact.palga.uucp> Message-ID: <14421.27124.845888.861314@dolphin.mojam.com> Gerrit> I want to parse the string literals from a file, so I want to Gerrit> get a dict like this: Gerrit> { Gerrit> 'foo': 'this is an easy-to-parse string', Gerrit> 'bar': 'this string, containing ", \' and newlines like\n\n\nthis, is a little harder to parse', Gerrit> 'foobar': 'this "\'string\'" is \'\'\'hard to parse' Gerrit> } Gerrit, Have you looked at the execfile builtin function? Given your sample input (in file strs.py), after executing dict1 = {} dict2 = {} execfile("strs.py", dict1, dict2) dict2 is { 'foo': 'this is an easy-to-parse string', 'foobar': 'this "\'string\'" is \'\'\'hard to parse', 'bar': 'this string, containing ", \' and newlines like\012\012\012this, is a little harder to parse' } Of course, there are the attendant security risks to be aware of (but see the rexec module). 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 Thu Dec 9 22:28:13 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 09 Dec 1999 20:28:13 -0700 Subject: What do we call ourselves? Message-ID: <3850734D.FD1D7A2C@callware.com> Hi All-- There's been some discussion over the last couple of years over the matter of how to refer to those who write Python for love, money or the greater glory of Monty. I have always favored Pythonista, because of its "attacking from the bushes" flavor ("nobody expects the Spanish Inquisition"), but others have offered Pythoneer, Pythonist, and several others which I cannot now remember. This evening, however, I was struck by a thought (our cat Harley is occasionally "struck by a thought," too, rather visibly--her eyes go blank, her ears go straight up, and she stares off into space with her mouth slightly open). I seemed to remember something from the middle Harry Potter book, _Harry Potter and the Chamber of Secrets_. I dug it out from underneath several occupation layers, and leafed through it. Ah, yes. There it is: page 194. "...the snake, instead of vanishing, flew ten feet into the air and fell back to the floor with a loud smack. Enraged, hissing furiously, it slithered straight toward Justin Finch-Fletchley and raised itself again, fangs exposed, poised to strike. "Harry wasn't sure what made him do it. He wasn't even aware of deciding to do it. All he knew was that his legs were carrying him forward as though he was on casters and that he had shouted stupidly at the snake, "Leave him alone!" And miraculously--inexplicably--the snake slumped to the floor, docile as a thick, black garden hose, its eyes now on Harry. Harry felt the fear drain out of him. He knew the snake wouldn't attack anyone now, though how he knew it, he couldn't have explained. ... "[Ron and Hermione] pushed Harry into and armchair and said, 'You're a Parselmouth. Why didn't you tell us?' "'I'm a what?' said Harry. "'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! -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 tomaz.ficko at agroruse.si Thu Dec 9 06:40:23 1999 From: tomaz.ficko at agroruse.si (Tomaz Ficko) Date: Thu, 9 Dec 1999 12:40:23 +0100 Subject: Copying files to file server Message-ID: I want to open a connection to a file server (Windows NT) from Python script and copy a file to it. I'm using Windows 95 and Python 1.5.2. I tried with win32wnet module but it didn't work. Any suggestions? Tom From paul at prescod.net Tue Dec 28 03:38:24 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 28 Dec 1999 03:38:24 -0500 Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> <19991227235513.A917@Ridcully.home> Message-ID: <38687700.903B3BF3@prescod.net> Malcolm Tredinnick wrote: > > Any changes of either of these pieces of syntax at this point would break > almost any script in existence. True, but Python 2 is supposed to be designed to break (at least some) scripts. :) It isn't clear how many. But Python 2 is going to have other backwards-incompatible changes. > The only way to accomodate them would be to > introduce redundant keywords, which would be ... well ... just evil (or > perl -- I always get those two muddled up). :-) I don't think that it is a big deal if there is a "proper" syntax and a "deprecated" syntax. The problem with Perl is it presents all choices as being equally "correct" so different programmers have no guidance as to the right one. Paul Prescod From sp00fD at yahoo.com Tue Dec 21 13:32:50 1999 From: sp00fD at yahoo.com (sp00fD) Date: Tue, 21 Dec 1999 18:32:50 GMT Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <83lnq7$c9d$1@news1.tele.dk> Message-ID: <83oh4i$4k8$1@nnrp1.deja.com> In article <83lnq7$c9d$1 at news1.tele.dk>, "Jesper Hertel" wrote: > I hope this was a joke. That kind of constructions is impossible to read for > other programmers, making the program hard to maintain. > How is this impossible to read? a ? b : c if a then b else c ? Sent via Deja.com http://www.deja.com/ Before you buy. From prestonlanders at my-deja.com Mon Dec 20 16:47:06 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Mon, 20 Dec 1999 21:47:06 GMT Subject: Equivalent to (a ? b : c) ? References: <83lgkq$2q$1@nnrp1.deja.com> Message-ID: <83m84p$i1b$1@nnrp1.deja.com> In article <83lgkq$2q$1 at nnrp1.deja.com>, malraux at my-deja.com wrote: > 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? Hey, Please correct me if I'm wrong, but there is no ternary conditional operator in Python. It would be kinda nice, but it's just syntactic sugar. Of course, there's nothing wrong with: if a: b else: c Though this works too: a and c or b cheers, ---Preston Sent via Deja.com http://www.deja.com/ Before you buy. From pinard at IRO.UMontreal.CA Fri Dec 3 15:13:46 1999 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 03 Dec 1999 15:13:46 -0500 Subject: Be gentle with me.... In-Reply-To: Preston Landers's message of "Fri, 03 Dec 1999 16:19:04 GMT" References: <828n3e$8kp$1@nnrp1.deja.com> <828qhj$bb1$1@nnrp1.deja.com> Message-ID: Preston Landers writes: > When I first came to Python from a C background, more than a year ago, > I was also thrown off by indentation being syntactically significant. Maybe the following might amuse some of you... I (unsucessfully) tried a few times to convince Richard Stallman, in the past years, that GNU C might be usefully augmented with an option in which it would warn if a `}' was not on the very same line as the corresponding '{', or else, was not on the very same column that the column of the leftmost non-white character on the line containing the corresponding `{'. (Of course, I also had other similar looking rules for many other cases, as most of us know that C is a bit more than only a question of braces :-). The basics of my idea was that it is a real big shame to not find a better use for all the redundancy which exists in the indentation. I thought that GNU C was progressive enough to introduce that just-apparently-revolutionary, yet still rather-simple-and-easily-implemented idea. Could have been a hit! 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! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From dfan at harmonixmusic.com Tue Dec 21 09:28:38 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 21 Dec 1999 09:28:38 -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: | Dan Schmidt writes: | | > mlh at vier.idi.ntnu.no (Magnus L. Hetland) writes: | [...] | > 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] | | It's not that bad :) | | However - it has a temporality to it that I don't think fits the | sentence... I think "for all xs in X and ys in Y, do something" | is quite standard english, yet "for all xs in X while ys in Y, do | something" sounds a bit silly... But you might actually say "for all x in X, while at the same time y traverses over Y". In fact, the syntax for it actually popped into my head (from English usage), before I noticed that it could actually work, since 'while' is a reserved word. -- Dan Schmidt | http://www.dfan.org From aahz at netcom.com Wed Dec 29 14:15:24 1999 From: aahz at netcom.com (Aahz Maruch) Date: 29 Dec 1999 19:15:24 GMT Subject: Super Tuples References: <386A1037.C6D458B3@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <84dh0i$17io$1@nntp6.u.washington.edu> Message-ID: <84dmkc$plh$1@nntp9.atl.mindspring.net> In article <84dh0i$17io$1 at nntp6.u.washington.edu>, Donn Cave wrote: > >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. There's one other problem with tuples: they are immutable, therefore they can't mimic C structs. It probably is the most Pythonic to come up with a good idiom for classes or dicts that can easily mimic structs; I usually use dicts for that purpose, myself. -- --- 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 clarence at beach.silcom.com Wed Dec 22 18:26:40 1999 From: clarence at beach.silcom.com (Clarence Gardner) Date: Wed, 22 Dec 1999 23:26:40 GMT Subject: Bug in python startup on linux? [Was: Wrong Executable? or something] References: <87d7s05upg.fsf@baal.winnegan.de> Message-ID: Bernhard Herzog wrote: : Siggy Brentrup writes: :> Clarence Gardner writes: :> I did a little more testing and found out that results depend on your :> PATH setting. :> : Python tries to initialize sys.path based on the location of the python : executable. If argv[0] contains no '/' python searches $PATH for the : executable and starts from there. : On Linux it seems that a program called by the #! mechanism only gets : the basename of the file in argv[0], i.e. there's no '/' and therefore : python searches through the directories in $PATH, so it might get the : wrong one. : I'm not sure whether this is to be considered a bug in Linux or Python, : but Python could perhaps work around this on a Linux system by using : /proc/self/exe (which is a symbolic link to the executable of the : process) as reference when it searches $PATH for the file. : -- : Bernhard Herzog | Sketch, a drawing program for Unix : herzog at online.de | http://sketch.sourceforge.net/ Thank you! I'm much less confused now. Bad Linux; bad! -- Clarence Gardner Software Engineer NetLojix Communications NASDAQ:NETX clarence at netlojix.com From anders.eriksson at morateknikutveckling.se Mon Dec 20 05:42:47 1999 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Mon, 20 Dec 1999 11:42:47 +0100 Subject: Very Stupid Newbie Question Regarding Databases References: <83jr9s$tco$1@nnrp1.deja.com> Message-ID: On Sun, 19 Dec 1999 23:55:41 GMT, 55wgm_guy at my-deja.com wrote: > >Name: >Email: >Phone Number: >(etc) > >Im starting to look at the gdbm, dbm, and anydbm modules. However, it >seems to me that to store records in the above format would require >some sort of key to retrieve a particular record. How can the *dbm >modules do this? Not really sure what the question is but ;-) And please consider that I'm also a beginner! As the key you could eigther use one of the fields that are unique (e.g email) or create an unique key for each record, e.g. record number (NB! the key must be a string). It all depends on what you want to do. I have gotten the impression that the *dbm modules should not be used directly(?) You would be better off using the shelve module // Anders From gmcm at hypernet.com Fri Dec 3 08:18:33 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 3 Dec 1999 08:18:33 -0500 Subject: Environment variables In-Reply-To: Message-ID: <1267895477-5653035@hypernet.com> Kevin Cazabon on making changes to environment vars: > 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. Actually, they do. Just not in already running cmd.exes. You can use os.putenv to affect the environment of the cmd.exe you're running in, but there's nothing you can do about other already existing ones. - Gordon From kc5tja at garnet.armored.net Tue Dec 7 22:14:33 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 8 Dec 1999 03:14:33 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: >Does every Forth word have a fixed number of arguments? That seems >like the only way it could work. Some Forth words can accept variable number of arguments (the word[s] which convert a number on the stack into a printable number are an example of such words). In addition, some words can return multiple results as well (FIND comes to mind). Yet, combined with colon definitions, immediate words, and the EVALUATE word, Forth's execution model can rival, and in some cases, exceed, Lisp's own macro subsystem. >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.... :) Lisp and Forth are indeed diabolical opposites. What I find ironic is that it is the opposite nature of the two languages which makes them immensely similar to each other. For instance, because Forth environments generally don't have garbage collection (some do have conservative collectors), you tend to write your code to be more memory concious(sp?) than you would under Lisp. What takes almost no memory to do in Forth would take up triple the memory normally used in Lisp, and vice versa. Trivia: The creator of Forth studied under the creator of Lisp, and are reportedly very good friends. I also find it interesting to see the people in comp.lang.lisp throw their noses up at almost any language on the planet. Yet, when one person says they're familiar with Forth, they welcome them with warm hearts. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From skaller at maxtal.com.au Sun Dec 12 15:37:36 1999 From: skaller at maxtal.com.au (skaller) Date: Mon, 13 Dec 1999 07:37:36 +1100 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> Message-ID: <38540790.98868144@maxtal.com.au> "Jesse D. Sightler" wrote: > > BTW, the same page has a rant about how 'old' most languages are in terms of > > their underlying technology, for example, C++ and Java use 20+ year old > > techniques. I quote again: > > > > I'd like to end this update with a rant, based on the observation that > > mainstream programming languages, C++ and Java, are dismally far behind the > > state-of-the-art. The theoretical underpinnings of these languages were all > > set in stone in the late 1960's, before I was even born! > > > > Compare this state of affairs too advances in microprocessor technology, > > where time-to-market is under 5 years; or games and 3D hardware, where there > > is less than 24 months of lag between "great new idea" and "product on store > > shelves". > > > > Yet with programming languages, the lag in widespread adoption of new > > theory-level advances seems to be 20-30 years. > > Would Python fall under the same critique? > > No. But then again neither would C++ or Java. > > Processors are based on silicon, which is based on atoms, which have > been around forever... therefore all processor technology could have > just as easily been available in the year 6000 B.C. Great logic > there... if you're an idiot. :) I happen to agree with what the original author is saying. There is a real issue here: why do people go for the latest hardware technology, but not the latest software, particularly programming languages?? At least in part, the answer is COMPATIBILITY. And not just with other software, but with built in mind sets -- human knowledge. For example, there is suitable theory, and much experimental practice, on technology which obsoletes object orientation. But very few non-academics know anything about it. Indeed, very few acedemics know anything about it. 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. There is a high performance, pragmatic, programming language whose engine and theoretical underpinnings are based on it (caml: Categorical Abstract Machine Language; ocaml: with objects). My Viper interpreter for Python is written in Ocaml. Why aren't people using it, instead of C, which is totally archaic? Because C is available everywhere and used to interface with the operating system; and modern programming is all about interfacing and resource managements and NOT computation (i.e. numerical calculations). Fortran -- it's still the fastest specialist language for numerical computation. C++ -- because it is more advanced than C, but still C compatible. One may wonder, why are people using Java? Well, it is basically a version of C/C++ which provides mind set compatibility though not physical compatibility, and overcoming _that_ hurdle required a monumental campaign from a seriously scared company, which had enough foresight to see its market position (based on work stations) was doomed, and also spot a new niche (Internet programming). So now we come to Python. In fact, it is based on archaic technology, and Guido is pushing to make it even more so. However, the _implementation_ technology is more modern. Why is it increasingly popular? Part of the answer is: it is archaic. It interfaces well to C -- archaic, but pragmatic. It uses a simplistic statement based grammar, and lacks proper scoping: archaic, but familiar. But it _also_ avoids some of the pitfalls of older languages: it has a clean syntax, for example, and a system of modules and packages, which is somewhat more modern, and the design supports pretence of object orientation, also slightly more modern. There is an important point here. Languages based on _modern_ theory are still experimental. Python on the other hand is _mature_: there is nothing new in it, it is just an excellent synthesis of the best mature technology. And this is a significant achievement, well recognized on comp.lang.python. There's an excellent reason to use a mature product: problems you have doing so have usually arisen before, and there is a sensible solution. Omissions and bugs from earlier versions have been fixed. The limitations of the system are known. The point probably is: software is much more complex than hardware. It therefore takes much longer for ideas to become 'industrial strength' products. This is why, for example, CPython still uses reference counting instead of a garbage collector. (And collectors have been around since LISP!) This may change in Python 2 -- both JPython and my Viper system use collectors, and together they should demonstrate that collectors are a practical choice for CPython too. How mature is Python? Well, in a few days there will be THREE implementations, which is indicative of a very strong language. In a few years, it might get Standardised, which is often indicative that the vestiges of experimental design are gone (C++ was an exception to this). Just look at Unix: archaic. Yet the fastest growing OS around -- Linux -- is based on the same archaic design. More modern systems (such as NeXt) have failed. [Windows is an exception -- but the modern design is hidden under a compatibility layer] It's very unlikely there will be any change in 'local' operating software until it is truly hidden under a layer of 'internet' software, when compatibility becomes less of an issue, or when parallel computing becomes important enough that a new paradigm is essential. -- 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 paul at prescod.net Tue Dec 28 03:38:28 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 28 Dec 1999 03:38:28 -0500 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <14439.35987.402193.17280@anthem.cnri.reston.va.us> Message-ID: <38687704.829BCC58@prescod.net> "Barry A. Warsaw" wrote: > > Neat idea, but what about > > >>> second, hour, minute = (hour=24, minute=0, second=0) > >>> print hour It's the same as: date =( 24, 0, 0 ) second, hour, minute = date The only difference is that in YOUR example it is easier to find your bug. > Even though I think this should print `0', it does look weird. The weirdness is your best friend. Paul Prescod From calishar at *NOSPAM*home.com Mon Dec 6 17:07:52 1999 From: calishar at *NOSPAM*home.com (Calishar) Date: Mon, 06 Dec 1999 22:07:52 GMT Subject: Struct and windll question (please help) Message-ID: Hi folks, Since i havent received a successful answer yet, I am going to repost the question, with examples. Sorry about the length, but I am starting to lose my hair over this, it seems like it should be simple, but I think my brain is teasing me. I am trying to call the infozip unzip32.dll (on a windows 95 system at the moment, but eventually on a winNT system too) in order to unzip a pkzip file (not gzip). Zlib doesn't seem to understand this type of file, so I am having to go outside standard python stuff. The calldll module has a function (call_foreign_function(address, input_args_format, result_args_format, argument_tuple)) which should be able to do what I need. What I am having problems with is constructing the format strings and tuple. The best effort I have had so far had an interesting error message when it failed----- expected impossible. Could someone who truly understands this better than I do (not hard at the moment, no brain cells left) please post a sample code snippet that I can work from? The dll function I am calling has the following definition: Wiz_SingleEntryUnzip(int ifnc, char **ifnv, int xfnc, char **xfnv, LPDCL lpDCL, LPUSERFUNCTIONS lpUserFunc) where ifnv and xfnv can be Null. (I think the format code should be 'i255si255s??' (no idea for the structs) or (iPiP??) using the struct module codes. Or should I be using the codes from PyArg_ParseTuple? I am creating the two structs using struct.pack at the moment, is this right? The LPDCL structure has the following definition typedef struct { int ExtractOnlyNewer; = true if you are to extract only newer int SpaceToUnderscore; = true if convert space to underscore int PromptToOverwrite; = true if prompt to overwrite is wanted int fQuiet; = quiet flag. 1 = few messages, 2 = no messages, 0 = all messages int ncflag = write to stdout if true int ntflag = test zip file int nvflag = verbose listing int nUflag = "update" (extract only newer/new files) int nzflag = display zip file comment int ndflag = all args are files/dir to be extracted int noflag = true if you are to always over-write files, false if not int naflag = do end-of-line translation int nZIflag; = get zip info if true int C_flag; = be case insensitive if TRUE int fPrivilege = 1 => restore Acl's, 2 => Use privileges LPSTR lpszZipFN = zip file name LPSTR lpszExtractDir = Directory to extract to. This should be NULL if you are extracting to the current directory. } DCL, far * LPDCL; and the LPUSERFUNCTIONS struct has this defintion: typedef unsigned short ush; typedef int (WINAPI DLLPRNT) (LPSTR, unsigned long); typedef int (WINAPI DLLPASSWORD) (LPSTR, int, LPCSTR, LPCSTR); typedef int (WINAPI DLLSERVICE) (LPSTR, unsigned long); typedef void (WINAPI DLLSND) (void); typedef int (WINAPI DLLREPLACE)(LPSTR); typedef void (WINAPI DLLMESSAGE)(unsigned long, unsigned long, unsigned, unsigned, unsigned, unsigned, unsigned, unsigned, char, LPSTR, LPSTR, unsigned long, char); Structure USERFUNCTIONS typedef struct { DLLPRNT *print; = a pointer to the application's print routine. DLLSND *sound; = a pointer to the application's sound routine. This can be NULL if your application doesn't use sound. DLLREPLACE *replace = a pointer to the application's replace routine. DLLPASSWORD *password = a pointer to the application's password routine. DLLMESSAGE *SendApplicationMessage = a pointer to the application's routine for displaying information about specific files in the archive. Used for listing the contents of an archive. DLLSERVICE *ServCallBk = Callback function designed to be used for allowing the application to process Windows messages, or canceling the operation, as well as giving the option of a progress indicator. If this function returns a non-zero value, then it will terminate what it is doing. It provides the application with the name of the name of the archive member it has just processed, as well as it's original size. NOTE: The values below are filled in only when listing the contents of an archive. unsigned long TotalSizeComp = value to be filled in by the dll for the compressed total size of the archive. Note this value does not include the size of the archive header and central directory list. unsigned long TotalSize = value to be filled in by the dll for the total size of all files in the archive. int CompFactor = value to be filled in by the dll for the overall compression factor. This could actually be computed from the other values, but it is available. unsigned int NumMembers = total number of files in the archive. WORD cchComment; = flag to be set if archive has a comment } USERFUNCTIONS, far * LPUSERFUNCTIONS; Thanks for reading this far Calishar From wlfraed at ix.netcom.com Thu Dec 2 23:23:18 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Thu, 02 Dec 1999 20:23:18 -0800 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" declaimed the following in comp.lang.python: > > Only for FORTRAN programmers. Python and C programmers, being zero-based, > get to celebrate a year earlier. I have one question... How was that imaginary year the C programmers lived between 1BC and AD1? -- > ============================================================== < > 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 aahz at netcom.com Tue Dec 28 10:36:12 1999 From: aahz at netcom.com (Aahz Maruch) Date: 28 Dec 1999 15:36:12 GMT Subject: Patch: httplib.py default timeout References: <840anc$9j8$1@nntp8.atl.mindspring.net> <14440.48375.677822.934000@dolphin.mojam.com> Message-ID: <84aldc$pdf$1@nntp9.atl.mindspring.net> In article <14440.48375.677822.934000 at dolphin.mojam.com>, Skip Montanaro wrote: > >I understand the motivation for the timeout, but shouldn't the default be to >not timeout at all: > > defaultTimeout = 0 # wait forever > ... > def connect(self, host, port = 0, timeout = defaultTimeout): > >? Although timeouts are very useful, they are hardly the norm. Your change >would break code that nominally works now because exceptions could get >raised where none are expected. Nope. Any code that currently uses httplib *HAS* to catch exceptions or break when the actual socket connect call fails (you'll note that the socket options get set *after* self.sock.connect()). See my other posts in this thread for more info. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 4 days and counting! From grisha at ispol.com Mon Dec 13 17:59:33 1999 From: grisha at ispol.com (Gregory Trubetskoy) Date: Mon, 13 Dec 1999 17:59:33 -0500 Subject: PyApache In-Reply-To: <80udu9$70$1@oceanite.cybercable.fr> References: <80p6p4$or5$1@oceanite.cybercable.fr> <80p9uj$43f$1@oceanite.cybercable.fr> <80u49o$m48$1@nnrp1.deja.com> <80udu9$70$1@oceanite.cybercable.fr> Message-ID: I do get quite a bit of e-mails regarding CGI support. Some people want the CGI support, and some people assume that a "print" statement will send output to the socket and ask me "why doesn't it work?" While "printing" output seems like a very simple way to go, you loose out on the ability to subclass and modify output in your subclass... Httpdpay was never meant as a way to speed-up or mimic CGI, it was meant to be a superior alternative to CGI programming, which (CGI, that is), IMHO is just lame. This is not to say that httpdapy is not powerful enough to support CGI, I just tried to leave the implementation to the imagination of the end user. I even left subtle hints in the source, for example the undocumented build_cgi_env() function... ;) Well, since some people have a love affair with CGI and insist on things being handed to them on a silver platter - here is an example of how you could run CGI scripts in the manner described below ("persistent"): http://www.ispol.com/home/grisha/httpdapy/new/extra/cgi_handler.py Enjoy. Note - I haven't tested this thoroughly. P.S. I am not at all sure what you mean by "It has to run under NT and Linux". This has nothing to do with CGI. All you need to be able to do is to compile Apache+httpdapy+Python on NT, which, last time I tried (over a year ago) worked just fine. P.P.S PyApache doesn't do this anymore, it will reset the interpreter every time. Keeping the interpreter around in a CGI environment is a can of worms. -- Gregory (Grisha) Trubetskoy grisha at ispol.com On Wed, 17 Nov 1999, Florent Rami?re wrote: > Hi ! > > Well, i have head about httpdapy, but i have read the documentation, and > it seems that the code has to be modified. This solution can not be used > for my needs. (It has to run under NT and Linux !) > > I may have missed something with httpdapy, did I ? > > Well, PyApache certainly does such a job, but I cannot find how ! > > such a shame, > > Florent. > > wrote in message news:80u49o$m48$1 at nnrp1.deja.com... > > > > > I have the same problem ! > > > Does anyone found a solution for this problem, or does pyApache > > > absolutly do not handle such a functionnality (maybe) ? > > > > > > Florent. > > > > > > leon wrote in message > > > news:80p6p4$or5$1 at oceanite.cybercable.fr... > > > > Hi, > > > > > > > > I'm using PyApache, and I would like to know if it's possible to > > make > > > > 'persistent' modules. In fact I want to do only one "import file.py" > > like > > > in > > > > mod_perl, instead of loading this file each time the script is > > parsed. > > > > I'm using httpdapy (http://www.ispol.com/home/grisha/httpdapy) and it > > only loads my modules once -unless, of course, i modify them. > > > > > > > > Sent via Deja.com http://www.deja.com/ > > Before you buy. > > > From effbot at pythonware.com Wed Dec 1 04:04:12 1999 From: effbot at pythonware.com (eff-bot) Date: Wed, 1 Dec 1999 10:04:12 +0100 Subject: '==' vs. 'is' behavior References: <382C2C6A.64A8F2C2@theriver.com> <14380.12036.197083.409565@weyr.cnri.reston.va.us> <8E7F86267duncanrcpcouk@news.rmplc.co.uk> <015301bf3b0a$685a3fc0$f29b12c2@secret.pythonware.com> Message-ID: <00b001bf3bdb$0acfa440$f29b12c2@secret.pythonware.com> Fran?ois Pinard wrote: > What is "the eff-bot"? I've read about "eff-bot" and "tim-bot" a few > times by now, and thought it was some kind of internal joke in the group, > but begin to think there might be some substance behind the expression! :-) http://www.deja.com/getdoc.xp?AN=238330113 ... Think about it -- when's the last time you spent 20 hours straight debugging your son/wife/friend/neighbor/dog/fer- ret/snake? And they *still* fell over anyway? ... http://www.deja.com/getdoc.xp?AN=336718323 ... So how many of you have ever actually met "Tim Peters"? I know Guido claims to have, but I've seen no proof. ... http://www.deja.com/getdoc.xp?AN=358532977 ... the last person to try it was found strangled by his phone cord with his PC's screen saver flashing "I'm sorry Dave, I can't let you do that" ... From warlock at eskimo.com Mon Dec 6 16:53:30 1999 From: warlock at eskimo.com (Jim Richardson) Date: Mon, 6 Dec 1999 13:53:30 -0800 Subject: indentation References: <14408.13481.279705.753821@weyr.cnri.reston.va.us> <829dlk$12p$1@news.wrc.xerox.com> Message-ID: On 4 Dec 1999 01:51:07 GMT, William Tanksley, in the persona of , brought forth the following words...: >On 3 Dec 1999 21:45:24 GMT, Mark Jackson wrote: >>"Fred L. Drake, Jr." writes: > >>> 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. > >Please may I forget it? Whatever fortrans other failings, HP fortran made automating tests with HP equip extremely easy to do. Being the lazy sort, I appreciated that :) -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From bwarsaw at python.org Mon Dec 27 18:56:03 1999 From: bwarsaw at python.org (Barry Warsaw) Date: Mon, 27 Dec 1999 18:56:03 -0500 (EST) Subject: IPC8 Developers Day Message-ID: <14439.64659.471458.700013@anthem.cnri.reston.va.us> The schedule for Developers' Day at IPC8 has been posted to http://www.python.org/workshops/2000-01/devday.html I will hopefully be getting position papers from folks soon after the new year, so please check back if you want to get a head start on the topics. There will be a little bit of time in the morning session for SIG updates, so if you're a SIG champion, please email me if you'd like to give a progress report. Depending on how many people sign up for the morning session, we may have time for other announcements or updates as well. Again, let me know if you'd like to reserve a slot (on the order of 5 - 10 minutes). -Barry From simon at george.maths.unsw.edu.au Wed Dec 1 20:15:59 1999 From: simon at george.maths.unsw.edu.au (Simon Evans) Date: 2 Dec 1999 01:15:59 GMT Subject: Plotting a single pixel (possible newbie question) Message-ID: <824h8f$nh$1@mirv.unsw.edu.au> Thanks to Helmut M. and Fredrik L. for the useful replies. I'll do some more playing and see what I can come up with. Now off to download PIL... Helmut Michels wrote: > DISLIN contains also some elementary image routines for > reading and writing pixels from and to the screen. For > example, the routine 'wpixel' writes one pixel to the screen. Also, Fredrik Lundh wrote: > assuming that you're drawing more than one pixel > per update, you can get decent results by com- > bining PIL [1] with Tkinter. > just draw the data into a PIL image memory, and > display it using Tkinter and PIL's ImageTk module. -- Simon. ================================================================= Simon Evans (simon at maths.unsw.edu.au) Physical Oceanography Group School of Mathematics, University of New South Wales, Australia. ================================================================= From mhammond at skippinet.com.au Thu Dec 9 06:14:43 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 09 Dec 1999 11:14:43 GMT Subject: Printing under Win32 References: <82nsdb$djj$1@news.hit.fi> Message-ID: Matti Johannes K?rki wrote in message <82nsdb$djj$1 at news.hit.fi>... > >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. Check out win32print in build 127 of the Python for Windows extensions. Pythonwin also knows how to print, but that may not be light-weight enough... Mark. From: Annapoorna Nayak Pangal Newsgroups: comp.lang.python Subject: Newbie -- pyd files ?? Date: Thu, 09 Dec 1999 16:30:18 +0800 Organization: Deja.com - Before you buy Lines: 39 Message-ID: <3.0.32.19991209163018.00729338 at mailhost.krdl.org.sg> NNTP-Posting-Host: postnews.dejanews.com Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Sender: annapn at mailhost.krdl.org.sg X-Mailer: Windows Eudora Pro Version 3.0 (32) To: comp.lang.python at list.deja.com X-DejaID: _iMZ437TTH6ZeIKD2pJ4Bug= Path: news!uunet!ffx.uu.net!newsfeed.mathworks.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail Xref: news comp.lang.python:77950 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 Hi ! I am a newbie to python. Want to know more on python script files having extension "pyd" . Actually, my problem is : I downloaded a complete python module from net and trying to execute it , but gives the error ---------------------------------------------------------------- from _LinearAlgebraModule import MakeMatrix, Add, Subtract, Multiply, Interp olate, GetAngleBetween2dVectors ImportError: cannot import name GetAngleBetween2dVectors ------------------------------------------------------------------ I donot find any file by name "_LinearAlgebraModule.py" on my system but there is a file by name "_LinearAlgebraModule.pyd" ! So, would like to know more on this "pyd" files. Any help would be greatly appreciated . Thanks in advance. Rgds, Annapoorna Sent via Deja.com http://www.deja.com/ Before you buy. From Alex.Martelli at think3.com Tue Dec 14 07:28:39 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Tue, 14 Dec 1999 13:28:39 +0100 Subject: Lists of lists over COM, how? Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D30@pces.cadlab.it> Martin writes: > I'd like to return a set of database records to Python in a single > variable > from a COM object in C++ and had hoped I could use a two-dimensional > VARIANT > array for this. Looking through the SafeArray* functions in the WIN API > they > only allow arrays of a single basic type. I had hoped that a list of lists > Yep, but the basic type can be VARIANT -- and, inside a VARIANT, among other things, you can stuff other (so-called SAFE-:-)ARRAYs, so you can do complicated stuff if you wish:-). But, in fact...: > with mixed data types would correspond to some variant array (since there > are both numbers and strings in these records). Anyone knows? > A VARIANT can easily hold either a string (BSTR) or number (any of several types thereof), so a SAFEARRAY of VARIANT is fine to hold such heterogeneous info as a database record. Alex From kuncej at mail.conservation.state.mo.us Wed Dec 8 11:24:07 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Wed, 08 Dec 1999 10:24:07 -0600 Subject: Linux.Com Message-ID: [Al Christians] > Python is running a healthy 4th in the Linux.Com scripting > languages poll. [Barry A. Warsaw] > Looks like your message has rallied the troops! It's now running > a distant second behind the 4-letter word of scripting languages :) > > Perl 42.65% (633) > Python 16.31% (242) > PHP 15.84% (235) [Tim Peters] >Take heart: Deeper analysis of the data demonstrates that the Python votes >are of much higher quality. And maybe, Python votes are more honest? ~10 hours later: PHP 59.90 % (3306) Perl 20.87 % (1152) Scripting languages suck 6.99 % (386) Python 6.34 % (350) It looks like PHP is good for writing a form-submission-bot --Jeff From alex at magenta.com Tue Dec 7 10:17:07 1999 From: alex at magenta.com (Alex Martelli) Date: Tue, 7 Dec 1999 16:17:07 +0100 Subject: sites offering free webspace & Python scripting...? Message-ID: <82j8cc$qju$1@serv1.iunet.it> I've looked in the FAQ's, but couldn't find this info...: are there sites offering free web space, _and_ the ability for the site maintainer to write Python server-side scripts for the web pages? (CGI would suffice, although, no doubt, faster ways would be preferable). I know of quite a few suppliers of free webspace that offer no scripting whatsoever, and a few that allow Perl scripting, but I'd really like to do my scripting in Python instead (for reasons I'm sure I don't have to explain on this newsgroup!-). Thanks in advance for any response... my newsfeed appears to be very flaky these days, so e-mail Cc's of any posted responses would be highly appreciated. Alex From mfletch at tpresence.com Sun Dec 12 18:31:18 1999 From: mfletch at tpresence.com (Mike Fletcher) Date: Sun, 12 Dec 1999 18:31:18 -0500 Subject: Dot product? Message-ID: (Prying dang tongue from cheek for a few seconds, blighter keeps getting caught in there)... The rebelliousness was related to the use of map and reduce, both of which are considered "evil"[1] by the powers that be (PTB). Those same PTB's have expressed interest in the list comprehensions. I was merely hoping to prevent middle-of-the-night visits by the Python Purity League (PPL) in retribution for putting forth methods of computation based on these satanic devices. In reality, I have no expectation of seeing map/reduce disappear in 1.6. I suppose the PTBs might declare a jihad and demand that all Loyal Followers of the Python (LFOTP) mount Arabian text editors and sweep the disbelieving functions from all code for version 2.0, but the Greater Ethos of Python (GEOP) tends to suggest not crippling massive quantities of code for the sake of ideological purity. The silliness was "this is a simple one-line function which slows us down considerably." (It didn't even occur to me to wrap it into a function until I'd already copied the text into the message and realised you'd asked for it as such.) So I felt silly incurring an extra function call just to re-package the arguments to map. Of course, the true LFOTP will call down fire upon my head for using an obscure-and-little-known feature instead of a readily understood function call. We Demons of Easy to Write but Speedy Computation (DOETWBSC) often offend the GEOP as we slavishly eke the golden elixir* with our evil inline expansions, maps, and algorithmic impurity. The DOETWBSC shall not cease our fight, the PPL cannot continue its reign of terror, nor should the LFOTP stand aside as our fledgling brotherhood is trampled beneath the heel of the PTB in contradiction to the very core of the GEOP. Rage against the slowness of the night! [1] unclear/non-intuitive, as declared by the council at Pythonica [2] CPU cycles, [Speedicus Markupicus Ch2v35] -----Original Message----- From: David C. Ullrich [mailto:ullrich at math.okstate.edu] Sent: Sunday, December 12, 1999 2:52 PM To: python-list at python.org Subject: Re: Dot product? ... > 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.(???) ... 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...) ... From timd at macquarie.com.au Wed Dec 22 18:12:09 1999 From: timd at macquarie.com.au (Timothy Docker) Date: 23 Dec 1999 10:12:09 +1100 Subject: Anyone else making music with python? References: <386115AB.A0DD3F6@angelfire.com> Message-ID: Paul Winkler writes: > 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... Some time ago whilst working on a museum project, I used the python midi modules to algorithmically generate some midi files, which I subsequently converted to audio files with timidity. It worked pretty well, but qualified as sound effects more than "music". Tim From thantos at chancel.org Thu Dec 23 03:01:06 1999 From: thantos at chancel.org (Alexander Williams) Date: Thu, 23 Dec 1999 08:01:06 GMT Subject: List comprehensions References: Message-ID: On Thu, 23 Dec 1999 17:44:38 +1100, Jesse Sweeney wrote: >which leaves xs as [30, 19, 5], not [30, 19, 31] as Albert was suggesting. >Someone who's actually used the patch might correct me, but I'd be surprised if >the scoping rules were different to the rules for for loops. I haven't installed it either; waiting until The Timbot(tm) has had his turn at brutalizing it, but I think it would be A Bad Thing(tm) for LC's /not/ to be treated like a local function with their own scope; while this edges into lexical closure territory, the alternative leads to weird unintuitive things (at least in my view). -- 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 jwbaxter at olympus.net Wed Dec 8 23:54:46 1999 From: jwbaxter at olympus.net (John W. Baxter) Date: Wed, 08 Dec 1999 20:54:46 -0800 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: In article <82mjag$7oh$1 at nntp2.atl.mindspring.net>, aahz at netcom.com (Aahz Maruch) wrote: > In article <14411.53378.154350.793014 at weyr.cnri.reston.va.us>, > Fred L. Drake, Jr. wrote: > >Mark Jackson writes: > >> > >> And Fortran. Don't forget Fortran. > > > > I guess I got lucky; having never learned Fortran, I don't have to > >forget it. ;-) > > 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 at the other end of the scale: I only briefly used a FORTRAN version with a number in the name: the number was II. Most of my FORTRAN was the unnumbered sort (before FORTRAN II). Source code for that (three-character identifiers) included in the comment describing one of the two subroutines: MAN CALLS DOG TO .... --John (who once refereed a basketball game with Vannevar Bush as my partner) -- John W. Baxter Port Ludlow, WA USA jwb at olympus.net From Richard.Jones at fulcrum.com.au Wed Dec 22 16:17:54 1999 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Thu, 23 Dec 1999 08:17:54 +1100 Subject: %* control characters question. In-Reply-To: Message from Gerrit Holl of 1999-Dec-22 16:53:17, <19991222165317.A11723@stopcontact.palga.uucp> Message-ID: <199912222117.IAA18178@envy.fulcrum.com.au> [Gerrit Holl] > is there a module to fetch %* control characters, like strftime does? strftime is a wrapper around the C function of the same name. > Currently, I have this code: > > s=raw_input("format: ") > string.replace(s, '%a', foo) > string.replace(s, '%b', bar) > string.replace(s, '%c', foobar) > etc. > > I also want '%4a' to work. Are there functions to parse this sort of things? Not as far as I know... Would the %(foo)s syntax help? As in: >>> "%(foo)s %(bar)s"%{'bar':'world', 'foo':'hello'} 'hello world' >>> "%(foo)s %(bar).3s"%{'bar':'world', 'foo':'hello'} 'hello wor' Perhaps using an re.sub on %a and %b? >>> import re >>> s="%a %.3b" >>> re.sub(r"%([^a-zA-Z]*)?a", r"%(foo)\1s", s) '%(foo)s %b' >>> re.sub(r"%([^a-zA-Z]*)?b", r"%(bar)\1s", _) '%(foo)s %(bar).3s' >>> _%{'bar':'world', 'foo':'hello'} 'hello wor' Richard From fdrake at acm.org Thu Dec 23 16:20:38 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 23 Dec 1999 16:20:38 -0500 (EST) Subject: __init__ keyword param for sub-class? In-Reply-To: References: <14434.30055.405044.204758@weyr.cnri.reston.va.us> <14434.32576.62080.865071@weyr.cnri.reston.va.us> Message-ID: <14434.37415.2150.108737@weyr.cnri.reston.va.us> Grant Edwards writes: > 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 Probably not too often; it's just harder to maintain, especially if your classes are large or complex. Name clashes are too easy to introduce. > it would be a good idea unless it is part of a major change > that's going to break programs anyway. Python 2.0! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From hnowak at cuci.nl Thu Dec 2 16:12:10 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Thu, 2 Dec 1999 22:12:10 +0100 Subject: SyntaxError: can't assign to function call win32com.client In-Reply-To: <823ppg$o2b$1@nnrp1.deja.com> Message-ID: <199912022114.WAA31872@dionysus.fw.cuci.nl> On 1 Dec 99, at 18:35, tiddlerdeja at my-deja.com wrote: > I'm trying to mirror this VB code (which works) with python code: > > objUser.DynamicProperty("BILLING_ADDRESS2") = "3 The Street" > > This code works in VB but in python I get the error: > > SyntaxError: can't assign to function call > > Can you tell me what syntax I need to use for python? > > Any help greatly appreciated. I don't want to have to use VB! This behavior is maybe best mimicked by using dictionaries. A simple example: class User: def __init__(self): self.DynamicProperty = {} objUser = User() objUser.DynamicProperty["blah"] = 4 objUser.DynamicProperty["foo"] = [1, 42, "hello"] print objUser.DynamicProperty["blah"] etc... I don't know much about properties in VB, but an expression like objUser.DynamicProperty("X") implies that DynamicProperty is a method of objUser, and thus a function. Assigning to it isn't possible, compare def twice(x): return 2*x twice(4) = 7 Doesn't make much sense, does it? :) Not in Python anyway. 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 paul at prescod.net Tue Dec 28 04:05:46 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 28 Dec 1999 04:05:46 -0500 Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> Message-ID: <38687D6A.D525D91F@prescod.net> 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? > In this case, minimal use of keywords is the focus. Why? Python has a lot of "extra" keywords like "and", "or", "is" "not". > >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. Paul Prescod From rjh at 3-cities.com Thu Dec 2 01:44:44 1999 From: rjh at 3-cities.com (Robert J. Harrison) Date: Wed, 01 Dec 1999 22:44:44 -0800 Subject: complexobject.c optimization error on SGI Message-ID: <3846155C.CEC8ECF9@3-cities.com> On an SGI (IRIX64 6.5, MIPSpro Compilers: Version 7.3.1m, -n32) Python-1.5.2/Objects/complexobject.c does not compile correctly with optimization. The problem shows up as a bus error in PyComplex_ImagAsDouble when importing Numeric Python. All works fine when this one file is compiled with -O0 (-O1 and higher fail). Since we use the complex arithmetic it would be nice to compile it with optimization. Has anyone got a workaround? -- Robert J. Harrison (rjh at 3-cities.com) From dkuhlman at netcom.com Wed Dec 15 19:05:40 1999 From: dkuhlman at netcom.com (G. David Kuhlman) Date: 16 Dec 1999 00:05:40 GMT Subject: Calling C functions (libs) from Python References: <83861d$com$1@serv.vrn.ru> Message-ID: <839ack$m5m$1@nntp2.atl.mindspring.net> Take a look at calldll. If I understand correctly, it does what you want. Go to: http://www.nightmare.com/software.html and search for "calldll". - Dave Eugene Akovantsev (aei at ic.vrn.ru) wrote: > 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 t.maddleton at news.vex.net Mon Dec 6 03:56:35 1999 From: t.maddleton at news.vex.net (t. maddleton) Date: 6 Dec 1999 08:56:35 GMT Subject: Python.org is down! References: Message-ID: <82fto3$2h8s$1@hub.org> On 6 Dec 1999 00:26:23 -0500, John Doe wrote: >The time now is 00:10 Eastern Standard Time (GMT -5) >in USA and python.org is down for sometime now. This url works (if you are desperate for documentation and can't wait for python.org to come back ) http://www.cwi.nl/www.python.org/doc/ (I wasn't sure what you were asking in your previous post, but you may want to look into os.environ and os.cwd() ?) From slinkp at angelfire.com Wed Dec 22 13:17:15 1999 From: slinkp at angelfire.com (Paul Winkler) Date: Wed, 22 Dec 1999 13:17:15 -0500 Subject: Anyone else making music with python? Message-ID: <386115AB.A0DD3F6@angelfire.com> 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... 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. -- ................ 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 badzen at yifan.net Sun Dec 19 02:25:01 1999 From: badzen at yifan.net (dj trombley) Date: Sun, 19 Dec 1999 07:25:01 GMT Subject: sockets References: <001101bf4a9e$bc716720$aa72d03f@sameer2> Message-ID: <385C87AA.ECC6B5A@yifan.net> sameer chowdhury wrote: > > 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. > > Error: > > Traceback (innermost last): > File "client_stuff.py", line 6, in ? > s.connect(HOST, PORT) > File "", line 1, in connect > socket.error: (10061, 'winsock error') > > client: > > # Echo client program > from socket import * > HOST = 'localhost' # The remote host > PORT = 81 # The same port as used by the server > s = socket(AF_INET, SOCK_STREAM) > s.connect(HOST, PORT) > s.send('stuff') > data = s.recv(1024) > s.close() > print 'Received', `data` > > server: > > # Echo server program > from socket import * > HOST = 'localhost' # Symbolic name meaning the local host > PORT = 81 # Arbitrary non-privileged server > s = socket(AF_INET, SOCK_STREAM) > s.bind(HOST, PORT) > s.listen(1) > conn, addr = s.accept() > print 'Connected by', addr > while 1: > data = conn.recv(1024) > if not data: break > conn.send(data) > conn.close() Winsock error 10061 is a CONNECTION_REFUSED. It is not clear from the above exactly what you are doing to "close both sockets" (there are three!) or to connect them a second time, so perhaps more detail is needed. I assume you realize that after accept()'ing a connection, the server socket is still active and can accept() further connections. -dj Dave Trombley From dworkin at ccs.neu.edu Thu Dec 16 20:55:43 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 16 Dec 1999 20:55:43 -0500 Subject: Newbie Getopts Question References: <385951E7.4394EDEC@coastalnet.com> Message-ID: "Andrew N. McGuire" writes: > this seems like a somewhat ineffecient way of handling options. There are certainly some things you can do to make your code cleaner here. However, you are not alone in your judgement of the standard getopt module. It works quite well, but is not as feature-rich as many people would like. Those people don't seem to agree on exactly how it should be better, though. Thus, several people have written their own getopt modules. I've seen one or two private in-house implementations, and a number of people have posted their own getopt replacements here. I have also done this, though to suit a specific need: I wrote a getopt-like module that was designed to mimic the functionality of the argument parsing in the suites of user commands for manipulating the Andrew File System. If anyone wants such a beast, feel free to ask me for it. With that diversion out of the way, I'll see if I can offer any useful suggestions about the code here... > arglist = sys.argv[1:] This isn't necessary. It could even be confusing, since you use that name for something else afterward. You can omit this and just replace the following line: > optlist, arglist = getopt.getopt(arglist, 'f:n:i:o:c:') With: optlist, arglist = getopt.getopt(sys.argv[1:], 'f:n:i:o:c:') > list = [] > > for opt in optlist: > list.append(opt[0]) Just because of all of the bad press map and lambda have had lately ;->, I'll mention that this whole snippet can be done as follows, among other ways: list = map(lambda x: x[0], optlist) > for opt in optlist: I recommend something more like: for opt, value in optlist: Then you can replace all following uses of `opt[0]' and `opt[1]' with `opt' and `value', respectively. Tuple unpacking in this sort of context is a wonderful feature that I use frequently. I'm sure that as you continue to familiarize yourself with Python, you will find many more ways to improve your code. -Justin From emile at fenx.com Tue Dec 14 08:25:56 1999 From: emile at fenx.com (Emile van Sebille) Date: Tue, 14 Dec 1999 05:25:56 -0800 Subject: Zope & Python mention in trade rags Message-ID: <001b01bf4636$c1e2ae60$01ffffc0@worldnet.att.net> Zope's in NetworkWorld this week. http://www.nwfusion.com/news/1999/1213apps.html Emile van Sebille emile at fenx.com ------------------- From wtanksle at hawking.armored.net Tue Dec 7 22:59:18 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 8 Dec 1999 03:59:18 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <82g4bl$42g$1@nnrp1.deja.com> <82j1l0$6vn$1@nnrp1.deja.com> Message-ID: On Tue, 07 Dec 1999 13:21:39 GMT, ajmayo at my-deja.com wrote: > 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. There's a few ways of abbreviating it, actually. (And by the way, "1" is a perfectly acceptable value for n.) As I posted, one-liners can be crammed into one line by means of semicolons, so if x: do() dah() looks like this: if x: do();dah() >This is just plain wasteful of communication line bandwidth, as well as >being a bit of a pain when you are writing the code. Negative on both counts. It's a pleasure when you're writing the code, and it's not "plain wasteful" if the language does what you need it to. Perl spends a lot of time being bandwidth efficient, but it winds up taking MORE room for many things (for example, compare the classical Perl "munitions export" cryptography .signature with ESR's Python equivalent -- the Python one is shorter). >[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. I like variable declaration as well. Use it all the time. Just not in Python :-). I like the fact that Python lets me skip it, although I wouldn't complain if it became optional. >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. Nope, not possible. You have to find other ways. >re Zope - yup, I will certainly be checking it out. Thanks again for >all your help. Good luck! -- -William "Billy" Tanksley, in hoc signo hack From b2blink at hotmail.com Thu Dec 16 15:35:20 1999 From: b2blink at hotmail.com (Ulf Engstrøm) Date: Thu, 16 Dec 1999 15:35:20 CET Subject: gif Message-ID: <19991216143520.48542.qmail@hotmail.com> OKi, this is really easy I bet, I just got stuck and I can't see out anymore.. How do I open up an image in either .gif or .jpeg and save it to a textfile in base64? I know about the base64 mod, but it seems like I can't read the .gifs and .jpegs right. What should I do about this? Best regards Ulf ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From python-list at teleo.net Tue Dec 14 15:53:01 1999 From: python-list at teleo.net (Patrick Phalen) Date: Tue, 14 Dec 1999 12:53:01 -0800 Subject: Documentation Translations In-Reply-To: <14422.42955.688108.522178@weyr.cnri.reston.va.us> References: <14422.42955.688108.522178@weyr.cnri.reston.va.us> Message-ID: <99121412574105.00954@quadra.teleo.net> [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? it's-frequently-all-Dutch-to-me-anyway-ly y'rs -patrick From edwardam at home.com Tue Dec 14 00:47:56 1999 From: edwardam at home.com (Edward Muller) Date: Tue, 14 Dec 1999 05:47:56 GMT Subject: GTK choking on wxPython References: <385586DF.5153D1F0@win.tue.nl> Message-ID: <3855DA0E.9B422CA3@home.com> Matt Gushee wrote: > Bas van der Linden writes: > > > I don't want to spoil your day, but on the wxWindows mailing list they > > were discussing an error in the configure scripts: it requires only gtk > > 1.2.1 but some code it uses can actually only be found in the more recent > > editions of gtk. I am not sure this will cure your problems... Just say > > to yourself: upgrading gtk is fun, upgrading gtk is fun and maybe you > > have a good time at it :-) > > Oh. Well, thanks for the info. I will do my best to have fun with it. > > -- > Matt Gushee > Portland, Maine, USA > mgushee at havenrock.com > http://www.havenrock.com/ Upgrading gtk is easy....The problem is, upgrading all of your apps may be more of a problem....Try the RPMs if you are under Linux (which I am assuming), or the SRC RPMS if you like to compile (not, knocking compiling, I usually go for the .src.rpm files myself if available).... Also check out October Gnome which includes python-gnome and pyGTK..... From papadopo at shfj.cea.fr Wed Dec 15 12:45:53 1999 From: papadopo at shfj.cea.fr (Dimitri Papadopoulos) Date: Wed, 15 Dec 1999 18:45:53 +0100 Subject: running and managing background shell commands Message-ID: <3857D3D1.C651BB88@shfj.cea.fr> Hi, I am translating this shell function to Python: _new_browser() { # start Netscape in the background # this will always return 0, even in the face of a failure... netscape "$*" & # ... so wait a few seconds, and check that Netscape is still alive i=3 while [ $i -gt 0 ] do sleep 1 ps -p $! > /dev/null || return 1 i=`expr $i - 1` done return 0 } How can I rewrite this function? As far as I know: 1) commands.getstatus cannot start a background command 2) os.system does start a background command 3) but $! is not available Do I have to fork and then execv - which is probably what the shell does anyway? From wtanksle at hawking.armored.net Sat Dec 4 20:36:46 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 5 Dec 1999 01:36:46 GMT Subject: Exposing COM via XML-RPC or Something Else References: <1267780385-12582932@hypernet.com> Message-ID: On Sat, 4 Dec 1999 16:18:45 -0500, Gordon McMillan wrote: >Bernhard Reiter wrote: >> >CORBA is NOT a component standard -- it's an interoperability >> >standard. >> Well AFAI understand it COM also is an interoperability standard, >> but I might just miss the point here. >"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. >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 >extensions do so well). The equivalent CORBA stuff (dynamic >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. 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? >> I do not habe much experience about it, I admit, but technically >> they also seem to have the same complexity. I just do not believe >> that COM is easier to code. Well this is, what the articles >> support, too. >It all depends on what you're doing and what tools you use. Mainly assembler right now; we'll be using C to implement the object system and most of its components, but also some assembly. >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. >- Gordon -- -William "Billy" Tanksley, in hoc signo hack From psheer at obsidian.co.za Sun Dec 26 12:47:42 1999 From: psheer at obsidian.co.za (Paul Sheer) Date: Sun, 26 Dec 1999 19:47:42 +0200 (RSA) Subject: KOALA 0.9.0 released: A database `microsoft access'-4GL-like backen d for PostGreSQL Message-ID: SOFTWARE RELEASE ANNOUNCEMENT ============================= KOALA - Version 0.9.0 --------------------- Availability: ------------- ftp://ftp.obsidian.co.za/pub/koala/ What is this package: ===================== This is an object-database / GUI / database-backend / data-widget / Microsoft-Access thingie for postgres. It allows you to create any type of incredibly complicated interlinked set of database tables without typing a single line of code. It supports every kind of postgres type corresponding to every type of gnome/gtk widget. You all do it from within a GUI. And the GUI form layouts are also stored within the database in their own table. Koala gives a form and dialog backend to any postgres database. Koala is written in Python with gnome-python (thanks James) for the interface. Koala is distributed under the GNU General Public License. ---------------------------------- Paul Sheer README.koala>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Koala's user reference: Theory and practical for creating GUI tables. ============================================= This documentation is by no means a comprehensive description of what is going on. It is to be read in combination with running the demos. Between the two, is all of what you may need to know to create tables and dialogs from within the GUI. `Koalii' is the plural of `koala'. A dialog is a form with lots of widgets inside it that usually need filling in. What is a koala: A koala is a widget in a dialog that corresponds to a column in a database table. It is hence a DATA WIDGET (term used in some circles). The dialog itself corresponds to the whole table. A particular instance of the dialog corresponds to a particular row of the table. A koala is also an python object that knows how to create that widget as well as format that data for the particular column in SQL. Koalii usually hold strings, integers, dates etc - like a persons name or his shoe size. A `compound' koala is a koala that holds only an integer where the integer is a reference to a row id of another table. For instance, a dialog of personal details may contain a string koala that holds the persons preferred brand of cologne. It would be better to rather have a table of all brands of cologne and then just store the particular row id of the brand instead of storing a string of the full name of the brand (This allows all brands to be accounted for and makes it impossible to input a non-existing, but similar sounding brand name into the widget). The table of all known colognes would have its own koalii: such as a string containing the name, another for manufacturer etc. These strings are called sub-koalii of the integer koala for this cologne. In postgres (the SQL server), row id's are actually called oid's (Object ID's) and are unique across the entire database. So we may have an oid referring to a person. The person has a row containing a lot of strings and integers describing them. One these integers is an oid, and is a reference to a row in another table of cologne brands. The cologne brand row will contain strings, integers etc describing it, and possibly some oid's linked to other tables of manufacturers, ingredients... and so on. In fact, the manufacturer may contain a list of employees which link all the way back to the persons table: in this way, the database can circular. A compound koala can hence be displayed in two ways: as a form with all its sub-koala represented as widgets (checkboxes, entry widgets etc.); or, when it itself is a sub-koala, as a widget inside the form of its parent-koala. The form has to be laid out neatly so that many sub-koala can be represented. This is actually quite tricky when you are dealing with a table of fifty fields. To do this neatly we group associated koala, displaying each group on a separate page of a gtk notebook. So for example, a `person' koala would have one page for his identity (first name, last name, title), and another page for his address (street, city, country, zip) and so on. In the code, these are called `pages', and there might be only one of them if there are only three or four fields. The form of each page is described by a formatting language, so that a form of a checkbox with an entry widget above it may look like this: ( %Cf / %Exf )f The details of these forms are as per the gtk_dialog_cauldron.3 man page, or the gnome sgml documentation of the gtk_dialog_cauldron() C function. There is one change however: You may mostly use %X instead of an actual format specifier, because the code will test the type of the koala being passed to that format specifier and then substitute the %X for an appropriate widget type. An exception is the checkbox (%C) and radiobutton (%R) widgets. There is no way to tell them apart because the are both `boolean' koalii. Instead of %X you should explicitly specify %R or %C as the case may be. The complete list of user widgets is as follows: koala_string This is the most basic type. It is a Gnome entry widget (%Eg) in the form and a `text' postgres type. koala_int A number entry widget, and an `int' postgres type. This has a calculator button to bring up a calculator even if it is totally inapplicable to the purpose of the data. The calculator also doesn't work, because it fails to add a grab or something - Gnome bug. koala_float Same but for a `float' postgres type. koala_floatrange Spin button widget and `float' type. koala_intrange Spin button widget and `int' type. koala_text Editor widget and `text' type. koala_largetext Same but with scrollbars. koala_bool Checkbox or radio button as explained, and a `bool' type. koala_date Gnome date edit widget and a `date' type. koala_datetime Gnome date edit widget with 24 hours and a `date' type. koala_time Three spin buttons with 0-23, 0-59 and 0-59, time sql type. koala_minutes Two spin buttons with 0-23 and 0-59, time sql type. koala_money Gtk entry widget with format of 999999.99 and `float' type. Note: One of the libpg (postgres library) or _pg (python postgres module) libraries has a bug that causes a segfault when using the `money' sql type. Hence the money koala now uses the float type in tables. koala_null If you read the gtk_dialog_cauldron.3 man page, you will see that some tokens in the format string require an argument merely for display purposes (such as a title to a frame). You can use the null koala for this, which does not represent a column in the table. koala_password An entry widget. This is NOT a password entry of the tradition type where asterisks replace characters. It is for storing passwords so that they can only be read by trusted users. The widget has a check button to the right that, when depressed, decrypts the text and then encrypts it again when raised. The encryption is done with triple-DES. This koala might be used, for instance, in a service IT business that has a database of customers machines that they administer. Each machine has a root password which you can safely store using this koala, only the encrypted text is transfered to the database. The key used to do the encryption is a hash of a password entered with the do_passwd() dialog. A few characters of the intermediate hash can be passed as the second argument to verify that the typed password is correct. koala_mutable This is the compound entity explained above. The widget is a Gnome entry widget that contains text that refers to the first sub-koala on the first page (i.e. the first column in the table). For instance a cologne koala would have the brand name as the first sub-koala, so the brand name would appear in an entry widget in the parent dialog. Next to the entry widget are two buttons, [?] and [^]. The first brings up a list box of possible values that may appear in the entry widget - it does a search through the table. The second displays the full dialog of the koala - the notebook with all its pages. Two extra pages appear in the notebook besides the ones containing sub-koala widgets. The are the `Edit' and `Access' pages. The Access page allows the user `postgres' to restrict or allow access to the particular koala in various ways. koala_auto This is just like the mutable koala, but the dialog is automatically created from a pre-existing table. This can be used in intermediate stages where you quickly want to create some kind of access to a table, where it doesn't have to look pretty. Type is `oid' like mutable. koala_mutablearray This widget is gtk clist - i.e. a table with column headings for each field. The table has `Add', `New', `Edit' and `Delete' buttons. The `Edit' button brings up a dialog just like the mutable koala, from where pages can be added and edited. New entities that are created within the form editor will appear as new columns in the table. The sql type is `text'. This is the one koala that uses more than one row. The table itself has an extra column `_key'. All `_key' with the same value belong together. koala_mutablestring Above we said that compound koala's have an oid value that indexed a row. Mutablestring is a mutable koalii that has a string as the index instead of an oid of the row. The string represents the first koala on the first page - which must be of sql type `text' - and would be the first column of the table. Note that there is not yet protection of duplicate entries. The user should make sure that two rows do not have the same index. koala_mutableint This is the same as mutablestring, but with an integer as an index. Note on editing pages: ---------------------- When you edit a page from within the GUI, it will not appear immediately in the notebook. You have to first test the page by clicking the `Test' button and then `Cancel' the dialog and then `Cancel' the parent dialog. Only then are the previous form layouts cleared from memory. The method append_mutable_page appends koala that do not appear in the page table. If koala already exist, no action is taken, even if the column types or form layout differs. This means that once you have created a page with append_mutable_page you can only alter it from within the GUI. Alternatively you can do a DELETE FROM table_pagearray WHERE _key = 'my_table'; Which will clear out the form and reference to any koalii. Stale (unlinked) koalii from this page will remain in table_entityarray, but these may be ignored. Note on date style: ------------------- Postgress outputs dates as 4/28/1984 or 28/4/1984 depending on the locale. I force my date to european style (28/4/1984) by using, postmaster -o -e ... in my init script (see postmaster(1) and postgres(1)). If you use non-european style, set, european_date_style = 0 in object_bases.py. This has nothing to do with the way that the date will display in the widget, which is has to do with Gnome and not with me. Be absolutely sure about what date style postgres is outputting, by actually creating a table with dates in it and doing a SELECT on them. Koala cannot autodetect this and will read the date incorrectly. Note on quotation marks: ------------------------ At the moment, the python code replaces all ' with ` before committing any string value to a table. How to jump in and create a database: ------------------------------------- There are two ways: one is to just run extended_bases.py as the main program (i.e. su postgres python extended_bases.py ) and then begin creating tables with the `New' button. Follow this example as a tutorial. Here we create a table of motor vehicles. 0. Postgres should be set up so that a user `postgres' can access a database called postgres and create and delete tables. See the postgres documentation about installing and configuring postgres. 1. run su postgres python extended_bases.py 2. Click on `New' 3. Enter `table_vehicles' 4. A notepad will appear with two pages: `Edit' and `Access' Raise the `Edit' page and click on `New'. 5. Enter `Identity' on the Title page, `100' in the `Order' field on the `Form' page. Now enter your form in the text area: ( (Registration Number:) %Xxf )f / ( (Make:) %Xxf )f / ( (Model:) %Xxf )f / ( (Year:) %Xxf )f It would be wise to read the full gtk_dialog_cauldron(3) man page. Note that newlines are completely ignored. 6. Now raise the `Koalii' page and read the message their. 7. Click on `Ok' 8. Click on `Edit' and go back to the `Koalii' page. 9. Click on `New' in the `Koalii' page. 10. A Koalii dialog will appear, enter: `Registration Number' in the `Title' field, `10' in the `Order' field, `string' in the `Type' field, `ident_registration' in the `Table column' field, and leave the rest blank. 11. Now repeat steps 9 and 10 for each of make, model and year. In each case, the `Table column' MUST be different and the `Title' field must be something descriptive. The `Order' field should indicate the order that the koalii appear in the form, preferably with large gaps in case you need to add new ones later, eg 20 for make, 30 for model, and 40 for year. 12. In the `Koalii' page of the `Pages' dialog, check A: that you have four entries B: that each entry has a different Column field C: that each entry has a properly descriptive Title field D: that each entry has a type of `string' E: that the order of the entries matches the order within the form 13. Hit `Ok' to go back to the `Edit' page of the `table_car' dialog. 14. You will notice that under `Enabled' is an `f'. Click on `Test' to test the page and then `Close' the test dialog. If there was something wrong with the form string, an appropriate error message may be printed (see README.patch_first). You may also get error messages that are very cryptic. Don't scratch your head trying to understand them, just double check all your koalii and your form string and try to make the page simpler. 15. `Cancel' the `table_car' dialog. 16. You will now notice a new button on the main menu: `table_car'. click on this button. 17. You can continue to add other pages to the notebook. Though do not ever delete pages and then reuse column names. Postgres lacks the `DROP COLUMN' feature (its also dangerous to use in this case) so stale columns will hang around. You can drop them by recreating the table, but this must be done with psql on the command line. Other way to create a table: ---------------------------- The other way to create a table is to program it in python. Here is a python script that does the same: #!/usr/bin/python from extended_bases import * class koala_car (koala_mutable): def widget_create (self, *args): self.append_mutable_page ("Identity", "( (Registration Number:) %Xxf )f /" "( (Make:) %Xxf )f /" "( (Model:) %Xxf )f /" "( (Year:) %Xxf )f", (("string", "ident_registration", "Registration Number", ""), ("string", "ident_make", "Make", ""), ("string", "ident_model", "Model", ""), ("string", "ident_year", "Year", ""))) return koala_mutable.widget_create (self) def do_table (heading, table): a = koala_mutable ("", heading, "", db, table) a.widget_create () s = search_dialog ("Search: " + heading) if s: a.list (heading, s[0]) db = initialise_bases ("postgres", "localhost", 5432) init_mutable_table (koala_car, db, "table_car") do_table ("Cars", "table_car") --------- Above, the last arguments were always left blank (i.e. ""). These are the default values for the field. In the above cases there is no entry that is more likely than any other, so we left them blank. Now that the form has been created, goto the `Access' page and add some groups so that others besides the postgres login can use the table. You must first create users and groups as explained in README.groups. You need only create one group. Then edit the `Identity' page again and goto `Access'. Here again you must add a group to the list. That concludes a trivial database. To create a complex database with links requires very little more effort... Here we are going to add an owner to the car. First we need to create a `table_person' table. (There may already be one as an example). Add a new page to your car notepad like this: Title: Owner Form: ( (Owner:) %Xxf )f / ( (Date of purchase:) %Xxf ) Entities: Title Order Type Column Table --------------- ------- --------------- --------------- ------------ Owner 10 mutable owner_owner table_person Date Purchased 20 date owner_date The entry widget next to `Owner' will have two buttons to select from a list of people and to add a new person to the list, respectively. You should beware of adding duplicate entries because these are perfectly allowable with a mutable koala, but may create confusion in the database. If there would never be a duplicate entry for the table you have created, then you can use mutablestring instead of mutable which indexes the table by the first column and does not allow duplicate entries. For table_person, the first column contains only the last name of the person. Since there can be many people with the same last name, mutable is used instead of mutablestring. Note that the mutable koala does not automatically insert a default value for a new instance of the dialog. Mutablestring does insert such a value if defined. ---------- -- -----BEGIN PGP PUBLIC KEY BLOCK----- Version: 2.6.3i mQCNAzdiRpAAAAEEANPUPC/Lrs4OCJOjWaIWaCYTzTIY1p73uPY+8ZOJH5fc4QNp IAX+EFQ/yZ3RMOLg8yy++HufzBwDoePO4W0MKwyVFCcNIIjsY6JCXWdbpQXsY1LL OASlGexQnEQ4mfc7ThOAKWSgPyiMv5vDJ6S0EL8rdIFL7fVv56BAxnN042FRAAUR tCJQYXVsIFNoZWVyIDxwc2hlZXJAb2JzaWRpYW4uY28uemE+iQCVAwUQN2JGkKBA xnN042FRAQF5CAP/Y0TaguqCpYiTEBHxZPpT/dliInVRBzryi4gdlgX6CCLDRRGH ATP4ac8aiATegc4ev4+vcdn4fBwc6fQ2AP6hd25ZI93vShxztM/bQlGWy0zp79Uo +69uGdJhdvgYpIsTCqppM/yjeXAJEqq5TG2Gy4pqHY235rspmeA/fX7kgIo= =aX4m -----END PGP PUBLIC KEY BLOCK----- Cellular . . . +27 83 604 0615 . . . . Land . . . +27 21 761 7224 Obsidian Systems . . . . Linux installations, support, networking info at obsidian.co.za . . . . . . . . . . Tel . . +27 21 448 9265 http://www.obsidian.co.za . . . . . . . Jhb . . . +27 11 792 6500 L I N U X . . . . . . . . . . . . . The Choice of a GNU Generation From darcy at vex.net Sun Dec 5 08:08:51 1999 From: darcy at vex.net (D'Arcy J.M. Cain) Date: 5 Dec 1999 13:08:51 GMT Subject: Very useful message -- Hah! References: Message-ID: <82do53$2rhr$1@hub.org> Dan Grassi wrote: > It seems that by design python, by design, is not to be used as a cgi > scripting language -- otherwise why would it produce this very meaningful > message at the slightest syntax error: > Internal Server Error Interesting viewpoint. I wrap all my CGIs in try/except clauses so that I can see the syntax error in the browser and I am considering removing them all except where I use them to trap user entry error. As it turns out, every time I have to debug a page it is easier to comment out the try/except and tail -f the error log. In particular, it is generally not helpful for tracebacks and such to appear on users' screens. Using the default action allows me to have them try whatever they are doing and look at the results without needing it it read by them or mailed. > Personally I've about had it, at least PHP provides reasonable error > messages. I wouldn't know. I won't use something that changes so incompatibly between versions as PHP did between 2 and 3. -- 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 claird at starbase.neosoft.com Thu Dec 23 18:13:13 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 23 Dec 1999 23:13:13 GMT Subject: making the Python case to my dept. References: <9911051740130D.02530@william.jinsa.org> <3824723A.5DE35FE5@callware.com> <99110611340304.02970@quadra.teleo.net> <80knjo$57n$1@nnrp1.deja.com> Message-ID: <66AF21747EFB37E0.226F6E2B98DD2B71.3D5726B1C68B5C12@lp.airnews.net> In article <80knjo$57n$1 at nnrp1.deja.com>, wrote: >I hit the hp e-speak site and everything was in java. I was just >wondering where you got this news from? . . . Does help answer that? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From tbryan at python.net Sun Dec 5 17:10:03 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Sun, 05 Dec 1999 17:10:03 -0500 Subject: Tkinter 1.5.2 ?? References: <38499F30.54313C44@interaccess.com> Message-ID: <384AE2BA.D3F9CD44@python.net> Clyde Davidson wrote: > > I am starting to get into Python. So, I bought "Learning Python" and updated > the Python that came with my Red Hat 6.0. I found 1.5.2 in RPM. However the > Python-Tkinter wouldn't install because it conflicted with my regular > Tkinter-1.5.1, or so my RPM package told me. For Python-related RPMs, the best place is http://andrich.net/python/ But for Tkinter, note the first Bug/FAQ at http://andrich.net/python/installation.html overriding-package-manager-warnings-ly yours ---Tom From kilian.lorenz at dkfz-heidelberg.de Tue Dec 14 10:10:41 1999 From: kilian.lorenz at dkfz-heidelberg.de (Kilian Lorenz) Date: Tue, 14 Dec 1999 16:10:41 +0100 Subject: time.time and again. References: <38549FF3.6AC95592@rtpro.net> Message-ID: <38565DF1.724EB961@dkfz-heidelberg.de> Tesla Coil wrote: > > Very new to Python and wondering if there's a function > like UN*X at(1) hidden away in a module, or if it would > need written from scratch. I know there's time.sleep(), > but looking for something more like "do this at 13:45." Hi, I'm no big Un*x- nor Python-Guru, but I think the "at"-program works somehow very complicated by storing a file in the directory /var/spool/atjobs/ or somewhere ... and later the crondaemon executes that stuff (perhaps ?!). Anyway, if you are already working on a Un*x-mashine, I would propose doing it like this: import os os.system('at ....') # your at-call like you used to do it before Regards, Kilian From python-list at teleo.net Mon Dec 27 02:30:20 1999 From: python-list at teleo.net (Patrick Phalen) Date: Sun, 26 Dec 1999 23:30:20 -0800 Subject: Tkinter config on RH 5.2 In-Reply-To: <38670A11.2756FA0A@calvin.gonthier-be.com> References: <38664B8A.6AEA7758@altern.org> <38670A11.2756FA0A@calvin.gonthier-be.com> Message-ID: <99122623365104.01988@quadra.teleo.net> [Thomas Lionel SMETS, on Sun, 26 Dec 1999] :: 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 Take a look at http://andrich.net/python. Oliver Andrich has RPMs for TKinter that work with RH 5.2. From tholap at compuserve.com Fri Dec 10 15:31:15 1999 From: tholap at compuserve.com (Olaf Appelt) Date: Fri, 10 Dec 1999 21:31:15 +0100 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> <38510920.172174013@news.oh.verio.com> Message-ID: <82ro5c$9n1$2@ssauraab-i-1.production.compuserve.com> Hi Kevin, > >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. Personaly I have no problem with that. The problem is that I have to fullfil some constraints. I currently have a working solution that is easy to use for the target audience (looks a lot like Basic), but it hard to maintain. It's sort of a self-built interpreter. Minimalistic, but sufficient for our needs. Yet, if could realize the needed functionality on top of something like Python, maintainance would become much easier. One solution is to keep our Basic dialect, but have a much simpler compiler that simply reformats everything into Python. That way I have no problem with Pythons syntax, but can still profit from its interpreter. Yet, not having to maintain that superficial grammer would be even nicer? :-) (I guess I'm lazy) > >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? Depends upon the language. ;-) In Python *I* would expect c now being a second reference to what d references. While the instance formerly known as c is now unreferenced and can be collected. The users of my language would expect c to have now the same numerical value that d has, but still preserving all state information that was associated with c. That's my problem. The variables in this language carry a set of informations and only one value is changed by assignment. > 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++. I'm not suffering from paradigma deficiency syndrome. ;-) I experienced a lot of languages and am therefor used to different paradigmas and willing and able to adapt my POV. I'm aware that I'm trying to do something with Python for which it was not built. Yet, given the realistic alternatives, Python is otherwise very high on my list. If I can find no better way, I'll go with the Python interpreter plus PseudoBasic pre-compiler solution. Thanks for your input. Olaf From dr10009 at cl.cam.ac.uk Fri Dec 10 09:31:16 1999 From: dr10009 at cl.cam.ac.uk (Dickon Reed) Date: 10 Dec 1999 14:31:16 GMT Subject: string interpolation syntactic sugar References: <82ogb2$db2$1@pegasus.csx.cam.ac.uk> <02d801bf4259$fa2737e0$f29b12c2@secret.pythonware.com> Message-ID: <82r2rk$4qf$1@pegasus.csx.cam.ac.uk> In article <02d801bf4259$fa2737e0$f29b12c2 at secret.pythonware.com>, Fredrik Lundh wrote: >Dickon Reed wrote: >> I propose a new kind of string literal wherein bracketed expressions >> are evaluated then converted to strings. > >argh! :-) >> An alternative approach might have a function to do this: >> >> interpolate("a {x} b {y}") > >I'm not sure if it works with 1.5.2, but Ping's string >interpolation module implements most of this Ping's module is interesting. I rewrote it to the syntax I had in mind, because I still prefer mine (being easier to describe and implement). If anyone's interested, my interpolate module is at: http://www.cl.cam.ac.uk/~dr10009/interpolate.py Doing the thing I originally suggested in the interpreter is still probably going to be more efficient, but this way is reasonably backwards compatible. The try: 1/0 except: munge traceback thing seems a little nasty to me; anyone know of a way of getting at the caller's locals and globals without throwing and catching an exception? Dickon ps. I wasn't aware of the use of % with dictionaries discussed in the other branch of this thread; string % locals() idiom is nice, but I hadn't seen it anywhere before. From Alex.Martelli at think3.com Fri Dec 17 04:20:46 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Fri, 17 Dec 1999 10:20:46 +0100 Subject: "sins" (aka, acknowledged language problems) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> Tim Peters is kind enough to respond to my request for an URL about acknowledged Python defects with detailed considerations boiling down to: lots of tiny pet peeves, but no consensus which seems to be a very accurate assessment. So, maybe I can move down a notch and try fishing for Python things which at least "annoy" a "vast" (carefully vague term:-) number of Pythonistas, without compensating advantages to "many" others. 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!-) The type/class split has been mentioned (it does not affect most people, it helps none, it hinders, albeit slightly, most of those who are trying to do certain advanced things). Would this also apply, to a weaker but broader extent, to the lack of assigning-operators, an "expression" kind of assignment, increment and decrement in particolar, or other issues of the expression/statement split? E.g., I would like to offer for comment a typical "Python-newbie" kind of personal anecdote. (Entering this from memory, so please excuse any typos that might happen)...: 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 may need a class, but let's first see if I can make it a function -- and I fire up IDLE and start editing smartcopy.py, after a long doc string detailing the above design, with...: import sys def copy(regex, dict, inp=sys.stdin, oup=sys.stdout): Now, I need to loop: read a line, check if it matches the regular-expression arg, and if so then do fancy things, finally output it. Darn, this needs that goofy idiom...: while 1: line = inp.readline() if not line: break if regex.search(line): pass # we'll fill this in later oup.write(line) I add the "if __name__=='__main__'" idiom and test it as a straight copy-through... ok. Now, for the 'meat' of the substitution... I look at the re module's documentation, and the doc for "sub" stares at me... "repl" can be a FUNCTION!? Wow... I add a first couple of line before the while: def repl(match,dict=dict): return eval(match.group(1),dict) and change the if/pass couplet and the write call to the single line: oup.write(regex.sub(repl,line)) That's *IT*? I can't believe it... yep, a little test convinces me, that it actually is. The "weekend project" turned into 15 minutes. My girlfriend, busy at her email on another computer, smiles indulgently at my childing enthusiasm at the result. And YET... human nature being what it is... I cannot help but keep staring at the result: import sys def copy(regex, dict, inp=sys.stdin, oup=sys.stdout): def repl(match,dict=dict): return eval(match.group(1),dict) while 1: line = inp.readline() if not line: break oup.write(regex.sub(repl,line)) and wonder that *FOUR*-count-em lines of this function, fully half of it, are devoted to the trivial, frequent, repetitive task of looping over input lines, reading each one, bailing out when done. Yeah, I know I could have written the break on the same line as the if, but that's considered bad Python style:_) 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. Apparently, I can't because "upper-crust" Pythonistas like the "while 1:/...break" style -- or at least, that's how a newbie like me can easily interpret the existing discussion. And yet, here, this idiom would rebalance the relative 'weight' of different parts of this tiny but useful function. I know I could write, for this specific case: for line in inp.readlines(): with similar overall effect, but why should I change semantics to "read everything at once", when line-at-a-time is what is really needed, just to get neater syntax? OK, OK, this is no doubt the kind of thing that can be classified as a very pet peeve, rather than as a "deadly sin"!-). 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...? With too much time on his hands, the newbie is sure to find something to grouch about!-) 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 on an example such as these, such warts as having to take 4 lines for such a very common idiom may stand out sharply by contrast, particularly since single-line idioms for this sort of thing are so common in languages otherwise far less powerful, AND since Python itself would easily allow a single-line idiom if the semantics was a slightly different one of roughly similar frequency. If I can get some balanced discussion about this, and perhaps similar problems, maybe I can put together a suitable page myself. Maybe call it "controversial booboos" rather than "deadly sins":-). If a "prospect" should see that THIS kind of minor issues is the worst that Python users have to complain about, and compare and contrast this picture with the famous "deadly sins", then maybe this could exert quite a draw:-). Alex-the-Python-newbie From gerrit.holl at pobox.com Wed Dec 15 08:45:23 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 15 Dec 1999 14:45:23 +0100 Subject: Interpolation between multiple modules of an application. Message-ID: <19991215144523.A1707@stopcontact.palga.uucp> Hello, [see below for the raw, unexplained question] I'm writing an application which consists of multiple modules. For example, a common.py module, which defines the function: # common.py def nomain(): print "this file isn't meant to be executed," print "please run the file 'discoverb'" # end and then, every module uses this function. I end up with having the following in *every* module: import common # ... if __name__ == '__main__': common.nomain() # cut here I also use the common module for other things. This isn't really bad, but consider the language.py module; it defines a Class like this: # language.py (untested code) import userdict class Language(userdict.userdict): def __init__(self, lang): self.data = {...} # define self.data Every module needs to print messages, so *every* module imports language and *every* module created a class so *every* time a file is parsed! That's wrong! The only, UGLY solution I found is pickling it. UGLY! So my question is: How do I share session-depentent objects between modules, without them all doing the same over and over again? regards, Gerrit. -- "The IETF motto is 'rough consensus and running code'" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 2:38pm up 34 min, 10 users, load average: 0.00, 0.00, 0.06 From NO_SPAMnpirzkal at hq.eso.org Wed Dec 1 15:03:06 1999 From: NO_SPAMnpirzkal at hq.eso.org (NO_SPAMnpirzkal at hq.eso.org) Date: 1 Dec 1999 20:03:06 GMT Subject: FITS file question References: <823sv5$qm3$1@nnrp1.deja.com> Message-ID: <823utq$30m$1@snatch.hq.eso.org> In <823sv5$qm3$1 at nnrp1.deja.com> nt_me at my-deja.com wrote: > How can FITS file images be displayed using Python? For example > can it be done using image or PhotoImage? > > Thanks ahead. > I used to have a small hack that would allow me to display a FITS file using ximtool. I simply wrapped the CDL IRAF C library into callable Python functions. I could then display any array into ximtool, including FITS images of course. From mlh at vier.idi.ntnu.no Fri Dec 3 09:05:49 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 03 Dec 1999 15:05:49 +0100 Subject: DLLs and Pythonwin Message-ID: Oh, well. So no I have a PC too... I have been using Python on Solaris (and FreeBSD) up until now, and will continue to do so, but now I also use it under Windows NT. (Hey! IDLE is neat ;) But - pythonw.exe complains that it can't find tcl80.dll in "the specified path". It seems that, at least the Tk part works fine (IDLE appears), and I did install tcl80.dll along with python. (It is there - I checked :) This isn't really a *problem* for me (except for the annoying warning that it can't find the dll), but it seems a bit unnecessary. Is there any preferred solution? Where is the path referred to specified (so I could put in the dll)? Shouldn't this be fixed by the installation wizard? (IMO, for Windows, it would be nice if everything were just plug-and-play... I mean - it almost is on UNIX, even, so... ;) -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From langjahr at itsdata.com Wed Dec 15 21:25:19 1999 From: langjahr at itsdata.com (Eric Langjahr) Date: Wed, 15 Dec 1999 18:25:19 -0800 Subject: C++ (was RE: Python suitability) References: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it> <838uvo$sc7$1@news1.xs4all.nl> Message-ID: Well inheritance has MANY potential issues which have been explored extensively in the OOP community. Composition is certainly preferable in many cases. Some people have described one aspect of the inheritance problem as the "YO-YO" effect. Inheritance has also been called, by some, the goto statement of the 90's The problems exist, to some extent, regardless of the specific OOP language. Now some OOP environments have better tools for browsing class hierarchies and so forth, but still that is only a partial solution. The basic problem is that it can be VERY hard to follow the flow of control in a very deep inheritance tree as method calls go up and down the tree. It can be even harder to subclass from this tree and override or redefine (whatever your terminology) without producing all sorts of unintended side effects (some of which may or may not show up immediately). In fact, from a strictly theoretical level, I think that Eiffel makes the only real attempt to solve this problem to some extent with Design By Contract concepts. While it doesn't solve the problem of understanding the hierarchy it does help to avoid producing unintended side effects IF the contracts are well thought out to start with. Fifteen years ago I would have insisted that inheritance was a KEY element of any OOPL. But now I am not so sure that this is really so. At least NOT the way it is implemented in most 'main stream' OO languages. In MANY cases I think programmers use IMPLEMENTATION inheritance simply because they lack BETTER tools to solve the code reuse / laziness / redundancy problem. MACRO facilities, genericity, and case programming environments (with a little 'c') could solve many of these problems better. Unfortunately the case tools I envision don't exist YET. Instead we have terrible 'object-oriented' application frameworks that often offer little real benefit. In many cases programmers would be better off using the old C starter application of the sort that was very common 10-15 years ago in Windows and Macintosh world than trying to fit square pegs into round holes. These 'oop' frameworks are, in many cases, worthless if your application needs to do much that is very different from what the implementor had in mind. In many cases, the companies producing these frameworks don't even use them for most of the software they produce. I find that interesting. IMHO our industry, and programmers, tend to follow trends and the 'latest' fad to a far greater extent than even society as a whole. Still all comes down to choosing the right tool for the right job. Apologies if I have drifted a bit off topic On 15 Dec 1999 20:51:04 GMT, boud at rempt.xs4all.nl (Boudewijn Rempt) wrote: >Alex Martelli wrote: >> Grant writes: > >>> About twice as long as it would take for a Modula-3 or >>> Smalltalk programmer. ;) I've never thought C++ was a >>> particularly decent example of an object-oriented language, but >>> maybe that's because I learned Smalltalk and M3 first. >>> >>> The whole virtual-function-method thing has always struck me as >>> very obtuse. You apparently have to guess ahead of time which >>> methods somebody might, at some point in the future, want to >>> override, and declare them differently from the non-overridable >>> ones... >>> >> Or, to put it another way: you have to DESIGN, rather than >> just start hacking. > >> Specifically, if you follow the advice of Scott Meyers, in his >> excellent "Effective C++" (CD Edition): never inherit from a >> concrete class. > >That makes C++ about as powerful as Visual Basic - in essence, >no inheritance at all, just interfaces... Having just done a >large project in Visual Basic, I've learnt how painfult that >limitation can be - and I was kind of surprised when I read >in Design Patterns that composition should be favoured over >inheritance. There are no doubt good reasons, but not one >I can think of. > >Boudewijn Rempt | http://denden.conlang.org From a.eyre at optichrome.com Fri Dec 17 06:05:17 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 17 Dec 1999 11:05:17 -0000 Subject: Control chars and special chars In-Reply-To: Message-ID: <003401bf487e$99cb2610$3acbd9c2@peridot.optichrome.com> > for i in range(255): print i, chr(i) range(32, 256) would be more suitable in this case From neelk at brick.cswv.com Fri Dec 31 09:15:22 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 31 Dec 1999 14:15:22 GMT Subject: "sins" (aka, acknowledged language problems) References: <000101bf528c$63c7c9c0$a02d153f@tim> Message-ID: Tim Peters wrote: > > [Scoping, yet again] > > That John could assume otherwise just goes to show that he thinks Python's > scheme is complicated because he's still trying to force some other > languages' view(s) onto it. Forcing a bloated square peg into a slimly > elegant round hole is indeed a complicated business . I think that in light of Viper, John can no longer be said to be *trying to use* a different scoping model in Python, because he has *succeeded*. :) Neel From gmcm at hypernet.com Fri Dec 10 09:47:31 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 10 Dec 1999 09:47:31 -0500 Subject: stdout to file In-Reply-To: <82qm35$dt7$1@phys-ma.sol.co.uk> Message-ID: <1267285900-453740@hypernet.com> Sposhua asks: > > Is there any point to using: > > file = open("inquisition.txt","w") > file.write("Nobody expected it.\n") > file.close() > > ...when this seems more efficient and closer to the shell: > > import sys > sys.stout = open("inquisition.txt","w") > print "Nobody expected it.\n" > > Are there occasions to use one instead of the other? Is #2 really > more efficient? The typical reason for using #2 would be that your code is filled with print statements, which you suddenly realize would be better directed to a log file. (They're not identical; #2 will be double spaced.) It's also a tad easier to do nice formatting with print statements. No, #2 is not more efficient. > Also, in #2, do you have to "close" stdout (and if so how, > sys.stout.close()?) and how do you reset stdout to the screen > (.close() again?). Nope. Better to save it and restore it. In fact, unless you know what you're doing, you'll have a hard time closing stdout. > PS, I'm sending this in Outlook, which I don't know very well. > Does it look ok in Pine and other text-only mailers? Do the lines > wrap at 70(ish) characters? Formatting doesn't seem to be one of the 99,000 reasons not to use Outlook . - Gordon From gmcm at hypernet.com Thu Dec 23 23:22:27 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 23 Dec 1999 23:22:27 -0500 Subject: embedding Python in C In-Reply-To: <38629946.55E9569F@be-research.ucsd.edu> Message-ID: <1266114037-33608165@hypernet.com> Curtis Jensen wrote: > Gordon McMillan wrote: > > > > Curtis Jensen asks: > > > > > From a C file, how can I get values from a Python Class? For > > > Example: > > > > > > File: Test.py > > > class Klass: > > > def __init__(self): > > > self.a = 1 > > > self.b = 2 > > > self.c = 3 > > > > > > How can I get the values of a,b, and c from within a C > > > function? Thanks > > > > Assuming you mean "from an instance of Klass", the answer > > is the same way you would in Python. Well, in dynamic > > Python. The equivalent of getattr(obj, name) is > > PyObject_GetAttrString(o, name). > > > > - Gordon > > Suppose I have an instance of Klass called foo. In the C code I > have: > int tmp; > PyObject *value; > PyObject *pmod; > > pmod = PyImport_ImportModule ("foo"); > value = PyObject_GetAttrString (pmod, "a"); > PyArg_ParseTuple(value, "i", &tmp); > printf("Value = %d\n",tmp); > > I should get "Value = 1" outputed to the screen right? No. You just imported a module named foo. I kind of expected your C code exposed a method (see the extending docs) that took a PyObject, checked that it was an instancetype, then looked for an attribute named a on the object. So your Python might look like: import CJs_extension foo = Foo() CJs_extension.do_something(foo) Then your C code can be fairly straightforward. Rooting around through Python namespaces looking for an instance of Foo could take a whole lot of code ;-). > I don't; > I get some realy big number. I'm not sure what is wrong. I've > tried several different combinations of variables and pointers > and I can't get it. What's wrong with the code? Thanks. > > -- > Curtis Jensen > cjensen at be-research.ucsd.edu > http://www-bioeng.ucsd.edu/~cjensen/ > FAX (425) 740-1451 - Gordon From felixt at dicksonstreet.com Mon Dec 20 02:22:45 1999 From: felixt at dicksonstreet.com (Felix Thibault) Date: Mon, 20 Dec 1999 01:22:45 -0600 Subject: question about Message-ID: <3.0.5.32.19991220012245.007eb910@mail.dicksonstreet.com> My basic question is: If I have a large nested dictionary whose keys are different slices of a large string, which are all in a much smaller set of strings, is there an advantage to building my dictionary like: dict[names[text[leftslice:rightslice]]] = value instead of: dict[text[leftslice:rightslice]] = value so that for all keys 'spam' use the same string instead of identical ones. Thanks- Felix Here are the details: I have a class which takes in an html document like: #test.html------------------------------------------------ T E S T D O C

This is only a test

  • This is only a list
  • Me too!
and returns a UserDict object like: {'html': {'': (0, 28), 'body': {'': (10, 24), 'h1': {'': (12, 14)}, 'ul': {'': (16, 22), 'li': {1: {'': (20, 20)}, 0: {'': (18, 18)}}}}, 'head': {'title': {'': (4, 6)}, '': (2, 8)}}} where the ''s are the indexes of the tuples in a TextTools taglist that go with and (if it exists). The dictionary is made by recursion over a list like [ ['html', 0, 28],...]. Originally I made the lists in this list from the slice of the document where the tagname is: name = lowertext[tagtuple[3][0][1]:tagtuple[3][0][2]] but since the TextTools documentation of the tagging engine begins "Marking certain parts of a text should not involve storing hundreds of small strings," this always bothered me. I already had a function that returned a dictionary with all the html tag names and using it to change the line above to: name = id[lowertext[tagtuple[3][0][1]:tagtuple[3][0][2]] didn't seem to cost me anything, performance-wise. The document I've been using for benchmarking has 998 tags, and about 20 tagnames. Am I gaining anything by making the dic- tionary the new way versus the original way? From paul at prescod.net Mon Dec 20 10:49:12 1999 From: paul at prescod.net (Paul Prescod) Date: Mon, 20 Dec 1999 09:49:12 -0600 Subject: Redirecting stderror to a browser References: Message-ID: <385E4FF8.445DF3FC@prescod.net> Sposhua wrote: > > Using Python 4 CGI, I'd like to redirect the errors to the browser window, so I > get meaningfull errors rather than the typical "500 Internal server error". The CGI module describes how to do this: http://www.python.org/doc/lib/node223.html -- Paul Prescod - ISOGEN Consulting Engineer speaking for himself The occasional act of disrespect for the American flag creates but a flickering insult to the values of democracy -- unless it provokes America into limiting the freedoms that are its hallmark. -- Paul Tash, executive editor of the St. Petersburg Times From dirkl at home.com Fri Dec 10 09:26:23 1999 From: dirkl at home.com (Dirk Leas) Date: Fri, 10 Dec 1999 07:26:23 -0700 Subject: mysql module w/ RH 6.1 or Mandrake 6.0 Message-ID: Can you provide links/instructions/howto on what mods have to be made to build the mysql implementation of dbi? The standard download won't build. mysql and Python are both working fine -- just can't build the module. I've been through the included docs and the install code and couldn't find any details. Looked on the RH distribution CD and couldn't find the files needed to build. TIA, D From thantos at chancel.org Wed Dec 22 18:57:21 1999 From: thantos at chancel.org (Alexander Williams) Date: Wed, 22 Dec 1999 23:57:21 GMT Subject: Lists of lists traversal References: <83m3fn$sb6$1@cronkite.cc.uga.edu> Message-ID: On 22 Dec 1999 16:45:22 -0500, Justin Sheehy wrote: >Your description above doesn't give me a very clear idea of what you >are trying to do. The following function, given a list of lists of >numbers, will return a list of their sums: > >>>> def Sum(ls): >... from operator import add >... newls = [] >... for i in ls: >... newls.append(reduce(add, i)) >... return newls >... Or, more succinctly: >>> import operator >>> def Sum2(ls): >>> return map(lambda l: reduce(operator.add, l), >>> ls) The horrifying need to use a lambda in here is one more scream amongst the wasteland for automatically curried functions. :) -- 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 fredrik at pythonware.com Sun Dec 5 16:02:38 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 5 Dec 1999 22:02:38 +0100 Subject: Very useful message -- Hah! References: <199912051856.KAA05698@mb3.mailbank.com> Message-ID: <009601bf3f64$10a82e00$f29b12c2@secret.pythonware.com> > > - start the interpreter with the -u option > > OK I don't know how to arrange that, color me dumb. in your sample script, change: #!/usr/bin/python to: #!/usr/bin/python -u > > - or call sys.stdout.flush() at the appropriate > > places (you have to import the sys module > > first). > > But that won't work for syntax error -- right? it will work, if you've redirected sys.stderr to sys.stdout (as you did in your sample).
From bwarsaw at cnri.reston.va.us Thu Dec 9 15:22:25 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 9 Dec 1999 15:22:25 -0500 (EST) 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: <14416.3969.90448.612046@anthem.cnri.reston.va.us> >>>>> "JH" == Jeremy Hylton writes: JH> And it's a good technique to point out! Another variant of JH> this that I've found useful is: JH> "a %(x)s b %(y)s" % obj.__dict__ And what I use all the time with executable scripts is something like: def usage(code, msg=''): print __doc__ % globals() if msg: print msg sys.exit(code) Then you put all the script's --help text in the module docstring, with a few %(thingie)s sprinkled around it. Works really well! -Barry From cjensen at be-research.ucsd.edu Fri Dec 24 17:37:00 1999 From: cjensen at be-research.ucsd.edu (Curtis Jensen) Date: Fri, 24 Dec 1999 14:37:00 -0800 Subject: Returning list of arrays from C Message-ID: <3863F58C.DFED78BF@be-research.ucsd.edu> I need to return a list of arrays from a CAPI. I'm using the Numeric module to create some C extensions. Though, I need to return several arrays to Python. How can I do this? -- Curtis Jensen cjensen at be-research.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From Alex.Martelli at think3.com Wed Dec 29 12:38:26 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Wed, 29 Dec 1999 18:38:26 +0100 Subject: random number generation: the newbie asks for advice Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D91@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 gerrit.holl at pobox.com Mon Dec 6 11:02:31 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 6 Dec 1999 17:02:31 +0100 Subject: Be gentle with me.... In-Reply-To: ; from wtanksle@hawking.armored.net on Sun, Dec 05, 1999 at 01:41:14AM +0000 References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: <19991206170231.A2226@stopcontact.palga.uucp> William Tanksley wrote: > One of the main reasons I use Python is the clean syntax, including the > indentation. Otherwise I'd be using Perl -- it's not that bad either, so > long as you limit your style and never look at anyone else's code. You're absolutly right, but this is just a way to prove it: 16:55:22:1/501:gerrit at stopcontact:~$ wc -l /usr/share/vim/vim54/syntax/perl.vim 342 /usr/share/vim/vim54/syntax/perl.vim 16:55:36:2/502:gerrit at stopcontact:~$ wc -l /usr/share/vim/vim54/syntax/python.vim 47 /usr/share/vim/vim54/syntax/python.vim regards, Gerrit. -- "The world is beating a path to our door" -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates) 4:55pm up 47 min, 16 users, load average: 0.00, 0.00, 0.00 From prestonlanders at my-deja.com Mon Dec 20 17:07:51 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Mon, 20 Dec 1999 22:07:51 GMT Subject: Question about map() and class methods References: <83lgi0$t$1@nnrp1.deja.com> Message-ID: <83m9bl$itb$1@nnrp1.deja.com> Hey scott, I'm not sure what you're ultimately trying to accomplish here, but a couple of tips: All class methods are called with *at least* one parameter, the class instance (people use the word 'self' merely as a convention). The map() function will call its first parameter as a function once for each thing in its second parameter (hopefully a list). That function call will have that thing as the only parameter (not including the implied class instance parameter.) Hope that made sense. Your foo.bar() function only accepts one parameter, its class instance. It needs to be something like: class foo: def bar(self, thing): return thing + thing In addition, I think you will need to instantiate your foo class before you can use its methods, but I could be wrong. So, you would do something like: >>> foo_instance = foo() >>> map(foo_instance.bar, [1, 2, 3]) [2, 4, 6] You may find it helpful to reread the section on classes in the tutorial. Then again, you might not. http://www.python.org/doc/current/tut/node11.html cheers, ---Preston In article <83lgi0$t$1 at nnrp1.deja.com>, malraux at my-deja.com wrote: > Hi all, > > I was attempting to use a class method with map() the other day, and > failed miserably. > > Basically, if I have a class foo: > > class foo: > def bar(self): > return(whatever) > > and I try to do this: > > x = map(foo.bar, someListOfFoos) > > The interpreter complains that foo.bar requires a class as its > argument. Obviously, if it would only continue with the call, it would > discover that yes, indeed, it has a whole list of them to chew on. > > I got around the problem by doing this: > > def mapFooBar(self): > foo.bar(self) > > map(mapFooBar, someListOfFoos) > > Which of course works fine. > > What am I missing here? > > Thanks, > > -scott > Sent via Deja.com http://www.deja.com/ Before you buy. From skaller at maxtal.com.au Wed Dec 1 08:55:56 1999 From: skaller at maxtal.com.au (skaller) Date: Thu, 02 Dec 1999 00:55:56 +1100 Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> <38435C43.B238EC15@mindspring.com> <3844BD09.53B39078@Lugoj.Com> Message-ID: <384528EC.52AE3F35@maxtal.com.au> James Logajan wrote: > No one is asking > for 2 to become 3, merely that *REFERENCES* be mutable. You couldn't > accomplish a whole hell of a lot of computation if references always pointed > to the same values for all time! This is the case for functional languages, and they can compute everything you want. -- 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 thamelry at vub.ac.be Fri Dec 3 16:35:02 1999 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 3 Dec 1999 21:35:02 GMT Subject: indentation References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> <19991203211232.A11045@stopcontact.palga.uucp> Message-ID: <829d26$s4d$1@mach.vub.ac.be> Gerrit Holl (gerrit.holl at pobox.com) wrote: [snip] : 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? [snip] Funny, that doesn't bother me one bit. I guess self is necessary for the inheritance implementation, where you have to provide a self instance to the base class methods. I think the use of self (or whatever you want to use) clarifies the distinction between local variables and class attributes. -- Cheers, ------------------------------------------------ Thomas Hamelryck//Free University Brussels (VUB) Intitute for Molecular Biology// ULTR Department Paardestraat 65//1640 Sint-Gensius-Rode//Belgium ------------------------------------------------ From hurd at sds.co.kr Thu Dec 9 04:41:45 1999 From: hurd at sds.co.kr (Youngbong Choe) Date: Thu, 9 Dec 1999 18:41:45 +0900 Subject: How can I get disk space usage? In-Reply-To: <006f01bf4228$b538b220$f29b12c2@secret.pythonware.com> References: <99120914373302.01692@hurd.sds.co.kr> <006f01bf4228$b538b220$f29b12c2@secret.pythonware.com> Message-ID: <99120918493000.01853@hurd.sds.co.kr> Thank you very much!! It works fine! :) Thu, 09 Dec 1999, Fredrik Lundh wrote: > 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 > >
> > > > > -- > http://www.python.org/mailman/listinfo/python-list From aa8vb at yahoo.com Wed Dec 29 12:54:21 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 29 Dec 1999 12:54:21 -0500 Subject: Newbie Tkinter Problem In-Reply-To: References: <87puvut4oz.fsf@baal.winnegan.de> Message-ID: <19991229125421.B692595@vislab.epa.gov> Colleen & Brian Smith: |In the script below, when I hard-code the file name, the button works fine. |However, when I use the askopenfilename dialog, something is preventing the |button from working normally. If somebody could |point out where I'm going wrong, I'd sure appreciate it. ... | 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. You might have gotten more responses had you posted the source as a MIME attachment that folks could directly save to a file and run. I had to clip the source out of your message, re-indent it, and comment out lines to libraries I didn't have: #from viewer import UI ... #self.pic = Image.open(self.picname) #self.pic.thumbnail((128, 128)) #self.display = UI(self,self.pic) #self.display.pack(side=RIGHT) Having done this, if I select a JPEG file, hit Open, the QUIT button works just fine. Randall From roy at popmail.med.nyu.edu Fri Dec 17 21:32:53 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Fri, 17 Dec 1999 21:32:53 -0500 Subject: circular references? Message-ID: Let's say I've got: class a: pass class b: def __init__ (self, x): self.x = x and then I do: foo = a() foo.b = b(foo) I've now got two objects that contain references to each other. Is this bad? From fdrake at acm.org Tue Dec 21 16:25:00 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 21 Dec 1999 16:25:00 -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> <14431.60189.682411.792427@weyr.cnri.reston.va.us> Message-ID: <14431.61484.662532.436321@weyr.cnri.reston.va.us> Magnus L. Hetland writes: > Suddenly it works. Hm. So it actually needs sourcecode - i'd say > that's quite a shortcoming You'll just have to get over that one... ;) > Except... As long as the source file is called spammodule, it seems > that the module name is also spammodule, although I would like it to > be called spam (which is what I called in the setup file, like the > example in the docs...) If you try "import spammodule" it should fail: >>> import parsermodule Traceback (innermost last): File "", line 1, in ? ImportError: dynamic module does not define init function (initparsermodule) (Only yours will say "initspammodule".) If you want the .so to be named spam.so, rename the source file to spam.c and adjust Setup.in to say: *shared* spam spam.c -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From clopez at abo.fi Mon Dec 13 11:26:54 1999 From: clopez at abo.fi (Cesar Lopez) Date: Mon, 13 Dec 1999 18:26:54 +0200 Subject: How to integrate some C++ classes in Python Message-ID: <38551E4D.B0D72D98@abo.fi> I need to use some of my C++ classes definition with the python interpreter in an embeded system, could you send me information about that. Thank you. From roy at popmail.med.nyu.edu Mon Dec 20 09:37:24 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Mon, 20 Dec 1999 09:37:24 -0500 Subject: Redirecting stderror to a browser References: Message-ID: NULL at my.pc wrote: > Using Python 4 CGI, I'd like to redirect the errors to the browser window, > so I get meaningfull errors rather than the typical "500 Internal server error". > I guess I could redirect it to a file, but seing immediately on the browser > would be much faster to work with. Assuming your server is on a unix machine, what I find works well for me is to open two windows to the server machine; one to edit my cgi code in, and another to run "tail -f error_log" in. The "-f" argument tells "tail" to keep watching the file to see if it grows and print stuff out as soon as it appears. The end result is that if my cgi produces anything on stderr, it instantly shows up in my 2nd window. -- Roy Smith New York University School of Medicine From skaller at maxtal.com.au Thu Dec 16 12:33:41 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 17 Dec 1999 04:33:41 +1100 Subject: List comprehensions Message-ID: <38592275.BBA2B61A@maxtal.com.au> What is the proposed syntax for list comprehensions? I have implemented: [ x + y for x in [1,2,3]] in Viper **. However, this is not very general, because it only allows a _single_ variable (x in the example). More precisely, you can have parallel variables like: [ x + y for x,y in [(1,2), (2,3), (3,4)]] but not products, that is, something like: [x+y for x in list1 for y in list2] ------------------------------------------------ Actually, a single 'for' is enough, provided you like functional combinators like: zip -- make a list of pairs from two equal length lists unzip -- make two lists from a list of pairs cross -- create a list of pairs of all elements from both lists etc -- other suitable list functors and their generalisations. Note that zip is already available -- zip(a,b) is just map(None, a,b) or something. But the idea of the syntax is to reduce the need for functional syntax. ---------------------------------------------------- ** Viper is now available for Un*x, the first alpha can be downloaded for evaluation (ONLY) from the temporary location ftp://ftp.cs.usyd.edu.au/jskaller/viper_2_0_a1.tar.gz You will need ocaml (caml.inria.fr) built with -pthreads, Gtk, readline, and, of course, Python. [There is a also a prebuilt binary for linux, but it may not run, since the python location is hard coded at /usr/local/lib/python1.5] -- 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 jens.arnfelt at get2net.dk Sun Dec 19 07:23:35 1999 From: jens.arnfelt at get2net.dk (Jens Arnfelt) Date: Sun, 19 Dec 1999 13:23:35 +0100 Subject: How do I read multipli bytes from file? Message-ID: 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 From wtanksle at hawking.armored.net Tue Dec 7 23:02:08 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 8 Dec 1999 04:02:08 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: On 7 Dec 1999 22:49:43 GMT, Neel Krishnaswami wrote: >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! They're also a big part of why it's ugly -- and I speak as a person who's long ago gotten over the parenthesis-phobia. >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. Forth does the same thing without punctuation of any kind -- a Forth program is merely a sequence of words. Any given word can look ahead in the input, pull words out, and stuff new words in. Many words can compile code as well as modify source. >Neel -- -William "Billy" Tanksley, in hoc signo hack From kent at tiamat.goathill.org Mon Dec 13 15:21:24 1999 From: kent at tiamat.goathill.org (Kent Polk) Date: 13 Dec 1999 20:21:24 GMT Subject: Weird threading problem under Solaris References: <82mi4u$nda$1@metro.ucc.usyd.edu.au> <384F92A6.E6D5282B@uk.sun.com> Message-ID: <945115163.639299@fezzik.endicor.com> On Thu, 09 Dec 1999 11:29:42 +0000, Gary Pennington wrote: >Hi, > >Stephen Norris wrote: > >> Are there any Solaris experts out there who know what this means? Anyone >> got any idea how to stop it? > >Python is masking signals and the OS can't deliver signals to the >appropriate LWP(thread)(s) (man _signotifywait for the full story). When I tried to compile Python for 64bit on Solaris 2.7 with threads, I ran into this type of situation. Python couldn't even start up as a result. I turned off optimization and the signals could be received. Don't know if this relates directly. From apederse at siving.hia.no Fri Dec 31 03:19:23 1999 From: apederse at siving.hia.no (Asle Pedersen) Date: Fri, 31 Dec 1999 09:19:23 +0100 Subject: MySQLdb problems References: <84ftnd$fpi$1@news06.btx.dtag.de> Message-ID: <84hotf$nni$1@snipp.uninett.no> I forward a reply from a similar message to yours on the group just a couple of days agoe. The reply was posted by Jeff Bauer, Rubicon Research (not posted to the group). -------------------------------------------------------------- Check out the starship: ftp starship.python.net cd /pub/crew/jbauer get mysql-python151-win32.zip This compiled version appears to work okay, but I don't use or support it. Grab the two files from the same ftp location: MySQL.pyd libmySQL.dll Place these files in your Python home directory. You may also want to replace your original python.exe and python15.dll from the distribution. --------------------------- I have not tried this yet but I think it will work. regards, Asle Pedersen Dominik Friedrich wrote in message news:84ftnd$fpi$1 at news06.btx.dtag.de... > i wanted to have a direct interface from python to mysql on WinNT without an > odbc driver, so i got the mysqldb package. when i tried to compile it i got > 9 warnings and the linker stoped with an internal error but the _mysql.pyd > was created. i copied this to the python dlls directory. when i try to > import it i get the error message: ImportError: DLL load failed with error > code 193 > what does it mean? can somebody help me to compile it correctly or give me a > compiled version for win32? > > Dominik Friedrich > > > From prestonlanders at my-deja.com Tue Dec 7 17:25:07 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Tue, 07 Dec 1999 22:25:07 GMT Subject: [disregard] Re: exchanging data btwn Python and lesser languages References: <82jau6$e72$1@nnrp1.deja.com> Message-ID: <82k1fv$voe$1@nnrp1.deja.com> Unless you're feeling particularly industrious today, you can disregard my message. In the interest of time, we've decided to go with an all- plain-text-to-files format that should be universally readable. Thanks to those who took the time to respond in email! ---Preston In article <82jau6$e72$1 at nnrp1.deja.com>, Preston Landers wrote: > 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. -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From see at my.sig Fri Dec 10 18:58:09 1999 From: see at my.sig (dg) Date: Fri, 10 Dec 1999 15:58:09 -0800 Subject: Tkinter/IDLE crash References: <82pkpk$3o0$1@mirv.unsw.edu.au> <82qvui$s5t$1@nnrp1.deja.com> Message-ID: In article <82qvui$s5t$1 at nnrp1.deja.com>, alex at magenta.com spoke thusly: > 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). 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. There is a slight pause, as if something is being loaded, but then I'm back at the command line with no app running. Could this be part of the problem you describe or is my setup wrong somehow (this behavior occurs immediately after installation). -- Don Groves (dgroves_ccwebster_net) Replace underscores to get my email address. From reic0024 at ub.d.umn.edu Sat Dec 4 11:50:45 1999 From: reic0024 at ub.d.umn.edu (Aaron J Reichow) Date: Sat, 4 Dec 1999 10:50:45 -0600 Subject: Problems using Opengl In-Reply-To: <38494049.B955743F@club-internet.fr> References: <38494049.B955743F@club-internet.fr> Message-ID: > 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. I had the very same problem, but did not look into why, as it wasn't a priority. But I know Mesa is working, and must be installed somewhat properly, as Q2 and Q3 work like a charm. Aaron From skaller at maxtal.com.au Thu Dec 16 15:30:10 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 17 Dec 1999 07:30:10 +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> <82pe7b$q76$1@nnrp1.deja.com> <38580410.B29EC285@maxtal.com.au> <8399kd$rj1$1@nnrp1.deja.com> Message-ID: <38594BD2.B576A1E@maxtal.com.au> Preston Landers wrote: > 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. [skaller} > > I don't agree: python is NOT inconsistent here. > I think we are talking about two different kinds of inconsistency. > 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, but there are ways to do this _other_ than by using inheritance. > 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? Simple: they're different concepts. It is unfortunate that 'OO' languages typically make the mistake of identifying them. It turns out this is completely wrong, and is the reason why OO doesn't work. I should be more precise: in most OO languages, a class is a construction that is used to declare a type. In static languages, class declarations specify types, which are _compile time_ concepts (only). This is not the case in dynamic languages, where the abstract notion of 'type' is distinct from, but represented by, actual type objects at run time: for example, in Python, there are TWO kinds of objects representing the 'type' abstraction: actual type objects, and classes. The latter can be constructed by the python programmer, whereas the former can only be constructed by the extension writer (or Guido :-) The 'inconsistency' I believe you are refering to is that there are two such 'type' representations at run time, and they have different properties: you can modify classes dynamically, and you can derived new classes, so that the class is 'really' the representation of the 'type' abstraction of the application programmer .. but when it comes to dictionaries, the abstraction has to be switched to type objects. This seems inconsistent to the programmer, right? > That is an implementation detail that interferes with the "purity" of OO > and tends to confuse people. Seems we agree so far... First, please excuse a digression: "purity" of OO is a bad thing, because OO doesn't work. It is good to support a familiar paradigm like OO, but it is also useful to support others as well. Python, for example, support procedural programming, and, to some extent, functional programming, as well as event driven programming (in some extensions like Tkinter), and it also supports generic programming (via both dynamism and also the 'protocols' API for sequences, etc). From my point of view, it is the 'protocols' feature which is Python's strongest point, not the OO (although I use that too). Now, to continue, lets examine the 'typeness' abstraction in more detail. Consider a sequence. The notion of sequence is a type abstraction of some kind. But it is NOT represented by a class, or by a type object. Why? Because OO doesn't work in general. What _does_ work is the notion of protocols: a set of functions operating on a set of types with particular behaviours, for example a sequence is characterised by having a length, and being able to get the i'th object of the sequence. So here's what happens in Python: the protocols are fixed by the language, and implemented by type objects.. ONE such protocol is the notion of 'object orientation': and it is represented by 'getattr' 'setattr' protocols, because 'objects in the OO sense' are characterised by having states which can be modified, usually via methods. Classes then are not 'types' in the fully abstract sense that protocols allow, but a special case. In Viper, type objects can be any object. What this means is that, unlike CPython, the 'virtual table' which supports protocols like 'sequence' and 'mapping' and 'class instance/object orientation' is not limited. [The cost, in the interpreter, is performance and robustness] In Viper, all the standard types ARE represented by type objects which are classes. But the instances of the objects are NOT instances of these classes. An 'integer' has a class for a type object, but that is a convenience to allow 'methods' to be defined for integers -- IN PYTHON (instead of C). [In other words, the 'type object' is a kind of attribute/method server for the instance] If I can put the model another way, there are TWO levels of indirection here: a class instance has a class which has a type, and the instance itself has a type: and the type of an instance is "PyInstance" and that of a class is "PyClass" and _neither_ represents the typeness of the instance from the application programmers point of view, instead, the class itself represents that. In CPython you cannot manipulate the type objects from python, in Viper you can, which opens up a whole lot of new, interesting things. For example, I have previously posted an example Viper is going to support (it doesn't yet). It is possible to define a class representing ListOfSomething where the 'Something' is bound when an instance is constructed: PyListOfInt = ListOfSomething(PyInt) and now, objects of type 'PyListOfInt' can be defined. These will be ordinary lists, except that even element is checked when it is put in the list, to make sure it is has type PyInt. This kind of flexibility is sometimes called 'metaprogramming'. And there is a vital theorem of metaprogramming: TWO levels of indirection are vital: you need the possibility that the type of something be an instance of another meta-type. Looked at another way: Pythons existing 'type' objects cannot be manipulated, whereas Viper's can, but in both cases, the fact that class objects themselves have a type, but are not themselves general types, is consequence of the fact that classes only implement ONE meta-programming protocol. I think the 'big' question is: 'can we uses classes for all type objects'? And I think the answer is NO, not in general. But, Viper shows, the converse is indeed possible: we _should_ be able to use classes for SOME type objects. So i don't think there is an inconsistency in CPython, so much as a lack of flexibility: there's no reason why type objects should themselves have a fixed type (namely TypeType). Summary: unifiying the notion of "type object" and "class" is a bad idea, but generalising the notion of type object so you can use a class AS a type object, seems to be an excellent idea: a class is a KIND of type object, but not the only possible one. If you want to have a look, you can download Viper from ftp://ftp.cs.usyd.edu.au/jskaller note that the 'ListOfSomething' cannot yet be made to work, because there is not yet a builtin function which is the equivalent to the 'new object' function in the new module. (that is, there is no way yet to create a raw object of a given type). -- 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 Alex.Martelli at think3.com Tue Dec 14 07:41:25 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Tue, 14 Dec 1999 13:41:25 +0100 Subject: CgiHttpServer workalike for Win/NT and Win/98? Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D31@pces.cadlab.it> 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...? (Worst case, I guess I can download PWS or thereabouts, but I liked the idea of a simple, minimal server in Python, easy to tweak and keep fully under control...:-). TIA, Alex From sendzimir at earthlink.net Tue Dec 28 07:54:05 1999 From: sendzimir at earthlink.net (Alexander Sendzimir) Date: Tue, 28 Dec 1999 12:54:05 GMT Subject: newbie question... Message-ID: <3868C1D2.614DA917@earthlink.net> According to David Beazley's invaluable book, mailbox.py is an undocumented module. However, since 1.5.1 of python this module has been modified. Does anyone know anything about this module? and where I might get information on the structure of unix mailboxes? It seems pretty simple. However...it never hurts to ask. THanks From sposhua at my.pc Wed Dec 22 08:41:39 1999 From: sposhua at my.pc (Sposhua) Date: Wed, 22 Dec 1999 13:41:39 +0000 Subject: os.popen() vs os.system() In-Reply-To: <19991222120612.B3554@stopcontact.palga.uucp> References: <19991222120612.B3554@stopcontact.palga.uucp> Message-ID: On Wed, 22 Dec 1999, Gerrit Holl wrote: > Sposhua wrote: > > a) popen automatically starts a new process while system only does it if you > > include an & > > Not true: > >>> os.getpid() > 3264 > >>> os.system("echo $$") > 3658 !? You are replying to a newbie here ;-) Didn't quite understand the answer... PS, thanks to all for the great responses from everyone *grovel,grovel* up to now. Hopefully this (coupled with my trusty book & tutorials) will eventually elevate me from my current newbie status so I can actually help out in here. Basically all my questions are more "WhyTo"s rather than "HowTo"s, does that make them more challenging? ;-) From aahz at netcom.com Fri Dec 17 09:57:26 1999 From: aahz at netcom.com (Aahz Maruch) Date: 17 Dec 1999 14:57:26 GMT Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> Message-ID: <83dj0m$ej1$1@nntp3.atl.mindspring.net> In article <6D8A17398E28D3119F860090274DD7DB4B3D51 at pces.cadlab.it>, Alex Martelli wrote: > >Would this also apply, to a weaker but broader extent, to the lack of >assigning-operators, an "expression" kind of assignment, increment and >decrement in particolar, or other issues of the expression/statement >split? Yes and no. I am, on the whole, very happy with the way Python absolutely does not allow assignments in conditions. Increment and decrement would be useful, but not if it would break the expression/statement split. I think you'll find that very few long-term Pythonistas see this as an issue. > while 1: > line = inp.readline() > if not line: > break > oup.write(regex.sub(repl,line)) > >and wonder that *FOUR*-count-em lines of this function, fully half of >it, are devoted to the trivial, frequent, repetitive task of looping >over input lines, reading each one, bailing out when done. Yeah, I >know I could have written the break on the same line as the if, but >that's considered bad Python style:_) > >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. Because the current consensus is that eventually you will be able to write for line in inp.readline(): In fact, if you're willing to take a chance on memory usage, you can already do for line in inp.readlines(): Fredrik already showed you another module that you can use; finally, you can try using QIO to make up for Python's deficiencies in line-by-line file IO. -- --- 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 thomas at bibsyst.no Thu Dec 16 08:30:24 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Thu, 16 Dec 1999 14:30:24 +0100 Subject: Size of files in human, readable form Message-ID: <3858E970.4D5BC77@bibsyst.no> Hi, 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. Tanx. Tw. From mlh at vier.idi.ntnu.no Wed Dec 8 09:57:26 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 08 Dec 1999 15:57:26 +0100 Subject: JPython - Problems using "re" References: <82lh78$12h$1@rairidh.dcs.ed.ac.uk> Message-ID: sdm at dcs.ed.ac.uk (Stephen McColl) writes: > hi there, > [...] > > But in JPython, (JPython 1.1 beta 4), "findall" isn't a method in the "re" module. > Is there another way to produce the same result (scan a string and return a list of > all matches)? Use a while-loop... import re p = re.compile("(pattern)") t = "this text contains the pattern several times (pattern pattern)" pos = 0 result = [] m = p.search(t,pos) while m: g = m.groups() if len(g) == 1: result.append(g[0]) else: result.append(g) pos = m.end() m = p.search(t,pos) print result > Thanks for any help in advance. > > stephen. > > -- > _________________________________________ > stephen mccoll sdm at dcs.ed.ac.uk > 4th Year Computer Science, Edinburgh University > -- -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From ivnowa at hvision.nl Sat Dec 4 16:52:47 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Sat, 4 Dec 1999 22:52:47 +0100 Subject: Tkinter question: image on canvas In-Reply-To: <199912042118.WAA05461@axil.hvision.nl> Message-ID: <199912042152.WAA06070@axil.hvision.nl> OK, replying to my own message... I think I found the problem. A typical case of "duh"... > > -----------begin code--------- > > from Tkinter import * > > class MemoryFrame (Frame): > . > . > def createImage(self): > img = PhotoImage(file="c:/001.gif") > print img > id = self.canvas.create_image(40, 40, image=img, anchor=NW) > print id This creates an image, and stores the only reference to the PhotoImage instance as a local variable. In other words, it will be destroyed as soon as the end of this method is reached. No wonder it doesn't display the image... =/ My other program didn't have this problem since it stored all images nicely in a dictionary. Duh-ly yours, --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 nobody at nonet.net Tue Dec 14 03:53:14 1999 From: nobody at nonet.net (martin) Date: Tue, 14 Dec 99 08:53:14 GMT Subject: Lists of lists over COM, how? Message-ID: Hi, I'd like to return a set of database records to Python in a single variable from a COM object in C++ and had hoped I could use a two-dimensional VARIANT array for this. Looking through the SafeArray* functions in the WIN API they only allow arrays of a single basic type. I had hoped that a list of lists with mixed data types would correspond to some variant array (since there are both numbers and strings in these records). Anyone knows? --Martin From mhammond at skippinet.com.au Mon Dec 6 05:55:44 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 06 Dec 1999 10:55:44 GMT Subject: Exposing COM via XML-RPC or Something Else References: <1267780385-12582932@hypernet.com> Message-ID: Samuel A. Falvo II wrote in message ... >In article , Samuel A. Falvo II >wrote: > >>>Please do battle with IDispatch - languages that already work with COM will >>>be much simpler to move to your Linux work if you do stick with this. Perl, > >You know what? In retrospect, I just realized that you wanted me to use >IDispatch instead of creating my own interface. My apologies for >misunderstanding your post. :-) My apologies for the ambiguity :-) >Where can I find the interface spec for IDispatch? I haven't found it on >Microsoft's site yet, but I'll keep looking. I found is at: http://msdn.microsoft.com/isapi/msdnlib2.idc?theURL=/library/wcedoc/wcesdkr/ ki_de_12.htm (good luck at getting that URL into your browser :-) Also look at IDispatchEx() - targetted more for "dynamic" objects. Much later, for arbitary scripting you could consider the Active Scripting interfaces. Like IDispatch, you may not agree 100% with the design, but it does exist, and therefore existing code may be usable - as opposed to inventing your own interfaces, and _forcing_ everyone to start from scratch! Mark, From alex at magenta.com Sun Dec 26 03:58:06 1999 From: alex at magenta.com (Alex Martelli) Date: Sun, 26 Dec 1999 09:58:06 +0100 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <38656610.E4DA287B@maxtal.com.au> Message-ID: <006b01bf4f7f$b3dfe920$bf2b2bc1@martelli> Neel Krishnaswami writes: > skaller wrote: > >Alex Martelli wrote: > > > >> 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! > > This is a failure of data structure, not of syntax. What's needed > is a way to write > > for foo in file.readlines(): > ... > > without allocating an entire list. IOW, we want to write: > > for foo in file.xreadlines(): That would put the burden on the implementor of the "file" object; in other words, on the implementor of every object that provides an "enumerating" method, i.e. one "returning the next element". For my original problem, I switched to file.readlines(), because having the whole block of lines around made other things much easier (recursive expansion of conditional and loop statements embedded in the template, to be precise). But, the road to one solution in present-day Python was also pretty clear from some of the responses I had received (Tim's and the effbot's, most of all). "for foo in bar:" internally expands to calls on bar.__getitem__(i), with i starting at 0 and working upwards, and terminating when __getitem__ raises IndexError. So, all we need is to implement that in a wrapper class. Taking a simple case, where we now write: while 1: item = container.nextitem() if not item: break # process item and we'd LIKE to write, say: while item from container.nextitem(): # process item we can ALREADY write: for item in enum(container.nextitem) # process item as long as we have: class enum: def __init__(self,stepper): self.stepper=stepper def __getitem__(self,key): item=self.stepper() if not item: raise IndexError return item I have asked on this list whether this kind of wrapper could present some gotchas, e.g. in performance, but got no answer, which is promising:-). In a more general case, we might want to pass to the "stepper" methods some arguments, or to subject items to some other test than Python's "boolean truth". A natural approach might be to have enum's __init__ take more (optional) arguments, to wit, the tuple of args to pass to stepper (with apply, of course) and the "tester" function. This might be ok, or it might increase overhead in the simple case since each __getitem__ would test what testing it could apply. A simple alternative would be a C++-like "factory and virtual functions beat repeated tests every day" idiom: -- rename class enum to enum0, -- add a class enum1: class enum: def __init__(self,stepper,tester): self.stepper=stepper self.tester=tester def __getitem__(self,key): item=self.stepper() if not self.tester(item): raise IndexError return item and make of enum itself a factory function: def enum(stepper,tester=None): if tester: return enum1(stepper,tester) else: return enum0(stepper) with the obvious generalization, if needed, to other optional arguments such as tuples (and/or kw-args dictionaries) to apply to the stepper and/or tester methods, etc (if apply has no substantial overhead wrt a direct call, then it would do just as well to use it all the time, I guess; not tested or measured, yet). > just like we currently write > > for i in xrange(100): > ... > > So the hypothetical xreadlines() method should return an object > that reads one additional line from the file each time it is called. Right; but it need not be hypothetical, see above. > 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 The iteration protocol implemented above seems good enough to me -- even though I was the one first expressing concern on this thread. Maybe putting this 'enum' thingy in the standard distribution (maybe in some example) would help. That's part of what I love about Python... it's sharp and limpid enough that a newbie like me can come up with interesting solutions such as this one, even without a deep understanding of the internals. It just takes a few days' reflection (I hope it will go down as I move from 'newbie' to 'reasonably skilled Pythonista', of course:-). > > 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] > > .. > > In Cpython, there is the items() method on dictionaries, > so you can write: > > for key, val in dict.items() > ... > > There's nothing like it for tuples and lists, but that should be > fixed. What about just adding a few lines of code to an example...: class seqenum: def __init__(self,sequence): self.sequence=sequence def __getitem__(self,key): return (key,self.sequence[key]) That's even simpler than the 'enum0' above (the sequence itself will raise the IndexError when the time comes to do so...:-). > As a general rule, syntax is a bad thing, to be avoided whenever > possible. Calls for additional syntax are typically a sign that > one of the basic operations of the semantics needs generalization. Or that one has not thought about things enough to realize that the desired semantics already _are_ there, and may just need a few lines' worth of wrapper code for syntax sugar?-) > Additional syntax adds cruft that makes that generalization doubly > harder to see. One, the immediate sop silences the people being > bothered, so you won't think any more about the problem until it crops > up again in a seemingly-different context. Two, adding special syntax > makes it harder to build the appropriate generalization, because the > special syntax reduces the regularity of the language. Good point. So, we need some *inertia* in changing a language's definition -- at least enough to make sure that the solution space possible within a given language IS well explored, before coming to the determination that the language needs extension. Fortunately, we have it -- and maybe we have a deeper explanation for Guido's apparent stonewalling about language changes...?-) Alex From ionel at psy.uva.nl Sat Dec 11 15:16:07 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Sat, 11 Dec 1999 21:16:07 +0100 Subject: DB-API-oriented example scripts? References: <199912100620.AAA22933@dolphin.mojam.com> <82r1vg$tt3$1@nnrp1.deja.com> Message-ID: <82ubgk$u3@mail.psy.uva.nl> | In article <199912100620.AAA22933 at dolphin.mojam.com>, | skip at mojam.com (Skip Montanaro) wrote: | > | > Are there any good examples of how to use this API available? I saw a | > reference to a Linux Journal article on the db sig's page which I | > will take a look at. I saw nothing that looked like pointers to example code | > in the Vaults of Parnassus. | > | > Any suggestions? Extensive examples of using the Python DB API for SQL databases come with Gadfly (Aaron Watters (Chordate Systems)). One can get started reading the page at: http://www.chordate.com/kwParsing/gadfly.html For more insight one might download Gadfly and inspect the demo/testing files. I personally found the examples quite clear and useful. I guess that nobody documented the DB API more extensively because the Python layer is such a thin wrapper over SQL. ionel From bsb at winnegan.de Sun Dec 26 04:46:36 1999 From: bsb at winnegan.de (Siggy Brentrup) Date: 26 Dec 1999 10:46:36 +0100 Subject: Newbie Tkinter Problem In-Reply-To: "Colleen & Brian Smith"'s message of "Sat, 25 Dec 1999 19:48:46 -0800" References: Message-ID: <87puvut4oz.fsf@baal.winnegan.de> "Colleen & Brian Smith" writes: > In the script below, when I hard-code the file name, the button > works fine. However, when I use the askopenfilename dialog, > something is preventing the button from working normally. If > somebody could point out where I'm going wrong, I'd sure appreciate > it. 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 irv at ellijay.com Tue Dec 7 14:38:10 1999 From: irv at ellijay.com (Irv Mullins) Date: Tue, 7 Dec 1999 14:38:10 -0500 Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> Message-ID: <384d60e4.0@news3.paonline.com> wrote in message news:828n3e$8kp$1 at 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). Heh... I think the folks on that other newsgroup don't bother to read the questions, just trot out the flames automatically. Come to think of it, how much intellect does it take to repeatly post "RTFM! $%#", anyway. Maybe they're just 'bots. Irv From fredrik at pythonware.com Sat Dec 4 05:40:45 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 4 Dec 1999 11:40:45 +0100 Subject: 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: <021901bf3e44$068941a0$f29b12c2@secret.pythonware.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... now that the 1.0 specification is out [1] [2], I'm pretty confident that there will be lots of implementations out there real soon now. on the other hand, why not use XML-RPC today, and switch to SOAP when code becomes available? > I do agree with you that SOAP would address my problem, > AND I WILL LOOK INTO DOING A PYTHON IMPLIMENTATION or you can wait for us to finish our implemenation (we wrote Python's highly popular XML-RPC library, and plan to add SOAP support in early 2000). on the other hand, if you have the time and energy, go ahead. competition is good ! 1) http://www.pythonware.com/madscientist/draft-box-http-soap-01.txt 2) http://www.newsalert.com/bin/story?StoryId=Coenz0bWbu0znmdKXqq&FQ=Secret+Labs+AB From fredrik at pythonware.com Wed Dec 8 11:07:50 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 8 Dec 1999 17:07:50 +0100 Subject: ANN: grassi python 3.0 References: <000101bf4150$44b895c0$5aa2143f@tim> Message-ID: <02de01bf4196$622428e0$f29b12c2@secret.pythonware.com> Tim Peters wrote: > 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): dan's problem was that if the script that attempts to import the module contains a syntax error, python prints a SyntaxError message to stderr and dies: import fatalsToBrowser imprt spellchcker the obvious solution is of course to run (or compile) the scripts before uploading them to the server, but dan didn't accept that... (on the other hand, you can always add something like this to sitecustomize, to make sure you get HTML formatted error messages for all Python programs...) From neelk at brick.cswv.com Wed Dec 29 21:40:46 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 30 Dec 1999 02:40:46 GMT Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> <38687D6A.D525D91F@prescod.net> <14440.49939.489193.842560@dolphin.mojam.com> <38693545.894CE515@prescod.net> Message-ID: Paul Prescod wrote: > > I'm saying that we could expose the fallback mechanism so that an object > could be instructed to fallback to another object. Do you mean that you want to make Python's object system prototype based, a la Self & Cecil? (In those languages, instead of having base classes, an object has /parents/, which are other objects which are searched when a lookup in the object fails and so on recursively. There are no distinguished classes -- everything is an object. I am told Javascript is also prototype-based, but I don't know it.) I believe you can get what you want with metaclasses right now, but they are unpleasantly difficult to write. (The concept isn't that hard imo, it's just that Python makes you jump through hoops to play with it. Compare to Smalltalk, where subclassing Class is dead easy.) In the short run, the two things that you need to make this easy are to allow the __bases__ lookup to use any object that satisfies the sequence protocol, rather than necessarily a tuple. Add to that __dict__ attributes that are arbitrary mappings rather than actual dictionaries, and you're cooking with gas. (If you read Guido's metaclass essay, you'll see that all the work he goes through are to enable these two little changes.) There's precedent for this -- in 1.5.2 Python changed so that you can assign a new __bases__ tuple to a class at runtime, whereas in 1.5.1 it was fixed for a class. In the slightly longer run, there's a need to figure out what the instance and class protocols are, exactly, and then expose the mechanism to the user. In Smalltalk, the difference between class and instance is substantially a matter of convention (if one the compiler knows about too). It would be nice if Python could move in the same direction, IMO. Neel From Alex.Martelli at think3.com Mon Dec 27 03:16:08 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Mon, 27 Dec 1999 09:16:08 +0100 Subject: "sins" (aka, acknowledged language problems) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D81@pces.cadlab.it> Bijan Parsia writes: > So, you could just use 'for' with the added notion that providing two > variables gives you the index in the first one. > > As I recall, this didn't lead to any confusion in NS. > > I don't know if this conflicts with already legal Python. But it seems > much preferable than a different keyword. > It would indeed conflict -- "for x, y in e" already has a useful meaning when e is a sequence of tuples, as it unpacks each tuple into x and y variables. I agree that piling keywords on top of each other is not the best of ideas; I would much prefer a syntax such as for x,y in somebuiltinfunction(e): ... where "somebuiltinfunction" would turn the existing sequence e into a virtual sequence of key-value pairs. This has the added advantage that, until "somebuiltinfunction" does get added to Python, you can easily write it as a wrapper (see my previous posts in this thread), already today. For mappings, the "items" method already works this way: for key,value in mydictionary.items(): ... except that it's uncertain whether its implementation needs space to store all of the list of key-value pairs (I guess it must), rather than just one at a time. So, the hypothetical new built-in function might work on mappings too, giving the same service as today's ".items", but in a possibly memory-optimized way working only in a "for" iteration rather than when a list-of-items is needed in general. As the name for "somebuiltinfunction", I personally like "enum" (because I think of this as "enumeration idioms"), but I realize this badly conflicts with the use of "enum" in C or C++. Thus, something like "iterator", "sequencer", "itemizator", or abbreviations thereof, might be deemed to be preferable to "enumerator" or abbreviations of it. I'm _not_ at all stuck on this level of syntactic sugar...:-). Alex From doughellmann at home.com Mon Dec 13 07:35:05 1999 From: doughellmann at home.com (Doug Hellmann) Date: Mon, 13 Dec 1999 12:35:05 GMT Subject: Need help with Tkinter for dynamic # of objects References: <831ov7$ap$1@bmerhc5e.ca.nortel.com> Message-ID: <3854E95B.61EB76C@home.com> It looks like you are trying to use a list to store the buttons after they are created. You need to create a list before you can insert anything into it. Try this: self.set_of_buttons = [] for n in range(m): self.set_of_buttons.append(Tkinter.Button(self)) Doug Donald Parker wrote: > > 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 tseaver at starbase.neosoft.com Thu Dec 23 13:37:57 1999 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 23 Dec 1999 18:37:57 GMT Subject: Sydney scoreboard? References: <385DB48C.7A7A52D6@bby.com.au> <3dk8m6zsxd.fsf@amarok.cnri.reston.va.us> Message-ID: In article <3dk8m6zsxd.fsf at amarok.cnri.reston.va.us>, Andrew M. Kuchling wrote: >Timothy Docker writes: >> Does that include setting the scoreboard on fire ? :-) I remember this >> happening sometime last season. >> Presumably this was not a software failure, but it brings a more >> concrete meaning to software "crash and burn". > >Now, now, let's not flame Mark over this... Perhaps this resulted from >burning too many cycles in unoptimized code. Or simply using 'signed >char'? Obviously "singed char" was the offending type. :) where-there's-smoke'ly, Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From phresh at aol.com Fri Dec 3 21:16:15 1999 From: phresh at aol.com (phresh at aol.com) Date: 4 Dec 1999 02:16:15 GMT Subject: Get Paid While You Surf the Web! 3977 Message-ID: <829thf$8p2$7247@bgtnsc03.worldnet.att.net> Get paid to surf the web! http://www.alladvantage.com/home.asp?refid=FCJ475 vgk From aa8vb at yahoo.com Thu Dec 30 06:55:16 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 30 Dec 1999 06:55:16 -0500 Subject: FINANCIAL MODELLING PACKAGE IN PYTHON? In-Reply-To: <387f6d37.25522789@news.demon.co.uk> References: <841d0c$j0n$1@violet.singnet.com.sg> <387f6d37.25522789@news.demon.co.uk> Message-ID: <19991230065516.A778039@vislab.epa.gov> Andy Robinson: |Anyone who wants to discuss this, come join the python-finance list at |www.egroups.com/group/python-finance/. It's been a bit quiet of late |but that's where my stuff and Kevin's is being discussed.. Will do. You ought to get the list sited on: http://www.python.org/psa/MailingLists.html This is the first I'd heard of it. -- Randall Hopper aa8vb at yahoo.com From tim_one at email.msn.com Fri Dec 17 03:27:15 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 17 Dec 1999 03:27:15 -0500 Subject: Python complaints In-Reply-To: <3858C226.949FC9C6@udel.edu> Message-ID: <001e01bf4868$86c32d80$63a2143f@tim> [Charles Boncelet] > ... > If Python is a typeless language, then shouldn't all functions > make a reasonable effort at promotion to try to do something > reasonable? 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. A fellow at work was trying to debug a piece of Perl that had this subexpression: len(@a) Perl tries very hard to do something reasonable: first it sees an array in scalar context, so says "OK, I'll return the length of the array!". Then len() sees the length, which is an integer, and says "Hey, I don't know how to do that! So I'll coerce the integer to something I *do* know how to take the length of -- a string!". So his array with 1,000-some elements returned 4 (1234 -> "1234" -> a string of length 4). There are no similar msgs about Python promotion surprises over on comp.lang.perl.misc . > (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. > 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. 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 From khowe at performance-net.com Mon Dec 6 17:20:18 1999 From: khowe at performance-net.com (Kevin Howe) Date: Mon, 6 Dec 1999 18:20:18 -0400 Subject: Looking for Python Developers in Nova Scotia, Canada Message-ID: Performance.net Strategic Internet Solutions (www.performance-net.com) is seeking Python Developers in the area of Nova Scotia, Canada for involvement in creating a Python wrapper/interface for our Credit Card Payment System's Java-Based Thin-Client. If interested, please contact Kevin Howe at khowe at performance-net.com. Best Regards, Kevin Howe, VP of Operations Performance.net Strategic Internet Solutions From ionel at psy.uva.nl Wed Dec 1 14:09:03 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Wed, 1 Dec 1999 20:09:03 +0100 Subject: wish: multiline comments References: Message-ID: <823rr5$gi1@mail.psy.uva.nl> Oleg Broytmann wrote in message news:Pine.LNX.4.21.9912011413580.21623-100000 at fep132.fep.ru... | 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"! :) I'd call them "anonymous strings". I knew them as a method to include comments, but still don't know how they are dealt with by the parser. I avoid using them because I fear they make it into the pseudo code, cluttering it. ionel From fdrake at acm.org Thu Dec 23 15:00:00 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 23 Dec 1999 15:00:00 -0500 (EST) Subject: __init__ keyword param for sub-class? In-Reply-To: References: <14434.30055.405044.204758@weyr.cnri.reston.va.us> Message-ID: <14434.32576.62080.865071@weyr.cnri.reston.va.us> Grant Edwards writes: > In Python is it considered good practice for methods/functions > to complain about unrecognized keyword options, or are they > generally just ignored? I'd say that in the "normal" case, where the keywords are named in the function signature rather than accepted as **kw, the names are checked. It is an error to pass a keyword arg that isn't used: >>> def func(abc=0): pass ... >>> func(bar=2) Traceback (innermost last): File "", line 1, in ? TypeError: unexpected keyword argument: bar > One thing I miss from having used Smalltalk is some general way > to refer to the superclass. Having a method specify the > superclass explicitly hampers reuse (at least in theory), and > seems a bit more fragile. I've read that picky a superclass > method would get sticky in a multiple inheritence system, but That's right; for: class A: def aMethod(self): pass class B: def aMethod(self): pass class C(A, B): def aMethod(self): super.aMethod() 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. 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*; something like "super" isn't even an unreasonable variable name (it's either a boolean or a SuperHero instance, right? ;). > the same issue comes up with overlapping superclass methods > that the subclass doesn't override. Right? So, I don't know > why we couldn't use the same mechanism to pick > Super.methodName() that would be used to do self.methodName() > when methodName isn't overridden. Ah, I should have read farther. I think the biggest problem is the introduction of additional keywords; I don't see a good way to get around that in 1.x. Perhaps this should be discussed as a 2.0 feature? It's certainly requested a lot, and with good reason. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From wtanksle at hawking.armored.net Mon Dec 27 21:05:59 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 28 Dec 1999 02:05:59 GMT Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D83@pces.cadlab.it> <3867CA1E.360E3B0E@maxtal.com.au> <00d701bf50c2$1b9832a0$c02b2bc1@martelli> Message-ID: On Tue, 28 Dec 1999 00:27:13 +0100, Alex Martelli wrote: >John Skaller writes: [talking about the Python equivalent of C's ?:] >But the more we talk about it, the more readable >it becomes -- because the general acquaintance Urgh. I think it's vile and nasty. I hope nobody ever ever uses it. It does NOT say what it means. Unlike myself :). >> shadowing generates an error may have some >> advantages, but it also has disadvantages too: >> hiding supports 'cut and paste'. >And this is bad because...? >The "cut and paste" style of "code re-use" is a >blight (and I've done enough code inspections >of allegedly "production" code, and code built >by pretty brilliant people too, to make me >_very_ arrogantly sure of this specific issue:-). The fact that it's so common implies something about it. >If Java's "no hiding" rule really discourages it >(and I'm not sure it does -- somebody is sure, >alas!, to invent some "smart editor" that will >rename local variables on the fly as you paste >the code...!-), then I would count that as a >pretty major advantage. I'm not sure that discouraging it is the right approach -- I think that making it unneeded is better. OO gave a start at that; Aspect Orientation makes another dent in the problem (www.aspectj.com). And BTW, there is already a program which handles variable renaming -- although not for the purpose of copy'n'paste, but rather for cut'n'paste (so you can move methods and variables from one class to another). Right now the only fully functional refactoring browser is for Smalltalk, but Java's time will come. >> 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). >I'll pass on this. I think the record for "most >work done in fewest lines" is still with bad old >APL, at least for the kind of jobs it handled >best. And, of course, right with it goes the record >for "most non-intentionally obfuscated code":-). It's a good language. I hate that character set, but even it has its uses. >> > If the wrappers are standardized, readability is no >> > problem. >> Most people think highly bracketted expressions >> are unreadable (eg LISP :-) >Yep, with the exception of rabid LISP'ers. Unreadable is an exaggeration. Harder than it should be ... yes. I like Lisp, though. >Would you thereby argue that the utter lack >of brackets in FORTH makes it the MOST >readable language? No, but I would argue that it makes it more convenient to read than a fully bracketed language (such as Lisp). >Or, is it an issue of striking a happy medium? Naw. It's about having a syntax, semantics, and set of conventions which fit well together. Lisp has a decent combo, so long as you ignore the parens. Rebol has a nice combo as well, as long as your lines are reasonably short (which implies a greater use of variables). And so on. >> > > 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. :-( >The only language I've used extensively, where function >calling does not require parentheses, is the 4-letter >language above alluded to, which shall here remain >nameless. (Well, and Forth, too, but "that was in >another country", and, besides, the machine I ran >_that_ on is dead). I must say that the usage one >finds there does not particularly argue for the lack >of parentheses enhancing readability, but that is >perhaps not a fair test-bed for such a quality:-). Forth and Rebol both actively minimize parentheses. Both are highly readable, assuming that one follows the basic conventions set up by the community. >Alex -- -William "Billy" Tanksley, in hoc signo hack From malcolmt at smart.net.au Fri Dec 17 19:37:57 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Sat, 18 Dec 1999 11:37:57 +1100 Subject: Python on NT systems (help a Unix guy, please) Message-ID: <19991218113757.A637@Ridcully.home> I recently protyped a program in Python that is destined to run on a Windows NT box. As usual, the Python version runs well enough that I have no real wish to rewrite it in C. So all that remains is to convince the owner of the NT box to install Python on his machine. The problem: disk space is a little tight on the target machine. Since I don't have any Windows machines at home at the moment, could somebody please let me know (just roughly) the disk space requirements for Python on NT? (private email is ok if you don't want to spam the list). Just for comparison purposes, a reasonably standard Python install on my Linux box (the only additional thing is the LLNL Numeric package) takes up just under 24MB, the requirements for tkinter is another 5.5MB with wxPython (source code and all) being 18MB (plus whatever wxWindows requires). Thanks in advance, Malcolm Tredinnick -- Despite the high cost of living, have you noticed how popular it remains? From Richard.Jones at fulcrum.com.au Wed Dec 15 18:11:12 1999 From: Richard.Jones at fulcrum.com.au (Richard Jones) Date: Thu, 16 Dec 1999 10:11:12 +1100 Subject: Calling C functions (libs) from Python In-Reply-To: Message from G. David Kuhlman of 1999-Dec-16 0:5:40, <839ack$m5m$1@nntp2.atl.mindspring.net> Message-ID: <199912152311.KAA08438@envy.fulcrum.com.au> [G. David Kuhlman] > Eugene Akovantsev (aei at ic.vrn.ru) wrote: > > How i can call external C functions from Python? I don't have > > sources, only *.h and *.lib files. > > > > Take a look at calldll. If I understand correctly, it does what you > want. Go to: > > http://www.nightmare.com/software.html > > and search for "calldll". An alternative is Minotaur, http://mini.net/pub/ts2/minotaur.html Richard From mhammond at skippinet.com.au Tue Dec 14 08:10:40 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 14 Dec 1999 13:10:40 GMT Subject: Declaring COM-interfaces in Python? References: <38562ebd.0@pandora.research.kpn.com> Message-ID: [posted and mailed] Richard Smol wrote in message <38562ebd.0 at pandora.research.kpn.com>... >Hi there, > >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... Mark. From robin at alldunn.com Wed Dec 29 02:59:01 1999 From: robin at alldunn.com (Robin Dunn) Date: Tue, 28 Dec 1999 23:59:01 -0800 Subject: wxPython References: <84c8au$6ia$1@nnrp1.deja.com> Message-ID: "trosen" wrote in message news:84c8au$6ia$1 at nnrp1.deja.com... > Does anyone know how to make boxes that you can click on and drag to a > different size using wxPython? Is it possible? For example, I create a > box of a particular size in a window. I want to change the length of > the box, so I click on one side of the box, and drag it to make it > larger. > Set handlers for the mouse events, when the mouse starts dragging check if the position is the same as one side of the box, if so redraw the box at the new position and size, following the mouse until the button is released. You might also want to look at the OGL library. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From sanderson at ttm.com Wed Dec 29 15:56:06 1999 From: sanderson at ttm.com (Scott Anderson) Date: Wed, 29 Dec 1999 15:56:06 -0500 Subject: newbie question... References: Message-ID: <386A7566.498AFEE3@ttm.com> Personally, I use Hungarian notation no matter what the language. The scoping and types stand out immediately... something that doesn't happen without some sort of standard notation. One example of this (IMO) is the PyGreSQL module. Some of that code is difficult to follow, being filled with one letter variable names and the like. Hungarian notation is particularly useful in dynamically typed languages like Python, although I have made a habit of using it everywhere. Incidentally, I've never worked for Microsoft, and the only Microsoft environment I've ever used was VB. Regards, -scott bitbucket at isomedia.com wrote: > > How did you know I learned my Python while at Microsoft? [...] > > And am I making enemies of you all with my silly variable names (the > trashed-hungarian notation)? That comes from 2 years (I wish it had > been less) of being forced to do ASP with VBScript. I didn't feel I > could trust the VBScript interpreter to do a thing right for me with > the types. From fdrake at acm.org Thu Dec 2 17:32:13 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 2 Dec 1999 17:32:13 -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: <14406.62317.911664.553279@weyr.cnri.reston.va.us> I presume you are aware of the Types-SIG? It appears to be defunct. If anyone is interested in seriously persuing this topic, you may want to grab hold of the SIG before it's deactivated. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From malraux at my-deja.com Tue Dec 28 12:13:09 1999 From: malraux at my-deja.com (Scott Anderson) Date: Tue, 28 Dec 1999 09:13:09 -0800 Subject: Equivalent to (a ? b : c) ? Message-ID: Spam detection software, running on the system "albatross.python.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Heh, cute. However, I would imagine that the overhead of tuple creation probably isn't worth the trouble. Regards, [...] Content analysis details: (6.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 4.2 MSGID_SPAM_CAPS Spam tool Message-Id: (caps variant) 2.0 FH_DATE_IS_19XX The date is not 19xx. -------------- next part -------------- An embedded message was scrubbed... From: "Scott Anderson" Subject: RE: Equivalent to (a ? b : c) ? Date: Tue, 28 Dec 1999 09:13:09 -0800 Size: 1964 URL: From hartmut at oberon.noris.de Sat Dec 11 17:31:39 1999 From: hartmut at oberon.noris.de (hartmut Goebel) Date: Sat, 11 Dec 1999 23:31:39 +0100 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> Message-ID: <16600277@oberon.noris.de> Skip Montanaro (skip at mojam.com) schrieb: >Referring to > > "a %(x)s b %(y)s" % locals() >and > "a %(x)s b %(y)s" % obj.__dict__ > >Hartmut asks: > > How efficient is this? > >Efficient enough. ;-) Oh, I should have been more verbose: Beening brand new to Python, I may miss some information yet :-) But I suppose, local() generates a new tuple. This may be quite unefficient. >You have to count format >elements from the beginning of the format string to the point at which you >want the new % thingie, then do the same in the tuple of substitution >values. An error-prone exercise, to be sure, especially if the values are >more complex (function calls with multiple arguments, yadda, yadda, yadda). Sure, that's why I'm pretty happy to have this "interpolate" feature right now :-) >Skip Montanaro | http://www.mojam.com/ +++hartmut From skip at mojam.com Fri Dec 10 11:31:20 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 10 Dec 1999 10:31:20 -0600 (CST) Subject: Any web automation modules? In-Reply-To: References: Message-ID: <14417.10968.24967.299348@dolphin.mojam.com> John> Is there any modules for getting web pages? Lynx has a simple John> switch but I do not know how to send user and passwords. I am a John> complete newbie to python. You can use urllib to fetch individual pages like: import urllib f = urllib.urlopen("http://www.python.org/") page = f.read() f.close() If you need to transfer an entire group of pages, check out websucker.py in the Python distribution tree at Tools/webchecker/websucker.py. 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 Thu Dec 16 10:00:51 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 16 Dec 1999 08:00:51 -0700 Subject: Python complaints References: <3858C226.949FC9C6@udel.edu> Message-ID: <3858FEA3.E593F38C@callware.com> Hi All-- Charles Boncelet wrote: > [bobbitt] > What kind of number is allowed? Can x be an integer, a float, complex, > long, hex? There is no way to know, without doing the experiment. > BTW, experimentation indicates that it fails if x is complex and works > for the others. sin seems to be promoting its argument to a float and > taking the sine. However, sin(complex) is a perfectly good mathematical > operation. It should work. > Use import cmath and s=cmath.sin(c) All of the standard math functions that live in math.py have correspondent functions in cmath.py. Metta, 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 jamarijr at hotmail.com Tue Dec 7 07:55:42 1999 From: jamarijr at hotmail.com (Arinte) Date: Tue, 07 Dec 1999 12:55:42 GMT Subject: Help need with tuples??? Message-ID: <82j04d$62g$1@nnrp1.deja.com> This is the third time I have posted this, but since I have gotten no replies I assume my other stuff wasn't clear enuff or there is a problem with python on my machine. I am in the process of moving to a win98 machine for testing instead of NT. Anywho, I have narrowed my problem down a bit. 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="" argvalue=0 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 Sorry, if this is a double posting, use deja instead of (could be private) company newsgroup. Sent via Deja.com http://www.deja.com/ Before you buy. From aa8vb at yahoo.com Thu Dec 2 16:40:10 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 2 Dec 1999 16:40:10 -0500 Subject: "for k in keys().sort()" -- Beyond the FAQ Message-ID: <19991202164009.A2121538@vislab.epa.gov> I read the FAQ, and while it makes sense, Python's normal bevity leaves me wondering why I can't do: --------------------------------- for key in sort( dict.keys() ) ... --------------------------------- rather than use 3 lines of slightly less clear: --------------------------------- keys = dict.keys() keys.sort() for key in keys: ... --------------------------------- Is there no built-in sort function that operates on a sequence and produces a new list? If you want this behavior, do you need to define your own sort function: def sort(l): l2 = l[:]; l2.sort(); return l2 for key in sort( dict.keys() ): ... ...or is there one lying around in the standard libraries? A shallow copy is just fine. Any insights appreciated. -- Randall Hopper aa8vb at yahoo.com |6.20. Why doesn't list.sort() return the sorted list? | |...list.sort() sorts the list in place.... | |As a result, here's the idiom to iterate over the keys of a dictionary in |sorted orted: | | keys = dict.keys() | keys.sort() | for key in keys: | ...do whatever with dict[key]... | From fdrake at acm.org Tue Dec 21 16:45:09 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 21 Dec 1999 16:45:09 -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> <14431.60189.682411.792427@weyr.cnri.reston.va.us> <14431.61484.662532.436321@weyr.cnri.reston.va.us> Message-ID: <14431.62693.315102.327391@weyr.cnri.reston.va.us> Magnus L. Hetland writes: > Oh - so (pardon my ignorance) how do you use parsermodule? "import parser" Way back in the dark ages, the "module" part was required. Only relatively recent modules omit it. > This sounds familiar, though... I think I had the same problem with > SWIG earlier ... (i.e. garbage names for the functions...) I'm not sure what's going on here. If you don't get it after a bit of sleep, send me your spludge.c and I'll take a look. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From insanik at hotmail.com Mon Dec 6 21:39:41 1999 From: insanik at hotmail.com (NH) Date: Mon, 6 Dec 1999 18:39:41 -0800 Subject: Is there a database in Zope? Message-ID: 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?) 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. 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. Thank you so much, Nick From gmcm at hypernet.com Tue Dec 7 13:24:58 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: 7 Dec 1999 12:24:58 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 7) Message-ID: While the Mars Lander appears to be dead, python.org came back to life within 48 hrs (creating, however, considerable disruption in the flow of it's mail lists). Mike Fletcher gives a summary of Python 3D projects: http://www.deja.com/getdoc.xp?AN=556166543 Norman Vine expands: http://www.deja.com/getdoc.xp?AN=556247544 In a thread on XML-RPC, Fredrik contributes pointers to info on SOAP (basically, an expansion of XML-RPC): http://www.deja.com/getdoc.xp?AN=556542767 Interest in type safety has made a comeback after nearly a year's hiatus: David Jeske gives us a pointer to his PyLint: http://www.deja.com/getdoc.xp?AN=557442122 http://www.chat.net/~jeske/Projects/PyLint/download/pylint-19991121.py And the Type-SIG has come back to life: http://www.python.org/sigs/types-sig/ vim users get loads of suggestions in the thread: http://www.deja.com/viewthread.xp?AN=555058129 A new feature on the Job's board page: http://www.python.org/Jobs.html lets you search certain job search websites for Python jobs. The origins of the tim-bot and eff-bot are exposed: http://www.deja.com/getdoc.xp?AN=238330113 http://www.deja.com/getdoc.xp?AN=336718323 http://www.deja.com/getdoc.xp?AN=358532977 Reminder of this year's conference: 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 http://starbase.neosoft.com/~claird/home.html claird at NeoSoft.com +1 281 996 8546 FAX From ivanlan at callware.com Mon Dec 13 13:31:39 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 13 Dec 1999 11:31:39 -0700 Subject: Python complaints References: <000201bf3bd4$2bda5e20$542d153f@tim> Message-ID: <38553B8B.822488D3@callware.com> Hi All-- Fran?ois Pinard wrote: > > "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. :-) > OK, I can understand the desire to eliminate lambda. But there are a couple of points I'm not clear on. To illustrate, I offer an example. --------------CUT HERE------------------------ #!/usr/local/bin/python from Tkinter import * import os import string img = None def die(): sys.exit(0) def listgifs(d="."): l = os.listdir(d) rl = [] for i in l: t = string.lower(i) g = string.rfind(t,".gif") if g >= 0: rl.append(i) if len(rl)<1: rl = None else: rl.sort() return rl def setimage(s): global elements global lb global img if s in elements: img = PhotoImage(file=s) lb["image"] = img def main(): global elements global lb elements = listgifs() if not elements: print "No gifs" n = len(elements) nm = n / 10 no = n % 10 if no: nm = nm + 1 print "For %d files, I'll make %d menus" % ( n, nm ) root = Tk() mb = Menu(root) cb = Menu(mb) cb.add_command(label="Exit",command=die) gm = Menu(mb) for i in range(nm): tm = Menu(gm) if i == nm - 1 and no != 0: lim = no else: lim = 10 for j in range(lim): ne = (10 * i) + j tm.add_command(label=elements[ne], command=lambda m=elements[ne]:setimage(m)) gm.add_cascade(label="List gifs %d" % (i),menu=tm) mb.add_cascade(label="File", menu=cb) mb.add_cascade(label="Gifs", menu=gm) lb = Label(root,text="No gif") lb.pack() root.config(menu=mb) root.mainloop() if __name__ == "__main__": main() --------------CUT HERE------------------------ (I don't need to hear about the political incorrectness of .gif files. ..;-) 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;-) 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? -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 leonel at sdm.pt Wed Dec 15 11:44:11 1999 From: leonel at sdm.pt (Leonel Silva) Date: Wed, 15 Dec 1999 16:44:11 +0000 Subject: Python 1.5.2 thread support Message-ID: 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 From fdrake at acm.org Thu Dec 30 16:06:39 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 30 Dec 1999 16:06:39 -0500 (EST) Subject: newbie question... In-Reply-To: <99123012552205.03415@quadra.teleo.net> References: <3868C1D2.614DA917@earthlink.net> <14443.40361.173274.782578@weyr.cnri.reston.va.us> <99123012552205.03415@quadra.teleo.net> Message-ID: <14443.51551.248502.118491@weyr.cnri.reston.va.us> Patrick Phalen writes: > Beazley simply means it is one of a group of modules which are > undocumented *in his book*. He says as much in the beginning section of > Undocumented Modules, page 242. Ah, the power of an out-of-context quote! I guess I shouldn't have left my copy at home. ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From pinard at IRO.UMontreal.CA Wed Dec 1 17:34:05 1999 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 01 Dec 1999 17:34:05 -0500 Subject: '==' vs. 'is' behavior In-Reply-To: "eff-bot"'s message of "Wed, 1 Dec 1999 10:04:12 +0100" References: <382C2C6A.64A8F2C2@theriver.com> <14380.12036.197083.409565@weyr.cnri.reston.va.us> <8E7F86267duncanrcpcouk@news.rmplc.co.uk> <015301bf3b0a$685a3fc0$f29b12c2@secret.pythonware.com> <00b001bf3bdb$0acfa440$f29b12c2@secret.pythonware.com> Message-ID: "eff-bot" ?crit: > http://www.deja.com/getdoc.xp?AN=238330113 > http://www.deja.com/getdoc.xp?AN=336718323 > http://www.deja.com/getdoc.xp?AN=358532977 Delightful! I'm usually not connected on the net (still UUCP most of the times), but today, I just happen to be, and I could appreciate the above! Thanks :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From garry at sage.att.com Mon Dec 20 10:44:34 1999 From: garry at sage.att.com (Garrett G. Hodgson) Date: Mon, 20 Dec 1999 15:44:34 GMT Subject: smtp References: <385DF2D3.A17FBE21@obop.com.pl> Message-ID: <385E4EE2.842D11A0@sage.att.com> "Przemys?aw G. Gawro?ski" wrote: > > I have a problem with smtp module (sending files). > > Can any one help ? yes, but a little more context might make it easier. -- 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 skaller at maxtal.com.au Sat Dec 4 14:52:31 1999 From: skaller at maxtal.com.au (skaller) Date: Sun, 05 Dec 1999 06:52:31 +1100 Subject: Very useful message -- Hah! References: <14408.36977.722575.657267@anthem.cnri.reston.va.us> Message-ID: <384970FF.853C9FA0@maxtal.com.au> "Barry A. Warsaw" wrote: > # 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 [] > 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') Hey, that's a nice piece of literate programming! -- 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 jam at quark.emich.edu Wed Dec 22 13:58:33 1999 From: jam at quark.emich.edu (Jeff) Date: Wed, 22 Dec 1999 13:58:33 -0500 Subject: Sorting large files In-Reply-To: <38611D77.68DFD3C0@erols.com>; from edcjones@erols.com on Wed, Dec 22, 1999 at 01:50:31PM -0500 References: <38611D77.68DFD3C0@erols.com> Message-ID: <19991222135833.D29417@quark.emich.edu> On Wed, Dec 22, 1999 at 01:50:31PM -0500, Edward C. Jones wrote: > A Python program of mine generates a large number of tuples of > ten integers each. I need to sort this collection of tuples. If > there weren't so many tuples, I could make a Python list of these > tuples and use sort(). Currently I write the tuples out to a file > in ASCII and use the UNIX sort command. Is there a faster way to > sort these tuples? Sort them in blocks using Python then merge > using the UNIX sort? Are there any faster sort programs (perhaps > in database systems)? > greetings, it really depends on what exactly you are trying to do. if you want to sort a tuple of length 10, convert it to a list, run the sort() method, and then convert it back to a tuple... but that's the easy part. what does the data look like? could you post a sample? regards, J -- || visit gfd || psa member -- || New Image Systems & Services, Inc. From fredrik at pythonware.com Tue Dec 14 03:18:40 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 14 Dec 1999 09:18:40 +0100 Subject: Need information om Python byte-code References: <8345m3$27t$1@hyperion.nitco.com> Message-ID: <011101bf460d$3a2b7930$f29b12c2@secret.pythonware.com> Nick Maxwell wrote: > 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! python always compiles everything to bytecode before it executes it (and caches the result in .pyc files). you don't have to do anything to get that behaviour... if you insist on compiling things yourself, use the "compile" (!) function: filename = "module.py" source = open(filename).read() code = compile(source, filename, "exec") exec code # run it the marshal module allows you to serialize code objects: data = marshal.dumps(code) # convert to string code = marshal.loads(data) # and back exec code # run it again pyc files are simply serialized code objects, plus a small header. see the py_compile module for details. From boud at calcifer.valdyas.org Wed Dec 1 17:13:03 1999 From: boud at calcifer.valdyas.org (Boudewijn Rempt) Date: 1 Dec 1999 22:13:03 GMT Subject: XPython (X11) References: <383E5350.1E07536A@xrce.xerox.com> <81ms2n$126$1@essle.valdyas.org> <81vsg2$g8$2@essle.valdyas.org> Message-ID: <8246hf$b5i$1@news1.xs4all.nl> Bernhard Reiter wrote: > Bad wording on my part, I guess. :) > Maybe I should call it internally aimed API. > Means: Yes, you can use it from outsite, but the abstraction in this > case is wrong. > Like: Why do I need a HTML widget if I can just delegate the task to > any HTML browser. The GNOME people would never delegate a task to the > KDE HTML widget. But they could have an API to delegate it to any > HTML browser and then let the user assemble it. If the user has > KDE on the machine, he might as well use the KDE HTML browser. There can be several quite good reasons. For instance, using a html widget gives you a relatively portable way of composing auto-layouting dialog boxes. One can use a html widget as a kind of rich text presentation box - again, using the layout engine. It's not much different from using a button or an edit box. You can do a lot with html besides browsing. > This is why the KDE and GNOME APIs are targeted within their own > structure, but not to seperate tasks and nurture compatibility. compatibility is always a tricky issue - especially if one wants to be different, too... >>Oh well, platform compatibility that costs money is still >>platform compatibility. > No. Proprietory software is not a real option. Well, I agree with that - but that rules Windows out as an option, too - so it doesn't matter anymore. -- Boudewijn Rempt | http://denden.conlang.org From Alex.Martelli at think3.com Mon Dec 27 02:58:27 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Mon, 27 Dec 1999 08:58:27 +0100 Subject: Python newbie Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D7F@pces.cadlab.it> John Ratcliff writes: > 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. > LLNL has developed, and distributes (as well as the Numerical extensions, the Image-Processing ones, and maybe others I forget), "CXX", which contains all you need to use C++ for interfacing to Python. Python's own core is still C -- as it probably, sadly, still needs to be to be as portable as it is, today... just look around www.mozilla.org for their "C++ portability rules", and tell me if you'd rather program in that stump of an arbitrarily restricted language subset, or, even more portably, in good clean standard C. I mean, "C++" without templates, without exceptions, without RTTI, without...?! Plus, if Python's core should expose its entry points as anything but "extern C", it would become tied to a signle specific C++ compiler per platform, due to name-mangling and object-layout issues, &c. I'm a reasonably rabid C++-ers myself, mind you, but that only holds when I _can_ use C++ -- say, 99.44% of the standard (I don't hold out for 100% -- e.g., I grumble each and every time about VC++'s lack of support for covariance of return values, partial specialization of templates, etc, but I still code in its decently wide standard subset). If I still needed to write code as portable as the Python core commendably is, as I did a few years ago, I would still code that in standard C, as I did then (I once had to take a largish subsystem I had coded in C++ and recode it from scratch in standard C because the alleged "C++" compilers on several platforms just wouldn't hack it -- and I vowed, "never again"!). > Are there Python variants that might be better suited, like this Viper > language I heard mentioned on the list? > Depends, I guess, on how stable a platform you need; if Viper's "alpha" stage of development suits your needs, then it might be quite an exciting platform to work on. Personally, I need to develop too much production code, these days, to do much more than "play", with anything but very solid platforms -- so, I deeply appreciate Python's fabulous stability and solidity (wish all the platform components I code with/for were half as reliable as it). But, if I was writing more proof-of-concept, throw-away prototypes, as was once the case and may be true again in the future, I would no doubt feel differently. > If Python is a dynamically typed language, how does it handle sending > specific types to a native function call or from a native call into > Python? > Basically, "opaque pointers", in many cases. The struct and array standard modules can also often help. Alex From mgushee at havenrock.com Thu Dec 30 18:37:13 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 30 Dec 1999 18:37:13 -0500 Subject: calling functions from Tk References: <842ma7$u2u$1@nnrp1.deja.com> <3864E324.11308615@callware.com> Message-ID: Ivan Van Laningham writes: > command=test > > 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. Yeah. I dunno about anybody else, but ... this makes perfect sense when you think about it, but it seems really non-intuitive to me. Shouldn't this be in big red letters in some FAQ somewhere? Or maybe it is, and nobody read it. -- Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ From calishar at my-deja.com Thu Dec 2 13:52:31 1999 From: calishar at my-deja.com (calishar at my-deja.com) Date: Thu, 02 Dec 1999 18:52:31 GMT Subject: windll question Message-ID: <826f4t$m0a$1@nnrp1.deja.com> 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 bjorn at roguewave.com Wed Dec 15 17:33:49 1999 From: bjorn at roguewave.com (Bjorn Pettersen) Date: Wed, 15 Dec 1999 15:33:49 -0700 Subject: Merging dictionaries References: <8391di$l4a$1@nnrp1.deja.com> Message-ID: <3858174C.C29043AC@roguewave.com> I think your problem is here: for left_key in left_dict.keys(): if left_key in right_dict_keys: which turns out to be O(n**2). If you change the if statement to: if right_dict.has_key(left_key): you should get back to O(n)'ish behavior. -- bjorn Preston Landers wrote: > Hello all, > > I've got a program that works with large data structures in the form of > nested dictionaries. > > The task at hand is to 'merge' two dictionaries with a special > merge_function() called for items that exist in both dictionaries. > > This is defined simply as putting 'missing' items from one into the > other. If an item exists in both, then the merge_function() function is > called, and the result of that is used as the value. In my case, the > merge_function() is simple addition lambda. > > I've got a recursive implementation posted below that works fine. Its > output is correct. However, it is unbearably slow. I have up to seven > levels of nesting, and lots and lots of items. > > The reason I'm posting is to find out if there is an iterative > solution. "Mastering Algorithms With Perl" said nothing about this > problem, unfortunately. ;-) Any ideas? If I can't come up with > anything I'm afraid I'm going to have to look for and alternate approach > to the overall problem and abandon these nested dictionaries. > > BTW I am aware of the limitations of the function I present below > (mainly, the two parameters must be similar in structure, number of > nested levels, etc) but it does the job I need. > > Sorry if the formatting is messed up, too. > > thanks, > > ---Preston > > import types > > def merge_dicts(left_dict, right_dict, merge_function): > """merge two dictionaries, returning the combination. recursively > operates on dicts within dicts. > You must supply a function that accepts two parameters and returns a > conceptually 'merged' value. > All type checking must be done by the merge_function you supply.""" > > return_dict = right_dict.copy() > > # check that we actually have a function > if type(merge_function) != types.FunctionType: > raise TypeError, "The merge_function supplied was not a valid > function." > > # cache the key lists > right_dict_keys = right_dict.keys() > > for left_key in left_dict.keys(): > if left_key in right_dict_keys: > > # cache the values > left_value = left_dict[left_key] > right_value = right_dict[left_key] > > # recurse on dictionaries > if type(left_value) == type({}): > return_dict[left_key] = merge_dicts(left_value, > right_value, merge_function) > continue > > # apply the merge function > return_dict[left_key] = merge_function(left_value, > right_value) > > else: > return_dict[left_key] = left_dict[left_key] > > return return_dict > > d1 = {"foo" : {"x": 1, "y": {"apple": 912.2, "banana": 11.8}}, "bar" : > {"x": 1, "y": 2}} > d2 = {"foo" : {"x": 1, "y": {"apple": 87.8, "banana": 0.2, "pear": 12}}, > "biff" : {"x": 1, "y": 2}} > > print merge_dicts(d1,d2, lambda x,y:x+y) > > # should print: > # {'foo': {'x': 2, 'y': {'banana': 12.0, 'pear': 12, 'apple': 1000.0}}, > 'bar': {'x': 1, 'y': 2}, 'biff': {'x': 1, 'y': 2}} > > -- > || Preston Landers || > > Sent via Deja.com http://www.deja.com/ > Before you buy. > -- > http://www.python.org/mailman/listinfo/python-list From tratt at dcs.kcl.ac.uk Tue Dec 28 07:17:13 1999 From: tratt at dcs.kcl.ac.uk (Laurence Tratt) Date: Tue, 28 Dec 1999 12:17:13 GMT Subject: obj in list and list ids the same References: <84a8k4$puq$1@nnrp1.deja.com> Message-ID: In message <84a8k4$puq$1 at nnrp1.deja.com> rdudfield at my-deja.com wrote: > 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(). If you're using CPython, then this is *very* unlikely (I can't speak for the other implementations); id() returns the memory address of a given object and unless malloc or something has gone wrong then id() will always return unique numbers for different objects[0]. So if you've genuinely got a list with something inside the list with the same id, you've probably append'ed your list into itself. Laurie [0] With the - obvious, given the implementation - caveat that objects with different lifetimes may have the same id -- http://eh.org/~laurie/comp/python/ From gerrit.holl at pobox.com Wed Dec 22 15:01:25 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 22 Dec 1999 21:01:25 +0100 Subject: When to use input()? Message-ID: <19991222210125.A1195@stopcontact.palga.uucp> Hello, 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. raw_input(), however, returns a string which can be passed to string.atoi() or IF you want to execute it, you can execute the code in a rexec environment. Or am I missing something? regards, Gerrit. -- "The move was on to 'Free the Lizard'" -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates) 8:45pm up 11 min, 2 users, load average: 0.00, 0.13, 0.15 From Dan at Grassi.com Sun Dec 5 15:02:06 1999 From: Dan at Grassi.com (Dan Grassi) Date: Sun, 05 Dec 1999 15:02:06 -0500 Subject: Very useful message -- Hah! References: <82do53$2rhr$1@hub.org><384A9BE0.B345509@inka.de> <384ABC57.DDC3B61E@inka.de> <384AC1E9.F2FA90AC@mindspring.com> Message-ID: in article 384AC1E9.F2FA90AC at mindspring.com, Jesse D. Sightler at jsight at mindspring.com wrote on 12/5/99 2:50 PM: > No, seriously, you did notice that he said "CGI", didn't you? Actually I did not make the distinction, I am just looking at the functionality. Obviously I am interested in python and feel it is better than php3. But that is really the question? The error handling in php is better but the language is inferior. >Eg, make sure that they can always be "dry-run" > outside of the webserver. I wish I could but some db accesses can not be made other than from the server. >Either that, or just use cgiwrap so that the > error logs are redirected to the browser. OK, can you point me to some info about using cgiwrap with python? Thanks, Dan From mhammond at skippinet.com.au Wed Dec 1 09:05:19 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 01 Dec 1999 14:05:19 GMT Subject: Using wxPython in COM server References: <3844dc35.143149908@news.mch.sni.de> Message-ID: Nikolai Kirsebom wrote in message <3844dc35.143149908 at news.mch.sni.de>... > >I manage to get the dialog presented, but at the same time I get an >application error in winword.exe (The instruction at "0x...." >referenced memory at "0x0000000". The memory could not be "read".) > >When I select OK in the application error message box, my dialog is >completely painted (static text and buttons), and I get e new message >box from the runtime library of Microsoft Visual C++ (Runtime error! >Program: C:\Program.....\Winword.exe abnormal program termination). Almost certainly a thread-state issue. wxPython probably doesnt release and acquire the Python thread-lock as it crosses the boundary from Python to C and back. This is almost always the end result of that support missing. Im afraid I can personally offer no additional advice - you need to speak to the wxPython guys and get thread support :-) Mark. From stuarty at excite.co.uk Fri Dec 3 09:59:25 1999 From: stuarty at excite.co.uk (stuart mcfadden) Date: 3 Dec 1999 14:59:25 GMT Subject: windows 9x exe Message-ID: <828lsd$rb4$2@news.qub.ac.uk> Has anyone found a way to make python scripts windows executable?, I checked the FAQ and it said there was no ideas as to how it would work. From samschul at pacbell.net Wed Dec 22 14:14:20 1999 From: samschul at pacbell.net (Sam Schulenburg) Date: Wed, 22 Dec 1999 19:14:20 GMT Subject: C++ Source documentation ? References: <38608E94.D37C2B0D@t-online.de> Message-ID: <83r7u7$25i$1@nnrp1.deja.com> In article <38608E94.D37C2B0D at t-online.de>, Stephane wrote: > Hi, > > 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?? > > Thanks > > Stephane > I have used Autoduck with both Python and C for generating both HTML and Windows help under windows. If this is the environment you are using then see the folowing URL for sample code and documentation: http://starship.python.net/crew/schulenburg/ Sent via Deja.com http://www.deja.com/ Before you buy. From pj at sgi.com Thu Dec 23 18:25:50 1999 From: pj at sgi.com (Paul Jackson) Date: 23 Dec 1999 23:25:50 GMT Subject: How to read lines from end of a file? References: <4rhfhazoj4.fsf@colargol.tihlde.hist.no> <4r7li5zrfm.fsf@colargol.tihlde.hist.no> Message-ID: <83ub1u$gs9qn@fido.engr.sgi.com> |> I want to read the lastlines from a file, one ? |> by one, until I find what I'm looking for. |> It seems like the reverse() function does what I want I'd be tempted to reverse the last big (100 Kbytes?) chunk, not the entire file. If the file were huge, I might rather risk missing the desired line than risk blowing out my memory to the swap device. All depends on what you're trying to do ... -- ======================================================================= I won't rest till it's the best ... Software Production Engineer Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj From johnm at magnet.com Tue Dec 28 17:26:21 1999 From: johnm at magnet.com (John Mitchell) Date: Tue, 28 Dec 1999 17:26:21 -0500 Subject: Py2K wishes In-Reply-To: <38693545.894CE515@prescod.net> Message-ID: On Tue, 28 Dec 1999, Paul Prescod wrote: > When you can't find something in the current function namespace, Python > "falls back" to the global namespace. When it can't find something > there, it "falls back" to the __builtins__ namespace. When Python can't > find something in an object instance it "falls back" to the object's > class object. When it can't find something there it "falls back" to the > class's base class. And so forth. > [...] > I'm saying that we could expose the fallback mechanism so that an > object could be instructed to fallback to another object. > > Paul Prescod Isnt this the same as Fulton's __of__ code developed for Zope? That is, a semi-automatic delegation to another instance instead of up the class hierarchy -- aka acquisition. This code, if it does what you want, has the advantage of being *done* and runnable now. Alas, I seem to remember Guido frowning on this specific extention... - j From sendzimir at earthlink.net Sun Dec 26 19:57:12 1999 From: sendzimir at earthlink.net (Alexander Sendzimir) Date: Sun, 26 Dec 1999 19:57:12 -0500 Subject: import mailbox.py Message-ID: <3866B968.1A8212E6@earthlink.net> N E W T O P Y T H O N Does anybody know what the status of mailbox.py is? I've been using it to learn from. None of it is documented. I would like to learn more about why certain things are done. Perhaps the author is around? 'Hey! What\'s that behind you?!??' From gerrit.holl at pobox.com Wed Dec 22 06:06:12 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Wed, 22 Dec 1999 12:06:12 +0100 Subject: os.popen() vs os.system() In-Reply-To: ; from sposhua@my.pc on Wed, Dec 22, 1999 at 09:47:00AM +0000 References: Message-ID: <19991222120612.B3554@stopcontact.palga.uucp> Sposhua wrote: > a) popen automatically starts a new process while system only does it if you > include an & Not true: >>> os.getpid() 3264 >>> os.system("echo $$") 3658 > b) popen hooks onto stdout and stdin True. With os.popen(), you can read and write like a pipe. os.system() doesn't let you do this. It's just like the C system() function, which use I also don't understand. Maybe it's just easier? regards, Gerrit. -- "Nature abhors a Vacuum" -- Brian Behlendorf on OSS (Open Sources, 1999 O'Reilly and Associates) 12:00pm up 55 min, 16 users, load average: 0.00, 0.00, 0.00 From jlouder at wfu.edu Thu Dec 2 12:26:07 1999 From: jlouder at wfu.edu (Joe Louderback) Date: 2 Dec 1999 17:26:07 GMT Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: <826a3f$32jc@f1n1.spenet.wfu.edu> Phil Mayes (nospam at bitbucket.com) wrote: > 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. To be fair, we Fortran programmers can start arrays with any index, so even the 4 BC problem can be solved ;-) Joe Louderback From s323140 at student.uq.edu.au Tue Dec 21 12:30:51 1999 From: s323140 at student.uq.edu.au (Rob Hodges) Date: 22 Dec 1999 03:30:51 +1000 Subject: ugly python namespace bug References: <83nkpe$998$1@news1.tele.dk> <19991221113510.A27335@quark.emich.edu> Message-ID: Jeff writes: > 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. > 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? I thought about this but decided I wouldn't want to see warnings for anybody else's modules I imported. But if it only warned when byte-compiling, that wouldn't be a problem. So provided that were the case, I agree this would be a better approach. -Rob From paul at prescod.net Mon Dec 27 05:55:34 1999 From: paul at prescod.net (Paul Prescod) Date: Mon, 27 Dec 1999 05:55:34 -0500 Subject: Super Tuples Message-ID: <386745A6.9B671DBF@prescod.net> 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 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. Opinions? Bets that Guido would apply a patch to this effect? Paul Prescod From nickb at earth.ox.ac.uk Thu Dec 9 17:02:17 1999 From: nickb at earth.ox.ac.uk (Nick Belshaw) Date: Thu, 09 Dec 1999 22:02:17 +0000 Subject: Tk Listbox Question References: <384FC9F6.1521A533@earth.ox.ac.uk> Message-ID: <385026E9.15A96D88@earth.ox.ac.uk> Kevin - hi thanks for the comment regarding Tk - Listbox. My real problem is item selection inside the Listbox. The default bindings for the widget are LH-MouseButton for selection/highlighting of an item. I can only access the hilighted item using 'active' or 'curselection'. If instead I bind a method onto the RH-MouseButton and click I get the old 'active' selection rather than a different item I may be trying to click on since the RH-Mousebutton has no effect on item selection in the Listbox - if that makes sense :-/ so I was wondering if its possible to alter the default bindings of the widget? cheers Nick/Oxford From JamesL at Lugoj.Com Sat Dec 4 00:36:50 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Fri, 03 Dec 1999 21:36:50 -0800 Subject: Python complaints References: <000401bf3bd4$2f000820$542d153f@tim> Message-ID: <3848A872.C704AB73@Lugoj.Com> Michael Hudson wrote: > > "Tim Peters" writes: > > At the risk of obfuscating it, here's another way to write the same thing: > > > > x = x+1 > > Rather more efficient too... Nice and efficient so long as all you do is increment yourself along the X axis. But suppose you are using Python to maintain a count of the population of the planet Earth and want to use a sensible variable name (for porting purposes of course, in case you need to us e the same code on the planet Mars and want to remember which variable had the population count in it so you can change it to the right name). You'd have code that would look like: populationOfthePlanetEarth = populationOfThePlanetEarth + 1 versus: populationOfThePlanetEarth++ And if you weren't careful, you might make a hidden typo (like I did in the first example), thereby causing a cessation of population growth which would seriously impact economic growth and cause untold hardship. Therefore in the interest of the world economy it is essential that the next version of Python support the increment operator. I rest my case. Or at least my head. From jbauer at rubic.com Tue Dec 28 18:58:50 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Tue, 28 Dec 1999 17:58:50 -0600 Subject: why? References: <38685b07.189574443@news.isomedia.com> Message-ID: <38694EBA.31EF2141@rubic.com> >> 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. Grant, 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> Jeff Bauer Rubicon Research From bjorn at roguewave.com Thu Dec 16 11:21:46 1999 From: bjorn at roguewave.com (bjorn) Date: Thu, 16 Dec 1999 09:21:46 -0700 Subject: C++ References: <816010E2456BD111A48700805FBBE2EEFDF91E@ex-quebec-u1.baan.com> Message-ID: <3859119A.4943B184@roguewave.com> But a language with a 997 page standard must be fully specified and without any ambiguities, no? ;-) -- bjorn Dublin, '99 Gaetan Corneau wrote: > Guys, > > I have been programming in C++ for eight years now, and I was on the > standard committee from '94 to '96, so I *really* don't need to be reminded > of the language's virtues and flaws. And I won't be dragged in a flame war. > > Could we just get back to Python now? :) > ______________________________________________________ > 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" > > -- > http://www.python.org/mailman/listinfo/python-list From arcege at shore.net Sat Dec 4 13:45:51 1999 From: arcege at shore.net (Michael P. Reilly) Date: Sat, 04 Dec 1999 18:45:51 GMT Subject: Equivalent Python API Code References: <8244tn$ns$1@nnrp1.deja.com> Message-ID: winkjj at my-deja.com wrote: : Could someone show me how to implement the following Python code using : the C API? :>>> mystr = '[100,200,300]' :>>> mylist = eval(mystr) :>>> mylist : [100, 200, 300] : Basically, I want to take a char* that holds the value of mystr, and : eval it, obtaining a PyObject* to a list. : Generically, I want to be able to eval any char* that represents some : code, and obtain a PyObject* to the real object... : I've tried using PyRun_String with the start token set to : Py_eval_input, but this doesn't work correctly. It is not in the API documentation. You need to review the source code, but you want to compile the string and evaluate that result. Here is some example code. #include #include #include int main(ac, av) int ac; char *av[]; { char *stmt1 = "mystr = '[100,200,300]'", *stmt2 = "eval(mystr)"; PyObject *globals, *co, *result, *PyEval_EvalCode(); Py_Initialize(); globals = PyDict_New(); /* compile a statement */ PyDict_SetItemString(globals, "__builtins__", PyEval_GetBuiltins()); if ((co = Py_CompileString(stmt1, "", Py_file_input)) == NULL) { PyErr_Print(); exit(1); } /* evaluate the compiled code */ result = PyEval_EvalCode((PyCodeObject *)co, globals, NULL); Py_DECREF(co); if (result == NULL) { PyErr_Print(); exit(1); } /* print the result */ PyObject_Print(result, stdout, Py_PRINT_RAW); fprintf(stdout, "\n"); Py_DECREF(result); /* compile an expression */ if ((co = Py_CompileString(stmt2, "", Py_eval_input)) == NULL) { PyErr_Print(); exit(1); } result = PyEval_EvalCode((PyCodeObject *)co, globals, NULL); Py_DECREF(co); if (result == NULL) { PyErr_Print(); exit(1); } /* print the result */ PyObject_Print(result, stdout, Py_PRINT_RAW); fprintf(stdout, "\n"); Py_DECREF(result); Py_DECREF(globals); Py_Finalize(); exit(0); } This should give you some direction on using compiled statements in C. -Arcege From a.eyre at optichrome.com Wed Dec 8 11:35:20 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Wed, 8 Dec 1999 16:35:20 -0000 Subject: Help need with tuples??? In-Reply-To: <82j04d$62g$1@nnrp1.deja.com> Message-ID: <000501bf419a$37b21550$3acbd9c2@peridot.optichrome.com> > This is the third time I have posted this, but since I have gotten no > replies I assume my other stuff wasn't clear enuff or there is a problem > with python on my machine. I am in the process of moving to a win98 > machine for testing instead of NT. > [snip] It would be easier to diagnose if you could post more of the source than this. -------------------------------------------- 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 bparsia at email.unc.edu Mon Dec 27 22:57:58 1999 From: bparsia at email.unc.edu (Bijan Parsia) Date: Mon, 27 Dec 1999 22:57:58 -0500 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D81@pces.cadlab.it> Message-ID: <1e3htfv.csi5dhrlrs0yN%bparsia@email.unc.edu> Alex Martelli wrote: > Bijan Parsia writes: > > > So, you could just use 'for' with the added notion that providing two > > variables gives you the index in the first one. > > > > As I recall, this didn't lead to any confusion in NS. > > > > I don't know if this conflicts with already legal Python. But it seems > > much preferable than a different keyword. > > > It would indeed conflict -- "for x, y in e" already has a useful > meaning when e is a sequence of tuples, as it unpacks each > tuple into x and y variables. Hmm. How about, "for index of x,y in e" or "foreach i of x in e" (where 'index' and 'i' are just variables)? Cheers, Bijan Parsia From herzog at online.de Sat Dec 11 14:08:22 1999 From: herzog at online.de (Bernhard Herzog) Date: 11 Dec 1999 20:08:22 +0100 Subject: Error confusing a newbie References: <19991210100320.B18389@dmcom.net> Message-ID: Wayne Topa writes: [...] > 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')' > > Here is the script > --------------------------------------------- > #!/usr/bin/env python > > import string,sys > from DateTime import * > > input = open('/var/log/totalppp', 'r') > times=input.readlines() > input.close() [snip rest of script] 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? -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://www.online.de/home/sketch/ From neelk at brick.cswv.com Wed Dec 29 18:13:37 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 29 Dec 1999 23:13:37 GMT Subject: random number generation: the newbie asks for advice References: <6D8A17398E28D3119F860090274DD7DB4B3D91@pces.cadlab.it> Message-ID: Alex Martelli wrote: > >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! Sounds like you want the Mersenne Twister! From the webpage: Mersenne Twister(MT) is a pseudorandom number generator developped by Makoto Matsumoto and Takuji Nishimura (alphabetical order) during 1996-1997. MT has the following merits: * It is designed with consideration on the flaws of various existing generators. * The algorithm is coded into a C source downloadable below. * Far longer period and far higher order of equidistribution than any other implemented generators. (It is proved that the period is 2^19937-1, and 623-dimensional equidistribution property is assured.) * Fast generation. (Although it depends on the system, it is reported that MT is sometimes faster than the standard ANSI-C library in a system with pipeline and cache memory.) * Efficient use of the memory. (The implemented C-code mt19937.c consumes only 624 words of working area.) The C source is available at: http://www.math.keio.ac.jp/~matumoto/emt.html Unfortunately, I don't think it has a Python wrapper yet. It should be easy to implement, though, since there's only a pair of very small C functions to wrap. Neel From ljz at asfast.com Fri Dec 24 14:09:12 1999 From: ljz at asfast.com (Lloyd Zusman) Date: 24 Dec 1999 14:09:12 -0500 Subject: \s doesn't match References: Message-ID: writes: > I did this: > > a = 'a b' > if match(r'\s',a): print 'error' > > and it didn't match. > > a = ' b' > > and it did match. Documentation seems to imply that \s matches > whitespace anywhere in the string, what gives? The `match' method matches characters anchored at the *beginning* of the string. What follows is the first part of the documentation for `match' .. match (pattern, string) Return how many characters at the beginning of string match the regular expression pattern. [ ... ] If you want to match for a pattern anywhere in the string, you should use `search' and not `match', as follows ... a = 'a b' if search(r'\s',a): print 'error' In other words, the `match' method works as if a `search' is being done with an implied `^' character as the leftmost character of the pattern ... match(r'\s',a) is equivalent to search(r'^\s',a) I hope this helps. -- Lloyd Zusman ljz at asfast.com From coursesm at sbdhcp-4024.statenisland-ny.est.tcg.com Tue Dec 14 08:02:16 1999 From: coursesm at sbdhcp-4024.statenisland-ny.est.tcg.com (Stephen Coursen) Date: 14 Dec 1999 13:02:16 GMT Subject: __getattr__, hasattr References: <835crr$fjl@mail.psy.uva.nl> Message-ID: On Tue, 14 Dec 1999 13:06:09 +0100, 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? > How exactly are you redefining __getattr__ ? In my redefinitions, I have it raise an AttributeError if the attribution in question isn't there. This causes hasattr to have the appropriate behavior. Steve > >Thanks, >ionel > > From sendzimir at earthlink.net Tue Dec 28 15:50:35 1999 From: sendzimir at earthlink.net (Alexander Sendzimir) Date: Tue, 28 Dec 1999 15:50:35 -0500 Subject: newbie question... Message-ID: <3869229B.C06B94E5@earthlink.net> As a developer new to the Python language and experienced with the Perl language (and quite a few others ;-), I'm wondering what the accepted method of handling a text file's contents are in Python. For example, the following Perl construct is pretty standard. while ( ) { # process each line as if comes off the file handle... } is typical. 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 # using some prefered method (there's more than # one way of doing this, of course ;-) THE BIG QUESTION: Am I understanding Python's philosophy properly? Thanks, abs From bwarsaw at cnri.reston.va.us Thu Dec 23 09:25:05 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 23 Dec 1999 09:25:05 -0500 (EST) Subject: Matching a constant string at beginning References: Message-ID: <14434.12481.342846.97148@anthem.cnri.reston.va.us> >>>>> "I" == ISO writes: I> is rather tedious. Of course, I could write a very small I> function to match a constant string at the beginning of I> another, but there just must be some idiom for doing this. In the current JPython betas, and in the next version of CPython (development version avalable via CVS), string objects have methods. Two new methods `startswith' and `endswith' have been added, which will fit the bill perfectly: -------------------- snip snip -------------------- Python 1.5.2+ (#8, Dec 22 1999, 17:27:05) [GCC 2.8.1] on sunos5 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> s = "Warsaw ain't just the capital of Poland" >>> s.startswith('Boston') 0 >>> s.startswith('Warsaw') 1 -------------------- snip snip -------------------- String methods will be one of those new features that'll change your life. :) Wait'll you try s.join(). -------------------- snip snip -------------------- >>> ' & '.join(['Guido', 'Tim', 'Gordon', 'David', 'Biff', 'etc.']) 'Guido & Tim & Gordon & David & Biff & etc.' >>> -------------------- snip snip -------------------- -Barry From andres at corrada.com Sat Dec 25 08:08:20 1999 From: andres at corrada.com (Andres Corrada) Date: Sat, 25 Dec 1999 08:08:20 -0500 Subject: Python mode on Macintosh Alpha editor? References: <840m5s$4fq0$1@swen.emba.uvm.edu> Message-ID: <3864C1C4.4BDFBB4C@corrada.com> Howard Oakley (howard at quercus.demon.uk) is currently maintaining a mode for the Alpha editor. I think it is included in the latest releases of Alpha. ------------------------------------------------------ Andres Corrada-Emmanuel Email: andres at corrada.com Owner http://www.corrada.com/mamey Mamey Phone: (413) 587-9595 ------------------------------------------------------ From nascheme at enme.ucalgary.ca Wed Dec 1 13:06:08 1999 From: nascheme at enme.ucalgary.ca (Neil Schemenauer) Date: Wed, 01 Dec 1999 18:06:08 GMT Subject: What's the canonical vi setting for Python indentation References: <38445B6A.A1283D2E@cs.mu.oz.au> <19991201111751.A1277@Ridcully.home> Message-ID: Quinn Dunkan wrote: >>On Tue, Nov 30, 1999 at 11:46:10PM +0000, Sean Blakey wrote: >>> I don't know about canonical, but I have the following in my .vimrc >>> set expandtab "Turn's tabs into spaces >>> set hardtabs=4 "Make tabs 4 spaces wide >>> set tabstop=4 >>> set shiftwidth=4 "For use with << and >> It is not really a good idea to change tabstop to a value other than 8. Use vim5 and softtabstop as Quinn suggests. I used to do it but have been reformed. It works great if you are the only one editing code and you don't have to edit files that use a mixture of tabs and spaces. >Here's my config: > >se et ts=8 sw=4 softtabstop=4 smarttab > >I like keeping tabs at 8 chars since many other things expect that. >For indentation I use: > >se ai >im : : That mapping is really cool. You should probably add expandtab to your list of options. If you only use sts then a tab will be inserted for 8 spaces. I think this gives about the same behavior as python.el: :au BufEnter *.py set sw=4 sts=4 et ai breaking that down: sw=4 " Use 4 spaces for << and >> (and other things) sts=4 " inserts 4 spaces (but replaces 8 with tabs) et " Expand all tab values to spaces ai " Automaticly indent new lines You don't have to worry about backspacing through 4 characters to remove an indent. Vim is smart enough to delete sts chars. You haven't changed the size of tabs so if you open I file that assumes ts=8 then everything will still look okay. If you hate tabs and want to see them, this is useful: set list listchars=tab:?? If you use the above indentation setting you should be pretty save anyhow. 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 geoff at elj.com Thu Dec 30 02:47:01 1999 From: geoff at elj.com (geoff at elj.com) Date: Thu, 30 Dec 1999 07:47:01 GMT Subject: random number generation: the newbie asks for advice References: <6D8A17398E28D3119F860090274DD7DB4B3D91@pces.cadlab.it> Message-ID: <84f227$469$1@nnrp1.deja.com> In article , neelk at alum.mit.edu wrote: > Alex Martelli wrote: > > > >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! > > Sounds like you want the Mersenne Twister! From the webpage: > > Mersenne Twister(MT) is a pseudorandom number generator developped > by Makoto Matsumoto and Takuji Nishimura (alphabetical order) during > 1996-1997. MT has the following merits: [..] > The C source is available at: > > http://www.math.keio.ac.jp/~matumoto/emt.html > > Unfortunately, I don't think it has a Python wrapper yet. It should be > easy to implement, though, since there's only a pair of very small C > functions to wrap. Should be quite easy to port Python. There is an Eiffel (using SmallEiffel http://smalleiffel.loria.fr/ ) wrapper available from the Eiffel Forum Archive at: http://www.eiffel-forum.org/archive/wagner/twister.htm Hope this helps. Geoff Eldridge -- email: geoff at elj.com -- elj-daily: http://www.elj.com/elj-daily.cgi Sent via Deja.com http://www.deja.com/ Before you buy. From skip at mojam.com Fri Dec 10 11:27:18 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 10 Dec 1999 10:27:18 -0600 (CST) Subject: string interpolation syntactic sugar In-Reply-To: <16600266@oberon.noris.de> 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> Message-ID: <14417.10726.522627.251334@dolphin.mojam.com> Referring to "a %(x)s b %(y)s" % locals() and "a %(x)s b %(y)s" % obj.__dict__ Hartmut asks: How efficient is this? Efficient enough. ;-) Seriously, it's pretty fast (it's essentially just sugar coated sprintf), and faster (and more readable) than the other obvious alternatives, like "a " + `x` + " b " + `y` and I imagine only slightly slower than the tuple-based interpolation: "a %s b %s" % (x, y) which gets to a maintenance nightmare if you have lots of substitutions to perform. Suppose you have "the %s %s %s jumped over the %s %s" % (x, y, z, i, j,) and you wanted to add a new format specifier. You have to count format elements from the beginning of the format string to the point at which you want the new % thingie, then do the same in the tuple of substitution values. An error-prone exercise, to be sure, especially if the values are more complex (function calls with multiple arguments, yadda, yadda, yadda). 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 tim_one at email.msn.com Sat Dec 4 22:11:19 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 4 Dec 1999 22:11:19 -0500 Subject: "%(a)s ... %(b)s" % {'a': foo, 'b': '%(b)s'} In-Reply-To: <19991204230919.A1360@stopcontact.palga.uucp> Message-ID: <000801bf3ece$671e7e60$3a2d153f@tim> [Gerrit Holl] > ... > But _why_ isn't this permitted: > >>> print '%(a)s, %(b)s' % {'a': 'aaaa'} > Traceback (innermost last): > File "", line 1, in ? > KeyError: b > > Can't Python automatticaly detect there's no B so leave it blank? It certainly could -- in fact, that it gives an error msg naming "b" now demonstrates that it's already detecting it . > Why doesn't Python do this? Likely because in *most* cases where a key is missing, it was an error on the programmer's part (perhaps they misspelled the key name in the format string, or perhaps they're referencing a key that simply doesn't exist due to a program logic error -- whichever, if a programmer tells Python to interpolate a key "b", and there is no key "b", the obvious response is to protest "but I can't!"). These kinds of mistakes are actually quite common, and it's good to get yelled at when you make them -- it wouldn't help in general for Python to make up some other behavior, *guessing* that what looks like an error really isn't. Most people wouldn't like that. I think you're going down a bad path here: look for approaches that don't require multiple layers of substitution to begin with! do-it-once-when-it's-ready-to-be-done-ly y'rs - tim From edwardam at home.com Wed Dec 1 21:51:23 1999 From: edwardam at home.com (Edward Muller) Date: Thu, 02 Dec 1999 02:51:23 GMT Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD81@gandalf.digicool.com> Message-ID: <3845DEA8.5A2A61A@home.com> Like I said in my original posting, what I am BASICALLY looking to do is expose COM object across the net via X (where X is some API/system that is cross platform & cross language). The original idea came up as a way to get my email from any system by writing a python program that would interact with the MAPI.Session COM object, expose the COM object (or something) and then on the client side I could write a program using the exposed (over the network) COM object.....So basically I could get my Exchange Email/Calendar/Task List on my Linux Box or one of our Solaris boxes, or via a Java client in a web browser, etc. etc. etc. 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. If this topic (Exposing COM via some mechanizm for use acrosss a network) please email me. 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. > > >Brian Lloyd brian at digicool.com > > Go Zope! > > -- > -William "Billy" Tanksley, in hoc signo hack From prestonlanders at my-deja.com Wed Dec 1 13:43:50 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Wed, 01 Dec 1999 18:43:50 GMT Subject: Looking for sshlib.py References: <19991130080326.A1376@quark.emich.edu> Message-ID: <823q95$ofa$1@nnrp1.deja.com> In article , "John Leach" wrote: > I'm looking to write a Python frontend for character-based applications > accessed via the internet. > telnet works well but I'd like something with more security (telnet sends > its password unencrypted I believe). Most telnets (especially most standard unix telnets) send *Everything* unencrypted, not just passwds. You may be interested in encrypting all traffic, not just passwords. In which case, ssh is definetely the way to go. You could brew you own custom SSL based module, but I would look at interfacing with ssh first. > I'll try calling ssh from within Python and see if that helps. Indeed, I think you can use the popen3 module to accomplish this. You may find the PyExpect modules (there are several variations) useful as well, as they assist in scripting interactive term-based programs. a Python sshlib is not a bad idea, though. If you do any work on this, be sure to post to the newsgroup. 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. :-( good luck, ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From python-list at teleo.net Fri Dec 31 01:11:41 1999 From: python-list at teleo.net (Patrick Phalen) Date: Thu, 30 Dec 1999 22:11:41 -0800 Subject: Converting an intergar to a string In-Reply-To: <19991231164828.A8614@dark.net> References: <19991231140532.A8331@dark.net> <082a01bf533f$a61d3400$0100a8c0@rochester.rr.com> <19991231164828.A8614@dark.net> Message-ID: <9912302217380C.03415@quadra.teleo.net> [Jeremy Lunn, on Thu, 30 Dec 1999] :: 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) Gosh, Jeremy, it sounds like maybe you're trying to learn Python by trial and error. There's an easier way. I really recommend the excellent documentation at http://www.python.org/doc/. Pay particular attention to the Tutorial and the Library Reference. You'll be glad you did. ;) From dworkin at ccs.neu.edu Wed Dec 22 16:45:22 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 22 Dec 1999 16:45:22 -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 Your description above doesn't give me a very clear idea of what you are trying to do. The following function, given a list of lists of numbers, will return a list of their sums: >>> def Sum(ls): ... from operator import add ... newls = [] ... for i in ls: ... newls.append(reduce(add, i)) ... return newls ... >>> l = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] >>> Sum(l) [6, 15, 24] Perhaps from there you can find a way to solve whatever problem you are trying to solve. -Justin From Dan at Grassi.com Fri Dec 3 22:30:51 1999 From: Dan at Grassi.com (Dan Grassi) Date: Fri, 03 Dec 1999 22:30:51 -0500 Subject: Very useful message -- Hah! Message-ID: It seems that by design python, by design, is not to be used as a cgi scripting language -- otherwise why would it produce this very meaningful message at the slightest syntax error: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, webmaster at xxxx and inform them of the time the error occurred, and anything you might have done that may have caused the error. Premature end of script headers: /usr/home/xxxxx/calculate.py Personally I've about had it, at least PHP provides reasonable error messages. Dan From phd at phd.russ.ru Wed Dec 22 04:41:04 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Wed, 22 Dec 1999 09:41:04 +0000 (GMT) Subject: strptime on Unix systems In-Reply-To: <19991222110107.A972@Ridcully.home> Message-ID: 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 > > 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)? I've tested your program (replaced "t =" with "tt =") on pentium linux, freebsd and sprac solaris. All the same ValueError... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From boud at rempt.xs4all.nl Fri Dec 31 08:48:06 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 31 Dec 1999 13:48:06 GMT Subject: Python not a Very High-Level Language? References: <84i4bn$rqh$1@clematis.singnet.com.sg> Message-ID: <84ic6m$ao9$1@news1.xs4all.nl> Ajith Prasad wrote: > 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. Yes, I read that too, a while ago, and it got me thinking about what a language like he proposes would look like. He made two striking suggestions - being able to draw part of the logic, in the sidebar of the code, as it were, and having a sort of underlying representation of the code (he said xml, but that's what everyone is saying these days), so that a particular development tool could show the code in various helpful ways. I think, however, that he has confused the language with the creation and maintenance tool (I hesitate to call it an editor anymore), Already in Steve MacConnels Code Complete, there was a proposal for an ideal programming environment. I do think even the best editors aren't getting close to the sophistication enjoyed by users of basic stuff like webbrowsers (the KDE2 general browser Konqueror is incredibly sophisticated) or office suites - so there he has a point. But even so, he doesn't mention good stuff like the ways you can nowadays combine code and documentation (as in Qt), or work with diagrams. Class browsers already exist (even though I find most of them more confusing than helpful). It's only the presentation that's lacking, I think. But for that you don't need in intermediary language, although that would come in handy to make one environment work for more than one language. I'd like to write a programming environment that not only included syntax highlighting, but also linking to documentation, a rich presentation of the program and its logic, but I suspect programmers will always go back to the ascii source. I know I do when I have to work with Visual Basic... It's the only way to clean up the mess produced by a too complicated environment. And anyway, I've first to finish my linguistics application and the simple xml editor I'm working on ;-). -- Boudewijn Rempt | http://denden.conlang.org From fredrik at pythonware.com Fri Dec 10 10:40:31 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 10 Dec 1999 16:40:31 +0100 Subject: Enviroment References: <6t38511bd8icf6n79%milek@korweta.task.gda.pl> Message-ID: <013401bf4324$e51ed530$f29b12c2@secret.pythonware.com> Robert Milkowski wrote: > I call the program in Python as CGI. > I need to set up LD_LIBRARY_PATH enviroment to "/usr/lib:/lib:/mnt/1/NSIN/lib:/mnt/1/NSIN/egcs-libs:" before importing some modules. > How can I do it in Python? os.putennv(LD_LIBRARY_PATH,"/usr/lib:/lib:/mnt/1/NSIN/lib:/mnt/1/NSIN/egcs-libs:/mnt/1/NSIN/linux-li bs:") > doesn't work. afaik, there's no error message in Python that just says "doesn't work". anyway, the correct syntax is: os.environ["LD_LIBRARY_PATH"] = "/usr/lib etc From sposhua at my.pc Wed Dec 15 07:12:48 1999 From: sposhua at my.pc (Sposhua) Date: Wed, 15 Dec 1999 12:12:48 +0000 Subject: output redirection In-Reply-To: <837sjt$osh$1@news1.sunrise.ch> References: <837sjt$osh$1@news1.sunrise.ch> Message-ID: On Wed, 15 Dec 1999, Nicola Ferrari wrote: > Hi, > I'm working with python 1.52 and tkinter (I've installed Tcl/Tk 8.0.5) under > windows NT4.0 > Python uses a self made C++ library which produces lots of outputs to the > standard output. > I would like to redirect these outputs from the python interpreter console > to another sink (for example a file), > but I'm not able to capture it...could someone help me? > thank you in advance Newby here, but I think this'll work... import sys sys.stdout = open("screen.dump","w") There again, I may be completely wrong... From psheer at obsidian.co.za Mon Dec 27 06:09:35 1999 From: psheer at obsidian.co.za (Paul Sheer) Date: Mon, 27 Dec 1999 13:09:35 +0200 (RSA) Subject: KOALA 0.9.0 released: A database `microsoft access'-4GL-like ba cken d for PostGreSQL In-Reply-To: <199912270528.VAA11723@rama.escnd1.sdca.home.com> Message-ID: try python 1.5.1 i'll fix this with the next release. -paul On 26 Dec, davecook at home.com did thusly spake: > 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 -- -----BEGIN PGP PUBLIC KEY BLOCK----- Version: 2.6.3i mQCNAzdiRpAAAAEEANPUPC/Lrs4OCJOjWaIWaCYTzTIY1p73uPY+8ZOJH5fc4QNp IAX+EFQ/yZ3RMOLg8yy++HufzBwDoePO4W0MKwyVFCcNIIjsY6JCXWdbpQXsY1LL OASlGexQnEQ4mfc7ThOAKWSgPyiMv5vDJ6S0EL8rdIFL7fVv56BAxnN042FRAAUR tCJQYXVsIFNoZWVyIDxwc2hlZXJAb2JzaWRpYW4uY28uemE+iQCVAwUQN2JGkKBA xnN042FRAQF5CAP/Y0TaguqCpYiTEBHxZPpT/dliInVRBzryi4gdlgX6CCLDRRGH ATP4ac8aiATegc4ev4+vcdn4fBwc6fQ2AP6hd25ZI93vShxztM/bQlGWy0zp79Uo +69uGdJhdvgYpIsTCqppM/yjeXAJEqq5TG2Gy4pqHY235rspmeA/fX7kgIo= =aX4m -----END PGP PUBLIC KEY BLOCK----- Cellular . . . +27 83 604 0615 . . . . Land . . . +27 21 761 7224 Obsidian Systems . . . . Linux installations, support, networking info at obsidian.co.za . . . . . . . . . . Tel . . +27 21 448 9265 http://www.obsidian.co.za . . . . . . . Jhb . . . +27 11 792 6500 L I N U X . . . . . . . . . . . . . The Choice of a GNU Generation From nospam at bitbucket.com Thu Dec 23 04:27:36 1999 From: nospam at bitbucket.com (Phil Mayes) Date: Thu, 23 Dec 1999 01:27:36 -0800 Subject: Patch: httplib.py default timeout References: <83r0lh$mj6$1@nntp6.atl.mindspring.net> Message-ID: 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'. > >The background is that we've been (okay, foolishly) trying to use urllib >in a production environment. We've also been using httplib directly >when urllib's behavior is inappropriate. In both cases we've been >having hangs in our programs; we fixed the latter problem by >manipulating HTTP.socket directly. That's not an option for urllib, and >we'd rather not dump urllib because we've already put in a fair amount >of time subclassing urllib to fix its behavior. Jeremy's urllib2 isn't >the answer, either, because it doesn't address the timeout problem. > >I don't think subclassing HTTP would help. ;-) > >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. 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. -- Phil Mayes pmayes AT olivebr DOT com From greybria at direct.ca Tue Dec 14 22:48:41 1999 From: greybria at direct.ca (Colleen & Brian Smith) Date: Tue, 14 Dec 1999 19:48:41 -0800 Subject: Python Imaging Library - Install Question Message-ID: If I try to run some of the example code in the manual, I get the following stack trace: >>> im=Image.open("C:\\Image Files\\b-29.jpg") >>> im.show() Traceback (innermost last): File "", line 1, in ? File "c:\Python\PIL\Image.py", line 694, in show _showxv(self, title, command) File "c:\Python\PIL\Image.py", line 974, in _showxv file = self._dump(format=format) File "c:\Python\PIL\Image.py", line 307, in _dump self.load() File "c:\Python\PIL\ImageFile.py", line 125, in load self.load_prepare() File "c:\Python\PIL\ImageFile.py", line 175, in load_prepare self.im = Image.core.new(self.mode, self.size) File "c:\Python\PIL\Image.py", line 40, in __getattr__ raise ImportError, "The _imaging C module is not installed" ImportError: The _imaging C module is not installed >>> I've installed PIL (95/NT 1.52 compatible version) in C:\Python\PIL and the _imaging.dll is installed there, C:\Windows\System and in C:\Python\DLLs. I've set the same $PYTHONPATH in my autoexec.bat as in the registry. SET $PYTHONPATH="C:\Python\Lib\plat-win;C:\Python\Lib;C:\Python\DLLs;C:\Python\L ib\lib-tk;c:\Python\PIL" What am I overlooking? Brian Smith greybria at direct.ca http://mypage.direct.ca/g/greybria From aahz at netcom.com Thu Dec 23 15:07:43 1999 From: aahz at netcom.com (Aahz Maruch) Date: 23 Dec 1999 20:07:43 GMT Subject: Patch: httplib.py default timeout References: <83r0lh$mj6$1@nntp6.atl.mindspring.net> <83trp0$ubi$1@nntp8.atl.mindspring.net> <14434.30162.38117.637290@weyr.cnri.reston.va.us> Message-ID: <83tvef$h6u$1@nntp9.atl.mindspring.net> In article <14434.30162.38117.637290 at weyr.cnri.reston.va.us>, Fred L. Drake, Jr. wrote: >Aahz Maruch writes: >> >> 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 > > Why would httplib be the common case? I'd think most casual users >would normally want urllib, especially since it also handles proxy >support. Yes, exactly. I think you missed my original post, so I'll repeat myself differently: There is currently no timeout support in httplib. In order for urllib to handle timeouts in the current configuration, it would have to directly manipulate the socket object inside HTTP() -- that's a Bad Idea, IMO. Given that we have to patch httplib to add timeout support, I think the correct approach is to make timeouts the default and not even expose the timeout interface to users of urllib (we also don't have to patch urllib that way). Anyone who currently manipulates the HTTP() socket to deal with timeouts will not be affected. And I think you'd agree that httplib is the most common case for urllib. Is that clearer? -- --- 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 kc5tja at garnet.armored.net Sat Dec 4 22:12:26 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 5 Dec 1999 03:12:26 GMT Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD81@gandalf.digicool.com> Message-ID: In article , Brian Lloyd wrote: Message ID: <613145F79272D211914B0020AFF6401914DD81 at gandalf.digicool.com> >> Highly satisfactory. Now all we need is a truly open COM >> implementation. I'm working on that right as we speak. I know the COM 0.9 specification on Microsoft's site is old, but it does serve as a useful foundation upon which a more modern COM implementation can be made. In fact, I'm stratifying the COM specification into two major levels: Level 1: Generic COM, or GCOM for short. This is the absolute minimum COM implementation possible. Level 2: GCOM Basic Services. These provide support functions and interfaces for things like monikers and other 100% Windows-independent things. As much as I hate to say it, this does NOT include uniform data transfer, as that uses a lot of data structures and definitions found in the Windows API. Anything above this, as far as I'm concerned, is implementation-specific stuff (for instance, one can conceivably make a Windows-compatible COM library which implements the Windows-specific stuff on top of GCOM level 2). >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 :^) No way. COM is contemporary, not legacy. And even then, it fills a very different need than the academically correct "object oriented" systems such as Python. I foresee a use for both types of objects for a long time to come. For example, the in-house work I'm doing for my company can make far, far better use of COM objects than the traditional notion of objects. Which is why I'm working on porting a minimal compliment of COM to Linux. :-) -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From fredrik at pythonware.com Fri Dec 17 07:03:54 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 17 Dec 1999 13:03:54 +0100 Subject: LISTS: Extract every other element References: <19991216131341.A153923@vislab.epa.gov> Message-ID: <031301bf4886$ced004e0$f29b12c2@secret.pythonware.com> 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,... ] footnote: a = b[::2] should work, but it doesn't. see http://www.python.org/doc/current/ref/slicings.html for further details. maybe in 1.6? From gmcm at hypernet.com Thu Dec 23 10:36:55 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 23 Dec 1999 10:36:55 -0500 Subject: Super-rexex? In-Reply-To: <14434.14004.510906.767308@weyr.cnri.reston.va.us> References: <19991223151828.A3636@stopcontact.palga.uucp> Message-ID: <1266159968-30845431@hypernet.com> Fred L. Drake, Jr. wrote: > Gerrit Holl writes: [snip] > 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. Isn't that the kind of parsing that shlex is good at? I'm inclined to think that John's (highly capable, wonderful, etc. etc.) tools are bit more than is required here. - Gordon From aa8vb at yahoo.com Thu Dec 16 13:13:41 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 16 Dec 1999 13:13:41 -0500 Subject: LISTS: Extract every other element Message-ID: <19991216131341.A153923@vislab.epa.gov> 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?: lst2 = [ None ] * len(lst)/2 for i in xrange( 0, len(lst), 2 ): lst2[i/2] = lst[i] -- Randall Hopper aa8vb at yahoo.com From zigu50 at yahoo.com Wed Dec 15 06:04:46 1999 From: zigu50 at yahoo.com (Nicola Ferrari) Date: Wed, 15 Dec 1999 12:04:46 +0100 Subject: output redirection Message-ID: <837sjt$osh$1@news1.sunrise.ch> Hi, I'm working with python 1.52 and tkinter (I've installed Tcl/Tk 8.0.5) under windows NT4.0 Python uses a self made C++ library which produces lots of outputs to the standard output. I would like to redirect these outputs from the python interpreter console to another sink (for example a file), but I'm not able to capture it...could someone help me? thank you in advance nicola ferrari From romberg at smaug.fsl.noaa.gov Wed Dec 15 13:23:11 1999 From: romberg at smaug.fsl.noaa.gov (Mike Romberg) Date: 15 Dec 1999 11:23:11 -0700 Subject: site.py as a frozen module? Message-ID: I've been attempting to use site.py as a frozen module. Unfortunatly it does not seem to work. I have verified that the module is correctly setup as a frozen module and I can import it with a regular ole' import. But python is not loading it on its own. The docs I've read don't really say if this should work or not. So... I'm wondering if anyone out there knows if this can be done. Thanks, Mike Romberg (romberg at fsl.noaa.gov) From gawron at obop.com.pl Wed Dec 8 06:47:38 1999 From: gawron at obop.com.pl (=?iso-8859-2?Q?Przemys=B3aw?= G. =?iso-8859-2?Q?Gawro=F1ski?=) Date: Wed, 08 Dec 1999 12:47:38 +0100 Subject: packing (struct module) Message-ID: <384E455A.61969B1D@obop.com.pl> I have a file with tab separated fields (posibly a different number in a different file, but the same within the file). I would like to pack it using some thing like this: import struct f = open( 'afile', 'r' ) lines = f.readlines() packedLines = [] if len( lines ) > 0: formatString = '1f' * lines[ 0 ].len() for l in lines: packedLines.append( struct.pack( formatString, l )) At this moment I would have a list of packed strings in packedLines. The problem is in the last line of code, since I cann't pass a list to the pack function. I would be very thank full, for sugestions on how to do this. Thanks Przemek From stidolph at origin.ea.com Wed Dec 1 08:44:11 1999 From: stidolph at origin.ea.com (Stidolph, David) Date: Wed, 1 Dec 1999 07:44:11 -0600 Subject: wish: multiline comments Message-ID: <11A17AA2B9EAD111BCEA00A0C9B41793034AAF53@molach.origin.ea.com> 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. -----Original Message----- From: Ionel Simionescu [mailto:ionel at psy.uva.nl] Sent: Wednesday, December 01, 1999 6:17 AM To: python-list at python.org Subject: wish: multiline comments Hi, I would like to see multiline comments possible in some future version of Python. Thank you, ionel -- http://www.python.org/mailman/listinfo/python-list From gerrit.holl at pobox.com Fri Dec 24 14:44:33 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 24 Dec 1999 20:44:33 +0100 Subject: Syntaxerror.offset? Message-ID: <19991224204433.A5753@stopcontact.palga.uucp> Hello, I'm using a subclass of SyntaxError for parsing a users file. But when raising an error, I've got a problem: what should I say by `offset'? Merry Christmas! regards, Gerrit. -- 8:33pm up 9:09, 15 users, load average: 0.00, 0.00, 0.00 From Dan at Grassi.com Sun Dec 5 21:09:57 1999 From: Dan at Grassi.com (Dan Grassi) Date: Sun, 05 Dec 1999 21:09:57 -0500 Subject: Very useful message -- Hah! References: Message-ID: in article jwbaxter-0512991744110001 at otter.olympus.net, John W. Baxter at jwbaxter at olympus.net wrote on 12/5/99 8:44 PM: > And I'm wondering why Python and Perl are so widely used to implement CGI > code if it is nearly impossible. Perhaps the 1,000,000 domain's that are running php are an indication of a change. Look at http://php3.org/usage.php3 But no on want to even consider that things _could_ be better! How interesting. Dan From turtle at sk.sympatico.ca Wed Dec 15 14:17:10 1999 From: turtle at sk.sympatico.ca (Kelly Parker) Date: 15 Dec 1999 19:17:10 GMT Subject: Christmas Gift Message-ID: <838pfm$fl$4799@news.filehills.com> It is Christmas time again. If you are interested in something really unique that you can only purchase through this posting, you are in luck. For a limited time we are offering the best Native Music and Limited Edition Canadian wildlife art prints available in North America. We take VISA over a toll free line anywhere in North America, and Money orders. There is only one way to view this Art and Music, send an email to turtle at sk.sympatico.ca and type "yes" in the subject line. You will be sent information on where to aquire this rare collection. Thank you, Tim From rdudfield at my-deja.com Tue Dec 28 07:04:56 1999 From: rdudfield at my-deja.com (rdudfield at my-deja.com) Date: Tue, 28 Dec 1999 12:04:56 GMT Subject: obj in list and list ids the same Message-ID: <84a8k4$puq$1@nnrp1.deja.com> 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. This happens when I am trying to copy a list of objects (sheets ) in the current object into a object which is also in a list( not the same one). Then I try to copy a object (shape) from a global list into a list inside a sheet object which is inside a list in the node object. The real problem I am having is when from in a method of an object(node), I copy a self.list of objects ( using copy.copy ) into a new node that I have created. This bit seems to work all right. The problem happens when I insert a object(shape) into a list within a node objects list of shapes. I hope this all makes sense... What it does is make the shape appear in sheet object in current node as well. This shouldn't happen. Any tips for getting around referencing problems? Like what are the prefered ways to copy a list? I didn't post the source cause I thought it was a bit big. Thanks for any help in advance. Sent via Deja.com http://www.deja.com/ Before you buy. From e_l_green at hotmail.com Mon Dec 27 10:20:50 1999 From: e_l_green at hotmail.com (Eric Lee Green) Date: Mon, 27 Dec 1999 08:20:50 -0700 Subject: Interface files was: Re: Python Considered Harmful References: <38673E22.C0D2155A@prescod.net> Message-ID: Paul Prescod wrote: > I don't appreciate the subject line. It doesn't seem to honestly reflect > your opinion and it just gives newcomers to the newsgroup a bad first > impression. Sorry. I was channeling Dijkstra at the time (grin). (Is he still alive?). > Eric Lee Green wrote: > > > > 1) The interface specification is the implementation. There is no seperate > > ".h" file such as with C++ that would contain the interface specification. > > With a big "C" or C++ project I print out the ".h" files and there's my > > interface specification > >... > > [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' :-). > problem is documentation then the better strategy is to write tools > specific to documentation rather than changing the programming language > to fit the needs of the documentation system. You are encouraged to help > us with the definition and implementation of those tools. In particular > see: > > http://www.python.org/pipermail/doc-sig/1999-December/thread.html > > You'll see we have something much more useful and elaborate than > printing out .h files under development. 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. > > 2) Debugging is a mess. The problem is that I tend to "stub" things a lot, or > > reference > > functions that have not yet been written (they're in the design doc, okay, so > > I know what their interfaces will be, I just haven't written them yet!). With > > a compiled language I run the compiler and linker and it tells me "hey stupid, > > you're missing something". > > There are various efforts under way to allow you to treat Python as a > statically checked (even binary-compiled) language if you want it to. Actually, wouldn't JPython do this for me? I'm not familiar with it, but I thought that it produced Java byte-codes? > > Of course, there's the one big advantage of Python -- it's quicker'n greased > > lightning for writing things in. I did in a month what would have taken four > > months in C++... > > It seems to me that that is really what matters, isn't it? Well, it's nice if the program works right too (grin). -E From grant at nowhere. Wed Dec 22 11:11:45 1999 From: grant at nowhere. (Grant Edwards) Date: Wed, 22 Dec 1999 16:11:45 GMT Subject: Bad programming style? References: Message-ID: In article , Sposhua wrote: >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. Yes, you can do this in Python by creating the string "r = 'ff'" and then executing it with "exec" or eval(). Any language that can execute data can do this -- Lisp is probably the most (in)famous example. It's an extremely powerful tool. [TNT is an extremely power tool. But, if you're planting petunias I recommend a spade: it's not as exciting, but it's easier to control the size of the hole, and you're not as likely to loose a limb.] Likewise, executing dynamically generated program code can at times be useful, but it's an easy way to have your program blow up in your face. OTOH, In Python you can (IIRC) create separate local and global namespaces for use by the code you run using exec or eval -- that should act as a good firewall: preventing a lot of collateral damage to your program's state-space when the inevitible does happen. Have fun, and remember to wear eye protection... -- Grant Edwards grante Yow! I feel real at SOPHISTICATED being in visi.com FRANCE! From hsmyers at sdragons.com Sun Dec 26 16:37:56 1999 From: hsmyers at sdragons.com (hsmyers at sdragons.com) Date: Sun, 26 Dec 1999 21:37:56 GMT Subject: problem accessing Access Message-ID: <8461k1$vnt$1@nnrp1.deja.com> With the following I get: >>> from win32com.client.dynamic import Dispatch >>> dbEngine = Dispatch('DAO.DBEngine') >>> db = dbEngine.OpenDatabase('c:/my documents/eco.mdb') >>> rs = db.OpenRecordset('ECO') >>> rs.Index = 'FEN' Traceback (innermost last): File "", line 1, in ? File "C:\Program Files\Python\win32com\client\dynamic.py", line 439, in __setattr__ raise AttributeError, "Property '%s.%s' can not be set." % (self._username_, attr) AttributeError: Property '.Index' can not be set. >>> The equivalent code in VB: Set db = Workspaces(0).OpenDatabase("C:\My Documents\eco") Set rsECO = db.OpenRecordset("ECO", dbOpenTable) rsECO.Index = "FEN" works just fine... All of which suggests that I'm doing something wrong---but I've no clue as to what? hsm Sent via Deja.com http://www.deja.com/ Before you buy. From alex at magenta.com Thu Dec 9 15:00:42 1999 From: alex at magenta.com (alex at magenta.com) Date: Thu, 09 Dec 1999 20:00:42 GMT Subject: some random reflections... Message-ID: <82p1p6$gdh$1@nnrp1.deja.com> Steve Tregidgo (smst at quantisci.co.uk) writes: [snip] > 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 But that would break if two loops were nested, a frequent need: for a in X: for b in X: mungle(a,b) as I mentioned in passing, in explaining why I think it would be better for X to be able to return an "enumerator object" (one implementing __next__ kinds of things) rather than doing the __next__-ish things itself -- that would break nested loops. Alex Sent via Deja.com http://www.deja.com/ Before you buy. From wtanksle at hawking.armored.net Sun Dec 12 20:25:28 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 13 Dec 1999 01:25:28 GMT Subject: List comprehension... References: Message-ID: On 13 Dec 1999 01:39:12 +0100, Magnus L. Hetland wrote: >Is list comprehension on its way into the language? Or is that just a >rumour, based on Greg's patch? I hope it's going it. >And - as allways, I can't leave the syntax alone without a suggestion >of my own... Greg's patch works like this (among other things): The amusing thing is that I tried to do the exact same thing as you're about to try. > [(i, s) for i in nums for s in strs] >To me, this sounds a bit like > [(i, s) for i in [nums for s in strs]] >which I guess doesn't give much meaning. I think the syntax would be >clearer (and more natural language-like) with an "and" instead of the >"for"s, after the first one. The first ones marks that this is the >list of (i, s) for all of the "i"s and all of the "s"s given. Thus: > [(i, s) for i in nums and s in strs] First of all, notice that "nums and s" is a valid parse of the middle of this string. Thus, it's ambiguous. Second, even if it wasn't, you forgot that 'if' is a valid keyword in such a comprehension. > Magnus -- -William "Billy" Tanksley, in hoc signo hack From fredrik at pythonware.com Fri Dec 17 07:58:29 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 17 Dec 1999 13:58:29 +0100 Subject: Packer References: <38585E6C.E286051B@pivot.net> Message-ID: <042601bf488e$73543e80$f29b12c2@secret.pythonware.com> Wayne wrote: > I'm have a screen layout that looks like this. Well, I want it to look > like this! > > Name of the window > > item 1 item > 2 item 3 > item 4 item > 5 item 6 > __________________ > > item 7 item > 8 item 9 > item 10 item > 11 item 12 not sure I understand, but that's probably because I'm looking at it with a proportional font. but I suspect you should forget about the packer, and use the grid manager instead: http://www.pythonware.com/library/tkinter/introduction/grid.htm From rvprasad at ksu.edu Wed Dec 8 00:52:45 1999 From: rvprasad at ksu.edu (Venkatesh Prasad Ranganath) Date: Wed, 08 Dec 1999 00:52:45 -0500 Subject: Linux.Com References: <384DC8F1.9A1F135F@easystreet.com> Message-ID: <384DF22D.A4BBEBBD@ksu.edu> Hi, Python is in the second place in the poll of scripting languages followed by PHP and many others. Yet to beat Perl. -------------- next part -------------- A non-text attachment was scrubbed... Name: rvprasad.vcf Type: text/x-vcard Size: 399 bytes Desc: Card for Venkatesh Prasad Ranganath URL: From bitbucket at isomedia.com Tue Dec 28 02:12:29 1999 From: bitbucket at isomedia.com (Eugene Goodrich) Date: Tue, 28 Dec 1999 07:12:29 GMT Subject: why? References: Message-ID: <38685b07.189574443@news.isomedia.com> 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? As a newbie-in-transition, I can stick up for Python by saying that it's easy to learn compared to a lot of other languages, but it doesn't have a buncha lotta shortcomings like some of the other (so-called) easy-to-learn languages. Without going into detail about things the language offers, I can say* that everything good you've ever heard about PERL is true about Python, only moreso. (And only a little of what you've heard is bad about PERL is true about Python.) (* I can say it, regardless of whether I'm right or wrong.) To give some specifics about some tasks you can do with it, you can: * fetch web pages with it and parse the results, removing HTML tags and reformatting it to display the portions of the page one-by-one. More specifically, you could make a script that asks for a word, looks the word up at a web dictionary, de-HTMLizes the results and displays them. * talk to news servers, requesting headers for a bunch of news articles you don't intend to read so you can strip out the email addresses and put them in a database. (Please note that doing this can shorten your lifespan by a lot.) * parse 2,000 word-perfect macro files that each contain a single person's or company's snail-mail contact information and put all the names and addresses into a CSV text file for someone to import into an address book. * open Microsoft Excel (r,c,whatever) files using Microsoft Excel (via COM) and change them or convert them to a different format. * simulate different web browsers and/or make a large number of requests of a web server to test features of a dynamic website, such as web-based voting or browser-capability-detection. * clean dinosaur-bone data out of Microsoft Access databases, connecting to them and running queries using Microsoft Access Data Objects (unless you'd prefer to do it a more difficult way). * recursively read all the directories on your hard disk and make a framed HTML index of all the jpeg images, so that loading this page in a web browser and clicking on the index items seamlessly brings up the indicated jpeg in the other frame window. * write a distributed application that involves worker scripts that run on a remote computer with a high-speed internet connection and do a lot of web surfing and that connect to a "mother" machine across the Internet that has a lower-speed connection but that has a SQL server to store refined data in. For added bonus points, implement a scheme such that when the "mother" machine is disconnected from the lower-speed connection every 5 hours and gets a new I.P. address when it reconnects, the "child" machine(s) can learn the "mother" machine's new I.P. address. * Replace VBScript as your language of choice for writing ASP pages. An added benefit of doing this is that you're not totally locked into using the Evil Empire's web server platform, because you'll know a "civilized" language. This list is not exhaustive, just as explaining that you can write poems and shopping lists with a pen and paper is not exhaustive of the activities a pen and paper can perform. And I may or may not have done all, some, or any of the above items. (I'll let the others talk about features, comparisons to other languages, syntactical joys, and the other 99 billion uses I didn't list.) -Eugene import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==') From scherbi at bam.com Thu Dec 30 09:23:28 1999 From: scherbi at bam.com (Bill Scherer) Date: Thu, 30 Dec 1999 09:23:28 -0500 Subject: Problems With stringformating... URGEND References: <386c66fc.6336922@news.carinthia.com> Message-ID: <386B6AE0.CAAF9570@bam.com> It appears to me that you just need to replace: """ %emailrec, markt_alt, markt, markt, id with: """ % (emailrec, markt_alt, markt, markt, id) After making this change, it works for me. 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 > > """ %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 > > -- > http://www.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff Bell Atlantic Mobile 914 365 7265 -------------- 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 tjreedy at udel.edu Wed Dec 22 14:48:41 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 22 Dec 1999 19:48:41 GMT Subject: Need a recursion lesson References: <83pdbe$5fj$1@news07.btx.dtag.de> Message-ID: <83r9up$fqa$1@news.udel.edu> In article <83pdbe$5fj$1 at news07.btx.dtag.de>, nickliz at t-online.de says... >I have no clue what I'm doing. Does anyone have any pointers to about how to >walk through something like this? Any help would be a lot. As RRoy already noted, the wheel is already programmed. To see how is works, look at the source code in the library path module (may be macpath, posixpath, ntpath, depeding on system). TJR From mhammond at skippinet.com.au Tue Dec 14 08:07:33 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 14 Dec 1999 13:07:33 GMT Subject: Lists of lists over COM, how? References: <6D8A17398E28D3119F860090274DD7DB4B3D30@pces.cadlab.it> Message-ID: Alex Martelli wrote in message <6D8A17398E28D3119F860090274DD7DB4B3D30 at pces.cadlab.it>... >Martin writes: > >> I'd like to return a set of database records to Python in a single >> variable >> from a COM object in C++ and had hoped I could use a two-dimensional >> VARIANT >> array for this. Looking through the SafeArray* functions in the WIN API >> they >> only allow arrays of a single basic type. I had hoped that a list of lists >> >Yep, but the basic type can be VARIANT -- and, inside a VARIANT, >among other things, you can stuff other (so-called SAFE-:-)ARRAYs, >so you can do complicated stuff if you wish:-). But, in fact...: Actually, SAFEARRAYs can be fully multi-dimensional - and Python supports them - except that in Python, each dimension must be the same size - ie, you must use a "square" sequence of sequences (of sequences ...). Which is fine for the intended application (and for most :-) Although if you are exposing this as a COM object, you could consider defining and using a "record" object... Mark. From thomas at bibsyst.no Mon Dec 13 08:51:11 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Mon, 13 Dec 1999 14:51:11 +0100 Subject: CDCover module ?? Message-ID: <3854F9CF.BBE5D92F@bibsyst.no> Hi, Some time ago I saw a module mentioned here in relation to a cddb-module ( I think ) that would fetch a cover to artist/group from some server ( pretty vague I know, but please ...). Any info on this subject would be appreciated, both on the name of the server in question and the module. Thanks. Best regards, Thomas Weholt From ogata at pobox-u-spam-u-die.com Sun Dec 19 17:28:37 1999 From: ogata at pobox-u-spam-u-die.com (Jefferson Ogata) Date: Sun, 19 Dec 1999 17:28:37 -0500 Subject: Script to add passwords References: <385BE5B1.80A48C80@rubic.com> Message-ID: Cameron Laird wrote: > Expect is wonderful, Python's wonderful, CGI keeps > rolling on. I use 'em all, of course. > > I'm tempted to give different advice to this ques- > tioner, though. He explains his motivation as a > need to automate an IMAP server (automation is also > wonderful, while I'm in a judgmental mode). What > I'm doing nowadays for most clients with e-mail needs > is setting up Unix servers where IMAP and brothers > (SMTP, POP) work from some authentication method > *other* than account validation. I like having > 10,000 e-mail accounts, but only eleven valid logins. > I don't hang out with other SysAds enough to judge > how widespread/accepted/successful/... this is. > It works for me, though, and I'm curious how others > see it. man chroot chroot your mail delivery and access stuff. Then you can set up a separate /etc/passwd, /etc/shadow that only grants mail access, because interactive programs aren't available. You still use normal authentication methods. -- Jefferson Ogata : Internetworker, Antibozo smtp: http://www.pobox.com/~ogata/ ICQ: 19569681 whois: jo317 at whois.networksolutions.com finger: ogata at pobox-u-spam-u-die.com From nospam at bitbucket.com Thu Dec 2 04:27:34 1999 From: nospam at bitbucket.com (Phil Mayes) Date: Thu, 2 Dec 1999 01:27:34 -0800 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: 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 From hei at adtranzsig.de Tue Dec 21 06:47:50 1999 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Tue, 21 Dec 1999 12:47:50 +0100 Subject: PYTHONPATH References: <9mBfONcXjnSNEDSMbOcLzJW8BG+Q@4ax.com> Message-ID: <945779888.127299@news.adtranzsig.de> >>> import sys >>> print sys.path ['', 'D:\\Programme\\Python', 'D:\\Programme\\Python\\Pythonwin', 'D:\\Programme\\Python\\win32', 'D:\\Programme\\Python\\win32\\lib', 'D:\\Programme\\Python', 'e:\\py', 'D:\\Programme\\Python\\Lib\\plat-win', 'D:\\Programme\\Python\\Lib', 'D:\\Programme\\Python\\DLLs', 'D:\\Programme\\Python\\DLLs', 'D:\\Programme\\Python\\lib', 'D:\\Programme\\Python\\lib\\plat-win', 'D:\\Programme\\Python\\lib\\lib-tk', 'D:\\Programme\\Python\\Pythonwin'] >>> sys.path.append("c:\\temp") >>> This adds a new dir to the path. -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net Anders M Eriksson schrieb in Nachricht <9mBfONcXjnSNEDSMbOcLzJW8BG+Q at 4ax.com>... >Hello! > >I'm a beginner 'Pythonneer' and I'm trying to get Python to work on my >Internet account. The ISP has installed Python 1.5.1 so the 'core' is >there and I've got it working but now I want to use HTMLgen to create >some html pages. Since the ISP hasn't installed HTMLgen I did on my >local account but I dont know how to change/create PYTHONPATH! From m.faassen at vet.uu.nl Fri Dec 3 11:07:58 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Dec 1999 16:07:58 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> Message-ID: <828psu$jco$1@newshost.accu.uu.nl> ajmayo at my-deja.com wrote: [snip snip snip] [Complaints about Perl] > 1. I hate, oh how I hate, the metacharacter at the front of every > variable which defines its type. Ah, Python doesn't have this. :) > 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? People complain about Python's error messages too. They're exceptions and propagate up from the line where the error occured; a traceback is produced and in the traceback you can also see the function where things went wrong. Still, people generally seem to say that Perl's 'use strict' mode produces better error messages than Python does. Though apparently some work is being done on this. > 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). Python doesn't do many compile time checks at all. Python class instances can have all kinds of member assignments during run-time and nothing's checked. That said, Python's OO facilities makes the creation of 'structure' type objects a lot easier than what I've seen of Perl. Also there's the struct module, which I haven't used, so let someone else talk about this. It's mostly for interfacing with C structs, though. > 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.. Zope's quite nice, though you're in for a heck of a learning curve. That is, fairly basic use of Zope isn't that hard to learn, but there's *lots* to learn after that. But I like Zope a lot and I'd recommend it. > 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? No point whatsoever. :) > 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. Most people get used to it within a few days, and then start stumbling over block delimiters in other languages. What are all those extraneous }s doing there? That was my experience, at least, and I've seen other people say the same in this newsgroup. There are a few staunch whitespace resisters in the group as well who agree with you that the use of delimiters would've been better for Python, but still like Python for other reasons. Anyway, give whitespace a try. Emacs with its python-mode is lovely with it, for instance, though other editors can be used as well. > 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). Javascript clean and elegant? :) My main exposure to javascript has been rape & paste scripts in web pages, full of browser-specific hackery, so I keep wishing the major browsers lightened up and started to support Python as the scripting language. Though I heard one can use Python with ActiveScripting inside internet explorer, and of course there's JPython as well. > Apart from the indentation, that is. I had trouble seeing where block > scope ends. Do give it a try; I think most people get past their troubles very quickly. > 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. Why would you be dynamically creating code? Anyway, if you are, you'd have to emit the right amount of spaces, but that's not really that hard: def emit_indented(f, lines, indent): indent_str = " " * indent for line in lines: f.write(indent_str) f.write(line) f.write("\n") # completely untested code > What if I > want to continue a line of code over multiple physical lines? You use \ (like in C): a very long\ line Though if something's in (), {} or [] you don't always have to: def lotsofarguments(foo, bar, baz): > So tell me, Python aficionados. > 1. Will I get over my initial confusion?. (can I use braces, or > BEGIN/END - I presume not) There's somekind of tool I believe that allows you to use begin/end (don't know its location but I think it's somewhere in the python distribution). I've never used it, as I got over my initial confusion. :) > 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.... It tends to produce NameError exceptions at things like this, and gives a traceback, like this: Traceback (innermost last): File "test.py", line 2, in ? foo = bar + 1 NameError: bar But I thought Perl gave fairly informative error messages as well? > 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. I don't know the JavaScript approach myself. You can use the struct and array modules to construct C like structs and arrays. Generally Python objects and lists are fine and much nicer to use, though. > 4. Is anyone here also using Zope. What do you think of it? I'm using Zope, as reported earlier in my reply. Zope's very very powerful, extensible and flexible. It is also underdocumented in some areas, though it does have lots of documentation (and the source as a last recourse). Its DTML sometimes gets convoluted when pushed beyond its original domain of reporting language, but it can be very powerful when used as a reporting language. Luckily there's always Python to make up for things. Zope's user community is about as nice as Python's (and there is of course overlap). Lots of cool stuff is continuously being developed. I believe Zope has a great future ahead. > 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?. I believe so, but I'll let the more knowledgable people answer that one. > (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). I wouldn't either if I were your colleague. :) Good luck! Was-that-gentle-enough?-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From ajung at sz-sb.de Wed Dec 1 01:52:28 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Wed, 1 Dec 1999 07:52:28 +0100 Subject: how to do *simple* syntax checking? In-Reply-To: <821nss$99v$1@nnrp1.deja.com>; from prestonlanders@my-deja.com on Tue, Nov 30, 1999 at 11:50:53PM +0000 References: <821nss$99v$1@nnrp1.deja.com> Message-ID: <19991201075228.A15658@sz-sb.de> On Tue, Nov 30, 1999 at 11:50:53PM +0000, Preston Landers wrote: > Okay, I know there was an earlier thread regarding pre-distribution > syntax checking (and the virtual impossibility of same). > > I understand Python is a dynamicly typed language, and I have no real > need to be able to find previously undeclared names in code before I > run it. > > However, it would be enormously helpful for me to be able to do > *simple* checks on Python code at make/'make install' time. Like > catching whitespace/indentation problems, missing semicolons, and the > like. > > I maintain a large set of Python programs, some of which are accessed > through a CGI interface. I develop some code, run make install, > restart my web server (not always though) and then load up my URL. > Only to find "500 Internal Server Error." > > Usually, if it's not a namespace issue, it's something silly like a > missing semicolon. But I have to track through the server logs to find > out what went wrong. > > I thought that Python's compile() function would be what I want, > because I thought that the SyntaxError exception was thrown when making > bytecode. But that's not the case, unless I was notably un-thorough in > my investigation. > > Basically, what I want is to do something like this for every Python > program in my makefile: > > try: > simple_syntax_check("myfile.py") > except: > # file is no good, abort make process > > # ... continue with make > > Am I just dreaming? Is this unrealistic? Or is this kind of thing > fully availible and documented and I am just blind? > > thanks, The following code should do the job: try: import myfile except: print 'content-type: text/plain' print '' print 'my program sux' sys.exit(1) myfile.main() Cheers, Andreas From gmcm at hypernet.com Thu Dec 2 14:22:18 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 2 Dec 1999 14:22:18 -0500 Subject: use Userdict for class __dict__ In-Reply-To: <3846b6aa@199.186.16.51> Message-ID: <1267959992-1768983@hypernet.com> Gang Li writes: > The proxy only works with instance. I want something working > with class, and the class subclass it will inherent the same > properties. Under normal circumstances, a class __dict__ (or base class __dict__) will be static, since it will be mutated only by an explicit reference through the class object. But if that's what you really want, you could get at least part of it by doing a metaclass. You can't override the definition of a class __dict__, though, because getattr, as you found out, assumes a real dict (it goes through the C interface, not the Python interface). So the metaclass would just use some variation on this same proxy trick. > "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 > > > > > > > > -- > http://www.python.org/mailman/listinfo/python-list - Gordon From jmb at xs4all.nl Tue Dec 14 09:21:03 1999 From: jmb at xs4all.nl (Hans Blaauw) Date: Tue, 14 Dec 1999 14:21:03 GMT Subject: Python & Mysql Message-ID: <19991214.14210300@mis.configured.host> Hello, Can someone send me a small example of python using the mysql database ? i'm learning to program and i want to use databases, i read some documents about the use of mysql within python but somehow i cannot ubderstand it without having some sort of example... if you have an example please mail it to jmb at xs4all.nl Many thanks !! Salut! Hans Blaauw From gerrit.holl at pobox.com Sat Dec 4 17:09:19 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sat, 4 Dec 1999 23:09:19 +0100 Subject: "%(a)s ... %(b)s" % {'a': foo, 'b': '%(b)s'} In-Reply-To: ; from mwh21@cam.ac.uk on Sat, Dec 04, 1999 at 03:26:54PM +0000 References: <19991204161814.A5289@stopcontact.palga.uucp> Message-ID: <19991204230919.A1360@stopcontact.palga.uucp> Michael Hudson wrote: > Gerrit Holl writes: > > > Hello, > > > > I'm facing the following problem. I set __version__ and now I set a string > > like this: > > > > 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? > > If you know the order you will be filling the fields in, then you can > double up the `%' signs, like: > > >>> __version__ = 1 > >>> t = "%(version)s %%(email)s"%{"version":__version__} > >>> t > '1 %(email)s' >>> s='%% sign, %%(email)s, %(version)s, %%%% sign' >>> s2=s % {'version': 1} >>> print s2 % sign, %(email)s, 1, %% sign >>> print s2 % {'email': 'gerrit at nl.linux.org'} {'email': 'gerrit at nl.linux.org'}ign, gerrit at nl.linux.org, 1, % sign kan lead to very unexspected things ;-) This can lead to ugly Quoting hell! > > or you could do > > >>> class NotQuiteDict: > def __getitem__(self,item): > if item == "version": > return "1" > else: > return "%%(%s)s"%item > > > >>> c = NotQuiteDict() > >>> "%(version)s %(email)s"%c > '1 %(email)s' > > which obviously needs generalisation, but I hope you get the idea. >>> class NotQuiteDict: ... dict = {} ... def __init__(self, **kw): ... for k, w in kw.items(): ... self.dict[k]=w ... # whitespace for readability :-) ... def __getitem__(self, item): ... if item in self.dict.keys(): ... return self.dict[item] ... else: ... return '%%(%s)s' % item >>> print '%(a)s, %(b)s' % NotQuiteDict(a='aaaa') aaaa, %(b)s But _why_ isn't this permitted: >>> print '%(a)s, %(b)s' % {'a': 'aaaa'} Traceback (innermost last): File "", line 1, in ? KeyError: b Can't Python automatticaly detect there's no B so leave it blank? Why doesn't Python do this? regards, Gerrit. -- "However, complexity is not always the enemy." -- Larry Wall (Open Sources, 1999 O'Reilly and Associates) 10:59pm up 36 min, 8 users, load average: 0.00, 0.01, 0.05 From ivanlan at callware.com Wed Dec 8 11:23:50 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 08 Dec 1999 09:23:50 -0700 Subject: Linux.Com References: Message-ID: <384E8616.19B738CA@callware.com> Hi All-- Jeffrey Kunce wrote: > > [Al Christians] > > Python is running a healthy 4th in the Linux.Com scripting > > languages poll. > > [Barry A. Warsaw] > > Looks like your message has rallied the troops! It's now running > > a distant second behind the 4-letter word of scripting languages :) > > > > Perl 42.65% (633) > > Python 16.31% (242) > > PHP 15.84% (235) > > [Tim Peters] > >Take heart: Deeper analysis of the data demonstrates that the Python votes > >are of much higher quality. > > And maybe, Python votes are more honest? > > ~10 hours later: > PHP 59.90 % (3306) > Perl 20.87 % (1152) > Scripting languages suck 6.99 % (386) > Python 6.34 % (350) > > It looks like PHP is good for writing a form-submission-bot > I wonder if our erstwhile friend Mr. Grassi is responsible? -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 robin at jessikat.demon.co.uk Thu Dec 9 10:29:04 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 9 Dec 1999 15:29:04 +0000 Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <6D8A17398E28D3119F860090274DD7DB4B3D04@pces.cadlab.it> <384F8E63.95B75B21@corrada.com> Message-ID: In article <384F8E63.95B75B21 at corrada.com>, Andres Corrada writes >Alex Martelli wrote: >> >> *THANKS* for this excellent piece of news, then!!! I'll be >> watching the news like a hawk (but my feed is flaky, so >> if there's any way I could get an email reminder when the >> time is right...). > >I'll keep you posted. > >------------------------------------------------------ >Andres Corrada-Emmanuel Email: andres at corrada.com >Owner http://www.corrada.com/mamey >Mamey Phone: (413) 587-9595 >------------------------------------------------------ > how do people support 'free' sites? Via advertising? -- Robin Becker From olivier.deckmyn at mail.dotcom.fr Sat Dec 4 04:09:19 1999 From: olivier.deckmyn at mail.dotcom.fr (Olivier Deckmyn) Date: Sat, 4 Dec 1999 10:09:19 +0100 Subject: Python Code Completion in an Editor Message-ID: <82alo7$5ko$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 kc5tja at garnet.armored.net Mon Dec 13 14:50:45 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 13 Dec 1999 19:50:45 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> <8336vj$c8k$1@nnrp1.deja.com> Message-ID: In article <8336vj$c8k$1 at nnrp1.deja.com>, e.e.sutton at cummins.com wrote: >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++. I strongly disagree with this. I found no less than three documents on Microsoft's web site which instructs the reader how to construct COM objects using C (which, by extension, includes assembly language for those who know how to read C as good as the English language ;) ) and C++. Check out http://www.microsoft.com/com (not msdn.microsoft.com!). There, you'll find plenty of examples on how to create new COM objects, how to register them with the operating system, how to build your object to handle aggregation and delegation, and more. 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 to create REAL COM objects is to use a compiled language, or an interpretted language which creates compiled stubs for your COM interfaces. -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From lull at acm.org Fri Dec 3 20:57:24 1999 From: lull at acm.org (John Lull) Date: Sat, 04 Dec 1999 01:57:24 GMT Subject: How to create cross between __getattr__() and __getitem__()? Message-ID: I'm trying to create a class where someting like: x = instance.undefined[i] works, given that "undefined" is the name of a previously-unknown attribute. I'd like to have that statement turn into one call something like: instance.getAttrItem(self, "undefined", i) which is invoked only once, with both the name of the unknown attribute and the desired index. Unfortunately, executing getAttrItem() is an expensive (ie very slow) operation, so I can't afford to try it any more times than absolutely necessary. My first thought was to have __getattr__() return a new object, containing a reference to "instance", the name of the attribute requested, and a __getitem__() procedure to handle the indexing operation by invoking newObject.instance.getAttrItem(). Unfortunately, though, I also need: x = instance.undefined to work normally (ie have __getattr__() invoke getAttrItem() without specifying an index), but I can't see any way for __getattr__() to know whether it should try getAttrItem() immediately or should create and return the new object. Can anyone suggest a (preferrably simple) way to accomplish this? Thanks. Regards, John From mfletch at tpresence.com Sun Dec 19 14:40:21 1999 From: mfletch at tpresence.com (Mike Fletcher) Date: Sun, 19 Dec 1999 14:40:21 -0500 Subject: LISTS: Extract every other element - SUMMARY Message-ID: Not with my testing on the code-as-given (incidentally, code as given had a nameerror on p in the second loop setup). I get: 1.098 -- algo7 1.052 -- for with multiply 1.134 -- for with divide 0.421 -- matrix step-slice 0.428 -- matrix reshape Those are with lists of size 10**7, similar results are seen at each size. However, your algo can be optimised to be twice as fast as in the following: def algo8(data): '''Chris' hard coded data slice without function call''' l = len(data) res = (l+1)/2 * [None] p=0 for p in xrange(0, l-99, 100): q = p/2 d = data[p:p+100] res[q:q+50] = [ d[ 1],d[ 3],d[ 5],d[ 7],d[ 9],d[11],d[13],d[15],d[17],d[19], d[21],d[23],d[25],d[27],d[29],d[31],d[33],d[35],d[37],d[39], d[41],d[43],d[45],d[47],d[49],d[51],d[53],d[55],d[57],d[59], d[61],d[63],d[65],d[67],d[69],d[71],d[73],d[75],d[77],d[79], d[81],d[83],d[85],d[87],d[89],d[91],d[93],d[95],d[97],d[99], ] for i in range(p+1, l, 2): res[i/2] = data[i] return res Still a tad shy of the Numeric results. But a big improvement over the other non-Numeric approaches. Time for this in testing on the same 10**7 list is 0.540 . Enjoy all, Mike -----Original Message----- From: Christian Tismer [mailto:tismer at appliedbiometrics.com] Sent: Sunday, December 19, 1999 1:16 PM To: Randall Hopper Cc: Adrian Eyre; python-list at python.org; Mike Fletcher Subject: Re: LISTS: Extract every other element - SUMMARY Hi Kids, the following will outperform everything by far, also Numeric. hee hee. ... From krutz at cg.tuwien.ac.at Wed Dec 15 13:11:00 1999 From: krutz at cg.tuwien.ac.at (Markus Krutz) Date: Wed, 15 Dec 1999 18:11:00 GMT Subject: bytecode to source Message-ID: <945280682.301456388@news.teleweb.at> Hi! Does anyone know of a module that decompiles bytecode files to source files? greetings Markus From edwardm_painewebber at my-deja.com Tue Dec 14 09:27:56 1999 From: edwardm_painewebber at my-deja.com (edwardm_painewebber at my-deja.com) Date: Tue, 14 Dec 1999 14:27:56 GMT Subject: win32ver module References: <833pct$r5b$1@nnrp1.deja.com> Message-ID: <835k57$3qd$1@nnrp1.deja.com> Thanks For The Info...I hope to hear back about the eventuality of the module. I don't have the necessary C/C++ skills or I would do it myself. Eagerly awaiting a win32ver module... In article , "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. > > Sent via Deja.com http://www.deja.com/ Before you buy. From ivanlan at callware.com Fri Dec 3 16:12:14 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Fri, 03 Dec 1999 14:12:14 -0700 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> <3847F117.3E2D1545@murl.com> <829b3u$mq6$1@newshost.accu.uu.nl> Message-ID: <3848322E.9CBDD81B@callware.com> Hi All-- Martijn Faassen wrote: > [snip] > Sure, just join the list. :) Gerrit posted about how to join it. I seem > to be alone on it so far.. > Martijn admits! He talks to himself in public! -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 Alex.Martelli at think3.com Fri Dec 17 09:14:15 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Fri, 17 Dec 1999 15:14:15 +0100 Subject: fileinput (was RE: "sins" (aka, acknowledged language problems)) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D55@pces.cadlab.it> Alexander Williams writes: > >import fileinput > >for line in fileinput.input(): > > The funny thing is that if Python had been /less/ intuitive, he'd have > stumbled over this class in the documentation in the course of digging > up file management. In fact, if he'd decided to just keep fiddling > with it for another half hour out of sheer bloody-mindedness, he would > have found it. > Assuming the "he" you mean is "me", I had indeed "stumbled over" the fileinput module, but it had struck me as an elegant approach to implement the typical "while(<>)" Perl idiom (with clearer syntax and more generality, of course, but that's par for the course:-); hardly appropriate for a function meant to copy-with-translation one arbitrary file onto another one, with stdin and stdout being just the defaults. Looking again at it I saw it had a bit more depth and generality, in that a FileInput object (or something polymorphic with it regarding iteration) might be about equivalent, as an argument to the function, to a file object (or something polymorphic with it regarding the readline method) -- perhaps better -- and surely allow the superior loop syntax I hanker for. Reading through the library docs doesn't guarantee one will realize the exact breadth and applicability of each module, of course -- that's what makes one a newbie as opposed to an old hand, innit?-) Alex From Dan at Grassi.com Sun Dec 5 18:23:13 1999 From: Dan at Grassi.com (Dan Grassi) Date: Sun, 05 Dec 1999 18:23:13 -0500 Subject: Python/cgi Was: Very useful message -- Hah! References: <82do53$2rhr$1@hub.org><384A9BE0.B345509@inka.de> <384ABC57.DDC3B61E@inka.de> <87u2lxuooi.fsf@freddy.page.street> Message-ID: in article slrn84lrkj.m5t.wtanksle at hawking.armored.net, William Tanksley at wtanksle at hawking.armored.net wrote on 12/5/99 5:56 PM: > I think I see what you're saying, but what you need isn't a new version of > Python, but rather an application (or library) which does something > different from what CGI does. You asked us about CGI, and then you > complained when Python implemented it correctly. OK, so the answer is to use php and not python on the web. So sad when pytjon is a much better language than php. I had hoped to have one language I could use for many things and that that language was going to be python. But it seems that I will use python for many things and php for the web. I can live with that. > Anyhow, what you want is likely already available -- if there's nothing > else, you can always use Zope, which is everything you need for a web app > all put together and made web-editable. Yes, I have looked at that. The main stumbling block is the in-availability of ZOPE from IHPs. Dan From NULL at my.pc Fri Dec 10 05:54:34 1999 From: NULL at my.pc (Sposhua) Date: Fri, 10 Dec 1999 10:54:34 -0000 Subject: stdout to file Message-ID: <82qm35$dt7$1@phys-ma.sol.co.uk> Right, useless newbie question here... Is there any point to using: file = open("inquisition.txt","w") file.write("Nobody expected it.\n") file.close() ...when this seems more efficient and closer to the shell: import sys sys.stout = open("inquisition.txt","w") print "Nobody expected it.\n" Are there occasions to use one instead of the other? Is #2 really more efficient? Also, in #2, do you have to "close" stdout (and if so how, sys.stout.close()?) and how do you reset stdout to the screen (.close() again?). Cheers PS, I'm sending this in Outlook, which I don't know very well. Does it look ok in Pine and other text-only mailers? Do the lines wrap at 70(ish) characters? From greg.ewing at compaq.com Mon Dec 13 08:27:40 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 14 Dec 1999 02:27:40 +1300 Subject: List comprehension... References: Message-ID: <3854F44C.DB24303B@compaq.com> "Magnus L. Hetland" wrote: > > [(i, s) for i in nums and s in strs] That would be ambiguous, because it could be parsed as [(i, s) for i in (nums and s in strs)] It *might* be feasible to use [(i, s) for i in nums and for s in strs] If I get a spare moment or two one day I'll try this and see whether the parser chokes. (Python's parser is a bit strange - it's hard to predict what it can handle and what it can't.) Greg From paul.m at yale.edu Wed Dec 1 12:20:17 1999 From: paul.m at yale.edu (Paul M) Date: Wed, 1 Dec 1999 12:20:17 -0500 Subject: wish: multiline comments References: <000b01bf3c10$4faf3910$3acbd9c2@peridot.optichrome.com> <018801bf3c12$d9722e80$f29b12c2@secret.pythonware.com> <009901bf3c15$6d5c5290$4500a8c0@thomasnotebook> <823l8h$shm$1@news.ycc.yale.edu> Message-ID: <823ldf$su4$1@news.ycc.yale.edu> Whoops, I sent that off without finishing... After importing foo2 there is a *.pyc file of ~ 2.6MB. Less than the original *.py file of 2.8MB but quite large still. Comments? Did I do something wrong? Paul M wrote in message <823l8h$shm$1 at news.ycc.yale.edu>... >Yes, but try: > > >Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 >Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>>> f = open('foo2.py', 'w') >>>> f.write('"""') >>>> for i in range(100000): >... f.write('a comment\nmore commenatry\n') >... >>>> f.write('"""') >>>> f.write('\nprint 'Finished!') > >Now try it. On NT4, with Python 1.5.2 I get.... > >C:\>python foo2.py >Finished! > >Now try importing it: > >>>> import foo2 >Finished! >>>> > >Tres Seaver wrote in message ... >> >>In article <009901bf3c15$6d5c5290$4500a8c0 at thomasnotebook>, >>Thomas Heller wrote: >>>> 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. >>> >>>AFAIK, python chokes on source files with more than >>>32767 lines (or was it 65536)? >>>But I never tried it. >>> >> >>[/home/tres] $ uname -a >>Linux silver 2.0.36 #1 Tue Oct 13 22:17:11 EDT 1998 i586 unknown >>[/home/tres] $ python >>Python 1.5.1 (#1, Jan 31 1999, 17:30:49) [GCC 2.7.2.3] on linux2 >>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>>>> f = open( 'foo.py', 'w' ) >>>>> for i in range( 100000 ): >>... f.write( 'x = 1\n' ) >>... >>>>> f.close() >>>>> ^D >>[/home/tres] $ python foo.py >>Memory fault (core dumped) >>[/home/tres] $ gdb python core >>GNU gdb 4.17.0.4 with Linux/x86 hardware watchpoint and FPU support >>Copyright 1998 Free Software Foundation, Inc. >>GDB is free software, covered by the GNU General Public License, and >you are >>welcome to change it and/or distribute copies of it under certain >conditions. >>Type "show copying" to see the conditions. >>There is absolutely no warranty for GDB. Type "show warranty" for >details. >>This GDB was configured as "i386-redhat-linux"... >>Core was generated by `python foo.py'. >>Program terminated with signal 11, Segmentation fault. >>Reading symbols from /lib/libdl.so.2...done. >>Reading symbols from /lib/libpthread.so.0...done. >>Reading symbols from /lib/libm.so.6...done. >>Reading symbols from /lib/libc.so.6...done. >>Reading symbols from /lib/ld-linux.so.2...done. >>#0 0x805f813 in PyNode_AddChild (n1=0x4005eff8, type=265, str=0x0, >> lineno=32768) at node.c:73 >>73 n = &n1->n_child[n1->n_nchildren++]; >>(gdb) where >>#0 0x805f813 in PyNode_AddChild (n1=0x4005eff8, type=265, str=0x0, >> lineno=32768) at node.c:73 >>#1 0x805fa46 in push (s=0x80b9340, type=265, d=0x808fb30, >newstate=1, >> lineno=32768) at parser.c:178 >>#2 0x805fbaf in PyParser_AddToken (ps=0x80b9340, type=1, >str=0x9d3a588 "x", >> lineno=32768) at parser.c:263 >>#3 0x804f4eb in parsetok (tok=0x80ae1d8, g=0x8090390, start=257, >> err_ret=0xbffffc24) at parsetok.c:163 >>#4 0x804f3f1 in PyParser_ParseFile (fp=0x8094908, >> filename=0xbffffeb2 "foo.py", g=0x8090390, start=257, ps1=0x0, >ps2=0x0, >> err_ret=0xbffffc24) at parsetok.c:113 >>#5 0x805bf5c in PyParser_SimpleParseFile (fp=0x8094908, >> filename=0xbffffeb2 "foo.py", start=257) at pythonrun.c:946 >>#6 0x805bdcd in PyRun_File (fp=0x8094908, filename=0xbffffeb2 >"foo.py", >> start=257, globals=0x8095d68, locals=0x8095d68) at >pythonrun.c:855 >>#7 0x805b5a6 in PyRun_SimpleFile (fp=0x8094908, filename=0xbffffeb2 >"foo.py") >> at pythonrun.c:565 >>#8 0x805b235 in PyRun_AnyFile (fp=0x8094908, filename=0xbffffeb2 >"foo.py") >> at pythonrun.c:444 >>#9 0x804f281 in Py_Main (argc=2, argv=0xbffffdf8) at main.c:286 >>#10 0x804ed22 in main (argc=2, argv=0xbffffdf8) at python.c:10 >>(gdb) >> >>It GPFs on NT4 with 1.5.2, as well. >> >>Tres. >>-- >>--------------------------------------------------------------- >>Tres Seaver tseaver at palladion.com 713-523-6582 >>Palladion Software http://www.palladion.com > From python-list at teleo.net Tue Dec 7 01:56:42 1999 From: python-list at teleo.net (Patrick Phalen) Date: Mon, 6 Dec 1999 22:56:42 -0800 Subject: Very useful message -- Hah! In-Reply-To: References: Message-ID: <99120622591102.02133@quadra.teleo.net> [Dan Grassi, on Sun, 05 Dec 1999] :: The death keel is when one can't see one's own short commings. Sadly that :: is this group. :: :: Bye, :: :: Dan Bye. From rvprasad at ksu.edu Sun Dec 12 13:07:57 1999 From: rvprasad at ksu.edu (Venkatesh Prasad Ranganath) Date: Sun, 12 Dec 1999 13:07:57 -0500 Subject: 500 Internal ... not the same of Dan References: <82j3c6$87h$1@nnrp1.deja.com> Message-ID: <3853E47D.1110E6B8@ksu.edu> Hi, Thought this may narrow down the options in which you think there may be errors. Internal server Error is an error from the HTTP Server serving the client. It may occur when the cgi script did not respond as required(format I mean) or the cgi script failed to execute. These are few cases where, when I worked with cgi scripts, I got INTERNAL SERVER ERROR. So, you may wanna test the script doesnot fail under any condition. Since, you say the script runs, it may be the case that it fails for certain cases. Failure being not executing to completion or the response which it generates not being compliant with the response CGI scripts should be. I presume the printing out to the stdout suitable CGI response (Content/type: ... blah blah) - Venkatesh -------------- next part -------------- A non-text attachment was scrubbed... Name: rvprasad.vcf Type: text/x-vcard Size: 399 bytes Desc: Card for Venkatesh Prasad Ranganath URL: From mlh at vier.idi.ntnu.no Mon Dec 13 17:29:48 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 13 Dec 1999 23:29:48 +0100 Subject: List comprehension... References: <3854F44C.DB24303B@compaq.com> Message-ID: Greg Ewing writes: > "Magnus L. Hetland" wrote: > > > > [(i, s) for i in nums and s in strs] > > That would be ambiguous, because it could be parsed as > > [(i, s) for i in (nums and s in strs)] Which, in the case that nums is not an empty list, would be [(i, s) for i in nums] IC. Oh, well... But what about: [(i, s) for i in nums, and s in strs] This is still grammatically correct English, AFAIK... And the ", and" constellation does not have another valid interpretation, does it? (Though it might not be really pretty...) > > It *might* be feasible to use > > [(i, s) for i in nums and for s in strs] Nice. Much less confusing than just using the *for* directly. (Of course, any mechanisms of parallel iteration might be used here if they appear... Like [(i, s) for i, s in nums, strs] or something) > If I get a spare moment or two one day I'll try this > and see whether the parser chokes. (Python's parser > is a bit strange - it's hard to predict what it can > handle and what it can't.) Good :) > > Greg -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From flounder_pounder at telebot.com Sat Dec 4 17:54:34 1999 From: flounder_pounder at telebot.com (flounder) Date: Sat, 04 Dec 1999 22:54:34 +0000 Subject: Help with Tkinter! Message-ID: <38499BA9.58C1DB67@telebot.com> This is whats going on I was playing around today and decided to learn Python so I did. I have used TK before with both TCL and Perl so I am also using it with Python and I have ran into a problem. The problem is that I have a button that when clicked I want to pass a textvariable from a Entry class to the function and print into stdout what is entered into the text box at the time when the button is pushed but when I click the button it does not work. Here is an example of a simplified version of what I want to do. Please Help :-( #!/usr/bin/python from Tkinter import * i="" def test(i): print i mw = Tk() mw.title("Python/TK") Label(mw, text="This is written with Python/TK").pack(side=TOP) Entry(mw, textvariable=i).pack(side=TOP) Button(mw, text="TEST", command=test(i)).pack(side=TOP) mw.mainloop() From paul at prescod.net Wed Dec 29 08:44:23 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 29 Dec 1999 08:44:23 -0500 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> Message-ID: <386A1037.C6D458B3@prescod.net> Eugene Goodrich wrote: > > When I started in Python, my PyMentor described tuples as immutable > lists. When they start acting like much more than that, isn't it time > to use an object? I agree that tuples in Python are often used merely as immutable lists. This bothers me for several reasons: * that isn't what "tuple" means in mathematics. In most mathematics EVERYTHING is immutable. Tuples and lists are still distinct * why does Python need an immutable list type but not an immutable dictionary? * isn't immutability more a property of where an object is used than the objects actual type? For example, don't you sometimes want to pass a list to a function but guarantee that the list won't be modified? * it is because of this abuse that the "one-item tuple" problem arises so often. There is no such problem in mathematics because a one-item tuple does not make sense. In Python world we most often use tuples as mathematicians do. Really, a tuple is supposed to be a collection of things where the sender and the recieiver have agreed on the number of items in advance, and every item 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 . If you use tuples as mathematicians do then single-item tuples can never arise because senders and recievers would never agree on a "protocol" (used loosely) that involves 1 length tuples (why use a tuple!). Paul Prescod From emile at fenx.com Thu Dec 9 21:55:50 1999 From: emile at fenx.com (Emile van Sebille) Date: Thu, 9 Dec 1999 18:55:50 -0800 Subject: LinuxCom Message-ID: <002f01bf42ba$12d40ba0$01ffffc0@worldnet.att.net> postscript pascal pbasic pcl Emile van Sebille emile at fenx.com ------------------- Jim Richardson wrote in message news:... > On Wed, 8 Dec 1999 00:07:20 -0500 (EST), > Barry A. Warsaw, in the persona of , > brought forth the following words...: > > > > >>>>>> "AC" == Al Christians writes: > > > > AC> Python is running a healthy 4th in the Linux.Com scripting > > AC> languages poll. > > > >Looks like your message has rallied the troops! It's now running a > >distant second behind the 4-letter word of scripting languages :) > > > >Perl 42.65% (633) > >Python 16.31% (242) > >PHP 15.84% (235) > > > >Hmm... anybody think we need more `P' languages? > > > >-Barry > > > (not scripting but whattheheck) > Prolog? > PL/1 > pan > umm... I am running out, any others? > > -- > Jim Richardson > Anarchist, pagan and proud of it > WWW.eskimo.com/~warlock > Linux, because life's too short for a buggy OS. > > -- > http://www.python.org/mailman/listinfo/python-list > > From Alex.Martelli at think3.com Tue Dec 14 12:15:24 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Tue, 14 Dec 1999 18:15:24 +0100 Subject: newbie : books on python Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D37@pces.cadlab.it> Mahboob Hussain writes: > I program in C/C++/Java/Perl and want to learn Python. Could you suggest > a few good books / sites to get me started ? > www.python.org is the site from which everything starts -- once you've exhausted the site itself and the links it gives, you're Tim or Guido:-). My personal recommendation about books (speaking as a newbie busy catching up on his reading:-) is to go for the dated but excellent "Internet programming with Python" -- don't get fooled by the misleading title, it's really about Python, the internet comes into it just about as a source of interesting examples. I also liked O'Reilly's new "Learning Python". "Programming with Python", OTOH, I'd give a miss, if I were you -- I found it chaotic to the point that it turned me off Python for a while, and when I mentioned the fact recently on this list/newsgroup, most respondents seemed to agree with this evaluation. Alex From ivanlan at callware.com Sat Dec 4 19:48:53 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Sat, 04 Dec 1999 17:48:53 -0700 Subject: Screensaver hooks. ... Message-ID: <3849B675.98D5D356@callware.com> Hi All, but mostly Mark-- Just out of curiousity, does Win32API include hooks to enable the creation of screensavers? -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 55wgm_guy at my-deja.com Sun Dec 19 18:55:41 1999 From: 55wgm_guy at my-deja.com (55wgm_guy at my-deja.com) Date: Sun, 19 Dec 1999 23:55:41 GMT Subject: Very Stupid Newbie Question Regarding Databases Message-ID: <83jr9s$tco$1@nnrp1.deja.com> Okay, Im obviously new to the Python world, but I have a project Im working on that will require databases. In particular, I want to store multiple records in the format: Name: Email: Phone Number: (etc) Im starting to look at the gdbm, dbm, and anydbm modules. However, it seems to me that to store records in the above format would require some sort of key to retrieve a particular record. How can the *dbm modules do this? Sent via Deja.com http://www.deja.com/ Before you buy. From paul at prescod.net Mon Dec 27 05:23:30 1999 From: paul at prescod.net (Paul Prescod) Date: Mon, 27 Dec 1999 05:23:30 -0500 Subject: Interface files was: Re: Python Considered Harmful References: Message-ID: <38673E22.C0D2155A@prescod.net> I don't appreciate the subject line. It doesn't seem to honestly reflect your opinion and it just gives newcomers to the newsgroup a bad first impression. Eric Lee Green wrote: > > 1) The interface specification is the implementation. There is no seperate > ".h" file such as with C++ that would contain the interface specification. > With a big "C" or C++ project I print out the ".h" files and there's my > interface specification >... > [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 @%!#. That's why most Pythoners think that if your problem is documentation then the better strategy is to write tools specific to documentation rather than changing the programming language to fit the needs of the documentation system. You are encouraged to help us with the definition and implementation of those tools. In particular see: http://www.python.org/pipermail/doc-sig/1999-December/thread.html You'll see we have something much more useful and elaborate than printing out .h files under development. Interface files might be a good idea for OTHER reasons, not related just to documentation, so there is also some work being done on that front. > 2) Debugging is a mess. The problem is that I tend to "stub" things a lot, or > reference > functions that have not yet been written (they're in the design doc, okay, so > I know what their interfaces will be, I just haven't written them yet!). With > a compiled language I run the compiler and linker and it tells me "hey stupid, > you're missing something". There are various efforts under way to allow you to treat Python as a statically checked (even binary-compiled) language if you want it to. > Of course, there's the one big advantage of Python -- it's quicker'n greased > lightning for writing things in. I did in a month what would have taken four > months in C++... It seems to me that that is really what matters, isn't it? Paul Prescod From goodswell at mail.com Sat Dec 11 23:06:49 1999 From: goodswell at mail.com (goodswell at mail.com) Date: Saturday, 11 Dec 1999 22:06:49 -0600 Subject: Want to buy VCD, Gifts and Office tools Message-ID: <11129922.0649@mail.com> Anybody can tell me which Internet Store have about goods for sales..? please e-mail me..!! thanks for help. Stephen reg. From tim_one at email.msn.com Thu Dec 30 01:09:27 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 30 Dec 1999 01:09:27 -0500 Subject: __rcall__??? In-Reply-To: <385FB976.3F05FD33@math.okstate.edu> Message-ID: <000401bf528c$6d78de00$a02d153f@tim> [David C. Ullrich] > ... I must be a version behind again or something, "Emulating numeric > types" is 3.3.5 here. The current docs are always available on the web; note that they get updated independently of-- and more often than --interpreter releases. Try: http://www.python.org/doc/current/ref/numeric-types.html > 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. >> ... __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 suspect you shot yourself in the foot by doing something like from math import * without admitting to it . "import *" is evil. math.pow is not __builtin__.pow; only the latter is hooked by __pow__ methods; math.pow, like the rest of math, is just a thin wrapper around your vendor's libm (or moral equivalent). Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam IDLE 0.5 -- press F1 for help >>> pow(2, 17388, 17389) # in honor of the season, the 2000th prime 1 >>> pow >>> from math import pow >>> pow(2, 17388, 17389) Traceback (innermost last): File "", line 1, in ? pow(2, 17388, 17389) TypeError: 2-sequence, 3-sequence >>> > ... 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 . in-a-language-with-curried-functions-rcall-could-be-natural-ly y'rs - tim From thomas at bibsyst.no Thu Dec 30 05:48:17 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Thu, 30 Dec 1999 11:48:17 +0100 Subject: Module-repository References: <386A02A2.5CB32ED9@bibsyst.no> <84ctcp$88k$1@news.glas.net> <386A18E7.99420D1E@bibsyst.no> Message-ID: <386B3871.50EF0915@bibsyst.no> Thomas Weholt wrote: > > 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 Well, after checking the site out it looks great too, but some of the links, the ones I tested, seem to be dead or extremely slow. Thomas From nyamatongwe at my-deja.com Fri Dec 24 19:13:00 1999 From: nyamatongwe at my-deja.com (nyamatongwe at my-deja.com) Date: Sat, 25 Dec 1999 00:13:00 GMT Subject: Pythonwin: any plans for COM+? References: <3863c163.8797109@judy> Message-ID: <84121d$um7$1@nnrp1.deja.com> Reini Urban writes, > 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: You should discount the 1997 article by Mary Kirtland (and similar early articles) as the scope of COM+ has diminished greatly since that article. Neil Sent via Deja.com http://www.deja.com/ Before you buy. From jh at cddk.dk Tue Dec 21 05:28:56 1999 From: jh at cddk.dk (Jesper Hertel) Date: Tue, 21 Dec 1999 11:28:56 +0100 Subject: ugly python namespace bug References: Message-ID: <83nkpe$998$1@news1.tele.dk> As a suggestion, maybe Python could be changed to allow for "constant" definitions or so. Like const def type(..): ...something... or const a = 2 Variables (and functions) declared like this would then have a flag telling that it is not allowed to change it, and an exception would be raised if someone tried to do it. Built-in functions could then be declared like this. One problem by this is the backwards compatibility. If someone redefines built-in functions in existing programs, they would not be able to run these programs in new versions of Python. I haven't quite thought this through. Just thinking loud... Jesper Hertel Roy Smith wrote in message news:roy-1A6F62.16025920121999 at netnews.nyu.edu... > I had a function which use to look like this: > > for type in stuff: > if type == default: > etc... > > It worked fine, but for one reason or another, I decided to change the variable > name from type to option, but forgot to change it in one place, and ended up > with: > > for option in stuff: > if type == default: > etc... > > My code stopped working, with the equality test always failing. I scratched my > head a while until I found the problem, but then couldn't figure out why I > didn't get a name error ("type" undefined) until a co-worker pointed out that > type is a built-in function. My first version of the code just over-wrote the > default value of type! > > I see how it all works now, but boy, stuff like this sure does invite all sorts > of nasty debugging problems! > > -- > Roy Smith > New York University School of Medicine > From python-list at teleo.net Thu Dec 2 16:34:29 1999 From: python-list at teleo.net (Patrick Phalen) Date: Thu, 2 Dec 1999 13:34:29 -0800 Subject: A Date With Tim Peters... In-Reply-To: <826dtd$bre$1@newshost.accu.uu.nl> References: <199912020003.TAA13009@eric.cnri.reston.va.us> <826dtd$bre$1@newshost.accu.uu.nl> Message-ID: <99120213381607.04234@quadra.teleo.net> [Martijn Faassen, on Thu, 02 Dec 1999] :: 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. Great idea. For purposes of announcing this to the news media, I propose you call it The Y0K Bug. From shouldbe at message.com Tue Dec 7 07:56:34 1999 From: shouldbe at message.com (Arinte) Date: Tue, 7 Dec 1999 07:56:34 -0500 Subject: Help with tuples please? Message-ID: <82ivrl$744$1@rtpnews.raleigh.ibm.com> This is the third time I have posted this, but since I have gotten no replies I assume my other stuff wasn't clear enuff or there is a problem with python on my machine. I am in the process of moving to a win98 machine for testing instead of NT. Anywho, I have narrowed my problem down a bit. 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="" argvalue=0 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 From dan at grassi.org Sun Dec 5 17:02:56 1999 From: dan at grassi.org (dgrassi) Date: Sun, 5 Dec 1999 17:02:56 -0500 Subject: Very useful message -- Hah! Message-ID: <199912052201.RAA11125@mail3.mia.bellsouth.net> On 12/5/99 4:02 PM Fredrik Lundh wrote: >in your sample script, change: > > #!/usr/bin/python > >to: > > #!/usr/bin/python -u > >> > - or call sys.stdout.flush() at the appropriate >> > places (you have to import the sys module >> > first). >> >> But that won't work for syntax error -- right? > >it will work, if you've redirected sys.stderr to >sys.stdout (as you did in your sample). Not for me: #!/usr/bin/python -u import sys import traceback print "Content-type: text/html" print sys.stderr = sys.stdout try: print "as" print "ax" except: print "\n\n
"
 traceback.print_exc()


produces the Apache "Internal Server Error".

Dan



From lugh at interaccess.com  Mon Dec  6 23:25:34 1999
From: lugh at interaccess.com (Clyde Davidson)
Date: Mon, 06 Dec 1999 22:25:34 -0600
Subject: Tkinter 1.5.2 ??
References: <38499F30.54313C44@interaccess.com> <384BC3EA.477D5B86@att.com>
Message-ID: <384C8C3E.EBB3D674@interaccess.com>

Good site! Thanks.

Clyde




Alex Flinsch wrote:
> 
> Clyde Davidson wrote:
> 
> > I am starting to get into Python. So, I bought "Learning Python" and updated
> > the Python that came with my Red Hat 6.0. I found 1.5.2 in RPM. However the
> > Python-Tkinter wouldn't install because it conflicted with my regular
> > Tkinter-1.5.1, or so my RPM package told me. I have tried to find version
> > 1.5.2 of the regular Tkinter, but haven't had any luck.
> >
> > Where can I find Tkinter 1.5.2 for Linux? I would prefer an RPM.
> 
> The following can be found at rufus.w3.org
> python-1.5.2-3mdk.i586 - python 1.5.2 for Linux-Mandrake
> tkinter-1.5.2-2mdk.i586 - tkinter 1.5.2 for Linux-Mandrake
> pythonlib-1.23-1mdk.noarch - all of the broken python modules from RedHat fixed
> for python 1.5.2
> 
> Since Mandrake is mostly based on red Hat, you shouldn't have much of a problem
> installing them.


From malcolmt at smart.net.au  Thu Dec 16 23:11:11 1999
From: malcolmt at smart.net.au (Malcolm Tredinnick)
Date: Fri, 17 Dec 1999 15:11:11 +1100
Subject: "sins" (aka, acknowledged language problems)
In-Reply-To: <000f01bf483a$b2e33140$63a2143f@tim>; from Tim Peters on Thu, Dec 16, 1999 at 09:59:12PM -0500
References: <837usr$6vg$1@serv1.iunet.it> <000f01bf483a$b2e33140$63a2143f@tim>
Message-ID: <19991217151111.A1413@Ridcully.home>

On Thu, Dec 16, 1999 at 09:59:12PM -0500, Tim Peters wrote:
> There is not.  A couple years ago I started a thread (see DejaNews) called
> "Why Python Stinks", hoping to uncover enough suppressed outrage to write a
> similar article about Python (my motivation was much like yours below).
> People were kind enough to whine about their pet peeves, but there was no
> consensus!
[.. the usual well-balanced Tim-stuff snipped ... you all know how it goes..]

In other words, for the "average person" -- that is the one over there with
2.4 children and 1.83 legs -- Python is *perfect* (on at least 5 days out of
every 7)? Good to hear!

More seriously, I am somebody who had to overcome an early attraction to the
darker side of scripting (a.k.a. Perl) before discovering Python last year. I
pretty much agree with the "Seven Deadly Sins of Pearl" and with Tim's
comments on it. Having watched the periodic "Why Python sucks" threads on here
over time, I must again agree with the "there is no consensus"-consensus.
Everybody has their pet gripes, but few seem to stop using Python because of
it (Perl's almost built in obfuscation was actually discouraging me from using
it, to give an example of the other side of this coin).

There was a point to me writing this initially .... here we go ... found it
again: 

I suspect (attach credibility to this at your own risk) that the lack of an
acknowledged set of "deadly sins" in Python may be due to two reasons:

(1) Python is younger than Perl and was "designed" rather than "evolved"
(I'm thinking of Guido's efforts to write a better ABC here. Since I am not a
qualified Python historian, I am willing to accept corrections on this
gracefully.) Guido and other contributors looked at what was available,
assessed their weaknesses and strengths and tried to put together something
that was "sensible" in their opinion.

(2) The Python community is still smaller than the Perl community and a random
sweep through many computer systems will uncover more Perl scripts than
Python scripts. Maybe we ("the community") just haven't reached a large enough
mass yet to generate the required hatred of certain features.

[Note: I am not actually anti-Perl despite what it may look like here. I just
prefer Python]

Just my thoughts,
Malcolm Tredinnick

--
Quantum physics: the dreams stuff is made of




From stuart at excite.co.uk  Fri Dec 10 08:34:41 1999
From: stuart at excite.co.uk (stuart mcfadden)
Date: Fri, 10 Dec 1999 13:34:41 +0000
Subject: What do we call ourselves?
References: <3850734D.FD1D7A2C@callware.com>
Message-ID: <38510171.70EF3E54@excite.co.uk>


Ivan Van Laningham wrote:

>
>
> Quod erat demonstrandum:  we are all Parselmouths!
>
> -ly y'rs,
> Ivan
> ----------------------------------------------

The parse bit I can understand.............




From thomas.heller at ion-tof.com  Fri Dec 17 05:21:19 1999
From: thomas.heller at ion-tof.com (Thomas Heller)
Date: Fri, 17 Dec 1999 11:21:19 +0100
Subject: problem with an infinite loop
References: <6D8A17398E28D3119F860090274DD7DB4B3D52@pces.cadlab.it>
Message-ID: <008301bf4878$77040210$4500a8c0@thomasnotebook>

[python crashes on windows for infinite recursive calls]
> 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.
> 
Python includes code to check for infinite recursion, but
unfortunately on windows crashes before the limit is reached.
This has been discussed some time ago. This was the thread:

http://www.deja.com/[LBURL=_LBHT,LBT,ST_rn=ps]/threadmsg_ct.xp?AN=484471678

Christian Tismer posted a script which patches the python15.dll
binary (no recompiling needed)

http://www.deja.com/[LBURL=_LBHT,LBT,ST_rn=ap]/threadmsg_ct.xp?AN=484809938

> 
> Alex

Thomas




From grant at nowhere.  Thu Dec 23 14:44:44 1999
From: grant at nowhere. (Grant Edwards)
Date: Thu, 23 Dec 1999 19:44:44 GMT
Subject: __init__ keyword param for sub-class?
References:  <14434.30055.405044.204758@weyr.cnri.reston.va.us>
Message-ID: 

Fred L. Drake, Jr. wrote:

> > 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
>
>  That's what I've always done.  There is at least one proposal to
>extend the call syntax to make the apply() unnecessary, but it's not
>in the core (though I seem to recall a patch to actually implement
>it).

>        return Pmw.ScrolledText.__init__(self, *posArgs, **keyArgs)

Yea, I remember this being discussed.  It's certainly easier to
read this way.

>  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)

That would be cool too.  Certainly easer to read.

In my example I deleted the keyword option after begin grokked
by my method, even though the Pmw __init__() didn't complain
when I left it there.

In Python is it considered good practice for methods/functions
to complain about unrecognized keyword options, or are they
generally just ignored?

One thing I miss from having used Smalltalk is some general way
to refer to the superclass.  Having a method specify the
superclass explicitly hampers reuse (at least in theory), and
seems a bit more fragile.  I've read that picky a superclass
method would get sticky in a multiple inheritence system, but
the same issue comes up with overlapping superclass methods
that the subclass doesn't override.  Right? So, I don't know
why we couldn't use the same mechanism to pick
Super.methodName() that would be used to do self.methodName()
when methodName isn't overridden.

Did that make sense?

-- 
Grant Edwards                   grante             Yow!  O.K.! Speak with a
                                  at               PHILADELPHIA ACCENT!! Send
                               visi.com            out for CHINESE FOOD!! Hop
                                                   a JET!


From mhammond at skippinet.com.au  Mon Dec 13 18:10:55 1999
From: mhammond at skippinet.com.au (Mark Hammond)
Date: Mon, 13 Dec 1999 23:10:55 GMT
Subject: win32com: subclass a com object?
References: <830pi6$n4k$1@nnrp1.deja.com> <832skg$4bn$1@nnrp1.deja.com>
Message-ID: <32f54.31$Nq1.272@news-server.bigpond.net.au>

tiddlerdeja at my-deja.com wrote in message <832skg$4bn$1 at nnrp1.deja.com>...

>Roughly speaking, for COM object:
>
>class foo:
>    def bar():
>        # do something
>    def x():
>        # blah
>    def y():
>        # blaah
>
>If I want to create myFoo by inheriting from foo. I want to override
>the method bar in the derived class. Can I just do:
>
>class myFoo(foo):
>    def bar():
>        # myBar

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".

My earlier post in this thread showed how to do it for your own Python app.
Allowing it to work for other apps is more difficult, but I doubt that is
what you are after...

Mark.





From fredrik at pythonware.com  Wed Dec  8 03:03:23 1999
From: fredrik at pythonware.com (Fredrik Lundh)
Date: Wed, 8 Dec 1999 09:03:23 +0100
Subject: Python type checking?
References: <82j9u8$da7$1@nnrp1.deja.com> <82jdoj$gg5$1@nnrp1.deja.com>
Message-ID: <012601bf4152$b474a410$f29b12c2@secret.pythonware.com>

 wrote:
> if (type(argvalue) == 'int'):
>   argvalue = long(argvalue)

type(value) return type objects, not strings.
better make that:

    if type(argvalue) is types.IntType:
        ...

or:

    if type(argvalue) is type(0):
        ...






From frank.sergeant at redneck.net  Mon Dec 27 15:09:04 1999
From: frank.sergeant at redneck.net (Frank Sergeant)
Date: 27 Dec 1999 14:09:04 -0600
Subject: Py2K wishes
References: <38675B72.18A139FF@prescod.net> <87ogbcuym5.fsf@den.home.net> 
Message-ID: <87aemwuowv.fsf@den.home.net>

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


From mgushee at havenrock.com  Thu Dec 30 18:27:24 1999
From: mgushee at havenrock.com (Matt Gushee)
Date: 30 Dec 1999 18:27:24 -0500
Subject: need hlp-how to read gifs that are on html page
References: <84gm6p$9cf@masters0.InterNex.Net>
Message-ID: 

"Bryan Webb"  writes:

> Hi,
>     I have sampe code to read an html page. I need to be able to read the
> gif files that would be on the html page. ANy help would be appreciated,
> examples even better.

How about something like this?

from Tkinter import *

class VerySimpleImageViewer(Canvas):
	def __init__(self, parent):
		Canvas.__init__(self, parent)
		self.pack()
		self.images = {}
		self.margins = (8, 8)   # or whatever
		self.currentimage = None

	def load(self, url, imgdata):
		## Imgdata is raw GIF data retrieved from the web.
		## VerySimpleImageViewer doesn't know anything about
		## how to get the data.

		## I haven't actually used the 'data' argument -- it's
		## conceivable the graphic might need to be processed
		## somehow before doing this -- but from the docs it
		## looks like you can feed the stuff from directly
		## from the web to PhotoImage.

		imgname = some_unspecified_name_manipulating_function(url)
		self.images[imgname] = PhotoImage(data=imgdata)

	def view(self, imgname):
		if self.currentimage is not None:
			## This doesn't destroy the image, just
			## removes it from the canvas.
			self.delete(self.currentimage)
		x, y = self.margins
		self.currentimage = self.create_image(x, y,
						      self.images[imgname])




Of course, nothing is ever this simple in real life :-)


-- 
Matt Gushee
Portland, Maine, USA
mgushee at havenrock.com
http://www.havenrock.com/


From neelk at brick.cswv.com  Sun Dec  5 08:39:57 1999
From: neelk at brick.cswv.com (Neel Krishnaswami)
Date: 5 Dec 1999 13:39:57 GMT
Subject: map versus the 'for' loop
References: <000101bf3ea4$a0206720$df2d153f@tim>  
Message-ID: 

Will Ware  wrote:
>
>Pardon my density: I can easily see how to do this with "len", since
>I can type "len" at the prompt and get a ""
>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 "" object?

Python 1.5.2 (#8, May 12 1999, 17:46:31)  [GCC 2.7.2.1] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam

>>> import operator
>>> operator.add(3,4)
7

It also contains versions for the other common operators. 


Neel



From bpcolema at uncg.edu  Thu Dec  9 13:10:11 1999
From: bpcolema at uncg.edu (Bryan Patrick Coleman)
Date: Thu, 9 Dec 1999 13:10:11 -0500
Subject: Mercury tools
In-Reply-To: <384FEC7E.29FA069A@pobox.com>
References: <384FEC7E.29FA069A@pobox.com>
Message-ID: 

I may have obtained a job where I will be writing extentions to the
mercury testing tools. I was thinking that python would be a good language
to do this with and was wondering if anyone has already done anything
along this line.

-  Bryan Patrick Coleman  
   bpcolema at uncg.edu  
   http://www.uncg.edu/~bpcolema

   Triad Linux Users Group

   Octagram Linux
   octagram at excite.com



From ullrich at math.okstate.edu  Wed Dec 22 13:34:05 1999
From: ullrich at math.okstate.edu (David C. Ullrich)
Date: Wed, 22 Dec 1999 12:34:05 -0600
Subject: __rcall__???
References: <002101bf4a98$01eda860$922d153f@tim>  <385E74B8.CC2CFFC8@math.okstate.edu> <5A7D006DE6BA7FF7.9D85F69C1855DCF4.4E8922E4E6A266A3@lp.airnews.net>
Message-ID: <3861199C.316253C5@math.okstate.edu>


Tres Seaver wrote:

> [...]
>
> * double dispatch
>     selecting the method to be called based on the classes of both objects
>         involved (as distinct from single dispatch, like a virtual function in
>         C++,
>
> * multimethods (Lisp and derivatives)
>     all arguments contribute to the selection algorithm.
>
> * Visitor
>     a design pattern [1] used to implement double dispatch in languages
>         which don't have multimethods as a native construct.
>
> [1] "design pattern" is the meme to use when searching: try hillside.net for
>     starters

    Thanks. (Searching on "LISP + Visitor" turned up fascinating stuff about
the Knights of the Lambda Calculus, Chaitin's Omega, etc, but I not what
I was looking for.)

> [...]
> >
> >    Wondering-whether-you-guys-find-your-'-'-keys-wear-out-first'ly,
>
> yes-but-sinterklaas-brings-us-new-ones-each-year'ly,

    Oh-I-see'ly,

DU

>
> Tres.
> --
> ---------------------------------------------------------------
> Tres Seaver           tseaver at palladion.com       713-523-6582
> Palladion Software    http://www.palladion.com



From sposhua at my.pc  Fri Dec 10 12:30:36 1999
From: sposhua at my.pc (Sposhua)
Date: Fri, 10 Dec 1999 17:30:36 +0000
Subject: stdout to file
In-Reply-To: <19991210164251.A4161@stopcontact.palga.uucp>
References: <82qm35$dt7$1@phys-ma.sol.co.uk> <19991210164251.A4161@stopcontact.palga.uucp>
Message-ID: 

On Fri, 10 Dec 1999, Gerrit Holl wrote:

> Where in the world is pc?

Nowhere. Not a real Email addy (anti spam; I've been on the astro newsgroups B4
and suddenly been offered porn and "how to become a millionaire doing absolutely
no work" ;-)

> Sposhua wrote:
> > Right, useless newbie question here...
> 
> Never useless! *you* can learn from it!

I meant useless newbie, not useless question ;-)

> >>> sys.stdout = sys.__stdout__

*written down in my "cool python bits 'n bobs" book*

> The lines wrap OK.

Cool. PS to Gordon McMillan: downloaded PC Pine ;-)



From boud at rempt.xs4all.nl  Mon Dec 13 14:34:03 1999
From: boud at rempt.xs4all.nl (Boudewijn Rempt)
Date: 13 Dec 1999 19:34:03 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>
Message-ID: <833hnb$n42$1@news1.xs4all.nl>

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.

-- 

Boudewijn Rempt  | http://denden.conlang.org


From wjk at wjk.mv.com  Wed Dec 29 21:24:27 1999
From: wjk at wjk.mv.com (Wm. King)
Date: Wed, 29 Dec 1999 21:24:27 -0500
Subject: Equivalent to (a ? b : c) ?
References: 
Message-ID: <386AC25B.FB43924C@wjk.mv.com>

((x and [val1]) or [val2])[0]

equivalent to C:     x ? val1 : val2




From mhammond at skippinet.com.au  Sat Dec 11 23:06:29 1999
From: mhammond at skippinet.com.au (Mark Hammond)
Date: Sun, 12 Dec 1999 04:06:29 GMT
Subject: COM and Python threads
References: <054f0654.99279019@usw-ex0102-009.remarq.com>
Message-ID: <9bF44.5184$Cl3.30257@news-server.bigpond.net.au>

sven wrote in message <054f0654.99279019 at usw-ex0102-009.remarq.com>...
>I have an app that uses a third pary COM component for some image
>processing (using makepy).
>I'm now trying add multi-threading and it's not playing nice with the
>COM component. When the 2nd thread tries to get an instance of the
>component I get a COM error "Coinitialize not called".

So call pythoncom.CoInitialize() :-)

Each thread needs to call this function.  The Pythoncom extensions call it
from the main thread for you.

COMs threading models are complex, and I havent the time to explain them in
detail now (you will just have to by our book when it hits :-), but...

Lookup the docs for CoInitializeEx() in the win32com reference - it is
exalained there.  You may also choose to check out the docs at
msdn.microsoft.com.  You may prefer to call
pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED).  The main Python
thread actually calls CoInitializeEx with the value
COINIT_APARTMENTTHREADED - you can change this by setting sys.coinit_flags
before importing pythoncom.  If this actually makes things better or worse
really depends on the control, but if it supports free-threading, then it
should help.

Mark.





From herzog at online.de  Tue Dec 21 15:47:27 1999
From: herzog at online.de (Bernhard Herzog)
Date: 21 Dec 1999 21:47:27 +0100
Subject: Bug in python startup on linux? [Was: Wrong Executable? or something]
References:  <87d7s05upg.fsf@baal.winnegan.de>
Message-ID: 

Siggy Brentrup  writes:

> Clarence Gardner  writes:
> 
> > This is a problem I've seen on many linux systems.  They're all RedHat or
> > Mandrake (extended RedHat).
> 
> Same holds for Debian slink aka 2.1
> 
> I did a little more testing and found out that results depend on your
> PATH setting.
> 
> Calling scripts with an empty PATH gives the expected results
[snip proof]
> I suspect a bug in the python startup routine, since sys.prefix
> and sys.exec_prefix are determined at configuration time.

Python tries to initialize sys.path based on the location of the python
executable. If argv[0] contains no '/' python searches $PATH for the
executable and starts from there.

On Linux it seems that a program called by the #! mechanism only gets
the basename of the file in argv[0], i.e. there's no '/' and therefore
python searches through the directories in $PATH, so it might get the
wrong one.

I'm not sure whether this is to be considered a bug in Linux or Python,
but Python could perhaps work around this on a Linux system by using
/proc/self/exe (which is a symbolic link to the executable of the
process) as reference when it searches $PATH for the file.

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


From alex at magenta.com  Thu Dec 30 03:12:56 1999
From: alex at magenta.com (Alex Martelli)
Date: Thu, 30 Dec 1999 09:12:56 +0100
Subject: random number generation: the newbie asks for advice
References: <6D8A17398E28D3119F860090274DD7DB4B3D91@pces.cadlab.it> 
Message-ID: <006601bf529d$f0c44180$c02b2bc1@martelli>

Ivan Frohne writes:

: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.

Another EXCELLENT pointer -- thanks!!!  It is indeed quite possible that the
speed is sufficient for my purposes, and the package would have many
other advantages -- even if I should recode the basical generator in terms
of packaged C (for speed purposes), which may well not be needed, all of
the rest would still come in very, very handy.

May I humbly suggest that the use of MT as one of the generators be
mailed to Mr Matsumoto (cfr the MT homepage that was suggested on
another response to my question) -- he lists MT-using software on the
page and I have not seen any reference to this on checking the page
out earlier (there are MT implementations in anything from Haskell
to F90 to Java, but no mention of this Python one).


Thanks!!!

Alex the happy newbie






From paul.m at yale.edu  Wed Dec  1 12:17:39 1999
From: paul.m at yale.edu (Paul M)
Date: Wed, 1 Dec 1999 12:17:39 -0500
Subject: wish: multiline comments
References: <000b01bf3c10$4faf3910$3acbd9c2@peridot.optichrome.com> <018801bf3c12$d9722e80$f29b12c2@secret.pythonware.com> <009901bf3c15$6d5c5290$4500a8c0@thomasnotebook> 
Message-ID: <823l8h$shm$1@news.ycc.yale.edu>

Yes, but try:


Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> f = open('foo.py', 'w')
>>> f.write('"""')
>>> for i in range(100000):
...     f.write('a comment\nmore commenatry\n')
...
>>> f.write('"""')
>>> f.write('\nprint 'Finished!')

Now try it.  On NT4, with Python 1.5.2 I get....

C:\>python foo2.py
Finished!

Now try importing it:

>>> import foo2
Finished!
>>>

Tres Seaver wrote in message ...
>
>In article <009901bf3c15$6d5c5290$4500a8c0 at thomasnotebook>,
>Thomas Heller  wrote:
>>> 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.
>>
>>AFAIK, python chokes on source files with more than
>>32767 lines (or was it 65536)?
>>But I never tried it.
>>
>
>[/home/tres] $ uname -a
>Linux silver 2.0.36 #1 Tue Oct 13 22:17:11 EDT 1998 i586 unknown
>[/home/tres] $ python
>Python 1.5.1 (#1, Jan 31 1999, 17:30:49)  [GCC 2.7.2.3] on linux2
>Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>>> f = open( 'foo.py', 'w' )
>>>> for i in range( 100000 ):
>...    f.write( 'x = 1\n' )
>...
>>>> f.close()
>>>> ^D
>[/home/tres] $ python foo.py
>Memory fault (core dumped)
>[/home/tres] $ gdb python core
>GNU gdb 4.17.0.4 with Linux/x86 hardware watchpoint and FPU support
>Copyright 1998 Free Software Foundation, Inc.
>GDB is free software, covered by the GNU General Public License, and
you are
>welcome to change it and/or distribute copies of it under certain
conditions.
>Type "show copying" to see the conditions.
>There is absolutely no warranty for GDB.  Type "show warranty" for
details.
>This GDB was configured as "i386-redhat-linux"...
>Core was generated by `python foo.py'.
>Program terminated with signal 11, Segmentation fault.
>Reading symbols from /lib/libdl.so.2...done.
>Reading symbols from /lib/libpthread.so.0...done.
>Reading symbols from /lib/libm.so.6...done.
>Reading symbols from /lib/libc.so.6...done.
>Reading symbols from /lib/ld-linux.so.2...done.
>#0  0x805f813 in PyNode_AddChild (n1=0x4005eff8, type=265, str=0x0,
>    lineno=32768) at node.c:73
>73              n = &n1->n_child[n1->n_nchildren++];
>(gdb) where
>#0  0x805f813 in PyNode_AddChild (n1=0x4005eff8, type=265, str=0x0,
>    lineno=32768) at node.c:73
>#1  0x805fa46 in push (s=0x80b9340, type=265, d=0x808fb30,
newstate=1,
>    lineno=32768) at parser.c:178
>#2  0x805fbaf in PyParser_AddToken (ps=0x80b9340, type=1,
str=0x9d3a588 "x",
>    lineno=32768) at parser.c:263
>#3  0x804f4eb in parsetok (tok=0x80ae1d8, g=0x8090390, start=257,
>    err_ret=0xbffffc24) at parsetok.c:163
>#4  0x804f3f1 in PyParser_ParseFile (fp=0x8094908,
>    filename=0xbffffeb2 "foo.py", g=0x8090390, start=257, ps1=0x0,
ps2=0x0,
>    err_ret=0xbffffc24) at parsetok.c:113
>#5  0x805bf5c in PyParser_SimpleParseFile (fp=0x8094908,
>    filename=0xbffffeb2 "foo.py", start=257) at pythonrun.c:946
>#6  0x805bdcd in PyRun_File (fp=0x8094908, filename=0xbffffeb2
"foo.py",
>    start=257, globals=0x8095d68, locals=0x8095d68) at
pythonrun.c:855
>#7  0x805b5a6 in PyRun_SimpleFile (fp=0x8094908, filename=0xbffffeb2
"foo.py")
>    at pythonrun.c:565
>#8  0x805b235 in PyRun_AnyFile (fp=0x8094908, filename=0xbffffeb2
"foo.py")
>    at pythonrun.c:444
>#9  0x804f281 in Py_Main (argc=2, argv=0xbffffdf8) at main.c:286
>#10 0x804ed22 in main (argc=2, argv=0xbffffdf8) at python.c:10
>(gdb)
>
>It GPFs on NT4 with 1.5.2, as well.
>
>Tres.
>--
>---------------------------------------------------------------
>Tres Seaver           tseaver at palladion.com       713-523-6582
>Palladion Software    http://www.palladion.com




From aahz at netcom.com  Mon Dec 27 11:17:09 1999
From: aahz at netcom.com (Aahz Maruch)
Date: 27 Dec 1999 16:17:09 GMT
Subject: Speed issues
References: <19991227143547.A3500@stopcontact.palga.uucp>
Message-ID: <8483e5$lqd$1@nntp8.atl.mindspring.net>

In article <19991227143547.A3500 at stopcontact.palga.uucp>,
Gerrit Holl   wrote:
>
>is an assigment slower than appending to a list?

It's not the assignment that's slower, it's string copying -- remember
that strings are immutable, so that 'o=o+c' has to make a copy of 'o'
every time you go through the loop.  Therefore o.append()/string.join()
is faster.  Note that cStringIO is even faster (by about 5%), but it
introduces a dependency on an external library.
--
                      --- Aahz (@netcom.com)

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

Eighth Virtual Anniversary -- 4 days and counting!


From boud at rempt.xs4all.nl  Thu Dec 16 12:43:45 1999
From: boud at rempt.xs4all.nl (Boudewijn Rempt)
Date: 16 Dec 1999 17:43:45 GMT
Subject: Inheritance vs Composition (was Re: C++)
References: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it> <838uvo$sc7$1@news1.xs4all.nl> <83b3op$jfp$1@nntp6.atl.mindspring.net>
Message-ID: <83b8ch$6uc$1@news1.xs4all.nl>

Aahz Maruch  wrote:
> In article <838uvo$sc7$1 at news1.xs4all.nl>,
> Boudewijn Rempt  wrote:
>>
>>That makes C++ about as powerful as Visual Basic - in essence, no
>>inheritance at all, just interfaces... Having just done a large project
>>in Visual Basic, I've learnt how painfult that limitation can be - and
>>I was kind of surprised when I read in Design Patterns that composition
>>should be favoured over inheritance. There are no doubt good reasons,
>>but not one I can think of.

> Let me clarify: the difference between inheritance and composition is
> the difference between "is-a" and "has-a".  For example, you would not
> design a "car" object to be inherited from "engine", "chassis",
> "transmission", and so on ("car is-a engine" makes no sense) -- you
> would *compose* the car object from its constituent parts ("car has-a
> engine" makes a lot of sense).

> Once you start thinking in terms of "is-a" versus "has-a", it's a lot
> easier to do proper design.

Well, that's clear - even to me, and I am the very epitome of corporate
cubicle programmerhood (Sinologist, retrained in six month for Oracle
work, never read a good cs book until I started with Python). And that's
why I hate it when I can't - easily - use VB to build a 'better' grid
control - when I have to build a control that has a grid... It's not
just laziness, but also schedule, cost and maintenaince pressures.
Indeed, when I program for fun, I tend to start with doing a simple 
subclass of all the gui components I'm likely to want to customize,
in order to promote consistent behaviour, look and feel.

That's why I was surprised by recent sentiments about the relative value
of inheritance and composition - I guess that the recent trend is just
another fashion, and that the future will balance it.

-- 

Boudewijn Rempt  | http://denden.conlang.org


From guido at CNRI.Reston.VA.US  Wed Dec  1 19:03:31 1999
From: guido at CNRI.Reston.VA.US (Guido van Rossum)
Date: Wed, 01 Dec 1999 19:03:31 -0500
Subject: A Date With Tim Peters...
Message-ID: <199912020003.TAA13009@eric.cnri.reston.va.us>

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:

- 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.  Don't wait till
the last moment, register before Christmas!  More info:

    http://www.python.org/workshops/2000-01/

Conference motto (due to Bruce Eckel): "Life's better without braces."

--Guido van Rossum (home page: http://www.python.org/~guido/)



From marc_risney at my-deja.com  Tue Dec 14 23:07:19 1999
From: marc_risney at my-deja.com (marc_risney at my-deja.com)
Date: Wed, 15 Dec 1999 04:07:19 GMT
Subject: sys.stdin and Java class
References: <199912142326.SAA00634@eric.cnri.reston.va.us>
Message-ID: <83745k$8ca$1@nnrp1.deja.com>

Pyhtonistas, I am having the most frustrating
attempt at the following task:

In my CGI I have created a function that feeds a
Java class a string, the output is an encrypted
key, problem, how do I capture the ouptu and
using sendmail pass the Loadkey???
I have used os.popen, os.system, nothing appears
to work...Help please!!, the ouput is occuring
during teh HTML creation in my CGI and interfering
here is my function

def GenerateLicenceKey(prod,exprdate):
     key = "java Checksum " + str(prod) + "-1-1-0-
-1234-" + exprdate
     keyfile = open('keys.txt','a')


     rslts = sys.stdout.write(key)
     rslts = raw_input()
     keyfile.write(rslts)
     keyfile.close()



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


From dworkin at ccs.neu.edu  Wed Dec 22 16:46:27 1999
From: dworkin at ccs.neu.edu (Justin Sheehy)
Date: 22 Dec 1999 16:46:27 -0500
Subject: strptime on Unix systems
References: <19991222110107.A972@Ridcully.home>
Message-ID: 

"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())
  ^
(I assume that you meant `tt', and not `t'...

> 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.)

Really?

I would expect it to break regardless of the value of `format'.  You
are passing a tuple as the first argument to time.strptime, which is
expecting a string.

However, there does seem to be a linux problem here.

Under FreeBSD and Solaris, at least, the time module works fine with
the above format string:

Python 1.5.2 (#3, Aug 24 1999, 15:55:20)  [GCC 2.7.2.1] on freebsd3
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from time import *
>>> t = time()
>>> format = '%a %b %d %H:%M:%S %Z %Y' 
>>> int(t) == (mktime(strptime(strftime(format, localtime(t)),
format)))
1

But under linux:

Python 1.5.2 (#1, Oct 22 1999, 16:54:21)  [GCC 2.7.2.3] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> from time import *
>>> t = time()
>>> format = '%a %b %d %H:%M:%S %Z %Y' 
>>> int(t) == (mktime(strptime(strftime(format, localtime(t)),
format)))
Traceback (innermost last):
  File "", line 1, in ?
ValueError: format mismatch

Indeed, looking at the manual page for the linux system call
strptime(), it does not seem to accept %Z as a format specifier.

-Justin

 


From rvprasad at ksu.edu  Sun Dec 12 17:36:37 1999
From: rvprasad at ksu.edu (Venkatesh Prasad Ranganath)
Date: Sun, 12 Dec 1999 17:36:37 -0500
Subject: Help with Tkinter!
References: <38499BA9.58C1DB67@telebot.com>
Message-ID: <38542375.E04E928E@ksu.edu>

Hi,

Here is a chunk of code that does the same.  It's different due to some
limitations in Python/Tk.

      1 #!/usr/bin/python
      2 
      3 from Tkinter import *
      4 
      5 
      6 def test():
      7     print i.get()
      8 
      9 mw = Tk()
     10 mw.title("Python/TK")
     11 
     12 i=StringVar()
     13 Label(mw, text="This is written with Python/TK").pack(side=TOP)
     14 
     15 Entry(mw, textvariable=i).pack(side=TOP)
     16 
     17 Button(mw, text="TEST", command=test).pack(side=TOP)
     18 
     19 mw.mainloop()

It seems that i="" and textvariable=i doesnot work in python as it works
in Tcl.  The variable used in text variable should be a StringVar() or
the value of the variable when textvariable was assigned is considered
even if the value in the variable changes.

- Venkatesh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rvprasad.vcf
Type: text/x-vcard
Size: 399 bytes
Desc: Card for Venkatesh Prasad Ranganath
URL: 

From e_l_green at hotmail.com  Mon Dec 27 01:48:30 1999
From: e_l_green at hotmail.com (Eric Lee Green)
Date: Sun, 26 Dec 1999 23:48:30 -0700
Subject: Python Considered Harmful
Message-ID: 

Sorry, a bit of a troll involved in the title :-(. 

Anyhow, I have been prototyping a fairly large project in Python, and have
come across some decided disadvantages as compared with more traditional
language. Specificationally:

1) The interface specification is the implementation. There is no seperate
".h" file such as with C++ that would contain the interface specification.
With a big "C" or C++ project I print out the ".h" files and there's my
interface specification (obviously I advocate and follow the practice of
writing your C or C++ in an object-oriented modular manner!). I don't care
about the implementation once the module has been debugged, all I care about
is its interfaces. I can see the interfaces for the whole project by flipping
through one slender folder with the .h files printed out. I can't do that with
Python.

2) Debugging is a mess. The problem is that I tend to "stub" things a lot, or
reference
functions that have not yet been written (they're in the design doc, okay, so
I know what their interfaces will be, I just haven't written them yet!). With
a compiled language I run the compiler and linker and it tells me "hey stupid,
you're missing something". With Python, I run it, and it tells me "doh, you
forgot to create a method for 'checksum_packet'. I run it again, it tells me
'doh, you forgot to create a method for 'register_connection'. I run it
again.... ad nauseum. 

Of course, there's the one big advantage of Python -- it's quicker'n greased
lightning for writing things in. I did in a month what would have taken four
months in C++... just getting  a bit irritated in the process with the whole
interface/implementation thing, because it's making keeping the design doc and
the implementation in sync a pain in the @%!#....

And it could be worse. It could be Perl.

-E


From thomas at bibsyst.no  Fri Dec 31 06:48:12 1999
From: thomas at bibsyst.no (Thomas Weholt)
Date: Fri, 31 Dec 1999 12:48:12 +0100
Subject: RPM-interface/module
References: <386B3CDB.FF843280@bibsyst.no>
Message-ID: <386C97FC.389E6458@bibsyst.no>

Question 1:

I guess this module is written in C or something and uses lots of stuff
only available on Red Hat-systems? It`s not just one simple
rpm.py-module, cuz that would be just to easy. I`m sayind this because I
want to use this module in a software-package that should be able to run
on lots of platforms, or at least win32 and i386-flavours of linux, and
I`ll have to disable the rpm-feature if the host platform is other than
Red Hat. Not that this is a huge problem, but it would be nice to know
if I *had* to do it.

All I want is to read out info about a single rpm-file, not scan the
rpm-database or anything else fancy. The best possible thing would be
something like :

rpm-info = rpm.open("python-scripts_1_3.rpm")

where rpm-info was an object containg stuff like software-category etc.
If this is Red Hat, possibly Suse or any other rpm-using linux-distro.
specific, I`d be glad to know.

Question 2:

I`d like info on any other module available similar to PIL, PST and
mp3infor.py etc. Stuff that extracts info stored in files, like Linux
Debian software-packages, zip-files, cab-files etc. Whatever. If there
is standardized info stored inside a file, I want that info. It would be
nice to be able to open zip-files, scan for file_id.diz, readme or
nfo-files or any other user-specified file, and read those files, index
the contents etc.

I want to use all this in a cd-indexing package I`ve probably mentioned
a million times before. Modules, scripts or any other sort of
information related to the subjects below would be appreciated :

* mp3 - got software to extract id3-tag info. Need module to
fetch/locate cover-image on the net based on album-info in the id3-tag
* Need CD-ROM module. I want to extract cd-label, creation date and any
other info stored in cd-roms.
* Any sort of module that extracts info from common file-formats, like
compressed archives, executables, libraries etc. Got PIL/PST so sound
and images should be covered. Even if it`s platform dependant, I`ll just
disable/enable features accordingly to current host-platform.


Any help, ideas or tips appreciated.

Happy new year and thanks for all the help you`ve given me so far.

Best regards,
Thomas Weholt


From earlybird at mop.no  Wed Dec  1 22:20:25 1999
From: earlybird at mop.no (Alexander Staubo)
Date: Thu, 2 Dec 1999 04:20:25 +0100
Subject: JPython and using string module in applet
Message-ID: 

Whenever I import the Python string module into a JPython applet, the 
applet initialization breaks using the MS JVM.

Seems like a security problem, but the documentation alleges that 
most core modules will work out of the box. Perhaps not for applets?

What would I use in lieau of the string module?

-- 
Alexander Staubo             http://www.mop.no/~alex/
"Reality is that which, when you stop believing in it,
doesn't go away." --Philip K. Dick



From news at dorb.com  Wed Dec 22 09:55:58 1999
From: news at dorb.com (Darrell)
Date: Wed, 22 Dec 1999 09:55:58 -0500
Subject: Question about a regular expression
References: <385F67E7.B5E4E83@ikb.mavt.ethz.ch>  
Message-ID: 

This doesn't work if you have nested parens.

>>> s='(1(2))'
>>> print re.search(r"\((.*?)\)",s).groups()
('1(2',)
>>>

Look on deja for 'ASCII delimited files' , which has this same problem.

--
--Darrell
"Rob Hodges"  wrote in message
news:m3puvztau2.fsf at phaedrus.zen.xom...
> 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
>
> --
> http://www.python.org/mailman/listinfo/python-list




From aahz at netcom.com  Wed Dec 22 17:08:38 1999
From: aahz at netcom.com (Aahz Maruch)
Date: 22 Dec 1999 22:08:38 GMT
Subject: Offtopic: millenium
References: <199912222000.PAA17264@eric.cnri.reston.va.us> <19991222215733.A2783@stopcontact.palga.uucp>
Message-ID: <83ri56$58q$1@nntp3.atl.mindspring.net>

In article <19991222215733.A2783 at stopcontact.palga.uucp>,
Gerrit Holl   wrote:
>>
>> We know that the Python conference isn't until the next millennium.
>
>Hmm, we've already had a discussion on this, haven't we?

To quote my partner: milleNNium milleNNium milleNNium milleNNium 

;-)

(Don't worry about it, Gerrit, I've misspelled it, too.)
--
                      --- 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 jfarrell at mincom.com  Tue Dec 14 00:53:01 1999
From: jfarrell at mincom.com (John Farrell)
Date: Tue, 14 Dec 1999 15:53:01 +1000
Subject: Please Critique
References: 
Message-ID: <3855DB3D.998F3081@mincom.com>

The basic algorithm is fine, but you put too much stuff in. For example,
naming the output file and opening it is completely unnecessary, as you
can use the shell's output redirection to do that for you. Also, when
dealing with strings, using indexes is clumsy compared to using the
string itself. In my code below, I use implicit indices (list[:x] means
list[0:x] and list[x:] means list[x:-1]) and destroy the line, rather
than fiddling with start, end and startKey. Also, Python does not require
you to close files (I guess it closes the file when the last reference
goes away), so I left that out. Your iteration to join the values of the
map together is a classical way of doing that sort of thing, but in
situations where I can see a simple transformation to be done to a list of
objects, I like to use map and lambda (or list comprehensions, when they
are in the language).

John

> import string
> screenfile = open('scracc.txt')
> newfile = open('scrnew.txt', "w")
> for line in screenfile.readlines():
>     mydict = {}
>     trimline = line[4:-1]
>     start = 0
>     length = len(trimline)
>     while start < length:
>         end = start + 4
>         startkey = start + 1
>         mydict[trimline[startkey:end]] = trimline[start:end]
>         start = end
>     sortkeys = mydict.keys()
>     sortkeys.sort()
>     mylist = []
>     for key in sortkeys:
>         mylist.append(mydict[key])
>     newline = line[0:4] + string.joinfields(mylist, "") + "\n"
>     newfile.write(newline)
> screenfile.close()
> newfile.close()

import string
for line in open('scracc.txt').readlines():
    userid = line[:4]
    line = line[4:]
    mydict = { }
    while len(line) >= 4:
        instruction = line[0]
        number = line[1:4]
        line = line[4:]
        mydict[number] = instruction
    sortkeys = mydict.keys()
    sortkeys.sort()
    fields = map(lambda x: mydict[x] + x, sortkeys)
    print userid + string.join(fields, '')

-- 
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 tiddlerdeja at my-deja.com  Fri Dec 17 09:21:39 1999
From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com)
Date: Fri, 17 Dec 1999 14:21:39 GMT
Subject: pythoncom and MTS
References: <83b5lq$5tr$1@nnrp1.deja.com> 
Message-ID: <83dgtf$orc$1@nnrp1.deja.com>

Also Mark, I was just wondering, are you the sole developer on
pythoncom? Are there others?

In article ,
  "Mark Hammond"  wrote:
>  wrote in message
> news:83b5lq$5tr$1 at nnrp1.deja.com...
> > Does anyone know if you can implement MTS (Microsoft Transaction
> > Server) complient/safe COM objects in python?
>
> 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?
>
> > -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.
>
> Mark.
>
>


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


From robin at jessikat.demon.co.uk  Thu Dec 30 11:14:56 1999
From: robin at jessikat.demon.co.uk (Robin Becker)
Date: Thu, 30 Dec 1999 16:14:56 +0000
Subject: [ANNOUNCE] Pygasm IDE wxWindows Linux Developer Release
References: <386B510D.3EC3B9DB@pcpros.net>
 <19991230070826.B778039@vislab.epa.gov>
Message-ID: 

In article <19991230070826.B778039 at vislab.epa.gov>, Randall Hopper
 writes
....
>
>I pulled it and ran 'python Pygasm.py'.  Here's what I got:
>
>    > python Pygasm.py                         
>    importing wxPython...
>    imported wxPython
>    Traceback (innermost last):
>      File "Pygasm.py", line 7, in ?
>        import Editor
>      File "Editor.py", line 7, in ?
>        from EditorViews import *
>      File "EditorViews.py", line 3, in ?
>        from wxPython.html import *
>    ImportError: No module named html
....
works just about with Win95 1.5.2 2.11.1

Seems like the event model for the IDE is fairly broken with Win32 as
there are several top-levels which don't seem to respond until they
become active. I could get various frames to have things inside them,
but it's clearly in a very alpha state.
-- 
Robin Becker


From tjg at avalongroup.net  Wed Dec 29 19:35:13 1999
From: tjg at avalongroup.net (Timothy Grant)
Date: Wed, 29 Dec 1999 16:35:13 -0800
Subject: Python Database Connectivity
Message-ID: <386AA8C1.EAD7DD3B@exceptionalminds.com>

Hi,

Just wondering if anyone has used Python on Windows to connect to an
ODBC database?

-- 
Stand Fast,
    tjg.

Chief Technology Officer              tjg at exceptionalminds.com
Red Hat Certified Engineer            www.exceptionalminds.com
Avalon Technology Group, Inc.                   (503) 246-3630
>>>>>>>>>>>>EXCEPTIONAL MINDS, INNOVATIVE PRODUCTS<<<<<<<<<<<<



From kuncej at mail.conservation.state.mo.us  Fri Dec 17 11:25:00 1999
From: kuncej at mail.conservation.state.mo.us (Jeff Kunce)
Date: Fri, 17 Dec 1999 10:25:00 -0600
Subject: Control chars and special chars
References: <003401bf487e$99cb2610$3acbd9c2@peridot.optichrome.com>
Message-ID: <5wt64.1187$xu5.17450@news.more.net>

> >       for i in range(255): print i, chr(i)
>
> range(32, 256) would be more suitable in this case
>

Not necessarily. If you run python in an "MS-DOS window"
on NT, you get all kinds of interesting characters in range(32).

  --Jeff




From fredrik at pythonware.com  Sun Dec 19 12:40:50 1999
From: fredrik at pythonware.com (Fredrik Lundh)
Date: Sun, 19 Dec 1999 18:40:50 +0100
Subject: Tcl/Tk 8.2
References: <385D0C6D.D92B2F12@omnitechconsulting.com>
Message-ID: <011201bf4a48$5cb48b60$f29b12c2@secret.pythonware.com>

Steve Simonet (Omni)  wrote:
> 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?

iirc, you have to rebuild the tk library (it's linked
against the Tk and Tcl DLL's), and probably also tweak
the initialization code (before you rebuild...).

fwiw, we went back to 8.0.5 after a while; 8.2 was
simply not stable enough for production use (pro-
bably some problem in tkinter, but we never figured
out what it was).








From cjensen at be-research.ucsd.edu  Thu Dec 16 20:41:09 1999
From: cjensen at be-research.ucsd.edu (Curtis Jensen)
Date: Thu, 16 Dec 1999 17:41:09 -0800
Subject: Accessing C global variables from Python
Message-ID: <385994B5.6AD05BF0@be-research.ucsd.edu>

Is there a way to access the global variables in a C class from Python? 
Without passing arguments back and forth between the two languages. 
Also, is it possible to do the same thing between C and Fortran?  If so,
can some one explain it to me.  Thanks.

-- 
Curtis Jensen
cjensen at be-research.ucsd.edu
FAX (425) 740-1451


From gmcm at hypernet.com  Mon Dec  6 17:58:40 1999
From: gmcm at hypernet.com (Gordon McMillan)
Date: Mon, 6 Dec 1999 17:58:40 -0500
Subject: Struct and windll question (please help)
In-Reply-To: 
Message-ID: <1267601765-23337311@hypernet.com>

Calishar  wrote:

>   I am trying to call the infozip unzip32.dll (on a windows 95
>   system
> at the moment, but eventually on a winNT system too) in order to
> unzip a pkzip file (not gzip). Zlib doesn't seem to understand
> this type of file, so I am having to go outside standard python
> stuff.
> 
>   The calldll module has a function
>   (call_foreign_function(address,
> input_args_format, result_args_format, argument_tuple)) which
> should be able to do what I need. What I am having problems with
> is constructing the format strings and tuple.

>   The dll function I am calling has the following definition:
> 
> Wiz_SingleEntryUnzip(int ifnc, char **ifnv, int xfnc, char
> **xfnv,
>                      LPDCL lpDCL, LPUSERFUNCTIONS lpUserFunc)
> 
> where ifnv and xfnv can be Null. (I think the format code should
> be 'i255si255s??' (no idea for the structs) or (iPiP??) using the
> struct module codes. Or should I be using the codes from
> PyArg_ParseTuple? I am creating the two structs using struct.pack
> at the moment, is this right?

Maybe ;-). You need to create a buffer using calldll.membuf. 
You can read and write to this buffer, and get the address of it. 
Basically you need to fill this buffer with the C values (yes, 
you can use struct) and then use buff.address() + 
displacement where the C is expecting a pointer. Allocate 
space in the buffer for out args, and read() them once the call 
is done.

Here's an example from a dll whose name and purpose shall 
remain nameless. The signature of the function is:

# status = accu_io_buffers_to_dib( BYTE ** DIB,
#				BYTE * buff1,
#				BYTE * buff2,
#				BYTE * buff3,
#				DWORD data_type,
#				DWORD bits_per_pixel,
#				DWORD rows,
#				DWORD columns,
#				DWORD free_flag)

and the code is:

def buffer_to_dib(buffer, rows, cols):
	params = calldll.membuf(4)
	params.write('\000'*4)
	start = params.address()
	paramfmt = 'l'
	argfmt = 'l'*9
	calltpl = ( start,	#outbuff **
		  buffer,	#buffer1
		  0,	#buffer2
		  0,	#buffer3
		  0,	#data_type,
		  8,	#bpp,
		  rows,
		  cols,
		  1)
	rc = calldll.call_foreign_function(
		accu_io_buffers_to_dib_address,
		argfmt,
		'l',
		calltpl)	
	rslt = params.read(0, 4)
	rslt_tpl = struct.unpack(paramfmt, rslt)
	print "buffer_to_dib rc=%d pDIB=%d " % (rc, rslt_tpl[0])
	return rslt_tpl[0]

This is a very crude example. You can do much cleverer 
things with calldll, but I never learned how.

- Gordon



From mlh at vier.idi.ntnu.no  Mon Dec 20 09:03:01 1999
From: mlh at vier.idi.ntnu.no (Magnus L. Hetland)
Date: 20 Dec 1999 15:03:01 +0100
Subject: How to cite Python and Numerical Python in papers?
References: 
Message-ID: 

Kelvin Chu  writes:

> Hello, Python gurus;
> 
> I'd like to cite both Python and the Numerical Python extensions in
> the references for a paper that I'm writing.  Are there preferred
> references to give for each set of code?

The Columbia Manual of Online Style gives several alternatives for
this sort of thing... What would you like to do: Cite a description of
the language/software (i.e. documentation/web-pages) or the binaries
themselves (i.e. downloads identified through ftp address)?

> 
> Thanks very much.
> 
> KC
> 
> -- 
> 
>   kelvin.chu at uvm.nospam.edu			     (802) 656-0064
>   http://www.uvm.nospam..edu/~kchu/		FAX: (802) 656-0817
> 

-- 
--

  Magnus
  Lie
  Hetland


From roth at teleport.com  Mon Dec 27 17:03:41 1999
From: roth at teleport.com (tony roth)
Date: Mon, 27 Dec 1999 14:03:41 -0800
Subject: newbie win32 stuff
Message-ID: 

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,'xyzdomain'
,0,4096*2)
for x in dm[0]:
   try:

rk=win32api.RegConnectRegistry(str(x['name']),win32con.HKEY_LOCAL_MACHINE)

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'])





From skaller at maxtal.com.au  Sat Dec 25 18:12:28 1999
From: skaller at maxtal.com.au (skaller)
Date: Sun, 26 Dec 1999 10:12:28 +1100
Subject: Python suitability
References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> <113901bf470c$cb236f60$0100a8c0@rochester.rr.com>
Message-ID: <38654F5C.378F8338@maxtal.com.au>

Darrell wrote:

> 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.

	I wonder how your comments would be modified if you
separated 'Python' from 'the current CPython implementation':
 
> 1. Deciding on a directory structure ...

	Agree. Design problem in general, only partly relating
to python.

> 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.

	Partly an artefact of CPython 1.5.2's use of reference counting:
Viper and JPython use a real garbage collector.
 
> 3. Slicing and dicing huge strings is a performance problem. 

	An artefact of CPython 1.5.2. Viper is _specifically_
designed to make string manipulation much faster. Those 'good python'
tricks you've probably used will make it much harder for the
compiler to optimise string performance. The 'a+b+c' form is 
the easiest to optimise.

> 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.

	My recommendation is: if you really have to write C/C++ modules
for performance -- make sure you keep the python script version up
to date semantically. When a script compiler becomes available,
you may be able to abandon your hand written C/C++ code in favour of it.
 
> 6. Many of the things you do in C++ are to over come it's own
>     limitations.

	The main limitation of C++ wrt python is the ugly syntax,
and the quantity of it that is required to do something which is
simple in Python. After all, Python is written in a subset of C++.
Python simply 'pre-makes' some design decisions for you.
This is an advantage if these decisions suit your application,
and a hassle if they don't, and you have to work around them.

> Go for it, but remember there are no silver bullets, software is hard.

	Design is hard, yes.

-- 
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  Fri Dec 10 06:04:42 1999
From: fredrik at pythonware.com (Fredrik Lundh)
Date: Fri, 10 Dec 1999 12:04:42 +0100
Subject: newbie needs help on dictionary
References: <38504788.86E9C885@es.co.nz> <82qklq$qsu$2@ssauraaa-i-1.production.compuserve.com>
Message-ID: <022001bf42fe$d6bed420$f29b12c2@secret.pythonware.com>

Olaf Appelt  wrote:
> 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:

nope.

> > count = turret[station][tool_name]

after this statement, "count" is a reference.

> > count = count + 1

but after this statement, "count" is rebound to
point to a newly created integer object.  the
dictionary still points to the *original* value.






From tismer at appliedbiometrics.com  Thu Dec 16 15:23:27 1999
From: tismer at appliedbiometrics.com (Christian Tismer)
Date: Thu, 16 Dec 1999 21:23:27 +0100
Subject: Byte to integer conversion
References: <38593499.5BD58BD1@ithaca.dbnet.ece.ntua.gr>
Message-ID: <38594A3F.2786471B@appliedbiometrics.com>


Elefterios Stamatogiannakis wrote:
> 
>         How can i convert two, three, four bytes into an integer?

one byte is cheap with the ord function:

>>> ord("@")
64
>>> 

> 
>         I know a way with pickle, using loads() but i wonder is there
> a more elegant way of doing it.

There is the struct module which can do such stuff.

>>> import struct
>>> struct.unpack("b", "#")
(35,)
>>> struct.unpack("h", "xx")
(30840,)
>>> struct.unpack("i", "abcd")
(1684234849,)
>>> 

The three-byte case isn't handled there. If you are lazy
and just want it short, use

>>> arg="abc"
>>> struct.unpack("i", arg + "\0")
(6513249,)
>>> 

assuming little endian here of course.

>         I don't care about big, little endian problems

You should at least know it when you compute
your salary this way.

ciao - chris

-- 
Christian Tismer             :^)   
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home



From jbauer at rubic.com  Sun Dec 19 07:10:11 1999
From: jbauer at rubic.com (Jeff Bauer)
Date: Sun, 19 Dec 1999 06:10:11 -0600
Subject: Python Powered Logo
References: <385C1DEE.F0F75674@safenet.pl>
Message-ID: <385CCB23.13B5EA6D@rubic.com>

> I am working slowly but steadily on my Web site which 
> will use a lot of Python CGI scripts and I would like 
> to use the "Python Powered" logo (the same as the one 
> at www.python.org).  Does any of you know who should 
> I ask about a permission?

http://www.python.org/psa/Logo.html

License
  Just van Rossum, hereafter referred to as THE DESIGNER, 
  herewith grants anyone using Python (THE USER) the right 
  to use the above shown logo (THE LOGO), containing the 
  slogan "Python Powered" (THE SLOGAN), for the sole purpose 
  to promote the Python Programming Language (PYTHON) and 
  nothing else. THE DESIGNER claims full copyright of THE 
  LOGO excluding THE SLOGAN which was invented by several 
  people at the same time, so they should yack it out
  themselves. Blah blah blah blah. Blah NO WARRANTIES blah 
  blah EXPLICIT blah blah blah blah OR IMPLIED blah blah 
  blah. Blah. Blah blah Unlimited Redistribution of THE LOGO 
  by THE USER in Unmodified State is Allowed blah blah blah 
  blah provided that THE USER does not Charge for THE LOGO 
  or the viewing or transmission thereof blah blah blah blah 
  blah blah. By looking at THE LOGO, you agree with this 
  LICENSE. If you do not agree with this LICENSE, you had 
  better not looked at THE LOGO. 

  copyright ? 1997 Just van Rossum 

---
Jeff Bauer
Rubicon Research



From bjorn at roguewave.com  Fri Dec 31 10:53:11 1999
From: bjorn at roguewave.com (Bjorn Pettersen)
Date: Fri, 31 Dec 1999 08:53:11 -0700
Subject: Error in inserting blob into ORACLE using ODBC.Windows
References: <386c0577.107657473@news.phoenix.com>
Message-ID: <386CD167.8525C821@roguewave.com>

Don't know too much about mxODBC, but a little bit about Oracle...

>From the first error you describe, it looks like you are trying to insert the
blob into something that is not a long or a long raw column.  My guess is that
you have declared the column as type BLOB, which is an oracle 8 datatype not
supported by odbc to any great extent.

For the second error, you probably want to open your icon file in binary mode,
i.e. f=open(icon_path, 'r+b')  (or is that 'rb', I forget...)

Hope this helps.

-- bjorn

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.
>
> After mxODBC 1.1.1 installation, i run the test.py and got some errors:
>
> Test suite:
>  Connecting to the database.
>  Connected to DBMS: Oracle8; Version: 08.00.5000
>               ODBC driver: SQOCI32.DLL 8.0.3.0.0; ODBC Version: 02.50
> ...
>  BLOB column type with binary data           : unexpected database error
> [mxODBC.OperationalError: ('S1000', 1461, 'ORA-01461: can bind a LONG value
> only for insert into a LONG column\012', 3176)]
>
> Then i tried out a few lines to insert a BLOB
>
> import ODBC
> conn = ODBC.Windows.Connect('...',clear_auto_commit=0)
> cur = conn.cursor()
> ...
> f=open(icon_path,'r')
> icon=f.read()
>
> sql='INSERT INTO my_table (seq_no, blob_data) VALUES (36,?)'
> cur.execute(sql,(icon,))
>
> and get this error:
> OperationalError: ('S1000', 1465, 'ORA-01465: invalid hex number\012',
> 3176)
>
> What step did i missed?
>
> I also need some pointer on how to get the BLOB backout.
>
> Tanming Fong
> tmfong at hotmail.com
>
> Thanks in advance for any help.
>
> --
> http://www.python.org/mailman/listinfo/python-list




From bwarsaw at cnri.reston.va.us  Mon Dec 13 23:44:10 1999
From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw)
Date: 13 Dec 1999 23:44:10 -0500
Subject: this is a test, please ignore
Message-ID: <613dt6nnc5.fsf@anthem.cnri.reston.va.us>

sorry for the intrusion.


From skip at mojam.com  Fri Dec  3 13:06:34 1999
From: skip at mojam.com (Skip Montanaro)
Date: Fri, 3 Dec 1999 12:06:34 -0600 (CST)
Subject: A Date With Tim Peters...
In-Reply-To: <14407.65473.929570.13611@goon.cnri.reston.va.us>
References: <199912020003.TAA13009@eric.cnri.reston.va.us>
	<825nbt$p50@mail.psy.uva.nl>
	<38479F07.110BAC47@corrada.com>
	<14407.65473.929570.13611@goon.cnri.reston.va.us>
Message-ID: <14408.1706.149384.905187@dolphin.mojam.com>

    Jeremy> I think a better solution than audio recording and Webcast
    Jeremy> (which sounds expensive to me)

I don't know about that.  Let me check with the folks at audiocast.net
(right down the hall).  My son's high school radio station is webcast by
some unknown-to-me-service.  I doubt they pay anything.

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 dash at onthe.org  Wed Dec 15 20:27:01 1999
From: dash at onthe.org (Dave Ashworth)
Date: Wed, 15 Dec 1999 20:27:01 -0500
Subject: pilot-link for win32
References: <839ckl$u0d$1@nnrp1.deja.com>
Message-ID: <38583FE5.FED85A1E@onthe.org>

calishar at my-deja.com wrote:
> 
> Hi Folks,
> 
>   Does anyone know somewhere I could find either a pre-built, or VC++
> compatible source version of pilot-link?
> 
You can find binaries at http://stud.fh-heilbronn.de/~christ/pilot-xfer/
-- 
--------------------
   David Ashworth
   dash at onthe.org
--------------------


From kuntsi at cc.helsinki.fi.spam.no  Mon Dec 27 13:58:59 1999
From: kuntsi at cc.helsinki.fi.spam.no (Antti Kuntsi)
Date: 27 Dec 1999 18:58:59 GMT
Subject: Super Tuples
References: <386745A6.9B671DBF@prescod.net>
Message-ID: 

Paul Prescod  sepusti:
> 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)


Here is my quick attempt to do the SuperTuple. There is at least one big
problem, as I don't know how to figure out the order in which the keyword
arguments were given.

Testing, if it works:
>>> st=SuperTuple(1,2,"fish", spam=600)
>>> print st, st.spam
(1, 2, 'fish', 600) 600
>>> print st.names(), st["spam"]
['spam'] 600
>>> print ("eggs",6)+st, st+("eggs", 6)
('eggs', 6, 1, 2, 'fish', 600) (1, 2, 'fish', 600, 'eggs', 6)
>>> st.eggs=600 # raises TypeError like a normal tuple
Traceback (innermost last):
  File "", line 1, in ?
  File "SuperTuple.py", line 92, in __setattr__
    raise TypeError, "object doesn't support item assignment"
TypeError: object doesn't support item assignment
>>> for value in st:
...         print value
... 
1
2
fish
600
>>>

##The source begins...


from types import IntType

class SuperTuple:
	def __init__(self, *args, **kwargs):
		self.__named={}
		for name, value in kwargs.items():
			self.__named[name]=value
		self.__values=args+tuple(self.__named.values())
			
	def __getattr__(self, name):
		try:
			return self.__named[name]
		except KeyError, which:
			raise AttributeError, which
			
	def __getitem__(self, index):
		if type(index)!=IntType:
			return self.__named[index]
		else:
			return self.__values[index]
	
	def __setattr__(self, name, value):
		if name in ("_SuperTuple__values", "_SuperTuple__named"):
			self.__dict__[name]=value
		else:
			raise TypeError, "object doesn't support item assignment"

	def __repr__(self):
		return str(self.__values)
	
	def __add__(self, right):
		return self.__values+right

	def __radd__(self, left):
		return left+self.__values
	
	def names(self):
		return self.__named.keys()

## EOF SuperTuple.py

--
______________________________________________________________
|O| ----------------------------------------------------------
| | |Twisted mind? No, just bent in several strategic places.|
`\| |___________________________________mickut at iki.fi/mickut/|


From gmcm at hypernet.com  Fri Dec 10 09:47:32 1999
From: gmcm at hypernet.com (Gordon McMillan)
Date: Fri, 10 Dec 1999 09:47:32 -0500
Subject: ODBC Problem on IIS4
In-Reply-To: <384FEC7E.29FA069A@pobox.com>
Message-ID: <1267285902-453672@hypernet.com>

Jack Knight writes:

> I am getting the following error when trying to do a simple SQL
> lookup:

>          cursor.execute(query,params)
>      dbi.internal-error: [Microsoft][ODBC Microsoft Access 97
>      Driver] Invalid argument. in EXEC
> 
> Setup is:
> Windows NT4 SP5, IIS4, ODBC V3.5. Python 1.5.
> 
> Offending Code fragment:
> 
> def login(id,password):
>  realPwd=decrypt(password)
>  # Perform the query to the database
>  connection=odbc.odbc(cfg.DSN)
>  cursor=connection.cursor()
>  params=[id,realPwd]
>  query="select CustomerID, Password, Status from CustomerDetails
>  where
> CustomerID=:1 and Password=:2"
>  cursor.execute(query,params)
>  row=cursor.fetchone()

IIRC, the Access driver wants "...CustomerID=? and 
Password=?". 

- Gordon



From bsb at winnegan.de  Tue Dec 21 07:44:59 1999
From: bsb at winnegan.de (Siggy Brentrup)
Date: 21 Dec 1999 13:44:59 +0100
Subject: Bug in python startup on linux? [Was: Wrong Executable? or something]
In-Reply-To: Clarence Gardner's message of "Mon, 20 Dec 1999 19:11:14 GMT"
References: 
Message-ID: <87d7s05upg.fsf@baal.winnegan.de>

Clarence Gardner  writes:

> This is a problem I've seen on many linux systems.  They're all RedHat or
> Mandrake (extended RedHat).

Same holds for Debian slink aka 2.1

I did a little more testing and found out that results depend on your
PATH setting.

Calling scripts with an empty PATH gives the expected results

$ echo $PATH
/home/bsb/bin:/usr/local/X11R6/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games

$ ~/prj/quicky/py1.5.1.py
1.5.1 (#1, Dec 17 1998, 20:58:15)  [GCC 2.7.2.3]
sys.prefix =  /usr/local
sys.exec_prefix =  /usr/local
sys.path =  ['/home/bsb/prj/quicky', '/usr/local/lib/python1.5/', '/usr/local/lib/python1.5/plat-linux2', '/usr/local/lib/python1.5/lib-tk', '/usr/local/lib/python1.5/lib-dynload', '/usr/local/lib/python1.5/site-packages', '/usr/local/lib/site-python']
PYTHONPATH = * NOT SET *

$ PATH= ~/prj/quicky/py1.5.1.py
1.5.1 (#1, Dec 17 1998, 20:58:15)  [GCC 2.7.2.3]
sys.prefix =  /usr
sys.exec_prefix =  /usr
sys.path =  ['/home/bsb/prj/quicky', '/usr/lib/python1.5/', '/usr/lib/python1.5/plat-linux2', '/usr/lib/python1.5/lib-tk', '/usr/lib/python1.5/lib-dynload', '/usr/local/lib/python1.5/site-packages', '/usr/local/lib/site-python', '/usr/lib/python1.5/site-packages', '/usr/lib/python1.5/site-packages/Bobo', '/usr/lib/python1.5/site-packages/HTMLgen', '/usr/lib/python1.5/site-packages/PIL', '/usr/lib/python1.5/site-packages/graphics', '/usr/lib/python1.5/site-packages/Numerical', '/usr/lib/site-python']
PYTHONPATH = * NOT SET *

$ PATH= ~/prj/quicky/py1.5.2+.py
1.5.2+ (#4, Nov 18 1999, 01:39:08)  [GCC egcs-2.91.66 19990314 (egcs-1.1.2 release)]
sys.prefix =  /usr/local
sys.exec_prefix =  /usr/local
sys.path =  ['/home/bsb/prj/quicky', '/usr/local/lib/python1.5/', '/usr/local/lib/python1.5/plat-linux2', '/usr/local/lib/python1.5/lib-tk', '/usr/local/lib/python1.5/lib-dynload', '/usr/local/lib/python1.5/site-packages', '/usr/local/lib/site-python']
PYTHONPATH = * NOT SET *

$ cat ~/prj/quicky/py1.5.1.py
#! /usr/bin/python

import sys, os

print sys.version
print "sys.prefix = ", sys.prefix
print "sys.exec_prefix = ", sys.exec_prefix
print "sys.path = ", sys.path

print "PYTHONPATH =",
try:
    print os.environ['PYTHONPATH']
except KeyError:
    print '* NOT SET *'

$ diff -u ~/prj/quicky/py1.5.1.py ~/prj/quicky/py1.5.2+.py
--- /home/bsb/prj/quicky/py1.5.1.py	Tue Dec 21 13:26:17 1999
+++ /home/bsb/prj/quicky/py1.5.2+.py	Tue Dec 21 13:25:33 1999
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#! /usr/local/bin/python
 
 import sys, os
 

I suspect a bug in the python startup routine, since sys.prefix
and sys.exec_prefix are determined at configuration time.

Siggy

-- 
Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/
****** ceterum censeo javascriptum esse restrictam *******



From matt at cmitech.com  Mon Dec 27 16:08:11 1999
From: matt at cmitech.com (Matt Mencel)
Date: 27 Dec 1999 15:08:11 -0600
Subject: Why doesn't this work?
Message-ID: 

When I try and run this code snippet I get this error in the f.read line.

<>
-1
Traceback (innermost last):
  File "net.py", line 10, in ?
    data = f.read() # Get the raw HTML
TypeError: not enough arguments


<>
import httplib
h=httplib.HTTP(www.somewebsite.com)
h.putrequest('GET', '/somepage.html')
h.putheader('Accept', 'text/html')
h.putheader('Accept', 'text/plain')
h.endheaders()
errcode, errmsg, headers = h.getreply()
print errcode # Should be 200
f = h.getfile()
data = f.read() # Get the raw HTML
f.close()







From cgw at fnal.gov  Wed Dec 15 13:19:11 1999
From: cgw at fnal.gov (Charles G Waldman)
Date: Wed, 15 Dec 1999 12:19:11 -0600 (CST)
Subject: running and managing background shell commands
In-Reply-To: <3857D3D1.C651BB88@shfj.cea.fr>
References: <3857D3D1.C651BB88@shfj.cea.fr>
Message-ID: <14423.56223.738584.30659@buffalo.fnal.gov>

Dimitri Papadopoulos writes:

 > 
 > How can I rewrite this function? As far as I know:
 > 1) commands.getstatus cannot start a background command
 > 2) os.system does start a background command
 > 3) but $! is not available

os.system("command &") will start a command in the background



From fredrik at pythonware.com  Wed Dec 15 09:28:46 1999
From: fredrik at pythonware.com (Fredrik Lundh)
Date: Wed, 15 Dec 1999 15:28:46 +0100
Subject: Interpolation between multiple modules of an application.
References: <19991215144523.A1707@stopcontact.palga.uucp>
Message-ID: <00aa01bf4708$b6714410$f29b12c2@secret.pythonware.com>

Gerrit Holl  wrote:
> This isn't really bad, but consider the language.py module; it defines
> a Class like this:
> 
> # language.py (untested code)
> 
> import userdict
> 
> class Language(userdict.userdict):
>     def __init__(self, lang):
>         self.data = {...} # define self.data
> 
> Every module needs to print messages, so *every* module imports language and
> *every* module created a class so *every* time a file is parsed! That's wrong!

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).

> 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.






From bgdarnel at my-deja.com  Thu Dec  2 19:36:01 1999
From: bgdarnel at my-deja.com (Ben Darnell)
Date: 3 Dec 1999 00:36:01 GMT
Subject: Inter-process communication options
Message-ID: 

I'm writing an app, using wxPython and Pyrite, which can synchronize
with a corresponding PalmOS application.  The problem is that if the
user tries to synchronize while the GUI is open and the user has made
changes which are not yet committed to disk, these changes will not be
reflected on the Palm, and the Palm's changes will not be reflected in
the GUI.  The sync and GUI processes need to talk to each other somehow.
I'm looking for some way to do this that is cross-platform (specifically
Windows and Unix at a minimum).  Here are some things I've thought of:

* Send a message to the GUI process and have it do the synchronization.
I'm not sure how well this would work, since it seems it would have to
make a copy of the Pyrite object in the other process.  There are
several ways this could be implemented, with varying degrees of
portability (fifos, sockets,...)

* Send messages to the GUI process, telling it to commit its changes to
disk before the sync, and to reload the data from disk afterwards.  This
is probably the simplest thing to implement, but it's rather
inefficient, since it forces an additional load/save cycle.  

* Use some sort of distributed object system (e.g. CORBA, COM) to let
both processes access the same in-memory data.  This is probably the
'cleanest' solution from a theoretical standpoint.  This imposes an
additional software requirement on the user besides Python and wxPython
(Pyrite is optional), which I would like to avoid but it is not a
showstopper.  ILU appears to be cross-platform; are there any other
cross-platform ORBs?

* Anything else I may have overlooked?

Thanks,
-Ben

-- 
Ben Darnell              bgdarnel at unity.nc su.edu
http://thoughtstream.org




From niels at endea.demon.nl  Fri Dec 24 14:37:13 1999
From: niels at endea.demon.nl (Niels Diepeveen)
Date: Fri, 24 Dec 1999 20:37:13 +0100
Subject: strptime on Unix systems
References: <19991222110107.A972@Ridcully.home>  <19991223104634.A766@Ridcully.home>
Message-ID: <3863CB69.D9A7D8A6@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 cwr at cts.com  Mon Dec 27 07:50:29 1999
From: cwr at cts.com (Will Rose)
Date: 27 Dec 1999 12:50:29 GMT
Subject: "Message file not found"
References: <3865594C.1AB35459@ndh.net>
Message-ID: <847nak$16ph$1@thoth.cts.com>

Stefan Schwarzer  wrote:
: 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".

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.


Will
cwr at crash.cts.com



From prestonlanders at my-deja.com  Thu Dec  2 16:54:03 1999
From: prestonlanders at my-deja.com (Preston Landers)
Date: Thu, 02 Dec 1999 21:54:03 GMT
Subject: breakout
References: <825o0f$250$1@news.qub.ac.uk>
Message-ID: <826poi$uef$1@nnrp1.deja.com>

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 ?
>
>

--
|| Preston Landers  ||


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



From marshall at ufm.org  Mon Dec 20 15:52:16 1999
From: marshall at ufm.org (Marshall)
Date: Mon, 20 Dec 1999 12:52:16 -0800
Subject: mxODBC - paramstyle - how to change default
Message-ID: 

I am enjoying using Marc Lemburg's mxODBC modules for database work. The
paramstyle setting is set to 'qmark' by default, how can a newbie like me
change this setting? Or is this not a really changable letting?

Thank you in advance.
Marshall




From infotechsys at pivot.net  Thu Dec 16 16:33:29 1999
From: infotechsys at pivot.net (Wayne)
Date: Thu, 16 Dec 1999 16:33:29 -0500
Subject: How to size master?
Message-ID: <38595AA9.3D05A9ED@pivot.net>

Hello,
Can somebody tell be how to size the top-level widget? For example

from Tkinter import *
class App:
        def __init__(self, master):
              L1 = Label(...............stuff)

How would I give master a heigth and width? I remember reading how  to
do this, but
I can't seem to find it now .
TIA.
Wayne




From vaton at postoffice.pacbell.net  Mon Dec 27 01:20:39 1999
From: vaton at postoffice.pacbell.net (Robert Shockley)
Date: Sun, 26 Dec 1999 22:20:39 -0800
Subject: How do I make a Python .bat executable file?
Message-ID: <38670537.FDBC1785@postoffice.pacbell.net>

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~





From timmuddletin at news.vex.net  Thu Dec 16 02:55:56 1999
From: timmuddletin at news.vex.net (tim muddletin)
Date: 16 Dec 1999 07:55:56 GMT
Subject: bytecode to source
References: <945280682.301456388@news.teleweb.at>
Message-ID: <83a5uc$10vt$1@news.tht.net>

On Wed, 15 Dec 1999 18:11:00 GMT, Markus Krutz  wrote:
>Does anyone know of a module that decompiles bytecode files to source files?

http://www.vex.net/parnassus/apyllo.py?find=decompile

(just a self indulgant reminder for everyone to come to the Vaults
to search for python stuff <-: --- one hit, albeit "pre-alpha")



From tanming_fong at phoenix.com  Thu Dec 30 20:34:02 1999
From: tanming_fong at phoenix.com (TM)
Date: 30 Dec 1999 19:34:02 -0600
Subject: Error in inserting blob into ORACLE using ODBC.Windows
Message-ID: <386c0577.107657473@news.phoenix.com>

I have a problem inserting BLOB into ORACLE using ODBC.Windows with either
the Oracle ODBC driver or the Micorsoft ODBC driver for Oracle.

After mxODBC 1.1.1 installation, i run the test.py and got some errors:

Test suite:
 Connecting to the database.
 Connected to DBMS: Oracle8; Version: 08.00.5000
              ODBC driver: SQOCI32.DLL 8.0.3.0.0; ODBC Version: 02.50
...
 BLOB column type with binary data           : unexpected database error
[mxODBC.OperationalError: ('S1000', 1461, 'ORA-01461: can bind a LONG value
only for insert into a LONG column\012', 3176)]


Then i tried out a few lines to insert a BLOB

import ODBC
conn = ODBC.Windows.Connect('...',clear_auto_commit=0)
cur = conn.cursor()
...
f=open(icon_path,'r')
icon=f.read()

sql='INSERT INTO my_table (seq_no, blob_data) VALUES (36,?)'
cur.execute(sql,(icon,))

and get this error:
OperationalError: ('S1000', 1465, 'ORA-01465: invalid hex number\012',
3176)

What step did i missed?

I also need some pointer on how to get the BLOB backout. 

Tanming Fong
tmfong at hotmail.com


Thanks in advance for any help. 



From nick at src.uchicago.edu  Sun Dec 19 17:03:22 1999
From: nick at src.uchicago.edu (Nick Collier)
Date: Sun, 19 Dec 1999 16:03:22 -0600
Subject: zlib and zip archives
Message-ID: 

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




From mhammond at skippinet.com.au  Thu Dec  9 17:24:01 1999
From: mhammond at skippinet.com.au (Mark Hammond)
Date: Thu, 09 Dec 1999 22:24:01 GMT
Subject: Copying files to file server
References: 
Message-ID: <5_V34.3331$Cl3.17409@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.

Tomaz Ficko wrote in message ...
>I want to open a connection to a file server (Windows NT) from Python
script
>and copy a file to it.
>I'm using Windows 95 and Python 1.5.2. I tried with win32wnet module but it
>didn't work. Any suggestions?
>
>
>
>Tom
>
>




From darrell at dorb.com  Thu Dec 30 22:32:21 1999
From: darrell at dorb.com (Darrell)
Date: Thu, 30 Dec 1999 22:32:21 -0500
Subject: problem with subracting from number that I get with cgi module
References: <19991231140532.A8331@dark.net>
Message-ID: <082a01bf533f$a61d3400$0100a8c0@rochester.rr.com>

Try this.

num = string.atoi( urlargs["num"].value)

--Darrell
----- Original Message ----- 
From: "Jeremy Lunn" 
To: 
Sent: Thursday, December 30, 1999 10:05 PM
Subject: problem with subracting from number that I get with cgi module


> Hi,
> 
> I am trying to get a number with the cgi modules like:
> form = cgi.FieldStorage()
> num = urlargs["num"].value
> 
> But I can't subtract from it, when I try to do that like:
> newnum = num-1
> 
> I get an error like this:
> Traceback (innermost last):
>   File "./numtest.py", line 9, in ?
>     numtwo = num-1
> TypeError: bad operand type(s) for -
> 
> Would this mean that the number I am getting isn't really a number or
> what?
> 
> Anyone have any ideas how I could get this to work?
> 
> Thanks
> 
> Jeremy
>       
> 
> -- 
> Jeremy Lunn
> Melbourne, Australia
> ICQ: 19255837
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list




From gerrit.holl at pobox.com  Fri Dec 17 05:23:04 1999
From: gerrit.holl at pobox.com (Gerrit Holl)
Date: Fri, 17 Dec 1999 11:23:04 +0100
Subject: LISTS: Extract every other element
In-Reply-To: <19991216131341.A153923@vislab.epa.gov>; from aa8vb@yahoo.com on Thu, Dec 16, 1999 at 01:13:41PM -0500
References: <19991216131341.A153923@vislab.epa.gov>
Message-ID: <19991217112304.A1847@stopcontact.palga.uucp>

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.

regards,
Gerrit.

-- 
"The world is beating a path to our door"

  -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates)
 11:21am  up 12 min, 16 users,  load average: 0.33, 0.29, 0.24



From wilson.austin.aj at bhp.com.au  Tue Dec  7 00:38:37 1999
From: wilson.austin.aj at bhp.com.au (Austin Wilson)
Date: Tue, 7 Dec 1999 16:38:37 +1100
Subject: Converting a Shell Script to run under Python
References: <82h11e$f2p$1@gossamer.itmel.bhp.com.au> 
Message-ID: <82i6dj$b2j$1@gossamer.itmel.bhp.com.au>

Thanks.  That worked beautifully.

What is the command for copying file1 to file3 (eg equivalent to cp file1
file3) and creating a soft link to a file (eg ln -s file2 file1)?

Thanks
Austin

Magnus L. Hetland  wrote in message
news:y0jhfhva9p5.fsf at vier.idi.ntnu.no...
> "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 76703.4222 at CompuServe.COM  Sun Dec 26 23:33:09 1999
From: 76703.4222 at CompuServe.COM (Jason Harper)
Date: 27 Dec 1999 04:33:09 GMT
Subject: A couple MacPython questions...
References: <199912262151.PAA10719@dolphin.mojam.com>
Message-ID: <846q65$g2n$1@ssauraaa-i-1.production.compuserve.com>

1. The Mac's Desktop isn't really expressible in terms of a pathname
- it's actually the union of the Desktop Folders on all mounted 
volumes (and you can't count on that name, you should use 
macfs.FindFolder() to get the proper, localized name).  However, the
code you posted should at least partially work, and indeed it does 
on my system - I suspect that your Desktop items are all on a 
different volume than 'Macintosh HD:', or that you don't actually 
have any files or folders on your desktop (disks, servers, and the 
Trash don't count).

3. If the file you're trying to turn into an applet is big, you may 
need to allocate more memory to BuildApplet - select it in the 
Finder, then choose Get Info from the File menu.  The default is 
less than 2MB.

There is a MacPython mailing list at www.python.org that you might 
want to join for questions like these.
	Jason Harper


From gmcm at hypernet.com  Wed Dec 22 19:26:39 1999
From: gmcm at hypernet.com (Gordon McMillan)
Date: Wed, 22 Dec 1999 19:26:39 -0500
Subject: embedding Python in C
In-Reply-To: <38616585.2A21FECF@be-research.ucsd.edu>
Message-ID: <1266214583-27560533@hypernet.com>

Curtis Jensen asks:

> From a C file, how can I get values from a Python Class?  
> For Example:
> 
> File: Test.py
> class Klass:
>   def __init__(self):
>     self.a = 1
>     self.b = 2
>     self.c = 3
> 
> How can I get the values of a,b, and c from within a C function?
> Thanks

Assuming you mean "from an instance of Klass", the answer 
is the same way you would in Python. Well, in dynamic 
Python. The equivalent of getattr(obj, name) is 
PyObject_GetAttrString(o, name).

- Gordon



From fredrik at pythonware.com  Wed Dec  1 10:06:27 1999
From: fredrik at pythonware.com (Fredrik Lundh)
Date: Wed, 1 Dec 1999 16:06:27 +0100
Subject: Help finding Matt Conyway's tutorial
References: <38436A58.98FEA03@pivot.net>
Message-ID: <014c01bf3c0d$a52303c0$f29b12c2@secret.pythonware.com>

Wayne  wrote:
> I'm trying to find an address for Matt Conway. I understand he has
> a tutorial called "A Tkinter Life Preserver" that I would like to
> down load. If there is any other tutorial out there that someone
> can point me to I be happy for the info.

start here:
http://www.python.org/topics/tkinter/doc.html








From a.eyre at optichrome.com  Tue Dec 14 05:18:22 1999
From: a.eyre at optichrome.com (Adrian Eyre)
Date: Tue, 14 Dec 1999 10:18:22 -0000
Subject: building string for __import__()
In-Reply-To: 
Message-ID: <003b01bf461c$8d05a810$3acbd9c2@peridot.optichrome.com>

> 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 
--------------------------------------------




From thor at localhost.localdomain  Thu Dec 30 08:57:28 1999
From: thor at localhost.localdomain (Manuel Gutierrez Algaba)
Date: 30 Dec 1999 13:57:28 GMT
Subject: [INSIST] Python ring
Message-ID: 

I think python ring has just grown mature, with its current
8 members and mainly because of cginews the number of hits
have greatly increased. Cheer up, let the others see what you've
done in python, join the python ring:

http://www.ctv.es/USERS/irmina/pythonring.html

-- 
Manolo


From tim_one at email.msn.com  Wed Dec  8 03:34:33 1999
From: tim_one at email.msn.com (Tim Peters)
Date: Wed, 8 Dec 1999 03:34:33 -0500
Subject: Linux.Com
In-Reply-To: <14413.59272.858902.938397@anthem.cnri.reston.va.us>
Message-ID: <001501bf4157$0e230700$5aa2143f@tim>

[Al Christians]
> Python is running a healthy 4th in the Linux.Com scripting
> languages poll.

[Barry A. Warsaw]
> Looks like your message has rallied the troops!  It's now running
> a distant second behind the 4-letter word of scripting languages :)
>
> Perl   42.65% (633)
> Python 16.31% (242)
> PHP    15.84% (235)

Take heart:  Deeper analysis of the data demonstrates that the Python votes
are of much higher quality.  In fact, multiplying number of votes by average
quality per vote puts Python far in the lead!

> Hmm... anybody think we need more `P' languages?

I always thought "Peters" would make a fine name for a language.

about-time-we-named-a-language-after-a-machine-ly y'rs  - tim





From service at fromhungary.com  Mon Dec  6 11:24:50 1999
From: service at fromhungary.com (service at fromhungary.com)
Date: 6 Dec 1999 16:24:50 GMT
Subject: live from hungary  3284
Message-ID: <82go0i$fou$5040@mail.euroweb.hu>

FREE PICS +++ FREE PICS +++ FREE PICS +++ FREE PICS
!!! LIVE FROM BUDAPEST !!!
THE  HOTTEST  SHOW  LIVE  FROM  HUNGARY BUDAPEST
 
Join our new site with a great FREE Picture Gallery

FREE PICS +++ FREE PICS +++ FREE PICS +++ FREE PICS++++

100 % FREE 

http://www.fromhungary.com

Come to the HOTTEST Show live from Budapest Hungary with the hottest
Girls and Boys

Special ++ HOT COUPLES ++ sweet LESBIAN Girls ++ ..........

http://www.fromhungary.com ++ http://www.fromhungary.com ++ http://www.fromhungary.com

eyiculzyqotpgln




From tiddlerdeja at my-deja.com  Sun Dec 12 18:43:58 1999
From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com)
Date: Sun, 12 Dec 1999 23:43:58 GMT
Subject: win32com: subclass a com object?
References: <830pi6$n4k$1@nnrp1.deja.com> 
Message-ID: <831bvt$3f0$1@nnrp1.deja.com>

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.
> >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).
>
> Hmm. I haven't done this, but you certainly can derive from the
> class, which wraps the COM object and intercept the method.
>
> Mark can tell you more about it.
> The most easiest solution would be to write your own class,
> initialise instances with the original COM instance
> and just imitate all methods and call the original object except of
> course for the method you want to change.
>
>
I know I'm being pretty lame, but could you give me an example? Even for
say MS Word?

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.:

class myMSWord(MSWord):
	...

Eh, how do you create a myMSWord? or where does the Dispatch call come
into it?

Or, after you run makepy.py over MSWord, which creates a file
xyz-123-abc.py under gen_py, how do you import it and which class do you
derive from?

Or maybe I don't know about python inheritance after all! :)

Any help appreciated.

Kieran

>


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


From tseaver at starbase.neosoft.com  Mon Dec 20 21:49:02 1999
From: tseaver at starbase.neosoft.com (Tres Seaver)
Date: 21 Dec 1999 02:49:02 GMT
Subject: __rcall__???
References: <002101bf4a98$01eda860$922d153f@tim>  <385E74B8.CC2CFFC8@math.okstate.edu>
Message-ID: <5A7D006DE6BA7FF7.9D85F69C1855DCF4.4E8922E4E6A266A3@lp.airnews.net>

In article <385E74B8.CC2CFFC8 at math.okstate.edu>,
David C. Ullrich  wrote:
>
>
>Tres Seaver wrote:
>
>> In article <002101bf4a98$01eda860$922d153f at tim>,
>> Tim Peters  wrote:
>> >[David C. Ullrich]
>> >>     So why isn't there a magic __rcall__, that would go with
>> >> __call__ like the other __rop__'s go with __op__?
>> >>
>> >>     It seems useful to me to allow x to alter the way f behaves
>> >> when you call f(x); ...
>> >
>> >Probably for the same reason there's no __rgetitem__ for the benefit of the
>> >millions of programmers who want
>> >
>> >    x[i]
>> >
>> >to use x as an index into sequence i .  That is, AFAIK nobody ever
>> >asked for it before, and it's not screamingly natural (you're not really
>> >*surprised* at the lack of __rcall__, right?).
>>
>> Smells like Visitor/multimethods/DoubleDispatch to me, and it _is_ a vacuum
>> which people code around, in most languages except Lisp and its progenty;
>> David is apparently the first to propose this particular solution
>> (quite Pythonic, it seems to me,
>
>    I got an email saying something about "Visitor methods". I won't ask what
>that is, I'll look it up somewhere.

* double dispatch
    selecting the method to be called based on the classes of both objects
	involved (as distinct from single dispatch, like a virtual function in
	C++,

* multimethods (Lisp and derivatives)
    all arguments contribute to the selection algorithm.

* Visitor
    a design pattern [1] used to implement double dispatch in languages
	which don't have multimethods as a native construct.


[1] "design pattern" is the meme to use when searching: try hillside.net for
    starters

>(I didn't think that I was the first person
>in the universe to wonder about this, but I don't know any of that programming
>stuff. In my implementation the concept is "ettiquette":  Data and Function
>both descend from Nice. Nice objects are very careful about stepping on
>other objects' toes - everyone else has a veto power.)
>
>> only adding slots to the jump
>> table is not likely to win wide support).
>
>    Wasn't actually saying that it should be added to the langauge,
>mainly wanted to make certain that it wasn't already there.
>
>> >better-hope-for-santa-to-do-it-cuz-i-doubt-guido-will-ly y'rs  - tim
>>
>> Looking-hopefully-for-sinterklaas'ly,
>>
>    Wondering-whether-you-guys-find-your-'-'-keys-wear-out-first,
>
>um, I mean
>
>    Wondering-whether-you-guys-find-your-'-'-keys-wear-out-first'ly,

yes-but-sinterklaas-brings-us-new-ones-each-year'ly,

Tres.
-- 
---------------------------------------------------------------
Tres Seaver           tseaver at palladion.com       713-523-6582
Palladion Software    http://www.palladion.com


From aa8vb at yahoo.com  Thu Dec 30 07:08:26 1999
From: aa8vb at yahoo.com (Randall Hopper)
Date: Thu, 30 Dec 1999 07:08:26 -0500
Subject: [ANNOUNCE] Pygasm IDE wxWindows Linux Developer Release
In-Reply-To: <386B510D.3EC3B9DB@pcpros.net>
References: <386B510D.3EC3B9DB@pcpros.net>
Message-ID: <19991230070826.B778039@vislab.epa.gov>

Cliff Baeseman:
 |Hi all,
 |
 |   I would just like to announce that I have tweaked the Pygasm IDE
 |Developer release code to run under linux and wxGTK.

Great!  I'm looking for a good GUI builder.

 |Pygasm is a wxWindows GUI assembler with a delphi look and feel. It
 |sports a Source Editor, Object inspector, WYSIWYG forms designer,
 |documentor.
 |
 |...the code at http://www.pcpros.net/~vbman

Your download link needs fixed.  The text reads right, but
the link is wrong (still points to pbuilder).

I pulled it and ran 'python Pygasm.py'.  Here's what I got:

    > python Pygasm.py                         
    importing wxPython...
    imported wxPython
    Traceback (innermost last):
      File "Pygasm.py", line 7, in ?
        import Editor
      File "Editor.py", line 7, in ?
        from EditorViews import *
      File "EditorViews.py", line 3, in ?
        from wxPython.html import *
    ImportError: No module named html

Here are the particulars:

    Python   1.5.2
    wxPython 2.1.11
    wxGTK    2.1.11
    SGI IRIX 6.5

-- 
Randall Hopper
aa8vb at yahoo.com



From ralphalberti at worldnet.att.net  Wed Dec  1 20:57:40 1999
From: ralphalberti at worldnet.att.net (Ralph Alberti)
Date: Wed, 01 Dec 1999 20:57:40 -0500
Subject: help me learn please!!!!!
References: <81aj0m$fmg$1@ins23.netins.net> <38427DCE.91A5D8C2@gssec.bt.co.uk>
Message-ID: <3845D214.2CA3856@worldnet.att.net>

Thanks for the tutorial.  It looks perfect for my needs.

  --Ralph


Alan Gauld wrote:
> 
> Charles Moore wrote:
> > I'd like to learn how to program are their any good suggestions as to were
> > to start I'm a complete beginner I ask of you to point me in the right
> > direction
> 
> I have a fairly extensive beginners tutorial that uses
> Python as the main language and Tcl and BASIC where
> a comparison is useful...
> 
> Try:
> 
> http://members.xoom.com/alan_gauld/tutor/tutindex.htm
> 
> Alan G.
> --
> =================================================
> This post represents the views of the author
> and does not necessarily accurately represent
> the views of BT.



From gerrit.holl at pobox.com  Thu Dec  2 10:33:34 1999
From: gerrit.holl at pobox.com (Gerrit Holl)
Date: Thu, 2 Dec 1999 16:33:34 +0100
Subject: Email address check function
Message-ID: <19991202163334.A3934@stopcontact.palga.uucp>

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 very often get messages from my MTA that it's received a message with a
wrong Message ID. One could also type an entirely wrong email address in the
form, and I want to attend the user on that.

regards,
Gerrit.

-- 
"The world is beating a path to our door"

  -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates)
  3:30pm  up  2:03, 16 users,  load average: 0.32, 0.56, 0.80



From skip at mojam.com  Thu Dec 23 12:32:32 1999
From: skip at mojam.com (Skip Montanaro)
Date: Thu, 23 Dec 1999 11:32:32 -0600 (CST)
Subject: Microsoft Python product?
In-Reply-To: 
References: <38603196.4EA438BD@golgotha.net>
	
Message-ID: <14434.23728.155860.872016@dolphin.mojam.com>

    Robin> Commerce Server was written in Python with some C extensions when
    Robin> MS aquired (assimilated) the company that built it. 

I believe that company was eShop.

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 wwww3577 at my-deja.com  Wed Dec  8 09:21:53 1999
From: wwww3577 at my-deja.com (wwww3577 at my-deja.com)
Date: Wed, 08 Dec 1999 14:21:53 GMT
Subject: Looking for David Gil Del Rosal
Message-ID: <82lpht$6a3$1@nnrp1.deja.com>

David Gil Del Rosal,

please, I need to get in contact with you
concerning a license.

Try mailing me through one (or all) of these
addresses:

   andy.zanna at bluewin.de
   andy at multimedia.it
   andy_zanna at agilent.com

Andy



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


From python-list at teleo.net  Sun Dec 26 23:14:59 1999
From: python-list at teleo.net (Patrick Phalen)
Date: Sun, 26 Dec 1999 20:14:59 -0800
Subject: Python Docs available for Rocket eBook
Message-ID: <99122620313603.01988@quadra.teleo.net>

Santa brought me a Rocket eBook for Christmas. Browsing through the
list of 2,500 book titles available for free, I was happy to discover
that both the Python Tutorial and Python Library Reference are
available for download to the eBook. Since the eBook is only 5" x 7.5"
and (depending on RAM) can hold between 4,000-32,000 pages prepared in
Rocket book format, it's easy to have a copy of the Library Reference
available anywhere.  :>)



From aa8vb at yahoo.com  Fri Dec 17 13:48:26 1999
From: aa8vb at yahoo.com (Randall Hopper)
Date: Fri, 17 Dec 1999 13:48:26 -0500
Subject: LISTS: Extract every other element - SUMMARY
In-Reply-To: <004801bf48a8$74d7ab60$3acbd9c2@peridot.optichrome.com>
References: <19991217091256.A168025@vislab.epa.gov> <004801bf48a8$74d7ab60$3acbd9c2@peridot.optichrome.com>
Message-ID: <19991217134826.A183473@vislab.epa.gov>

Adrian Eyre:
 |> I coded each of these up, working with the same list of 100,000
 |> integers.  Here are the results.
 |>
 |> [snip]
 |
 |Did you try them all with the -O option?

No, these were without -O.  -O betters the times around 4-5%.  Relative
performance rankings stay the same though.


    > python odd_elements.py 
    APPROACH #1 :   100.00%  (2.07391 sec)
    APPROACH #1b:    96.95%  (2.01062 sec)
    APPROACH #2 :   697.01%  (14.4554 sec)
    APPROACH #3 :   122.20%  (2.53422 sec)
    APPROACH #4 :   315.16%  (6.53619 sec)
    APPROACH #4b:   719.41%  (14.92 sec)
    APPROACH #5 :   109.06%  (2.26185 sec)
    APPROACH #6 :    68.83%  (1.42751 sec)

    > python -O odd_elements.py 
    APPROACH #1 :   100.00%  (1.96201 sec)
    APPROACH #1b:    97.42%  (1.91136 sec)
    APPROACH #2 :   711.30%  (13.9558 sec)
    APPROACH #3 :   125.33%  (2.45899 sec)
    APPROACH #4 :   306.96%  (6.02248 sec)
    APPROACH #4b:   731.77%  (14.3575 sec)
    APPROACH #5 :   115.87%  (2.27329 sec)
    APPROACH #6 :    71.37%  (1.40032 sec)

-- 
Randall Hopper
aa8vb at yahoo.com



From MSteed at altiris.com  Fri Dec 10 09:25:16 1999
From: MSteed at altiris.com (Mike Steed)
Date: Fri, 10 Dec 1999 07:25:16 -0700
Subject: Linux.Com
Message-ID: <65118AEEFF5AD3118E8300508B124877073CCD@webmail.altiris.com>

> From: warlock at eskimo.com [mailto:warlock at eskimo.com]
> Sent: Thursday, December 09, 1999 2:42 PM
> To: python-list at python.org
> Subject: Re: Linux.Com
> 
> 
> On Wed, 8 Dec 1999 00:07:20 -0500 (EST), 
>  Barry A. Warsaw, in the persona of ,
>  brought forth the following words...:
> 
> >
> >>>>>> "AC" == Al Christians  writes:
> >
> >    AC> Python is running a healthy 4th in the Linux.Com scripting
> >    AC> languages poll.
> >
> >Looks like your message has rallied the troops!  It's now running a
> >distant second behind the 4-letter word of scripting languages :)
> >
> >Perl   42.65% (633)
> >Python 16.31% (242)
> >PHP    15.84% (235)
> >
> >Hmm... anybody think we need more `P' languages?
> >
> >-Barry
> >
> (not scripting but whattheheck) 
> Prolog? 
> PL/1
> pan
> umm... I am running out, any others?

Well, I guess you asked for it.

ftp://wuarchive.wustl.edu/doc/misc/lang-list.txt

I was going to copy just the "P" languages here, but the text (which
includes descriptions) is over 50KBytes.  Incidentally, the list still
refers to Python-1.0.0, ca. 1991.  "Available for Unix, Amoeba, and Mac."

--
M.



From gmcm at hypernet.com  Sun Dec 12 10:41:33 1999
From: gmcm at hypernet.com (Gordon McMillan)
Date: Sun, 12 Dec 1999 10:41:33 -0500
Subject: Packaging packages?
In-Reply-To: 
Message-ID: <1267109922-8994161@hypernet.com>

Michael P. Reilly wrote:

> Fredrik Lundh  wrote:
> : Jeffrey Kunce  wrote: :>
> Is there a way to collect all the python modules in a package
> into one file? 

> : 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.

> 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)].

- Gordon



From artymiak at safenet.pl  Sun Dec 19 07:12:01 1999
From: artymiak at safenet.pl (Jacek Artymiak)
Date: Sun, 19 Dec 1999 12:12:01 GMT
Subject: Python Users Counter
Message-ID: <385CD1C1.F8342DD0@safenet.pl>

Greetings Python Fans!

I just published the first version of my Python Users Counter page.  If
you use Python, go to http://www.wszechnica.safenet.pl , scroll to
Python section and click on the Python users Counter.  

Enjoy!

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 BgPorter at NOacmSPAM.org  Wed Dec 15 09:19:09 1999
From: BgPorter at NOacmSPAM.org (Brett g Porter)
Date: Wed, 15 Dec 1999 14:19:09 GMT
Subject: C++ (was RE: Python suitability)
References: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it>
Message-ID: 

"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.

Thx.
BgP





From skaller at maxtal.com.au  Sun Dec 26 10:42:39 1999
From: skaller at maxtal.com.au (skaller)
Date: Mon, 27 Dec 1999 02:42:39 +1100
Subject: "sins" (aka, acknowledged language problems)
References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <38656610.E4DA287B@maxtal.com.au> <006c01bf4f82$a39bc220$bf2b2bc1@martelli>
Message-ID: <3866376F.72E62E79@maxtal.com.au>

Alex Martelli wrote:

> > 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.

	It's very often possible to 'solve' this
kind of problem with wrapper classes -- but it isn't
always good programming style.

	Firstly, it requires writing the class
non-locally, to solve a localised problem.
Secondly, the reader has to find the class,
and try to understand it, and remember its name.
I think people remember patterns (idioms) better than names.

	If the class is 'general purpose'
enough, it is common to make a utilities
module. But somehow, this doesn't work well:
everyone has their own private 'utilities'.

	The 'classic' bungle (well, I did it :-)
was to #define BEGIN and END (a'la modula) and use
them in C: it makes the code unreadable -- except
to a Modula programmer :-)

	I think my point is, it seems to be better
to write out the long winded code each time
than wrap it up, unless it has significant application
related functionality, or is somehow 'standardised':
made part of the core language, or be a part of a
very popular toolkit. E.g I might forgive someone
for using mxTools.

	[Please note these truly are vague, personal
impressions]
 
> (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).

	Yeah -- even if it works, you get an uneasy 
feeling that it make the code a bit harder to read?

> 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.

	Python's scopes are NOT simple.
The idea that 'exactly two scopes' is simpler
that 'stack of scopes' is a misconception,
and it doesn't even work in Python: 
there are at least two places where it fails:
(a) the __builtins__ hack, to make builtin
functions available, and (b) in except clauses,
to make the exception available.

	On the other hand, starting from some
weird hackery, I have eventually evolved an implementation
in Viper of a thing called an 'environment' which is
represented internally by an abstraction supporting
get, set and del methods for variables. At present,
I use six or seven distinct instances of environments
in various contexts:

	a) module environment (for defining modules)
	b) class environment (for defining classes)
	c) function environment (for executing function bodies)
	d) exception handler environment (for exception handlers)
	e) with/do environment (for the with/do statement)
	f) python globals/locals environment 
		(for compatibility in 'exec' et al)
	g) null environment (bottom of an environment chain)
	h) stacked environment (used during imports??)

and the increasingly clean implementation tends to suggest
this concept actually works better in python than 'two scopes'.
It was, of course, necessary to do something like this in
Viper to support lexical scoping.

> What are the drawbacks of supplying the needed
> wrappers, rather than adding new syntax...?

	For a start, efficiency. And, as above,
readability.
 
> > 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.

	I'm not sure. I also have no candidate syntax
for defining the labels. Labelled breaks give me
an uneasy feeling.
 
> > 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:-).

	Quite a lot of the time, you CAN provide the y:
using functional programming with map and reduce etc.
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.

	for example, to loop thru two lists I can write:

	for x,y in zip(l1, l2): ..

which is something like:

	for x,y in map(None, l1, l2):

although I can never figure map(None, ..) out.
But somehow, this is wrapping the structure TOO much.
Guido noted something like

	for x in l1; for y in l2:

at the last conference, which is a bit ugly,
but it _exhibits_ the intended structure better
than functional wrapping: here I can see a
pattern, rather than remember a name.

-- 
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 greg.ewing at compaq.com  Mon Dec 20 05:50:18 1999
From: greg.ewing at compaq.com (Greg Ewing)
Date: Mon, 20 Dec 1999 23:50:18 +1300
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> <8399kd$rj1$1@nnrp1.deja.com> <38594BD2.B576A1E@maxtal.com.au>
Message-ID: <385E09EA.FD8FB88@compaq.com>

skaller wrote:
> 
>         The 'inconsistency' I believe you are refering to is
> that there are two such 'type' representations at run time,
> and they have different properties: you can modify classes
> dynamically, and you can derived new classes, so that
> the class is 'really' the representation of the 'type'
> abstraction of the application programmer .. but when it
> comes to dictionaries, the abstraction has to be switched
> to type objects.
> 
>         This seems inconsistent to the programmer, right?

I think people are unhappy with the situation
not so much because of some theoretical notion of types, but
because of more pragmatic considerations.

Sure you can subclass from UserDict, UserList, etc. and get the
behaviour you want, most of the time. But the resulting objects
are far less efficient to use than their built-in counterparts.
One feels that there should be some way to build on the built-in
behaviour of these objects without incurring such a large
performance penalty.

Also, these "fake" objects don't always work, because some
built-in or extension functions expect to get a genuine
built-in object.

>         For example, I have previously posted an example
> Viper is going to support (it doesn't yet). It is possible
> to define a class representing
> 
>         ListOfSomething
> 
> where the 'Something' is bound when an instance is constructed:
> 
>         PyListOfInt = ListOfSomething(PyInt)

I'm curious - what is this list object actually like? Does
it share the same representation as the built-in list
object? If so, how does this come about?

There seems to be a third notion of "type" lurking behind
the scenes, namely the run-time representation of the object.
In CPython this is the C type of the data structure representing
the object, and there is a one-to-one correspondence between
TypeObjects and C structures, which the interpreter exploits
to make sure that what it's about to do is an appropriate
thing to do to this kind of C structure.

In Viper, it seems that this relationship no longer holds,
since you can plug any object in as a type object. What
ensures that the representation of an object matches what
the methods in its type object expect?

Greg


From mlh at vier.idi.ntnu.no  Tue Dec 21 16:19:19 1999
From: mlh at vier.idi.ntnu.no (Magnus L. Hetland)
Date: 21 Dec 1999 22:19:19 +0100
Subject: Arg! [Long]
References:  <14431.56728.357282.276777@weyr.cnri.reston.va.us>  <14431.58546.940849.802614@weyr.cnri.reston.va.us>  <14431.60189.682411.792427@weyr.cnri.reston.va.us>
Message-ID: 

"Fred L. Drake, Jr."  writes:

> 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!

ARG!

(I'm *really* getting sleepy now...)

>   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.
> ;)

Well - I had one... Now I have to make another one... (tapping
away...)

Ah!

Suddenly it works. Hm. So it actually needs sourcecode - i'd say
that's quite a shortcoming 



Except... As long as the source file is called spammodule, it seems
that the module name is also spammodule, although I would like it to
be called spam (which is what I called in the setup file, like the
example in the docs...)

--

  Magnus
  Lie
  Hetland


From aahz at netcom.com  Fri Dec 31 17:32:32 1999
From: aahz at netcom.com (Aahz Maruch)
Date: 31 Dec 1999 22:32:32 GMT
Subject: File handling summary (was newbie question...)...
References: <386D127F.3840BEE7@earthlink.net>
Message-ID: <84jau0$1if$1@nntp9.atl.mindspring.net>

In article <386D127F.3840BEE7 at earthlink.net>,
Alexander Sendzimir   wrote:
>
>All measurements are over 100 runs. Each run timed using GNU time.

Try time.time() next time.  ;-)  (That will make sure you factor out the
Python loading 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.

I'll guess that this has to do with memory allocation.
--
                      --- Aahz (@netcom.com)

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

Eighth Virtual Anniversary -- today!


From bitbucket at isomedia.com  Tue Dec 28 17:52:03 1999
From: bitbucket at isomedia.com (Eugene Goodrich)
Date: Tue, 28 Dec 1999 22:52:03 GMT
Subject: Super Tuples
References: <386745A6.9B671DBF@prescod.net>  <3869337E.996B9BAE@prescod.net>
Message-ID: <38693e89.14008172@news.isomedia.com>

When I started in Python, my PyMentor described tuples as immutable
lists.  When they start acting like much more than that, isn't it time
to use an object?

     -Eugene

>
>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
>

import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==')


From annis at biostat.wisc.edu  Thu Dec 16 17:34:54 1999
From: annis at biostat.wisc.edu (William Annis)
Date: 16 Dec 1999 16:34:54 -0600
Subject: ANN: PyKstat-0.02 - Solaris kstat(3k) interface
Message-ID: 

        PyKstat is a Python interface to the Solaris kstat kernel
statistics chain.  Now you don't have to fork off 'uptime' and parse
the output to find out your machine's load.  It's written with the
help of SWIG.  In fact, I don't think it would have happened without
SWIG. :)

        This is a new feature update from version 0.01.  Now several
RAW kstats can be queried: vminfo, ncstats (directory name cache),
cpustat and sysinfo.

        The code, with some additional information, can be found at
http://www.biostat.wisc.edu/~annis/creations/pykstat.html .

        Now, to update the Parnassus entry...

-- 
William Annis - System Administrator - Biomedical Computing Group
annis at biostat.wisc.edu                       PGP ID:1024/FBF64031
Mi parolas Esperanton - La Internacia Lingvo    www.esperanto.org


From mhammond at skippinet.com.au  Sun Dec 19 19:43:44 1999
From: mhammond at skippinet.com.au (Mark Hammond)
Date: Mon, 20 Dec 1999 00:43:44 GMT
Subject: win32 binary data manipulation in ASP
References: <385CC64E.25E91136@bogusaddress.com>
Message-ID: <4Ze74.5225$NV6.22879@news-server.bigpond.net.au>

"Joe Smith"  wrote in message
news:385CC64E.25E91136 at bogusaddress.com...
>
> I am trying to write a server side ASP script in python.
>
>     buffer = os.read(fd, numBytes)
>     Response.BinaryWrite(buffer)
>
> I notice that I am getting exactly double the number of bytes on
output.  I
> suspect that the string returned from os.read() is getting converted
to
> unicode.
>
> I am looking for a way to convert the string to an array of bytes,
not an array
> of unicode characters.

If you have build 127 of win32all, you can use a buffer object.  eg:

   data = os.read(fd, numBytes)
   Response.BinaryWrite(buffer(data))

[ie, note that "buffer" is a Python builtin, so the variable name was
changed]

This also depends on ASP accepting data in this format - Im guessing
it will, but I dont know for sure...

Mark.





From s323140 at student.uq.edu.au  Wed Dec 22 04:58:58 1999
From: s323140 at student.uq.edu.au (Rob Hodges)
Date: 22 Dec 1999 19:58:58 +1000
Subject: Equivalent to (a ? b : c) ?
References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <83lnq7$c9d$1@news1.tele.dk>   <86puvz6dbg.fsf@g.local>
Message-ID: 

Gareth McCaughan  writes:

> Rob Hodges wrote:
> 
> [someone else:]
> >>>> ((a and (b,)) or (c,))[0]
> > Someone mentioned that this is idiomatic Python, but actually it is
> > idiomatic lisp.
> 
> Eh?
> 
> Certainly (if a b c) is idiomatic Lisp with the same meaning,
> but the particular hack involved certainly isn't. You *could*
> say something like
>   (car (or (and a (list b)) (list c)))
> but that would be horribly unidiomatic Lisp. I'm not sure
> what the point is here.

Not being an old-time lisper, I guess I must have been speaking crap
since I have been corrected both on and off-list!  However I recall
having seen the lazy `and' and `or' exploited together more than a few
times when wading through the source of various emacs packages and
quickly becoming familiar with its meaning, making it seem fairly
natural to me in Python.  

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.  

Making lists out of b and c, and grabbing the car of result is not
idiomatic lisp; in fact I completely overlooked that because although
it doesn't exactly look natural in Python, it's easy enough to see
what's happening even if you don't know why it was done -- whereas if
you don't recognise the laziness of `and' and `or', you'll have a
really hard time seeing what's going on.  So that was what I saw as
being the confusing part.  Even though they are lazy in C too (if
memory serves...), you don't often see that exploited (probably
because you have the conditional operator there...)


BTW, my derivation of "idiomatic" was intended tongue-in-cheek; not as
a linguistic analysis.  Sorry to have offended the linguists, though I
did learn the true derivation, so it was a profitable comment for me
at least :)  I will offer in exchange that perhaps "idiot" does stem
from the same root after all, in the sense that it might be
interpreted as "someone who does things that make sense to themself
[but to nobody else]".  Food for thought (and more offtopic by the
minute; sorry).  

Cheers,
-Rob



From jeske at egroups.net  Sun Dec  5 16:15:49 1999
From: jeske at egroups.net (David Jeske)
Date: Sun, 5 Dec 1999 13:15:49 -0800
Subject: Python Type-Inference based LINT.. (pylint.py)
In-Reply-To: <38482EB9.76AA5046@maxtal.com.au>; from python-list-admin@python.org on Fri, Dec 03, 1999 at 10:36:12PM -0500
References: <199912040336.WAA22210@python.org>
Message-ID: <19991205131549.M19929@teapot.egroups.net>

> Jeremy Hylton wrote:
> 
> > 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.

This is a very interesting issue. On the one hand, it definetly makes
sense to let the code implicitly define the "micro-types" because that
is in fact what is actually required for the code to run correctly.

However, I'm not sure that it's incredibly useful to allow code based
on such fine grained types to static check correctly. Here is a
(somewhat long) example:

There is another goal of pylint.py, and that is to output a
ctags-esque list of what functions and variables are of what types.

(see "Theory of Operation: Stage 2" in
http://www.chat.net/~jeske/Projects/PyLint/download/pylint-19991121.py)

In this case, it seems far more relevant to upgrade to the proper type
than to provide the micro-type. For example, for the function below,
"A" seems more human readable than "B":

 def sumListElements(a_list):
   total = 0
   for an_element in a_list:
     total = total + an_element
   return total
 
-- We then extract and output one of the following type signatures:

 A) sumListElements( SequenceType of NumberType ) -> NumberType
 B) sumListElements( MicroType{
                               __getitem__(NumberType) -> MicroType{__add__},
                               __len__() -> NumberType 
                               } ) -> MicroType{__add__}


NOTE: I've left out the __coerce__, and the functional type signature
for __add__ just to make the type signature smaller. However, I hope
you get the idea.

Now that we have a picture in our heads of the "micro-type" signature
vs. the "proper type" signature of the same function. 

-- Here is the starter question:

How relevant is it to do the static checking based on B instead of A?

Could you pass an object to sumListElements which only implemented
"__getitem__" and "__len__"? Yes, you could. However, it seems
terribly fragile to allow this kind of behavior to go unchecked. When
someone is coding inside of sumListElements in the future, it seems
reasonable for them to make the assumption that they are working with
a whole-type such as a Sequence (i.e. list). They might take a look at
the function and decide that they want to fix a bug which exists:

The old version of the function assumes that the elements which are
added are going to be numbers. This version allows there to be
strings, or other addable elements:

 def sumListElements(a_list):
   total = a_list[0]
   for an_element in a_list[1:]:
     total = total + an_element
   return total

This changes the "proper type" signature to:

  sumListElements( SequenceType of AddableType ) -> AddableType

However, in doing so, it also requires that the "a_list" argument
include __getslice__, another part of SequenceType. Making the
implicit type signature closer to:

 sumListElements( MicroType{
                            __getitem__(NumberType) -> MicroType{__add__},
                            __len__() -> NumberType,
                            __getslice__(NumberType,NumberType) -> 
                                     MicroType{__getitem__(NumberType) -> MicroType{__add__}
                           } ) -> MicroType{__add__}

If you were coding the above function, I would gander that you would
consider this a reasonable change to have made. In the "proper type"
signature, it only became more general. No existing code would
break. However, if code was allowed to rely on the "micro-type"
signature and pass in objects which only implemented __getitem__ and
__len__, that code would now be broken.

The good news is that the static checker would catch the problem
anyhow. The bad news is that IMHO it seems fragile.

-- Here is the final question:

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
      total = a_list[0]
      for an_element in a_list[1:]:
        total = total + an_element
      return total

 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


-- 
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske at egroups.net
                    eGroups Core Server Engineering



From effbot at pythonware.com  Fri Dec  3 07:45:55 1999
From: effbot at pythonware.com (eff-bot)
Date: Fri, 3 Dec 1999 13:45:55 +0100
Subject: A Date With Tim Peters...
References: <199912020003.TAA13009@eric.cnri.reston.va.us> 
Message-ID: <00a701bf3d8c$581f8640$f29b12c2@secret.pythonware.com>

Raymond Sheffield  wrote:
> I recommend a cage, a whip, and a stun-gun.

hmm.  tim doesn't look that scary to me:

    http://www.music-booking.de/tim/

> I think of Godzilla and Peters in the same sentence. 

don't worry.  Captain Bio will be there to help:

    http://www.biocomics.com/




From tim_one at email.msn.com  Sat Dec  4 17:12:19 1999
From: tim_one at email.msn.com (Tim Peters)
Date: Sat, 4 Dec 1999 17:12:19 -0500
Subject: indentation
In-Reply-To: <82b297$1lq$1@thoth.cts.com>
Message-ID: <000201bf3ea4$a16e9200$df2d153f@tim>

[Will Rose]
> I always assumed that Python's whitespace rules _came_ from Fortran IV:
> or at least something overly intimate with 80-col punched cards.

Python's use of whitespace is the polar opposite of Fortran Classic's:
whitespace means nothing in the latter, not even as a token separator.

      DO 5 INDEX = 1, 20

is the same as

      DO5INDEX=1,20

is the same as

           D     O5IND     EX =1,2     0

None of them mean what

     DO 5 INDEX = 1, 20

means, though, because the leading "D" in the last one is in column 6.
Python's rules have nothing in common with any of that.

whitespace-ignored-vs-whitespace-required-ly y'rs  - tim





From dworkin at ccs.neu.edu  Tue Dec 28 10:19:23 1999
From: dworkin at ccs.neu.edu (Justin Sheehy)
Date: 28 Dec 1999 10:19:23 -0500
Subject: Speed issues
References: <19991227143547.A3500@stopcontact.palga.uucp>
Message-ID: 

Gerrit Holl  writes:

> is an assigment slower than appending to a list?

That isn't really the important question, given your example.

> def f(s):
>  o=[]
>  for c in s:
>   o.append(chr(ord(c)/2))
>  return string.join(o, '')
> 
> or:
> 
> def f(s):
>  o=''
>  for c in s:
>   o = o + chr(ord(c)/2) 
>  return o
> 
> What is faster? What do you prefer?

The first approach will generally be much faster, but the reason for
it is that the second approach will construct and throw away so many
temporary strings along the way.

Each time the line 

  o = o + chr(ord(c)/2)  

Is processed, a new, slightly larger string is built and the previous
one is thrown away.  The first approach does not have this problem.

-Justin

 


From sposhua at my.pc  Thu Dec 16 04:20:59 1999
From: sposhua at my.pc (Sposhua)
Date: Thu, 16 Dec 1999 09:20:59 +0000
Subject: Not really about python...
In-Reply-To: <3857b005.0@news.cyberway.com.sg>
References:  <3857b005.0@news.cyberway.com.sg>
Message-ID: 

On 15 Dec 1999, Ng Pheng Siong wrote:

> According to Sposhua  :
> > 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 ;-)
> 
> IIRC, once upon a time, the canonical command-line SMTP talker for NT
> was called "blat". It was much used by Perl CGI programmers.

Just for the record, I found that a command-line mailer exists for NT called
sendmail.exe (only it wasn't installed on my system).

> Of course, on Python, just use smtplib.

I should have known that in Python there is a library for everything...



From mfletch at tpresence.com  Fri Dec 17 06:16:39 1999
From: mfletch at tpresence.com (Mike Fletcher)
Date: Fri, 17 Dec 1999 06:16:39 -0500
Subject: LISTS: Extract every other element
Message-ID: 

With the little module below, I attempted to test the speed of your
implementation.  It is really quite good (not to mention linear with the
size of the data being processed). The Numeric approach requires about 1/2
the time in all cases. My (slightly modified) approach is slightly faster.
On data sets of 10**7 integers, time on my machine is 1.097 for my
list-based approach, and 0.451 for the Numeric approach, and 1.185 for your
implementation. 10**8 causes severe memory effects on my machine.

So, in conclusion, if you can use Numeric arrays, you can likely cut your
time by two (not counting whatever savings can be seen by not calling
Numeric.array(data) in the taking function).  If you cannot, I can't see a
more efficient approach using straight lists. All-in-all, none of these is a
really slow algorithm unless you're doing this many times.

Incidentally, the only difference between our algorithms is that I'm using
an integer multiply instead of an integer divide.

Hope this helps,
Mike

def test1( data, step=2 ):
	result = [None]*(len(data)/step)
	for index in xrange(len(data)/step):
		result[index]=data[index*step]
	return result

def test2( data, step=2, offset=0):
	import Numeric
	data = Numeric.array( data, Numeric.Int32 )
	print len(data)
	data.shape= (step, -1)
	return data[offset]

def test3( data, step=2):
	lst2 = [ None ] * (len(data)/2)
	for i in xrange( 0, len(data), 2 ):
		lst2[i/2] = data[i]



##print test1( testdata )
import profile
def bigTest( ):
	for exponent in range(1, 7): # up to 10**7 (10 million)
		global data
		data = range( 10**exponent)
		print "list"
		profile.run ("test1( data)")
		print "matrix"
		profile.run ("test2( data)")
		print "given"
		profile.run ("test3( data)")
if __name__ == '__main__':
	bigTest()

-----Original Message-----
From: Randall Hopper [mailto:aa8vb at yahoo.com]
Sent: Thursday, December 16, 1999 1:14 PM
To: python-list at python.org
Subject: LISTS: Extract every other element


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?:

      lst2 = [ None ] * len(lst)/2
      for i in xrange( 0, len(lst), 2 ):
        lst2[i/2] = lst[i]

-- 
Randall Hopper
aa8vb at yahoo.com

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



From tratt at dcs.kcl.ac.uk  Tue Dec 28 15:08:12 1999
From: tratt at dcs.kcl.ac.uk (Laurence Tratt)
Date: Tue, 28 Dec 1999 20:08:12 GMT
Subject: obj in list and list ids the same
References: <84a8k4$puq$1@nnrp1.deja.com>  <84ar5o$6n4$1@nnrp1.deja.com>
Message-ID: <5f0da77749.laurie@btinternet.com>

In message <84ar5o$6n4$1 at nnrp1.deja.com>
          rdudfield at my-deja.com wrote:

[rdudfield at my-deja.com]
>>> 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().
[Laurie]
>> If you're using CPython, then this is *very* unlikely (I can't speak for
>> the other implementations); id() returns the memory address of a given
>> object
[rdudfield at my-deja.com]
> Could the problem be with copy.copy maybe?

I doubt it, but it's worth knowing that copy.copy on a list is basically
equivalent to list[:], so:

  a = [ ... ]
  a_copy1 = copy.copy(a)
  a_copy2 = a[:]

will both return new *shallow* copies of a. If you want to copy the list,
and also make a brand new copy of everything inside it, you need
copy.deepcopy.

Somewhere I presume you have code like:

  l = [ ... ]
  print id(l)
  for item in l:
    if id(item) == id(l):
       print "List '%s' and item '%s' have same ids" % (str(l), str(item))
       print item is l        # See what 'is' has to say about the objects;
                              #   this won't work if 'is' is implemented
                              #   using id() or equivalent

I think you need to double check to see you really are getting different
objects yielding the same id() at the same time. Check what C extension
modules you are using; perhaps one of them is getting its ref counts in a
twist. As far as I know, Python 1.5.2 doesn't have any known leaks; but less
well known extensions may have leaks.


Laurie
-- 
http://eh.org/~laurie/comp/python/


From bjorn at roguewave.com  Fri Dec 17 12:00:06 1999
From: bjorn at roguewave.com (bjorn)
Date: Fri, 17 Dec 1999 10:00:06 -0700
Subject: iteration (was RE: "sins" (aka, acknowledged language problems))
References: <6D8A17398E28D3119F860090274DD7DB4B3D53@pces.cadlab.it> <83djat$u1k$1@nntp9.atl.mindspring.net>
Message-ID: <385A6C16.949548E0@roguewave.com>


Aahz Maruch wrote:

> 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.

And to make sure we can get off on another tangent... ;-)

I recently had to implement my own special purpose list-like structure in c++ for
use by my python program.  I implemented __getitem__ and __len__ and was naive
enough to think that that would be enough for:

    for x in myList:
        foo(x)

but of course it caused a coredump when python kept requesting items way beyond
the __len__ of the container...  I solved it by:

    i = 0
    while i < len(myList):
        x = myList[i]
        foo(x)

which works, but wasn't what I was hoping for (*sigh*)...  Anyone know how to
raise an IndexError through SWIG?

-- bjorn




From aprasad at magix.com.sg  Fri Dec 24 21:10:03 1999
From: aprasad at magix.com.sg (Ajith Prasad)
Date: Sat, 25 Dec 1999 10:10:03 +0800
Subject: FINANCIAL MODELLING PACKAGE IN PYTHON?
Message-ID: <841d0c$j0n$1@violet.singnet.com.sg>

Andy Robinson's website at http://www.robanal.demon.co.uk mentions his work
on DoubleTalk which uses Python to handle accounting transactions. I saw
also references to work by Kevin McDermott on use of Python in finance.

I wonder whether anyone is working on a full-fledged financial modelling
package in Python? I have in mind a package similar to IFPS (Interactive
Financial Planning System) described in "Visual IFPS/Plus for Business"
by Paul Gray (details at http://www.amazon.com), but extensible in Python
with OLAP-type functionality. I am sure that there would be a good market
for such a product among finance professionals who need much more than a
spreadsheet but who find current commercially available OLAP packages
inadequate as they have very convoluted and limited rules languages for
expressing business logic, especially, financial or corporate models.





From skip at mojam.com  Tue Dec  7 09:06:00 1999
From: skip at mojam.com (Skip Montanaro)
Date: Tue, 7 Dec 1999 08:06:00 -0600 (CST)
Subject: Help with tuples please?
In-Reply-To: <82ivrl$744$1@rtpnews.raleigh.ibm.com>
References: <82ivrl$744$1@rtpnews.raleigh.ibm.com>
Message-ID: <14413.5192.187203.108127@dolphin.mojam.com>

    Arinte>   PyErr_SetString(PyExc_SystemError,
    Arinte>       "new style getargs format but argument is not a tuple");

It's been awhile since I ran across this problem (and you didn't post
example code ;-), so my memory may fail me here.  Have you checked the
initialization of your PyMethodDef struct(s) in your extension module?  Each
item in the methods array should have three elements, the third being the
integer 1.  Check Modules/xxmodule.c for a skeletal definition.

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 zippy at cs.brandeis.edu  Sat Dec 11 02:22:16 1999
From: zippy at cs.brandeis.edu (Patrick Tufts)
Date: Fri, 10 Dec 1999 23:22:16 -0800
Subject: Python and regexp efficiency.. again.. :)
References: 
Message-ID: <101219992322162268%zippy@cs.brandeis.edu>

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:

   ^commonstring(.*)

and then matching the saved pattern (.*) against a dictionary of
possible extensions.

--Pat


From fdrake at acm.org  Fri Dec 10 12:00:44 1999
From: fdrake at acm.org (Fred L. Drake, Jr.)
Date: Fri, 10 Dec 1999 12:00:44 -0500 (EST)
Subject: How to parse (in the C code) a tuple not sent as an argument?
In-Reply-To: 
References: 
Message-ID: <14417.12732.444503.250188@weyr.cnri.reston.va.us>

Wojciech Zabolotny writes:
 > I have to parse in my C extension module a rather complicated tuple,
 > which is not send as an argument.
 > Is it correct and safe to use the PyArg_ParseTuple for this purpose?

  This is perfectly reasonable.  You can use the ';' format character
to specify an error message to use when a TypeError is raised because
the tuple being parsed doesn't match the format specifier.


  -Fred

--
Fred L. Drake, Jr.	     
Corporation for National Research Initiatives



From warlock at eskimo.com  Thu Dec  9 16:41:45 1999
From: warlock at eskimo.com (Jim Richardson)
Date: Thu, 9 Dec 1999 13:41:45 -0800
Subject: Linux.Com
References: <384DC8F1.9A1F135F@easystreet.com>  <14413.59272.858902.938397@anthem.cnri.reston.va.us>
Message-ID: 

On Wed, 8 Dec 1999 00:07:20 -0500 (EST), 
 Barry A. Warsaw, in the persona of ,
 brought forth the following words...:

>
>>>>>> "AC" == Al Christians  writes:
>
>    AC> Python is running a healthy 4th in the Linux.Com scripting
>    AC> languages poll.
>
>Looks like your message has rallied the troops!  It's now running a
>distant second behind the 4-letter word of scripting languages :)
>
>Perl   42.65% (633)
>Python 16.31% (242)
>PHP    15.84% (235)
>
>Hmm... anybody think we need more `P' languages?
>
>-Barry
>
(not scripting but whattheheck) 
Prolog? 
PL/1
pan
umm... I am running out, any others?

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



From news at dorb.com  Fri Dec  3 23:26:49 1999
From: news at dorb.com (Darrell)
Date: Fri, 3 Dec 1999 23:26:49 -0500
Subject: How to create cross between __getattr__() and __getitem__()?
References: 
Message-ID: 

Assuming I understand, this might help.

attrs={'dog':1, 'cat':2}

class A:
    def __getattr__(self, name):
        print 'GET IT!'
        global attrs
        val=attrs.get(name,None)
        if val:
            setattr(self, name,val)
        return val

a=A()
print a.dog
print a.dog

################ OUTPUT
GET IT!
1
1

--
--Darrell
"John Lull"  wrote in message
news:r8sg4sko7tjsstc9g544q697ji0s8ush0i at 4ax.com...
> I'm trying to create a class where someting like:
>    x = instance.undefined[i]
> works, given that "undefined" is the name of a previously-unknown
> attribute.
>
> I'd like to have that statement turn into one call something like:
>    instance.getAttrItem(self, "undefined", i)
> which is invoked only once, with both the name of the unknown
> attribute and the desired index.
>
> Unfortunately, executing getAttrItem() is an expensive (ie very slow)
> operation, so I can't afford to try it any more times than absolutely
> necessary.
>
> My first thought was to have __getattr__() return a new object,
> containing a reference to "instance", the name of the attribute
> requested, and a __getitem__() procedure to handle the indexing
> operation by invoking newObject.instance.getAttrItem().
>
> Unfortunately, though, I also need:
>    x = instance.undefined
> to work normally (ie have __getattr__() invoke getAttrItem() without
> specifying an index), but I can't see any way for __getattr__() to
> know whether it should try getAttrItem() immediately or should create
> and return the new object.
>
> Can anyone suggest a (preferrably simple) way to accomplish this?
>
> Thanks.
>
> Regards,
> John
>
> --
> http://www.python.org/mailman/listinfo/python-list





From badzen at yifan.net  Fri Dec 17 02:40:47 1999
From: badzen at yifan.net (dj trombley)
Date: Fri, 17 Dec 1999 07:40:47 GMT
Subject: Accessing C global variables from Python
References: <385994B5.6AD05BF0@be-research.ucsd.edu>
Message-ID: <3859E881.8AEA7083@yifan.net>


Curtis Jensen wrote:
> 
> Is there a way to access the global variables in a C class from Python?
> Without passing arguments back and forth between the two languages.
> Also, is it possible to do the same thing between C and Fortran?  If so,
> can some one explain it to me.  Thanks.
> 
> --
> Curtis Jensen
> cjensen at be-research.ucsd.edu
> FAX (425) 740-1451

The easy answer is "No." =)

C global variables are no more than locations in memory.
Therefore, to access them from Python, you'd have to access arbitrary
addresses 
in memory, which the Python interpreter probably does not have
permission to do.

Technically speaking, there are various shared memory schemes that one
can use to
allow "interoperation" between the two languages, but this approach is
sort of Wrong.

If the thing absolutely must be done, the Right solution is to write a
Python module in
C which will provide an object whose members access the various
variables who you wish to expose.

As for fortran, I don't know it.  But in general it will depend in the
latter approach on
if there is an interface or no for embedding C code.

-dj

Dave Trombley



From jasonic at nomadicsltd.com  Fri Dec 24 23:30:42 1999
From: jasonic at nomadicsltd.com (Jason Cunliffe)
Date: 25 Dec 1999 04:30:42 GMT
Subject: Anyone else making music with python?
References: <386115AB.A0DD3F6@angelfire.com>
Message-ID: <01bf4e90$25820b80$053abcc3@brancusi.pro-net.co.uk>

No not crazy at all - it is a shame that there is so little media or art
being done in Python. 

Not had time to look at your work yet, but in case you don't already know
about about it, I suggest to take a good look at Tim Tompson's wonderful 
'KeyKit':

http://thompsonresidence.com/keykit/

A terrific oops language for midi with a neat gui included. Kind of a cross
between MAX and HMSL. cross platform, free, source and lots of fun. Might
be linked to Python in many interesting ways. Lots of great ideas to be
inspired by.

enjoy

- Jason

Paul Winkler  wrote in article
<386115AB.A0DD3F6 at angelfire.com>...
> 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...
[snip]


From gmcm at hypernet.com  Tue Dec  7 11:43:44 1999
From: gmcm at hypernet.com (Gordon McMillan)
Date: Tue, 7 Dec 1999 11:43:44 -0500
Subject: 500 Internal ... not the same of Dan
In-Reply-To: <82j3c6$87h$1@nnrp1.deja.com>
Message-ID: <1267537923-27181052@hypernet.com>

mk_999 at my-deja.com writes:

> 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.

Since the update works, it is more likely that your error is in 
the page generation for the response. Please look at that 
other thread for how to trap errors, (most of these suggestions 
were misdirected, since the problem in that thread was a 
syntax error, not a runtime error).
 


- Gordon



From kdart at pacbell.net  Sat Dec 11 03:31:40 1999
From: kdart at pacbell.net (Keith Dart)
Date: Sat, 11 Dec 1999 00:31:40 -0800
Subject: pytags ?????
Message-ID: 

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.


                       /___\\|//__////
                       \   (+ +)  \\\\
-- --------------------oOOo~(_)~oOOo----------------------------------------
Keith Dart 


============================================================================



From claird at starbase.neosoft.com  Sun Dec 19 16:50:38 1999
From: claird at starbase.neosoft.com (Cameron Laird)
Date: 19 Dec 1999 21:50:38 GMT
Subject: Script to add passwords
References:  <385BE5B1.80A48C80@rubic.com>
Message-ID: 

In article <385BE5B1.80A48C80 at rubic.com>, Jeff Bauer   wrote:
>Bruno,
>
>You may consider using Paul Sheer's python Expect 
>module to perform this kind of task.  His example
>even includes a script demonstrating how to set
>a Unix password.
>
>ftp.obsidian.co.za/pub/expect
			.
			.
			.
>> 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.
>

Expect is wonderful, Python's wonderful, CGI keeps
rolling on.  I use 'em all, of course.

I'm tempted to give different advice to this ques-
tioner, though.  He explains his motivation as a
need to automate an IMAP server (automation is also
wonderful, while I'm in a judgmental mode).  What
I'm doing nowadays for most clients with e-mail needs
is setting up Unix servers where IMAP and brothers
(SMTP, POP) work from some authentication method
*other* than account validation.  I like having
10,000 e-mail accounts, but only eleven valid logins.
I don't hang out with other SysAds enough to judge
how widespread/accepted/successful/... this is.
It works for me, though, and I'm curious how others
see it.
-- 

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


From glandrum at my-deja.com  Thu Dec  9 15:38:47 1999
From: glandrum at my-deja.com (Greg Landrum)
Date: Thu, 09 Dec 1999 20:38:47 GMT
Subject: Win32 and the clipboard
References: <326536345498D311B3BC00105A39802A074522@newsintern.dspace.de>
Message-ID: <82p40m$i91$1@nnrp1.deja.com>

In article
<326536345498D311B3BC00105A39802A074522 at newsintern.dspace.de>,
  Stefan Migowsky  wrote:
>
> 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.
>

Since I needed a debug version, I had to install from source anyway.
Unfortunately in the source version I have (which I think corresponds
to build 127, I'm not sure because winCVS and I don't get along so
well) win32clipboard doesn't actually work: importing it leads
to an immediate seg fault under NT.

The problem is that initwin32clipboard() in win32clipboardmodule.cpp
is missing a call to PyWinGlobals_Ensure().  Once I copied some
initialization in from another module to give:
extern "C" __declspec(dllexport) void
initwin32clipboard(void)
{
  PyObject *dict, *module;
  PyWinGlobals_Ensure();
  module = Py_InitModule("win32clipboard", clipboard_functions);
  dict = PyModule_GetDict(module);
  Py_INCREF(PyWinExc_ApiError);
  PyDict_SetItemString(dict, "error", PyWinExc_ApiError);
}

everything worked fine.
(well, I haven't tested it yet, but I can at least import...
which is a step in the right direction)  :-)

-greg


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


From winkjj at my-deja.com  Wed Dec  1 16:45:28 1999
From: winkjj at my-deja.com (winkjj at my-deja.com)
Date: Wed, 01 Dec 1999 21:45:28 GMT
Subject: Equivalent Python API Code
Message-ID: <8244tn$ns$1@nnrp1.deja.com>

Could someone show me how to implement the following Python code using
the C API?

>>> mystr = '[100,200,300]'
>>> mylist = eval(mystr)
>>> mylist
[100, 200, 300]

Basically, I want to take a char* that holds the value of mystr, and
eval it, obtaining a PyObject* to a list.

Generically, I want to be able to eval any char* that represents some
code, and obtain a PyObject* to the real object...

I've tried using PyRun_String with the start token set to
Py_eval_input, but this doesn't work correctly.

Thanks in advance for your help....

Jeff.


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



From gmcm at hypernet.com  Fri Dec  3 10:22:12 1999
From: gmcm at hypernet.com (Gordon McMillan)
Date: Fri, 3 Dec 1999 10:22:12 -0500
Subject: DLLs and Pythonwin
In-Reply-To: 
Message-ID: <1267888063-6099284@hypernet.com>

Magnus L. Hetland writes:

> Oh, well. So no I have a PC too... I have been using Python on
> Solaris (and FreeBSD) up until now, and will continue to do so,
> but now I also use it under Windows NT. (Hey! IDLE is neat ;)
> 
> But - pythonw.exe complains that it can't find tcl80.dll in "the
> specified path". It seems that, at least the Tk part works fine
> (IDLE appears), and I did install tcl80.dll along with python.
> (It is there - I checked :)

It's finding it; just not where it expects to find it...
 
> This isn't really a *problem* for me (except for the annoying
> warning that it can't find the dll), but it seems a bit
> unnecessary. Is there any preferred solution? Where is the path
> referred to specified (so I could put in the dll)? Shouldn't this
> be fixed by the installation wizard? (IMO, for Windows, it would
> be nice if everything were just plug-and-play... I mean - it
> almost is on UNIX, even, so... ;)

Do NOT move the dll (then it won't find the libs). Put the dll's 
directory on you PATH. See lib-tk/FixTk.py if you want to 
know what's going on.

BTW, Pythonw and Pythonwn are entirely separate beasts. 
The latter is Mark Hammond's Python / MFC integration.

- Gordon



From scoobysnax5336 at my-deja.com  Sat Dec 25 10:34:43 1999
From: scoobysnax5336 at my-deja.com (scoobysnax5336 at my-deja.com)
Date: Sat, 25 Dec 1999 15:34:43 GMT
Subject: Tkinter documentation?
References: <841k01$n16$1@news1.konnect.net>
Message-ID: <842o0j$v38$1@nnrp1.deja.com>

http://www.pythonware.com/library.htm
has www version as well as pdf.
hope this helps.

                   Chris

In article <841k01$n16$1 at news1.konnect.net>,
  "Gregory A McCoy"  wrote:
> Hello,
>
>     I am trying to locate any documentation on tkinter.
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?
>
>     I would appreciate any pointers to docs that I am missing.
Perhaps a
> small demonstration program, eh???
>
>


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


From roy at popmail.med.nyu.edu  Mon Dec 20 16:02:59 1999
From: roy at popmail.med.nyu.edu (Roy Smith)
Date: Mon, 20 Dec 1999 16:02:59 -0500
Subject: ugly python namespace bug
Message-ID: 

I had a function which use to look like this:

   for type in stuff:
      if type == default:
         etc...

It worked fine, but for one reason or another, I decided to change the variable 
name from type to option, but forgot to change it in one place, and ended up 
with:

   for option in stuff:
      if type == default:
         etc...

My code stopped working, with the equality test always failing.  I scratched my 
head a while until I found the problem, but then couldn't figure out why I 
didn't get a name error ("type" undefined) until a co-worker pointed out that 
type is a built-in function.  My first version of the code just over-wrote the 
default value of type!

I see how it all works now, but boy, stuff like this sure does invite all sorts 
of nasty debugging problems!

-- 
Roy Smith 
New York University School of Medicine



From news at dorb.com  Wed Dec 22 19:12:52 1999
From: news at dorb.com (Darrell)
Date: Wed, 22 Dec 1999 19:12:52 -0500
Subject: How to read lines from end of a file?
References: <4rhfhazoj4.fsf@colargol.tihlde.hist.no> 
Message-ID: 

import sys

def readLinesFromEnd(fn,maxLen):
    """
    Read lines from the end of a file up to a max.

    fn:: file name to read from
    maxLen:: max number of bytes to read
    """
    fp=open(fn)
        # seek to the end
    fp.seek(0,2)
        # seek back from the end
    fp.seek(-min(maxLen,fp.tell()),2)
        # Dump the first line
        # It might be chopped off
    lines=fp.readlines()[1:]
    return lines

def main():
    print readLinesFromEnd(sys.argv[1],1000)

main()

--
--Darrell
"Alexander Williams"  wrote in message
news:slrn862nn8.6rk.thantos at chancel.org...
> 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
> --
> http://www.python.org/mailman/listinfo/python-list




From akuchlin at mems-exchange.org  Wed Dec 22 15:11:20 1999
From: akuchlin at mems-exchange.org (Andrew M. Kuchling)
Date: 22 Dec 1999 15:11:20 -0500
Subject: Python warts
Message-ID: <3dg0wuzqfr.fsf@amarok.cnri.reston.va.us>

The recent discussion of "Python sins" encouraged me to finish writing
a Web page on Python's design flaws.  I've added some comments from
the recent thread, but I'm sure there are arguments and
counterarguments that I've missed, and flaws that I haven't thought of
(or have ignored due to authorial bias).

See  http://starship.python.net/crew/amk/python/warts.html ; comments welcome!

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
If knowledge can create problems, it is not through ignorance that we can
solve them.
    -- Isaac Asimov



From jcosby at wolfenet.com  Sat Dec  4 16:05:22 1999
From: jcosby at wolfenet.com (Jon Cosby)
Date: Sat, 4 Dec 1999 13:05:22 -0800
Subject: Help!
Message-ID: <82bvla$q70$1@sparky.wolfe.net>

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. It shouldn't
take more than adding a new line to the registry editor - Is there something
I'm overlooking? I've read Aaron Watter's page over and over, and followed
it closely, but this just isn't working.
If anybody has any suggestions, please contact me.



--
Jon Cosby

E-mail: jcosby at wolfenet.com
Website: http://www.wolfenet.com/~jcosby/





From seant at iname.com  Thu Dec 23 23:32:04 1999
From: seant at iname.com (Sean True)
Date: Thu, 23 Dec 1999 23:32:04 -0500
Subject: Anyone know of a simple socket proxy in python?
Message-ID: 

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:

python plug.py hostname 80 21 23

would route all incoming connections to ports 80, 21, and 23 to an
internal host named 'hostname'.

I'll reinvent the wheel if necessary, but wanted to check. Comments on
the practicality of such a plug in Python are also welcome.

-- Sean



From tholap at compuserve.com  Fri Dec 10 15:15:49 1999
From: tholap at compuserve.com (Olaf Appelt)
Date: Fri, 10 Dec 1999 21:15:49 +0100
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> <022101bf42fe$d6e065e0$f29b12c2@secret.pythonware.com>
Message-ID: <82ro5b$9n1$1@ssauraab-i-1.production.compuserve.com>

Hi Fredrik,


thanks for your comments.

> > > 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?
>
> nope.  you should think a bit more about your
> original problem.

OK. I need to know whether a given identifier was accessed (assigned a new
value or used in an expression).
I'm open for suggestions to achieve this other than by defining a set of
classes that carry that information:

class MyVariable
   def __init__ (self, default = 0)
      self.value = default
      self.readAccessed = 0
      self.writeAccessed = 0

   def assign (self, other)        # ugly
      self.value = other
      self.writeAccessed = 1

   def __add__ (self, other)
      r = MyVariable (self.value + other)
      self.readAccessed = 1
      return r

   #... all remaining arithmetic operators

Something like the above would result in what I need, I think. Except that
assignment would look bad.

Plan A was to define a set of classes like the above.
Let the user do some arithmetic with them, plus a few ifs, fors and whiles
and then examine the instances from C++ (retrieving value and state
information).

> if I understand things correctly, you want to
> set a variable to something, execute some user
> code, and then inspect that variable.  right?

Sounds right.

> okay, here's how to do that:
>
>     c = "my value"
>
>     namespace = {}
>     namespace["c"] = c
>
>     exec usercode in namespace
>
>     c = namespace["c"]
>
>     print c
>
> in other words, let the user change "c" to whatever
> he/she wants, and pick up the result afterwards.  if
> it's not the right type, convert it (if that's a reason-
> able thing to do).  otherwise, complain to the user.

OK, but I see two problems with this:
1. I still don't know whether it was accessed for read and/or write.
2. I can complain that the variable has an invalid value, but I can't tell
when exactly it changed to that value, which would be important for the
target audience (folks who know the problem domain, but not much about
programming).


Olaf





From kclark at ntlug.org  Thu Dec 30 18:21:09 1999
From: kclark at ntlug.org (Kendall Clark)
Date: Thu, 30 Dec 1999 17:21:09 -0600 (CST)
Subject: [OT] OpenSource Python Books?
In-Reply-To: <3d7lhwrq05.fsf@amarok.cnri.reston.va.us>
References: <84g70v$tcq$1@nnrp1.deja.com>
	
	<386BC2A4.628D9C9A@callware.com>
	<3d7lhwrq05.fsf@amarok.cnri.reston.va.us>
Message-ID: <14443.59621.975171.406252@cmpu.net>

>>>>> "Andrew" == Andrew M Kuchling  writes:

    Andrew> Book topics... hmmm.  A good JPython book would be great,
    Andrew> and would probably increase JPython's visibility in the
    Andrew> Java community a lot; a book about Numeric Python would
    Andrew> probably have the same effect in the Fortran community.  I
    Andrew> suspect there's room for several Tkinter books beyond the
    Andrew> two upcoming ones, and there's space for GTk and Qt books,
    Andrew> too.

I'd take this in a bit of a different direction. As a relatively new
programmer, whose first and, so far, only language is Python (and
being totally self-taught), I'd like to see Python get used in some of 
the places where Scheme has traditionally been used; i.e., as the
"first language" in academic settings, with all the appropriate books
using Python instead of (or in addition to) Scheme.

I'd give my eye teeth for any of the following:

Algorithms in Python
Essentials of Programming Languages (using Python)
Structure and Interpretation of Computer Programs (using Python)
Patterns in Python

I know Scheme has some features that make it more desirable in some
ways than Python for stuff like EOPL, but Python was *so* much easier
for me to advance rapidly with than Scheme. Maybe that's just the
quirks of my brain, though.

I suppose such books will come about only insofar as CS profs use
Python as the "first language". I also have a hunch that as I improve
as a programmer, and learn a 2nd and 3rd language, my desire for these
things will diminish. But, hey, a Python autodidact can hope!

Any signs that Python is getting used by CS profs/depts as a first language?

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?

Best,

Kendall Clark
--
Honesty subverts!



From volumeregeling at hotmail.com  Wed Dec  1 10:31:25 1999
From: volumeregeling at hotmail.com (volumeregeling)
Date: Wed, 01 Dec 1999 15:31:25 GMT
Subject: how to get methods from COM objects
Message-ID: <38453eff.5789544@122.0.0.250>

Hi,

Can anybody tell me how to extract methods from a COM object.
For instance i?d like to know what methods internet explorer exposes,
so i can direct IE from within python.


thanks.



From hinsen at cnrs-orleans.fr  Fri Dec  3 08:27:05 1999
From: hinsen at cnrs-orleans.fr (Konrad Hinsen)
Date: 03 Dec 1999 14:27:05 +0100
Subject: A Date With Tim Peters...
References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street>  <38465BA0.4F1A90A4@appliedbiometrics.com>
Message-ID: 

Christian Tismer  writes:

> Another viewpoint:
> What is your first birthday?
> It is the day after your first year of life,
> which starts on your zeroth birthay which is your birth.

This is in fact the convention we use for all measurements *except*
dates. The first day of a month gets the number one, not zero, etc.
But these are just arbitary conventions that differ between cultures,
even counting is not universal. Another strange habit (to us at least,
with the possible exception of musicians) is "inclusive counting",
i.e. counting the first *and* last item when calculating differences,
yielding for example two days between Monday and Tuesday. This was
customary with the Romans and led to some misunderstandings in the
application of leap years.
-- 
-------------------------------------------------------------------------------
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 mhammond at skippinet.com.au  Sun Dec  5 01:06:52 1999
From: mhammond at skippinet.com.au (Mark Hammond)
Date: Sun, 05 Dec 1999 06:06:52 GMT
Subject: Screensaver hooks. ...
References: <3849B675.98D5D356@callware.com>
Message-ID: <0in24.3774$GA.19427@news-server.bigpond.net.au>

Ivan Van Laningham wrote in message <3849B675.98D5D356 at callware.com>...
>Hi All, but mostly Mark--
>Just out of curiousity, does Win32API include hooks to enable the
>creation of screensavers?

Afraid not - would be fun to do tho :-)

Mark.





From reic0024 at ub.d.umn.edu  Thu Dec  2 22:55:46 1999
From: reic0024 at ub.d.umn.edu (Aaron J Reichow)
Date: Thu, 2 Dec 1999 21:55:46 -0600
Subject: split this newsgroup?
In-Reply-To: <38473B4E.9050DF4D@callware.com>
References:  <38473B4E.9050DF4D@callware.com>
Message-ID: 

I second that no.  IMO, it's not that much, and I can usually handle to
read it once a day.

Aaron




From bernhard at alpha1.csd.uwm.edu  Fri Dec 10 16:17:07 1999
From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter)
Date: 10 Dec 1999 21:17:07 GMT
Subject: Please Critique
References: 
Message-ID: 

On 7 Dec 1999 02:32:04 GMT, Michael Fraley  wrote:

>This is my first real-world Python script, I'd like to hear any
>pointers on how to improve it or do things better. 

>Here's my script. I'd really appreciate any pointers on how to 
>improve it.

Add documentation to it. (Docstrings and some lines seperating blocks.)
Use the (standard) fileinput module.
You might take advantage of the range(function) to do the splitting.
	Something like for keyposition in range (0,len(trimline),4):

Bernhard


.import string
.screenfile = open('scracc.txt')
.newfile = open('scrnew.txt', "w")
.for line in screenfile.readlines():
.    mydict = {}
.    trimline = line[4:-1]
.    start = 0
.    length = len(trimline)
.    while start < length:
.	end = start + 4
.	startkey = start + 1
.	mydict[trimline[startkey:end]] = trimline[start:end]
.	start = end
.    sortkeys = mydict.keys()
.    sortkeys.sort()
.    mylist = []
.    for key in sortkeys:
.	mylist.append(mydict[key])
.    newline = line[0:4] + string.joinfields(mylist, "") + "\n"
.    newfile.write(newline)
.screenfile.close()
.newfile.close()

	
-- 
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 garry at sage.att.com  Wed Dec 15 10:53:58 1999
From: garry at sage.att.com (Garrett G. Hodgson)
Date: Wed, 15 Dec 1999 15:53:58 GMT
Subject: some random reflections of a "Python newbie": (1) books, and free 
 sites
References: <001d01bf42bd$4c9d69a0$60a2143f@tim>
Message-ID: <3857B996.A26BFC8A@sage.att.com>

Tim Peters wrote:
> 
> [Alex Martelli]
> > ...
> > 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)...?
> 
> Join the PSA (see http://www.python.org/) and you'll get a free account on
> the Starship.

does this also apply for folks who register for the 8th python
conference, which requires membership as part of the registration
process?  if so, how (and when) do i find out how to use this account?


-- 
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 sdyer7073 at my-deja.com  Mon Dec 20 17:28:15 1999
From: sdyer7073 at my-deja.com (Shawn Dyer)
Date: Mon, 20 Dec 1999 22:28:15 GMT
Subject: Redirecting stderror to a browser
References: 
Message-ID: <83mahr$jor$1@nnrp1.deja.com>

Try:

sys.stderr=sys.stdout

In article
,
  NULL at my.pc wrote:
> Newbie here, slowly consuming a large book but I need to know this
now...
>
> Using Python 4 CGI, I'd like to redirect the errors to the browser
window, so I
> get meaningfull errors rather than the typical "500 Internal server
error". I
> guess I could redirect it to a file, but seing immediately on the
browser would
> be much faster to work with. Cheers
>
>


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


From fredrik at pythonware.com  Wed Dec 15 04:53:16 1999
From: fredrik at pythonware.com (Fredrik Lundh)
Date: Wed, 15 Dec 1999 10:53:16 +0100
Subject: Python Imaging Library - Install Question
References: 
Message-ID: <007a01bf46e2$36d5aeb0$f29b12c2@secret.pythonware.com>

Colleen & Brian Smith :
> If I try to run some of the example code in the manual, I get the following
> stack trace:
> 
> >>> im=Image.open("C:\\Image Files\\b-29.jpg")
> >>> im.show()
> Traceback (innermost last):
>   File "", line 1, in ?
>   File "c:\Python\PIL\Image.py", line 694, in show
>     _showxv(self, title, command)
>   File "c:\Python\PIL\Image.py", line 974, in _showxv
>     file = self._dump(format=format)
>   File "c:\Python\PIL\Image.py", line 307, in _dump
>     self.load()
>   File "c:\Python\PIL\ImageFile.py", line 125, in load
>     self.load_prepare()
>   File "c:\Python\PIL\ImageFile.py", line 175, in load_prepare
>     self.im = Image.core.new(self.mode, self.size)
>   File "c:\Python\PIL\Image.py", line 40, in __getattr__
>     raise ImportError, "The _imaging C module is not installed"
> ImportError: The _imaging C module is not installed
> >>>
> 
> I've installed PIL (95/NT 1.52 compatible version) in C:\Python\PIL and the
> _imaging.dll is installed there, C:\Windows\System and in C:\Python\DLLs.
> I've set the same $PYTHONPATH in my autoexec.bat as in the registry.

what happens if you try to import the _imaging module
from the interpreter prompt:

    >>> import _imaging

> SET
> $PYTHONPATH="C:\Python\Lib\plat-win;C:\Python\Lib;C:\Python\DLLs;C:\Python\L
> ib\lib-tk;c:\Python\PIL"

hmm.  if you're using the standard command shell, I'm
pretty sure you shouldn't use $-signs and quotes in
there...






From fredrik at pythonware.com  Wed Dec  1 10:20:06 1999
From: fredrik at pythonware.com (Fredrik Lundh)
Date: Wed, 1 Dec 1999 16:20:06 +0100
Subject: GUI : Group Button
References: <823dac$e44$1@nnrp1.deja.com>
Message-ID: <016201bf3c0f$8cf9a450$f29b12c2@secret.pythonware.com>

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






From undo at concreteillusions.fi  Thu Dec 30 08:32:56 1999
From: undo at concreteillusions.fi (Joonas Rapila)
Date: Thu, 30 Dec 1999 13:32:56 GMT
Subject: Compiling python with threads
Message-ID: <386B5F2D.989A0C13@concreteillusions.fi>

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.



From timmuddletin at news.vex.net  Fri Dec 10 19:53:19 1999
From: timmuddletin at news.vex.net (tim muddletin)
Date: 11 Dec 1999 00:53:19 GMT
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> <14416.3969.90448.612046@anthem.cnri.reston.va.us>
Message-ID: <82s79v$1eii$2@news.tht.net>

Wow, neat little docstring hacks. (-: Thanks for the nifty tips
Barry/Skip/etcetc!



From ivanlan at callware.com  Wed Dec 15 22:20:47 1999
From: ivanlan at callware.com (Ivan Van Laningham)
Date: Wed, 15 Dec 1999 20:20:47 -0700
Subject: help with an error in Tkinter
References: <38567BDA.EC2F01D9@pivot.net>
Message-ID: <38585A8F.AE0016B0@callware.com>

Hi All--

Wayne wrote:
> 
> Hello,
> I'm reading the book(?) " An introduction to Tkinter" and in doing one

??  Who's the author?

> 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
> 

Here's a corrected version:

from Tkinter import *

class App:
     def __init__(self, master):
          self.var = IntVar()
	  # You need to close the parens.
          c = Checkbutton(master, text = "Enable Tab", variable
=self.var, command = self.cb)
          c.pack()
	  # You need to close the parens, and spell it "command", not "commnad"
          self.button = Button(master, text = "Quit", fg = "red",
command = master.quit)
          self.button.pack()
          # And here, the "command" callback doesn't get passed the
"event" parameter.
     def cb(self, event=0):
          print "variable is", self.var.get()

root = Tk()
app = App(root)
root.mainloop()


Proofread lots.
-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 greg.ewing at compaq.com  Mon Dec 13 05:35:43 1999
From: greg.ewing at compaq.com (Greg Ewing)
Date: Mon, 13 Dec 1999 23:35:43 +1300
Subject: Dot product?
References: <3852B91D.6EE31805@math.okstate.edu>
Message-ID: <3854CBFF.85A69AA@compaq.com>

"David C. Ullrich" wrote:
> 
> but it doesn't look right -
> seems like the Python way would involve a "for x in X"
> instead of that "for j in range(len(X))".

Sadly, that *is* the current Python idiom for doing parallel
iteration without incurring the overhead of constructing an
intermediate object.

List comprehensions won't change this, unless whatever flavour
of them we get includes a syntax for parallel iteration -- in
which case the normal "for" loop will probably get it as well.

My preferred backward-compatible candidate for this is:

   for x and y in list1, list2:
      ...

Greg


From bsb at winnegan.de  Thu Dec 16 11:16:42 1999
From: bsb at winnegan.de (Siggy Brentrup)
Date: 16 Dec 1999 17:16:42 +0100
Subject: DNS lookup
In-Reply-To: Michael Spalinski's message of "16 Dec 1999 09:54:32 -0500"
References: 
Message-ID: <87ln6u274l.fsf@baal.winnegan.de>

Michael Spalinski  writes:

> Is there a module which would let me do something like
> 
> nslookup('132.151.1.90')
> 
> and get the string 'parrot.python.org'?

Just happened to do this some minutes ago:

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 socket
>>> socket.gethostbyaddr('132.151.1.90')
('parrot.python.org', [], ['132.151.1.90'])
>>> host, aliases, ips = socket.gethostbyaddr('132.151.1.90')
>>> print host
parrot.python.org
>>> 

not-quite-Cato-ly-yoUr's
  Siggy
-- 
Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/
****** ceterum censeo javascriptum esse restrictam *******



From phd at phd.russ.ru  Tue Dec  7 09:59:20 1999
From: phd at phd.russ.ru (Oleg Broytmann)
Date: Tue, 7 Dec 1999 14:59:20 +0000 (GMT)
Subject: Converting a Shell Script to run under Python
In-Reply-To: 
Message-ID: 

On 7 Dec 1999, Magnus L. Hetland wrote:
> > 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.

from shutil import copy2
copy2("src", "dst")

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




From ngps at madcap.dyn.ml.org  Thu Dec 16 10:16:30 1999
From: ngps at madcap.dyn.ml.org (Ng Pheng Siong)
Date: 16 Dec 99 15:16:30 GMT
Subject: download web page with python
References: <83a3m4$diq$1@nnrp1.deja.com>
Message-ID: <3859024e.0@news.cyberway.com.sg>

According to  :
> I want to do this, but the web page (symantec's antivirus signature
> update page--http://www.symantec.com/avcenter/download.html) has a form
> to ask which product you want, then runs a CGI script, and gives you
> info back.

Something along these lines:

import urllib

url = "http://www.symantec.com/avcenter/cgi-bin/navsarc.cgi"
post_data = urllib.urlencode({"PROD":"N95", "LANG":"US"})
url_obj = urlopen(url, post_data)
print url_obj.readlines()


-- 
Ng Pheng Siong  * http://www.post1.com/home/ngps



From themantis at trojanslair.zzn.com  Fri Dec  3 00:47:18 1999
From: themantis at trojanslair.zzn.com (Black Mantis)
Date: Thu, 02 Dec 1999 21:47:18 -0800
Subject: python 3D graphics
Message-ID: <38475965.E80E77FB@trojanslair.zzn.com>

Hi

I am wondering if anybody has any useful information on programing in 3D
in python. i would appreciate it very much




From tim_one at email.msn.com  Fri Dec 10 03:48:53 1999
From: tim_one at email.msn.com (Tim Peters)
Date: Fri, 10 Dec 1999 03:48:53 -0500
Subject: FORTRAN (was Re: indentation)
In-Reply-To: <38503F7E.66E9D5BD@lanl.gov>
Message-ID: <000401bf42eb$63054220$412d153f@tim>

[Christian Tismer]
> I'm 43,

Heh heh -- what a puppy.  Wet behind the ears, I tell you!

> and I learned FORTRAN IV right after Algol 64 in the late 70s.
> Can't remember if it was this, or an earlier Fortran version which
> had no dynamic variables but just statics?

[William B. Clodius]
> 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.

No correction here!  That certainly matches my memories of implementing
Fortran.

In fact, in the mid 80's I was on an ANSI committee defining parallelism
extensions for Fortran, and one of the vendor representatives prevailed in
squashing anything that required so much as a *stack* (! quite a trick when
dealing with dynamic threads and thread-local COMMON and ...).

> 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 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 cite a reference at
> this time.)

My memory on this is fuzzy too.  In general, the Fortran stds never said
anything about capacities, though; e.g., I don't think the std supported a
claim that more than one integer had to be representable -- or that *all*
integers *couldn't* be.  Similarly I don't think a conforming processor was
*required* to accept anything "bigger" than CHARACTER*1.  Such things were
left to common sense and the "natural" capacities of the target platforms:
speed at any cost.  Right on; Fortran served its audience well.

Cray (at least at the time) invented a "hidden" argument for every formal
CHARACTER argument, in which was passed the actual capacity of the actual
argument.  So, in general, supporting CHARACTER*(*) didn't require any
dynamic allocation, regardless of string size.

Trickier were chains of CHARACTER concatenations.  IIRC, the std prohibited
catenations involving a CHARACTER*(*) dummy argument unless it formed the
right-hand side of a character assignment stmt.  In this way, no strings of
"unknown" length could be passed as arguments, and in an assigment stmt you
could generate code to stop catenating the RHS as soon as the capacity of
the LHS character vrbl was reached (which in turn was either of fixed
declared size, or of dummy argument *(*) size and so had its true capacity
"secretly" passed in).

> ...
> As a side point, dynamic languages can also be implemented statically
> with defined limits on depth of recursion or sizes of dynamic entities,
> it is just wasteful of computer memory and implementor's time to make
> that an implementation goal on current user systems (there have been
> user systems in the past that only allowed static allocation and of
> course micro-controllers usually require static allocation).

Stacks will triumph when the last people who fear them finally die off --
although heaps may require the sacrifice of the generation following .
While there was much to love in the Fortran line, the Fortran 77 CHARACTER
hack has got to be the feeblest string gimmick implemented at the greatest
cost & clumsiness of any such facility in any language.  All to save some
measly mallocs.

python-still-makes-me-feel-like-a-rebel-ly y'rs  - tim





From bhoel at server.python.net  Sat Dec 11 18:04:29 1999
From: bhoel at server.python.net (Berthold =?iso-8859-1?q?H=F6llmann?=)
Date: 12 Dec 1999 00:04:29 +0100
Subject: Dot product?
In-Reply-To: "David C. Ullrich"'s message of "Sat, 11 Dec 1999 14:50:37 -0600"
References: <3852B91D.6EE31805@math.okstate.edu>
Message-ID: 

"David C. Ullrich"  writes:

>     Ok, so I'm dense. How do I take the traditional "dot product"
> of two vectors? In a nice Pythonic sort of way, I mean. Say
> the vectors are represented as sequences of numerics - then
> of course I can say just
> 
> def Dot(X, Y):
>     res = 0
>     for j in range(len(X)):
>         res = res + X[j] * Y[j]
>     return res
> 
> and that gives the right answer, but it doesn't look right -
> seems like the Python way would involve a "for x in X"
> instead of that "for j in range(len(X))".
> 
>     For example if Transpose returns the transpose of a
> sequence of sequences (ie Transpose(s)[j][k] = s[k][j])
> I can say
> 
> def Dot(X, Y):
>     res = 0
>     for (x,y) in Transpose((X,Y)):
>         res = res + x * y
>     return res
> 

How about:

def Dot(X, Y):
    res = 0.
    for (x,y) in map(None, X, Y):
        res = res + x * y
    return res

> and that looks "right". For that matter once I have a
> Transpose I could just use reduce. But when I write
> a Transpose routine I have the same complaints with
> the way it looks, only more so.
> 
>     Is there a keen way to do this sort of thing, or do I
> just have to use the index as above? (Come to think
> of it I think what I really want is a nice Transpose -
> that's been coming up a lot, Dot is just one place.)
> 
Cheers

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



From khowe at performance-net.com  Tue Dec 21 15:02:11 1999
From: khowe at performance-net.com (Kevin Howe)
Date: Tue, 21 Dec 1999 16:02:11 -0400
Subject: Jpython woes, please help
Message-ID: 

I recently downloaded Sun's JDK122 and JPython11B4 and things work well
until I try to compile into Java .class or .jar files.

After compiling the HelloWorld.py demo script into a class using the
following:
    jpythonc --core HelloWorld.py

I get this error when run:
    java.lang.NoClassDefFoundError: org/python/core/PyObject

When I compile to a jar file like so:
    jpythonc --core --jar HelloWorld.jar HelloWorld.py

All is well until it starts "Tracking Java Dependencies", where it produces:
    Atribute Error: java package 'org.python.modules' has no attibute
'__path__'

Can anyone enlighten me as to what's happenning here?

Much Thanks,
kh




From Jerome.Kalifa at polytechnique.fr  Thu Dec  2 15:55:10 1999
From: Jerome.Kalifa at polytechnique.fr (Jerome Kalifa)
Date: 02 Dec 1999 15:55:10 -0500
Subject: A Date With Tim Peters...
References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street>  <38465dde@news.uni-bielefeld.de>
Message-ID: 

delgado at pinax.Mathematik.Uni-Bielefeld.DE (Olaf Delgado) writes:
>
> Unfortunately then, our calender must be written in FORTRAN.

It was the only language available by this time (actually, there was
Cobol too, but some great visionners anticipated that our era may last
more than 99 years).
-- 
Jerome Kalifa
Center for Biomedical Engineering, MC 8904, Schapiro
Columbia University, New York,  NY 10027



From maxm at normik.dk  Mon Dec 20 10:37:57 1999
From: maxm at normik.dk (maxm)
Date: Mon, 20 Dec 1999 16:37:57 +0100
Subject: Equivalent to (a ? b : c) ?
References: <83lgkq$2q$1@nnrp1.deja.com>
Message-ID: <011601bf4b00$3183aee0$110010ac@normik.dk>

From: 
Subject: Equivalent to (a ? b : c) ?


> 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?


>From my own personal Python cookbook here is:

######################################################################
## Why aren't there any unary type expression like "(Test)?trueVal:falseVal"
in Python?

Thanks to Python's dynamic typing you can easily add the C "?:" expression
to the language by defining a single function that will work with all types:

---

def ifexp(cond, trueVal, falseVal):
   if cond:
      return trueVal
   else:
      return falseVal

print "You scored %s point%s" % (score, ifexp(score == 1, "", "s"))

---

Note that you'd have to define a whole set of these functions in a
statically typed language, one for each type of the Vals.

Answer by: James Logajan 
######################################################################


Kind regards

    Max M


------------------------------------------------------------------------
Max M Rasmussen,   New Media Director    http://www.normik.dk   Denmark
e-mail                                   mailto:maxm at normik.dk






From djc at itga.com.au  Tue Dec 14 19:38:52 1999
From: djc at itga.com.au (Dave Cole)
Date: 15 Dec 1999 11:38:52 +1100
Subject: Bug in Python 1.5.2 exception handling?
Message-ID: <87hfhlujfn.fsf@heresy.itga.com.au>

It looks like function locals are not deleted if that function is
terminated by an exception.  They seem to hang around until they are
unref'ed when the function is next called.

Consider the following program:

- bogus.py - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
class c:
    def __init__(self, val):
        self.val = val
    def __del__(self):
        print val, 'deleted'

def check_return(val):
    print 'return:',
    o = c(val)

def check_raise(val):
    print 'raise:',
    o = c(val)
    raise ValueError

for val in range(3):
    check_return(val)
for val in range(3):
    try:
        check_raise(val)
    except:
        pass
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

This is what I get when I run it:

heresy:~% python bogus.py 
return: 0 deleted
return: 1 deleted
return: 2 deleted
raise: raise: 1 deleted
raise: 2 deleted
2 deleted
heresy:~% 

- Dave


From gerrit.holl at pobox.com  Fri Dec  3 07:20:17 1999
From: gerrit.holl at pobox.com (Gerrit Holl)
Date: Fri, 3 Dec 1999 13:20:17 +0100
Subject: split this newsgroup?
In-Reply-To: <026401bf3d79$12002600$f29b12c2@secret.pythonware.com>; from fredrik@pythonware.com on Fri, Dec 03, 1999 at 11:27:57AM +0100
References:  <026401bf3d79$12002600$f29b12c2@secret.pythonware.com>
Message-ID: <19991203132017.A2483@stopcontact.palga.uucp>

Fredrik Lundh wrote:
> Max M. Stalnaker  wrote:
> > The volume on this newgroup might justify splitting
> > the newgroup.  Comments?
> 
> what subgroups did you have in mind?

I think only tutor at python.org should become a newsgroup, with a FAQ
regularly posted (once or twice a week). If this newsgroup grows, we
might make a newsgroup c.l.py.graphics, for GUI, 3d, plotting, gif,
jpeg, png, etc.


let's-make-a-newsgroup-called-c.l.py.how-do-I-send-an-email-with-subject,
regards,
Gerrit.
-- 
"The world is beating a path to our door"

  -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates)
  1:17pm  up 51 min, 14 users,  load average: 0.00, 0.00, 0.00



From bernhard at alpha1.csd.uwm.edu  Sun Dec 26 17:08:42 1999
From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter)
Date: 26 Dec 1999 22:08:42 GMT
Subject: SPSS support unfriendly
Message-ID: 

This is the christmas rant about SPSS, Inc. and its support department.
They would not help me, though there is a bug in SPSS for Windows v9.0.1.
because I used python to script it.

I thought I just let you know. :)
On the other hand I have good experience with Mark Hammond's support 
for the win32 extensions. He also confirmed that SPSS' COM server just throws
the towel there, without giving the client more to work with.

Here is part of my communications with them (some personal stuff blacked out):

. From: WWW Support                    
. To: "'Bernhard Reiter'"                                    
. Subject: RE: Spss Base v9.0.1 crashes (Win32,Scripting)                       
. Date: Wed, 15 Dec 1999 09:30:13 -0600                                       

. I have little to suggest.  We never tested SPSS for Windows
. using Python script, and so can make no guarantees that
. it will run properly in that environment.

. -----Original Message-----
. From: Bernhard Reiter [mailto:bernhard at uwm.edu]
. Sent: Tuesday, December 14, 1999 3:26 PM
. To: support at spss.com
. Subject: Spss Base v9.0.1 crashes (Win32,Scripting)

. using:
. 	Spss for Windows 9.0.1 (24 Feb 1999)
. 	Standard Version
. 
. 	Registered for:

. I encounter frequent crashes scripting Spss.
. The crashes are random in appearance and nature. 
. Sometimes it just works.
. 
. Task: I am scripting SPSS using python via python's win32com extensions
. just like any other COM scripting language.
. 
. I run multiple linear regressions and "consume" the resulting
. output into a textfile I write. The objects in the output view are
. deleted after each regression result is read.
. 
. This usually works fine for 10 up to 20 regressions before SPSS crashes.
. 
. Sometimes the COM server just throws an DISP_E_EXCEPTION exception
. without further error information and stopps. This happens when I
. apply Deactivate() on an activated SPSSPivot or SPSSNotes outputItem
. object.
. 
. Sometimes Spss just crashes without any error message.
. 
. Sometimes is generates an application error. I have attached some
. Dr.Watson debug dumps for you to check.
. 
. And like I said, it even works fine sometimes. This is unrelated to
. restarts or cold boots. But once it didn't work, it is unlikely to 
. work later in the same session.
. 
. The error also occurs on other computers and IIRC also with SPSS 8.0
. which we were running for a short time. The script AFAIK also worked on
. SPSS 7.x.
. 
. If it helped I could also send the python program or other information
. you need to you.
. 
. Regards,
. 	Bernhard Reiter

I received no answer on my followup to them, explaining again, why the error
is not on the python site.
	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 skip at mojam.com  Mon Dec 27 23:12:25 1999
From: skip at mojam.com (Skip Montanaro)
Date: Mon, 27 Dec 1999 22:12:25 -0600 (CST)
Subject: Super Tuples
In-Reply-To: <14439.35987.402193.17280@anthem.cnri.reston.va.us>
References: <386745A6.9B671DBF@prescod.net>
	<14439.35987.402193.17280@anthem.cnri.reston.va.us>
Message-ID: <14440.14505.603625.329128@dolphin.mojam.com>


    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

Hmm.  Attributes, but no methods?  Why doesn't the current class notion
solve the problem?  In fact, I'm not sure what the problem you're trying to
solve is.

What's the result of

    time = (hour=24, minute=00, second=00)
    point = (x=1, y=2, z=3)

    time = point

?  Is there some type-checking going on, or does time lose its
hour/minute/second attributes or just add x/y/z attributes?

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 ava at dde974.equipement.gouv.fr  Wed Dec 22 08:15:26 1999
From: ava at dde974.equipement.gouv.fr (Ava)
Date: Wed, 22 Dec 1999 17:15:26 +0400
Subject: how to use win32wnet.WNetAddConnection2 ?
Message-ID: 

The first message contains an error, here is the correct one:
my apologies for the inconvenience

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:', '\\\\server\share$', '', 'user',
'pass')
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 ivnowa at hvision.nl  Sat Dec  4 09:18:35 1999
From: ivnowa at hvision.nl (Hans Nowak)
Date: Sat, 4 Dec 1999 15:18:35 +0100
Subject: Python complaints
In-Reply-To: <3848A872.C704AB73@Lugoj.Com>
Message-ID: <199912041417.PAA26787@axil.hvision.nl>

On 3 Dec 99, James Logajan wrote:

> Nice and efficient so long as all you do is increment yourself along the X
> axis. But suppose you are using Python to maintain a count of the
> population of the planet Earth and want to use a sensible variable name
> (for porting purposes of course, in case you need to us e the same code on
> the planet Mars and want to remember which variable had the population
> count in it so you can change it to the right name). You'd have code that
> would look like:
> 
> populationOfthePlanetEarth = populationOfThePlanetEarth + 1
> 
> versus:
> 
> populationOfThePlanetEarth++
> 
> And if you weren't careful, you might make a hidden typo (like I did in
> the first example), thereby causing a cessation of population growth which
> would seriously impact economic growth and cause untold hardship.
> Therefore in the interest of the world economy it is essential that the
> next version of Python support the increment operator.

Aw, c'mon, everybody knows that such an important program would be 
written in Perl... ;-)

--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 fdrake at acm.org  Thu Dec 23 14:19:46 1999
From: fdrake at acm.org (Fred L. Drake, Jr.)
Date: Thu, 23 Dec 1999 14:19:46 -0500 (EST)
Subject: Patch: httplib.py default timeout
In-Reply-To: <83trp0$ubi$1@nntp8.atl.mindspring.net>
References: <83r0lh$mj6$1@nntp6.atl.mindspring.net>
	
	<83trp0$ubi$1@nntp8.atl.mindspring.net>
Message-ID: <14434.30162.38117.637290@weyr.cnri.reston.va.us>

Aahz Maruch writes:
 > 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

  Why would httplib be the common case?  I'd think most casual users
would normally want urllib, especially since it also handles proxy
support.


  -Fred

--
Fred L. Drake, Jr.	  
Corporation for National Research Initiatives



From Gareth.McCaughan at pobox.com  Tue Dec 21 19:15:15 1999
From: Gareth.McCaughan at pobox.com (Gareth McCaughan)
Date: 22 Dec 1999 00:15:15 +0000
Subject: Equivalent to (a ? b : c) ?
References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it>
	<83lnq7$c9d$1@news1.tele.dk> 
	
Message-ID: <86puvz6dbg.fsf@g.local>

Rob Hodges wrote:

[someone else:]
>>>> ((a and (b,)) or (c,))[0]
> Someone mentioned that this is idiomatic Python, but actually it is
> idiomatic lisp.

Eh?

Certainly (if a b c) is idiomatic Lisp with the same meaning,
but the particular hack involved certainly isn't. You *could*
say something like
  (car (or (and a (list b)) (list c)))
but that would be horribly unidiomatic Lisp. I'm not sure
what the point is here.

-- 
Gareth McCaughan  Gareth.McCaughan at pobox.com
sig under construction


From python-list at teleo.net  Thu Dec 16 14:29:27 1999
From: python-list at teleo.net (Patrick Phalen)
Date: Thu, 16 Dec 1999 11:29:27 -0800
Subject: RFC: Implementing ECS in Python
In-Reply-To: <14425.4385.984935.767038@cmpu.net>
References: <14425.4385.984935.767038@cmpu.net>
Message-ID: <99121611340100.01681@quadra.teleo.net>

[Kendall Clark, on Thu, 16 Dec 1999]

:: I'm planning a free software implementation of Apache's ECS (Element
:: Construction Set) in Python. You can find ECS at
:: 
::      
:: 
:: With ECS you can programmatically build XML, HTML4 and RTF structured
:: documents in an OOP way.

Wonderful idea.

You might want to give this a glance for synergy potential:
http://www.xml.com/pub/1999/12/zope/



From hweaver at pinetel.com  Wed Dec 15 14:26:47 1999
From: hweaver at pinetel.com (Harold Weaver)
Date: Wed, 15 Dec 1999 11:26:47 -0800
Subject: Idle install - no module time
Message-ID: <3857EB77.BA02A2CF@pinetel.com>

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

...
<

So, what gives?  (This should be easy to figure out)

Thanks.

-- Hal



From worldwin at liii.com  Fri Dec 17 00:22:28 1999
From: worldwin at liii.com (dj trombley)
Date: Fri, 17 Dec 1999 05:22:28 GMT
Subject: Tkinter+python threads problem while mutilating IDLE...
Message-ID: <3859C813.F4C47C8B@liii.com>

Hello, Greg here...

First of all, the question I'm posing is: Why does the attached code
crash and is there any way to work around the problem? 

Now, a little explanation... The code is a hack which is supposed to
cause IDLE, when IDLE is started with a filename on the commandline, to
check for an instance of IDLE and have the file loaded in the currently
running instance. It doesn't modify any existing IDLE source files -
it's a replacement for idle.py It's not clever... 

The problem is that when the 'server' receives the command line from the
new, 'client', IDLE instance, it tries to open the requested files and
locks up. We think that the problem is with python threading and have
run out of ideas. Can anybody offer any clues?

Greg Velichansky, Dave Trombley
-------------- next part --------------
#! /usr/bin/env python
import PyShell
from socket import *
from select import *
from thread import *
from cPickle import *
import sys
import traceback

class AmIHere:
    def __init__(self):
        try:
            self.sock = socket(AF_INET, SOCK_STREAM)
            self.addr = gethostbyaddr("localhost")
            try:
                self.sock.connect((self.addr[2][0], 7781))
            	self.prevInst = 1
            except:
                traceback.print_exc()
                self.prevInst = 0
                try:
                    self.sock.shutdown(2)
                except:
                    pass
                self.sock = socket(AF_INET, SOCK_STREAM)
                	            
            if not self.prevInst:
                self.sock.bind((self.addr[2][0], 7781))
                self.sock.listen(3)
                start_new_thread(self.server, ())
                PyShell.main()
                return
            else:
                try:
                    cmdstr = dumps(sys.argv)
                    self.sock.send(cmdstr)
                except:
                    PyShell.main()
                    return
                return
        except:
            traceback.print_exc()
            PyShell.main()
            return
            
    def server(self):
        try:
            while(1):
                print(str(select([self.sock],[],[])))
                con = self.sock.accept()
                cmdstr = con[0].recv(4096)
                filelist = loads(cmdstr)
                print str(filelist)
                for i in filelist[1:]:  
                    PyShell.flist.open(i)
                    aPath = os.path.abspath(os.path.dirname(i))
                    if not aPath in sys.path:
                        sys.path.insert(0, aPath)
                else:
                    aPath = os.getcwd()
                    if not aPath in sys.path:
                        sys.path.insert(0, aPath)
 	except:
 		# Note:  Remove this.  It breaks.
 		traceback.print_exc()       
            
        
AmIHere()

From mfletch at vrtelecom.com  Fri Dec  3 06:40:54 1999
From: mfletch at vrtelecom.com (Mike C. Fletcher)
Date: Fri, 03 Dec 1999 11:40:54 GMT
Subject: python 3D graphics
References: <38475965.E80E77FB@trojanslair.zzn.com> <8283dr$sg6$1@mach.vub.ac.be>
Message-ID: 

Quick answer:
    wxPython does have a 3D Canvas, but it's currently almost entirely
un-documented, they have a demo (as does Pythonwin, for that matter).  The
basic idea is, once you have the Canvas, you can quite easily use any OpenGL
calls you want through PyOpenGL, so no-one seems interested in doing any
more work on it (that I've seen).  Numeric module has some support for
vector operations.  I've yet to get array-data updates to work, but I
haven't really tried that hard. Still, you have plenty of low-level access
to OpenGL graphics (note Alice in the list below uses Direct3D, not OpenGL).

Likely what you want:
    Alice -- Direct3D-based rendering, targetted at kids and neophytes, has
a web plug-in as well.
    http://crystal.linuxgames.com -- Python scripting in an LGPL game engine
    http://www.kitware.com/vtk.html has the visualisation toolkit with
Python bindings
    JPython has access to all of the Java 3D apis including Magician and
Java3D

Other stuff:
    Python can run the Cortona VRML control's automation interface without
problem on Win32 (gives a full VRML environment with high-level access to a
fairly decent and extensible sceneGraph engine).  I've used this in a small
in-house project.
    The Quark Army Knife (scripting environment with 3D display).  The 3D
stuff was pretty distant from the Python stuff, but I haven't looked at it
in ages.
    http://www.onthenet.com.au/~briblack/pyrpg/ Role-playing engine (early)
with 3D rendering of a maze (haven't used)
    Blender (another editing environment, out in release, with commerical
and "oldware" versions). (haven't used)
    MagicLight (an editing environment still in alpha of a second iteration
far as I know). http://home.bip.net/mikael_aronsson/
    TrueSpace 4.0 includes Python as a scripting language (haven't used)
    The people working on GEL have expressed interest in Python during
discussions on the CCon's biota list (don't think it's going to do much, but
you never know :) ).
    Renderman systems    http://reality.sgi.com/newquist_engr/snakeman/
http://www.lysator.liu.se/~ture/terry.html

That's about all off the top of my head (and a quick search of Dejanews
;) ).  Enjoy,
Mike





From da at ski.org  Wed Dec  1 19:05:48 1999
From: da at ski.org (David Ascher)
Date: Wed, 1 Dec 1999 16:05:48 -0800 (Pacific Standard Time)
Subject: __getslice__ incorrectness
In-Reply-To: <02121999.1@sanctum.jae>
Message-ID: 

On Thu, 2 Dec 1999, Juergen A. Erhard wrote:

[Complains that __getslice__ with missing indices is broken]

> Will this be fixed (it's a lot better the way it's documented than the
> way it's implemented ;-)

The best way to get it fixed is to submit a patch =).

IMO, you're right, it's not doing the right thing. The behavior you're
seeing comes from Objects/abstract.c's PySequence_GetSlice, which does:

		if (i1 < 0 || i2 < 0) {
			if (m->sq_length) {
				int l = (*m->sq_length)(s);
				if (l < 0)
					return NULL;
				if (i1 < 0)
					i1 += l;
				if (i2 < 0)
					i2 += l;
			}
		}

(where i1 and i2 are the two indices, which are -1 if unspecified)

This allows the getslice behavior to do the right thing for sequences of
all kinds as long as 'the right thing' is what Python builtin sequences do
(-1 means ones from the end of the length, etc.), without having to burden
the implementation of lists, tuples, and strings with this special-case.

I would suggest that the if() block should be special-classed, and not
operate if the object m is an instance.

In other words, something like:

<		if (i1 < 0 || i2 < 0) {
>               if (!PyInstance_Check(s) && (i1 < 0 || i2 > 0)) {

(untested)

As to whether this would break existing code, who knows...

--david

See http://www.python.org/1.5/patch.html for patch submission guidelines.






From alex at kawo2.rwth-aachen.de  Wed Dec  1 21:37:45 1999
From: alex at kawo2.rwth-aachen.de (Alex Farber)
Date: Thu, 02 Dec 1999 03:37:45 +0100
Subject: russian e-zine seeks a python co-editor
Message-ID: <3845DB79.531EAAE7@kawo2.rwth-aachen.de>

If you don't speak Russian, please skip this posting.

Do you regularly read comp.lang.python? Do you like the idea 
of a non-commercial Russian-language e-zine for developers? 
The "Pref News" e-zine, located at  http://simplex.ru/news/ 
is dedicated to Perl, UNIX and database programming. Currently
maintained by two people it provides links to articles and
tutorials, interesting code snippets found in newsgroups.

We are looking for some Python enthusiast, who would post 
interesting links and maybe digests from this newsgroup.

It won't take you much time - already 20 minutes a week
would be a helpful contribution. Please contact me.

Best regards
Alex



From skip at mojam.com  Thu Dec 16 09:54:05 1999
From: skip at mojam.com (Skip Montanaro)
Date: Thu, 16 Dec 1999 08:54:05 -0600 (CST)
Subject: gif
In-Reply-To: <19991216143520.48542.qmail@hotmail.com>
References: <19991216143520.48542.qmail@hotmail.com>
Message-ID: <14424.64781.570890.600550@dolphin.mojam.com>

    Ulf> How do I open up an image in either .gif or .jpeg and save it to a
    Ulf> textfile in base64? I know about the base64 mod, but it seems like
    Ulf> I can't read the .gifs and .jpegs right. What should I do about
    Ulf> this?

If you're on Windows, make sure you open the image file using the binary
flag:

    gif = open(gifname, "rb")
    b64 = open(b64name, "wb")	# "b" shouldn't be needed here
    base64.encode(gif, b64)
    gif.close()
    b64.close()

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 skip at mojam.com  Thu Dec  9 11:24:48 1999
From: skip at mojam.com (Skip Montanaro)
Date: Thu, 9 Dec 1999 10:24:48 -0600 (CST)
Subject: How to add element to the list in C extension module?
In-Reply-To: 
References: 
	
	
	
Message-ID: <14415.55248.815848.60254@dolphin.mojam.com>

    Wojciech> Sorry for replaying my own post, but I've just found the
    Wojciech> solution.  PyList_Append did the trick for lists. For tuples
    Wojciech> it seems to be necessary to use _PyTuple_Resize and
    Wojciech> PyTuple_SetItem, which is probably much less efficient

Be careful, there pardner...  There is only one condition where it is safe
to resize a tuple.  The leading underscore indicates that _PyTuple_Resize is
not an external API function.  If your code is the only one holding a
reference to it (it has a reference count of 1), then it is safe to resize
the tuple.  Tuples are supposed to be immutable, so you will run into
problems if you resize it while it's referenced from somewhere else.

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 doughellmann at home.com  Wed Dec  8 07:19:25 1999
From: doughellmann at home.com (Doug Hellmann)
Date: Wed, 08 Dec 1999 12:19:25 GMT
Subject: Mutli-Column Listboxes in Tkinter?
References: 
Message-ID: <384E4E2C.F655FFB1@home.com>

You could download my PmwContribD package at
http://members.home.net/doughellmann/PmwContribD.  Even though the docs
don't mention it yet, the package includes a multi-columned listbox in
MCScrolledListBox.py.  You can define as many columns as you want when
you create the widget.  When you set the "list," you send a sequence of
sequences to fill in the values.  Selection of a row sets the value of
the listbox to the tuple containing the values from each column. 
Selecting multiple rows sets the value to the sequence of tuples.

Let me know if you have any problems/questions with this.

Doug

Scott Barron wrote:
> 
> 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 hiro at dagram.tdh.qntm.com  Mon Dec 20 14:09:43 1999
From: hiro at dagram.tdh.qntm.com (Hirofumi Furusawa)
Date: 20 Dec 1999 19:09:43 GMT
Subject: Why can pyhton deal with a big project?
Message-ID: <83lutn$sfn$1@news3.dti.ne.jp>

I started to learn about perl and am said, "Perl is bad for a certain size of
project. It's global variables causes problem." O.K. I see, then I seek
another programming language and am interested in python.

Books say "Python can deal with a big project." But they don't say why python
can.

Python is a script language like perl and need not to declare variable types,
so I cannot understand why python.

I want to know more about python. please tell me a good documantation about my
question or something...

thank you

-- 
    _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
   _/           Hirofumi Furusawa              _/
  _/      Home - fsawa at remus.dti.ne.jp        _/
 _/  School - y8a1198 at students.chiba-u.ac.jp _/
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


From alex at magenta.com  Thu Dec  9 17:12:34 1999
From: alex at magenta.com (Alex Martelli)
Date: Thu, 9 Dec 1999 23:12:34 +0100
Subject: Where can I find info on IDispatchEx()
References: <1267780385-12582932@hypernet.com>       <82m49p$fa5$1@nnrp1.deja.com>
Message-ID: <82pc6o$9oj$1@nslave2.tin.it>

 wrote in message 82m49p$fa5$1 at 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.

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.

Actually, what appear as properties are variables, as in
the example you quote:

> objPerl.EvalScript '$greet = 'Hello, world.\n';"

See?  "$greet" is a _variable_...

> 'Display greeting in a message box. *** It is used like a property! ***

Yep, because it's a variable in the script.



Alex





From ionel at psy.uva.nl  Sat Dec  4 09:11:16 1999
From: ionel at psy.uva.nl (Ionel Simionescu)
Date: Sat, 4 Dec 1999 15:11:16 +0100
Subject: map versus the 'for' loop
Message-ID: <82b7gn$qut@mail.psy.uva.nl>

Hi,


In some situations, the use of map() can speed up things, which would
normally be done in a loop.

--- e.g.

# 
y = map(func, x)

# vs.

# 
y = [None]* len(x)
for k in range(x): y[k] = func(x[k])

---

I hereby ask those with knowledge about the interpreter's internals what the
trade-offs/cavets are.

The speed gain brought by map() might have a cost (e.g. space) that I'm not
aware of, and which could bite in certain situations.


Thank you,
ionel





From greybria at direct.ca  Sat Dec 25 22:48:46 1999
From: greybria at direct.ca (Colleen & Brian Smith)
Date: Sat, 25 Dec 1999 19:48:46 -0800
Subject: Newbie Tkinter Problem
Message-ID: 

In the script below, when I hard-code the file name, the button works fine.
However, when I use the askopenfilename dialog, something is preventing the
button from working normally. If somebody could
point out where I'm going wrong, I'd sure appreciate it.

--------------------------------------
from Tkinter import *
import Image, ImageTk
from viewer import UI
from tkFileDialog import *

class Application(Frame):

    def createWidgets(self):
  self.QUIT = Button(self)
  self.QUIT["text"] = "QUIT"
  self.QUIT["fg"]   = "red"
  self.QUIT["command"] =  self.quit
  self.QUIT.pack(side=LEFT)

    def LoadPic(self):
  self.picname=askopenfilename(filetypes=[("JPEG", "*.jpg")])
  self.pic = Image.open(self.picname)
  self.pic.thumbnail((128, 128))
  self.display = UI(self,self.pic)
  self.display.pack(side=RIGHT)

    def __init__(self, master=None):
  Frame.__init__(self, master)
  self.pack()
  self.createWidgets()
  self.LoadPic()
  self.pack()

app = Application()
app.mainloop()

--
Colleen & Brian Smith
greybria at direct.ca
http://mypage.direct.ca/g/greybria




From bitbucket at isomedia.com  Tue Dec 28 16:30:08 1999
From: bitbucket at isomedia.com (Eugene Goodrich)
Date: Tue, 28 Dec 1999 21:30:08 GMT
Subject: newbie question...
References: <3869229B.C06B94E5@earthlink.net>
Message-ID: <3869298b.8634305@news.isomedia.com>

The example Justin Sheehy gave is certainly better most of the time,
but if you feel you _must_ do it like that Perl code (say, you've got
a 100 MB file you don't feel like putting into memory all at once),
you can do this:

	oFile = open ('delme.txt', 'r')
	sStr = oFile.readline()
	while (sStr):
		# do something with sStr
		sStr = oFile.readline ()
	oFile.close()

Someone please correct me if this does not have the reduced memory
requirements for large files that I believe it does.

-Eugene

On Tue, 28 Dec 1999 15:50:35 -0500, Alexander Sendzimir
 wrote:

>As a developer new to the Python language and experienced with the Perl language
>(and quite a few others ;-), I'm wondering what the accepted method of handling
>a text file's contents are in Python. For example, the following Perl construct
>is pretty standard.
>
>    while (  )
>    {
>        # process each line as if comes off the file handle...
>    }
>
>is typical.
>
>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
>    # using some prefered method (there's more than
>    # one way of doing this, of course ;-)
>
>THE BIG QUESTION: Am I understanding Python's philosophy properly?
>
>Thanks,
>
>abs
>
>
>

import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==')


From JamesL at Lugoj.Com  Fri Dec 17 23:35:17 1999
From: JamesL at Lugoj.Com (James Logajan)
Date: Fri, 17 Dec 1999 20:35:17 -0800
Subject: circular references?
References: 
Message-ID: <385B0F05.E2D073D4@Lugoj.Com>

Roy Smith wrote:
> 
> Let's say I've got:
> 
> class a:
>    pass
> 
> class b:
>    def __init__ (self, x):
>       self.x = x
> 
> and then I do:
> 
> foo = a()
> foo.b = b(foo)
> 
> I've now got two objects that contain references to each other.  Is this
> bad?

No. There are many good reasons for using circular references and even more
complex graphs. Use them when it is needed; just remember to clean them up
afterword. Otherwise you may "leak" memory. Proponents of "true" garbage
collection (GC) would point out that Python's reference counting can not
reclaim foo's memory after foo goes out of scope of the execution frame. The
programmer must explicitly set foo.b or foo.b.x to None (or some other
benign value) or "del foo.b" before foo goes out of scope to avoid a leak.
If you are designing your data structures for use in algorithms you
understand, this should not be particularly burdensome. If you find it
burdensome for any reason, then Java or another language with "true" GC may
be the thing to look into.


From rob at hooft.net  Thu Dec  2 03:50:57 1999
From: rob at hooft.net (Rob W. W. Hooft)
Date: 02 Dec 1999 09:50:57 +0100
Subject: Displaying an array as an image
References: 
Message-ID: 

>>>>> "DF" == David Fenyes  writes:

 DF> Hello, Is there an easy way to display a 2D array as an image
 DF> using just Tkinter?  I'm aware of a TK Image canvas widget, but
 DF> can't find docs on how to use it or what an 'image' is supposed
 DF> to consist of.  I'm just evaluating numerical python as a
 DF> platform and this is a pretty important functionality that is not
 DF> really addressed in any of the readily available docs.

I have written a program (part of a proprietary program suite) that
does this using PIL/Tkinter for data visualization.  An additional
problem with my type of data is that it has more than 8 significant
bits. If you have similar data, you could have a look at the example
code I put on my starship webpage:

  http://starship.python.net/crew/hooft/

Regards,

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



From gmcm at hypernet.com  Fri Dec 17 11:19:17 1999
From: gmcm at hypernet.com (Gordon McMillan)
Date: Fri, 17 Dec 1999 11:19:17 -0500
Subject: python constructor overloading
In-Reply-To: <385A5C98.1BEB9873@EarthLink.Net>
Message-ID: <1266675828-4948460@hypernet.com>

Greg Copeland wrote:

> Darrell wrote:
> > 
> > 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.
> 
> In this particular case, I wouldn't expect this to happen.  Since
> the container should technically live longer than the contained. 
> In short, if the container is gone, everything within it should
> also be gone.  No memory leaked.

Bzzt. The container is unavailable, but unless you specifically 
clear it, it will still exist, because it's ref count hasn't gone to 
zero because there are objects (which happen to be inside it) 
which still reference it.

[subclassing]
 
> Obviously, I want to keep all of the existing engine's
> functionality, but simply extend it with the turbo's boost
> methods.  As I understand it, you can't do this?!?!?  If I
> understand you correctly, I have to re-implement engine's
> constructor and extend it in the turboEngine's constructor.

You have to call the base class's __init__ explicitly. __init__ 
isn't actually a "constructor", it is an "initializer". In other 
words, "self" is the real, final thing when __init__ runs; you 
just get to set up it's state, not influence it's construction.

There's nothing automatic about __init__, which is why mixins 
are easy and useful in Python (but rarely so elsewhere).

>  If
> that's the case, I greatly condom the OO-implementation of
> python.  

Now that's a Freudian slip if I've ever seen one.

> So it isn't so.  If this is that case, I'd say the
> python authors have been using MFC way too much!  :P~

I can assure you that Python's principle author wouldn't 
recognize MFC if it stole all his condoms.
 


- Gordon



From jam at quark.emich.edu  Wed Dec 15 08:13:04 1999
From: jam at quark.emich.edu (Jeff)
Date: Wed, 15 Dec 1999 08:13:04 -0500
Subject: smtp and the From header field
In-Reply-To: <837uk2$2jp$1@snipp.uninett.no>
References: <837uk2$2jp$1@snipp.uninett.no>
Message-ID: <19991215081304.C26450@quark.emich.edu>

On Wed, Dec 15, 1999 at 12:39:09PM +0100, Asle Pedersen wrote:
> While testing the smtp library I have not been able to figure out how to use
> the different formats of the FROM header. It is usuall to place in addition
> to the email-address also the name of the person holding the address in the
> FROM field. Do anyone have experience in using the SMPT libray to place such
> information in the From field?
> Investigating the library it seems that it checks the from field for
> conformity with RFC822 but I don't think there is anything wrong
> syntactically in the data I'm placing there.
> 
> Asle Pedersen
> 

remember that SMTP is only the *transport* for the message, and what you are
transporting is an RFC822-type message (for which there is also a module, I
believe).. I would suggest checking dejanews for more information.

regards,
J
-- 
|| visit gfd 
|| psa member --  
|| New Image Systems & Services, Inc. 



From jam at quark.emich.edu  Mon Dec 20 14:28:20 1999
From: jam at quark.emich.edu (Jeff)
Date: Mon, 20 Dec 1999 14:28:20 -0500
Subject: Why can pyhton deal with a big project?
In-Reply-To: <83lutn$sfn$1@news3.dti.ne.jp>; from hiro@dagram.tdh.qntm.com on Mon, Dec 20, 1999 at 07:09:43PM +0000
References: <83lutn$sfn$1@news3.dti.ne.jp>
Message-ID: <19991220142820.A25651@quark.emich.edu>

On Mon, Dec 20, 1999 at 07:09:43PM +0000, Hirofumi Furusawa wrote:
> 
[..snipped..]
> I want to know more about python. please tell me a good documantation about my
> question or something...
> 
> thank you
> 

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.

regards,
J
-- 
|| visit gfd 
|| psa member --  
|| New Image Systems & Services, Inc. 



From apederse at siving.hia.no  Thu Dec 30 03:30:19 1999
From: apederse at siving.hia.no (Asle Pedersen)
Date: Thu, 30 Dec 1999 09:30:19 +0100
Subject: complex FETCH using IMAPLIB
Message-ID: <84f55u$95e$1@snipp.uninett.no>

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')

-Asle Pedersen




From michelorengo at netscape.com  Wed Dec 15 15:15:03 1999
From: michelorengo at netscape.com (Michel Orengo)
Date: Wed, 15 Dec 1999 20:15:03 GMT
Subject: C++ (was RE: Python suitability)
References: <1266856018-8846450@hypernet.com>
Message-ID: <3857F6CB.24ACF345@netscape.com>


Gordon McMillan wrote:

> If C++ (or Java) gave you those tools, there would be no
> "need" for UML. UML "works" (for some definition of "works"
> ) because it hides language complexity. It also lacks
> expressiveness.
>
> Look at "Design Patterns". Most of those patterns are directly
> expressible in Python. So much so, that if you translate the
> UML into Python and use that, the result will be needlessly
> complex and stilted. What the UML actually expresses is how
> to get around language barriers.
>
> There are useful diagrams in UML, (eg, the state and
> transition diagrams). Unfortunately, the one most tools use to
> generate code (and draw from reverse engineering) has
> everything to do with language structure, and nothing to do
> with what actually happens at runtime. To put it bluntly:
> people spend most of their time designing the wrong thing.
>

I tend to agree that there is no much sense in designing forever an
application and at one point it's better to start coding.
However, we should draw a line between desing and business analysis. I
use UML to formalize the business rules.
Some people think that their business analysis is their design. That's
not true and with such thing in mind, they are designing an application
rather than understanding the business. That's why it is not uncommon to
find E/R models that are the exact image of a database schema, or Object
Models that represent technical objects.
There is no point of doing that.
Models should help to understand the business and put in a rather
"mathematical" or "logical" way business rules.
Once this is formalized, then it is possible to design or to go directly
to prototype.
Generating database schema from E/R diagram or object model or
generating code from whatever diagram is bullshit. It is no more than a
complex documentation of your program.
What you want to document is the business that make you design your
application the way you design it.


> The secret to good performance is to prototype and prototype,
> then code the bottlenecks in a faster language. The secret to
> large systems is to prototype and prototype, until you've got
> clean separation of the system into managable pieces, then
> code in whatever language most suits the need of each piece.
>
> This is contrary to the advice of a lot of the gurus you mention;
> but they have a large vested interest in the process.
>

That makes me want to write a book ;-)

Michel



From matthewm at es.co.nz  Fri Dec 24 19:04:17 1999
From: matthewm at es.co.nz (Matthew Miller)
Date: Sat, 25 Dec 1999 13:04:17 +1300
Subject: help with ? on popen under w98
Message-ID: <38640A01.776DC88D@es.co.nz>

hi all,

something like...

os.popen('date','w').write(new_date) works fine under NT but i've had no
success using this under w98 - it just ignores what is piped to it.

i've had to resort to writing a file with the date, and then issue 'date
< .\\new_date'

surely, there has to be a better way! thanks for the help. matthew.





From andres at corrada.com  Thu Dec  9 06:11:31 1999
From: andres at corrada.com (Andres Corrada)
Date: Thu, 09 Dec 1999 06:11:31 -0500
Subject: some random reflections of a "Python newbie": (1) books, and free  
 sites
References: <6D8A17398E28D3119F860090274DD7DB4B3D04@pces.cadlab.it>
Message-ID: <384F8E63.95B75B21@corrada.com>

Alex Martelli wrote:
> 
> *THANKS* for this excellent piece of news, then!!! I'll be
> watching the news like a hawk (but my feed is flaky, so
> if there's any way I could get an email reminder when the
> time is right...).

I'll keep you posted.

------------------------------------------------------
Andres Corrada-Emmanuel   Email: andres at corrada.com
Owner                     http://www.corrada.com/mamey
Mamey                     Phone: (413) 587-9595
------------------------------------------------------



From gmcm at hypernet.com  Wed Dec 15 13:55:01 1999
From: gmcm at hypernet.com (Gordon McMillan)
Date: Wed, 15 Dec 1999 13:55:01 -0500
Subject: site.py as a frozen module?
In-Reply-To: 
Message-ID: <1266839252-9855944@hypernet.com>

Mike Romberg wrote:

>   I've been attempting to use site.py as a frozen module.
> Unfortunatly it does not seem to work.  I have verified that the
> module is correctly setup as a frozen module and I can import it
> with a regular ole' import.  But python is not loading it on its
> own.
> 
>   The docs I've read don't really say if this should work or not.
> So... I'm wondering if anyone out there knows if this can be
> done.

Should work, as long as you've told Python about your frozen 
modules before it tries (site is imported as part of 
Py_Initialize).

OTOH, you could set Py_NoSiteFlag, and then import it 
yourself and get the same effect. 

- Gordon



From jam at quark.emich.edu  Sat Dec 11 15:16:22 1999
From: jam at quark.emich.edu (Jeff)
Date: Sat, 11 Dec 1999 15:16:22 -0500
Subject: Error confusing a newbie
In-Reply-To: <19991211140450.B27756@dmcom.net>
References: <19991210100320.B18389@dmcom.net>  <19991211105659.A23924@dmcom.net> <19991211111707.A20613@quark.emich.edu> <19991211140450.B27756@dmcom.net>
Message-ID: <19991211151622.C20613@quark.emich.edu>

On Sat, Dec 11, 1999 at 02:04:50PM -0500, Wayne Topa wrote:
> Yes Jeff, that is the only way it _does_ work. as I described in my
> original post. 
> 

ok. I don't mean to rehash old points, but it was necessary to double check
the facts. if you are able to run it without problems by giving the script
directly to the interpreter, then indeed the problem is in the configuration
of the environment, and python itself should not be blamed for the problem.

> As I have been burned before, using tabs, I now uses spaces only, for
> indentation.
> 

ok. consistency is key. 

> Originallly I wrote it using vim and just checked it with Jed, spaces
> and no tabs.  I just ran tabpolice.py on net_time.py and it didn't
> complain so I am 99.999% sure that I have only spaces.
> 

good.

> >| 
> >| 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')?
> 
> running ' python net_time.py'  works correctly no matter if the
> header line is #!/usr/bin/python or  #!/usr/bin/env python.
> 

well, when you run the python interpreter, and give it a script on the
command line, it ignores lines with "#" characters (or, more correctly,
everything beyond the '#' character). this is very much expected behavior.
did you change the '/usr/bin/env...' part to a direct path to the
interpreter and get different results, or the same problem?

> It gives the error
> VT3 root-Deb-Slink:/program/Python# ./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')'
> 

this is definately the shell (probably bash) interpreting the python code
for itself. another response mentioned that 'import' is a common tool for
conversion of graphics formats (or maybe taking screen shots, I can't
remember).. at any rate, the errors are *not* from the python interpreter,
but rather the shell complaining about the input you are feeding it.

> with either version and it is executable
> VT3 root-Deb-Slink:/program/Python# ls -l net_time.py
> -rwxr-xr-x   1 root     root          839 Dec 11 13:39 net_time.py
> 

if the script wasn't marked executable, you wouldn't have gotten as far as
you did, so I know that isn't the issue.

> 
> The complete script is included in my first post of this problem.
>

I'll check the archives for the original script, but again I don't think
there's anything wrong with your python code, since you mention that it
works ok when you run it as 'python net_time.py'.

> Well it didn't help but then again it didn't hurt either.  You did
> make me wonder so I went and re-checked all of your points.  This one
> os a stinker!
> 

definately.. I would comb the config of the shell for problems. try changing
the '#!' line as I mentioned and see if that solves the problem. perhaps
the 'env' program is the actual culprite.

> Thanks Jeff
> 

regards,
J
-- 
|| visit gfd 
|| psa member --  
|| New Image Systems & Services, Inc. 



From arcege at shore.net  Sun Dec 12 09:20:30 1999
From: arcege at shore.net (Michael P. Reilly)
Date: Sun, 12 Dec 1999 14:20:30 GMT
Subject: Looking for a Unix alike tar tool written in Python
References: <82h1ts$pus$1@nnrp1.deja.com> 
Message-ID: 

Michael P. Reilly  wrote:

: 

My apologies.  I didn't realize that I hadn't fixed the permissions on
the file preventing access.  I've corrected it to give the ISP's web
server access.

Sorry 'about that,
  -Arcege



From XX at XX.COM  Fri Dec  3 15:47:55 1999
From: XX at XX.COM (X CB)
Date: Fri, 3 Dec 1999 14:47:55 -0600
Subject: trouble with python 1.5.2 install on win98
References: <81elc8$8i2$1@nnrp1.deja.com> <4Hc14.1553$uI1.107478@news2.giganews.com>
Message-ID: 

Found it!  Fixed it!

Just in case someone else had the same problem I had...


"Apparently some tcl based program stomped all over my tcl install."  was
the case this time.
It seems that some program installed versions of tk*.dlls to my
winnt/system32 directory and as you all know this directory is by default
first in the search order.  Rename 'em and IDLE mysteriously and wonderfully
works..




X CB  wrote in message
news:4Hc14.1553$uI1.107478 at 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 dworkin at ccs.neu.edu  Wed Dec 29 12:29:24 1999
From: dworkin at ccs.neu.edu (Justin Sheehy)
Date: 29 Dec 1999 12:29:24 -0500
Subject: Super Tuples
References: <386745A6.9B671DBF@prescod.net>  <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <386A1037.C6D458B3@prescod.net>
Message-ID: 

Paul Prescod  writes:

> I agree that tuples in Python are often used merely as immutable lists.
> This bothers me

What else are they used as?

>  * why does Python need an immutable list type but not an immutable
> dictionary?

To name just the first example that comes to mind, tuples (because
they are immutable lists) make great dictionary keys.  I don't think
that an immutable dictionary type would be nearly as useful in that
sense.

>  * isn't immutability more a property of where an object is used than
> the objects actual type? For example, don't you sometimes want to pass a
> list to a function but guarantee that the list won't be modified?

No.  When you want that, you want to pass a tuple, not a list.  :-)

>  * it is because of this abuse that the "one-item tuple" problem arises
> so often.

Which abuse?

> In Python world we most often use tuples as mathematicians do.

>From what I have seen, people most often use Python tuples as
immutable lists, since that is essentially what they are.  This use
happens to very frequently overlap with the mathematical sense of a
tuple.  

> If you use tuples as mathematicians do then single-item tuples can never
> arise because senders and recievers would never agree on a "protocol"
> (used loosely) that involves 1 length tuples (why use a tuple!).

Surely, creating a 1-item tuple to begin with rarely makes sense.
Also, the syntax for doing so is admittedly ugly.  However, there are
plenty of situations where one-item tuples can end up occurring as a
result of data handling.

For instance, a function may receive a tuple of arbitrary size.  (Yes,
I know that this goes against your personal notion of a tuple, but it
makes plenty of sense in Python terms.)  That function may break down
the data in the tuple in a recursive manner, which can certainly lead
to one-item tuples.  What is the big deal with that?

It really sounds like what you are asking for is a lot more like a
dictionary than a tuple.  It sounds like you should be lobbying for a
new mapping type, not a change to the existing (and very useful) tuple.

Or is the problem simply that the word "tuple" evokes for you
something different than what Python calls by that name?
It really sounds like all of the uses which you name for these Super
Tuples would be solved quite well by a dictionary, or perhaps a
lockable dictionary.  

The primary virtue of tuples is that they are simple, immutable sequences.

I see no benefit in removing any of their simplicity.  

-Justin

 


From badzen at yifan.net  Mon Dec 20 12:15:19 1999
From: badzen at yifan.net (dj trombley)
Date: Mon, 20 Dec 1999 17:15:19 GMT
Subject: Question about map() and class methods
References: <83lgi0$t$1@nnrp1.deja.com>
Message-ID: <385E63A4.FDFEA2ED@yifan.net>


malraux at my-deja.com wrote:
> 
> Hi all,
> 
> I was attempting to use a class method with map() the other day, and
> failed miserably.
> 
> Basically, if I have a class foo:
> 
> class foo:
>     def bar(self):
>         return(whatever)
> 
> and I try to do this:
> 
> x = map(foo.bar, someListOfFoos)
> 
> The interpreter complains that foo.bar requires a class as its
> argument.  Obviously, if it would only continue with the call, it would
> discover that yes, indeed, it has a whole list of them to chew on.
> 
> I got around the problem by doing this:
> 
> def mapFooBar(self):
>     foo.bar(self)
> 
> map(mapFooBar, someListOfFoos)
> 
> Which of course works fine.
> 
> What am I missing here?
> 
> Thanks,
> 
> -scott
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.


It seems you might want the following:

class foo:
   def bar(self):
   return(whatever)

x = map(.bar, someListOfFoos)


Calling an unbound method always requires explicitly passing the first
argument; further unbound methods have a different type than instance
methods.  If you want a method to behave as a 'static method' might in
other OOP languages, you can of course declare it in the class without
the first argument, and always make the call unbound to any instance,
ie. with the class name.  But, for extra tweak value, consider the
following example of what I term 'argument promotion':

class foo:
   global b
   def bar(s, arg = None):
         if arg == None:
            print "Adding to the class-wide \"b\""
	    b = b + s 
         else:
            print "Adding to the instance's \"b\""
	    b = b + arg

Now, the function bar can be called as foo.bar() or .bar(), and will
act differently according to if you want the 'static' version or the
'instance' version.  

Dave_the_Python_enthusiast:  Try _that_ in Java!
Dave_the_Java_enthusiast:  Yecch.  Why would I do a thing like that??

In any case, you can see that bound calling in Python is quite flexible.

On a more general note, the issue which I think is at the bottom of why
so many people initially encounter this sort of confusion is a syntactic
one:  that is, we often refer to what is best said as "the potential
concrete incarnations of the code block defined with name  in the
scope of " simply as foo.bar, but that is a syntax collision with
the _unbound_method_ foo.bar; it would be nice if there was a convention
that humans could use to talk about the former when ambiguity arises. 
Anyone have any other thoughts on the issue?

-dj

Dave Trombley



From aahz at netcom.com  Thu Dec 16 11:24:57 1999
From: aahz at netcom.com (Aahz Maruch)
Date: 16 Dec 1999 16:24:57 GMT
Subject: Inheritance vs Composition (was Re: C++)
References: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it> <838uvo$sc7$1@news1.xs4all.nl>
Message-ID: <83b3op$jfp$1@nntp6.atl.mindspring.net>

In article <838uvo$sc7$1 at news1.xs4all.nl>,
Boudewijn Rempt  wrote:
>
>That makes C++ about as powerful as Visual Basic - in essence, no
>inheritance at all, just interfaces... Having just done a large project
>in Visual Basic, I've learnt how painfult that limitation can be - and
>I was kind of surprised when I read in Design Patterns that composition
>should be favoured over inheritance. There are no doubt good reasons,
>but not one I can think of.

Let me clarify: the difference between inheritance and composition is
the difference between "is-a" and "has-a".  For example, you would not
design a "car" object to be inherited from "engine", "chassis",
"transmission", and so on ("car is-a engine" makes no sense) -- you
would *compose* the car object from its constituent parts ("car has-a
engine" makes a lot of sense).

Once you start thinking in terms of "is-a" versus "has-a", it's a lot
easier to do proper design.

[I'm blanking on where I first saw this crucial distinction; anyone who
wants to remind me would be very welcome.]
--
                      --- 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 jaakovb at orckit.com  Thu Dec 23 01:12:03 1999
From: jaakovb at orckit.com (jaakovb)
Date: Thu, 23 Dec 1999 08:12:03 +0200
Subject: Python & Corba
Message-ID: <83se6d$n8t$1@news.netvision.net.il>

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




From malraux at my-deja.com  Mon Dec 20 10:06:04 1999
From: malraux at my-deja.com (malraux at my-deja.com)
Date: Mon, 20 Dec 1999 15:06:04 GMT
Subject: Equivalent to (a ? b : c) ?
Message-ID: <83lgkq$2q$1@nnrp1.deja.com>

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?

Thanks,

-scott


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


From edwardam at home.com  Sat Dec  4 18:12:00 1999
From: edwardam at home.com (Edward Muller)
Date: Sat, 04 Dec 1999 18:12:00 -0500
Subject: 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> <021901bf3e44$068941a0$f29b12c2@secret.pythonware.com>
Message-ID: <38499FBF.EE83C50@home.com>

Fredrik Lundh wrote:

> 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...
>
> now that the 1.0 specification is out [1] [2], I'm pretty
> confident that there will be lots of implementations out
> there real soon now.
>
> on the other hand, why not use XML-RPC today, and
> switch to SOAP when code becomes available?
>
> > I do agree with you that SOAP would address my problem,
> > AND I WILL LOOK INTO DOING A PYTHON IMPLIMENTATION
>
> or you can wait for us to finish our implemenation (we
> wrote Python's highly popular XML-RPC library, and plan
> to add SOAP support in early 2000).  on the other hand,
> if you have the time and energy, go ahead.  competition
> is good !
>
> 
>
> 1) http://www.pythonware.com/madscientist/draft-box-http-soap-01.txt
> 2) http://www.newsalert.com/bin/story?StoryId=Coenz0bWbu0znmdKXqq&FQ=Secret+Labs+AB

That's what I decided to do.

Just wanted to thank everyone for the input.






From tismer at appliedbiometrics.com  Sun Dec 12 07:11:12 1999
From: tismer at appliedbiometrics.com (Christian Tismer)
Date: Sun, 12 Dec 1999 13:11:12 +0100
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: <385390E0.B95EFCFC@appliedbiometrics.com>


Fran?ois Pinard wrote:
> 
> 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.

Sorry, I meant A68 of course. Was it since the key distance
from "6" to 8 is the same as to "4", or did I use the mean,
or had the "IV" in mind, no idea, it was late.

ciao - chris

-- 
Christian Tismer             :^)   
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home



From just at letterror.com  Mon Dec 27 10:54:56 1999
From: just at letterror.com (Just van Rossum)
Date: Mon, 27 Dec 1999 16:54:56 +0100
Subject: [Pythonmac-SIG] Re: [ANNOUNCE] PySol 3.10 - a solitaire game
 collection
In-Reply-To: 
References: <19991222015859.A9045@laetitia.oberhumer.com>
Message-ID: 

At 3:18 PM +0100 12/25/99, Joachim Schmitz wrote:
>did anyone successfully run it on an iMac. After loading about 85 % the
>loading stops with an "not enough memory error" ?

The trick is to give BuildApplet a *lot* of memory, then give the resulting
applet about 12 megs of memory. This worked for me. (The trouble is caused
by the fact that PySol is one huge source file, and Python's
parser/compiler eats a lot of memory when working with large source files.
*Running* PySol is not the problem, compiling is.)

Just





From news at dorb.com  Fri Dec 31 10:40:53 1999
From: news at dorb.com (Darrell)
Date: Fri, 31 Dec 1999 10:40:53 -0500
Subject: Splitting up classes between files
References: 
Message-ID: 

Using import a1,a2,... in a.py to avoid making the user do it, is tricky.

Your users will now have to write a.a1.xxx
If they had the import a1 they could just say a1.xxx

You could try this in a.py.
    from a1 import *
    from a2 import *

Now they can say a.xxx, but they might get xxx from a2.
from xxx import * is considered unhealthy and should be used with care.

You could stay with the import a1,a2,... in a.py. Then write an interface to
this collection of modules in a.py. Remember that a function in a.py can
return an instance from a1.py and your user doesn't need an "import a1".


--
--Darrell
"Roy Smith"  wrote in message
news:roy-E337E8.09101731121999 at netnews.nyu.edu...
> I've got a top-level class, a, and a bunch of sub-classes, a1, a2, a3,
etc.  To
> make it easier to manage the code, I'd like to put each in a separate
file, but
> still have the user be able to import the whole bunch with a single
import, i.e.
> not have to do "import a, a1, a2, a3, etc".
>
> Can I just put "import a1, a2, a3, etc" in the bottom of my "a.py" file?
It
> seems like it should work fine, but are there any hidden gotchas?
>





From smb at bby.com.au  Sun Dec 19 23:46:04 1999
From: smb at bby.com.au (Sarah Burke)
Date: Mon, 20 Dec 1999 14:46:04 +1000
Subject: Sydney scoreboard?
Message-ID: <385DB48C.7A7A52D6@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



From cjc26 at nospam.cornell.edu  Mon Dec 20 19:48:03 1999
From: cjc26 at nospam.cornell.edu (Cliff Crawford)
Date: 21 Dec 1999 00:48:03 GMT
Subject: Lists of lists traversal
References: <83m3fn$sb6$1@cronkite.cc.uga.edu> 
Message-ID: <83mio3$f1a$1@news01.cit.cornell.edu>

Pada 20 Dec 1999 21:17:27 GMT, Kaleissin bilang:
| 
| What I would do in your case:
| 
| listpos = 0
| while listpos < len(list_of_lists):
| 	list_of_lists[listpos] = reduce(lambda x, y: x+y, list_of_lists[listpos])
| 	listpos = listpos + 1
| 
| This destroys the original lists btw. To keep them, append the resulting 
| sum to some other list instead of replacing the list with it as above. 
| You could use a for instead of the while too, in that case.
| 
| It might not be very effective but it looks nice... list comprehension 
| version, anyone?

[reduce(lambda x, y: x+y, l) for l in list_of_lists]

:-)


-- 
cliff crawford   http://www.people.cornell.edu/pages/cjc26/
-><-             "You and your stupid orthography" -- Mark


From Jim.Tittsler at tokyopc.org  Mon Dec 20 21:53:14 1999
From: Jim.Tittsler at tokyopc.org (Jim Tittsler)
Date: 21 Dec 1999 02:53:14 GMT
Subject: smtp
References: <385DF2D3.A17FBE21@obop.com.pl>
Message-ID: 

On Mon, 20 Dec 1999 10:11:47 +0100, Przemys?aw G. Gawro?ski wrote:
>I have a problem with smtp module (sending files).

The MimeWriter module can simplify generating multipart MIME messages. The
body of each part can contain one of your file "attachments."


From tismer at appliedbiometrics.com  Sun Dec 19 16:21:38 1999
From: tismer at appliedbiometrics.com (Christian Tismer)
Date: Sun, 19 Dec 1999 22:21:38 +0100
Subject: LISTS: Extract every other element - SUMMARY
References: 
Message-ID: <385D4C62.B0D9E43D@appliedbiometrics.com>


Mike Fletcher wrote:
> 
> 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:

[fine so far, but...]

> DATA LENGTH 1000000
>  1.0831
>  1.2168
>  0.4660
>  0.4605
>  0.6465
>  0.5405

There is something wrong.
This single call cannot cost this much.

Can you please give me your current test set?
I got the test 1..4 files from your postings,
and at least test2() and test4() are wrong
since they do not give plain lists back.

ciao - chris

-- 
Christian Tismer             :^)   
Applied Biometrics GmbH      :     Have a break! Take a ride on Python's
Kaiserin-Augusta-Allee 101   :    *Starship* http://starship.python.net
10553 Berlin                 :     PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint       E182 71C7 1A9D 66E9 9D15  D3CC D4D7 93E2 1FAE F6DF
     we're tired of banana software - shipped green, ripens at home



From fredrik at pythonware.com  Thu Dec  9 04:45:40 1999
From: fredrik at pythonware.com (Fredrik Lundh)
Date: Thu, 9 Dec 1999 10:45:40 +0100
Subject: Embedding questions
References: <82n5ec$e2a$1@ssauraab-i-1.production.compuserve.com>
Message-ID: <00a401bf422a$28ae6280$f29b12c2@secret.pythonware.com>

Olaf Appelt  wrote:
> 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?

Greg Stein's imputil.py [1] allows you to modify the
import statement so it can pick up code from any
data source.

an example (assuming "db" is a database object which
works pretty much like a code string dictionary).

...

class DatabaseImporter(Importer):
    
    def __init__(self, db):
        self.__db = db

    def get_code(self, parent, modname, fqname):
        # is it a module?
        try:
            code = marshal.loads(self.__db[fqname])
            return 0, code
        except KeyError:
            pass
        # is it a package?
        try:
            fqname = fqname + ".__init__"
            code = marshal.loads(self.__db[fqname])
            return 1, code
        except KeyError:
            pass
        return None # not found in this database

# prepends the database to the import chain
DatabaseImporter(mydb).install()

...

to compile python source code into code strings, use:

    string = marshal.dumps(compile(source, filename, "exec"))

...

hope this helps!



1) http://www.lyra.org/greg/python/imputil.py




From sposhua at my.pc  Tue Dec 14 04:41:37 1999
From: sposhua at my.pc (Sposhua)
Date: Tue, 14 Dec 1999 09:41:37 +0000
Subject: Internet programming with python
Message-ID: 

Any1 know if there is a reprint / update of this book in the pipeline?




From annis at biostat.wisc.edu  Wed Dec 15 13:33:04 1999
From: annis at biostat.wisc.edu (William Annis)
Date: 15 Dec 1999 12:33:04 -0600
Subject: ANN Mom.v3 - yet another monitoring system
Message-ID: 

        In response to censorious comments and coy references to "the
bazaar" from my peers at LISA '99, I have decided to make the current
version of my Unix system monitoring system available in spite of its
wildly pre-alpha state.  I gave a Work in Progress (WiP) talk about
this, and several people who saw that talk have been looking at the
system, but I think it's time for a wider audience.

        The core of the system is written entirely in Python, which is
why I'm announcing it here first, instead of on Freshmeat.  I admit to
a strong Solaris bias, so there are several SWIGgy extensions to get
interesting data straight out of the kernel instead of forking off the
many tools and parsing their output.  The system is known to work on
RH Linux 6.0 as well, though the agents are less interesting.  Feel
free to send me Linux agents. :)

        The system has been designed as an infrastructure to allow the
statistical modeling (time series models, in particular) of a network
of computers from which will allow the system to identify unusual
behavior.  The statistical bits aren't finished yet -- I'm working
with several statisticians on the problem -- but the data collection
and notification system is very flexible.

        You can see the WiP slides (PostScript) for a quick overview
of why I did this: http://www.biostat.wisc.edu/~annis/mom3/wip.ps .

        The main web page for the system has more detail and links to
snapshots, docs and examples: http://www.biostat.wisc.edu/~annis/mom3/ .

        If you use Solaris, you'll also want my PyKstat package
installed to make best use of the many Solaris agents:
http://www.biostat.wisc.edu/~annis/creations/pykstat.html .

        Questions, comments (friendly) and bug reports always
welcome. 

-- 
William Annis - System Administrator - Biomedical Computing Group
annis at biostat.wisc.edu                       PGP ID:1024/FBF64031
Mi parolas Esperanton - La Internacia Lingvo    www.esperanto.org


From daniel.dittmar at sap.com  Mon Dec 13 07:47:49 1999
From: daniel.dittmar at sap.com (Daniel Dittmar)
Date: Mon, 13 Dec 1999 12:47:49 GMT
Subject: Multiple interpreters and the global lock
Message-ID: <832pti$7u2$1@mailusr.wdf.sap-ag.de>

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.

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?
- what would be the smoothest path to completition, breaking
  the least code?


Core interpreter:

   All (most) routines will require an additional parameter,
the interpreter (PyThreadState *).  It is probably a good
idea to give these routines new names.  The old names are
still around as wrappers to the new routines, they take the
'current' interpreter from a global variable (read on to
'keeping extension modules binary compatible' why this is
useful).  Would the additional parameter have a 'negative
impact on performance'?

Because objects aren't shared between interpreter,
no special handling of reference counting is necessary.
(I know there are exceptions to this)


Extension modules:

New and adapted modules:
will call the new names, passing the interpreter object
along.  They get the interpreter as the first argument to an
extension function.  Such functions are marked by the
INTERPRETER_PROTECTED flag in the PyMethodDef struct.  They
would still use something like Py_BEGIN_ALLOW_THREADS etc.
for multiple threads inside a single interpreter, but this
lock would be interpreter local.

Binary compatibility:
because older extension functions lack the
INTERPRETER_PROTECTED flag, the 'current' interpreter knows
that they still rely on a global interpreter.  The 'current'
interpreter acquires the global lock (it's still around),
sets the global interpreter to itself and calls the
function.  Upon returning, the global lock is released and
the global interpreter pointer is cleared.  Would this
actually work for a module compiled for the current Python?
Or would there be a need to recompile these, thus providing
only source compatibility?


Problems:

Static objects (mostly type objects):

    PyTypeObject variables are often static in an extension
module.  This of course makes them shared between multiple
interpreters.  As reference counting is not (should not) be
synchronized, this could lead to a zero count and
destruction of a static object, which is never a good idea.
Does anyone has an idea how to solve this?  (I think it was
Frederik Lundh who pointed to this problem in a similar
thread).

memory management:

   having to synchronize on a single heap limits
scalability, especially when lots of objects get allocated
and released.  The right way would be to have each
interpreter have it's own heap.  As objects aren't shared,
this would be a solution.

   But is a bit more difficult to remain binary compatible
for 'old' modules.  This would require replacing 'malloc'
with a Python specific implementation.  Unfortunately, this
will not work in the Windows world, where extension DLLs are
linked to get their malloc from a specific runtime DLL.

   One intermediate step would be to provide a allocator
object as part of the interpreter and to encourage everyone
to use it.  The first version will only call malloc and
free, thus preserving compatibility.  But this gives
everyone a chance to prepare their sources for an upcoming
incompatible release (Python 2.0), where functions without
INTERPRETER_PROTECTED are no longer accepted.


Disclaimer:

   The cause for this post is not to advance mankind, but to
advance a commercial product.

   Any references to implementation details of Perl and
JavaScript are only partly for information.  They serve
mostly to stir competition.

Daniel Dittmar
daniel.dittmar at sap.com
SAP AG, Basis Entwicklung Berlin



From aahz at netcom.com  Fri Dec 24 10:25:56 1999
From: aahz at netcom.com (Aahz Maruch)
Date: 24 Dec 1999 15:25:56 GMT
Subject: Bad programming style?
References: <6D8A17398E28D3119F860090274DD7DB4B3D7C@pces.cadlab.it>
Message-ID: <8403a4$7pv$1@nntp4.atl.mindspring.net>

In article <6D8A17398E28D3119F860090274DD7DB4B3D7C at pces.cadlab.it>,
Alex Martelli   wrote:
>
>(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?-)

In honor of Tanith, how about "101 things you don't want your
compiler/interpreter to report when you're deep in a debug cycle"?
--
                      --- 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 tim_one at email.msn.com  Fri Dec 17 03:08:17 1999
From: tim_one at email.msn.com (Tim Peters)
Date: Fri, 17 Dec 1999 03:08:17 -0500
Subject: Bug in Python 1.5.2 exception handling?
In-Reply-To: <87u2lju5yh.fsf@heresy.itga.com.au>
Message-ID: <001c01bf4865$e1059740$63a2143f@tim>

[Dave Cole, suprised by locals surviving exit-by-exception]
> ...
> 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.

I doubt you want to chance that.

     def something_or_other(self):
         tran = Transaction(self.db, 'update_id')
         try:
             # lots o' database stuff
             tran.commit = 1
         finally:
             tran.dispose()  # contains what __del__ does now

is reliable under CPython or JPython.  I wish there were an even simpler way
to write these kinds of acquire/release pairs, but for now this is as good
as it gets.  It's not like it's *un*readable!  Quite clear, actually.  I
think it's just the "extra" indentation that irks me.

whitespace-is-a-precious-commodity-ly y'rs  - tim





From aa8vb at yahoo.com  Thu Dec  9 08:03:50 1999
From: aa8vb at yahoo.com (Randall Hopper)
Date: Thu, 9 Dec 1999 08:03:50 -0500
Subject: X display visual
In-Reply-To: <944690214.197.926615478@cs.usyd.edu.au>
References: <944690214.197.926615478@cs.usyd.edu.au>
Message-ID: <19991209080349.A9138@vislab.epa.gov>

Piers Lauder:
 |Randall Hopper  wrote:
 | >
 | > To be more robust, pick a visual returned by:
 | >
 | >  root.winfo_visualsavailable()
 |
 |Just for the record, this particular Tkinter method
 |doesn't work on either my Linux or Solaris boxes:
...
 |	>>> r.winfo_visualsavailable()
...
 |	TypeError: illegal argument type for built-in operation

 |To track doesn what exactly *is* being returned, I tried:
...
 |
 |	>>> r.tk.call('winfo', 'visualsavailable', r._w, None)
 |	'{truecolor 24}'
...
 |	>>> map(parseitem, 'truecolor 24')
...
 |	TypeError: illegal argument type for built-in operation


Sounds like this could be the same problem that the MSWin user hit since
MSWin versions have only one visual as well.

Feel free to file a bug report on this via the Python bug form:

      http://www.python.org/search/search_bugs.html

or if you don't want to, let me know and I'll put one in.

-- 
Randall Hopper
aa8vb at yahoo.com



From grant at nowhere.  Tue Dec 14 16:58:23 1999
From: grant at nowhere. (Grant Edwards)
Date: Tue, 14 Dec 1999 21:58:23 GMT
Subject: Python suitability
References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> <%1y54.9585$W2.27026@iad-read.news.verio.net>
Message-ID: 

Tom Culliton wrote:
>Nemeth Miklos   wrote:
>>
>>> 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?

About twice as long as it would take for a Modula-3 or
Smalltalk programmer.  ;) I've never thought C++ was a
particularly decent example of an object-oriented language, but
maybe that's because I learned Smalltalk and M3 first.

The whole virtual-function-method thing has always struck me as
very obtuse.  You apparently have to guess ahead of time which
methods somebody might, at some point in the future, want to
override, and declare them differently from the non-overridable
ones...

>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.

Especially for somebody with experienced in a decent OO
langage. If you already understand how Tk works (from use with
Tcl or Scheme, for example), then you should be able to start
cranking on a decent sized GUI app after a couple days' study.

-- 
Grant Edwards                   grante             Yow!  I have a TINY BOWL in
                                  at               my HEAD
                               visi.com            


From mstenber at cc.Helsinki.FI  Sat Dec 11 06:12:01 1999
From: mstenber at cc.Helsinki.FI (Markus Stenberg)
Date: 11 Dec 1999 13:12:01 +0200
Subject: Python and regexp efficiency.. again.. :)
References:  <101219992322162268%zippy@cs.brandeis.edu>
Message-ID: 

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 skip at mojam.com  Fri Dec 10 01:58:44 1999
From: skip at mojam.com (Skip Montanaro)
Date: Fri, 10 Dec 1999 00:58:44 -0600 (CST)
Subject: Linux.Com
In-Reply-To: 
References: <384DC8F1.9A1F135F@easystreet.com>
	<14413.59272.858902.938397@anthem.cnri.reston.va.us>
	
Message-ID: <14416.42148.678723.591443@dolphin.mojam.com>

Just so nobody smokes something and starts to take the linux.com poll about
scripting languages too seriously, I just saw the following comment from a
PHP fan:

    Perl would get my second vote, though, because I consider it a cool
    version of C++ :)

I guess I've forgotten the definition of "cool" or I now speak Middle
English...

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 bowman at montana.com  Sun Dec  5 11:09:23 1999
From: bowman at montana.com (bowman)
Date: Sun, 05 Dec 1999 16:09:23 GMT
Subject: Tkinter 1.5.2 ??
References: <38499F30.54313C44@interaccess.com>  <3849F4A6.E6E4D52D@interaccess.com>
Message-ID: 

Clyde Davidson  wrote:

>OK, if that's what's there. But where is the this?

http://www.python.org is the source of all good things Python.




From tim_one at email.msn.com  Fri Dec 10 03:48:46 1999
From: tim_one at email.msn.com (Tim Peters)
Date: Fri, 10 Dec 1999 03:48:46 -0500
Subject: some random reflections of a "Python newbie": (2) language issues
In-Reply-To: <001e01bf42bd$4da0cfe0$60a2143f@tim>
Message-ID: <000101bf42eb$5ef49be0$412d153f@tim>

[some moron posing as me]
> "if a in X:" currently works only if X is a list, tuple or string.  In
> Python 1.6 it's supposed to work too if X is an instance of a class that
> supports the special __contains__ method; see the 1.6 docs,
> preferably after they're written .

You can tell that wasn't me because the first claim is wrong!  I expect I
wrote the rest of it, though.

sometimes-infallibility-has-to-be-taken-on-faith-ly y'rs  - tim





From mlh at vier.idi.ntnu.no  Mon Dec 20 09:28:28 1999
From: mlh at vier.idi.ntnu.no (Magnus L. Hetland)
Date: 20 Dec 1999 15:28:28 +0100
Subject: List comprehensions
References: <38592275.BBA2B61A@maxtal.com.au> <385E045D.9EC36473@compaq.com>
Message-ID: 

Greg Ewing  writes:

> 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

Have you looked into adding separators (like "and") between the
iterators yet? (You *did* see that as a possibility, didn't you?)

After all, that is what is done in math, more or less... (Either using
a logical and or a comma.)

  (Quasi-LaTeX)
  P = {(x,y) | x \in X \and y \in Y}

  (Quasy-Python)
  P = [(x, y) for x in X and for y in Y]

The use of "and for" (since "and" would be ambiguous) seems a bit
verbose -- which is something that speeks for your current format...

  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)

i.e. parallel iteration, which can also be quite useful sometimes.

(Maybe X and Y should be of equal length... And I'm not quite sure
what would happen if you introduce if-clauses in each of the
iterators...)

Anyway... I guess my conclusion is that I withdraw my earlier
suggestion of using "and" as a separator for the iterators, since they
clearly should not be separated, but are indeed contained within each
other, so to speak.

(Or am I just confused here?)

--

  Magnus
  Lie
  Hetland


From phd at phd.russ.ru  Tue Dec 21 06:54:44 1999
From: phd at phd.russ.ru (Oleg Broytmann)
Date: Tue, 21 Dec 1999 11:54:44 +0000 (GMT)
Subject: Size of files in human, readable form
In-Reply-To: <385F3515.6606E58F@mincom.com>
Message-ID: 

Hans,

   this is definetely for your snippets collection. Excellent example of
code.

On Tue, 21 Dec 1999, Martin Pool wrote:

> 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".
> 
> 

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




From gtcopeland at EarthLink.Net  Fri Dec 17 12:44:43 1999
From: gtcopeland at EarthLink.Net (Greg Copeland)
Date: Fri, 17 Dec 1999 17:44:43 +0000
Subject: python constructor overloading
References: <1266675828-4948460@hypernet.com>
Message-ID: <385A768B.F61C80F7@EarthLink.Net>

Gordon McMillan wrote:
> 
> Greg Copeland wrote:
> 
> > Darrell wrote:
> > >
> > > 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.
> >
> > In this particular case, I wouldn't expect this to happen.  Since
> > the container should technically live longer than the contained.
> > In short, if the container is gone, everything within it should
> > also be gone.  No memory leaked.
> 
> Bzzt. The container is unavailable, but unless you specifically
> clear it, it will still exist, because it's ref count hasn't gone to
> zero because there are objects (which happen to be inside it)
> which still reference it.

Thanks for spelling this out.  I had, however, already read about this
issue.  My objects will be explicitly collected (at least, my intent is
to).  Err, rather, I assume that 'sys.exc_traceback = None' will do this
after the contained have lived their life?  I poorly expressed my self
here as I didn't believe it to be central to my point of contention. 
Thanks.  I'll pay more attention next time!  :) 

> 
> [subclassing]
> 
> > Obviously, I want to keep all of the existing engine's
> > functionality, but simply extend it with the turbo's boost
> > methods.  As I understand it, you can't do this?!?!?  If I
> > understand you correctly, I have to re-implement engine's
> > constructor and extend it in the turboEngine's constructor.
> 
> You have to call the base class's __init__ explicitly. __init__
> isn't actually a "constructor", it is an "initializer". In other
> words, "self" is the real, final thing when __init__ runs; you
> just get to set up it's state, not influence it's construction.

Hmmm.  I'll try again.  I guess it was something I was doing wrong.  I
was getting an unbound method error.  As for the constructor/initializer
reference.  To me, it looks like python's equivalent to a C++
constructor, so that's what I called it.  Is "initializer" the correct
terminology for python?

> 
> There's nothing automatic about __init__, which is why mixins
> are easy and useful in Python (but rarely so elsewhere).

Can you expand on this a bit?  Everything I've seen suggests that
__init__ is automatic.  If you can point me to some read'n here, that
would be great.  I'm also not sure how a mixin would help here, other
than to provide a method that accepts the reference to the container. 
Obviously, you've pushed me to something that "feels" better, but isn't
exactly what I was hoping for.  Still, I say thanks!

> 
> >  If
> > that's the case, I greatly condom the OO-implementation of
> > python.
> 
> Now that's a Freudian slip if I've ever seen one.
> 

Spell checkers are just dandy.  I originally misspelled it.  The spell
checker gave me that and OBVIOUSLY didn't catch it...in time.  I saw it
right after I hit the send button.  Grrr...


> > So it isn't so.  If this is that case, I'd say the
> > python authors have been using MFC way too much!  :P~
> 
> I can assure you that Python's principle author wouldn't
> recognize MFC if it stole all his condoms.

:)  Cute!

> 
> 
> - Gordon

Greg


P.S.  I'm expecting my Python books to be here this week...  :)



From pstmarie at my-deja.com  Wed Dec  8 18:28:46 1999
From: pstmarie at my-deja.com (pstmarie at my-deja.com)
Date: Wed, 08 Dec 1999 23:28:46 GMT
Subject: tail -f with Python/Tkinter
Message-ID: <82mpj9$vq8$1@nnrp1.deja.com>

Hi,
I'm quite new to Python and have not been able to
find the answer to this in my books or on the web.
How do I tail -f a log file using a Tkinter
widget? It's on a Linux system..

Thanks,

pete


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


From emmanuel.pietriga at xrce.xerox.com  Thu Dec  2 02:16:17 1999
From: emmanuel.pietriga at xrce.xerox.com (Emmanuel Pietriga)
Date: Thu, 02 Dec 1999 08:16:17 +0100
Subject: XPython (X11)
References: <383E5350.1E07536A@xrce.xerox.com> <821m2h$7ne$1@nnrp1.deja.com>
Message-ID: <38461CC1.B9EE4CE3@xrce.xerox.com>

aj10 at my-deja.com wrote:

> 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.

YES, perf. is critical.


--
emmanuel.pietriga at xrce.xerox.com               |  Xerox Research Centre Europe
Document Model and Transformation Technologies |  6, Chemin de Maupertuis
+33 4 76 61 50 32  (direct)                    |  38240 MEYLAN, FRANCE
+33 4 76 61 50 50  (switchboard)               |  http://www.xrce.xerox.com






From gerrit.holl at pobox.com  Wed Dec 22 10:53:17 1999
From: gerrit.holl at pobox.com (Gerrit Holl)
Date: Wed, 22 Dec 1999 16:53:17 +0100
Subject: %* control characters question.
Message-ID: <19991222165317.A11723@stopcontact.palga.uucp>

Hello,

is there a module to fetch %* control characters, like strftime does?
Currently, I have this code:

s=raw_input("format: ")
string.replace(s, '%a', foo)
string.replace(s, '%b', bar)
string.replace(s, '%c', foobar)
etc.

I also want '%4a' to work. Are there functions to parse this sort of things?

regards,
Gerrit.

-- 
"The world is beating a path to our door"

  -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates)
  4:45pm  up  5:40, 16 users,  load average: 0.00, 0.01, 0.00



From claird at starbase.neosoft.com  Sun Dec 19 11:57:36 1999
From: claird at starbase.neosoft.com (Cameron Laird)
Date: 19 Dec 1999 16:57:36 GMT
Subject: Newbie question : Info on Python under DOS/Windows
References: <381ec4c4.7451128@212.225.36.99> <38209987.2A7005C3@interet.com>
Message-ID: 

In article <38209987.2A7005C3 at interet.com>,
James C. Ahlstrom  wrote:
>Endgamer wrote:
>> hold the date on reboot after the millenium.
>> My question is: I've found it hard to locate resources or  information
>> on Python under DOS/Windows - are there any special groups, sites or
>
>Python on DOS/Win95 works the same as on Unix.  Just
>start at www.python.org.
>
>Jim Ahlstrom

'Couple of things I think Endgamer deserves to hear:
1.  If narrow-sense MS-DOS interests you, Python
    still has a lot to offer you.  I don't know
    of anyone building MS-DOS versions from re-
    cent Python releases, and I'm not current
    with what the possibilities are.  However,
    I use a version 1.epsilon port to MS-DOS,
    and am thoroughly satisfied with it.  More
    details available, if it matters.
2.  I suspect Mr. Ahlstrom doesn't work in
    Marketing.  To write that "Python on ...
    Win95 works the same as on Unix" seriously
    undersells what the Py-on-Win* folks have
    accomplished.  It speaks COM!  It knows the
    registry!  Multiple GUI toolkits are well-
    supported!

    I summarize:  Win*!Python does what you want.
    Give it a look.
-- 

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


From nielsenjf at my-deja.com  Mon Dec 27 17:21:19 1999
From: nielsenjf at my-deja.com (John Nielsen)
Date: Mon, 27 Dec 1999 22:21:19 GMT
Subject: Python and ASP Observations
References: <38651fc7.144536242@news.isomedia.com>
Message-ID: <848odi$pk1$1@nnrp1.deja.com>

Thanks for your news posting w/ASP. I am starting down that road myself.

With regards to storing objects, ever try using Cpickel?

I have pickeled complicated python objects, sent them as a string via
COM, then unpickeled on the other side.  It works great. The only
disadvantage, of course, is that ohter languages like VBscript won't
work with this, since it can't unpickel.

john

In article <38651fc7.144536242 at news.isomedia.com>,
  bitbucket at isomedia.com (Eugene Goodrich) wrote:
> 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==')
>

--
nielsenjf at my-Deja.com


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


From stigb at tihlde.org  Thu Dec 23 09:02:05 1999
From: stigb at tihlde.org (Stig Bjorlykke)
Date: 23 Dec 1999 15:02:05 +0100
Subject: How to read lines from end of a file?
References: <4rhfhazoj4.fsf@colargol.tihlde.hist.no>    
Message-ID: <4r7li5zrfm.fsf@colargol.tihlde.hist.no>

"Darrell"  writes:

| Maybe maxLen should be sys.maxint by default. Then paranoid or
| performance concerned, can tone it down from there.

This was not exactly what I was looking for:  I want to read the last
lines from a file, one by one, until I find what I'm looking for.

Instead of using your function I could have used 'tail -10 file', but I
don't know where my log entry is in the file, so I have to search
backwards in the file to find it.

Hope this clarifies the situation I have ;)


PS: It seems like the reverse() function does what I want, so I use
that until I find something better.


-- 
Stig Bj?rlykke
Linux user


From kkethine at cisco.com  Tue Dec 21 16:29:42 1999
From: kkethine at cisco.com (Gopal Kethineni)
Date: Tue, 21 Dec 1999 13:29:42 -0800
Subject: How to access Oracle?
Message-ID: <945811978.70442@sj-nntpcache-4.cisco.com>

Hi

I am new to Python.

How do I connect to Oracle 7.3.4?

Do I have complete solution (all compatible data types,
full set of JDBC/ODBC/OCI features)?


Thanks
KG




From ajung at sz-sb.de  Thu Dec 30 04:59:57 1999
From: ajung at sz-sb.de (Andreas Jung)
Date: Thu, 30 Dec 1999 10:59:57 +0100
Subject: Python - CGI script
In-Reply-To: <19991230.3584900@negrita.brunner.org>; from LCortes@Flash.Net on Thu, Dec 30, 1999 at 04:01:27AM +0000
References: <19991230.3584900@negrita.brunner.org>
Message-ID: <19991230105957.A8593@sz-sb.de>

On Thu, Dec 30, 1999 at 04:01:27AM +0000, Luis Cortes wrote:
> 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.
> 


*snip*

.....
upload.py: import cgi form = cgi.FieldStorage() fileitem = form['userfile'] if fileitem.file: fname = tempfile.mktemp() fp=open(fname,'w') fp.write(fileitem.file.read()) fp.close() ..... -- _\\|//_ (' O-O ') ------------------------------ooO-(_)-Ooo-------------------------------------- Andreas Jung, Saarbr?cker Zeitung Verlag und Druckerei GmbH Saarbr?cker Daten-Innovations-Center Untert?rkheimerstra?e 15, D-66103 Saarbr?cken, Germany Phone: +49-(0)681-502-1528, Fax: +49-(0)681-502-1509 Email: ajung at sz-sb.de (PGP key available) ------------------------------------------------------------------------------- "Well is UNIX Y2K-compliant?" and I said, ``No problem at all, but in 2038 I plan on being retired, because it is not going to be a good year for UNIX systems!'' (GvR) From aahz at netcom.com Thu Dec 30 13:49:08 1999 From: aahz at netcom.com (Aahz Maruch) Date: 30 Dec 1999 18:49:08 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> <84g50u$rtf$1@nnrp1.deja.com> Message-ID: <84g9f4$8bs$1@nntp3.atl.mindspring.net> In article <84g50u$rtf$1 at nnrp1.deja.com>, wrote: > >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. See HTMLParser.save_begin() -- --- 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 JoeSmith at bogusaddress.com Sun Dec 19 22:12:04 1999 From: JoeSmith at bogusaddress.com (Joe Smith) Date: Mon, 20 Dec 1999 03:12:04 GMT Subject: win32 binary data manipulation in ASP References: <385CC64E.25E91136@bogusaddress.com> <4Ze74.5225$NV6.22879@news-server.bigpond.net.au> Message-ID: <385D9F54.6435B1FC@bogusaddress.com> I was using build 125 that I downloaded from the www.python.org site about 2 weeks ago. So, I did not really think that there might be a new build or that your site might be the one to look at. I tried using the buffer(), but I guess 125 was not as good as 127. Thanks. Mark Hammond wrote: > "Joe Smith" wrote in message > news:385CC64E.25E91136 at bogusaddress.com... > > > > I am trying to write a server side ASP script in python. > > > > buffer = os.read(fd, numBytes) > > Response.BinaryWrite(buffer) > > > > I notice that I am getting exactly double the number of bytes on > output. I > > suspect that the string returned from os.read() is getting converted > to > > unicode. > > > > I am looking for a way to convert the string to an array of bytes, > not an array > > of unicode characters. > > If you have build 127 of win32all, you can use a buffer object. eg: > > data = os.read(fd, numBytes) > Response.BinaryWrite(buffer(data)) > > [ie, note that "buffer" is a Python builtin, so the variable name was > changed] > > This also depends on ASP accepting data in this format - Im guessing > it will, but I dont know for sure... > > Mark. From jh at cddk.dk Mon Dec 20 12:20:21 1999 From: jh at cddk.dk (Jesper Hertel) Date: Mon, 20 Dec 1999 18:20:21 +0100 Subject: Question about map() and class methods References: <83lgi0$t$1@nnrp1.deja.com> Message-ID: <83logp$fir$1@news1.tele.dk> I cannot redo the things you do. When I run this program: --- class foo: def bar(self): return("foo.bar") x = map(foo.bar, [foo(), foo()]) print x ---- I get ['foo.bar', 'foo.bar'] just as expected. Are you sure someListOfFoos are objects (instances of classes) and not classes? Jesper Hertel wrote in message news:83lgi0$t$1 at nnrp1.deja.com... > Hi all, > > I was attempting to use a class method with map() the other day, and > failed miserably. > > Basically, if I have a class foo: > > class foo: > def bar(self): > return(whatever) > > and I try to do this: > > x = map(foo.bar, someListOfFoos) > > The interpreter complains that foo.bar requires a class as its > argument. Obviously, if it would only continue with the call, it would > discover that yes, indeed, it has a whole list of them to chew on. > > I got around the problem by doing this: > > def mapFooBar(self): > foo.bar(self) > > map(mapFooBar, someListOfFoos) > > Which of course works fine. > > What am I missing here? > > Thanks, > > -scott > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From donn at u.washington.edu Mon Dec 13 12:41:32 1999 From: donn at u.washington.edu (Donn Cave) Date: 13 Dec 1999 17:41:32 GMT Subject: Old-timer UN*X trivia [was Re: Error confusing a newbie] References: <19991210100320.B18389@dmcom.net> <19991211161917.C27756@dmcom.net> Message-ID: <833b4c$dn4$1@nntp6.u.washington.edu> Quoth grant at nowhere. (Grant Edwards): | In article , Mitchell Morris wrote: |>>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. Yes, usually, but it's not UNIX per se, it's up to the application that actually tries to execute the file. First thing is usually an execve(2), and at this point the UNIX magic number either works or doesn't. If it doesn't, execve() returns an error and the application decides what to do. Some, probably all, Bourne shells try to interpret the script themselves. The C Shell looks for a lone "#" at the top and uses that to decide whether to try to interpret the script, or run the Bourne shell on it. I think "rc" just reports an error. | >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. Right. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From m.faassen at vet.uu.nl Fri Dec 3 07:17:30 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Dec 1999 12:17:30 GMT Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> Message-ID: <828ccq$jai$2@newshost.accu.uu.nl> Raymond Sheffield wrote: > 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. Oh come on. Did you really think the *real* Tim Peters entity would show up? Of course it'll hire an actor to *play* Tim Peters. We-can-easily-find-out-as-he'll-look-so-normal-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From Dom at myrddin.demon.co.uk Tue Dec 7 02:07:39 1999 From: Dom at myrddin.demon.co.uk (Dominic Mitchell) Date: 07 Dec 1999 07:07:39 +0000 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: <874sdvmdok.fsf@myrddin.demon.co.uk> "Austin Wilson" writes: > What is the command for copying file1 to file3 (eg equivalent to cp file1 > file3) and creating a soft link to a file (eg ln -s file2 file1)? os.system("cp file1 file2") os.system("ln -s file2 file1") Well, that's an almost exact duplicate of what the shell does. :-) More seriously, try this: # Copy a file. You may like to use a couple of temp. vars. open('file2').write(open('file1').read() # Symlink a file. os.symlink('file2', 'file1') Note that the latter is dependent on being run on a Unix box. Generally, python's system programming interface closely follows that of C (except where it doesn't, so have a go at reading the manual pages under sections 2 and 3, then try searching for that in the python manual. -Dom From grant at nowhere. Thu Dec 9 17:50:43 1999 From: grant at nowhere. (Grant Edwards) Date: Thu, 09 Dec 1999 22:50:43 GMT Subject: use map() to call object methods? Message-ID: If I've got a list of objects "objList", all of which implement a method named "get", and I want a list of the results of calling that method on all of the objects, is this the best way to do that? getList = map(lambda x: x.get(), objList) The alternative would be something like: getList = [] for x in objList: getList.append(x.get()) -- Grant Edwards grante Yow! You must be a CUB at SCOUT!! Have you made your visi.com MONEY-DROP today?? From mlh at vier.idi.ntnu.no Wed Dec 8 10:14:38 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 08 Dec 1999 16:14:38 +0100 Subject: JPython - Problems using "re" References: <82lh78$12h$1@rairidh.dcs.ed.ac.uk> Message-ID: Or... perhaps as a function :) import re def findall(pattern, text): p = re.compile(pattern) result = [] pos = 0 m = p.search(text,pos) while m: g = m.groups() if len(g) == 1: result.append(g[0]) else: result.append(g) pos = m.end() m = p.search(text,pos) return result I'm not sure if it duplicates re.findall exactly, but it seems to work OK... -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From martineg at ifi.uio.no Sat Dec 4 15:03:22 1999 From: martineg at ifi.uio.no (Martin Eggen) Date: 04 Dec 1999 21:03:22 +0100 Subject: os.system References: Message-ID: * David Smead | This works in the test mode, but jeeps isn't called when executed as a | CGI. Any comments would be appreciated. | ------- here's the script called jeeps | | #!/bin/sh | date > jnkdate Perhaps because the script is running as 'nobody' or another such user when running as a CGI, which might not have write access to . -- Martin Eggen http://www.stud.ifi.uio.no/~martineg/ From paul at prescod.net Tue Dec 28 03:38:33 1999 From: paul at prescod.net (Paul Prescod) Date: Tue, 28 Dec 1999 03:38:33 -0500 Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <8483fu$ook$1@nntp5.atl.mindspring.net> Message-ID: <38687709.EC36EAC6@prescod.net> Aahz Maruch wrote: > > I think you're more likely to get somewhere with the "locking dict" idea > that others have mentioned, essentially the immutable equivalent of a > dict. An immutable dict has none of the benefits that I listed. In particular, it cannot be used as a tuple! Paul Prescod From amcguire at coastalnet.com Tue Dec 14 11:03:29 1999 From: amcguire at coastalnet.com (Andrew N. McGuire) Date: Tue, 14 Dec 1999 10:03:29 -0600 Subject: Newbie Variable Definition Question Message-ID: <38566A51.A1DFD2F6@coastalnet.com> Hey all, I am a python newbie and am picking up on it very quickly. Python seems to be a remarkably simple language to learn, however I have one question.. This is primarily oriented towards the *nix guys out there.... In Bourne / Korn / Bash shells there is the syntax... if [ $variable = "" ]; then commands fi This tests if a variable is defined, and if not, execute commands. Also there is the following statement as well.... variable=${variable:=value} This checks if variable is defined and if not, it assigns it a value of "value". 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. Any help is greatly appreciated, and thanks in advance. Regards, Andrew N. McGuire UNIX System Administrator From nikolai.kirsebom at siemens.no Wed Dec 1 03:40:23 1999 From: nikolai.kirsebom at siemens.no (Nikolai Kirsebom) Date: Wed, 01 Dec 1999 08:40:23 GMT Subject: Using wxPython in COM server Message-ID: <3844dc35.143149908@news.mch.sni.de> I have one question related to my usage of wxPython in a COM servers. I would like to have a method in my com-server which presents a dialog requesting Yes/No from the user, in principle as shown below. The method (com-server) is being used from Word97. ---------------------------- def RequestYesNo(self): from wxPython.wx import * win = wxDialog(NULL, -1, "HELLO", wxDefaultPosition, wxSize(350, 200)) wxStaticText(win, -1, "This is a wxDialog", wxPoint(20, 20)) wxButton(win, wxID_OK, " OK ", wxPoint(75, 120), wxDefaultSize).SetDefault() wxButton(win, wxID_CANCEL, " Cancel ", wxPoint(200, 120), wxDefaultSize) val = win.ShowModal() return val ---------------------------- I manage to get the dialog presented, but at the same time I get an application error in winword.exe (The instruction at "0x...." referenced memory at "0x0000000". The memory could not be "read".) When I select OK in the application error message box, my dialog is completely painted (static text and buttons), and I get e new message box from the runtime library of Microsoft Visual C++ (Runtime error! Program: C:\Program.....\Winword.exe abnormal program termination). Does anyone have any idea what the problem is. A friend of mine (who's not familiar with the Python environment) though it could have something to do with the message loop being executed when my dialog is presented dispatches some events that Word does not 'like'. Thanks Nikolai Kirsebom Environment: NT4 SP 5, Python 1.5.2b, PythonWin 127, wxPython 2.1.11 From kc5tja at garnet.armored.net Sat Dec 4 22:15:27 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 5 Dec 1999 03:15:27 GMT Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD81@gandalf.digicool.com> Message-ID: >CORBA still seems to be more mature. The only reason to use COM is, >if you want to interoperate with the Microsoftproduct world. Nope. COM is not Windows specific; ActiveX is. What's more, COM is much, much easier to use than CORBA (I've used both), much much easier to implement, and far easier to debug. That is why COM is so popular today. (There are plenty of technologies that Microsoft introduced but weren't adopted, even on Windows, despite their attempts to strong-arm, so please don't give me this argument.) >Why not stick with CORBA and SOAP, where needed? :) Because CORBA is a major pain in the ass to use, and it's voraciously resource hungry? -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From g_will at cyberus.ca Fri Dec 3 08:29:27 1999 From: g_will at cyberus.ca (Gordon Williams) Date: Fri, 03 Dec 1999 13:29:27 GMT Subject: Using wxPython in Tkinter? Message-ID: <01bf3d92$45925240$1c41c3d1@Cyberus.cyberus.ca> Hi All, I have an interface built in Tkinter with a whole bunch of buttons and other widgets as well as a canvas area where I am doing some plotting (an oscilloscope application). I am finding that the plotting is taking too long using Tkinter because of the number of points in each line. I would like to change the plotting aspect to wxPython (or something else of equivalent speed) but would like to retain the buttons, etc. in Tkinter. The reason for retaining Tkinter is twofold: because I don't want to have to rewrite the whole thing; and I make use of check and radio buttons in depressed button style and these are not available in wxPython (without some work and complication). Is it possible that both Tk and wx can co-exist in the same application with both parts of the interface functioning as they should? Thanks, Gordon Williams From da at ski.org Wed Dec 1 14:14:44 1999 From: da at ski.org (David Ascher) Date: Wed, 1 Dec 1999 11:14:44 -0800 (Pacific Standard Time) Subject: XML tool status? In-Reply-To: <38455AA6.79D5D42C@mchp.siemens.de> Message-ID: On Wed, 1 Dec 1999, Alan Robinson wrote: > "Andrew M. Kuchling" wrote: > >........ > > The code's been developed subsequently, and the CVS tree is much more > > recent. > > Is there any chance of an update as some of us can't quite > get at the CVS tree. Your (implied) wish is my command: http://starship.python.net/crew/da/xmldists/ has a snapshot of the XML CVS tree, which will be updated nightly. --david ascher From aa8vb at yahoo.com Tue Dec 14 07:18:20 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Tue, 14 Dec 1999 07:18:20 -0500 Subject: GTK choking on wxPython In-Reply-To: <385586DF.5153D1F0@win.tue.nl> References: <385586DF.5153D1F0@win.tue.nl> Message-ID: <19991214071820.A78767@vislab.epa.gov> Bas van der Linden: |Matt Gushee wrote: | |> Platform: Red Hat Linux 5.2 (kernel 2.0.36, glibc 2.0.7) |> GTK: 1.2.1 |> Python: 1.5.2 |> wxWindows: wxGTK 2.1.11 |> wxPython: 2.1.11 ... |> Please don't tell me I have to upgrade GTK (unless it's true ;-). I |> hate upgrading GTK. | |I don't want to spoil your day, but on the wxWindows mailing list they |were discussing an error in the configure scripts: it requires only gtk |1.2.1 but some code it uses can actually only be found in the more recent |editions of gtk. In case it is version-related, I'll give you a datapoint. No problems here with wxGTK-2.1.11, wxPython-2.1.11, and Glib/GTK 1.2.6. Whether GTK 1.2.6 vs. 1.2.1 is the key, I don't know. -- Randall Hopper aa8vb at yahoo.com From fredrik at pythonware.com Thu Dec 30 04:55:34 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 30 Dec 1999 10:55:34 +0100 Subject: why? References: <38685b07.189574443@news.isomedia.com> Message-ID: <00b801bf52ac$7f909ea0$f29b12c2@secret.pythonware.com> 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. From ivanlan at callware.com Wed Dec 8 15:06:35 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Wed, 08 Dec 1999 13:06:35 -0700 Subject: X display visual References: <384C39EE.6B5921EC@callware.com> <14412.15539.879016.832154@weyr.cnri.reston.va.us> <384C39EE.6B5921EC@callware.com> <19991208141839.A3847@vislab.epa.gov> Message-ID: <384EBA4B.CC68FBD7@callware.com> Hi All-- Randall Hopper wrote: > [snip] > |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? > > Yes. Frame and Toplevel widgets have visual and colormap resources which > can be set. Here is some simple code that just deals with 8bpp pseudo and > 24bpp true. > > --------------------------------------------------------------------------- > root = Tk() > root.wm_withdraw() > > # Determine the depth, if non specified > if depth: assert depth in [ 8, 24 ] > else: depth = root.winfo_depth() > > # Just force 24-bit > depth = 24 > > if depth == 8: visual = "pseudocolor 8" > else: visual = "truecolor 24" > > main = Toplevel( root, visual=visual ) > --------------------------------------------------------------------------- > > Stack your widgets under 'main' rather than 'root'. > > To be more robust, pick a visual returned by: > > root.winfo_visualsavailable() > > As you suggested, selecting the proper visual is the best solution (as > opposed to forcing the user to reconfigure the default depth of their X > server). > 1) I don't follow the logic in solution 1, above: it looks like you're forcing the depth to 24 regardless of whatever you find out. 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: Traceback (innermost last): File ".\ccube.py", line 212, in ? x = root.winfo_visualsavailable() File ".\Tkinter.py", line 429, in winfo_visualsavailable return map(parseitem, data) File ".\Tkinter.py", line 428, in parseitem return x[:1] + tuple(map(getint, x[1:])) TypeError: illegal argument type for built-in operation I put a temporary print into Tkinter.py: def winfo_visualsavailable(self, includeids=0): data = self.tk.split( self.tk.call('winfo', 'visualsavailable', self._w, includeids and 'includeids' or None)) print data # <== Temp print def parseitem(x, self=self): return x[:1] + tuple(map(getint, x[1:])) return map(parseitem, data) Before getting the exception, it prints "truecolor 16" for the data--i.e., just a plain old string. On Linux, the same call returns a list of tuples: [('pseudocolor', 8), ('directcolor', 8), .... and works fine. I ended up just putting a quick check in to find out the depth, and if it's less than 16 I modify the number of colors the program asks for. -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 mikael at isy.liu.se Wed Dec 1 12:36:22 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 01 Dec 1999 18:36:22 +0100 (MET) Subject: Python complaints In-Reply-To: <3845360D.B816DFE6@maxtal.com.au> Message-ID: On 01-Dec-99 skaller wrote: > OK. I implemented the following operators last night in Viper: > > += -= *= /= %= <<= >>= |= &= ^= := ++ -- > (i.e. all the 'C' assignment operators, plus := which is the same as =) I'm used to interprete <= as 'less than or equal' and << as 'much less than', so I guess <<= means 'much less than or equal'. :-) /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 01-Dec-99 Time: 18:32:21 This message was sent by XF-Mail. ----------------------------------------------------------------------- From wjk at wjk.mv.com Thu Dec 2 00:38:05 1999 From: wjk at wjk.mv.com (William J. King) Date: Thu, 02 Dec 1999 00:38:05 -0500 Subject: Newbie: switch question in Python Message-ID: <384605BC.56EAB34E@wjk.mv.com> Hi again! I was reading a tutorial that said there was no switch statement in Python...and that I could use a 'conditional' if else etc. -- so I wrote a switch and would like to know if its ok to do this or if you have any other better ideas... Thanks to all for their help in learning Python in the past 2 weekends.... #Python command 'switch' based #on a dictionary with commands that #follow indention rules...... switch = {1: 'for m in range(1,3):\n\t\tprint m\n', 4: 'for m in range(4,7):\n\t\tprint m\n', 3: 'for m in range(9,11):\n\t\tprint m\n', 6: 'print "Key", m, "was found here!"'} for q in range(0,7): try: exec switch[q] except: print "Sorry, not in command_list" From megera at mira.sai.msu.su Tue Dec 7 16:21:34 1999 From: megera at mira.sai.msu.su (Oleg Bartunov) Date: 7 Dec 1999 21:21:34 GMT Subject: undefined reference to __pthread_detach' (Linux libc5, Python 1.52) Message-ID: Hello, I tried to built Python 1.52 with thread support (pth v.1-2.1) on my Linux 2.2.13 libc5 system but get error message at linking stage (long lines are wrapped): ../libpython1.5.a(thread.o): In function `PyThread_start_new_thread': /u/megera/app/arc/Python-1.5.2/Python/thread_pthread.h:161: undefined reference to `Pthread_create' /u/megera/app/arc/Python-1.5.2/Python/thread_pthread.h:185: undefined reference to `__pthread_detach' But 0:22[om]:~/app/arc/Python-1.5.2>nm /usr/local/lib/libpthread.so | grep __pthread_detach 00005720 T __pthread_detach so, what's the problem ? I didn't subscribed to this group (well, until I get Python compiled and Zope working :-) so please reply to oleg at sai.msu.su -- Oleg _____________________________________________________________ Oleg Bartunov, sci.researcher, hostmaster of AstroNet, Sternberg Astronomical Institute, Moscow University (Russia) Internet: oleg at sai.msu.su, http://www.sai.msu.su/~megera/ phone: +007(095)939-16-83, +007(095)939-23-83 From mlh at vier.idi.ntnu.no Tue Dec 7 16:55:21 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 07 Dec 1999 22:55:21 +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> <82jkol$kl2$1@hub.org> Message-ID: "D'Arcy J.M. Cain" writes: > 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? Because if there is a primitive (like the system command cp) for copying, I guess it might be more effective than reading it all into memory and then writing it to disk... > 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. -- 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 Mon Dec 13 16:23:49 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 13 Dec 1999 22:23:49 +0100 Subject: Parsing strings from files. Message-ID: <19991213222349.A4593@stopcontact.palga.uucp> Hello, consider the following file: ### cut here ### foo="this is an easy-to-parse string" bar='''this string, containing ", ' and newlines like this, is a little harder to parse''' foobar='this "\'string\'" is \'\'\'hard'+' '+'to parse' ### cut here ### I want to parse the string literals from a file, so I want to get a dict like this: { 'foo': 'this is an easy-to-parse string', 'bar': 'this string, containing ", \' and newlines like\n\n\nthis, is a little harder to parse', 'foobar': 'this "\'string\'" is \'\'\'hard to parse' } I want this because I've got a user configuration file, and because some strings are very long and contain newlines, I don't want to be the file newline delimited. I want to have the same string rules as Python has; so the code exists. I just want to reuse it. But how? regards, Gerrit. -- Writing unreadable Python code is easy: >>> exec 'exec \'print \\\'\\\\\\\\\\\'\'' \ From hnowak at cuci.nl Mon Dec 20 02:13:42 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Mon, 20 Dec 1999 08:13:42 +0100 Subject: . pythondx In-Reply-To: Message-ID: <199912200716.HAA03056@dionysus.fw.cuci.nl> On 19 Dec 99, at 9:17, Al Aab wrote: > for native dos : > > any1 knows how to > exit, control-z suspend, leaving 49 k in ram. Try Ctrl-D. Ctrl-Z is a Windows-ism. :) > another problem : > the pythondx full version, has a static cursor > (the lite-version's cursor is ok. ) Hmm... What do you mean by a 'static cursor'? Veel liefs, --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 tseaver at starbase.neosoft.com Sun Dec 19 22:49:16 1999 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 20 Dec 1999 03:49:16 GMT Subject: __rcall__??? References: <002101bf4a98$01eda860$922d153f@tim> Message-ID: In article <002101bf4a98$01eda860$922d153f at tim>, Tim Peters wrote: >[David C. Ullrich] >> So why isn't there a magic __rcall__, that would go with >> __call__ like the other __rop__'s go with __op__? >> >> It seems useful to me to allow x to alter the way f behaves >> when you call f(x); ... > >Probably for the same reason there's no __rgetitem__ for the benefit of the >millions of programmers who want > > x[i] > >to use x as an index into sequence i . That is, AFAIK nobody ever >asked for it before, and it's not screamingly natural (you're not really >*surprised* at the lack of __rcall__, right?). Smells like Visitor/multimethods/DoubleDispatch to me, and it _is_ a vacuum which people code around, in most languages except Lisp and its progenty; David is apparently the first to propose this particular solution (quite Pythonic, it seems to me, only adding slots to the jump table is not likely to win wide support). >better-hope-for-santa-to-do-it-cuz-i-doubt-guido-will-ly y'rs - tim Looking-hopefully-for-sinterklaas'ly, Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From fredrik at pythonware.com Fri Dec 10 09:10:05 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 10 Dec 1999 15:10:05 +0100 Subject: Tkinter/IDLE crash References: <82pkpk$3o0$1@mirv.unsw.edu.au> Message-ID: <004601bf4318$45033f20$f29b12c2@secret.pythonware.com> Simon Evans wrote: > self.button = Button(frame, text="QUIT", fg="red", command=frame.quit) > self.button.pack(side=LEFT) > > 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. what happens if you change frame.quit to frame.destroy? From tholap at compuserve.com Fri Dec 10 15:32:52 1999 From: tholap at compuserve.com (Olaf Appelt) Date: Fri, 10 Dec 1999 21:32:52 +0100 Subject: newbie needs help on dictionary References: <38504788.86E9C885@es.co.nz> <82qklq$qsu$2@ssauraaa-i-1.production.compuserve.com> <022001bf42fe$d6bed420$f29b12c2@secret.pythonware.com> Message-ID: <82ro5d$9n1$3@ssauraab-i-1.production.compuserve.com> > > 'count' is not a copy of 'turret[station][tool_name]', it's a reference. > > So the following should result in the same thing: > > nope. > > > > count = turret[station][tool_name] > > after this statement, "count" is a reference. > > > > count = count + 1 > > but after this statement, "count" is rebound to > point to a newly created integer object. the > dictionary still points to the *original* value. I see. Thanks for the correction. Olaf From gerrit.holl at pobox.com Thu Dec 2 14:30:08 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 2 Dec 1999 20:30:08 +0100 Subject: A Date With Tim Peters... In-Reply-To: <825nbt$p50@mail.psy.uva.nl>; from ionel@psy.uva.nl on Thu, Dec 02, 1999 at 01:04:56PM +0100 References: <199912020003.TAA13009@eric.cnri.reston.va.us> <825nbt$p50@mail.psy.uva.nl> Message-ID: <19991202203008.A7698@stopcontact.palga.uucp> 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... regards, Gerrit. -- "The world is beating a path to our door" -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates) 8:27pm up 7:00, 14 users, load average: 1.24, 1.24, 1.20 From gmcm at hypernet.com Tue Dec 28 11:41:05 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: 28 Dec 1999 16:41:05 GMT Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 28) Message-ID: <9A29DD15378F8BE8.9D1111FFDBB080F0.3E3244C13684F1DB@lp.airnews.net> The holiday week brought Pythondom three nice new shiny packages: Markus F.X.J. Oberhumer announces that Version 3.10 of PySol is here (128 solitaire card games in one!): http://wildsau.idv.uni-linz.ac.at/mfx/pysol.html Kevin Dahlhausen announces pyhints - a script that scans Python source and builds a hint script for VIM (prompts you with function signatures): http://www.deja.com/getdoc.xp?AN=563701938 Paul Sheer announces KOALA 0.9.0, a database / GUI forms package for postgres and Gnome (uses Python 1.5.1): http://www.deja.com/getdoc.xp?AN=565059802 Bernard Herzog uncovers the reason why maintaining two Python installations on Linux is difficult: http://www.deja.com/getdoc.xp?AN=563559697 Ng Pheng Siong provides a nice overview what must be done to use urllib with differnt sorts of firewalls: http://www.deja.com/getdoc.xp?AN=563817592 In the Windows / COM world, we got two nice overviews: Eugene Goodrich provides hints for those doing ASP coding: http://www.deja.com/getdoc.xp?AN=564839534 John Nielsen (via Mark Hammond) offers help to those stuck with administering Exchange on NT (or using Python/COM with ADSI): http://www.deja.com/getdoc.xp?AN=563607231 Andrew M. Kuchling updates his "Python warts" page to reflect the most recent rounds of discussion on Python's shortcomings: http://starship.python.net/crew/amk/python/warts.html ======================================================================== 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 The Vaults of Parnassus ambitiously collects Python resources http://www.vex.net/~x/parnassus/ 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 slinkp at angelfire.com Wed Dec 29 14:30:04 1999 From: slinkp at angelfire.com (Paul Winkler) Date: Wed, 29 Dec 1999 14:30:04 -0500 Subject: Anyone else making music with python? References: <386115AB.A0DD3F6@angelfire.com> <01bf4e90$25820b80$053abcc3@brancusi.pro-net.co.uk> Message-ID: <386A613C.2F9F81B@angelfire.com> Jason Cunliffe wrote: > > No not crazy at all - it is a shame that there is so little media or art > being done in Python. > > Not had time to look at your work yet, but in case you don't already know > about about it, I suggest to take a good look at Tim Tompson's wonderful > 'KeyKit': I should really have a look there. Part of my problem is that I'm both a novice programmer and a habitual wheel-re-inventer... I end up doing things like this without properly exploring what exists already! thanks for the tip, --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 c.kotsokalis at noc.ntua.gr Thu Dec 30 09:42:24 1999 From: c.kotsokalis at noc.ntua.gr (Constantinos A. Kotsokalis) Date: 30 Dec 1999 14:42:24 GMT Subject: a word of advice Message-ID: I do not know if this has been said in any of these two groups before, but here's a bit of advice: If you try to compile ctsybase python module to use with Sybase under Linux (or any other OS, for that matter) and get a core dump when you try to import it (doesn't matter if it's statically linked or a dynamic module), make sure your locale (LC_ALL env. variable) is available in sybase's locales file (locales/locales.dat). It took me some three hours yesterday night to locate the problem (thanks, redhat, for stripping the python executable and cut the way to valuable debugging information :-)). If your locale is not available, either change locale or add it to the locales file as an ``alias''. Regards, Costas PS: I wonder why isql worked... -- Constantinos A. Kotsokalis || c.kotsokalis at noc.ntua.gr National Technical University of Athens Network Management Center Tel. No: +30 1 7721861 From gerrit.holl at pobox.com Tue Dec 21 10:05:35 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 21 Dec 1999 16:05:35 +0100 Subject: Diffs In-Reply-To: ; from bernhard@alpha1.csd.uwm.edu on Mon, Dec 20, 1999 at 09:30:58PM +0000 References: <19991218223342.A11575@stopcontact.palga.uucp> Message-ID: <19991221160535.B2087@stopcontact.palga.uucp> Bernhard Reiter wrote: > On Sat, 18 Dec 1999 22:33:42 +0100, Gerrit Holl wrote: > >where should I send diffs? > > Depends on the diff. 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...? regards, Gerrit. -- "Open Standards, Open Documents, and Open Source" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 4:04pm up 31 min, 3 users, load average: 0.00, 0.00, 0.02 From robin at jessikat.demon.co.uk Fri Dec 3 10:25:24 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Fri, 3 Dec 1999 15:25:24 +0000 Subject: Using wxPython in COM server References: <3844dc35.143149908@news.mch.sni.de> Message-ID: In article , Robin Dunn writes ... >At a minimum, you might try something like this: > > def RequestYesNo(self): > from wxPython.wx import * > class MyApp(wxApp): > def OnInit(self): > return true > app = MyApp(0) > > win = wxDialog(NULL, -1, "HELLO", wxDefaultPosition, wxSize(350,200)) > wxStaticText(win, -1, "This is a wxDialog", wxPoint(20, 20)) > wxButton(win, wxID_OK, " OK ", wxPoint(75, >120),wxDefaultSize).SetDefault() > wxButton(win, wxID_CANCEL, " Cancel ", wxPoint(200, 120),wxDefaultSize) > val = win.ShowModal() > win.Destroy() > return val > > >Although I am not sure what you might lose by not getting into the >app.MainLoop... > ... I tried this snippet and it works the first time, but complains about only being allowed one app per process. How do I shut down wxPython cleanly and later restart it? -- Robin Becker From gerrit.holl at pobox.com Mon Dec 20 16:05:20 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Mon, 20 Dec 1999 22:05:20 +0100 Subject: First Tkinter application. Comments please? Message-ID: <19991220220520.A7846@stopcontact.palga.uucp> Hello, I just created my first Tkinter.Canvas application. Can someone please be kind enough to comment on the code? Maybe my ``problem'' could be solved much easier... # cut here from Tkinter import * UP = 98 # keycodes LEFT = 100 RIGHT = 102 DOWN = 104 class App: id = 0 def __init__(self, root): self.root = root self.draw = Canvas(self.root, width=400, height=400) self.draw.create_oval(0, 0, 10, 10, tags="it", fill="blue") self.draw.pack() # What's better: this, or binding and ignoring everything # that's not a keycode of one of these? self.root.bind("", self.move_it) self.root.bind("", self.move_it) self.root.bind("", self.move_it) self.root.bind("", self.move_it) self.root.mainloop() def move_it(self, *args): # Because bind gives an argument, which I will always need, but # after doesn't give the argument. if len(args): self.dir = args[0] if self.dir.keycode == UP: self.draw.move("it", 0, -1) elif self.dir.keycode == DOWN: self.draw.move("it", 0, 1) elif self.dir.keycode == RIGHT: self.draw.move("it", 1, 0) elif self.dir.keycode == LEFT: self.draw.move("it", -1, 0) # Because otherwise, it gets called twice as many times. if self.id: self.root.after_cancel(self.id) self.id = self.root.after(10, self.move_it) App(Tk()) # cut here If the code is ``good'' (I don't think it is), it might suit well for an example in the Demo/tkinter/ dir. It costed me very much time to find out how I had do do the after_cancel. I looked in the source, saw the method and thought "what is the argument? "it"? "move_it"?". I ended up looking in the source of idle. I think that if this example is OK, it's a good example of using keycodes and preventing the 'self.root.after(...)' to be executed too much. regards, Gerrit `who loves Tkinter now he finally understands it'. -- "The IETF motto is 'rough consensus and running code'" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 9:54pm up 7:39, 10 users, load average: 0.05, 0.05, 0.01 From boncelet at udel.edu Tue Dec 14 06:13:25 1999 From: boncelet at udel.edu (Charles Boncelet) Date: Tue, 14 Dec 1999 11:13:25 +0000 Subject: Python complaints References: <000201bf3bd4$2bda5e20$542d153f@tim> Message-ID: <38562655.77A3B3DC@udel.edu> Grant Edwards wrote: > > 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. 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? -- Charles Boncelet University of Delaware Newark DE 19716 USA http://www.eecis.udel.edu/~boncelet/ From felixt at dicksonstreet.com Mon Dec 20 02:31:51 1999 From: felixt at dicksonstreet.com (Felix Thibault) Date: Mon, 20 Dec 1999 01:31:51 -0600 Subject: question about using the same vs. identical strings for keys Message-ID: <3.0.5.32.19991220013151.0089d6e0@mail.dicksonstreet.com> My basic question is: If I have a large nested dictionary whose keys are different slices of a large string, which are all in a much smaller set of strings, is there an advantage to building my dictionary like: dict[names[text[leftslice:rightslice]]] = value instead of: dict[text[leftslice:rightslice]] = value so that all keys 'spam' use the same string instead of identical ones? Thanks- Felix Here are the details: I have a class which takes in an html document like: #test.html------------------------------------------------ T E S T D O C

This is only a test

  • This is only a list
  • Me too!
and returns a UserDict object like: {'html': {'': (0, 28), 'body': {'': (10, 24), 'h1': {'': (12, 14)}, 'ul': {'': (16, 22), 'li': {1: {'': (20, 20)}, 0: {'': (18, 18)}}}}, 'head': {'title': {'': (4, 6)}, '': (2, 8)}}} where the ''s are the indexes of the tuples in a TextTools taglist that go with and (if it exists). The dictionary is made by recursion over a list like [ ['html', 0, 28],...]. Originally I made the lists in this list from the slice of the document where the tagname is: name = lowertext[tagtuple[3][0][1]:tagtuple[3][0][2]] but since the TextTools documentation of the tagging engine begins "Marking certain parts of a text should not involve storing hundreds of small strings," this always bothered me. I already had a function that returned a dictionary with all the html tag names and using it to change the line above to: name = id[lowertext[tagtuple[3][0][1]:tagtuple[3][0][2]] didn't seem to cost me anything, performance-wise, but it didn't speed anything up either and it made the code a little less straightforward. The document I've been using for benchmarking has 998 tags, and about 20 tagnames. Am I gaining anything by making the dictionary the new way versus the original way? From aahz at netcom.com Thu Dec 16 11:31:56 1999 From: aahz at netcom.com (Aahz Maruch) Date: 16 Dec 1999 16:31:56 GMT Subject: Python complaints References: <3858C226.949FC9C6@udel.edu> <3858FEA3.E593F38C@callware.com> Message-ID: <83b45s$lp4$1@nntp1.atl.mindspring.net> In article <3858FEA3.E593F38C at callware.com>, Ivan Van Laningham wrote: >Charles Boncelet wrote: >> >> What kind of number is allowed? Can x be an integer, a float, complex, >> long, hex? There is no way to know, without doing the experiment. >> BTW, experimentation indicates that it fails if x is complex and works >> for the others. sin seems to be promoting its argument to a float and >> taking the sine. However, sin(complex) is a perfectly good mathematical >> operation. It should work. > >Use > import cmath > >and > s=cmath.sin(c) > >All of the standard math functions that live in math.py have >correspondent functions in cmath.py. That's precisely the problem Charles was complaining about -- how the heck are you supposed to know this? And why should you need to know this? (I actually know the answer to the latter question, but I figure the Timbot has nothing better to do.... ;-) -- --- 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 skaller at maxtal.com.au Sun Dec 12 00:00:30 1999 From: skaller at maxtal.com.au (skaller) Date: Sun, 12 Dec 1999 16:00:30 +1100 Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> <3843D685.C8C13355@maxtal.com.au> Message-ID: <38532BEE.6D0376FB@maxtal.com.au> Manuel Gutierrez Algaba wrote: > > On Wed, 01 Dec 1999 00:52:05 +1100, skaller wrote: [mutable integers in Viper] > I'm really glad of your effort producing Viperi. Perhaps , I'd even > become a Viperi user some day. Specially it's worth the effort of > providing a better Garbage collector,... Actually, providing the collector required no effort at all for me, since it is already part of the implementation language's run time system. > But I don't like this kind of C-like short expresions, and furthermore > it seems that you give the Integer a new Object life, but then > you start treatign them like Integers again or worse , like pointers. > > x.inc() would be more acceptable. The actual implementation follows Tim Peter's suggestion that references NOT be used. Also, they're not expressions: x = y++ # NOT ALLOWED The operators are all shorthands for assignments, and can only be used as statements: y++ # OK, same as y = y + 1 [BTW: the first release of Viper has been posted to incoming on ftp.python.org, it hasn't made the download section yet] -- 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 mlh at vier.idi.ntnu.no Mon Dec 6 19:53:57 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 07 Dec 1999 01:53:57 +0100 Subject: About PIL References: <007601bf3fe5$6f11c740$f29b12c2@secret.pythonware.com> Message-ID: mlh at vier.idi.ntnu.no (Magnus L. Hetland) writes: > Is PIL written entirely in Python, or is there a C module lurking in there? Found out myself. Sorry I asked. Am tired. Sleep now. :) -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From tony.mcdonald at ncl.ac.uk Fri Dec 3 09:13:04 1999 From: tony.mcdonald at ncl.ac.uk (Tony McDonald) Date: Fri, 03 Dec 1999 14:13:04 +0000 Subject: Is there a proxy-enabled version of httplib.py anywhere? References: <009801bf3d8c$3e2ff7b0$f29b12c2@secret.pythonware.com> Message-ID: > 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). > > > > Sorry Fredrik, I wasn't explicit enough! I'm ok with using urllib and environment variables, it's just that other programs I'm using are explicitly including httplib and doing things like; h=httplib.HTTP(host) which then goes nowhere. Or am I missing something really obvious here? (it wouldn't be the first time I've done that...) many thanks, Tone. From greg.ewing at compaq.com Mon Dec 13 08:17:34 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 14 Dec 1999 02:17:34 +1300 Subject: Dot product? References: <3852B91D.6EE31805@math.okstate.edu> <3854CBFF.85A69AA@compaq.com> Message-ID: <3854F1EE.3CA02CD6@compaq.com> "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". > > 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 :-( Greg From dan at control.com Wed Dec 15 10:46:43 1999 From: dan at control.com (Dan L. Pierson) Date: Wed, 15 Dec 1999 10:46:43 -0500 Subject: Declaring COM-interfaces in Python? References: <38562ebd.0@pandora.research.kpn.com> <3856bffe.121727274@judy> Message-ID: rurban at xarch.tu-graz.ac.at (Reini Urban) wrote: > And dispinterfaces? Here's a working example of a dispinterface implemented in Python: class SymbolConflictHandler: '''COM object that implements the DIqsMergeProblem interface. This interface is used by IqsProgram::MergeClipData to report errors in the merge that may be correctable by the client. ''' # This member makes an instance of this class wrappable as a COM object # using the default dispatch policy. _public_methods_ = [ 'SymbolConflict' ] error_dict = { LE_HRESULTS.QST_E_DUPLICATE_STEP : 'Duplicate step name', LE_HRESULTS.QST_E_DUPLICATE_NAME : 'Symbol name in use', LE_HRESULTS.QST_E_DUPLICATE_VALUE : \ 'That value already has a name' } def SymbolConflict(self, Why, ClipName, ClipType, ClipValue, ClipSpecial, ExistName, ExistType, ExistValue, ExistSpecial): if Why == LE_HRESULTS.QST_E_DUPLICATE_VALUE: return ExistName else: return self._PrefixSymbol(ClipName) def _PrefixSymbol(self, name): global _conflict_counter _conflict_counter = _conflict_counter + 1 prefix = Registry.ProgramOptions.GetVal('Duplicate Symbol Prefix') newName = '%s%d_%s' % (prefix, _conflict_counter, name) if len(newName) > 40: return newName[:39] else: return newName Passing this to the client looks like: from win32com.server import util #, policy, dispatcher handler = util.wrap(SymbolConflictHandler()) self.hFirst, self.hLast = self.program.MergeClipData(self.pasteBin, 0, self.refNode, self.before, handler) It looks like Agent is forcing a bunch of bogus line breaks in here, sorry. Dan Pierson, Control Technology Corporation dan at control.com From tim_one at email.msn.com Tue Dec 7 00:22:10 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 7 Dec 1999 00:22:10 -0500 Subject: A Date With Tim Peters... In-Reply-To: <8896A98247CD6C6E.947A4F75CB4B059F.612EA19A444D5899@lp.airnews.net> Message-ID: <001801bf4073$033e6260$88a0143f@tim> [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 :) > > A-zero-by-any-other-sign'ly, >>> import math >>> zero = 0.0 >>> math.atan2(zero, zero) 0.0 >>> zero = -zero >>> math.atan2(zero, zero) -3.14159265359 >>> That is, IEEE-754 mandates signed zeroes too, in part so that an underflow "remembers which direction it came from". cdc-was-ahead-of-its-time-ly y'rs - tim From tim_one at email.msn.com Sun Dec 19 22:12:11 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 19 Dec 1999 22:12:11 -0500 Subject: __rcall__??? In-Reply-To: <385BD126.CB698A38@math.okstate.edu> Message-ID: <002101bf4a98$01eda860$922d153f@tim> [David C. Ullrich] > So why isn't there a magic __rcall__, that would go with > __call__ like the other __rop__'s go with __op__? > > It seems useful to me to allow x to alter the way f behaves > when you call f(x); ... Probably for the same reason there's no __rgetitem__ for the benefit of the millions of programmers who want x[i] to use x as an index into sequence i . That is, AFAIK nobody ever asked for it before, and it's not screamingly natural (you're not really *surprised* at the lack of __rcall__, right?). better-hope-for-santa-to-do-it-cuz-i-doubt-guido-will-ly y'rs - tim From ivanlan at callware.com Tue Dec 14 00:08:00 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 13 Dec 1999 22:08:00 -0700 Subject: Need help with Tkinter References: <8342a8$1td$1@nnrp1.deja.com> Message-ID: <3855D0B0.5B7DB8DA@callware.com> Hi All-- rodzilla2000 at my-deja.com wrote: > > I'm trying to learn python/Tkinter... > > I tried modifying the hello.py script that guido included in the 1.5.2 > source. > > Here's what I was trying to do (to learn while tinkering...) > > Change the "Hello World" button a "Add Exit Button" that would put > another button on the screen to allow exiting the program. > > Add the additional exit button... > > Here's the code: > #!/usr/local/bin/python # Button test... import sys from Tkinter import * #main routine def main(): global root # Added root=Tk() btnAddButton=Button(root) btnAddButton['text']='Add Exit Button' btnAddButton['command']=subAddButton # You must mention subAddButton, not call it btnAddButton.pack() #start mainloop root.mainloop() #<=== You must call mainloop, not just mention it. def subAddButton(event=0): global root # Added btnExitButton=Button(root) btnExitButton['text']='Exit Program' btnExitButton['command']=subExit #see below btnExitButton.pack() def subExit(): sys.exit(0) #execute the main routine main() ===========END OF CODE subAddButton is the function object; subAddButton() _calls_ the function object. If you say btnAddButton['command']=subAddButton(root) you are calling the function. Since the function has been called, naturally it makes the button appear before you tell it to. Since you can't control what parameters are passed to command functions, you have to make the root window a global (otherwise, only main() can see it) so that it can be seen inside the subAddButton() function. Finally, you need to call root.mainloop(); when you do so, it doesn't end until you push the exit button. If you only mention the name, the main() function just returns, and exits the program. I don't know how it ran on your system; pure bad luck, I guess. You'd do better to organize your program as a class; then you don't have to pepper your callbacks with global this, global that. -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 tjg at avalongroup.net Mon Dec 20 17:58:06 1999 From: tjg at avalongroup.net (Timothy Grant) Date: Mon, 20 Dec 1999 14:58:06 -0800 Subject: Python/Python Windows/PostgreSQL/ODBC Message-ID: <385EB47E.B1DE547B@exceptionalminds.com> Hi The subject says it all. Got a project that involves Python: I currently run Python under Linux and connect to a PostgreSQL database with no problems using PyGreSQL. I now need to access the very same database from a Windows 98 box. This is my first stop down this road, so any guidance would be greatly appreciated. Do I rely on ODBC, or are there better methods of access available? If I rely on ODBC, are there any "Gotchas" I gotta watch out for? Thanks. -- Stand Fast, tjg. Timothy Grant tjg at exceptionalminds.com Chief Technology Officer www.exceptionalminds.com Red Hat Certified Engineer office (503) 246-3630 Avalon Technology Group, Inc. fax (503) 246-3124 >>>>>>>>>>Exceptional Minds, Innovative Products<<<<<<<<<< From ivanlan at callware.com Tue Dec 7 19:41:29 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 07 Dec 1999 17:41:29 -0700 Subject: Python/cgi Was: Very useful message -- Hah! References: <199912052201.RAA11142@mail3.mia.bellsouth.net> <3854a300.15783926@news.demon.co.uk> Message-ID: <384DA939.1BC5E111@callware.com> Hi All-- Andy Robinson wrote: > > dgrassi wrote: > [Very nice summary of the Recent Unpleasantness snipped] > > 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? > I believe that Mr. Grassi has taken his marbles and gone home, depriving us of the perls he strew before us. -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 kgandco at home.com Tue Dec 28 00:03:10 1999 From: kgandco at home.com (ekko) Date: Tue, 28 Dec 1999 05:03:10 GMT Subject: why? References: <386847C5.3CEB812F@earthlink.net> Message-ID: Alexander Sendzimir wrote in message news:386847C5.3CEB812F at earthlink.net... > What type of languages do you currently employ? The only language I am familiar with is QBASIC and a little HTML (if that even is a programming language). From prestonlanders at my-deja.com Thu Dec 2 12:57:32 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Thu, 02 Dec 1999 17:57:32 GMT Subject: syntax checking underway; question about catching exceptions References: <824chl$6ev$1@nnrp1.deja.com> <00ce01bf3c5e$2d1645d0$f29b12c2@secret.pythonware.com> Message-ID: <826bu2$jgv$1@nnrp1.deja.com> Very helpful, Fredrik. Thanks alot!!! I don't know what I would do without the Python newsgroup and website. Erm, probably start hacking in Perl full-time. And we don't want that, do we? ;-) ----Preston In article <00ce01bf3c5e$2d1645d0$f29b12c2 at secret.pythonware.com>, "Fredrik Lundh" wrote: > 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! > > > > -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From hat at se-46.wpa.wtb.tue.nl Tue Dec 21 11:54:16 1999 From: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) Date: 21 Dec 1999 16:54:16 GMT Subject: List comprehensions References: Message-ID: On Tue, 21 Dec 1999 11:05:57 -0500, Mike Fletcher wrote: >How about: > >[ (x*2,x/2,x**y), > for x in somelist, > for y in someotherlist, >] >Which seems to take care of most of the problems, it's got a decent sound >(especially with the commas present), is unambiguous as far as I can see, >and provides for parallel iteration. While I prefer the explicit syntax of Huh, I may be missing something, but to me it is nested in each other. Note that there is no real reason why two for-loops would not be nested in each other. For example, to create a list of tuples containing all combinations of elements of X: [ (x,y), for x in X, for y in X ] Compare it with [ x | x <- xs, x>5 ] To most people (and me included), this is res=[] for x in xs: if x>5: res = res + [x] In other words, from left to right, each element is nested in the previous one. Imho, that principle is easy to explain and very intuitive for users (you almost don't have to explain it). 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 !' For example, [ (x,y) | x and y <- xs and ys ] or in Pythonese: [ (x,y), for x and y in xs and ys ] except that the 'and' puts the user on the wrong foot, as he is automagically associating the construct with a condition. Also, the 'in', which is more or less the important part here, is not quite visible any more. 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 :-) ) Albert --- Look ma, windows without Windows !! From aa8vb at yahoo.com Wed Dec 8 15:50:01 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 8 Dec 1999 15:50:01 -0500 Subject: X display visual In-Reply-To: <384EBA4B.CC68FBD7@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> Message-ID: <19991208155001.A4994@vislab.epa.gov> Ivan Van Laningham: |Randall Hopper wrote: |> |[snip] |> |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? ... |> # Determine the depth, if non specified |> if depth: assert depth in [ 8, 24 ] |> else: depth = root.winfo_depth() |> |> # Just force 24-bit |> depth = 24 ... | |1) I don't follow the logic in solution 1, above: it looks like you're |forcing the depth to 24 regardless of whatever you find out. That's what was asked for ;-) I left the sensing in there for hysterical purposes, in case someone was interested. |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. -- Randall Hopper aa8vb at yahoo.com From holland at voicenet.com Sat Dec 25 07:34:01 1999 From: holland at voicenet.com (J. Holland) Date: Sat, 25 Dec 1999 07:34:01 -0500 Subject: Newbie: raw_input question Message-ID: When running python on Linux, how can one trap or disable the ctrl-z key combo when it is entered as a response to a raw_input statement? Thanks JIm From badzen at yifan.net Mon Dec 20 11:53:06 1999 From: badzen at yifan.net (dj trombley) Date: Mon, 20 Dec 1999 16:53:06 GMT Subject: problems with python's shell References: <83krop$s5q$1@news1.sunrise.ch> Message-ID: <385E5E6E.14BC674C@yifan.net> zigu wrote: > > Hi > I'm working with python 1.52 and tkinter (I've installed Tcl/Tk 8.0.5) under > windows NT4.0 > I start a program from a tkinter window, I capture the output in a file to > redirect it, but the python shell stays open anyway (obviously with no > output..). > Somebody knows how can I run a program direct from a tkinter window without > opening the python shell? > thanks If you mean what I think you do, you should run 'pythonw.exe' instead of 'python.exe'. The former does not create a console window. -dj Dave Trombley From gregj at ancor.com Tue Dec 7 11:48:21 1999 From: gregj at ancor.com (gregj at ancor.com) Date: Tue, 07 Dec 1999 16:48:21 GMT Subject: Python type checking? References: <82j9u8$da7$1@nnrp1.deja.com> Message-ID: <82jdoj$gg5$1@nnrp1.deja.com> In article <82j9u8$da7$1 at nnrp1.deja.com>, Arinte wrote: > 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. if (type(argvalue) == 'int'): argvalue = long(argvalue) > TIA > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From wtanksle at hawking.armored.net Tue Dec 7 23:06:32 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 8 Dec 1999 04:06:32 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> Message-ID: On 8 Dec 1999 00:33:41 GMT, Neel Krishnaswami wrote: >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. No, although variable-length argument lists are as hard to do in Forth as variable-length return lists are in Lisp. Interestingly enough, and as you might expect, variable length returns are trivial in Forth. >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. Forth doesn't have any syntax, so there are no trees to linearize. There IS a stack, though; Forth is RPN. Parens wouldn't help you. Forth is far too expressive. You'd have to use a lot of highly complex lambda expressions as well in order to represent a fairly simple forth expression via parens. And often vice versa -- it's a different way of thinking. >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.... :) That's a very amusing way to put it. Yes, I could agree with your brother. >Neel -- -William "Billy" Tanksley, in hoc signo hack From jam at quark.emich.edu Fri Dec 3 09:03:01 1999 From: jam at quark.emich.edu (Jeff) Date: Fri, 3 Dec 1999 09:03:01 -0500 Subject: Python conference accomodations In-Reply-To: References: Message-ID: <19991203090301.B2810@quark.emich.edu> On Fri, Dec 03, 1999 at 02:24:28PM +0100, Joachim Schmitz wrote: > Hi, > > I planning to attend the conference, are there alternative > (cheaper) hotels, within walking distance to the conference hotel ? Or > could some give an german resident a hint, where to look ? Our > travelagents here are not that familiar with the Arlington localities :-) > > > Mit freundlichen Gr??en > > Joachim Schmitz > > WWW-Consultant > > email: js at ac-copy.net > tel: +49-241-89491-0 > fax: +49-241-89491-29 > greetings, I would suggest checking online for rate information, especially if you need to travel to the US from overseas-- you may be able to find a package deal that suits your budget. I checked just now, and the first site I looked into, http://travel.com/ may be able to assist. it's a starting point at least. you might also try a site like http://home.netscape.com/ or http://yahoo.com/ for other ideas. hope that helps. regards, J -- || visit gfd || psa member #293 || New Image Systems & Services, Inc. From hniksic at iskon.hr Thu Dec 23 09:10:06 1999 From: hniksic at iskon.hr (Hrvoje Niksic) Date: 23 Dec 1999 15:10:06 +0100 Subject: Matching a constant string at beginning References: <14434.10917.222100.686450@weyr.cnri.reston.va.us> Message-ID: <9t9ln6lwxxd.fsf@mraz.iskon.hr> "Fred L. Drake, Jr." writes: > s = some string... > if s.startswith("Simpsons"): > do something interesting... Very cool! It's long bothered me that you can't check whether a string starts with a phrase without either consing (s[:3] == 'foo') or resorting to regexps (re.match('^foo', s)). From prestonlanders at my-deja.com Wed Dec 1 18:55:34 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Wed, 01 Dec 1999 23:55:34 GMT Subject: syntax checking underway; question about catching exceptions Message-ID: <824chl$6ev$1@nnrp1.deja.com> Hello, A big thanks to those who answered my question yesterday about doing a syntax check with compile(). I've got some code going that I've found useful, and I thought I would share it (below.) The reason that I'm posting is that I'm having a bit of trouble catching the syntax exceptions appropriately. What I want to find out is the line number / statement that caused compile to fail. If I simply do this: compile(file, "", "exec") then, upon a syntax error, the resulting traceback contains all the information I need to go in and fix the problem. However, the program is aborted at that point, and I can't do any post-processing or check any of the remaining python files. 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. I can't figure out how to get what I want! You would think that all the information I need would be in the tb object, because if I don't wrap compile() in a try: except: all that information *is* in the traceback. What's going on? Below is the program I'm using to do a simple python syntax check. I put a call to this at the end of my Makefile. It does currently rely on the Unix 'find' command, so if you're using a lesser OS, you will have to adapt. ;-) thanks ---Preston --------------------------------- #!/usr/bin/env python1.5 """This program does a syntax check on Python files. use -r or --recursive to delve into subdirectories (default is to only examine current dir) use -c or --continue to keep going after an error has been found. Copyright 1999 Preston Landers """ import os, sys, string, traceback, commands, getopt def get_files_to_examine(recursive = None): """returns a list of paths to Python files to be checked. If recursive is set, then will delve into subdirs.""" if recursive: find_cmd = 'find . -name \*.py' else: find_cmd = 'find . -maxdepth 1 -name \*.py' status, output = commands.getstatusoutput(find_cmd) if status: print output print "Find failed...?" raise SystemExit(1) files = string.split(output, "\n") return files def examine_files(python_files, err_continue = None): ### do the test for python_file in python_files: file = open(python_file).read() ### this whole try: except: block is neccesary if ### you want to be able to continue after errors try: compile(file, python_file, "exec") except: exception, msg, tb = sys.exc_info() print "%s: %s: %s" % (python_file, exception, msg) traceback.print_tb(tb) if not err_continue: print "ABORTING" raise SystemExit(1) else: print "%s: GOOD" % python_file ### this is what I would use if I wanted to see exactly ### where the error occured (each error will halt program) # compile(file, python_file, "exec") if __name__ == "__main__": recursive = None # assume not recursive err_continue = None # assume break on error try: options, args = getopt.getopt(sys.argv[1:], 'hrc', ["help", "recursive", "continue"]) except: print "Unrecognized option." print __doc__ raise SystemExit(1) for option_name, option_value in options: if option_name in ["-h", "--help"]: print __doc__ raise SystemExit(0) elif option_name in ["-r", "--recursive"]: recursive = 1 elif option_name in ["-c", "--continue"]: err_continue = 1 files_to_examine = get_files_to_examine(recursive) examine_files(files_to_examine, err_continue) raise SystemExit(0) # success -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From tiddlerdeja at my-deja.com Mon Dec 13 08:34:08 1999 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Mon, 13 Dec 1999 13:34:08 GMT Subject: win32com: subclass a com object? References: <830pi6$n4k$1@nnrp1.deja.com> Message-ID: <832skg$4bn$1@nnrp1.deja.com> As I said, I'm fairy new to COM too. Is COM just interface inheritance? What about implementation inheritance? Roughly speaking, for COM object: class foo: def bar(): # do something def x(): # blah def y(): # blaah If I want to create myFoo by inheriting from foo. I want to override the method bar in the derived class. Can I just do: class myFoo(foo): def bar(): # myBar Or do I have to do: class myFoo(): def __init__(): self.f = foo() def bar(): # my bar def x(): #f.x() def y(): #f.y() Sorry for thr terrible python syntax, I'm new to this. So my question is, is there no implementation inheritance in COM? Any information greatly appreciated. Sent via Deja.com http://www.deja.com/ Before you buy. From kdart at pacbell.net Sat Dec 11 05:39:29 1999 From: kdart at pacbell.net (Keith Dart) Date: Sat, 11 Dec 1999 02:39:29 -0800 Subject: Error confusing a newbie In-Reply-To: <19991210100320.B18389@dmcom.net> References: <19991210100320.B18389@dmcom.net> Message-ID: On Fri, 10 Dec 1999, 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 script is definitely being interpreted by a command shell, and not the python interpreter. Why this is happening is hard to tell from the information given. In any case, that is not really a python problem. I notice you are invoking the script without a "./". That is, as "net_time.py", and not "./net_time.py", implying that you have a "." in your PATH. True? Further, your prompt indicates you are running as root. A word of warning: having a "." in root's path is a big security risk. Perhaps you have another net_time.py script that is in your PATH? /___\\|//__//// \ (+ +) \\\\ -- --------------------oOOo~(_)~oOOo---------------------------------------- Keith Dart ============================================================================ From warlock at eskimo.com Thu Dec 9 16:38:14 1999 From: warlock at eskimo.com (Jim Richardson) Date: Thu, 9 Dec 1999 13:38:14 -0800 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: On Wed, 08 Dec 1999 23:21:03 GMT, Neil Schemenauer, in the persona of , brought forth the following words...: >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. :) I'm 35 and I used it 15 years ago in the military, and about 10 years ago in the satellite business. Although both were pretty non-conventional. Using it as a control language for test equipment. Avoiding some of it's er, peculiarities. -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS. From martin.frost at excite.co.uk Sun Dec 12 08:28:49 1999 From: martin.frost at excite.co.uk (_martin_) Date: Sun, 12 Dec 1999 13:28:49 +0000 Subject: Locking files? n stuff Message-ID: Hi all, I'm new to this so here's a little background... I'm in my final year at Uni, and for my final year project I am comparing Python with Perl (in a web context). I am intending to write some scripts both in Python and Perl that do approx. the same thing. The project also involves writing a report on my findings. 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. So can anybody help me with this? 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. ?) [Using latest perl and RH6] Also, while I'm here, is it possible to flush the output of html? As I originally wanted to have one script that handles adding and viewing the guestbook. ie initial view = a form with Add and View buttons When Add is pressed, the page clears and the Add form is displayed When View is pressed, the page clears and the guestbook entries are displayed. Another query I have, is what datatype to use to store and retrieve the data? It's gonna be a separate file (so's I can monitor it), I thought about just writing $trings to the data file. Or should I use lists, or tuples? Any help is most appreciated -- _martin_ yorkshire pagan, tull listenin rocker. -------------------------------------------------------------------------------- born, bred, studying in yorkshire email:martin at fronbow.force9.co.uk. SPAMMERS- use excite, ne1 else use ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -- _martin_ yorkshire pagan, tull listenin rocker. born, bred, studying in yorkshire email:martin at fronbow.force9.co.uk. uly: '71 M Y* L++ U KQ C c- B p+ Sh s++R H+ I++ FC(The Moor) R(S11) N(S) From donn at oz.net Sat Dec 4 01:15:12 1999 From: donn at oz.net (Donn Cave) Date: 4 Dec 1999 06:15:12 GMT Subject: How do i get output from pope3 while process is running? References: <384858EA.A9C9D2B7@fc.hp.com> Message-ID: <82abhg$kbh$0@216.39.151.169> Quoth Andrew Patterson : | 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: It's not your code, it's the external command. It buffers up all its output and doesn't write anything to the pipe until the exit flushes the output buffer. This is standard for C library I/O (stdout) to devices other than a tty, but if you can rewrite the command, all it needs is a fflush(stdout) after any interesting output. Otherwise, it's a much bigger headache, because you need a tty for it. This means a pseudo-tty, a two-way pipe that works like a terminal. The most popular software for this technique is a Tcl application called "Expect", and there are Python variations but I don't know exactly where we stand on that today. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From torppa at polykoira.megabaud.fi Fri Dec 24 20:43:37 1999 From: torppa at polykoira.megabaud.fi (Jarkko Torppa) Date: 25 Dec 1999 01:43:37 GMT Subject: strptime on Unix systems References: <19991222110107.A972@Ridcully.home> <19991223104634.A766@Ridcully.home> <3863C992.DD863CDC@endea.demon.nl> Message-ID: <8417g9$1n$1@news.kolumbus.fi> In article <3863C992.DD863CDC at endea.demon.nl>, Niels Diepeveen wrote: >So, on the whole it's not very clear what %Z should do. BTW, what does >it do on BSD? on *BSD it's undefined. Dunno what it does on FreeBSD. On SunOS 5.7 %Z Timezone name or no characters if no time zone information exists. Local timezone information is used as though strptime() called tzset() (see ctime(3C)). Errors may not be detected. This behavior is subject to change in a future release -- Jarkko Torppa torppa at staff.megabaud.fi From dworkin at ccs.neu.edu Mon Dec 20 16:48:53 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 20 Dec 1999 16:48:53 -0500 Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <83lnq7$c9d$1@news1.tele.dk> Message-ID: "Jesper Hertel" writes: > > ((a and (b,)) or (c,))[0] > I hope this was a joke. That kind of constructions is impossible to read for > other programmers, making the program hard to maintain. > > I like maxm's function much better, because you can easily understand what > the meaning is. Sure, maxm's function is much nicer-looking and easier to read. But the above snippet has the same effect as C's ternary operator, while the function does not. -Justin From TheBlueWizard at pressroom.com Mon Dec 27 20:26:10 1999 From: TheBlueWizard at pressroom.com (The Blue Wizard) Date: Tue, 28 Dec 1999 01:26:10 GMT Subject: Interface files was: Re: Python Considered Harmful References: <38673E22.C0D2155A@prescod.net> Message-ID: <01bf50d2$5c48eaa0$2b9508d1@TheBlueWizard> Eric Lee Green wrote in article ... > Paul Prescod wrote: [snip] > > Eric Lee Green wrote: > > > > > > 1) The interface specification is the implementation. There is no seperate > > > ".h" file such as with C++ that would contain the interface specification. > > > With a big "C" or C++ project I print out the ".h" files and there's my > > > interface specification > > >... > > > [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' :-). Um...I for one prefer to have my codings localized, which means I prefer to not separate out interfacing stuff from implementation stuff, so I can look at a given code fragment and know immediately how it is used/implemented so I can fix it as needed. The same goes for variables and other parts. [snip] > > > 2) Debugging is a mess. The problem is that I tend to "stub" things a lot, or > > > reference > > > functions that have not yet been written (they're in the design doc, okay, so > > > I know what their interfaces will be, I just haven't written them yet!). With > > > a compiled language I run the compiler and linker and it tells me "hey stupid, > > > you're missing something". > > > > There are various efforts under way to allow you to treat Python as a > > statically checked (even binary-compiled) language if you want it to. kewl > Actually, wouldn't JPython do this for me? I'm not familiar with it, but I > thought that it produced Java byte-codes? > > > > Of course, there's the one big advantage of Python -- it's quicker'n greased > > > lightning for writing things in. I did in a month what would have taken four > > > months in C++... > > > > It seems to me that that is really what matters, isn't it? > > Well, it's nice if the program works right too (grin). It is tough to design a "perfect" language...I recently ran into a situation which calls for some logic-like programming, and I found that I can't readily whip it up using Python like I would with Prolog for example....oh well! Keep-on-wishing-ly yours, The Blue Wizard From kbaldermann at entire-systems.com Thu Dec 16 08:01:05 1999 From: kbaldermann at entire-systems.com (Klaus Baldermann) Date: Thu, 16 Dec 1999 14:01:05 +0100 Subject: Help?? Struct packing of Date time not has stopped working??!?! References: <835mvi$62t$1@nnrp1.deja.com> <01c401bf47c3$dfe75da0$f29b12c2@secret.pythonware.com> Message-ID: <3858e292@194.120.211.23> Fredrik Lundh wrote in message <01c401bf47c3$dfe75da0$f29b12c2 at secret.pythonware.com>... >"!L" to unpack a 32-bit integer is a lousy idea -- >what if you're running on a 64-bit platform? well, I guess the struct module (or at least its documentation) would have to be changed then :-) """ Native size and alignment are determined using the C compiler's sizeof expression. This is always combined with native byte order. Standard size and alignment are as follows: no alignment is required for any type (so you have to use pad bytes); short is 2 bytes; int and long are 4 bytes. float and double are 32-bit and 64-bit IEEE floating point numbers, respectively. """ Klaus From 55555 at dakotacom.net Thu Dec 9 15:18:11 1999 From: 55555 at dakotacom.net (55555) Date: 9 Dec 1999 14:18:11 -0600 Subject: browser interface? References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> Message-ID: <38500e83_3@news5.newsfeeds.com> On Wed, 8 Dec 1999 00:27:31 -0800, Patrick Phalen wrote: > [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? > I am basically trying to cheat learning how to program a GUI. I've played around with Tkinter before, but I wasn't moving along quickly enough. So I'm thinking I could print html to a browser on my machine using cgi instead of using the python console or Tkinter (this would not at all involve the internet). I figure that any links that I print could just lead back to the script that was used to create the page in the first page and use arguements from the hyperlink to call a new function. The negative part of this is that I don't want to reparse a bunch of text files every time I need user input. Does this make sense? I'm trying to create a mail client if that helps. Thanks again. -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==---------- http://www.newsfeeds.com The Largest Usenet Servers in the World! ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==----- From guido at CNRI.Reston.VA.US Mon Dec 6 21:31:24 1999 From: guido at CNRI.Reston.VA.US (Guido van Rossum) Date: Mon, 06 Dec 1999 21:31:24 -0500 Subject: Looking for a Python job? Message-ID: <199912070231.VAA21432@eric.cnri.reston.va.us> Now that python.org is back on line (sigh), we've added a feature to the Python job board page: http://www.python.org/Jobs.html In the left margin, you'll see a series of buttons. These represent various popular job search websites. Clicking on one of these buttons will perform a search on the corresponding website for jobs with the keyword "Python" in its description. This is a shortcut for going to the site and typing "Python" in its search box. Python employment is growing: for example, in August, it was reported that Dice listed 150 Python jobs. It now lists over 260! Of course, we still accept job descriptions for our own Python job board (the rest of the page listed above). And make sure those jobs get filled -- now's the time to teach yourself Python with some of the books available from http://www.python.org/psa/bookstore/ --Guido van Rossum (home page: http://www.python.org/~guido/) From R.Smol at research.kpn.com Tue Dec 14 06:49:15 1999 From: R.Smol at research.kpn.com (Richard Smol) Date: Tue, 14 Dec 1999 12:49:15 +0100 Subject: Declaring COM-interfaces in Python? Message-ID: <38562ebd.0@pandora.research.kpn.com> Hi there, 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? TIA! Greetz, RS From dworkin at ccs.neu.edu Mon Dec 13 12:29:14 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 13 Dec 1999 12:29:14 -0500 Subject: Extracting list of keys from 2-key dictionary References: <831vjl$goe$1@nnrp1.deja.com> Message-ID: mdfranz at my-deja.com writes: > Is there a quicker/easier way in python than the snippet below to do > this? > > for a,b in dict.keys(): > if dict.has_key(x,b): > if b not in list: > list.append(b) Sure. I assume that just above this code you have: list = [] This is one way to do it, using a variation on the idiom that I have adopted for building lists without duplicates in Python: xdict = {} for a,b in dict.keys(): if dict.has_key(x,b): xdict[b] = 1 list = xdict.keys() -Justin From prestonlanders at my-deja.com Sun Dec 5 22:53:57 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Mon, 06 Dec 1999 03:53:57 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <828qhj$bb1$1@nnrp1.deja.com> <82aj7d$2dl9$2@hub.org> Message-ID: <82fc0k$jrj$1@nnrp1.deja.com> Interesting. I had no idea that this was a valid construct: >>> foo = "x" "y" "z" >>> print foo 'xyz' thanks for the informative post. You're right about the ugly string, mine was a bad example. learning-something-new-every-dayly-yours, ---Preston In article <82aj7d$2dl9$2 at hub.org>, xxx at NO-MAIL wrote: > On Fri, 03 Dec 1999 16:19:04 GMT, Preston Landers wrote: > >> want to continue a line of code over multiple physical lines? > > > >x = "This is a \ > > line of code \ > > spanning multiple \ > > lines" > > Although the original poster asked about code spanning lines, and the > above example, while in a string, demonstrates the concept, i want to > point out that the above string will produce... > > "This is a line of code spanning multiple lines" > > (For that ugly effect you might as well use multi-line quotes... > > x = """This is a > line of code > spanning multiple > lines""" > > ) > > However, to demonstrate the concept of multi-line code AND keep the > spacing nice in our string, this works best... > > x = "This is a " \ > "line of code " \ > "spanning multiple " \ > "lines" > > -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From bww00 at amdahl.com Thu Dec 30 17:19:07 1999 From: bww00 at amdahl.com (Bryan Webb) Date: Thu, 30 Dec 1999 16:19:07 -0600 Subject: need hlp-how to read gifs that are on html page Message-ID: <84gm6p$9cf@masters0.InterNex.Net> Hi, I have sampe code to read an html page. I need to be able to read the gif files that would be on the html page. ANy help would be appreciated, examples even better. Thanks Bryan Webb From jratcliff at worldnet.att.net Sat Dec 25 20:41:32 1999 From: jratcliff at worldnet.att.net (John Ratcliff) Date: Sat, 25 Dec 1999 19:41:32 -0600 Subject: Python newbie References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> <113901bf470c$cb236f60$0100a8c0@rochester.rr.com> <38654F5C.378F8338@maxtal.com.au> Message-ID: <002601bf4f42$58e98cc0$49294b0c@amd> I have just joined the list and I wanted to introduce myself. I am a professional game developer, currently working for Verant Interactive. I have been a software developer for over 20 years. My first major published computer game was '688 Attack Sub' for Electronic Arts way back in 1985. Since then I have developed a number of real-time 3d computer games, all with multiplayer support. Other games I have worked on include SSN21 Seawolf, Scarab, and Cyberstrike 2. I also acted as a technology provider for hundreds of games by developing a suite of sound and music drivers, MIDPAK and DIGPAK, as well as network drivers and a video codec. I am currently working on an, as yet unannounced, product for Verant Interactive. When I can discuss the project itself I will try to explain some of the technical issues involved in more detail, but suffice it to say that it is massively multiplayer real-time 3d product targeted for multiple systems. I develop in straight ANSI C++ and I am obsessive compulsive about making sure my code compiles with any ANSI complient C++ compiler. Any OS specific calls are always tightly bound to a generic wrapper interface that can be specifically targeted to whatever the system turns out to be. I typically create applications where all of the OS specific calls reduce to only a few dozen methods and no more. My current development team is 4 artists and 3 programmers, though I will be bringing on 3 more developers and 4 more artists very soon. If you are an expert game programmer feel free to send me a copy of your resume. The reason I have joined the Python list is because I am searching for a reasonable programming langauge that compiles down to a virtual machine byte code. My goal is that I will have a core engine on the client and on the server side. The basic game logic should all be written in some kind of general purpose scripting langauge which can be modified to invoke any of my native methods as if they were extensions to the language itself. My reasons for this are primarily as follows: (1) This architectural design absolutely *requires* a clear and distint seperation between game logic and the core game engine itself. Because of this absolute seperation of 'church and state' you can be 100% assured that the *same game engine* can run MULTIPLE games! This is incredibly valuable to say the least! (2) Virtual machines operate in a protected area of your own code space. You can have non-programmers, artists, level designers, and game designers, make modifications to game content and game logic without any risk of crashing the game itself. (3) Game content is not static. In a multiplayer environment this is absolutely critical. If you buy a single player game and it provides a certain amount of content for your money, that's just fine. But, in a pay-for-play multliplayer game, players demand and expect a constant flow of new content. Moreover, game balance must constantly be monitored and changed as a game world evolves in an online environment shaped by hundreds of thousands of people. Having all of the game logic represented as compiled byte code means you can easily download and patch the gaming system, even as it's running, on demand. While it is true that ultimately you could simply download new pieces of game logic as compiled code, as either DLL's or simply patches to an executable, this doesn't work very well when your product targets multiple processors and operating systems. (4) By selecting a custom langauge and virtual machine which you embed into your application, you can target the very specific needs of your engine. You can modify the language itself and slice into the language wherever you know there are performance bottlenecks throughout your pipeline. You can customize the language to make it fit the specifics of your environment and introduce simpler syntax for non-programmers to use. You can offload from your own development schedule by placing what would normally have been a large coding burden on your team onto game designers and level designers who, to be quite honest, would have more fun doing it themselves anyway. They can modify and change economies, damage assesment, physics, object placement, and general game rules themselves, while you can focus on fast graphics, fast collision detection and the other high speed and hard core requirements of a real time system. These are the main reasons I am interested in using a bytecode virtual machine for my game engine. What I have described sounds, of course, a lot like Java. However, if you search the internet you will find that Java virtual machines are not exactly 'open source.' There is Kaffe, but it doesn't seem targeted towards the Windows OS or VC development environment. More to the point, it's probably overkill. Java tries to be *the* application programming environment rather than a supplement to a core client application. It seems very fat for the kind of thing I want to do. So far Python seems to be the absolute best candidate for what I am trying to implement. I would be interested in hearing comments or suggestions from others as to how well they feel Python is suited for this kind of an application. If you could share your experiences using Python in a similar fashion I would enjoy hearing them. I downloaded Python and have begun to take a look at it. It seems, at initial examination, to meet most of my needs. A few quick questions. Is it easy to build a version of the source that contains *only* the byte code interpreter, and not the run time parser and compiler? Much of the Python stuff seems geared towards the interactive command line interface, which is nice if that's what you need, but I want to use the standard model of compile source to byte code, and then run only that byte code in my virtual machine. Is Python virtually linked? How does it resolve links between various python object modules? At run time? When you create a variable in Python how is it typed? Is it a float, an int, etc? It appears to be dynamically typed, which is syntacticaly simple for the novice I suppose, but I am anal enough that I do like strong typing. More to the point, while I don't plan to put my ultra-high performance code in Python, I can't afford for it to be outrageously slow either. What are the performance characteristics of the Python VM? When I used the Python GUI interface there was no option on the menu to just 'compile' a piece of python source. When I issued the command line option to compile a piece of source i.e. "compile foo" where 'foo' represents a Python source file on disk, it gives me an error message. Well, that's enough rambling for now. I hope that Python is well suited for my application since it wouldl speed up my development time considerably. If I do adopt Pythin I will do my best to be a strong contributor to the community. Much Thanks, John W. Ratcliff From malcolmt at smart.net.au Mon Dec 20 06:15:47 1999 From: malcolmt at smart.net.au (Malcolm Tredinnick) Date: Mon, 20 Dec 1999 22:15:47 +1100 Subject: time, strptime, daylight saving In-Reply-To: ; from Oleg Broytmann on Mon, Dec 20, 1999 at 09:32:20AM +0000 References: Message-ID: <19991220221547.A716@Ridcully.home> On Mon, Dec 20, 1999 at 09:32:20AM +0000, Oleg Broytmann wrote: [... analysis snipped ...] > Well, this show that on Solaris and FreeBSD mktime() correctly uses > is_dst flag; linux ignores it (but produces correct result). In some sense > FreeBSD and Solaris are doing more correct job. > > The question is simple - how can I ask time module whether any given > date is under daylight saving rule or not? How can I get the value for x > (in my second variant of the program)? OK ... I certainly learnt something out of that. Nice diagnostic work! :-) To answer your question, if you pass a value of -1 as the last element of the tuple to mktime(), it will fill in the right value from the system's time zone. I guess that is what you want (use x = -1). Cheers, Malcolm Tredinnick -- I intend to live forever -- so far, so good. From alex at magenta.com Mon Dec 27 18:27:13 1999 From: alex at magenta.com (Alex Martelli) Date: Tue, 28 Dec 1999 00:27:13 +0100 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D83@pces.cadlab.it> <3867CA1E.360E3B0E@maxtal.com.au> Message-ID: <00d701bf50c2$1b9832a0$c02b2bc1@martelli> John Skaller writes: > > 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 But it did make certain names for patterns widespread, and therefore widely recognizable by-name. You said your recognition works by-pattern, not by-name; but, surely, the existence and success of the book, and of the whole patterns movement, argues for the existence, within the ranks of our calling, of many who, like me, much prefer verbal, by-name modes of thought. An example of why experience is a good pre-requisite for arrogance, I think. A clever guy can make some plausible-sounding argument for, or against, anything (that was the whole point of the sophists: they taught how to argue convincingly for whatever one wanted, for a price, of course). Experience has more potential for solidity. (It's also a point Stroustrup argues convincingly in "Design & Evolution" -- how he put protected data members in because he let himself be swayed by good arguments, without experience backing them up, and regretted it ever since...). > 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. But for any language there will be patterns that cannot be directly encoded in it -- else, doesn't one fall into the classical barber-like paradoxes? Goedel numbers, Turing halting problems, etc, etc? Sure, for any finite set of patterns, you can find a language encoding them all. But, for any finitely described language, it should be possible to show that there are patterns it cannot encode, it seems to me; that a meta-language, naming and discussing emergent entities _about_ the language, is going to be needed anyway. > > 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", [snip] > You're right: are these really equivalent? No, if the thing named "iftrue" can have a value that is false by Python rules (the general idiom of ternary selection that always works being: (condition and [iftrue] or [iffalse])[0] whose readability I will not assert:-). But, the equivalence does hold in many practically useful cases (wherever you know something about "iftrue"'s 'truth value' being ok). But the more we talk about it, the more readable it becomes -- because the general acquaintance with it grows. Note: nothing in IT changes, yet it "becomes" more readable... because, the readability characteristic is part of the _language games_ we play; it's about human beings, who interact with language, not about language in a vacuum (language has _no_ "characteristics in a vacuum" -- "whatever we're talking about, we're talking about the natural history of human beings" -- Wittgenstein's "Untersuchungen" being a good part of my arrogance on _this_ specific issue;-). > > > 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 :-) You're right, I'm outmatched in the arrogance game...: >>> try: ... raise IndexError, "hello" ... except IndexError, x: ... print x ... hello >>> x >>> It seems to _me_, as a humble (:-) language newbie, that this x is in no strange and magical scope, but, rather, exactly in the scope I would have expected it to be (here, typing things into the interactive interpreter, the global one). Ok, so, in Viper, it isn't. Still, if your assertion does not hold for "Python as we know it", you might want to revise your consequent assertion about the complexity of Python's Locals-Globals-Builtins triad of scopes...? As I said originally, that simplicity need not spoil your personal love affair with "properly nested scopes". Personally, I adore C++'s NON-properly-nested namespaces -- ones that I can strew around a large number of disjoint header and source files -- but maybe that's just me (well, I'm sure we can think of another language which decouples namespaces [modules] similarly, but, its name being a 4-letter word, I guess we won't sully this newsgroup/list with it:-). > > I particularly appreciated Java's abandonment > > of classical rules for nested lexical scopes -- the [snip] > Yeah, but the scopes still nest and control > object lifetimes accordingly, right? The fact that I'm not sure I would say they "control lifetimes", given the peculiarities of Java garbage collection. But, yes, in a limited sense -- if an object is "visible" (accessible) it's guaranteed to be alive, although the reverse is not true (it may or may not be garbage collected, and if it is, its finalizer may resurrect it anyway) -- I'm not familiar enough with weak references in Java to say how they affect this picture. The nesting issue is also a bit complicated, since (like in C++) a class that inherits or extends acts a bit like a nested-but-not-lexically-so scope, while a lexically-nested class acquires (in Java, not in C++) different visibility (and, if I recall correctly, _accessibility_ too). > shadowing generates an error may have some > advantages, but it also has disadvantages too: > hiding supports 'cut and paste'. And this is bad because...? The "cut and paste" style of "code re-use" is a blight (and I've done enough code inspections of allegedly "production" code, and code built by pretty brilliant people too, to make me _very_ arrogantly sure of this specific issue:-). If Java's "no hiding" rule really discourages it (and I'm not sure it does -- somebody is sure, alas!, to invent some "smart editor" that will rename local variables on the fly as you paste the code...!-), then I would count that as a pretty major advantage. > 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). I'll pass on this. I think the record for "most work done in fewest lines" is still with bad old APL, at least for the kind of jobs it handled best. And, of course, right with it goes the record for "most non-intentionally obfuscated code":-). > in C++. The lack of proper lexical scoping makes > templates more or less useless. The authors of the Blitz++ library, and other rabid users of templates, appear not to agree with your opinion of their uselessness -- and to have the experience to back their opinions up. (The _readability_ of those masses of templates being a point to be argued quite separately, of course; but, they *DO* seem to make for a *powerful* compile-time code generator engine -- Turing-complete, I hear). > > If the wrappers are standardized, readability is no > > problem. > > Most people think highly bracketted expressions > are unreadable (eg LISP :-) Yep, with the exception of rabid LISP'ers. Would you thereby argue that the utter lack of brackets in FORTH makes it the MOST readable language? Or, is it an issue of striking a happy medium? > >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 Yes, but, since Python's scopes are few:-), cannot you _tell_ that kv_enum is used from the __builtins__ dictionary, if it is not assigned in the other two namespaces? If it _is_ assigned, no optimization, sure. I may not have conceptualized Python's compilation process correctly enough, but isn't this what it already does to distinguish local vs global identifiers? If assigned anywhere within local scope, it's deemed to be a local identifier, else, a global or built-in -- at least (switching rapidly into humble mode again -- not enough experience to back up arrogance here:-), that's how I had mentally modeled the process. Of course, it _would_ help if the __builtins__ namespace was locked... but, it would not offend my aesthetics if the language specs just said, "if you assign to any member of __builtins__, it is unspecified whether the assignment affects the script's semantics", much as is currently specified for assignment to members of locals() -- i.e., such hackery would be specified to be a low-level, version specific dirty trick, not guaranteed not to break on any future compiler releases. This would allow similar optimizations, if desired, on any frequent and important idiom involving built-in functions -- an important general aspect, it seems to me. > > 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. I _could_ "localize" (make a local copy of the class definition), but, why ever would I WANT to? I don't feel any need to "localize" such language aspects as "and", "or", etc -- and you just pointed out that the "ifor" you want to implement could not be "localized" (in fact, it could not be redefined at all by the user, neither locally nor otherwise) as an _advantage_. That's not spaghetti (another issue on which I feel superbly confident -- you see, being Italian, I have _nothing_ to learn about pasta from an Australian... hey, would you let ME teach you about kangaroos?-) [I should notice in passing that I love Australia, that my favourite hat is made in Australia, _and_ that my regular partner on OKbridge lives in Canberra -- just to prevent a lynch mob forming Down Under to come after me... or would the mention of Canberra just make things even worse for a New South Welsh...?-)] > > > 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. :-( The only language I've used extensively, where function calling does not require parentheses, is the 4-letter language above alluded to, which shall here remain nameless. (Well, and Forth, too, but "that was in another country", and, besides, the machine I ran _that_ on is dead). I must say that the usage one finds there does not particularly argue for the lack of parentheses enhancing readability, but that is perhaps not a fair test-bed for such a quality:-). Alex From hniksic at iskon.hr Mon Dec 20 12:37:04 1999 From: hniksic at iskon.hr (Hrvoje Niksic) Date: 20 Dec 1999 18:37:04 +0100 Subject: Equivalent to (a ? b : c) ? References: <83lgkq$2q$1@nnrp1.deja.com> <011601bf4b00$3183aee0$110010ac@normik.dk> Message-ID: <9t9wvq97bun.fsf@mraz.iskon.hr> "maxm" writes: > ###################################################################### > ## Why aren't there any unary type expression like "(Test)?trueVal:falseVal" > in Python? > > Thanks to Python's dynamic typing you can easily add the C "?:" > expression to the language by defining a single function that will > work with all types: No, this is not even close to C's ?: operator. The trick you are missing is that ?: is lazy. For example: x = foo() ? bar() : baz(); ...will call foo(), and based on that will call either bar() or baz(), never both. Your ifexp() will evaluate both expressions. The solution that is correct in all cases has been posted by others: ((a and (b,)) or (c,))[0] From amcguire at coastalnet.com Thu Dec 16 16:02:53 1999 From: amcguire at coastalnet.com (Andrew N. McGuire) Date: Thu, 16 Dec 1999 15:02:53 -0600 Subject: Newbie Getopts Question Message-ID: <3859537D.43F28542@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 Alan.Robinson at mchp.siemens.de Wed Dec 1 12:28:06 1999 From: Alan.Robinson at mchp.siemens.de (Alan Robinson) Date: Wed, 01 Dec 1999 17:28:06 +0000 Subject: XML tool status? References: <3dhfi3hiv1.fsf@amarok.cnri.reston.va.us> Message-ID: <38455AA6.79D5D42C@mchp.siemens.de> "Andrew M. Kuchling" wrote: >........ > The code's been developed subsequently, and the CVS tree is much more > recent. Is there any chance of an update as some of us can't quite get at the CVS tree. -- alan.robinson at mchp.siemens.de, Fujitsu Siemens Computers, FSC EP OS BS HA1 Otto-Hahn-Ring 6, 81739 Muenchen. tel/fax +49 (89) 636 48443/40638 ---=== http://www.munich-irish-rovers.de/ ===--- From frank.sergeant at redneck.net Tue Dec 28 01:10:58 1999 From: frank.sergeant at redneck.net (Frank Sergeant) Date: 28 Dec 1999 00:10:58 -0600 Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> <87ogbcuym5.fsf@den.home.net> <14440.14613.951856.73684@dolphin.mojam.com> Message-ID: <87902fvbm5.fsf@den.home.net> Skip Montanaro writes: > 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... No, no, just a missing brain. I meant to write "definition". -- Frank From XX at XX.COM Wed Dec 22 08:57:09 1999 From: XX at XX.COM (X CB) Date: Wed, 22 Dec 1999 07:57:09 -0600 Subject: Zope project management? References: Message-ID: Robert Leftwich wrote in message news:NDBBKOPFDEKGPDKEKFGMIEENCNAA.robert at leftfieldcorp.com... > Greg Wilson wrote: > > > Hello. Has anyone used Zope (or other Python software) to build a project > > management platform? I'm looking for something like Microsoft Project, > but > > (a) cross-platform, (b) web-enabled, and (c) Python friendly. > > Have a look at the Xen project management system written in Zope > http://bits.netizen.com.au/Xen/. > > Robert Leftwich > Not a Bad package. Leaves a little to be desired with product documentation but is simple enough to setup and use anyway. From kuncej at mail.conservation.state.mo.us Thu Dec 9 13:24:53 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Thu, 09 Dec 1999 12:24:53 -0600 Subject: Packaging packages? Message-ID: >> Is there a way to collect all the python modules in a package >> into one file? >Look more closely. Just ... Works like a charm! Thanks! I kinda figured the parts were all there, I just needed someone to explain it to me r-e-a-l s-l-o-w :-) >Then the magic incantation: *almost* transparent. I suppose that integration into the standard python distribution will brought up at Developer's Day? You can count on my vote. --Jeff From wtanksle at hawking.armored.net Fri Dec 3 22:27:49 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 4 Dec 1999 03:27:49 GMT Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD81@gandalf.digicool.com> Message-ID: On 1 Dec 1999 20:42:32 GMT, Bernhard Reiter wrote: >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. www.cetus-links.org? I've been going through that too. Excellent. Any other places you'd recommend? >CORBA still seems to be more mature. The only reason to use COM is, >if you want to interoperate with the Microsoftproduct world. CORBA is NOT a component standard -- it's an interoperability standard. It's HUGE! >The big part of the microsoft COM platform is the MTS (microsoft transaction >server) if you want to do to distributed objects. Um -- that's true for COM+, but COM doesn't need it to operate. >Why not stick with CORBA and SOAP, where needed? :) Because both are huge, bulky, slow, and require preprocessing. COM and SOAP work together _much_ more simply, and COM is far easier and faster to code. One thing I like about JavaBeans, though: they're data-driven rather than code-driven. I'm thinking of specifying a 'bean' format for my OS's COM objects to allow the same thing. Of course, the result would be incompatible with COM, but hey. Does anyone know of a free implementation of COM? I can't find any, and I'm suprised, because COM is very simple. > Bernhard -- -William "Billy" Tanksley, in hoc signo hack From timd at macquarie.com.au Tue Dec 21 21:24:37 1999 From: timd at macquarie.com.au (Timothy Docker) Date: 22 Dec 1999 13:24:37 +1100 Subject: Sydney scoreboard? References: <385DB48C.7A7A52D6@bby.com.au> <8On74.6414$Dh3.85256@ozemail.com.au> Message-ID: "Mark Hammond" writes: > 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! Does that include setting the scoreboard on fire ? :-) I remember this happening sometime last season. Dramatic photos at http://www.afl.com.au/photos/round_164.htm (search for "fire" on that page) Presumably this was not a software failure, but it brings a more concrete meaning to software "crash and burn". -------------------------------------------------------------- Tim Docker timd at macquarie.com.au Quantative Applications Division Macquarie Bank From alex at magenta.com Thu Dec 9 14:52:56 1999 From: alex at magenta.com (alex at magenta.com) Date: Thu, 09 Dec 1999 19:52:56 GMT Subject: sites offering free webspace & Python scripting...? References: <82j8cc$qju$1@serv1.iunet.it> Message-ID: <82p1ak$fuu$1@nnrp1.deja.com> In article , irmina at ctv.es wrote: [snip] > >I know of quite a few suppliers of free webspace that > >offer no scripting whatsoever, and a few that allow > >Perl scripting, but I'd really like to do my scripting in > > Which one offers free web space and *free Perl scripting* ? Hmmm, I guess hogging the info would be against the spirit of this group, hn?-) Took me quite a bit of effort to find out, but, here goes... -- here's a few that seem to work pretty well: http://www.virtualave.net http://www.webhosting.com http://www.prohosting.com http://www.webjump.com One of those (I forget which) doesn't even force you to show their ads, although they do _ask_ it as a favour. Maybe if we all now started lobbying them to suggest they support Python too...:-) Alex Sent via Deja.com http://www.deja.com/ Before you buy. From rjroy at takingcontrol.com Tue Dec 21 22:38:26 1999 From: rjroy at takingcontrol.com (Robert Roy) Date: Wed, 22 Dec 1999 03:38:26 GMT Subject: Need a recursion lesson References: <83pdbe$5fj$1@news07.btx.dtag.de> Message-ID: <38604757.188824765@news1.on.sympatico.ca> On Wed, 22 Dec 1999 03:33:44 +0100, "Eide" wrote: >Hello, >I would like to do a search for file types, and I figure a good way to do it >would be with recursion... compare a sliced 'file[:-6]' of each item in >list from a directory. And if there is another directory in that list to do >a listdir on it and .... My head is spinning already. >I have no clue what I'm doing. Does anyone have any pointers to about how to >walk through something like this? Any help would be a lot. > >Nick > > No need to re-invent the wheel, see the os.path module import os def visit(arg, dirname, names): print dirname for fn in names: name, ext = os.path.splitext(fn) print ext os.path.walk('c:/temp',visit, ()) From badzen at yifan.net Fri Dec 17 02:28:12 1999 From: badzen at yifan.net (dj trombley) Date: Fri, 17 Dec 1999 07:28:12 GMT Subject: Perl to Python References: <38581995.91AC5AA8@exelixis.com> Message-ID: <3859E58E.1D590AE4@yifan.net> Amber Shao wrote: > > Hi, > > Does anyone know if there is a way to call Python module from a Perl > script? > > thanks > amber You should simply start a Python interpreter from within the Perl script, as you would any other external interpreter or program. If you want more control, and you are somewhat more ambitious, you can write a C module for Perl which uses the Python interface. -dj Dave Trombley From wheinemanNOwhSPAM at uconect.net.invalid Wed Dec 8 11:17:25 1999 From: wheinemanNOwhSPAM at uconect.net.invalid (wheineman) Date: Wed, 08 Dec 1999 08:17:25 -0800 Subject: Need RS232 PYTHON's library running on NT4.0 SP5 References: <384E8284.CDD90A1B@pacwan.frNOSPAM> Message-ID: <00844d40.1b47e6a7@usw-ex0101-007.remarq.com> I swigged the Win32 Communications API and you could use that in conjunction with Mark Hammond's Win32 extensions for Python. My documentation is slight but the module closely follows the Win32 API functions and you could use the Win32 docs. A simple command line terminal app is provided as an example. See http://www.uconect.net/~wheineman/python/win32comm.zip . * 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 bennettt at am.appstate.edu Wed Dec 8 19:41:22 1999 From: bennettt at am.appstate.edu (TMGB) Date: Wed, 08 Dec 1999 19:41:22 -0500 Subject: Email address check function References: <19991202163334.A3934@stopcontact.palga.uucp> <3dyabd2n9a.fsf@amarok.cnri.reston.va.us> <19991202205932.B8481@stopcontact.palga.uucp> Message-ID: <384EFAB2.BF6FFB73@am.appstate.edu> I don't know if this helps but I've used a form that mails the results of a form to different people and the form uses the user's own mailserver to send it from. That way if it is an invalid email address I don't get the error message and don't get invalid data to deal with. In the snippet below, the "sentfrom" value is suppose to be the user's email address then the mail server is set to the value of the string starting from the end of the string all the way up to the @ symbol but not including the @. This is assumed to be the mail server for that user. This is using SMTPlib of course. # Asign MAILTO results from form to mailto values # mailserver=form["mserver"].value # first get user's domain from email address and use their server to mail from mailserver=form["sentfrom"].value[string.find(form["sentfrom"].value,"@")+1:] mailrecip=form["sendto"].value subject=form["subject"].value sender=form["sentfrom"].value message=form["message"].value mail=smtplib.SMTP(mailserver) mail.sendmail(sender,mailrecip,message) mail.quit Thomas Gerrit Holl wrote: > > Andrew M. Kuchling wrote: > > Gerrit Holl writes: > > > 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 '@'. > > > > Definitely. In _Mastering Regular Expressions_, Jeffrey Frield > > derives a regular expression for matching valid RFC-822 email > > addresses. Perl versions can be downloaded from > > http://public.yahoo.com/~jfriedl/regex/code.html. > > Perl :-(... Well, I'll play with re.compile(). > > > The version in the PCRE test suite begins: > > > > /[\040\t]* # Nab whitespace. > > (?: > > \( # ( > > [^\\\x80-\xff\n\015()] * # normal* > > (?: # ( > [cut] > > > > ... and so on, lasting for 593 lines in all. > > 593 lines!? I think I'll be happy with the input some faster then, the > server it runs on has only 90 mHZ... > > > But of course you can't > > verify an address like foo at bar.com without actually sending e-mail to > > it and seeing if it bounces. > > Of course not. But people entering a wrong adres, just won't get answer. But > mail with an address not matching the above, sometimes bounces. > > regards, > Gerrit. > > -- > "People get annoyed when you try to debug them." > > -- Larry Wall (Open Sources, 1999 O'Reilly and Associates) > 8:57pm up 7:30, 14 users, load average: 1.30, 1.23, 1.11 -- -------------------------------------------------------------------- Rock and Rule Zope Rocks -- http://www.zope.org Python Rules -- http://www.python.org -------------------------------------------------------------------- Thomas McMillan Grant Bennett Appalachian State University Computer Consultant II University Library bennettt at am.appstate.edu http://www.library.appstate.edu/webmaster/ Voice: 828 262 6587 FAX: 828 262 3001 Windows 95 is a 32-bit extension to a 16-bit patch for an 8-bit operating system that was originally coded for a 4-bit microprocessor. - Chris Dunphy Boot Magazine From bsb at winnegan.de Sat Dec 25 09:39:04 1999 From: bsb at winnegan.de (Siggy Brentrup) Date: 25 Dec 1999 15:39:04 +0100 Subject: Newbie: raw_input question In-Reply-To: "J. Holland"'s message of "Sat, 25 Dec 1999 07:34:01 -0500" References: Message-ID: <87d7rv84qf.fsf@baal.winnegan.de> "J. Holland" writes: > When running python on Linux, how can one trap or disable the ctrl-z > key combo when it is entered as a response to a raw_input statement? It's Xmas day :) After looking into the manuals, I'm attaching a preliminary solution. Among other deficiencies, it doesn't check for stdin being a tty. HIH Siggy -------------- next part -------------- A non-text attachment was scrubbed... Name: no_suspend.py Type: application/octet-stream Size: 628 bytes Desc: not available URL: -------------- next part -------------- Siggy Brentrup - bsb at winnegan.de - http://www.winnegan.de/ ****** ceterum censeo javascriptum esse restrictam ******* From badzen at yifan.net Sat Dec 18 00:46:19 1999 From: badzen at yifan.net (dj trombley) Date: Sat, 18 Dec 1999 05:46:19 GMT Subject: circular references? References: <385B1AE9.DD4F8ED3@yifan.net> Message-ID: <385B1F14.B998E386@yifan.net> Just a minute ago, I wrote: > (usually best done in the __del__ method) This is erroneous. __del__ does not get called until the reference count reaches zero. What caused me to be confused was a practice I usually employ which hides such references in container objects, and itself be properly collected. In this case, I use the __del__ method of the container object. Sorry for the confusion. -dj Dave Trombley From Roberto.Lupi at ascu.unian.it Fri Dec 3 09:21:56 1999 From: Roberto.Lupi at ascu.unian.it (Roberto Lupi) Date: Fri, 3 Dec 1999 15:21:56 +0100 Subject: difference between invocation of python script on unix and microsoft? References: <81vkig$228@news.service.uci.edu> Message-ID: In article <81vkig$228 at news.service.uci.edu>, strombrg at bingy.acs.uci.edu says... > python c:/full/path/to/newstosgf < filename > > ...under microsoft? I recently installed perl to my laptop with NT, the README says that redirection won't work with the standard shell (CMD.EXE on NT, COMMAND.COM on Win9x). Your problem looks suspiciously similar. -- Roberto Lupi From gmcm at hypernet.com Mon Dec 27 09:33:48 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 27 Dec 1999 09:33:48 -0500 Subject: Python Considered Harmful In-Reply-To: Message-ID: <1265818153-51405123@hypernet.com> Eric Lee Green writes: > Sorry, a bit of a troll involved in the title :-(. Becoming productive with Python means breaking some old habits - including the need to make flames. > Anyhow, I have been prototyping a fairly large project in Python, > and have come across some decided disadvantages as compared with > more traditional language. Specificationally: > > 1) The interface specification is the implementation. There is no > seperate ".h" file such as with C++ that would contain the > interface specification. With a big "C" or C++ project I print > out the ".h" files and there's my interface specification > (obviously I advocate and follow the practice of writing your C > or C++ in an object-oriented modular manner!). I don't care about > the implementation once the module has been debugged, all I care > about is its interfaces. I can see the interfaces for the whole > project by flipping through one slender folder with the .h files > printed out. I can't do that with Python. Or Java. Think about what you're saying, though. You have the habit of letting the compiler point out the missing pieces. If you see that as a "language" issue, then you should be fair and admit that it's balanced by Python's syntactic simplicity. I see it as a "tool" issue, and the right tool for Python (as for any other language, but that's another story) is grep. Practically, I often create "abstract" base classes which specify interface and have "pass" (or "assert 1 == 0") as method bodies. No, the compiler won't point out when you've let it get out of synch with the "concrete" subclasses, but it satisfies the need for a class overview. More importantly, I regard the early stages of Python development as creating an executable design; so what I'm primarily working on is getting interfaces as simple as possible. > 2) Debugging is a mess. The problem is that I tend to "stub" > things a lot, or reference functions that have not yet been > written (they're in the design doc, okay, so I know what their > interfaces will be, I just haven't written them yet!). With a > compiled language I run the compiler and linker and it tells me > "hey stupid, you're missing something". With Python, I run it, > and it tells me "doh, you forgot to create a method for > 'checksum_packet'. I run it again, it tells me 'doh, you forgot > to create a method for 'register_connection'. I run it again.... > ad nauseum. So? When you run a compile and get 42 syntax errors, how many actually need fixing? If you try to fix more than 5, you're probably breaking something. I usually fix the first, then do a quick scan to find obviously unrelated errors. In practice, that means rarely fixing more than 3 errors per compile cycle. OK, Python only finds them one at a time. Shrug. > Of course, there's the one big advantage of Python -- it's > quicker'n greased lightning for writing things in. I did in a > month what would have taken four months in C++... just getting a > bit irritated in the process with the whole > interface/implementation thing, because it's making keeping the > design doc and the implementation in sync a pain in the @%!#.... Prototype for awhile. When you've got the interfaces clean, freeze it into a design doc. Over the period of 3 years, almost all my pre-Python beliefs about the "proper" way to develop systems have been completely shredded. You might like to check out the interfaces alpha on the types- SIG home page (along with the discussion Paul pointed you to). You should definitely check out DocTest in the System area of the contrib ftp site. - Gordon From dave.rose at wcom.com Thu Dec 16 10:36:42 1999 From: dave.rose at wcom.com (Dave Rose) Date: Thu, 16 Dec 1999 15:36:42 GMT Subject: Problems with Dynamic Library compiling on AIX 4.2 Python 1.5.2 Message-ID: I am trying to post this question again as I have received no input to date and am running out of time to settle this problem ld_so_aix is returning an error 1547-002 can not open .so for input. That is the file that I am attempting to build. If I remove the -o .so from the command line, I get an error that the init function is not found. I know that this is some type of problem on my side, but I have been struggling with this for a couple of days now and it is starting to get old. Any Help would be warmly welcomed. Dave Rose From infotechsys at pivot.net Sun Dec 19 22:49:37 1999 From: infotechsys at pivot.net (Wayne) Date: Sun, 19 Dec 1999 22:49:37 -0500 Subject: Tkinter Q.. Message-ID: <385DA751.E1F7E62D@pivot.net> Hello, I'm learning Tkinter, as such I'm using Mark Lutz book "Programming Python". On page 323 there an example that I'm using to play around with. What I would like to know is when I put width and height in the init for Frame I not get a window with those values. . . . class Hello(Frame): def __init__(self, parent = None): Frame.__init__(self, parent, width = 300, height = 300) . . So, what am I doing wrong? TIA. Wayne From gerrit.holl at pobox.com Thu Dec 23 09:18:28 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 23 Dec 1999 15:18:28 +0100 Subject: Super-rexex? Message-ID: <19991223151828.A3636@stopcontact.palga.uucp> Hello all, 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! How do I do this? regards, Gerrit. -- "Open Standards, Open Documents, and Open Source" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 1:24pm up 2:42, 12 users, load average: 0.00, 0.00, 0.00 From felixt at dicksonstreet.com Wed Dec 15 03:08:46 1999 From: felixt at dicksonstreet.com (Felix Thibault) Date: Wed, 15 Dec 1999 02:08:46 -0600 Subject: defining a method inside of another method Message-ID: <3.0.5.32.19991215020846.008825e0@mail.dicksonstreet.com> This is probably a trivial question, but it's driving me crazy: I have a class that has methods that look like this: class Eggs: def keep(self, inlist): keepers = filter(self.choose, inlist) mn = {} for name, stuff, idont, careabout in keepers: mn[name] = () def mystacks(dict = mn): return dict.copy() self.stacker = mystacks return keepers Both keep and stacker get called as self.keep(inlist) and self.stacker() in other methods, and they both work like they're supposed to. In keep, I have 2 names in the header, and self gets passed in as the first argument- but if self were being passed in as the first argument to stacker wouldn't it overwrite dict and mess up mystacks ??? Where does it go? What am I missing? Thanks! Felix From gchiaramonte at prodigy.net Tue Dec 14 09:02:29 1999 From: gchiaramonte at prodigy.net (Gene Chiaramonte) Date: Tue, 14 Dec 1999 10:02:29 -0400 Subject: Python15.Dll & Borland C++ Builder 3 Message-ID: <835ic8$g8e$1@ffx2nh5.news.uu.net> I'm using C++ Builder 3 and tried including Python.h to see if I could use the Python15.dll. Here's a snippet of what happens: #include "Python.h" // this is fine PyObject *t; // this is fine Py_Initialize(); // !!! this causes the following Link Error [LinkerError] Unresolved external '_Py_Initialize' referenced from C:\MY DOCUMENTS\DEV\CPP3\IPORT\UNIT2.OBJ. Any idea why this happens and how to fix it? Thanks, Gene From fredrik at pythonware.com Thu Dec 9 10:25:22 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 9 Dec 1999 16:25:22 +0100 Subject: string interpolation syntactic sugar References: <82ogb2$db2$1@pegasus.csx.cam.ac.uk> Message-ID: <02d801bf4259$fa2737e0$f29b12c2@secret.pythonware.com> Dickon Reed wrote: > I propose a new kind of string literal wherein bracketed expressions > are evaluated then converted to strings. argh! > An alternative approach might have a function to do this: > > interpolate("a {x} b {y}") that's reasonable. > 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. I'm not sure if it works with 1.5.2, but Ping's string interpolation module implements most of this (with a slightly different syntax). start here: http://www.lfw.org/python/ From estama at milos.dbnet.ece.ntua.gr Fri Dec 17 08:28:10 1999 From: estama at milos.dbnet.ece.ntua.gr (Lefteris Stamatogiannakis) Date: Fri, 17 Dec 1999 15:28:10 +0200 (EET) Subject: Byte to integer conversion In-Reply-To: <14425.17444.750167.930304@buffalo.fnal.gov> References: <38593499.5BD58BD1@ithaca.dbnet.ece.ntua.gr> <14425.17444.750167.930304@buffalo.fnal.gov> Message-ID: On Thu, 16 Dec 1999, Charles G Waldman wrote: > Elefterios Stamatogiannakis writes: > > 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. > > >>> l = [1,2,3] > >>> reduce(lambda x,y: x*256+y, l) > 66051 > > > I don't care about big, little endian problems > > If you sudenly start to care about this, you can just reverse/reorder > the list as needed. > > This method is computational intensive. You could use the shift operator to do the multiplication by 256. Faster of all is to do: loads("i"+word_string+"\000\000") Using marshal (not pickle as i said in my previous mail). Anything better? I would expect to do something like that using int() or a variation of that. The question i'am asking is the same as saying that: I received two bytes from a socket. How do i convert them into an integer in a fast and elegant way?.. Also...... I have opened a file this way: f=open(......) I would expect a method like: f.len() to give me the file length. There isn't something like that. The only way i have found is: 1. f.seek(0,2) f.tell 2.Via stat() Does anything as simple as f.len() exist? Thank you. Elefterios Stamatogiannakis. From b2blink at hotmail.com Tue Dec 21 14:21:46 1999 From: b2blink at hotmail.com (Ulf Engstrøm) Date: Tue, 21 Dec 1999 14:21:46 CET Subject: Tkinter variables Message-ID: <19991221132146.25098.qmail@hotmail.com> I'll answer my own question with an other question, since I do have a solution that seems to work. If I use numbers in a dict like: dict = {} for name, num in myClass.names,range(len(myClass.names)): var = StringVar() dict[num] = Checkbutton(root,text=name,onvalue=name,offvalue='',variable=var) dict[num].grid(row=num) dict[num].var = var Is this a workable solution or which one would be better? Regards Ulf Engstr?m ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From emmanuel.pietriga at xrce.xerox.com Wed Dec 8 05:46:08 1999 From: emmanuel.pietriga at xrce.xerox.com (Emmanuel Pietriga) Date: Wed, 08 Dec 1999 11:46:08 +0100 Subject: Python threads Message-ID: <384E36F0.30A43165@xrce.xerox.com> I seem to have a problem with pyhon's thred scheduler. I have created an application using XPython, in which I want to have two threads: -one is in charge of repainting a drawingArea periodically (about every 20 ms) -the other is in charge of listening for events To test this, before doing something complex, I have simply tested a little program in which I repaint some squares which are moved every time the drawingArea is repainted. The eventListener thread just prints the name of the event. The problem is that, even with time.sleep(???) in the eventListener thread, the other one (repainting thread) isn't allowed to execute very often (once every 4 sec., and in a very heratic way). I have also tried to put one of the thread's code in the while1: pass of the main function. It behaves the same. I think the problem comes from the thread scheduler. But I don't know what to do! Can anyone help me please? Thanks. I run python 1.5.2 with XPython in a SOLARIS 2.6 environment. Note that Xt.NextEvent() is a blocking function (I mean, it returns when an event occurs) Here is the code of my little test program: import sys import Xt import Xm import X import whrandom import Xcursorfont import thread import time global drawingList def main(): global drawingList toplevel = Xt.Initialize('toplevel',[],sys.argv) da = toplevel.CreateDrawingArea('da',{}) da.SetValues({'background':'gray','width':800,'height':600}) da.ManageChild() toplevel.RealizeWidget() pm=toplevel.CreatePixmap(800,600) gc=pm.CreateGC({'foreground':3}) drawingList=[] for i in range(20): for j in range(20): drawingList.append(SGlyph(i*10,j*10)) print 'trying to start threads' try: thread.start_new_thread(listenThr,()) thread.start_new_thread(drawThr,tuple([da,pm,gc])) print 'threads started' except: print 'Couldn\'t start thread' while 1: pass def drawThr(da,pm,gc): offset=0 while 1: offset=offset+1 gc.SetForeground(2) gc.FillRectangle(0,0,800,600) for o in drawingList: o.drawMe(gc,10+offset) pm.CopyArea(da,gc,0,0,800,600,0,0) time.sleep(0.2) def listenThr(): while 1: evt=Xt.NextEvent() #print evt.__name__ time.sleep(0.01) class SGlyph: def __init__(self,xc,yc): self.x=xc self.y=yc def drawMe(self,gc,offset): gc.SetForeground(5) gc.FillRectangle(self.x+offset-2,self.y+offset-2,4,4) main() From hat at se-46.wpa.wtb.tue.nl Wed Dec 22 07:43:33 1999 From: hat at se-46.wpa.wtb.tue.nl (Albert Hofkamp) Date: 22 Dec 1999 12:43:33 GMT Subject: List comprehensions References: <38592275.BBA2B61A@maxtal.com.au> <385E045D.9EC36473@compaq.com> Message-ID: On Wed, 22 Dec 1999, Alexander Williams wrote: >On 21 Dec 1999 17:21:27 GMT, Albert Hofkamp >wrote: >>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 >> >> > >Hmmm, am I to assume that the *[] syntax causes it to return a curried >function that takes a list of things as its argument and returns a >list of things as its result? If so, then your while example in >Python there is a bit flawed ... No it is not, chi is heavily based on CSP and guarded command language (from Dijkstra). The [ .. ] is a case-like selection statement (except with non-deterministic choice). '|' separates alternatives, the expression before the '->' is the guard, and the statements behind it are executed after the choice is made. The *-prefix means it is repetitive. The Python translation is thus correct, except that the order of evaluation of the guards may be the other way around. ( Unlike Python, chi is not a intuitive language at first sight. It takes some time to understand it, but it allows very compact notation of calculations with a lot of data. It is mainly being used to describe scheduling strategies used in manufacturing control systems of highly complex factories ). Ok, enough off-topic for now. People who want to know more, plz email me. > >>> zip(xs, ys) > >... and get exactly the list you wanted; once you have zipped lists >together, you can then feed them to a Comprehension. 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 !! ) >Works in Python, though (or it will, once we have Comprehensions in >place ... I did some thinking about fold(), and came to the conclusion that your idea is correct. Fold should be left separate from map and filter. 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. >wonder if I can push for infinite lists, too? ...) :) Sure, just implement lazy evaluation :-) >> [ x+3 | y <- ys, z <- zs, y>z, x <- xs, y+z> >>and define separate functions for each level. >>(anyone care to do this with map and filter ?) > >Let's see ... Not really easily with map and filter, because quite >honestly they're intended to be soley parallel iterators (fulfilling Hmm, maybe this is the cause of the misunderstandings about these parallel iterators. Due to my lack of knowledge of Python, I assumed map() and filter() as described in Bird & Wadler for functional programming. Basic idea there is map(f,xs): applies function f to each element of xs, and returns a list of results. filter(f,xs): applies function f to each element of xs, and returns a list of elements for which f returns true. 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. I must have a closer look at these functions !! >Interestingly, though, with a wee bit of juggling, its structure looks >very similar, like so: > > Haskell: > >>> retList = [x+3 | y <- ys, > >>> z <- zs, y>z, > >>> x <- xs, y+z >... mirrors the (slightly reorganized) ... > > Python: > >>> for y in ys: > >>> for z in zs: > >>> if y>z: > >>> for x in xs: > >>> if (y+z) >>> retList.append(x+3) > >Interestingly, they have the same structure in both the list >expansions and the tests. I think that is what makes them so easy to read and understand. Once you have this mapping in your mind, you can almost write it down without thinking. When you then have to convert it to a language without this constrcut, it turns out to be a nightmare in 'normal' coding :-) >My own intuitive feeling is that a List Comprehension should return a >/list/ (even if its an empty list or a singleton list), while if you >want a single value to emerge, you need a function. Now, this begs I fully agree on that. Basically, the [ and ] already make you believe the result is a list, even if you don't fully understand the contents. >the question of those times a list /is/ the value and when its a list >of values ... I probably don't fully understand the consequences, but I see no real problem (but all languages I really know work with static typing). With a list comprehension, you get as much levels of lists as you put in, with a function, it is reduced with at least 1 level. xs = [ [], [], [] ] [ x | x <- xs, x!=[1] ] returns a list of lists (equal to xs in fact) fold() returns a list (at most, depending on what the folding function does). (about the latter, assume eg that I write a fold which calculates the maximum length of the elements in xs. The input is a list of lists, and the output is a natural number) Albert --- Look ma, windows without Windows !! From ionel at psy.uva.nl Fri Dec 3 05:35:55 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Fri, 3 Dec 1999 11:35:55 +0100 Subject: python 3D graphics References: <38475965.E80E77FB@trojanslair.zzn.com> Message-ID: <8286gv$8kl@mail.psy.uva.nl> Black Mantis wrote in message news:38475965.E80E77FB at trojanslair.zzn.com... | Hi | | I am wondering if anybody has any useful information on programing in 3D | in python. i would appreciate it very much You get OpenGL canvases from wxPython and, I guess, Tkinter. There is also Alice, for playing with animation. (www.alice.org) If you mean/need only 3D data visualization, you can use DISLIN, for example. You also have an interface to VTK (Visualization Toolkit), recently integrated with wxPython. There are also other native graphics packages and interface to external libraries. Lookup the relevant SIG's. ionel PS The programming itself it's up to you. :-) You just can do it from Python. From mikael at isy.liu.se Thu Dec 9 14:39:12 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 09 Dec 1999 20:39:12 +0100 (MET) Subject: Passing variable to python from a url In-Reply-To: <385000DD.EE770B2D@yahoo.com> Message-ID: On 09-Dec-99 Tekhir wrote: > passing a variable in a url like so "script.py?variable=1" Is there a way > to do this in python? Try import os Then check dictionary os.environ For me this dictionary contains the key "QUERY_STRING" - among other things. That's under Solaris and webserver Apache. Good luck! /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 09-Dec-99 Time: 20:31:37 This message was sent by XF-Mail. ----------------------------------------------------------------------- From dworkin at ccs.neu.edu Tue Dec 28 09:48:29 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 28 Dec 1999 09:48:29 -0500 Subject: strptime on Unix systems References: <19991222110107.A972@Ridcully.home> <19991223104634.A766@Ridcully.home> <3863C992.DD863CDC@endea.demon.nl> Message-ID: Niels Diepeveen writes: > So, on the whole it's not very clear what %Z should do. BTW, what does > it do on BSD? On FreeBSD: The %Z format specifier only accepts time zone abbreviations of the local time zone, or the value "GMT". This limitation is because of ambiguity due to of the over loading of time zone abbreviations. One such example is EST which is both Eastern Standard Time and Eastern Australia Summer Time. -Justin From b2blink at hotmail.com Thu Dec 16 08:23:23 1999 From: b2blink at hotmail.com (Ulf Engstrøm) Date: Thu, 16 Dec 1999 08:23:23 CET Subject: Zope Project Management? Message-ID: <19991216072323.70853.qmail@hotmail.com> Hi. journyX has made a timesheet program in Python that has some project thingys and that is integratable with Microsoft Project 98. Probably not exxactly what you're looking for, but worth giving a look I guess. http://www.journyx.com or http://www.b2b-link.com/timesheet Regards Ulf Engstr?m http://www.b2b-link.com ulf.engstrom at b2b-link.com >Hello. Has anyone used Zope (or other Python software) to build a >project >management platform? I'm looking for something like >Microsoft Project, >but >(a) cross-platform, (b) web-enabled, and (c) Python friendly. ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From peche at dial.pipex.com Sun Dec 26 09:26:54 1999 From: peche at dial.pipex.com (Keith White) Date: Sun, 26 Dec 1999 14:26:54 +0000 Subject: tutorial questions (examples fail). Message-ID: <386625AE.C88C4992@dial.pipex.com> am running 1.5.2 have printed the tutorial,and got as far as page 17. here things go wrong. in Defining functions the fibonacci example fails both in interactive mode and if created as a script with such things as myfish at peche:~ > python Python 1.5.2 (#3, Dec 26 1999, 13:32:19) [GCC egcs-2.91.66 19990314 (egcs-1.1.2 on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> def fib(n): # write Fibonacci series up to n ... "Print a Fibonacci series up to n" File "", line 2 "Print a Fibonacci series up to n" ^ SyntaxError: invalid syntax as you can see i tried rebuilding python,etc. but it doent work. If i remove the function documentation i get this >>> def fib(n): # etc,etc ... a, b = 0, 1 File "", line 2 a, b = 0, 1 ^ SyntaxError: invalid syntax Help,whats going on. Also i seem to have lost my command line editing facility in rxvt and xterm whilst interactive. -- Keith. From Michael.Husmann at digitalmap.hi.bosch.de Wed Dec 22 07:38:17 1999 From: Michael.Husmann at digitalmap.hi.bosch.de (Michael Husmann) Date: Wed, 22 Dec 1999 13:38:17 +0100 Subject: Module urllib Message-ID: <3860C639.17CF1185@digitalmap.hi.bosch.de> What is to be done to open an url when I fist have to pass a firewall? I would l ike to use the function urlopen, but I don't know how to pass my User ID and my Password. Is there somebody who can give me a hint? Regards, Michael From alex at magenta.com Sun Dec 12 05:00:27 1999 From: alex at magenta.com (Alex Martelli) Date: Sun, 12 Dec 1999 11:00:27 +0100 Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <6D8A17398E28D3119F860090274DD7DB4B3D04@pces.cadlab.it><384F8E63.95B75B21@corrada.com> <4E1vGBAwowU4Ew+N@jessikat.demon.co.uk> Message-ID: <82vv01$mme$1@nslave2.tin.it> Robin Becker wrote in message 4E1vGBAwowU4Ew+N at jessikat.demon.co.uk... [snip] > >>how do people support 'free' sites? Via advertising? [snip] > >Or they give away a basic service and hope to tempt you to buy > >the "full" service pack. Or basic service is free, but any extras > >cost money. That's how prohosting.com works, it seems to me, except that the 'basic' part includes a lot, such as CGI scripting; the 'extras' that they hope you will eventually purchase are domain-name hosting or parking, site design, and other professional stuff. I would describe this business model as generating goodwill and notoriety and hoping to cash in on those. > time is ticking over. Apparently freeserve, btconnect et al aren't quite > so nasty, but all are getting kickbacks on the telephone time. This is the basic business model here in Italy, too, and the reason so many free providers are springing up, because the cashflow is rapid. IS Providers here are technically 'phone companies', which 'happen' to receive much more incoming traffic from Telecom Italia (or other 'real' phone companies) than they generate towards them (unsurprisingly, because they don't actually offer phone subscriptions...:-); periodically, Telecom Italia must therefore pay them a fraction of the money it earns from traffic going to them. It works out to about 3 or 4 cents of a Euro, or equivalently of a US$, per minute of connect time, going into the ISP's coffers; not a fortune, but a useful adjunct to other (slower/less reliable) income sources. Some also offer ISDN service, I think they make a bit more out of it. It's basically the same idea as international "free" phone-sex lines (except that in those cases the amount per minute is far higher, since international calls are costlier). >From the user's POV, if he's using POTS and a modem (or, ISDN) to connect to an ISP, he's paying the phone bill anyway; so, the free supplier _is_ actually free, in that all he's paying is the phone bill, nothing extra. I think this only works for countries where a phone call has a cost proportional to its length, of course, but that is indeed the case in Italy. Alex From grant at nowhere. Tue Dec 14 12:36:50 1999 From: grant at nowhere. (Grant Edwards) Date: Tue, 14 Dec 1999 17:36:50 GMT Subject: newbie : books on python References: <6D8A17398E28D3119F860090274DD7DB4B3D37@pces.cadlab.it> Message-ID: Alex Martelli wrote: >Mahboob Hussain writes: > >> I program in C/C++/Java/Perl and want to learn Python. Could you suggest >> a few good books / sites to get me started ? > >My personal recommendation about books (speaking as a newbie >busy catching up on his reading:-) is to go for the dated but >excellent "Internet programming with Python" [...] >I also liked O'Reilly's new "Learning Python". "Programming >with Python", OTOH, I'd give a miss, if I were you -- I found >it chaotic to the point that it turned me off Python for a >while NB: _Programming_Python_ (O'Reilly) and _Programming_with_Python_ (Prima) are two different books. I've got the latter and don't recommend it. Just to confuse the issue further, there's a third book in German: _Mit_Python_programmieren_ (English: Programming with Python). Two other books I've seen recommended for experienced programmers are _The_Quick_Python_Book_ and _Python_Essential_Reference_. -- Grant Edwards grante Yow! DIDI... is that a at MARTIAN name, or, are we visi.com in ISRAEL? From grant at nowhere. Fri Dec 10 09:52:37 1999 From: grant at nowhere. (Grant Edwards) Date: Fri, 10 Dec 1999 14:52:37 GMT Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <82o0to$6eq$1@serv1.iunet.it> <82pcm0$p6t$1@nnrp1.deja.com> Message-ID: In article <82pcm0$p6t$1 at nnrp1.deja.com>, Preston Landers wrote: >In article <82o0to$6eq$1 at serv1.iunet.it>, > "Alex Martelli" wrote: > >> 1. what put me off Python for so long? >> Short answer: the book "Programming Python" did. > >"Programming Python" indeed sucks. I hear a revised edition is in the >works, but don't hold your breath. Avoid this book like the plague. >I'm sorry it put you off Python. No one needs a turgid, out of date >rehash of the material on python.org. "Programming with Python" also sucks. Don't buy it. It's mostly just a collection of example scripts and an incomplete rehash of of the language and library references. Everytime I need to look up something, I end up looking on the web pages The CD that comes with it isn't even usable: everything is in compressed tar files, so you have to copy the examples to another drive to look at or try them. The _least_ they could have done is uncompressed and untarred the stuff so that it was usable from the CD. The CD only has 13 Meg of space used, so there's no reason to have the files compressed -- other than they were too f@#%ing lazy to think about making a usable CD and just dumped a copy of their ftp site onto the CD. I was in a hurry, and the only other book in stock was the pocket reference from O'Reilly. Had I spent more time browsing through the book, it would still be on the shelf. What I'd like is a good intermediate level book written for an audience that already knows the basics of programming and language theory. -- Grant Edwards grante Yow! Will the third world at war keep "Bosom Buddies" visi.com off the air? From mwh21 at cam.ac.uk Sat Dec 4 10:26:54 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 04 Dec 1999 15:26:54 +0000 Subject: "%(a)s ... %(b)s" % {'a': foo, 'b': '%(b)s'} References: <19991204161814.A5289@stopcontact.palga.uucp> Message-ID: Gerrit Holl writes: > Hello, > > I'm facing the following problem. I set __version__ and now I set a string > like this: > > 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? If you know the order you will be filling the fields in, then you can double up the `%' signs, like: >>> __version__ = 1 >>> t = "%(version)s %%(email)s"%{"version":__version__} >>> t '1 %(email)s' or you could do >>> class NotQuiteDict: def __getitem__(self,item): if item == "version": return "1" else: return "%%(%s)s"%item >>> c = NotQuiteDict() >>> "%(version)s %(email)s"%c '1 %(email)s' which obviously needs generalisation, but I hope you get the idea. Cheers, Michael From akuchlin at mems-exchange.org Thu Dec 2 13:47:29 1999 From: akuchlin at mems-exchange.org (Andrew M. Kuchling) Date: 02 Dec 1999 13:47:29 -0500 Subject: Email address check function References: <19991202163334.A3934@stopcontact.palga.uucp> Message-ID: <3dyabd2n9a.fsf@amarok.cnri.reston.va.us> Gerrit Holl writes: > 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 '@'. Definitely. In _Mastering Regular Expressions_, Jeffrey Frield derives a regular expression for matching valid RFC-822 email addresses. Perl versions can be downloaded from http://public.yahoo.com/~jfriedl/regex/code.html . The version in the PCRE test suite begins: /[\040\t]* # Nab whitespace. (?: \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: # ( (?: \\ [^\x80-\xff] | \( # ( [^\\\x80-\xff\n\015()] * # normal* (?: \\ [^\x80-\xff] [^\\\x80-\xff\n\015()] * )* # (special normal*)* \) # ) ) # special [^\\\x80-\xff\n\015()] * # normal* )* # )* \) # ) [\040\t]* )* # If comment found, allow more spaces. ... and so on, lasting for 593 lines in all. But of course you can't verify an address like foo at bar.com without actually sending e-mail to it and seeing if it bounces. -- A.M. Kuchling http://starship.python.net/crew/amk/ "Aha! I knew I'd find you here!" "Huh? Well, good for you. Now it's your turn to hide." -- Weevil Dendrite and Ambrose Bierce in STANLEY AND HIS MONSTER #2 From aahz at netcom.com Fri Dec 10 21:30:58 1999 From: aahz at netcom.com (Aahz Maruch) Date: 11 Dec 1999 02:30:58 GMT 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> Message-ID: <82sd12$1b3$1@nntp3.atl.mindspring.net> 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/ From mike at ssi.com Mon Dec 20 12:43:37 1999 From: mike at ssi.com (Mike Palmer) Date: Mon, 20 Dec 1999 09:43:37 -0800 Subject: windll exception Message-ID: <83lpss$7q3@tu228.tus.ssi1.com> 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? 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 ignored ---------------------- From ivnowa at hvision.nl Thu Dec 9 17:20:04 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Thu, 9 Dec 1999 23:20:04 +0100 Subject: Tk Listbox bindings (was: Tk Listbox Question) In-Reply-To: Message-ID: <199912092219.XAA26417@axil.hvision.nl> On 9 Dec 99, Kevin Cazabon wrote: > It's actually pretty simple... most of what you need can be found in > Fred's "Introduction to Tkinter" at: > http://www.pythonware.com/library/tkinter/introduction > > Here's a quickie though. It's in a class wrapper because I've build > myself a 'standard' set of compound widgits that I use. You could call > this by simply calling: "list = display_list(parent, items_in_list)" > > > ####################################################################### > class display_list(Frame): > > [snip] > > #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. 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? TIA, --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 nhv at cape.com Fri Dec 3 11:06:18 1999 From: nhv at cape.com (Norman Vine) Date: Fri, 3 Dec 1999 11:06:18 -0500 Subject: python 3D graphics References: <38475965.E80E77FB@trojanslair.zzn.com> Message-ID: <828pr7$p42$1@newsie2.cent.net> The Pretty Poly 3D Modeller is a project to produce a free, powerful 3D modeller for Linux primarily, but built for cross-platform from the start. http://prettypoly.sourceforge.net/ Although the project is less then a month old there is a technology demo available and progress seems rapid. This is project is being built with OpenGL, Python and FLTK Norman Vine From jratcliff at worldnet.att.net Sun Dec 26 18:06:45 1999 From: jratcliff at worldnet.att.net (John Ratcliff) Date: Sun, 26 Dec 1999 17:06:45 -0600 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> Message-ID: <000d01bf4ff5$e33d7220$5c2a4b0c@amd> 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. Are there Python variants that might be better suited, like this Viper language I heard mentioned on the list? If Python is a dynamically typed language, how does it handle sending specific types to a native function call or from a native call into Python? Thanks, John From Alex.Martelli at think3.com Tue Dec 28 05:26:55 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Tue, 28 Dec 1999 11:26:55 +0100 Subject: why? Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D8B@pces.cadlab.it> Eugene writes: > 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. > [snipped: Eugene's highly condivisible paean about Python's uses] > (I'll let the others talk about features, comparisons to other > languages, syntactical joys, and the other 99 billion uses I didn't > One aspect that has little to do with any of the foregoing (or most other uses), which was the "straw that broke the Camel's back" in my specific case (pun intentional), are Python's "long integers" -- unlimited-magnitude integers (well, limited by your machine's memory, of course:-). I wanted to rewrite certain combinatorial computations, that I had originally and experimentally encoded in a weird mixture of C++ and Perl, and fishing around for "what would the best packaging be for these". And suddenly it dawned -- Python had built-in unlimited integers! All the factorials you want, without any need for extensions, libraries, add-ons, etc -- just loop and compute (and memoize, for speed), and exact accounting of combinations and permutations falls in your lap, just like that. That provided the extra motivation to make me look deeper into the language -- where I soon found out it could easily replace all the uses I had ever found for Perl, Tcl, VBscript, etc, and then some. Now, all I need is to convince a certain Tcl "enthusiast" [not really all that enthusiastic, but...] that Python's use of whitespace is not disgusting, and get him to recode his beautiful library of bridge-oriented C-coded Tcl-extensions into Python-friendly terms (or else, fork his published sources and do the recoding myself, but that sounds nasty...), and I would be all set... Alex From thor at localhost.localdomain Fri Dec 10 09:51:00 1999 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 10 Dec 1999 14:51:00 GMT Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> <3843D685.C8C13355@maxtal.com.au> Message-ID: On Wed, 01 Dec 1999 00:52:05 +1100, skaller wrote: > Integers are NOT objects in Python, they're values. >Same for strings and tuples. We can pretend they're objects, >and say they're 'immutable', but the truth is that they're >just plain values. > > My new Viper interpreter may support 'mutable' >integers and strings as follows: you write: > > x := 1 > x++ > x+=1 > >This notation actually creates a reference (pointer) to the value, >so x is a 'reference to an integer', and x++ actually means: > > x := x + 1 > >To see the difference consider: > > a = 1 > x := a > x++ > print a,x > > >Comments on this idea appreciated. > I'm really glad of your effort producing Viperi. Perhaps , I'd even become a Viperi user some day. Specially it's worth the effort of providing a better Garbage collector,... But I don't like this kind of C-like short expresions, and furthermore it seems that you give the Integer a new Object life, but then you start treatign them like Integers again or worse , like pointers. x.inc() would be more acceptable. -- Manolo From ullrich at math.okstate.edu Mon Dec 20 13:09:21 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 20 Dec 1999 12:09:21 -0600 Subject: __rcall__??? References: <002101bf4a98$01eda860$922d153f@tim> Message-ID: <385E70D1.236ED0BB@math.okstate.edu> Tim Peters wrote: > [David C. Ullrich] > > So why isn't there a magic __rcall__, that would go with > > __call__ like the other __rop__'s go with __op__? > > > > It seems useful to me to allow x to alter the way f behaves > > when you call f(x); ... > > Probably for the same reason there's no __rgetitem__ for the benefit of the > millions of programmers who want > > x[i] > > to use x as an index into sequence i . Yeah, I was gonna ask about that (haha). > That is, AFAIK nobody ever > asked for it before, and it's not screamingly natural (you're not really > *surprised* at the lack of __rcall__, right?). No, it doesn't seem screamingly natural, and I'm not really surprised at the lack of it. Well, it doesn't seem so natural in most contexts; it actually does seem fairly natural (and it _is_ very useful, putting-each -bit-of-code-where-it-belongs-wise) in this thing I'm doing. But I wasn't actually expecting anyone to add it to Python for me, I just thought I'd ask (mainly because the other day when I asked about Transpose it turned out that there _was_ a Transpose built in, just spelled funny. Coulda been there _was_ a misspelled __rcall__ already there as well. I gather not.) 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)? 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. > better-hope-for-santa-to-do-it-cuz-i-doubt-guido-will-ly y'rs - tim Thanks. Of course today is already Dec. 20 (hehe, I bet actually I _will_ be able to find a few North Pole URL's if I look...) From m.faassen at vet.uu.nl Fri Dec 3 19:15:15 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Dec 1999 00:15:15 GMT 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> <3847F117.3E2D1545@murl.com> <829b3u$mq6$1@newshost.accu.uu.nl> <3848322E.9CBDD81B@callware.com> Message-ID: <829mej$ide$1@newshost.accu.uu.nl> Ivan Van Laningham wrote: > Hi All-- > Martijn Faassen wrote: >> > [snip] >> Sure, just join the list. :) Gerrit posted about how to join it. I seem >> to be alone on it so far.. >> > Martijn admits! He talks to himself in public! On that list I did reply to myself, but here I was talking to Jim Kraai, I thought? Or-I-may-be-confused-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From mal at lemburg.com Fri Dec 10 12:03:13 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 10 Dec 1999 18:03:13 +0100 Subject: ODBC Problem on IIS4 References: <384FEC7E.29FA069A@pobox.com> Message-ID: <38513251.F1116DA4@lemburg.com> Jack Knight wrote: > > I am getting the following error when trying to do a simple SQL lookup: > > > File "C:\InetPub\cgi-bin\loginMethod.py", line 54, in getCName > cursor.execute(query,params) > dbi.internal-error: [Microsoft][ODBC Microsoft Access 97 Driver] Invalid argument. in EXEC > > Setup is: > Windows NT4 SP5, IIS4, ODBC V3.5. Python 1.5. > > Offending Code fragment: > > query="select CustomerID, Password, Status from CustomerDetails where CustomerID=:1 and Password=:2" > cursor.execute(query,params) ODBC uses the question mark as parameter marker, ':n' is Oracle style I think. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 21 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From sean001 at skynow.net Mon Dec 20 11:11:54 1999 From: sean001 at skynow.net (Torture) Date: Mon, 20 Dec 1999 16:11:54 -0000 Subject: FAQ Message-ID: <385e6375.0@news1.cluster1.telinco.net> Where can i get an FAQ for this NG? From salvador at my-deja.com Thu Dec 30 12:11:22 1999 From: salvador at my-deja.com (Salva) Date: Thu, 30 Dec 1999 17:11:22 GMT Subject: Super Tuples References: <386A1037.C6D458B3@prescod.net> <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <84dh0i$17io$1@nntp6.u.washington.edu> <386B2964.DAEE01CA@prescod.net> Message-ID: <84g33f$qic$1@nnrp1.deja.com> In article <386B2964.DAEE01CA at prescod.net>, Paul Prescod wrote: > For this to work you would probably need tuple pre-declaration to set up > the namespace. Once you start pre-declaring you are basically into the > world of object instances. You are right, but predeclaring the structs you are going to use can be very easy and it has additional benefits like better error checking. And now another supertuple implementation that tries to go towards the c struct idea... ------------------------------------------------------------------ #!/usr/local/bin/python class Supertuple: def __init__(self,*slots): self.slots=slots reverse={} for i in range(0,len(slots)): reverse[slots[i]]=i self.reverse=reverse def __call__(self,*t,**d): return apply(Instance,(self,)+t,d) class Instance: __inited=0 def __init__(self,klass,*t,**d): self.__klass=klass values=[None]*len(klass.slots) for i in range(0,len(t)): values[i]=t[i] for (k,v) in d.items(): index=klass.reverse[k] values[index]=v self.__values=values self.__inited=1 def __getattr__(self,name): try: index=self.__klass.reverse[name] return self.__values[index] except KeyError: raise AttributeError,name def __setattr__(self,name,value): if not self.__inited: self.__dict__[name]=value else: try: index=self.__klass.reverse[name] self.__values[index]=value except KeyError: raise AttributeError,name def __getitem__(self,index): return self.__values[index] def __len__(self): return len(self.__values) def __strpair(self,index): return (self.__klass.slots[index]+ '='+ repr(self.__values[index])) def __str__(self): pairs=map(self.__strpair, range(0,len(self.__values))) return ('('+ reduce(lambda x,y: x+', '+y, pairs)+ ')') def __repr__(self): return self.__str__() if __name__=='__main__': Date=Supertuple('month','day','year') d=Date('Dec',31,1999) print d month,day,year=d print month,day,year print d.year d.year=2000 print d d2=Date(year=1000) d3=Date('Dec',year=3000) d4=Date(year=1400,month='Feb',day=34) print d2,d3,d4 Point=Supertuple('x','y') p=Point() p.x=25;p.y=23 print p ------------------------------------------------------------------ - Salva Sent via Deja.com http://www.deja.com/ Before you buy. From nickliz at t-online.de Tue Dec 21 21:33:44 1999 From: nickliz at t-online.de (Eide) Date: Wed, 22 Dec 1999 03:33:44 +0100 Subject: Need a recursion lesson Message-ID: <83pdbe$5fj$1@news07.btx.dtag.de> Hello, I would like to do a search for file types, and I figure a good way to do it would be with recursion... compare a sliced 'file[:-6]' of each item in list from a directory. And if there is another directory in that list to do a listdir on it and .... My head is spinning already. I have no clue what I'm doing. Does anyone have any pointers to about how to walk through something like this? Any help would be a lot. Nick From mjackson at wc.eso.mc.xerox.com Sat Dec 4 17:36:26 1999 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 4 Dec 1999 22:36:26 GMT Subject: indentation References: <000201bf3ea4$a16e9200$df2d153f@tim> Message-ID: <82c51a$qim$1@news.wrc.xerox.com> "Tim Peters" writes: > [Will Rose] > > I always assumed that Python's whitespace rules _came_ from Fortran IV: > > or at least something overly intimate with 80-col punched cards. > > Python's use of whitespace is the polar opposite of Fortran Classic's: > whitespace means nothing in the latter, not even as a token separator. "Consistently separating words by spaces became a general custom about the tenth century A.D., and lasted until about 1957, when FORTRAN abandoned the practice." (Sun FORTRAN Reference Manual) -- 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 mikael at isy.liu.se Wed Dec 8 02:53:23 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 08 Dec 1999 08:53:23 +0100 (MET) Subject: Converting a Shell Script to run under Python In-Reply-To: <82jkol$kl2$1@hub.org> Message-ID: On 07-Dec-99 D'Arcy J.M. Cain wrote: > Magnus L. Hetland wrote: > > > 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've always thought that I should close my files when I'm done. I can't see how that should/could be done using this paradigm. What if I want to reaccess any of the files? Doesn't that cause problems? Or will the files be automagically closed since I haven't bound them to any variable? /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 08-Dec-99 Time: 08:45:36 This message was sent by XF-Mail. ----------------------------------------------------------------------- From cjensen at be-research.ucsd.edu Wed Dec 22 18:57:23 1999 From: cjensen at be-research.ucsd.edu (Curtis Jensen) Date: Wed, 22 Dec 1999 15:57:23 -0800 Subject: embedding Python in C Message-ID: <38616563.3E8AF4E3@be-research.ucsd.edu> >From a C file, how can I get values from a Python Class? For Example: File: Test.py class Klass: def __init__(self): self.a = 1 self.b = 2 self.c = 3 How can I get the values of a,b, and c from within a C function? Thanks -- Curtis Jensen cjensen at be-research.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From srn at fn.com.au Wed Dec 8 16:21:34 1999 From: srn at fn.com.au (Stephen Norris) Date: 8 Dec 1999 21:21:34 GMT Subject: Weird threading problem under Solaris Message-ID: <82mi4u$nda$1@metro.ucc.usyd.edu.au> I have a multi-threaded daemon running on a Solaris system, written in Python. One thread (the main thread, in fact) sits in a loop doing accept() calls and adding the results to a queue. I noticed that sometimes it seems to take about 12 seconds (almost exactly 12 seconds, in fact) to establish the connection - i.e. to get to the accept. When I truss the process, I see it's spending most of its time doing: 944606947.228986: signotifywait() = 32 944606947.229439: lwp_sigredirect(0, SIGWAITING) = 0 944606947.229563: signotifywait() = 32 944606947.229690: lwp_sigredirect(0, SIGWAITING) = 0 over and over again (the number is a timestamp). Eventually it gets around to an accept(), which immediately returns a new connection, then it goes back to it's lwp_blah calling. Are there any Solaris experts out there who know what this means? Anyone got any idea how to stop it? Any hints or vague suggestions would be appreciated, I've been after this one for about a week now :( Stephen -- Stephen Norris srn at fn.com.au PGP key available via finger srn at flibble.fn.com.au. Farrow Norris Pty. Ltd. http://www.fn.com.au/ From paul at prescod.net Wed Dec 29 16:21:19 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 29 Dec 1999 16:21:19 -0500 Subject: Py2K apologies References: <38675B72.18A139FF@prescod.net> Message-ID: <386A7B4F.EB0BDFD3@prescod.net> Paul Prescod wrote: > > .... > > This would imply the following: > > class SomeClass( someParentClass ): pass > > assert SomeClass.__fallback__ == someParentClass > assert SomeClass().__fallback__ == SomeClass.__fallback__ This last example is not right and that probably is causing a lot of the confusion around here. I apologize profusely. I was just tossing out ideas in the middle of the night. It should be: assert SomeClass().__fallback__ == SomeClass In other words, the fallback of an INSTANCE is the class. Overall, the idea is not fully fleshed out because as Gordon pointed out methods do not just "fallback" so that part would have to use the mechanism instances currently use. Even if the relationship between instances and classes could not be implemented in this way, the relationship between classes and base classes and between many kinds of proxies and their targets could be. Paul Prescod From bernhard at alpha1.csd.uwm.edu Sat Dec 4 15:32:38 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 4 Dec 1999 20:32:38 GMT Subject: Exposing COM via XML-RPC or Something Else References: <613145F79272D211914B0020AFF6401914DD81@gandalf.digicool.com> Message-ID: On 4 Dec 1999 03:27:49 GMT, William Tanksley wrote: >>I just read through a huge bunch of literature regarding >>the comparison of COM and CORBA. > >www.cetus-links.org? Wow, that links list is impressive. > I've been going through that too. Excellent. Any >other places you'd recommend? COM versus CORBA: A Decision Framework DCOM and CORBA Side by Side, Step By Step, and Layer by Layer Linkpage to CORBA-RMI-COM comparisions CORBA Comparison Project (see link to postscript paper) Discussion CORBAvsCOM Performance Computing - Making Sense Of The COM vs. CORBA Debate >>CORBA still seems to be more mature. The only reason to use COM is, >>if you want to interoperate with the Microsoftproduct world. > >CORBA is NOT a component standard -- it's an interoperability standard. Well AFAI understand it COM also is an interoperability standard, but I might just miss the point here. >>The big part of the microsoft COM platform is the MTS (microsoft transaction >>server) if you want to do to distributed objects. > >Um -- that's true for COM+, but COM doesn't need it to operate. Well if you don't want distributed computing... >>Why not stick with CORBA and SOAP, where needed? :) >Because both are huge, bulky, slow, and require preprocessing. COM and >SOAP work together _much_ more simply, and COM is far easier and faster to >code. I do not habe much experience about it, I admit, but technically they also seem to have the same complexity. I just do not believe that COM is easier to code. Well this is, what the articles support, too. 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 ajung at sz-sb.de Thu Dec 30 06:47:17 1999 From: ajung at sz-sb.de (Andreas Jung) Date: Thu, 30 Dec 1999 12:47:17 +0100 Subject: How to dates in Python? In-Reply-To: <386ad5ed.1918579@news.mindspring.com>; from costas_menico@mindspring.com on Thu, Dec 30, 1999 at 03:49:18AM +0000 References: <386ad5ed.1918579@news.mindspring.com> Message-ID: <19991230124717.A780@sz-sb.de> On Thu, Dec 30, 1999 at 03:49:18AM +0000, Costas Menico wrote: > Is there a datetime manipulation/math module for Python? > Take a look at mxDateTime: http://starship.python.net/~lemburg/mxDateTime.html Cheers, Andreas -- _\\|//_ (' O-O ') ------------------------------ooO-(_)-Ooo-------------------------------------- Andreas Jung, Saarbr?cker Zeitung Verlag und Druckerei GmbH Saarbr?cker Daten-Innovations-Center Untert?rkheimerstra?e 15, D-66103 Saarbr?cken, Germany Phone: +49-(0)681-502-1528, Fax: +49-(0)681-502-1509 Email: ajung at sz-sb.de (PGP key available) ------------------------------------------------------------------------------- "Well is UNIX Y2K-compliant?" and I said, ``No problem at all, but in 2038 I plan on being retired, because it is not going to be a good year for UNIX systems!'' (GvR) From paul at prescod.net Wed Dec 29 08:33:53 1999 From: paul at prescod.net (Paul Prescod) Date: Wed, 29 Dec 1999 08:33:53 -0500 Subject: Py2K wishes References: <1265702489-58362226@hypernet.com> Message-ID: <386A0DC1.471874F2@prescod.net> Gordon McMillan wrote: > > If you're catching specific methods, why not subclass? You cannot subclass objects that are passed to you. Perhaps that is a way of describing what I want: to be able to subclass arbitrary objects. I'm trying to generalize the *mechanism* used to do subclassing in Python (fallback) so that it is available when you don't want the syntax/semantics of "subclassing". > 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. No, my code looks like: class Proxy: ... def foo( self, nm ): return Unicode2ASCII( self.__obj.foo() ) def bar( self, nm ): return Unicode2ASCII( self.__obj.bar() ) def __getattr__(self, nm): attr = getattr(self.__obj, nm) if type(attr) == type(''): return Unicode(attr) return attr I want it to look like: class Proxy: ... def __init__( self, obj ): self.__fallback__=obj self.__obj=obj def foo( self, nm ): return Unicode2ASCII( self.__obj.foo() ) def bar( self, nm ): return Unicode2ASCII( self.__obj.bar() ) Paul Prescod From milek at task.gda.pl Fri Dec 10 10:29:01 1999 From: milek at task.gda.pl (Robert Milkowski) Date: 10 Dec 1999 15:29:01 GMT Subject: Enviroment Message-ID: <6t38511bd8icf6n79%milek@korweta.task.gda.pl> Hi. I call the program in Python as CGI. I need to set up LD_LIBRARY_PATH enviroment to "/usr/lib:/lib:/mnt/1/NSIN/lib:/mnt/1/NSIN/egcs-libs:" before importing some modules. How can I do it in Python? os.putennv(LD_LIBRARY_PATH,"/usr/lib:/lib:/mnt/1/NSIN/lib:/mnt/1/NSIN/egcs-libs:/mnt/1/NSIN/linux-libs:") doesn't work. -- Robert Milkowski milek at task.gda.pl From alex at magenta.com Sun Dec 19 13:39:20 1999 From: alex at magenta.com (Alex Martelli) Date: Sun, 19 Dec 1999 19:39:20 +0100 Subject: Critique a newbie's "Smart-copy" class please...? Message-ID: <005e01bf4a50$a28186e0$db2b2bc1@martelli> Mostly to learn, partly to end up with a useful artefact, I've written a 'smart-copy' class, intended to take as input a file (or similar) which may include embedded Python expressions and statements, and copy it to an output file (or similar) with substitutions. Statements and expressions are identified through arbitrary regular-expression objects passed in to the class, for maximum convenience (so regex's can be chosen that will be unlikely to conflict with whatever kind of material is being copied); a 'globals' dictionary for the evaluation is also passed in. For example, with the test-code: if __name__=='__main__': "Test: stdin->stdout with full processing" import re import sys x=23 rex=re.compile('@([^@]+)@') rbe=re.compile('\+') ren=re.compile('-') rco=re.compile('=') cop = copier(rex, globals(), rbe, ren, rco) cop.copy(sys.stdin) expression will be identified by being enclosed in '@...@', statements are on lines starting with +, and may be continued with lines starting with =, and are terminated with lines starting with -, so, for example, if standard input is a first line (x is @x@) +for w in range(1,5): hello @w@ there + if w%2: the number @w@ is odd = else: the number @w@ is even - - a last line (w is now @w@) standard output will be: a first line (x is 23) hello 1 there the number 1 is odd hello 2 there the number 2 is even hello 3 there the number 3 is odd hello 4 there the number 4 is even a last line (w is now 4) After not a little soul-searching I've settled for 'slurping' the file being read with .readlines(), and a recursive set-up for nested statements (mostly intended for if, for, while thingies). It seems like the simplest set of choices here. I think the key feature still missing is including other files, which would probably also be done best by recursion, but before doing that I'd like some critique of my style and choices by more experienced Pythonistas. I'm unsure about everything, from, how verbose or detailed it might be best to be in doc strings and comments in this language, to, have I gone overboard in making things part of my object's state rather than passing them in as arguments, etc, etc... So, thanks in advance for whatever critiques and suggestions you may offer. """ Smart-copy of a "template" file to another file (e.g., to standard output, for CGI/&c purposes). The file is copied, except that Python expressions embedded in it are expanded (and some Python statements, such as conditionals and loops, can also be embedded, on a line-oriented basis). The Python expressions are identified through a compiled regular-expression object, which, on each and every line, is used for a _search_ on the string; if a MatchObject "match" results, match.group(1) is eval'd as a Python expression, and substituted in place; a dictionary for the evaluation must also be passed. Many such matches per line are possible. Statements can also be embedded; this is mostly intended to be used with if/elif/else, for, while. Statement-related lines are recognized through 3 more regular-expression objects that are passed in, one each for 'statement', 'continuation', 'finish', used for reg-ex 'match' (i.e., from line-start). The 'stat' and 'cont' re's are followed by the corresponding statement lines (beginning statement, and continuation statement -- the latter makes sense mostly for, e.g., 'else', and 'elif') while the rest of the 'finish' lines is ignored. Statements can be properly nested; all statements end at end of file unless 'finish' lines were found sooner. """ import sys import string class _nevermatch: "Polymorphic with a regex that never matches" def match(self, line): return 0 class copier: "Smart-copier class, see module's docstring" def copyblock(self,i,last): "Main copy method: process lines [i,last) of block" def repl(match,self=self): "return the eval of a found expression, for replacement" return '%s' % eval(match.group(1),self.globals,self.locals) block = self.locals['_bl'] while i Executing: {"+stat+"}" exec stat in self.globals,self.locals i=j+1 else: # normal line, just copy with substitution self.ouf.write(self.regex.sub(repl,line)) i=i+1 def __init__(self, regex, dict, restat=None, restend=None, recont=None, ouf=sys.stdout): "Initialize self's data fields" self.regex = regex self.globals = dict self.locals = { '_cb':self.copyblock } self.restat = restat or _nevermatch() self.restend = restend or _nevermatch() self.recont = recont or _nevermatch() self.ouf = ouf def copy(self, inf=sys.stdin, block=None): "Entry point: copy-with-processing a file, or block of lines" if not block: block = inf.readlines() self.locals['_bl'] = block self.copyblock(0, len(block)) Alex From fdrake at acm.org Wed Dec 1 09:27:47 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 1 Dec 1999 09:27:47 -0500 (EST) Subject: python test frameworks In-Reply-To: <3d903fhhch.fsf@amarok.cnri.reston.va.us> References: <14402.65296.413573.98151@weyr.cnri.reston.va.us> <3d903fhhch.fsf@amarok.cnri.reston.va.us> Message-ID: <14405.12387.436432.910120@weyr.cnri.reston.va.us> "Fred L. Drake, Jr." writes: > There's also the somewhat-general (and completely undocumented) > "test" package in the Python standard library. That might be worth a > look; I'm not sure how re-targetable it is. Andrew M. Kuchling writes: > It's usable for external software in 1.5.2, since I use it for the > test suite in the standalone distribution of the PCRE module. Great news! Does this mean that documentation is forthcoming? ;-) This would be a good topic for a HOW-TO document. I can even envision a Topic Guide that deals with issues of testing and other forms for code checking (coverage analysis, pylint flavors, etc.). Now we just need to draft someone knowledgeable in the area and inflict upon him or her the burning itch to write documentation...! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From mgushee at havenrock.com Mon Dec 13 10:32:34 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 13 Dec 1999 10:32:34 -0500 Subject: XML parsing References: <945048362snz@vision25.demon.co.uk> Message-ID: 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 -- 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. 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): 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. Matt Gushee Portland, Maine, USA From rwadkins at flash.net Fri Dec 10 12:56:25 1999 From: rwadkins at flash.net (Very Frustrated) Date: Fri, 10 Dec 1999 17:56:25 GMT Subject: calling Python from C: I can't get this part. Message-ID: <82res6$896$1@nnrp1.deja.com> I know this should be easy, but I've read the documents at www.python.org and the SWIG manual and it is still not clear how I do the following. Maybe someone here can help. I've used SWIG to port Arthur Corcoran's genetic algorithm library (libga100) to Python. It works fine with the example evaluation function included in the library. I've made all the helper functions within SWIG to set and get values in genes, chromosomes, etc. Here's the part I can't get. Within the library, there's a structure called the GA_Info_Ptr. This structure keeps up with various things about the GA run. One item that it keeps up with is a pointer to the evaluation function that is called to score a chromosome. In C, this looks like the following (abbreviated) code: 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. The rest is easy, but even after looking at the examples in the SWIG manual, I am still not clear how you do this. Any help would be greatly appreciated. --Randy Sent via Deja.com http://www.deja.com/ Before you buy. From fredrik at pythonware.com Fri Dec 17 05:28:16 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 17 Dec 1999 11:28:16 +0100 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> Message-ID: <029e01bf4879$72585ee0$f29b12c2@secret.pythonware.com> Alex Martelli wrote: > I cannot help but keep staring at the result: > > import sys > > def copy(regex, dict, inp=sys.stdin, oup=sys.stdout): > def repl(match,dict=dict): > return eval(match.group(1),dict) > while 1: > line = inp.readline() > if not line: > break > oup.write(regex.sub(repl,line)) > > and wonder that *FOUR*-count-em lines of > this function, fully half of it, are devoted to > the trivial, frequent, repetitive task of looping > over input lines, reading each one, bailing > out when done. hmm. by some reason, my brain treats that while/if/break stuff as one large "glyph". am I the only one here who has a brain equipped with a 2D pattern matcher? ;-) > But why can't I change those 4 lines to, say: > while line := inp.readline(): how about: import fileinput for line in fileinput.input(): ... From m.faassen at vet.uu.nl Fri Dec 3 19:31:40 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Dec 1999 00:31:40 GMT Subject: Mailinglist about Dutch Python users group. References: <19991203173153.A7422@stopcontact.palga.uucp> Message-ID: <829ndc$ide$3@newshost.accu.uu.nl> Gerrit Holl wrote: > Hello, > I've made a mailinglist where the Dutch users can discuss about a Dutch > Python users group, because there are so many Dutch users who'll never > go to a Python conference because it's so far away. Not only because of that, I hope. Let's just get together, conference or no conference! Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From nickb at earth.ox.ac.uk Thu Dec 9 10:25:43 1999 From: nickb at earth.ox.ac.uk (Nick Belshaw) Date: Thu, 09 Dec 1999 15:25:43 +0000 Subject: Tk Listbox Question Message-ID: <384FC9F6.1521A533@earth.ox.ac.uk> Calling Tk wizards- Could anyone (/F?) tell me if it's possible to modify - without too much difficulty - the bindings on a Tk Listbox. What I would like to do is select an item with either Left or Right Mouse Buttons but with different actions on depending on which was used. doable or too tricky? or dead easy and I'm thick! thanks for any ideas Nick/Oxford From jeremy at cnri.reston.va.us Thu Dec 9 12:07:13 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 9 Dec 1999 12:07:13 -0500 (EST) Subject: string interpolation syntactic sugar In-Reply-To: <82ogb2$db2$1@pegasus.csx.cam.ac.uk> References: <82ogb2$db2$1@pegasus.csx.cam.ac.uk> Message-ID: <14415.57793.278683.360085@goon.cnri.reston.va.us> >>>>> "DR" == Dickon Reed writes: DR> As far as I know, if in Python I want a string comprised of the DR> concatenation of some strings and some expressions converted to DR> strings, I have to do something like: DR> " a "+`x`+" b "+`y` DR> or: DR> " a %s b %s" % (`x`, `y`) DR> The first sometimes gets awkward and the second means I have to DR> match up the format string with the tuple which can be a source DR> of bugs. When I have complicated formats, I usually turn to dictionaries rather than trying to match up format strings with a tuple of values: "a %(x)s b %(y)s" % { 'x': math.log(0), 'y': y } I'm not sure that the suggested approach of putting some kind of special delimiters to mark eval-able parts of strings is much of an improvement. Jeremy From rodzilla2000 at my-deja.com Wed Dec 15 22:26:16 1999 From: rodzilla2000 at my-deja.com (rodzilla2000 at my-deja.com) Date: Thu, 16 Dec 1999 03:26:16 GMT Subject: Need help with Tkinter References: <8342a8$1td$1@nnrp1.deja.com> Message-ID: <839m4l$4lo$1@nnrp1.deja.com> Thanks for your responses... I think I understand now what's going on... I've ordered the new Tkinter book, from amazon.com, but I think it's been delayed by the publisher or something... Can't wait to get it! Sent via Deja.com http://www.deja.com/ Before you buy. From jim at digicool.com Mon Dec 27 12:33:50 1999 From: jim at digicool.com (Jim Fulton) Date: Mon, 27 Dec 1999 17:33:50 +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> Message-ID: <3867A2FE.C9FFC5B9@digicool.com> 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. We have never found Python to provide any significant limitation to the salability of Zope wrt application complexity. In fact, features of Python facilitated implementing features of Zope, such as transparent persistence, transactional programming, and acquisition that greatly facilitate the management of complexity and salability. (On the performance side, Python, being a very high-level language, sometimes poses computational or memory usage challenges, but these are rarer than one might expect.) Jim -- 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 mlh at vier.idi.ntnu.no Tue Dec 21 15:21:59 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 21 Dec 1999 21:21:59 +0100 Subject: Arg! (Makefile.pre.in) References: <14431.56728.357282.276777@weyr.cnri.reston.va.us> Message-ID: "Fred L. Drake, Jr." writes: > Magnus, > Perhaps you could tell us exactly the commands you entered and what > Setup.in looked like? Sure. I tried a lot of variants, but here is one: Setup.in contains: *shared* spam spamodule.c The commands are (for instance) as follows: make -f Makefile.pre.in boot (This seems to work) Now I run make: make: *** No rule to make target `spamodule.c', needed by `spamodule.o'. Stop Note: This is a set of conditions/errors I haven't encountered before... It all seems rather stochastic ;) Browsing the Makefile.pre.in it seems that it has the wrong value for, among other things, the installdir. So, I try: make -f Makefile.pre.in Makefile VERSION=1.5 installdir=/some/python/install/directory When I run make, I get the same error as before. (Hm. Strange - the last time I did this, make complained about the non-existent target "default"). If I try make spammodule I get all kinds of errors about undefined symbols (suggesting some linking problem): gcc -g -O2 -I/store/include/python1.5 -I/store/include/python1.5 -DHAVE_CONFIG_H spammodule.c -o spammodule Undefined first referenced symbol in file Py_InitModule4 /var/tmp/cczDaaxu1.o Py_BuildValue /var/tmp/cczDaaxu1.o PyArg_ParseTuple /var/tmp/cczDaaxu1.o main /store/lib/gcc-lib/sparc-sun-solaris2/2.8.1/crt1.o ld: fatal: Symbol referencing errors. No output written to spammodule I *do* include Python.h... > That would help a lot. Well - it is always difficult to provide information when one has no clue as to what the problem might be, as one does not know what is relevant... > Also, are you sure you're using Misc/Makefile.pre.in, not > ./Makefile.pre.in, from the source distribution? Yes... There is no ./Makefile.pre.in that I can see... :) -- Magnus Lie Hetland From the_wrights at onaustralia.com.au Mon Dec 20 05:53:02 1999 From: the_wrights at onaustralia.com.au (the_wrights) Date: Mon, 20 Dec 1999 21:53:02 +1100 Subject: Sydney scoreboard? References: <385DB48C.7A7A52D6@bby.com.au> Message-ID: <8On74.6414$Dh3.85256@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 customise the display. I don't know if python is being used in other smaller-less-important-and-hardly-culturally-signficant-stadium?stadia-in-so me-northern-villages..... :-) cheers chris wright From gerrit.holl at pobox.com Thu Dec 23 15:43:53 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 23 Dec 1999 21:43:53 +0100 Subject: Super-rexex? In-Reply-To: <1266159968-30845431@hypernet.com>; from gmcm@hypernet.com on Thu, Dec 23, 1999 at 10:36:55AM -0500 References: <19991223151828.A3636@stopcontact.palga.uucp> <14434.14004.510906.767308@weyr.cnri.reston.va.us> <1266159968-30845431@hypernet.com> Message-ID: <19991223214353.A8069@stopcontact.palga.uucp> Gerrit Holl asked: [Super rexec for execfile() with strings only?] Fred L. Drake, Jr. answered: [ConfigParser module] Gordon McMillan reacted: [shlex module] They both don't seem to be what I want. I'm reinventing the wheel if I use them. *All* I want is having a dictionairy with the same string rules Python uses. Not many users will need to see the file: only translators will. If I've got a file like this: foo="content of foo...BEEP\a...BEEP\a..." bar='A string...\n\ with fun...' foobar="""If you want to have a string, spanning multiple lines, containing ' and " many times, triple quotes suit the best...""" And the function should a dictionairy like:`: {'foo': 'content of foo...BEEP\a...BEEP\a...', 'bar': 'A string...\012with fun...', 'foobar': 'If you [...] lines,\012containing \' and " many [...] best...'} So in fact, execfile() is almost exactly what I need. It's SO CLOSE, it's a pity to parse a file with shlex() for it... Shall I just keep secret to translators, so that only people who've read the source and people who've read this message know it? Much easier, but quite ugly... regards, Gerrit. -- "The IETF motto is 'rough consensus and running code'" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 9:24pm up 10:42, 13 users, load average: 0.08, 0.02, 0.05 From quinn at cruzeiro.ugcs.caltech.edu Sat Dec 18 13:29:24 1999 From: quinn at cruzeiro.ugcs.caltech.edu (Quinn Dunkan) Date: 18 Dec 1999 18:29:24 GMT Subject: Python complaints References: <3858C226.949FC9C6@udel.edu> <14425.4841.291880.269618@weyr.cnri.reston.va.us> <62ij5sov45demdte805irtg48hd0eu8m3o@4ax.com> Message-ID: On Fri, 17 Dec 1999 00:23:23 -0500, Kevin wrote: >On Thu, 16 Dec 1999 11:27:21 -0500 (EST), "Fred L. Drake, Jr." > wrote: > >>> 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)? >> >> 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. This kind of polymorphism is what python (and dynamic OO in general) is good at. From clopez at abo.fi Tue Dec 14 06:25:00 1999 From: clopez at abo.fi (Cesar Lopez) Date: Tue, 14 Dec 99 11:25:00 GMT Subject: I need information about extending and embedding Python Message-ID: I need to make a library for python to update some external devices in an embeded system with a little Hitachi microcontroller, so I need information about How to do that, I must to define a method to define librarys to control devices like, RS-232 port, Leds, Keyboards, Speakers. Now I?ve defined a litle program in C++, its control a green Led (on/off) and now I want to do that with the python interpreter, so I need your help. From sbarron at twilight. Sun Dec 12 15:33:17 1999 From: sbarron at twilight. (Scott Barron) Date: Sun, 12 Dec 1999 20:33:17 GMT Subject: Wrapping C functions that use memcpy/mmap Message-ID: Hi folks, I am attempting to wrap a C library and port a bunch of code to Python. Some of the C code has a function like this (somewhat abbreviated :) : char contents[] = "spam"; int function (..., vm_address_t *data, ..., size_t datalen, size_t amount) { /* ... */ if (*data_len < amount) *data = (vm_address_t)mmap (0, amount, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); memcpy ((char*)*data, contents, amount); /* ... */ return 0; } Where vm_addresss_t is a pointer to some memory (shared by the client and this program). My question is, how might I do such a thing in Python? Will it be safe to call the mmap and memcpy functions from C controlled by Python? Thanks, Scott From garry at sage.att.com Mon Dec 6 16:18:00 1999 From: garry at sage.att.com (Garrett G. Hodgson) Date: Mon, 6 Dec 1999 21:18:00 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: <384C2808.B359063F@sage.att.com> "Fred L. Drake, Jr." 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? ;) i started in APL, a loooooooong way from python. i still love the indentaion thing. maybe i used up my tolerance for line noise. -- 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 sasha at ofoto.com Sat Dec 11 16:16:56 1999 From: sasha at ofoto.com (sven) Date: Sat, 11 Dec 1999 13:16:56 -0800 Subject: COM and Python threads Message-ID: <054f0654.99279019@usw-ex0102-009.remarq.com> I have an app that uses a third pary COM component for some image processing (using makepy). I'm now trying add multi-threading and it's not playing nice with the COM component. When the 2nd thread tries to get an instance of the component I get a COM error "Coinitialize not called". Has anyone come across this behaviour with PythonCOM and threads before? Or might it just be particular to the component I am using? * 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 dotproduct at usa.net Mon Dec 13 23:01:04 1999 From: dotproduct at usa.net (Nick Maxwell) Date: Mon, 13 Dec 1999 22:01:04 -0600 Subject: Need information om Python byte-code References: <8345m3$27t$1@hyperion.nitco.com> <834cjv$duk$1@news.tht.net> Message-ID: <8374e4$oo4$1@hyperion.nitco.com> >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! (-: Not at all! I love getting information like this :) I have visited both of these links, but had no time as of yet to really study the code. I will do so however once I get done writing my damn term paper (school is at the bottom of all the counterproductivity in my life :) Thanks again for the replies everyone :) - Nick Maxwell dotproduct at usa.net From badzen at yifan.net Fri Dec 17 02:21:01 1999 From: badzen at yifan.net (dj trombley) Date: Fri, 17 Dec 1999 07:21:01 GMT Subject: defining a method inside of another method References: <3.0.5.32.19991215020846.008825e0@mail.dicksonstreet.com> Message-ID: <3859E3E0.5D07E242@yifan.net> Felix Thibault wrote: > > This is probably a trivial question, but it's driving me crazy: > > I have a class that has methods that look like this: > > class Eggs: > def keep(self, inlist): > keepers = filter(self.choose, inlist) > mn = {} > for name, stuff, idont, careabout in keepers: > mn[name] = () > def mystacks(dict = mn): > return dict.copy() > self.stacker = mystacks > return keepers > > Both keep and stacker get called as self.keep(inlist) and self.stacker() in > other methods, and they both work like they're supposed to. In keep, I have > 2 names in the header, and self gets passed in as the first argument- but > if self were being passed in as the first argument to stacker wouldn't it > overwrite dict and mess up mystacks ??? Where does it go? What am I missing? > > Thanks! > > Felix Any time you call a method as an attribute of another object, the object is applied as the first argument to that method. For example, I could define the following: class foo: def __init__(self): self.bar = 5 def add_my_bar(x,y): return (x.bar + y) f = foo() foo.add = f.add_my_bar And then calling "f.add(6)" will return 11, for example. However, a function does not have this behavior when it is called in the same way. Simply assigning the object to an object attribute does not make it a method of that object. The essential difference here is in what namespace the assignment occurs. If you use the variable passed as thefirst argument to a method, (typically called "self") then this assignment is to the dictionary of the instance. If you use the class object itself, then functions assigned become methods and behave in the expected way; as if they has been defined along with the class. You can refer to the class being defined from within the class definition by simply using its name. -dj Dave Trombley From quickbbs at my-deja.com Tue Dec 14 10:16:07 1999 From: quickbbs at my-deja.com (quickbbs at my-deja.com) Date: Tue, 14 Dec 1999 15:16:07 GMT Subject: Help?? Struct packing of Date time not has stopped working??!?! Message-ID: <835mvi$62t$1@nnrp1.deja.com> Folks, (Please if your going to email, please email replies to junkster at rochester.rr.com, I don't check this Deja Account, and I'm just using it due to work's firewall) A strange little problem has cropped up, that I can't explain. My Python Time server is starting to cause errors, that I believe are server related. In other words, the client attachs, and reports: "struct.err: str size does not match format". Previous to (at least) 11/30/1999, it was/is working. But we just noticed that the client was reporting this error today (12/14/1999). I suspect that STRUCT isn't handling the packing of the long correctly, as far as the manual's go, it looks AOK, but..... Here's the server code: # # Python Time Server, based off of RFC 868. # # Thanks to (no particular order, nor is this complete): # # Jeff [jam .at. quark.emich.edu] # Paul Foley [(setq reply-to (concatenate 'string "Paul Foley " # ""))] # # And other folks in comp.language.python for their assistance with this code. # # This code is free to the public, EXCEPT, I would appreciate any changes to be # emailed to me ("Junkster at rochester.rr.com") # # Changes: # # v1.0a (10/15/99) # - Added Logging (see logfilename) # - Rewrote Time Generation routine to use time.time() # - Increased # of default threads # import time from socket import * import struct import sys # # Constants # epoch = 2208988800L # Difference between 1900 & 1970 per RFC868 logfilename = 'TIMESERVER.LOG' # Name of the log file numb_threads = 10 def timeserver_calculation(): total = epoch + time.time() return total def server(host="", port=37, backlog=5): sock = socket (AF_INET, SOCK_STREAM) sock.bind (host, port) sock.listen (backlog) print "listening on port %s (%s, %s)" % (port, `host`, backlog) while 1: connection = (conn, addr) = sock.accept() ft = timeserver_calculation() lt = long(ft) timetuple = time.localtime(time.time()) logentry = time.strftime('%x %X', timetuple) + ' client ' + str(addr[0]) + ' connected for timeStamp ('+str(lt)+')' print logentry logfile = open(logfilename, 'a') logfile.write (logentry+'\n') logfile.close conn.send ( struct.pack("!L", lt)) conn.close() if __name__ == "__main__": server('', 37, numb_threads) ----- Here's the client code ---- # Python Time Server client, based off of RFC 868. # # Thanks to the folks in comp.language.python for their assistance with this code. # # This code is free to the public, EXCEPT, I would appreciate any changes to be # emailed to me ("Junkster at rochester.rr.com") # import os import struct import sys from telnetlib import Telnet import time # # Use Telnet library to connect to server on port 37 # print "Connecting to : ", sys.argv[1] tn_session = Telnet(sys.argv[1], 37) # Connect to NTP date / time server datetime = tn_session.read_all() # Read the Integer tn_session.close() # Close the Telnet session dt = struct.unpack ("!L", datetime) # Unpack the data from the server # # "Dump the Data to Screen for Debug" # print "Server Returned: ",datetime," | Unpacked structure value : ", dt # # Epoch is the diff. between Epochs between Python & RFC 868 # epoch = 2208988800L dt = (dt[0]) - epoch # Remove "Tuple" status & Convert it to a python time value # # Print out "English" Version of time/date # timetuple = time.localtime(dt) print "Time - ", time.asctime(timetuple) # # # if sys.platform == "win32": import win32api #print (timetuple[0], timetuple[1], timetuple[6], timetuple[2], timetuple[3], timetuple[4], timetuple[5], 0) #win32api.SetSystemTime (timetuple[0], timetuple[1], timetuple[6], timetuple[2], timetuple[3], timetuple[4], timetuple[5], 0) os.system ('date '+ time.strftime('%x', timetuple) ) os.system ('time '+ time.strftime('%X', timetuple) ) Sent via Deja.com http://www.deja.com/ Before you buy. From claird at starbase.neosoft.com Sun Dec 19 11:49:21 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Dec 1999 16:49:21 GMT Subject: eff-bot Python book ... revisited References: <7va9hf$ngi$1@marcie.fissiontech.com> <00fd01bf23cb$e4b6ed30$f29b12c2@secret.pythonware.com> <381C952F.2E8F30EC@callware.com> Message-ID: In article , =?ISO-8859-1?Q?Fran=E7ois_Pinard?= wrote: >Ivan Van Laningham writes: > >> (And last time I checked, the PDF viewer for Linux sucked; maybe that's >> changed by now, maybe Adobe offers their own 4.0 viewer for Linux. ...) > >I'm far from PDF, but it happened that Ghostscript helped me at viewing it >conveniently on Linux -- through `gv', I rarely use Ghostscript directly. > >However, sending to the printer from `gv' (a Tkinter introduction, if I >remember well?) was less happy, as the inter-letter spacing was all wrong, >making the printed result especially difficult to read. Even if it helps >me (?!) at reading more slowly, the fatigue grows faster. I have no idea >of the cause of this random spacing, far less the solution. . . . There's *got* to be a happier conclusion than this. I'm running right now on an unmaintained FreeBSD 2.2.2 (that's an OS dating to 20 May 1997), and the xpdf (dated 29 Apr 1998) I'm using does everything I've asked. While I know almost nothing about this subject, I've got to think that some combination of pieces will take at least Ivan farther than he seems to be now. Persevere. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From gerrit.holl at pobox.com Thu Dec 2 14:55:12 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 2 Dec 1999 20:55:12 +0100 Subject: Environment variables In-Reply-To: ; from jeff@parlant.com on Thu, Dec 02, 1999 at 11:09:26AM -0700 References: Message-ID: <19991202205512.A8481@stopcontact.palga.uucp> jeff wrote: > How do I set environment variables outside the python script? os.environ["PATH"] = "/bin:/usr/bin:/usr/local/bin" > 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). Not possible. The Python script is started as a child. You can't set environment variables for a parent. > I need this for both Linux and NT/Win2k. I don't know how it works on NT, but on Linux, you could output this, like dircolors does: export VARNAME=VARCONTENT; export ANOTHERVARNAME=ANOTHERVARCONTENT you could make a shell script: #!/bin/sh eval $(script.py $*) Have fun! -- "Open Standards, Open Documents, and Open Source" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 8:52pm up 7:25, 14 users, load average: 1.35, 1.19, 1.06 From hirend at home.com Wed Dec 29 15:08:32 1999 From: hirend at home.com (Hirendra Hindocha) Date: Wed, 29 Dec 1999 20:08:32 GMT Subject: Python books review ? Message-ID: Hi, 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 ? I'm looking for reviews on - Programming With Python Tim Altom; Paperback Python Annotated Archives Martin C. Brown, et al; Paperback The Quick Python Book Kenneth McDonald, Daryl D. Harms; Paperback Please post to the newsgroup. Thanks, Hiren From DOUGS at oceanic.com Sat Dec 4 13:42:00 1999 From: DOUGS at oceanic.com (Doug Stanfield) Date: Sat, 4 Dec 1999 08:42:00 -1000 Subject: Tutorial for a NEWBIE Message-ID: <5650A1190E4FD111BC7E0000F8034D26A0F186@huina.oceanic.com> I would also suggest subscribing to the Python tutor mail list at http://www.python.org/mailman/listinfo/tutor -Doug- > -----Original Message----- > From: Thomas A. Bryan [mailto:tbryan at python.net] > Sent: Friday, December 03, 1999 3:16 PM > To: python-list at python.org > Subject: Re: Tutorial for a NEWBIE > > > Nasshi wrote: > > > > 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 > > http://members.xoom.com/alan_gauld/tutor/tutindex.htm > > or > > the tutorial at http://www.python.org/doc/ > > ---Tom > > -- > http://www.python.org/mailman/listinfo/python-list > From ngps at madcap.dyn.ml.org Wed Dec 15 10:13:09 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 15 Dec 99 15:13:09 GMT Subject: Not really about python... References: Message-ID: <3857b005.0@news.cyberway.com.sg> According to Sposhua : > 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 ;-) IIRC, once upon a time, the canonical command-line SMTP talker for NT was called "blat". It was much used by Perl CGI programmers. Of course, on Python, just use smtplib. -- Ng Pheng Siong * http://www.post1.com/home/ngps From kcazabon at home.com Sat Dec 4 00:56:07 1999 From: kcazabon at home.com (Kevin Cazabon) Date: Sat, 04 Dec 1999 05:56:07 GMT Subject: Environment variables References: <1267895477-5653035@hypernet.com> Message-ID: Hmmm... I haven't had that experience, here's what happens to me on NT: ################## newpath = os.environ["PATH"] + ";c:\\Program Files\\Tcl\\bin" pathkey = RegOpenKey(win32con.HKEY_LOCAL_MACHINE, \ "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\", \ 0, win32con.KEY_SET_VALUE) RegSetValueEx(pathkey, "Path", 0, win32con.REG_SZ, newpath) RegFlushKey(pathkey) RegCloseKey(pathkey) ################## This is supposed to add "c:\Program Files\Tcl\bin" to the NT PATH (so that Tcl will work, for example). However, if I then immediately exit Python, and start a new Python program that requies Tcl/Tk, I get an error saying that one of the required DLL's is not in the system path (and it conveniently lists the current PATH, which does NOT have my addition in it). 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. Does that make sense? Is there an easier way to make it effective immediately (the "flush" doesn't seem to do anything). I use the os.putenv(), but it's no good for a separate Python thread. (Hey Mark, if you're out there...) q:] Oh well... Kevin Cazabon kcazabon at home.com "Gordon McMillan" wrote in message news:1267895477-5653035 at hypernet.com... > Kevin Cazabon on making changes to environment vars: > > > 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. > > Actually, they do. Just not in already running cmd.exes. You > can use os.putenv to affect the environment of the cmd.exe > you're running in, but there's nothing you can do about other > already existing ones. > > > > - Gordon > > From ivanlan at callware.com Tue Dec 21 19:10:58 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 21 Dec 1999 17:10:58 -0700 Subject: Sydney scoreboard? References: <385DB48C.7A7A52D6@bby.com.au> <8On74.6414$Dh3.85256@ozemail.com.au> Message-ID: <38601712.5DE2F5A1@callware.com> Hi All--- Mark Hammond wrote: > [snip] > 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 :-) > Hey! No fair! It's supposed to take over this half first! > 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! > Oooh, sounds juicy. Can you post some code? (Seriously; it might be kind of fun to see this stuff.) -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 Tue Dec 21 16:35:55 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 21 Dec 1999 22:35:55 +0100 Subject: Arg! [Long] References: <14431.56728.357282.276777@weyr.cnri.reston.va.us> <14431.58546.940849.802614@weyr.cnri.reston.va.us> <14431.60189.682411.792427@weyr.cnri.reston.va.us> <14431.61484.662532.436321@weyr.cnri.reston.va.us> Message-ID: "Fred L. Drake, Jr." writes: > Magnus L. Hetland writes: > > Suddenly it works. Hm. So it actually needs sourcecode - i'd say > > that's quite a shortcoming > > You'll just have to get over that one... ;) Oh, well... OK. ;) > If you try "import spammodule" it should fail: > > >>> import parsermodule > Traceback (innermost last): > File "", line 1, in ? > ImportError: dynamic module does not define init function > (initparsermodule) Oh - so (pardon my ignorance) how do you use parsermodule? > > (Only yours will say "initspammodule".) > If you want the .so to be named spam.so, rename the source file to > spam.c and adjust Setup.in to say: > > *shared* > spam spam.c I did that. (Or - rather, I renamed it to spludge, since there already seemed to be a module "spam" taking precedence over mine.) So - no I can compile it and import it. Yay! I guess I shouldn't be too upset about it not working... >>> dir(spludge) ['', '__doc__', '__file__', '__name__'] >>> There should be a 'system' in there, according to: static PyMethodDef SpludgeMethods[] = { {"system", spludge_system, METH_VARARGS}, {NULL, NULL} /* sentinel */ }; void initspludge() { (void) Py_InitModule("spludge", SpludgeMethods); } This sounds familiar, though... I think I had the same problem with SWIG earlier ... (i.e. garbage names for the functions...) > > > -Fred -- Magnus Lie Hetland From bernhard at alpha1.csd.uwm.edu Mon Dec 20 16:42:55 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 20 Dec 1999 21:42:55 GMT Subject: help with negative numbers please References: <83jd7t$mi1$1@hardcore.ivn.net> <83k2sn$aji$1@news.udel.edu> Message-ID: On 20 Dec 1999 02:05:11 GMT, Terry Reedy wrote: >In article <83jd7t$mi1$1 at hardcore.ivn.net>, jmace at ior.com says... >> >>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. >Put the equation in your code as you wrote it. If this does not answer your >question, rephrase it. Yes, the question is not quite clear. Let me explain a bit. "y" is only one variable, you tell the python program: please take the value z stands for and substract the value x stands for and save it in y. y = z - x If you then need another value you can fill a different variable. y2 = -(z - x) Okay, let's assume you want to be sure that y1 contains the positive difference and y2 the negative difference, you can try: y1 = abs(z-x) y2 = - y1 This should give you some clues. 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 fdrake at acm.org Thu Dec 30 12:02:42 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 30 Dec 1999 12:02:42 -0500 (EST) Subject: Pythonwin: any plans for COM+? In-Reply-To: <84121d$um7$1@nnrp1.deja.com> References: <3863c163.8797109@judy> <84121d$um7$1@nnrp1.deja.com> Message-ID: <14443.36914.972940.98406@weyr.cnri.reston.va.us> nyamatongwe at my-deja.com writes: > You should discount the 1997 article by Mary Kirtland (and similar > early articles) as the scope of COM+ has diminished greatly since that > article. Neil, Is Platt's "Understanding COM+" considered reasonable by "the knowledgable"? It's not very technical, but I just wanted a high- level overview. Thanks! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From fredrik at pythonware.com Sat Dec 4 04:44:22 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 4 Dec 1999 10:44:22 +0100 Subject: Python complaints References: <000401bf3bd4$2f000820$542d153f@tim> <3848A872.C704AB73@Lugoj.Com> Message-ID: <00d701bf3e3c$25c1a1f0$f29b12c2@secret.pythonware.com> James Logajan wrote: > You'd have code that would look like: > > populationOfthePlanetEarth = populationOfThePlanetEarth + 1 > > versus: > > populationOfThePlanetEarth++ earth.population.add(1) From pramod at tcsi.com Wed Dec 8 15:10:39 1999 From: pramod at tcsi.com (Pramod Kumar Singh) Date: Wed, 08 Dec 1999 12:10:39 -0800 Subject: Re-enter python tcl interpreter problem Message-ID: <384EBB3F.538D8319@tcsi.com> Hi, I have the an interesting scenario. OM1 - Object Manager 1 OM2 - Object Manager 2 These object managers are multi-threaded and have the capability to execute python implemented operations when a client executes an operation on a object. Within these python operation I can also execute a remote operation on another object residing on another object manager. This remote operation invoke is done through tcl. e.g OBJ1 resides in OM1 and OBJ2 resides in OM2. OBJ1 has operation op1() and OBJ2 has operation op2() When a client invokes OBJ1.op1() on OM1, the python operation op1 is executed, which in turn calls OBJ2.op2() on OM2. But op2() takes a lot of time and thus holds the OM1 from receiving any other client request. In order to resolve this problem, I made the tcl call release the main thread (done in c++) and let the request continue in another thread. This way OM1 is not blocked and can receive any number of request. Now here is the problem. When two clients are invoking operations simultaneously on OBJ1 in OM1, my process OM1 crashes. Here is what happens. i) The remote operation through tcl has released the main loop to let OM1 receive any other request. ii) OM1 is still executing the remote request through tcl in another thread. iii) During this time another client has requested on OM1 OBJ1.op1() and thus the tcl interpreter is re-entered to call the remote operation of OBJ2.op2(). This is where the crash occurs. This gives me a conlusion that TCL interpreter cannot be re-entered before a task is still going on in same tcl. interpreter. Is this correct ? Is there any workaround for this ? Am I missing any kind of flag or such ? Has anybody faced such a situation and resolved it. I did read about suggestions on using multi-threaded tcl 8.2.2, but for my circumstance of software tied up to Python 1.5.1 I can't upgrade to 8.2.2. Any other suggestions. Here is the error given by tcl interpeter in OM1. TclExecuteByteCode: done instruction at pc 6: stack top 7 != entry stack top 5 Source: "OBJ2.op2 -sync"TclExecuteByteCode execution failure: end stack top != start stack top I am using Python 1.5.1 and TCL/TK 8.0.5 The dbx stack trace is as follows [7] TclExecuteByteCode(interp = 0x164128, codePtr = 0x101e58), line 710 in "tclExecute.c" [8] Tcl_EvalObj(interp = 0x164128, objPtr = 0x17c810), line 2640 in "tclBasic.c" [9] Tcl_UplevelObjCmd(dummy = (nil), interp = 0x164128, objc = 1, objv = 0x16778c), line 605 in "tclProc.c" [10] TclExecuteByteCode(interp = 0x164128, codePtr = 0x92490), line 956 in "tclExecute.c" [11] Tcl_EvalObj(interp = 0x164128, objPtr = 0x16d1c8), line 2640 in "tclBasic.c" [12] TclObjInterpProc(clientData = 0x1b4b00, interp = 0x164128, objc = 3, objv = 0x167778), line 992 in "tclProc.c" [13] TclExecuteByteCode(interp = 0x164128, codePtr = 0x1e1da8), line 956 in "tclExecute.c" [14] Tcl_EvalObj(interp = 0x164128, objPtr = 0x16d5d0), line 2640 in "tclBasic.c" [15] Tcl_Eval(interp = 0x164128, string = 0x133340 "Line.Find -sync"), line 2448 in "tclBasic.c" dbx: warning: can't find file "" dbx: warning: see `help pathmap' [16] Tkapp_Call(0x153d28, 0x1d8500, 0x6d609b18, 0x0, 0x1d8640, 0x2), at 0x6efa20e8 dbx: warning: can't find file "" [17] call_builtin(0x153ce0, 0x80da8, 0x0, 0x0, 0x109564, 0x153d28), at 0x6efde254 [18] PyEval_CallObjectWithKeywords(0x153ce0, 0x80da8, 0x0, 0x0, 0x80da8, 0x1), at 0x6efddf84 [19] eval_code2(0x1d8500, 0x0, 0x14c508, 0x1, 0x83, 0x1396aa), at 0x6efda754 [20] call_function(0x0, 0x0, 0x0, 0x0, 0x133338, 0x6e696144), at 0x6efdeaf8 [21] PyEval_CallObjectWithKeywords(0x14efd8, 0x1d5810, 0x0, 0x6d609fac, 0x6d609fa8, 0x1034d8), at 0x6efddf54 Any help is highly appreciated. Thanks, Regards, Pramod/ From 55555 at dakotacom.net Tue Dec 7 19:53:03 1999 From: 55555 at dakotacom.net (55555) Date: 7 Dec 1999 18:53:03 -0600 Subject: browser interface? References: <384af243_4@news5.newsfeeds.com> <99120623372703.02133@quadra.teleo.net> Message-ID: <384dabef_4@news5.newsfeeds.com> On Tue, 7 Dec 1999 08:30:04 -0800, Patrick Phalen wrote: > [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. > 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. -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==---------- http://www.newsfeeds.com The Largest Usenet Servers in the World! ------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==----- From mlh at vier.idi.ntnu.no Tue Dec 21 12:35:33 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 21 Dec 1999 18:35:33 +0100 Subject: Lists of lists traversal References: <83m3fn$sb6$1@cronkite.cc.uga.edu> <83mio3$f1a$1@news01.cit.cornell.edu> Message-ID: cjc26 at nospam.cornell.edu (Cliff Crawford) writes: > Pada 20 Dec 1999 21:17:27 GMT, Kaleissin bilang: [...] > > [reduce(lambda x, y: x+y, l) for l in list_of_lists] While we are simplifying... (Having imported add from operator): [reduce(add,l) for l in lost_of_lists] I must say - for single iterators, where there seems to be little controversy over syntax - this list comprehension stuff can be really neat :) Although - for those who haven't installed it (like me), this works nicely: map(lambda l: reduce(add,l), list_of_lists) -- Magnus Lie Hetland From alwyns at prism.co.za Wed Dec 15 07:38:31 1999 From: alwyns at prism.co.za (Alwyn Schoeman) Date: Wed, 15 Dec 1999 14:38:31 +0200 Subject: Mutable parameters to functions Message-ID: <38578BC7.FE55E37@prism.co.za> Hi, I've been working through Mark and David's book Learning Python. On page 105 there is an example that states that when you change a argument that is mutable in place (thew!) then you also change the value of the variable in the callers namespace. Ok, now on page 107 there is an example on returning multiple values. The code is as follows: def multiple(x,y): x = 2 y = [3,4] return x, y X = 1 L = [1, 2] X, L = multiple (X, L) X, L result is then (2, [3, 4]) Now, the question is whether the statement y = [3, 4] constitutes an inplace change of the global variable L? would X = multiple(X,L) yield the same results? Thank you -- ~~~~~~~~~~~~~~ Alwyn Schoeman Systems Engineer Prism Secure Solutions From t.middletan at news.vex.net Tue Dec 7 01:41:05 1999 From: t.middletan at news.vex.net (t. middletan) Date: 7 Dec 1999 06:41:05 GMT Subject: ANN: grassi python 3.0 References: <82eu7a$anq$1@nnrp1.deja.com> <82ftb9$2gat$1@hub.org> Message-ID: <82ia61$2a0i$1@hub.org> quinn at dinar.ugcs.caltech.edu (Quinn Dunkan) wrote: >But it DOESN'T do what he wants! You are right. My brain short circuited as usual. Why i considered 1/0 a syntax error in my example is a complete mystery to me. Heh. >(and behold well, because it took me a while to figure out how >to make a syntax error in perl): Just leave out a few semi-colons or braces. Wooo. >Therefore, perl also sucks as a cgi language. Grassi is right; >everyone else is just plain wrong. Maybe you guys should form a club or something? >py = popen2.Popen3('python ' + sys.argv[1], 1) Ah, the wrapper concept taken to new heights... new heights of... something. Heh. Someone should be collecting all these 'creative' solutions! >The way I can think of involves dup()... but I'll leave >that for Dan... Yep, you can't do everything. Especially since you'll be so busy now porting all your stuff to PHP. (Though i still think a 'simple' non-wrapper solution for non-syntax errors --- a la Carp, but not so bizarre looking --- would be useful for some... Fredrik's idea of using the sys.exitfunc might work? Say for example cgi.errorsToBrowser() which would set stderr to be redirected to StringIO object, sets an exitfunc() which checks sys.last_traceback (as Fredrik suggested)... and if there is a traceback then to print minimal headers and the traceback.. Yes, i know that this is a security risk generally, and that it won't stop the syntax/compile errors, and the function would even be generally annoying probably to anyone who knows what they are doing... but still, it seems to me some might benefit from it, making it so simple to catch many errors easily with python CGI.) From boud at rempt.xs4all.nl Wed Dec 15 15:51:04 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 15 Dec 1999 20:51:04 GMT Subject: C++ (was RE: Python suitability) References: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it> Message-ID: <838uvo$sc7$1@news1.xs4all.nl> Alex Martelli wrote: > Grant writes: >> About twice as long as it would take for a Modula-3 or >> Smalltalk programmer. ;) I've never thought C++ was a >> particularly decent example of an object-oriented language, but >> maybe that's because I learned Smalltalk and M3 first. >> >> The whole virtual-function-method thing has always struck me as >> very obtuse. You apparently have to guess ahead of time which >> methods somebody might, at some point in the future, want to >> override, and declare them differently from the non-overridable >> ones... >> > Or, to put it another way: you have to DESIGN, rather than > just start hacking. > Specifically, if you follow the advice of Scott Meyers, in his > excellent "Effective C++" (CD Edition): never inherit from a > concrete class. That makes C++ about as powerful as Visual Basic - in essence, no inheritance at all, just interfaces... Having just done a large project in Visual Basic, I've learnt how painfult that limitation can be - and I was kind of surprised when I read in Design Patterns that composition should be favoured over inheritance. There are no doubt good reasons, but not one I can think of. Boudewijn Rempt | http://denden.conlang.org From fdrake at acm.org Thu Dec 9 13:17:45 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 9 Dec 1999 13:17:45 -0500 (EST) Subject: Help! ConfigParser module In-Reply-To: References: Message-ID: <14415.62025.395983.189636@weyr.cnri.reston.va.us> Marshall writes: > 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 from ConfigParser import ConfigParser mycfgfile = ConfigParser() mycfgfile.read(["myconf.cfg"]) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From alex at magenta.com Wed Dec 15 19:03:18 1999 From: alex at magenta.com (Alex Martelli) Date: Thu, 16 Dec 1999 01:03:18 +0100 Subject: C++ (was RE: Python suitability) References: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it> <838uvo$sc7$1@news1.xs4all.nl> Message-ID: <006e01bf4759$3aeaefc0$c02b2bc1@martelli> Boudewijn Rempt writes: > > Specifically, if you follow the advice of Scott Meyers, in his > > excellent "Effective C++" (CD Edition): never inherit from a > > concrete class. > > That makes C++ about as powerful as Visual Basic - in essence, > no inheritance at all, just interfaces... Having just done a No inheritance of implementation, yep -- not between components, at least (how you split up one single component is really a different issue than how separate components interact -- concrete-class inheritance has other problems, of course, but such tricks as "the pattern without a name", depending on templates as well as inheritance, are another kettle of fish). C++ is just as powerful as VB (or Python, or machine code) _today_ -- they're basically all Turing complete in abstract terms, subject only to physical machines' limitations. C++ offers a lots of features that are there for various, mostly historical, reasons -- e.g., just about all would agree that public data members are a Bad Thing, yet C++ lets you exposes them if you wish to; _protected_ data members are a feature Stroustrup considers to have been a great mistake to put into the language, the one he would take away if he could run history backwards. Etc, etc. > large project in Visual Basic, I've learnt how painfult that > limitation can be - and I was kind of surprised when I read > in Design Patterns that composition should be favoured over > inheritance. There are no doubt good reasons, but not one > I can think of. Maybe Lakos, "Large Scale C++ Software Design", could help you see why -- he's talking mainly about interaction _between_ components, where the case is sharpest. But basically, and reductively: inheritance of implementation introduces a larger degree of coupling than one would like, and strong dependencies. Containment and delegation, aka 'composition', is a more 'normal' situation for client software, easier to control. The key benefit of inheritance, i.e. polymorphism (in a strictly typed language) can be obtained by inheriting from abstract classes, aka interfaces, only; indeed, it can be obtained better. Consider, in a C++ kind of world...: Suppose function F takes a reference to an object of class C. How is it relevant for F, what data items (not public!-) C has? It's irrelevant implementation detail -- and so are methods that are protected or private. All F cares about is what it can "legally" do with C, i.e. its public interface -- possibly, other public interfaces the object might expose (as could be tested for via dynamic_cast, etc). Therefore, why would you ever want to design F to accept a pointer to a NON-abstract class? What extra benefit would this non-abstractness provide? (Some performance through inlining etc, perhaps -- the kind of optimization that should be left to a late, tuning stage for a design, and only performed on truly performance-critical spots... a tiny fraction of a whole design, hopefully:-). So, interfaces are the base of the design. When a class is implementing an interface (which in C++ is expressed by inheritance -- Java is cleverer, having an "implements" keyword, but I suspect you dislike that since VB also uses it:-) then you have some instruments for that implementation. You can do it with the least coupling by containment and delegation -- but it takes lots of boilerplate, because C++ lacks a smooth way to express this key idiom (Python's ability to automate delegation through the overloading of __getattr__ is almost a dream come true, but, I digress:-). What you can through concrete inheritance is merely a modest reduction in boilerplate (and possibly a modest performance gain). A point has been made on this thread about the wonders of prototyping, and I'll be the last to disagree with that. But, the way I like to prototype is: sketch the key items (the interfaces); slap up skeleton implementations of them; try writing the client code; refine the interface design, iterate. More and more these days many of the interfaces are expressed in COM -- in a good part, because this lets me prototype them faster (e.g., in Python -- *bliss*!-) _and_ test more thoroughly that their functionality is actually what is needed (since the client code can also be coded in a powerful and fluid language...). When the time comes to move to C++ implementations for some of the things (pretty early, in some cases, e.g. things that are "known" will be performance-critical, or involve certain low level system interactions -- although I guess that, as I learn Python better, the second half of this may decrease), I tend to have the needed stub/skeleton collection or "infrastructure". And code reuse can often be gotten through suitable templates ("generic programming") rather than through inheritance of implementation... Alex From m.faassen at vet.uu.nl Thu Dec 2 13:31:09 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 Dec 1999 18:31:09 GMT Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: <826dtd$bre$1@newshost.accu.uu.nl> 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. 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. :) 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? From Gareth.McCaughan at pobox.com Wed Dec 22 20:51:11 1999 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: 23 Dec 1999 01:51:11 +0000 Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <83lnq7$c9d$1@news1.tele.dk> <86puvz6dbg.fsf@g.local> Message-ID: <86aen2o25s.fsf@g.local> Rob Hodges wrote: >> [someone else:] >>>>>> ((a and (b,)) or (c,))[0] >>> Someone mentioned that this is idiomatic Python, but actually it is >>> idiomatic lisp. .. > Not being an old-time lisper, I guess I must have been speaking crap > since I have been corrected both on and off-list! However I recall > having seen the lazy `and' and `or' exploited together more than a few > times when wading through the source of various emacs packages and > quickly becoming familiar with its meaning, making it seem fairly > natural to me in Python. Oh, I see. It's true that short-circuit "and" and "or" do get used in this kind of way sometimes, but I think this ought to be used very sparingly; the typical case where it makes sense is where you have a number of different ways to try to get a value and you try them until one succeeds. This makes sense in Lisp more often than it does in Python because Lisp doesn't have such a multiplicity of false values (only one, in fact); so it's more often easy to arrange that success always yields something true. > 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? Er, this is getting a bit off-topic... > Making lists out of b and c, and grabbing the car of result is not > idiomatic lisp; in fact I completely overlooked that because although > it doesn't exactly look natural in Python, it's easy enough to see > what's happening even if you don't know why it was done -- whereas if > you don't recognise the laziness of `and' and `or', you'll have a > really hard time seeing what's going on. 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. I think I'm saying much more about my own idiosyncrasies than about what's really idiomatic Python... > So that was what I saw as > being the confusing part. Even though they are lazy in C too (if > memory serves...), (Yes, they are. And in Perl.) > you don't often see that exploited (probably > because you have the conditional operator there...) Also because in C they do the Wrong Thing. a && b && c isn't equal to c if a,b,c are all true. This means you *can't* (ab)use the short-circuit Booleans to get an equivalent of ?:, even if you want to. > BTW, my derivation of "idiomatic" was intended tongue-in-cheek; not as > a linguistic analysis. Sorry to have offended the linguists, though I > did learn the true derivation, so it was a profitable comment for me > at least :) I will offer in exchange that perhaps "idiot" does stem > from the same root after all, in the sense that it might be > interpreted as "someone who does things that make sense to themself > [but to nobody else]". Food for thought (and more offtopic by the > minute; sorry). "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. -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From scherbi at bam.com Wed Dec 22 06:40:41 1999 From: scherbi at bam.com (Bill Scherer) Date: Wed, 22 Dec 1999 06:40:41 -0500 Subject: Python port on Open Edition References: <8E9EBCE5Etheistoperamailcom@207.69.128.201> <385A25BF.C718E4FA@bam.com> Message-ID: <3860B8B9.919F9CB5@bam.com> Martin Eggen wrote: > > Nice to see other than me has been trying to get it to work, though. :) Actually, I haven't ever tried to get Python running on OE. I just remembered that IBM had a web page about it. My company does run OE, so I hope one day to run Python there... 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 t.keil at zvs.zgs.de Mon Dec 6 10:16:43 1999 From: t.keil at zvs.zgs.de (Thomas Keil) Date: Mon, 06 Dec 1999 16:16:43 +0100 Subject: Q: Python for 8088 Palmtop Message-ID: <384BD35B.3EF3@zvs.zgs.de> Hello, I'm looking for a tiny python binary to use it on my 8088 palmtop. Please give me a hint. Many thanks! -- _ o | )_/# T Message-ID: <82od57$i7n$1@serv1.iunet.it> As I said in my other recent post...: Alex Martelli wrote in message news:82o0to$6eq$1 at 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!-). I'm continuing with numbered points from 3, since points 1 and 2 I made in the other post. 3. "dictionary locking" in lieu of declarations Some of us are into the "bondage and discipline" style of programming -- we really want whatever language engine we're using to diagnose as many of our errors as it can, as soon as it can. Perl and Visual Basic started out even freer than Python, regarding variable declarations, but now they have -w, "use strict", and "Option Explicit", to help those of us who are addicted to this - optionally, of course, so freer spirits lose nothing by this. Python is, well, halfway there -- it WILL tell me, if I mis-spell a variable name in an expression; however, it will NOT help me in any way, if my mis-spelling is on the left-hand side of an assignment statement. The asymmetry is somewhat unpleasant, and there is no support for our preferred style. One idea I came up with, which could help matters a bit, I think, and appears to be more in the spirit of Python, than "declarations": what if I could *LOCK* a dictionary, any dictionary, including, of course, those where variable names are kept for the various scopes; so that any attempt to _add a new entry_ to the dictionary would raise an exception. This way, those of us who choose to, could program in this style: start by "initializing", e.g. an instance of a class in __init__, by assigning initial values to all of its variables; then, self.__dict__.lock(1), and I'd be all set -- no further instance variables nor methods could be "accidentally" added to self any more (until, of course, I unlocked its dictionary once more, presumably with self.__dict__.lock(0) -- maybe in some exception handler for the exception raised by writing a locked dictionary, etc). Thinking along these lines, in some cases I could use a _stronger_ form of locking, one roughly equivalent to C++'s "const", where, not just creating new entries in a dictionary, but even attempting to change what one of them refers to, would also raise exceptions. Maybe .lock(2), etc. Given Python's powers of "introspection", I bet some prototype for this could already be hacked up, by subclassing the dictionary and playing with __getattr__, __setattr__, and __delattr__ -- but, as a newbie, I'm somewhat reluctant to start along this path myself, in particular since these dictionaries seem to be somewhat "magical" (a much beloved term in Perl, of course, not in Python...:-). But that is part of my motivation for posting this here -- if somebody can show me how to make my dictionaries behave this way, I can play with it and see if it is as useful as I now think. 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"...!). It's a pity to have to write, say, if X.hasElement(a): rather than the natural if a in X and it's a net loss of polymorphism, without any compensating gain that I can see. The way I envision this -- if X chooses to implement a method __contains__, then, for an "a in X" test, that method is called, with a as an argument, and its return value is taken as the test's result. If X has no such method, then we're back to the current semantics of "if a in X", i.e., X must be a sequence, etc etc. 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 way I envision this -- if X chooses to implement a method __enum__, then, that method must return an object which implements methods such as __current__ (returning the current element in the iteration) and __advance__ (returning false if at end, else stepping forward) -- this is more flexible than requiring X itself to implement such methods, of course, because we must support nested loops for a in X: for b in X: # etc, etc just as the current semantics do. This one, I cannot see (being a newbie) 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:-). OK, enough for now, I think... I will highly appreciate any feedback in this matter (if its contents are "we don't need this junk", I would further much appreciate being explained _why_ we don't need it -- e.g., why must there be forever an asymmetry between reading and writing, or, why is it right and proper that in be always O(N) even when applied to a RHS that wouldn't need it to be, etc). Alex From phd at phd.russ.ru Mon Dec 20 06:28:11 1999 From: phd at phd.russ.ru (Oleg Broytmann) Date: Mon, 20 Dec 1999 11:28:11 +0000 (GMT) Subject: time, strptime, daylight saving In-Reply-To: <19991220221547.A716@Ridcully.home> Message-ID: On Mon, 20 Dec 1999, Malcolm Tredinnick wrote: > To answer your question, if you pass a value of -1 as the last element of the > tuple to mktime(), it will fill in the right value from the system's time > zone. I guess that is what you want (use x = -1). Yes, it seems to work for my simple tests! Nice, thank you. Will give it more tests in real programs... Oleg. ---- Oleg Broytmann Foundation for Effective Policies phd at phd.russ.ru Programmers don't die, they just GOSUB without RETURN. From fredrik at pythonware.com Wed Dec 15 07:58:21 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 15 Dec 1999 13:58:21 +0100 Subject: Mutable parameters to functions References: <38578BC7.FE55E37@prism.co.za> Message-ID: <004c01bf46fc$128ff370$f29b12c2@secret.pythonware.com> Alwyn Schoeman wrote: > I've been working through Mark and David's book Learning Python. > > On page 105 there is an example that states that when you change > a argument that is mutable in place (thew!) then you also change > the value of the variable in the callers namespace. > > Ok, now on page 107 there is an example on returning multiple > values. The code is as follows: > def multiple(x,y): > x = 2 > y = [3,4] > return x, y > > X = 1 > L = [1, 2] > X, L = multiple (X, L) > X, L > > result is then (2, [3, 4]) > > Now, the question is whether the statement y = [3, 4] constitutes > an inplace change of the global variable L? nope. a plain assignment never modifies a variable (it only changes the name binding in the relevant namespace) in this example, it's the "X, L = multiple" assignment that replaces (rebinds) the value of L. if another variable points to the same list, it's not affected. likewise, if you change the last two lines to: > X, Y = multiple (X, L) > X, Y, L you get: (2, [3, 4], [1, 2]) > would X = multiple(X,L) yield the same results? yes or no, depending on what you mean ;-) (yes, the assignment inside "multiple" doesn't modify the global variable. or no, if you print both X and L as in the example, you get diff- erent output...) ... summary: the *ONLY* way to modify an object in place is to call a method on it. X.append(1) this includes syntactic sugar: X.member = 1 # calls X.__setattr__ X[0] = 1 # calls X.__setitem__ del X[1:3] # calls X.__delslice__ # etc but not plain assignment statements. hope this helps! From mavip5 at inet.polyu.edu.hk Fri Dec 3 23:37:14 1999 From: mavip5 at inet.polyu.edu.hk (Li Dongfeng) Date: Sat, 04 Dec 1999 12:37:14 +0800 Subject: How do i get output from pope3 while process is running? References: <384858EA.A9C9D2B7@fc.hp.com> Message-ID: <38489A7A.853E1039@inet.polyu.edu.hk> Try the patch(I think you can't do readlines() more than once): 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 From ullrich at math.okstate.edu Sat Dec 11 15:50:37 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 11 Dec 1999 14:50:37 -0600 Subject: Dot product? Message-ID: <3852B91D.6EE31805@math.okstate.edu> Ok, so I'm dense. How do I take the traditional "dot product" of two vectors? In a nice Pythonic sort of way, I mean. Say the vectors are represented as sequences of numerics - then of course I can say just def Dot(X, Y): res = 0 for j in range(len(X)): res = res + X[j] * Y[j] return res and that gives the right answer, but it doesn't look right - seems like the Python way would involve a "for x in X" instead of that "for j in range(len(X))". For example if Transpose returns the transpose of a sequence of sequences (ie Transpose(s)[j][k] = s[k][j]) I can say def Dot(X, Y): res = 0 for (x,y) in Transpose((X,Y)): res = res + x * y return res and that looks "right". For that matter once I have a Transpose I could just use reduce. But when I write a Transpose routine I have the same complaints with the way it looks, only more so. Is there a keen way to do this sort of thing, or do I just have to use the index as above? (Come to think of it I think what I really want is a nice Transpose - that's been coming up a lot, Dot is just one place.) DU From gmcm at hypernet.com Mon Dec 27 09:33:48 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 27 Dec 1999 09:33:48 -0500 Subject: How do I make a Python .bat executable file? In-Reply-To: <38670537.FDBC1785@postoffice.pacbell.net> Message-ID: <1265818152-51405200@hypernet.com> 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 ionel at psy.uva.nl Sat Dec 4 14:53:21 1999 From: ionel at psy.uva.nl (Ionel Simionescu) Date: Sat, 4 Dec 1999 20:53:21 +0100 Subject: Python Code Completion in an Editor References: <82alo7$5ko$1@feed.teaser.fr> Message-ID: <82bri3$27j@mail.psy.uva.nl> Olivier Deckmyn wrote in message news:82alo7$5ko$1 at feed.teaser.fr... | "How can I use python code completion in my own application?" | Is this integration difficult ? starting point --- Basically you need to let your editor know that for a certain key (e.g. TAB) it should: 1. call a function similar to complete(text, state) (see the rlcompleter module, http://www.python.org/doc/lib/completer-objects.html) and 2. use the result from complete to offer the user a choice or automatically write some chars. (Note that you may need to make changes to rlcompleter before you can use it.) How you bind the specific keystroke event with this behavior depends on the API of the text-control you use. ionel From mfletch at tpresence.com Fri Dec 17 13:55:43 1999 From: mfletch at tpresence.com (Mike Fletcher) Date: Fri, 17 Dec 1999 13:55:43 -0500 Subject: LISTS: Extract every other element - SUMMARY Message-ID: One more, ever-so-slightly faster version... Speed benefit above the column-selection Numeric is pretty minor (~.44 (avg) down to .433), but if you've got a need for speed, every few milliseconds counts :) . def test4( data, step=2, offset=0): import Numeric return Numeric.array( data, Numeric.Int32 )[::2] Enjoy, Mike -----Original Message----- From: Randall Hopper [mailto:aa8vb at yahoo.com] Sent: Friday, December 17, 1999 9:13 AM To: Charles G Waldman; Mike Fletcher; Adrian Eyre Cc: python-list at python.org Subject: LISTS: Extract every other element - SUMMARY Thanks for the suggestions. Many of these are really novel ideas I hadn't thought of. I coded each of these up, working with the same list of 100,000 integers. Here are the results. To my amazement, the simple for loop approach is pretty decent, as Mike mentioned. Numeric will get you a little improvement (30-35%) if you use the shape-change column-selection approach Mike suggested. RESULTS: Using range() Using xrange() ----------------------------------------------------------- APPROACH #1 | 100.00% (2.13357 sec) | 100.00% (2.03318 sec) * APPROACH #1b | 96.91% (2.0677 sec) | 98.20% (1.9965 sec) * APPROACH #2 | 690.97% (14.7423 sec) | 719.24% (14.6235 sec) * APPROACH #3 | 121.29% (2.58789 sec) | 122.02% (2.48094 sec) * APPROACH #4 | 308.55% (6.58309 sec) | 323.81% (6.58367 sec) APPROACH #4b | 705.80% (15.0587 sec) | 740.94% (15.0646 sec) APPROACH #5 | 104.58% (2.23128 sec) | 105.42% (2.14335 sec) * APPROACH #6 | 66.42% (1.41702 sec) | 70.39% (1.43119 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 #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] ) ---------------------------------------------------------------------------- - -- Randall Hopper aa8vb at yahoo.com From scarblac-spamtrap at pino.selwerd.cx Mon Dec 13 05:21:03 1999 From: scarblac-spamtrap at pino.selwerd.cx (Remco Gerlich) Date: 13 Dec 1999 10:21:03 GMT Subject: Extracting list of keys from 2-key dictionary References: <831vjl$goe$1@nnrp1.deja.com> Message-ID: mdfranz at my-deja.com wrote: > I'm porting a script from perl that uses: > > dict[a,b] instead of $hash{$a}{$b} > > My goal is to get a unique list of the second keys for a value, when a=x > > In perl, this can be done with: > > @list = keys %{$hash{x}} > > Is there a quicker/easier way in python than the snippet below to do > this? > > for a,b in dict.keys(): > if dict.has_key(x,b): > if b not in list: > list.append(b) I'm not sure what you mean. You have a dict of which the keys are tuples (a,b), and you want to find a list of unique b's given a=x? But those b's are unique automatically, since a is fixed, and there can be only one key (a,b) for each b. So I would do: list = [] for a,b in dict.keys(): if a == x: list.append(b) But it depends on your data to know if it could be faster, I suppose. If you have *many* keys, and a=x for only a few of them, and b has a limited range, you should try out all the possible (x,b) pairs with has_key. -- 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 doylep at ecf.toronto.edu Tue Dec 21 06:11:22 1999 From: doylep at ecf.toronto.edu (doylep at ecf.toronto.edu) Date: Tue, 21 Dec 1999 11:11:22 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> <8399kd$rj1$1@nnrp1.deja.com> <38594BD2.B576A1E@maxtal.com.au> Message-ID: <83nn8o$hrn$1@nnrp1.deja.com> In article <38594BD2.B576A1E at maxtal.com.au>, skaller wrote: > > First, please excuse a digression: "purity" of OO is a > bad thing, because OO doesn't work. What is your reasoning behind the statement that OO doesn't work? Perhaps, if you would rather not explain, you have a URL handy? -- Patrick Doyle doylep at ecf.toronto.edu Sent via Deja.com http://www.deja.com/ Before you buy. From andy at robanal.demon.co.uk Wed Dec 29 15:25:04 1999 From: andy at robanal.demon.co.uk (Andy Robinson) Date: Wed, 29 Dec 1999 20:25:04 GMT Subject: FINANCIAL MODELLING PACKAGE IN PYTHON? References: <841d0c$j0n$1@violet.singnet.com.sg> Message-ID: <387f6d37.25522789@news.demon.co.uk> "Ajith Prasad" wrote: >Andy Robinson's website at http://www.robanal.demon.co.uk mentions his work >on DoubleTalk which uses Python to handle accounting transactions. I saw >also references to work by Kevin McDermott on use of Python in finance. > >I wonder whether anyone is working on a full-fledged financial modelling >package in Python? I have in mind a package similar to IFPS (Interactive >Financial Planning System) described in "Visual IFPS/Plus for Business" >by Paul Gray (details at http://www.amazon.com), but extensible in Python >with OLAP-type functionality. I am sure that there would be a good market >for such a product among finance professionals who need much more than a >spreadsheet but who find current commercially available OLAP packages >inadequate as they have very convoluted and limited rules languages for >expressing business logic, especially, financial or corporate models. Anyone who wants to discuss this, come join the python-finance list at www.egroups.com/group/python-finance/. It's been a bit quiet of late but that's where my stuff and Kevin's is being discussed.. I'm very keen to move Doubletalk forward - it's kind of my life's work - but have had to step back from Python development for a few months. The long term goals are exactly those you outline above and it should all start moving again in a month or so. - Andy Robinson From aahz at netcom.com Wed Dec 15 00:11:51 1999 From: aahz at netcom.com (Aahz Maruch) Date: 15 Dec 1999 05:11:51 GMT Subject: Python complaints References: <000201bf3bd4$2bda5e20$542d153f@tim> <38562655.77A3B3DC@udel.edu> Message-ID: <8377un$oea$1@nntp3.atl.mindspring.net> In article <38562655.77A3B3DC at udel.edu>, Charles Boncelet wrote: >>> Attribution lost: >>>> >>>> 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] > >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? The theory is that because the list comprehension is a single statement, you save some loop overhead (just as map() does). For a large, tight loop, it can make a difference. -- --- 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 cjensen at be-research.ucsd.edu Wed Dec 22 18:57:57 1999 From: cjensen at be-research.ucsd.edu (Curtis Jensen) Date: Wed, 22 Dec 1999 15:57:57 -0800 Subject: embedding Python in C Message-ID: <38616585.2A21FECF@be-research.ucsd.edu> >From a C file, how can I get values from a Python Class? For Example: File: Test.py class Klass: def __init__(self): self.a = 1 self.b = 2 self.c = 3 How can I get the values of a,b, and c from within a C function? Thanks -- Curtis Jensen cjensen at be-research.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From artymiak at safenet.pl Sun Dec 19 06:57:45 1999 From: artymiak at safenet.pl (Jacek Artymiak) Date: Sun, 19 Dec 1999 11:57:45 GMT Subject: Python Powered Logo Message-ID: <385C1DEE.F0F75674@safenet.pl> Hi all! I am working slowly but steadily on my Web site which will use a lot of Python CGI scripts and I would like to use the "Python Powered" logo (the same as the one at www.python.org). Does any of you know who should I ask about a permission? Thanks for your help in advance! Merry Christmas and a Happy Near 2000 to all comp.lang.python readers! 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 helge.hess at mdlink.de Wed Dec 15 14:38:33 1999 From: helge.hess at mdlink.de (Helge Hess) Date: Wed, 15 Dec 1999 20:38:33 +0100 Subject: Zope project management? References: Message-ID: <3857EE39.B9DEAC7C@mdlink.de> Hi Greg, Greg Wilson wrote: > Hello. Has anyone used Zope (or other Python software) to build a project > management platform? I'm looking for something like Microsoft Project, but > (a) cross-platform, (b) web-enabled, and (c) Python friendly. You might want to take a look at our SKYRIX application server. It's not written with Zope but is (a) portable across Unixes, (b) completly web based and (c) scriptable via Python. In release 3.2, which will be made available at CeBIT 2000 (starting in February), a project management app will be included (some stuff is already available in 3.1, but it needs to be completed to be truly called a 'project management' app). A pre-release version of SKYRIX 3.1 is available on every SuSE 6.2 and SuSE 6.3 CD, the released version is available from our ftp server on request. best regards Helge Hess -- SKYRIX-OS Web Application Environment - http://www.skyrix.com SKYRIX-IAS Groupware Application Suite - http://www.skyrix.com From hanwen at dokkum.cs.uu.nl Sun Dec 19 19:40:00 1999 From: hanwen at dokkum.cs.uu.nl (Han-Wen Nienhuys) Date: 20 Dec 1999 01:40:00 +0100 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <029e01bf4879$72585ee0$f29b12c2@secret.pythonware.com> Message-ID: <83jtt0$leh$1@dokkum.cs.uu.nl> In article <029e01bf4879$72585ee0$f29b12c2 at secret.pythonware.com>, Fredrik Lundh wrote: >> def copy(regex, dict, inp=sys.stdin, oup=sys.stdout): >> def repl(match,dict=dict): >> return eval(match.group(1),dict) >> while 1: >> line = inp.readline() >> if not line: >> break >> oup.write(regex.sub(repl,line)) >> >> and wonder that *FOUR*-count-em lines of [..] > >import fileinput >for line in fileinput.input(): > ... How about def repl(match,dict=dict): return eval(match.group(1),dict) oup.write (re.sub (repl, inp.read())) -- Han-Wen Nienhuys, hanwen at cs.uu.nl ** GNU LilyPond - The Music Typesetter http://www.cs.uu.nl/people/hanwen/lilypond/index.html From kgandco at home.com Mon Dec 27 22:40:32 1999 From: kgandco at home.com (ekko) Date: Tue, 28 Dec 1999 03:40:32 GMT Subject: why? Message-ID: 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. From hartmut at oberon.noris.de Tue Dec 21 12:55:37 1999 From: hartmut at oberon.noris.de (hartmut Goebel) Date: Tue, 21 Dec 1999 18:55:37 +0100 Subject: Java -> Python (-> JDBC) -> DB (was Python/Python Windows/PostgreSQL/ODBC) References: <385EB47E.B1DE547B@exceptionalminds.com> Message-ID: <16600352@oberon.noris.de> Timothy Grant (tjg at avalongroup.net) schrieb: >The subject says it all. I have a quite related problem, perhaps somebody has some advice for me. It's a bit complex and off-topic. But since here are a lot of experienced programmers, I hope to find help here :-) Together with a co-worker I'm just about starting an OpenSource project (see below). First step should be a prototype for testing interfaces and performance. Later we (or others :-) may port some of the stuff to another language (e.g C) for native compilation. Currently we are struggling about the - design (abstraction layer or not) - programming language - DB interfacing (via language modules or JDBC -- which is also a language module) - modularization These are the constrains: he me Plattform Windos NT(?) Linux Language Java Python preferance Interfacing via SQL/JDBC via Abstraction-Layer to DBMS onto SQL/JDBC RDBMs InstantDB or PostGreSQL PostGreSQL (not yet settled) Well, nothing is settled yet :-( So for making good progress I had this idea: - Write an absraction layer in Python. I think this would be the quickest way to get the API-prototype. - Allow interfacing from Java to the Python layer, so my co-worker can still programm in Java :-) - If usefull: access the DBMS via JDBC. (I'm quite unsure about this.) Later is should be easy to replace the Python layer with e.g. C and access it fom Python, Java, C, you-name-it. For me, I'm new to Python but seam to like it. I've never done Java, but it does not seam to suite me. My Co-worker did nothing with Python an only a little with Java. Actual Questions: - Is it possible to _easy_ embedd Python into Java, preferable without writing stubs? I've seen JPython but am not quite sure whether is can to this job easily. Esp. I messed a short intro for this specific topic. - Is it possible to access java classes, esp. JDBC from within Python? - Does ist make sense to use JDBC instead of Pythons DB-API? (If he really selects InstandDB, this would become a must :-( - Can Python modules be compiled/transformed into shared libs/dlls? - Is DB-Api easy to use? (I only had a short look at it.) - What software packages do we need to download? I'll gladly accept any RTFM with pointer :-) About the project (for those interested): We are going to re-implement a DB based News/Mail system we both used on Amiga. It's called UMS (Universal Massage System, http://ums.home.pages.de/) and has some nice feature we are still missing an any other plattform. Readers for UMS are very comfortable -- well, have been, since nowerdays Amigas are quite a bit slow ;-) Thanks for all answers! +++hartmut From boud at rempt.xs4all.nl Fri Dec 10 02:16:58 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 10 Dec 1999 07:16:58 GMT Subject: DB-API-oriented example scripts? References: <199912100620.AAA22933@dolphin.mojam.com> Message-ID: <82q9da$1j6$1@news1.xs4all.nl> Skip Montanaro wrote: > I'm gearing up to try and replace a lot of homegrown database code with > MySQL using the MySQLdb module. I'm not much of a relational database > person, however, so I'm fairly unfamiliar with the computational model > expected by the Python DB API. I can muddle my way through SQL. The > MySQLdb module comes with no example code as far as I could tell however, > and relies heavily on the 2.0 version of the Python DB API spec for docs, > which contains no examples. The DB-API II stuff is quite easy to use. You must however separate the SQL statements from the Python statements - SQL is another language, that takes a bit of learning. For the rest, it's really simple. Open a connection, throw the SQL together with a dictionary of parameters at the connection, and you get the returned rows. One example (still not perfect - there are a few problems with relf-referring tables, and I wonder wether the object hierarchy is as clean as it should be), is my dbObjects module. This constructs a datadictionary representing the relations between tables, and then generates the relevant SQL, sends it to the connection, together with the dictionary of values and returns the values in objects. There are complications, like deferred fetching and things like that, but MySQL doesn't really support it. It's better to ask for small sets of data, instead of large sets that you retrieve in many passes. > Any suggestions? I'm not sure about _good_, but take a look at it: http://www.xs4all.nl/~bsarempt/python For an example of an application using it: http://www.xs4all.nl/~bsarempt/linguistics - but that example also needs PyKDE/PyQt. -- Boudewijn Rempt | http://denden.conlang.org From pinard at IRO.UMontreal.CA Thu Dec 9 19:25:32 1999 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 09 Dec 1999 19:25:32 -0500 Subject: FORTRAN (was Re: indentation) In-Reply-To: Christian Tismer's message of "Fri, 10 Dec 1999 00:08:59 +0100" References: <65118AEEFF5AD3118E8300508B124877073CC6@webmail.altiris.com> <384EF139.91ACD637@bioreason.com> <38500A94.FB6EF7DE@be-research.ucsd.edu> <3850368B.F104F1D9@appliedbiometrics.com> Message-ID: 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. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From ivanlan at callware.com Mon Dec 27 10:47:44 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Mon, 27 Dec 1999 08:47:44 -0700 Subject: Xitami CGI scripts & shebang (was RE: How do I make a Python .batexecutable file?) References: <6D8A17398E28D3119F860090274DD7DB4B3D87@pces.cadlab.it> Message-ID: <38678A20.63C6F8AB@callware.com> Hi All-- Alex Martelli wrote: > > 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). > The hash-bang trick is also critical if you're using Apache for Win95/98/NT, too. In my book, I give an example program that uses Python to ensure that CGI programs start with the correct #! line; this is important, because I mirror my real webserver (Apache on NT) with a backup at home (Apache on RH Linux 5.2), and Linux won't accept #! when it points to a slime link. -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 aahz at netcom.com Tue Dec 28 10:38:19 1999 From: aahz at netcom.com (Aahz Maruch) Date: 28 Dec 1999 15:38:19 GMT Subject: Patch: httplib.py default timeout References: <840anc$9j8$1@nntp8.atl.mindspring.net> Message-ID: <84alhb$tnn$1@nntp1.atl.mindspring.net> In article , Phil Mayes wrote: > >Winsock v1.1 doesn't support SO_RCVTIMEO: That's a good point. I'd better wrap self.sock.setsockopt() in a try/except (with except:pass). -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 4 days and counting! From skaller at maxtal.com.au Thu Dec 16 12:36:29 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 17 Dec 1999 04:36:29 +1100 Subject: Python complaints References: <000201bf3bd4$2bda5e20$542d153f@tim> <38562655.77A3B3DC@udel.edu> <8377un$oea$1@nntp3.atl.mindspring.net> Message-ID: <3859231D.50B1681@maxtal.com.au> Aahz Maruch wrote: > > In article <38562655.77A3B3DC at udel.edu>, > >>>> 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] > > > >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? > > The theory is that because the list comprehension is a single statement, > you save some loop overhead (just as map() does). For a large, tight > loop, it can make a difference. There is also the potential for comprehensions to be evaluated lazily: this save a HUGE amount of space, and a considerable amount of time. -- 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 aahz at netcom.com Thu Dec 30 18:39:55 1999 From: aahz at netcom.com (Aahz Maruch) Date: 30 Dec 1999 23:39:55 GMT 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> Message-ID: <84gqgb$s46$1@nntp6.atl.mindspring.net> 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. ;-) >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. -- --- 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 robin at alldunn.com Fri Dec 3 15:35:07 1999 From: robin at alldunn.com (Robin Dunn) Date: Fri, 3 Dec 1999 12:35:07 -0800 Subject: Using wxPython in COM server References: <3844dc35.143149908@news.mch.sni.de> Message-ID: Robin Becker wrote in message news:CLP9PCAkD+R4EwQr at jessikat.demon.co.uk... > In article , Robin Dunn > writes > ... > >At a minimum, you might try something like this: > > > > def RequestYesNo(self): > > from wxPython.wx import * > > class MyApp(wxApp): > > def OnInit(self): > > return true > > app = MyApp(0) > > > > win = wxDialog(NULL, -1, "HELLO", wxDefaultPosition, wxSize(350,200)) > > wxStaticText(win, -1, "This is a wxDialog", wxPoint(20, 20)) > > wxButton(win, wxID_OK, " OK ", wxPoint(75, > >120),wxDefaultSize).SetDefault() > > wxButton(win, wxID_CANCEL, " Cancel ", wxPoint(200, 120),wxDefaultSize) > > val = win.ShowModal() > > win.Destroy() > > return val > > > > > >Although I am not sure what you might lose by not getting into the > >app.MainLoop... > > > ... > > I tried this snippet and it works the first time, but complains about > only being allowed one app per process. How do I shut down wxPython > cleanly and later restart it? Did you do the win.Destroy()? That message is generated if there are any exiting top level windows when you try to create a new app object. Actually, now that I think about it for a minute, this is the problem of not getting into the MainLoop. Top level windows don't delete themselves when Destroy is called because there may still be pending events. So instead they are deleted in idle time which is processed as part of the main loop. Try this: Add a call to app.MainLoop() just before the last line. This should return almost immediately because once it deletes the wxDialog there will be no top level windows left and that is the signal for the mainloop to terminate. -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From sdm at dcs.ed.ac.uk Wed Dec 8 06:59:36 1999 From: sdm at dcs.ed.ac.uk (Stephen McColl) Date: 8 Dec 1999 11:59:36 GMT Subject: JPython - Problems using "re" Message-ID: <82lh78$12h$1@rairidh.dcs.ed.ac.uk> hi there, I've only been using JPython for a couple of weeks and have found it to be a great language. I've been trying to learn it and have been reasonably successfull but have come up against a problem using the "re" regular expression library. In Python, there is an operation called "findall" that can be applied over a string, and to quote the Python documentation.. findall(pattern, string) : Return a list of all non-overlapping matches of pattern in string. If one or more groups are present in the pattern, return a list of groups; this will be a list of tuples if the pattern has more than one group. Empty matches are included in the result. New in version 1.5.2. But in JPython, (JPython 1.1 beta 4), "findall" isn't a method in the "re" module. Is there another way to produce the same result (scan a string and return a list of all matches)? Thanks for any help in advance. stephen. -- _________________________________________ stephen mccoll sdm at dcs.ed.ac.uk 4th Year Computer Science, Edinburgh University From tiddlerdeja at my-deja.com Wed Dec 1 13:35:28 1999 From: tiddlerdeja at my-deja.com (tiddlerdeja at my-deja.com) Date: Wed, 01 Dec 1999 18:35:28 GMT Subject: SyntaxError: can't assign to function call win32com.client Message-ID: <823ppg$o2b$1@nnrp1.deja.com> I'm trying to mirror this VB code (which works) with python code: objUser.DynamicProperty("BILLING_ADDRESS2") = "3 The Street" This code works in VB but in python I get the error: SyntaxError: can't assign to function call Can you tell me what syntax I need to use for python? Any help greatly appreciated. I don't want to have to use VB! Kieran Breen Sent via Deja.com http://www.deja.com/ Before you buy. From pythonnewsgrp at my-deja.com Wed Dec 8 20:25:21 1999 From: pythonnewsgrp at my-deja.com (pythonnewsgrp at my-deja.com) Date: Thu, 09 Dec 1999 01:25:21 GMT Subject: periodic PendingCall in embedding Message-ID: <82n0du$4gq$1@nnrp1.deja.com> Hi I'm building a python extension module and need to schedule the periodic calling of a C routine in the extension code (it's a sort of event handler, but that's not really important), and I'm looking at Py_AddPendingCall, which looks very suitable as it makes sure the C routine is called when the interpreter is between instructions. However, when Py_MakePendingCalls schedules a call, if that function wants to schedule itself for execution again _after_ the next python instruction, it looks like it can't, as calling Py_AddPendingCall will cause itself to be immediately reexecuted upon returning? Am I wrong or is there a way to get round this? Any help would be most appreciated, thanks Christopher Sent via Deja.com http://www.deja.com/ Before you buy. From jfk at pobox.com Thu Dec 9 12:53:03 1999 From: jfk at pobox.com (Jack Knight) Date: Thu, 09 Dec 1999 17:53:03 +0000 Subject: ODBC Problem on IIS4 Message-ID: <384FEC7E.29FA069A@pobox.com> Hi, Sorry if this is a FAQ, but I can't find anything on it anywhere! I am getting the following error when trying to do a simple SQL lookup: File "C:\InetPub\cgi-bin\loginMethod.py", line 54, in getCName cursor.execute(query,params) dbi.internal-error: [Microsoft][ODBC Microsoft Access 97 Driver] Invalid argument. in EXEC Setup is: Windows NT4 SP5, IIS4, ODBC V3.5. Python 1.5. Offending Code fragment: def login(id,password): realPwd=decrypt(password) # Perform the query to the database connection=odbc.odbc(cfg.DSN) cursor=connection.cursor() params=[id,realPwd] query="select CustomerID, Password, Status from CustomerDetails where CustomerID=:1 and Password=:2" cursor.execute(query,params) row=cursor.fetchone() The DSN is all OK, since Perl works fine. Do I perhaps have a wrong dbi or odbc module for Python? TiA, Jack Knight -------------- next part -------------- An HTML attachment was scrubbed... URL: From fdrake at acm.org Thu Dec 23 09:30:38 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 23 Dec 1999 09:30:38 -0500 (EST) Subject: Matching a constant string at beginning In-Reply-To: <9t9ln6lwxxd.fsf@mraz.iskon.hr> References: <14434.10917.222100.686450@weyr.cnri.reston.va.us> <9t9ln6lwxxd.fsf@mraz.iskon.hr> Message-ID: <14434.12814.5547.909891@weyr.cnri.reston.va.us> Hrvoje Niksic writes: > Very cool! And all thanks to that python-mode hacker, Barry Warsaw! > It's long bothered me that you can't check whether a string starts > with a phrase without either consing (s[:3] == 'foo') or resorting to > regexps (re.match('^foo', s)). What I've done occaisionally to avoid the magic number problem is this: s1 = some string... s2 = "match this!" if s1[:len(s2)] == s2: # whatever... It's a little too idiomatic for me to really like it, but makes it easier to keep track of. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From tholap at compuserve.com Thu Dec 9 07:03:20 1999 From: tholap at compuserve.com (Olaf Appelt) Date: Thu, 9 Dec 1999 13:03:20 +0100 Subject: Embedding questions References: <82n5ec$e2a$1@ssauraab-i-1.production.compuserve.com> Message-ID: <82o7rt$gsf$1@ssauraac-i-1.production.compuserve.com> Hi Quinn, thanks for commenting. > 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. You misunderstand my problem. There's other state information coded into class Currency, besides just the value. I need to couple a given name with a certain instance, not just any instance of the right 'type'. Perhaps another example makes it clearer: c = Currency (30) c.SetMyState (whatever) c = Currency (50) Isn't it true that the second assignment creates a new instance of class Currency, leaving my former instance with it's state set to whatever, no longer bound to the name c? > >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. Thanks for the pointers. Olaf From wlfraed at ix.netcom.com Tue Dec 7 10:38:29 1999 From: wlfraed at ix.netcom.com (Dennis Lee Bieber) Date: Tue, 07 Dec 1999 07:38:29 -0800 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> <826a3f$32jc@f1n1.spenet.wfu.edu> Message-ID: <2yZNODmQmsrUYEYYZwgwiMJT+xz2@4ax.com> On 02 Dec 1999 13:16:23 -0500, Lloyd Zusman declaimed the following in comp.lang.python: > > But can you cause FORTRAN to think that there is no integer between > -1 and +1? :) Old FORTRAN IV on a system that doesn't write-protect "constants"... easily. program main call fakeout(0) ... subroutine fakeout(iarg) iarg = iarg + 1 return end -- > ============================================================== < > 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 tseaver at starbase.neosoft.com Wed Dec 1 11:51:20 1999 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 1 Dec 1999 16:51:20 GMT Subject: wish: multiline comments References: <000b01bf3c10$4faf3910$3acbd9c2@peridot.optichrome.com> <018801bf3c12$d9722e80$f29b12c2@secret.pythonware.com> <009901bf3c15$6d5c5290$4500a8c0@thomasnotebook> Message-ID: In article <009901bf3c15$6d5c5290$4500a8c0 at thomasnotebook>, Thomas Heller wrote: >> 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. > >AFAIK, python chokes on source files with more than >32767 lines (or was it 65536)? >But I never tried it. > [/home/tres] $ uname -a Linux silver 2.0.36 #1 Tue Oct 13 22:17:11 EDT 1998 i586 unknown [/home/tres] $ python Python 1.5.1 (#1, Jan 31 1999, 17:30:49) [GCC 2.7.2.3] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> f = open( 'foo.py', 'w' ) >>> for i in range( 100000 ): ... f.write( 'x = 1\n' ) ... >>> f.close() >>> ^D [/home/tres] $ python foo.py Memory fault (core dumped) [/home/tres] $ gdb python core GNU gdb 4.17.0.4 with Linux/x86 hardware watchpoint and FPU support Copyright 1998 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux"... Core was generated by `python foo.py'. Program terminated with signal 11, Segmentation fault. Reading symbols from /lib/libdl.so.2...done. Reading symbols from /lib/libpthread.so.0...done. Reading symbols from /lib/libm.so.6...done. Reading symbols from /lib/libc.so.6...done. Reading symbols from /lib/ld-linux.so.2...done. #0 0x805f813 in PyNode_AddChild (n1=0x4005eff8, type=265, str=0x0, lineno=32768) at node.c:73 73 n = &n1->n_child[n1->n_nchildren++]; (gdb) where #0 0x805f813 in PyNode_AddChild (n1=0x4005eff8, type=265, str=0x0, lineno=32768) at node.c:73 #1 0x805fa46 in push (s=0x80b9340, type=265, d=0x808fb30, newstate=1, lineno=32768) at parser.c:178 #2 0x805fbaf in PyParser_AddToken (ps=0x80b9340, type=1, str=0x9d3a588 "x", lineno=32768) at parser.c:263 #3 0x804f4eb in parsetok (tok=0x80ae1d8, g=0x8090390, start=257, err_ret=0xbffffc24) at parsetok.c:163 #4 0x804f3f1 in PyParser_ParseFile (fp=0x8094908, filename=0xbffffeb2 "foo.py", g=0x8090390, start=257, ps1=0x0, ps2=0x0, err_ret=0xbffffc24) at parsetok.c:113 #5 0x805bf5c in PyParser_SimpleParseFile (fp=0x8094908, filename=0xbffffeb2 "foo.py", start=257) at pythonrun.c:946 #6 0x805bdcd in PyRun_File (fp=0x8094908, filename=0xbffffeb2 "foo.py", start=257, globals=0x8095d68, locals=0x8095d68) at pythonrun.c:855 #7 0x805b5a6 in PyRun_SimpleFile (fp=0x8094908, filename=0xbffffeb2 "foo.py") at pythonrun.c:565 #8 0x805b235 in PyRun_AnyFile (fp=0x8094908, filename=0xbffffeb2 "foo.py") at pythonrun.c:444 #9 0x804f281 in Py_Main (argc=2, argv=0xbffffdf8) at main.c:286 #10 0x804ed22 in main (argc=2, argv=0xbffffdf8) at python.c:10 (gdb) It GPFs on NT4 with 1.5.2, as well. Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From tismer at appliedbiometrics.com Sun Dec 19 13:15:58 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sun, 19 Dec 1999 19:15:58 +0100 Subject: LISTS: Extract every other element - SUMMARY References: <19991217091256.A168025@vislab.epa.gov> <004801bf48a8$74d7ab60$3acbd9c2@peridot.optichrome.com> <19991217134826.A183473@vislab.epa.gov> Message-ID: <385D20DE.1E7AA3D@appliedbiometrics.com> Hi Kids, the following will outperform everything by far, also Numeric. hee hee. Randall Hopper wrote: > > Adrian Eyre: > |> I coded each of these up, working with the same list of 100,000 > |> integers. Here are the results. > |> > |> [snip] > | > |Did you try them all with the -O option? > > No, these were without -O. -O betters the times around 4-5%. Relative > performance rankings stay the same though. > > > python odd_elements.py > APPROACH #1 : 100.00% (2.07391 sec) > APPROACH #1b: 96.95% (2.01062 sec) > APPROACH #2 : 697.01% (14.4554 sec) > APPROACH #3 : 122.20% (2.53422 sec) > APPROACH #4 : 315.16% (6.53619 sec) > APPROACH #4b: 719.41% (14.92 sec) > APPROACH #5 : 109.06% (2.26185 sec) > APPROACH #6 : 68.83% (1.42751 sec) Please test approach 7, it should range at 40% or so. def slice100(d): return [ d[ 1],d[ 3],d[ 5],d[ 7],d[ 9],d[11],d[13],d[15],d[17],d[19], d[21],d[23],d[25],d[27],d[29],d[31],d[33],d[35],d[37],d[39], d[41],d[43],d[45],d[47],d[49],d[51],d[53],d[55],d[57],d[59], d[61],d[63],d[65],d[67],d[69],d[71],d[73],d[75],d[77],d[79], d[81],d[83],d[85],d[87],d[89],d[91],d[93],d[95],d[97],d[99], ] def algo7(data): l = len(data) res = (l+1)/2 * [None] for p in xrange(0, l-99, 100): q = p/2 res[q:q+50] = slice100(data[p:p+100]) for i in range(p+1, l, 2): res[i/2] = data[i] return res The key observation is this: Access to the indexed elements costs three fast opcodes each: Here the end of its code. 342 LOAD_FAST 0 (d) 345 LOAD_CONST 49 (97) 348 BINARY_SUBSCR 349 LOAD_FAST 0 (d) 352 LOAD_CONST 50 (99) 355 BINARY_SUBSCR 356 BUILD_LIST 50 359 RETURN_VALUE I used this trick long before when I needed fast access to many database columns in arbitrary order. My approach was to create a function on the fly with explicit indexing. Hard to beat. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From doughellmann at home.com Mon Dec 13 07:27:17 1999 From: doughellmann at home.com (Doug Hellmann) Date: Mon, 13 Dec 1999 12:27:17 GMT Subject: Suitability of Python for a Big Application? References: <830vic$r2t$1@nnrp1.deja.com> <83125j$5d$1@news1.xs4all.nl> Message-ID: <3854E787.44EBDAE3@home.com> Boudewijn Rempt wrote: > > If you really need to use a variety of databases, then you probably > can't rely on stored procedures/packages to do the server-side work, > because there isn't a database where those work in the same way. And > even so, support for, say Oracle packages, is skimpy outside Oracles > own tools. I'm going to install Oracle next week to try whether they > can be accessed from Python, though. Get the DCOracle package distributed by Digital Creations from www.zope.org. It provides excellent access to Oracle 8. Doug From shouldbe at message.com Thu Dec 30 09:38:53 1999 From: shouldbe at message.com (Arinte) Date: Thu, 30 Dec 1999 14:38:53 GMT Subject: No constructor calls???? Message-ID: <18Ka4.3688$9e3.188173@newsread1.prod.itd.earthlink.net> When I have this code the constructor is called xpac=PossDevice.PossArg("12345678",21) devlist.append( xpac ) but, this code doesn't seem to function devlist.append( PossDevice.PossArg("12345678",21) ) Is the second one invalid or something? How can I do the first one in one call? TIA From smigowsky at dspace.de Thu Dec 9 03:43:59 1999 From: smigowsky at dspace.de (Stefan Migowsky) Date: Thu, 9 Dec 1999 09:43:59 +0100 Subject: Win32 and the clipboard Message-ID: <326536345498D311B3BC00105A39802A074522@newsintern.dspace.de> Hi, 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. Stefan mailto:smigowsky at dspace.de http://www.dspace.de >-----Original Message----- >From: Greg Landrum [mailto:glandrum at my-deja.com] >Sent: Thursday, December 09, 1999 7:39 AM >To: python-list at python.org >Subject: Win32 and the clipboard > > > > >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. >-- >http://www.python.org/mailman/listinfo/python-list > From m.faassen at vet.uu.nl Mon Dec 13 04:53:41 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 13 Dec 1999 09:53:41 GMT Subject: Suitability of Python for a Big Application? References: <830vic$r2t$1@nnrp1.deja.com> <83181a$n90$1@ssauraab-i-1.production.compuserve.com> Message-ID: <832fn5$iio$2@newshost.accu.uu.nl> 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. This may be true, but is debatable, and.. [snip] > 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. While smalltalk implementations may be faster than Python, Smalltalk is just as dynamically typed as Python, isn't it? 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? 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++!); static type checking doesn't magically make large scale engineering problems go away, though it can help, of course. 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 Thu Dec 9 11:15:41 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 9 Dec 1999 17:15:41 +0100 Subject: How to add element to the list in C extension module? References: Message-ID: <02ff01bf4260$a4940180$f29b12c2@secret.pythonware.com> Wojciech Zabolotny wrote: > I'd rather prefere to do it in the pure C, due to the portability reasons. > Anyway, what API function should I use to add a new element to the list > or tuple? the list object API, perhaps? http://www.python.org/doc/current/api/listObjects.html From gabor.papp at caere.com Wed Dec 15 11:20:21 1999 From: gabor.papp at caere.com (Gabor Papp) Date: Wed, 15 Dec 1999 17:20:21 +0100 Subject: cursors for Tk References: <38534DC5.82CEB43A@trojanslair.zzn.com> Message-ID: <3857BFC4.F501503F@caere.com> > can someone tell me a list of all the cursor types available for a > windows 95 machine? you can find the list of cursor types in the tk source in the win\rc\tk.rc file. the available names are 'X_cursor','based_arrow_down','based_arrow_up','boat','bogosity','bottom_left_corner', 'bottom_right_corner','bottom_side','bottom_tee','box_spiral','center_ptr','circle','clock', 'coffee_mug','cross','cross_reverse','crosshair','diamond_cross','dot','dotbox','double_arrow', 'draft_large','draft_small','draped_box','exchange','fleur','gobbler','gumby','hand1','hand2', 'heart','icon','iron_cross','left_ptr','left_side','left_tee','leftbutton','ll_angle','lr_angle', 'man','middlebutton','mouse','pencil','pirate','plus','question_arrow','right_ptr','right_side', 'right_tee','rightbutton','rtl_logo','sailboat','sb_down_arrow','sb_h_double_arrow', 'sb_left_arrow','sb_right_arrow','sb_up_arrow','sb_v_double_arrow','shuttle','sizing', 'spider','spraycan','star','target','tcross','top_left_arrow','top_left_corner', 'top_right_corner','top_side','top_tee','trek','ul_angle','umbrella','ur_angle','watch', 'xterm' From gmcm at hypernet.com Fri Dec 17 21:35:40 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 17 Dec 1999 21:35:40 -0500 Subject: Python on NT systems (help a Unix guy, please) In-Reply-To: <19991218113757.A637@Ridcully.home> Message-ID: <1266638846-2041198@hypernet.com> Malcolm Tredinnick asks: > The problem: disk space is a little tight on the target machine. > Since I don't have any Windows machines at home at the moment, > could somebody please let me know (just roughly) the disk space > requirements for Python on NT? (private email is ok if you don't > want to spam the list). A binary-only but fully functional Python + Tk built with my installer will occupy less than 2M. http://starship.python.net/crew/gmcm/install.html > Just for comparison purposes, a reasonably standard Python > install on my Linux box (the only additional thing is the LLNL > Numeric package) takes up just under 24MB, the requirements for > tkinter is another 5.5MB with wxPython (source code and all) > being 18MB (plus whatever wxWindows requires). > > Thanks in advance, > Malcolm Tredinnick > > -- > Despite the high cost of living, have you noticed how popular it > remains? > > > -- > http://www.python.org/mailman/listinfo/python-list - Gordon From jfarrell at mincom.com Sun Dec 5 19:59:43 1999 From: jfarrell at mincom.com (John Farrell) Date: Mon, 06 Dec 1999 10:59:43 +1000 Subject: Java 1.2 and JPython References: <199912011207.HAA04934@python.org> Message-ID: <384B0A7F.B685E594@mincom.com> sdossett at metaphoria.net wrote: > 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. Scott, anything on the CLASSPATH is available, so it's a fair bet that JPython works with JDK1.3 as well. 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 fredrik at pythonware.com Wed Dec 29 06:53:12 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 29 Dec 1999 12:53:12 +0100 Subject: newbie question... References: <3869229B.C06B94E5@earthlink.net> <3869298b.8634305@news.isomedia.com> Message-ID: <00a901bf51f3$499c8340$f29b12c2@secret.pythonware.com> Eugene Goodrich wrote: > The example Justin Sheehy gave is certainly better most of the time, > but if you feel you _must_ do it like that Perl code (say, you've got > a 100 MB file you don't feel like putting into memory all at once), > you can do this: > > oFile = open ('delme.txt', 'r') > sStr = oFile.readline() > while (sStr): > # do something with sStr > sStr = oFile.readline () > oFile.close() is that microsoft python? ;-) fwiw, the standard pydiom (at least as long as we're talking 1.5.2) is: f = open('delme.txt') # rt is default while 1: s = f.readline() if not s: break # do something > Someone please correct me if this does not have the reduced memory > requirements for large files that I believe it does. for a better speed/memory tradeoff, you can use "readlines" in the following way: f = open('delme.txt') while 1: lines = f.readlines(100000) if not lines: break for s in lines: # do something also see the fileinput module. "Get into a rut early: Do the same processes the same way. Accumulate idioms. Standardize. The only difference between Shakespeare and you was the size of his idiom list - not the size of his vocabulary." -- Alan Perlis From thomas at bibsyst.no Fri Dec 31 07:09:32 1999 From: thomas at bibsyst.no (Thomas Weholt) Date: Fri, 31 Dec 1999 13:09:32 +0100 Subject: IMDB-interface/script ( Was : Re: RPM-interface/module ) References: <386B3CDB.FF843280@bibsyst.no> Message-ID: <386C9CFC.451A18DB@bibsyst.no> Hi, Has anybody written or tried to access International Movie Database, IDBM, using python before ?? Thomas From dworkin at ccs.neu.edu Thu Dec 23 10:44:13 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 23 Dec 1999 10:44:13 -0500 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: Anders M Eriksson writes: > > def ternaryif(a, b, c): > > if a: return b > > return c > Now I'm confused! in the ternaryif function how will both b and c be > evaluated? Not even in the function, but before it really starts. :-) Before `a' is even tested for truth or falsity, all three parameters have been evaluated. In the case where the parameters are simple data types, this doesn't matter. But if evaluating them causes side effects, it is important. If I called ternaryif like this: ternaryif(somevalue, Bfunc(), Cfunc()) The variables b and c would be set to the values returned by these functions. Regardless of the value of `somevalue', both Bfunc() and Cfunc() have already been executed. This is very different from a short-circuiting operator. -Justin From jestess at wcnet.net Wed Dec 29 23:07:28 1999 From: jestess at wcnet.net (John Estess) Date: Wed, 29 Dec 1999 22:07:28 -0600 Subject: console package? Message-ID: <386ADA80.B17F335D@wcnet.net> Is there a console package (like dialog) for Python? Where? I'm seriously considering using Python for an installation program (without X), but can't find a decent package to do so. The thought of writing a package for dialog doesn't fill me with joy :-( -- _/ _/_/_/ || John Estess _/ _/ _/_/ || jestess at wcnet.net _/_/_/ _/_/_/ || From fredrik at pythonware.com Wed Dec 8 03:00:02 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 8 Dec 1999 09:00:02 +0100 Subject: Converting data to little endian References: <82jjc6$ks1$1@nnrp1.deja.com> Message-ID: <011401bf4152$3ce09c60$f29b12c2@secret.pythonware.com> Travis Oliphant 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). > > One possibility is to use the NumPy extensions and store your data in a > multiarray object. There is a byteswapped method of the multiarray object > that lets you byteswap your data. footnote: the standard array module also provides a byteswap operation: >>> import array >>> a = array.array("i", [1, 2]) >>> a array('i', [1, 2]) >>> a.byteswap() >>> a array('i', [16777216, 33554432]) > There is also a way to check the endianness of your machine (so > you can determine whether or not to byteswap). from array-example-4.py in the eff-bot guide: def little_endian(): return ord(array.array("i",[1]).tostring()[0]) From nathan at islanddata.com Mon Dec 6 12:06:23 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Mon, 06 Dec 1999 09:06:23 -0800 (PST) Subject: Very useful message -- Hah! In-Reply-To: Message-ID: On 04-Dec-99 Dan Grassi wrote: > It seems that by design python, by design, is not to be used as a cgi > scripting language -- otherwise why would it produce this very > meaningful > message at the slightest syntax error: > > > Internal Server Error This is the web server's error. You will have to check the web server cgi error logs to find python's (much more useful) error message. If nothing else, this offers you a little bit of security. You wouldn't want hackers knowing exactly what kind of errors they can produce or give away telling tracebacks. However, ideally you will never have these errors in a production situation, so this is what I do when under development: Wrap the whole thing (perhaps a main function) in a try block. catch any uncaught errors outside and print it out nicely. Here's a scrap of code I use: def print_exception(): from traceback import print_exc tempstd = sys.stderr sys.stderr = sys.stdout print_exc() sys.stderr = tempstd .... try: main() except: print 'Content-Type: text/plain' print print 'An unexpected error has occurred. Please report' print 'the following information to the webmaster at' print 'webmaster at website.com' print print print_exception() ---------------------------------- Nathan Clegg nathan at islanddata.com From shouldbe at message.com Thu Dec 2 12:14:17 1999 From: shouldbe at message.com (Arinte) Date: Thu, 2 Dec 1999 12:14:17 -0500 Subject: Deducing classes??? Message-ID: <826933$1amc$1@rtpnews.raleigh.ibm.com> Questions peppered in the comments of the code. I have these python classes. class PossDevice: def __init__(self, devname, hand, classname): self.devname = devname <---- Are these private to the class? self.handle = hand <---- Are these private to the class? self.classname = classname <---- Are these private to the class? def IOCTL(self, command, dargs): poss.IOCtl(self.devname,dargs) #make this pass the ioctl command as an PossArg with a special name 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 devlist = [10,9] devlist[0] = PossDevice.PossArg("check",10) devlist[1] = PossDevice.PossArg("boo","testing strings") #face = devlist[0] print devlist[0].getName() print devlist[0].getValue() ooo = PossDevice.PossDevice(10,"devlist",79) ooo.IOCTL(10,devlist) ---------------------------------------------------------------------------- ---------------------------------------- Then I have this c/c++ code talking with it. PyObject *IOCtl(PyObject* self,PyObject* args){ int rets(0); PosArgEx* p=createArgs(PyObject_GetItem(args, Py_BuildValue("i",1) )); delete p; return Py_BuildValue("i",rets); } PosArgEx* createArgs(PyObject* pobj) { int icnt(PyObject_Length(pobj)); // gives a value of 2 as expected if (icnt==-1) return NULL; PosArgEx* pargs = new PosArgEx(icnt); PyObject *tobj,*vobj,*nobj,*dummy; char *typestr; char* namestr; char* vstr; long val(0); for(int idx=0;idx Message-ID: <83aot6$1q7t$1@news.tht.net> On Thu, 16 Dec 1999 14:30:24 +0100, 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. Your in luck, simple things are my speciality! >>> import os,sys >>> os.path.getsize(sys.executable) 24638 >>> os.stat(sys.executable)[6] 24638 >>> From pramod at tcsi.com Thu Dec 9 02:58:53 1999 From: pramod at tcsi.com (Pramod Kumar Singh) Date: Wed, 08 Dec 1999 23:58:53 -0800 Subject: Now crash in python References: <384EBB3F.538D8319@tcsi.com> Message-ID: <384F613D.AC68A7D0@tcsi.com> As per an advice I upgraded to Python 1.5.2 and TCL/TK 8.2.2. This time the crash is in python. The stack is given below. Does anybody has any clue?? (dbx) where current thread: t at 14 =>[1] reset_exc_info(0x81a20, 0x4, 0x0, 0x0, 0x1e7250, 0xffffffff), at 0x6f010ca0 [2] eval_code2(0x80b00, 0x0, 0x1e2334, 0x1, 0x53, 0x11000b), at 0x6f010404 [3] call_function(0x0, 0x0, 0x0, 0x0, 0x133360, 0x6e596144), at 0x6f013544 [4] PyEval_CallObjectWithKeywords(0x153988, 0x1daf30, 0x0, 0x6ce01fc4, 0x6ce01fc0, 0x133368), at 0x6f012954 [5] builtin_apply(0x0, 0x1daeb0, 0x0, 0x0, 0x64, 0x133380), at 0x6efe8a5c [6] call_builtin(0x7ff48, 0x1daeb0, 0x0, 0xe, 0x133368, 0xb9), at 0x6f012c20 [7] PyEval_CallObjectWithKeywords(0x7ff48, 0x1daeb0, 0x0, 0x0, 0x1daeb0, 0x2), at 0x6f012984 [8] eval_code2(0x1daf30, 0x0, 0x10dc50, 0x2, 0x83, 0x12e235), at 0x6f00f47c [9] eval_code2(0x13c5f8, 0x0, 0x142c24, 0x1, 0x83, 0x1b4586), at 0x6f00f154 [10] call_function(0x0, 0x0, 0x0, 0x0, 0x47657454, 0x3), at 0x6f013544 [11] PyEval_CallObjectWithKeywords(0x1e3d30, 0x82e90, 0x0, 0x6ce02774, 0x6ce02770, 0x1e3d30), at 0x6f012954 [12] builtin_apply(0x0, 0x1daf90, 0x0, 0x0, 0x106d04, 0x1e3d30), at 0x6efe8a5c [13] call_builtin(0x7ff48, 0x1daf90, 0x0, 0x0, 0x1e3d30, 0x66), at 0x6f012c20 [14] PyEval_CallObjectWithKeywords(0x7ff48, 0x1daf90, 0x0, 0x0, 0x1daf90, 0x2), at 0x6f012984 [15] eval_code2(0x82e90, 0x0, 0x150f28, 0x2, 0x83, 0x1da216), at 0x6f00f47c [16] call_function(0x0, 0x0, 0x0, 0x6e9e6b60, 0x82e90, 0xffffffff), at 0x6f013544 [17] PyEval_CallObjectWithKeywords(0x1e3cd0, 0x0, 0x0, 0x0, 0x0, 0x6ce02e30), at 0x6f012954 [18] dyPythonServer::_PyExecute(inst = 0x1e1080, opName = 0x6f780 "op2", mode = 1, errorData = CLASS, req = CLASS, res = CLASS), line 428 in "dyPythonServer.C" From python-list at teleo.net Thu Dec 30 15:50:22 1999 From: python-list at teleo.net (Patrick Phalen) Date: Thu, 30 Dec 1999 12:50:22 -0800 Subject: newbie question... In-Reply-To: <14443.40361.173274.782578@weyr.cnri.reston.va.us> References: <3868C1D2.614DA917@earthlink.net> <14443.40361.173274.782578@weyr.cnri.reston.va.us> Message-ID: <99123012552205.03415@quadra.teleo.net> [Fred L. Drake, Jr., on Thu, 30 Dec 1999] :: Alexander Sendzimir writes: :: > According to David Beazley's invaluable book, mailbox.py is an undocumented :: > module. However, since 1.5.1 of python this module has been modified. Does :: :: Alexander, :: It is documented in the current version of the documentation. See: :: :: http://www.python.org/doc/current/lib/module-mailbox.html Beazley simply means it is one of a group of modules which are undocumented *in his book*. He says as much in the beginning section of Undocumented Modules, page 242. From cwr at cts.com Mon Dec 6 01:54:17 1999 From: cwr at cts.com (Will Rose) Date: 6 Dec 1999 06:54:17 GMT Subject: Very useful message -- Hah! References: <82do53$2rhr$1@hub.org> <384A9BE0.B345509@inka.de> <384ABC57.DDC3B61E@inka.de> Message-ID: <82fmip$18hl$1@thoth.cts.com> Michael Str?der wrote: [...] : OK. Name another programming language which seems more appropriate for : developing CGI-BINs to you and let's analyze that... INTERCAL. It's such an achievment getting it to run, you don't _care_ about the error messages. (And no, that's not a serious comment, but this doesn't seem to be a serious discussion. Python's merits and demerits are already well established.) Will cwr at crash.cts.com From kuncej at mail.conservation.state.mo.us Sun Dec 5 15:32:36 1999 From: kuncej at mail.conservation.state.mo.us (Jeffrey Kunce) Date: Sun, 05 Dec 1999 14:32:36 -0600 Subject: Environment variables Message-ID: >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). For NT, I have some that wraps the environment variables in the registry as a dictionary (for both getting and setting). It also includes support for modifying the PATH variable in the registry See: regenviron.py at: http://starship.python.net/crew/jjkunce/netinstall/python_network_setup.html It doesn't solve the "immediate availability" problem discussed elsewhere. Newly set environment variables are available after a logoff/logon, though. --Jeff From webmaster at python.org Thu Dec 9 11:10:58 1999 From: webmaster at python.org (Python.Org Webmaster) Date: Thu, 9 Dec 1999 11:10:58 -0500 (EST) Subject: Python.Org Redesign Contest Message-ID: <14415.54418.939654.345378@anthem.cnri.reston.va.us> Hello Zopistas, Wouldn't you love the Python.Org site to use Zope? Don't you think the Python.Org style is getting a bit dated? Here's your chance to change all that. The design of the Python.Org web site is nearly two years old now, and while functionally it works very well, we're getting bored with it. We've decided that we're hackers, not web site designers so we thought we'd conduct a little contest: here's your chance to design the new Python.Org web site! Our requirements are: - Use the Zope 2.x platform. We're looking for both a Web site design and an application design. - We want the site to be at least as user friendly as the current site is. This means you should try to keep stuff like images to a minimum in order to help download times for people around the world. - The look should be consistent throughout the whole site. - We want it to be easy to delegate content management of parts of the site to "champions" selected from the Python community. A big goal of this whole effort is to make it easier for the rest of the community to share in the upkeep of the site. For that reason, it should be easy for these champions to make changes, upload new pages, etc. - It should be easy to import as much of the existing Python.Org content as possible. - Bonus points if your solution allows us to include a redesigned JPython.Org site as a virtual domain. - Deadline for submission is Monday, February 21, 2000. We'd hoped to select the new design by time of the Python conference, but we've been informed that some useful Zope products won't be available until after the conference. Better better than sooner :) Everything else is up to you. You can use the existing site design as a starting point, or come up with your own ideas. If we select your design, we will of course need the rights to use your design and code, and your permission to modify it as necessary. Your prize will be prominent acknowledgements on the site (i.e. the "fame" part of "fame and fortune" :). Submissions and questions can be directed to design at python.org Good luck! -Barry & Guido, et al P.S. A copy of this announcement is also available at http://www.python.org/Redesign.html From gmcm at hypernet.com Fri Dec 17 16:08:14 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 17 Dec 1999 16:08:14 -0500 Subject: python constructor overloading In-Reply-To: <385A768B.F61C80F7@EarthLink.Net> Message-ID: <1266658490-859699@hypernet.com> Greg Copeland wrote: > Gordon McMillan wrote: > > [circular references 'twixt objects and container] > > Bzzt. The container is unavailable, but unless you specifically > > clear it, it will still exist, because it's ref count hasn't > > gone to zero because there are objects (which happen to be > > inside it) which still reference it. > > Thanks for spelling this out. I had, however, already read about > this issue. My objects will be explicitly collected (at least, > my intent is to). Err, rather, I assume that 'sys.exc_traceback > = None' will do this after the contained have lived their life? > I poorly expressed my self here as I didn't believe it to be > central to my point of contention. Thanks. I'll pay more > attention next time! :) I'm not clear on what you're saying, so I'll spell things out: The 'sys.exc_traceback = None' trick will allow the locals from whence the exception was thrown to be collected. You can break a container / contained cycle from either side - either explicitly delete the object from the container, or explicitly set the object's reference to the container to None, or both. It all depends on the respective desired lifetimes of the objects / container. To be thorough, you would have a release(self) method on the object, *and* do container[key] = None. > > > > [subclassing] > > > > > Obviously, I want to keep all of the existing engine's > > > functionality, but simply extend it with the turbo's boost > > > methods. As I understand it, you can't do this?!?!? If I > > > understand you correctly, I have to re-implement engine's > > > constructor and extend it in the turboEngine's constructor. > > > > You have to call the base class's __init__ explicitly. __init__ > > isn't actually a "constructor", it is an "initializer". In > > other words, "self" is the real, final thing when __init__ > > runs; you just get to set up it's state, not influence it's > > construction. > > Hmmm. I'll try again. I guess it was something I was doing > wrong. I was getting an unbound method error. You need to say: base.__init__(self, arg, ...) because "base.__init__" is an unbound method (you're referencing it through the class, not an instance). You undoubtedly omitted the "self". > As for the > constructor/initializer reference. To me, it looks like python's > equivalent to a C++ constructor, so that's what I called it. Is > "initializer" the correct terminology for python? "Constructor" would be the more common term, but you need to realize that it's not the same as a C++ constructor ;-). > > > > There's nothing automatic about __init__, which is why mixins > > are easy and useful in Python (but rarely so elsewhere). > > Can you expand on this a bit? Everything I've seen suggests that > __init__ is automatic. If you can point me to some read'n here, > that would be great. The instance construction mechanism calls the instance's __init__ (if it has one) as it's final act, but there's nothing like the C++ mechanism that goes looking for appropriate base class constructors. If you want to call them, *you* have to do it, (so most people call the immediate superclass's __init__ ). You can learn the gory details by reading the stuff in Demo/metaclasses, but wear a helmet so you don't make a mess of the walls. Better yet, put a mark on your calendar to look at this six months from now. > I'm also not sure how a mixin would help > here, other than to provide a method that accepts the reference > to the container. Obviously, you've pushed me to something that > "feels" better, but isn't exactly what I was hoping for. Still, > I say thanks! I've completely lost track of what your problem was ;-). Just saying that in Python, mixins are easy and natural; and this is largely because instance construction and instance initialization aren't confounded. - Gordon From neelk at brick.cswv.com Thu Dec 30 09:27:28 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 30 Dec 1999 14:27:28 GMT Subject: The Don Beaudry/Jim Fulton hack References: <9GHa4.1682$wG6.149869@ndnws01.ne.mediaone.net> Message-ID: Dave Abrahams wrote: > > 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"? Read GvR's essay, "Metaclass Programming in Python 1.5" at http://www.python.org/doc/essays/metaclasses/ I have to admit that you are more hardcore than me -- I never bothered looking at the C source once I had found this essay. :) Neel From alex at magenta.com Wed Dec 29 16:49:15 1999 From: alex at magenta.com (Alex Martelli) Date: Wed, 29 Dec 1999 22:49:15 +0100 Subject: stop the presses (?) -- superb free web site installs Python for free CGI...? References: <19991229191504.3E9631CD1E@dinsdale.python.org> Message-ID: <016f01bf5246$91de0c20$db2b2bc1@martelli> Maybe I should have waited until confirming they're going to do it, but -- I'll be away for a few days so I wanted to break the presumably-good news as they're still hot... Remember my quest for a free website that would let me write CGI scripts _in Python_, and how I grumbled about Perl being the only way to write scripts on those few free web hosts that do allow CGI at all...? OK, www.prohosting.com may be coming to the rescue -- already, I thought them the best free site of all, since, for example, they don't *impose* ad banners on free sites; they *courteously ask* you to display their banner on your pages, but won't kill you if you don't. Besides, they sell professional hosting services, not ads -- they hope to generate goodwill, and if your free website becomes commercial and starts needing fast support, you'll choose them to host it (if they keep treating me like this, I will, and, meanwhile, if their quality stays this way, I'll surely be recommending them to anyone who asks). So, anyway, their free support service finally answered my Python request -- _apogizing_ for not having it around already, explaining they used to but none of their customers used it anyway, and promising to put it up soon on the specific machine that is going to host my site. Now *that* is the attitude I like -- I hope they do follow through, but, even worst case, it's already much better than the canned "your request was noted, but we have no plans about this at this time" responses from the other free-with-CGI-Perl sites such as xoom. If there is interest, I'll keep the group posted about any follow-ups to this story (in a few days, when I'm back from my overdue year's-end-break:-). Alex From frohne at gci.net Wed Dec 22 18:23:23 1999 From: frohne at gci.net (Ivan Frohne) Date: Wed, 22 Dec 1999 14:23:23 -0900 Subject: Python-powered Win95 Replacement Shell References: <386112d2.34743796@news.telus.net> <009601bf4cc1$e270b6e0$c02b2bc1@martelli> Message-ID: > 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. Being more foolhardy than Alex, I did download and install Graphite. No problems until, as advised, I rebooted. Graphite takes over the display, although Windows 98 is there (invisible) in the background. Nothing seemed to work; finally I right-clicked, got to the Control Panel and uninstalled Graphite. No lasting ill-effects, apparently. But not much learned, either. There is no Help, and absolutely no other documentation, either. I gather there are (or will be) a mail system and a browser incorporated. The displayed (analog) clock works, and there is a functional system resources display. More of an alpha than a beta. Looks promising though. There is a news server -- see http://www.graphite.sh --Ivan Frohne From fredrik at pythonware.com Wed Dec 15 06:35:41 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 15 Dec 1999 12:35:41 +0100 Subject: Tkintr uses Tcl? References: Message-ID: <013601bf46f0$853bb000$f29b12c2@secret.pythonware.com> Grant Edwards wrote: > I get the impression from various postings and documentation > that Tkintr uses Tcl. Is this true? yes. (or rather, Tkinter uses an unmodified version of Tk, which requires Tcl). > 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? some overhead, not necessarily "a lot". it's usually not a problem IRL. (it isn't that difficult to get rid of most of the existing overhead, but I have a few other things to fix first ;-) > I presume it is less work than the Stk approach? definitely. before scriptics started messing things up in 8.1, catching up with a new Tk release was usually no harder than "download and recompile". From michels at linmpi.mpg.de Wed Dec 1 08:47:56 1999 From: michels at linmpi.mpg.de (Helmut Michels) Date: Wed, 01 Dec 1999 14:47:56 +0100 Subject: Plotting a single pixel (possible newbie question) References: <821sd5$7h0$1@mirv.unsw.edu.au> Message-ID: <3845270B.8BE53A6@linmpi.mpg.de> Simon Evans wrote: > 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. > ================================================================= DISLIN contains also some elementary image routines for reading and writing pixels from and to the screen. For example, the routine 'wpixel' writes one pixel to the screen. Normally, DISLIN is a high-level plotting library for displaying data with a few statements. ------------------- Helmut Michels Max-Planck-Institut fuer Aeronomie Phone: +49 5556 979-334 Max-Planck-Str. 2 Fax : +49 5556 979-240 D-37191 Katlenburg-Lindau Mail : michels at linmpi.mpg.de DISLIN Home Page: http://www.linmpi.mpg.de/dislin From hnowak at cuci.nl Tue Dec 14 12:37:58 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Tue, 14 Dec 1999 18:37:58 +0100 Subject: Python & Mysql Message-ID: <199912141740.SAA03165@dionysus.fw.cuci.nl> On 14 Dec 99, Hans Blaauw wrote: > Hello, > > Can someone send me a small example of python using the mysql database ? > > i'm learning to program and i want to use databases, i read some > documents about the use of mysql within python but somehow i cannot > ubderstand it without having some sort of example... > > if you have an example please mail it to jmb at xs4all.nl > > Many thanks !! I don't know much about MySQL myself, but my snippets page has two (related) example files (they require the MySQL module, I don't know where to get this one, but some others on this list certainly do): http://tor.dhs.org/~zephyrfalcon/snippets/html/database.html I'd like to have more examples by the way; anyone has information about talking to M$ SQL Server or an Access database? --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 worldwin at liii.com Fri Dec 17 01:57:17 1999 From: worldwin at liii.com (dj trombley) Date: Fri, 17 Dec 1999 06:57:17 GMT Subject: packing (struct module) References: <384E455A.61969B1D@obop.com.pl> Message-ID: <3859DE4F.382F6C32@liii.com> > import struct > > f = open( 'afile', 'r' ) > lines = f.readlines() > packedLines = [] > > if len( lines ) > 0: > formatString = '1f' * lines[ 0 ].len() > > for l in lines: > packedLines.append( struct.pack( formatString, l )) > > At this moment I would have a list of packed strings in packedLines. > The problem is in the last line of code, since I cann't pass a list to > the pack function. There is a mechanism for applying a list of arguments to a function. It is a builtin called apply(). For example: packedLines.append(apply(struct.pack, l)) apply() takes as its second argument a tuple, but will convert arbitrary sequences to tuples if it needs to. -dj Dave Trombley From ivanlan at callware.com Thu Dec 9 15:31:06 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 09 Dec 1999 13:31:06 -0700 Subject: Tk stuff... References: <3850095A.9935920D@orchestream.com> Message-ID: <3850118A.C897A3D1@callware.com> Hi All, Tobe-- Tobe Bradshaw wrote: > > 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. > import sys from Tkinter import * w = 400 h = 400 def die(event=0): sys.exit(0) def chsize(event): global w,h,xp,yp,xdelta,ydelta w = event.width h = event.height if __name__ == "__main__": root = Tk() cv = Canvas(root,width=w,height=h,borderwidth=0, background="#409040", highlightthickness=0) cv.bind("", chsize) root.bind("", die) cv.pack(expand=1,fill=BOTH) root.mainloop() ----------------------- The key here is cv.pack(expand=1,fill=BOTH) That tells the Pack manager to expand the Canvas in BOTH directions when the parent (root) is resized. > 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)... > The only place to get info right now is at http://www.pythonware.com The tutorial there is not complete, but it's a lot better than nothing. /F is so busy he doesn't have time to update it. There are several books coming out, including one by Fredrik, but none are out *now*. John Grayson's book looks very good to me. I don't think you're going to get many volunteers to write your code for you. No one wants to deprive you of your fun.;-) > (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). > -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 idoerg at cc.huji.ac.il Thu Dec 9 03:28:19 1999 From: idoerg at cc.huji.ac.il (Iddo Friedberg) Date: Thu, 09 Dec 1999 10:28:19 +0200 Subject: Numeric Conversion Message-ID: <384F6823.E66085F1@cc.huji.ac.il> 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. 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). Thanks in advance, Iddo Friedberg -- .. -.. -.. --- ..-. .-. .. . -.. -... .. .-. --. From DOUGS at oceanic.com Fri Dec 3 10:36:45 1999 From: DOUGS at oceanic.com (Doug Stanfield) Date: Fri, 3 Dec 1999 05:36:45 -1000 Subject: split this newsgroup? Message-ID: <5650A1190E4FD111BC7E0000F8034D26A0F17A@huina.oceanic.com> 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 That would produce about an equal split. Now, would Guido subscribe to both? finding-dealing-with-300-messages-on-the-py-list-the-best-parts-of-the-day-l y y'rs -Doug- > -----Original Message----- > From: Max M. Stalnaker [mailto:stalnaker at acm.org] > Sent: Thursday, December 02, 1999 5:23 PM > To: python-list at python.org > Subject: split this newsgroup? > > > The volume on this newgroup might justify splitting the > newgroup. Comments? > > -- > Max M. Stalnaker mailto:stalnaker at acm.org http://www.astarcc.com > > From pdasilvaX at esoterica.pt Tue Dec 28 19:03:00 1999 From: pdasilvaX at esoterica.pt (Paulo da Silva) Date: Sun, 29 Dec 1999 00:03:00 +0000 Subject: Before I go with python ... Message-ID: <385C20B4.87FACEED@esoterica.pt> I'm considering to use python after reading some docs about it. I have a doubt I couldn't get responded until now. Is it possible to have assynchronous I/O, for example continuing a program while another task is wainting on a socket? How is taht achieved? Multithread? Just a call after the socket has data? TIA for any enlightments. Paulo da Silva -- Please remove the anti-spam Xs from my email address. PF. retirar os Xs anti-spam do meu endereco de email. From fdrake at acm.org Thu Dec 23 10:43:45 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 23 Dec 1999 10:43:45 -0500 (EST) Subject: Super-rexex? In-Reply-To: <1266159968-30845431@hypernet.com> References: <19991223151828.A3636@stopcontact.palga.uucp> <1266159968-30845431@hypernet.com> Message-ID: <14434.17201.392259.129118@weyr.cnri.reston.va.us> Gordon McMillan writes: > Isn't that the kind of parsing that shlex is good at? I'm inclined > to think that John's (highly capable, wonderful, etc. etc.) tools > are bit more than is required here. Good point. One of those new-fangled modules screwing up my knowledge of the library, dadburnit! Yes, that would probably be a good one to play with for this. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From cfelling at iae.nl Thu Dec 9 18:14:22 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 10 Dec 1999 00:14:22 +0100 Subject: Embedding questions References: <82n5ec$e2a$1@ssauraab-i-1.production.compuserve.com> Message-ID: <82pd4e$2bu$1@vvs.superst.iae.nl> Olaf Appelt wrote: ...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 >>>class Currency >>> def __call__(self, other): >>> self.value = other >>>... which would allow the even uglier >>> c(a+b) mind you that now you changed the state of the instance by calling itself:) -- groetjes, carel From piet at cs.uu.nl Wed Dec 1 04:16:28 1999 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 01 Dec 1999 10:16:28 +0100 Subject: '==' vs. 'is' behavior References: <99Nov30.193151pst."3757"@watson.parc.xerox.com> Message-ID: >>>>> Bill Janssen (BJ) writes: BJ> Actually, the presence of "is" and "==" in Python is one of the nicer BJ> features. "is" is the Lisp "eq", while "==" is the Lisp "equal". BJ> These are really the two comparisons from Lisp that make the most BJ> sense. BJ> Java, on the other hand, only gives you "eql"! Ugh! Bletcherous! Huh??? Java has == which is equivalent to Python's `is' for objects and == for primitive values, and it has the equals method for objects which is like Python's ==. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: Piet.van.Oostrum at gironet.nl From arcege at shore.net Wed Dec 15 11:19:34 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 15 Dec 1999 16:19:34 GMT Subject: calling Python from C: I can't get this part. References: <82res6$896$1@nnrp1.deja.com> <385399BB.2BC1D709@appliedbiometrics.com> <836h18$qnu$1@nnrp1.deja.com> Message-ID: Very Frustrated wrote: : Okay, almost there. This is adapted from callback2 in the SWIG examples. [snip] : 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); I would say off hand that you need to get your arguments right. Functions are passed a tuple of values, not the value itself. Try either: arglist = Py_BuildValue("(s)", chrom); result = PyObject_CallObject(func, arglist); or: result = PyObject_CallFunction(func, "s", chrom); The documented API is PyObject_Call*, not PyEval_*; it would probably be better to use those routines instead. -Arcege From bjorn at roguewave.com Fri Dec 17 19:50:28 1999 From: bjorn at roguewave.com (bjorn) Date: Fri, 17 Dec 1999 17:50:28 -0700 Subject: Python on NT systems (help a Unix guy, please) References: <19991218113757.A637@Ridcully.home> Message-ID: <385ADA53.A5FC730C@roguewave.com> The standard installation, plus the win32 packages is 11.3 Mb. -- bjorn Malcolm Tredinnick wrote: > I recently protyped a program in Python that is destined to run on a Windows > NT box. As usual, the Python version runs well enough that I have no real wish > to rewrite it in C. So all that remains is to convince the owner of the NT box > to install Python on his machine. > > The problem: disk space is a little tight on the target machine. Since I don't > have any Windows machines at home at the moment, could somebody please let me > know (just roughly) the disk space requirements for Python on NT? (private > email is ok if you don't want to spam the list). > > Just for comparison purposes, a reasonably standard Python install on my Linux > box (the only additional thing is the LLNL Numeric package) takes up just > under 24MB, the requirements for tkinter is another 5.5MB with wxPython > (source code and all) being 18MB (plus whatever wxWindows requires). > > Thanks in advance, > Malcolm Tredinnick > > -- > Despite the high cost of living, have you noticed how popular it remains? > > -- > http://www.python.org/mailman/listinfo/python-list From billtut at microsoft.com Tue Dec 7 03:08:39 1999 From: billtut at microsoft.com (Bill Tutt) Date: Tue, 7 Dec 1999 00:08:39 -0800 Subject: Exposing COM via XML-RPC or Something Else Message-ID: <4D0A23B3F74DD111ACCD00805F31D8100DB9162C@RED-MSG-50> > -----Original Message----- > From: kc5tja at garnet.armored.net [mailto:kc5tja at garnet.armored.net] > Where can I find the interface spec for IDispatch? I haven't > found it on > Microsoft's site yet, but I'll keep looking. > MSDN is online at: http://msdn.microsoft.com/library/default.htm IDispatch is documented at: (path from the root node), not a URL: Platform SDK\ComponentServices\COM\Automation\Dispath and API Functions. The most annyoing thing with writing IDispatch from scratch is writing the default IDispatch handler for dual interfaces. Bill From jh at cddk.dk Tue Dec 21 05:24:58 1999 From: jh at cddk.dk (Jesper Hertel) Date: Tue, 21 Dec 1999 11:24:58 +0100 Subject: ugly python namespace bug References: Message-ID: <83nkhv$88p$1@news1.tele.dk> I get around this by using an editor that colors Python keywords and built-in functions. Then I immediately see when I (by mistake) use keywords or builtin functions as variables. Personally I like TextPad on the Windows platform. Jesper Hertel Roy Smith wrote in message news:roy-1A6F62.16025920121999 at netnews.nyu.edu... > I had a function which use to look like this: > > for type in stuff: > if type == default: > etc... > > It worked fine, but for one reason or another, I decided to change the variable > name from type to option, but forgot to change it in one place, and ended up > with: > > for option in stuff: > if type == default: > etc... > > My code stopped working, with the equality test always failing. I scratched my > head a while until I found the problem, but then couldn't figure out why I > didn't get a name error ("type" undefined) until a co-worker pointed out that > type is a built-in function. My first version of the code just over-wrote the > default value of type! > > I see how it all works now, but boy, stuff like this sure does invite all sorts > of nasty debugging problems! > > -- > Roy Smith > New York University School of Medicine > From worldwin at liii.com Fri Dec 17 01:53:28 1999 From: worldwin at liii.com (dj trombley) Date: Fri, 17 Dec 1999 06:53:28 GMT Subject: Python threads References: <384E36F0.30A43165@xrce.xerox.com> Message-ID: <3859DD69.660D91F8@liii.com> Emmanuel Pietriga wrote: > The problem is that, even with time.sleep(???) in the eventListener > thread, the other one (repainting thread) isn't allowed to execute very > often (once every 4 sec., and in a very heratic way). > > I have also tried to put one of the thread's code in the while1: pass of > the main function. It behaves the same. > I think the problem comes from the thread scheduler. But I don't know > what to do! You may want to try lowering the interval at which python checks to switch threads. This can be done with sys.setcheckinterval(). is the number of python atomic instructions that get executed before a switch is possible. Keep in mind that calls to C extensions are considered atomic, so they can greatly affect this sort of performance. In my experience, sometimes it is worth it to run a seperate python interpreter in another process and use some sort of IPC. Admittedly, the current state of python threads leave something to be desired with respect to this sort of issue, and others (the per-exc frame signal thing, thread suspension, per-thread check intervals, etc). -dj Dave Trombley From hniksic at iskon.hr Sun Dec 12 13:17:02 1999 From: hniksic at iskon.hr (Hrvoje Niksic) Date: 12 Dec 1999 19:17:02 +0100 Subject: Python interpreter thread-safe? Message-ID: <9t99030xbvl.fsf@mraz.iskon.hr> Suppose you need to embed Python in a multi-threaded application. The question is: is Python interpreter thread-safe? I.e. is it possible to parse and evaluate Python code in separate instances of the interpreter within a single process simultaneously? From mhammond at skippinet.com.au Fri Dec 10 07:29:14 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 10 Dec 1999 12:29:14 GMT Subject: Copying files to file server References: <5_V34.3331$Cl3.17409@news-server.bigpond.net.au> Message-ID: Tomaz Ficko wrote in message ... >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\\f i >cko','','username','password') >Traceback (innermost last): > File "", line 1, in ? > >win32wnet.WNetAddConnection2(RESOURCETYPE_DISK,'e:/','\\\\mars\\tehnolog\\f i >cko','','username','password') >api_error: (0, 'WNetAddConnection2', 'No error message is available') Hrm. Actually, WNetAddConnection2 has a buglet in that when it fails, it doesnt pass the correct error code - hence the zero and "No error..." for the error info. So, it appears the function failed, but we dont know why :-( When I try it with a fixed version I get error number 50 - "The network request is not supported" The SDK documentation for this function states that for the password and username params: "Windows 95/98: This parameter must be NULL or an empty string." Looking up MSDN offers the following knowledge base articles that may apply: Q173011 : INFO: WNetAddConnection2 and Multiple User Credentials Q218497 : INFO: User Authentication Issues with ADSI WinNT Provider The news isnt too good - although vague, they pretty much say "dont be surprised if it doesnt work on Windows 95" - and given the comment about the username/password on 95/98, Im not surprised why :-) >the server (backup) and disconnect from server. Is that possible with Python >from Windows 95. If you can work out how to do it in _any_ language, Python will be able to too :-) Im afraid I can't... Mark. From jesse at student.usyd.edu.au Thu Dec 23 01:44:38 1999 From: jesse at student.usyd.edu.au (Jesse Sweeney) Date: Thu, 23 Dec 1999 17:44:38 +1100 Subject: List comprehensions References: Message-ID: On Wed, 22 Dec 1999 10:51:39 GMT, thantos at chancel.org (Alexander Williams) wrote: >On 22 Dec 1999 10:28:52 GMT, Albert Hofkamp >wrote: [ snip ] >> Another matter is scoping. I hope that code like >> i := 30 >> ys := [ 4 ] >> xs := [ i ] + [ i+15, for i in ys ] + [ i+1 ] >> >>is well-defined. >>I'd like to have xs == [ 30, 19, 31 ] at the end, but I am too new to >>Python to say anything useful about scoping. >>Is this what you'd expect, and is it feasible ? > >Certainly; I don't expect scoping in the LCs will be much of an >issue. The above mock-up should be completely defined under present >scoping rules. Well, I haven't actually installed the patch in question, but as I understand it the comprehension-using code above would translate to the following current Python: i = 30 ys = [4] xs = [i] for i in ys: xs = xs + [i+15] xs = xs + [i+1] which leaves xs as [30, 19, 5], not [30, 19, 31] as Albert was suggesting. Someone who's actually used the patch might correct me, but I'd be surprised if the scoping rules were different to the rules for for loops. Cheers, Jesse. From ivanlan at callware.com Thu Dec 2 08:41:59 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 02 Dec 1999 06:41:59 -0700 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> Message-ID: <38467727.BC269134@callware.com> Hi All-- "David N. Welton" wrote: > > 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? > Oooh, let's open the can of worms of the century! I belong to the CALNDR-L mailing list, and even on that list, which has 150 of the world's most opinionated calendar experts, their is wide disagreement on the start of the millennium (note that there are two n's, by the way). And I do mean *wide*. The consensus (if there can be such a thing on CALNDR-L), seems to be that _if_ you are looking at our calendar as the traditional, Catholic-instigated, Gregorian calendar of AD & BC fame, the third millennium indeed begins 1/1/2001, since 0 did not exist when Dionysus Exiguus ("Dennis the Little," as S.J. Gould has translated it) proposed and used the AD dating in or around 532 AD. Since we call the current century the "20th" century, it would seem that most people are using the traditional AD/BC Gregorian calendar. The venerable Bede (English, ~800 AD) added and used the BC notation for the first time, in his "History of the English-Speaking Peoples." 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. This of course begs the question "where the hell is century zero"? ;-) I think the argument will go on for at least another millennium. ... I happen to go with the second view, myself, but that's just my own preference. S.J. Gould says you should party on both 12/31/1999 and 12/31/2000;-) -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 sk at fyemf.fys.ntnu.no Mon Dec 13 10:58:28 1999 From: sk at fyemf.fys.ntnu.no (Steinar Knutsen) Date: 13 Dec 1999 15:58:28 -0000 Subject: What do we call ourselves? References: <3850734D.FD1D7A2C@callware.com> Message-ID: <833534$do$1@fyemf.fys.ntnu.no> In article , John Leach wrote: >This is getting totally off the point, but did Red Hat name one of >their distributions Hedwig after Harry Potter's owl or was it named for >something else? I didn't know about Red Hat's ?Hedwig? before you mentioned it, but Ibsen's ?Hedvig? in the play ?The Wild Duck? (Vildanden) would be my first guess. (But then again, it could also be St Hedwig (1174-1243), an owl, or something completely different. :) ) -- Steinar From fredrik at pythonware.com Thu Dec 23 07:15:29 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 23 Dec 1999 13:15:29 +0100 Subject: eff-bot Python book ... revisited References: <7va9hf$ngi$1@marcie.fissiontech.com> <00fd01bf23cb$e4b6ed30$f29b12c2@secret.pythonware.com> <381C952F.2E8F30EC@callware.com> Message-ID: <00f701bf4d3f$684f2940$f29b12c2@secret.pythonware.com> footnote: to celebrate the eff-bot's first week as a bestselling author [1], the eff-bot guide [2] will be available at 25% off the ordinary price for the rest of 1999. and yes, the eff-bot will now shut down for the holi- days. we've performed extensive Y2K testing, so we're pretty confident that we will have him back on line in early 2000. happy holidays to all of you! 1) http://www1.fatbrain.com/ematter/bestsellers.asp?vm=e 2) http://www.pythonware.com/people/fredrik/librarybook.htm From r-stadhe at online.no Fri Dec 17 20:24:32 1999 From: r-stadhe at online.no (Rolf C Stadheim) Date: Sat, 18 Dec 1999 02:24:32 +0100 Subject: Embedded Python with Tkinter? Message-ID: <385AE250.D426B207@online.no> Hello, I wondered if anyone knew where I could get examples of embedded Python modules in C/C++, where the Python modules uses Tkinter? Or , how to simply use Python with Tkinter in C/C++? I can access Python functions that simply return a value, but as soon as I try to access a Python function that starts a (Tkinter GUI) mainloop(), my application crashes. An illustrative example of C/C++ code would be invaluable! Regards, Rolf C Stadheim From prestonlanders at my-deja.com Tue Dec 7 11:00:10 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Tue, 07 Dec 1999 16:00:10 GMT Subject: exchanging data btwn Python and lesser languages Message-ID: <82jau6$e72$1@nnrp1.deja.com> 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? thanks in advance, ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From geoff at gnaa.net Thu Dec 16 02:17:26 1999 From: geoff at gnaa.net (geoff at gnaa.net) Date: Thu, 16 Dec 1999 07:17:26 GMT Subject: download web page with python Message-ID: <83a3m4$diq$1@nnrp1.deja.com> I am just going through the Learning Python book, and I came accross the example about how to retrieve information from the web. I want to do this, but the web page (symantec's antivirus signature update page--http://www.symantec.com/avcenter/download.html) has a form to ask which product you want, then runs a CGI script, and gives you info back. Does anyone have any ideas how I can get by the form, and retrieve the page that I want. Once I get the page I will have no problems parsing it. TIA geoff Sent via Deja.com http://www.deja.com/ Before you buy. From mal at lemburg.com Fri Dec 10 18:31:30 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 11 Dec 1999 00:31:30 +0100 Subject: Python and regexp efficiency.. again.. :) References: Message-ID: <38518D51.4A32C685@lemburg.com> Markus Stenberg wrote: > > 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? Hmm, have you tried mxTextTools ? As an example, the HTML parser provided as example can easily handle 900kB HTML/sec. on a K6/266 machine. There are some nice tools available to help build the needed Tagging Tables. More infos are available on my Python Pages, including pointers to those tools. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 21 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From fredrik at pythonware.com Fri Dec 3 05:27:57 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 3 Dec 1999 11:27:57 +0100 Subject: split this newsgroup? References: Message-ID: <026401bf3d79$12002600$f29b12c2@secret.pythonware.com> Max M. Stalnaker wrote: > The volume on this newgroup might justify splitting > the newgroup. Comments? what subgroups did you have in mind? From bernhard at alpha1.csd.uwm.edu Mon Dec 20 16:30:58 1999 From: bernhard at alpha1.csd.uwm.edu (Bernhard Reiter) Date: 20 Dec 1999 21:30:58 GMT Subject: Diffs References: <19991218223342.A11575@stopcontact.palga.uucp> Message-ID: On Sat, 18 Dec 1999 22:33:42 +0100, Gerrit Holl wrote: >where should I send diffs? Depends on the diff. 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 tjreedy at udel.edu Fri Dec 3 15:28:22 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 3 Dec 1999 20:28:22 GMT Subject: Using open() under Window 97 References: <828s0t$ad6$1@ilana.cenaath.cena.dgac.fr> Message-ID: <829956$5br$1@news.udel.edu> In article <828s0t$ad6$1 at ilana.cenaath.cena.dgac.fr>, kahn at cena.dgac.fr says... >This program run under UNIX ... >but under Window, even if the file is in current directory I've got the >fallowing message: ... > IOError: [Errno 2] No such file or directory: 'sol.tx> I suspect the current working directory is different from what you think. (This has happened to me also on WIN97.) import os; print os.getcwd() # to check (func name may be wrong) os.chdir('full path') # to set to what you want TJR From fredrik at pythonware.com Fri Dec 10 06:08:06 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 10 Dec 1999 12:08:06 +0100 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: <022101bf42fe$d6e065e0$f29b12c2@secret.pythonware.com> Olaf Appelt wrote: > > ...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? nope. you should think a bit more about your original problem. if I understand things correctly, you want to set a variable to something, execute some user code, and then inspect that variable. right? okay, here's how to do that: c = "my value" namespace = {} namespace["c"] = c exec usercode in namespace c = namespace["c"] print c in other words, let the user change "c" to whatever he/she wants, and pick up the result afterwards. if it's not the right type, convert it (if that's a reason- able thing to do). otherwise, complain to the user. From thantos at chancel.org Fri Dec 17 08:24:13 1999 From: thantos at chancel.org (Alexander Williams) Date: Fri, 17 Dec 1999 13:24:13 GMT Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <029e01bf4879$72585ee0$f29b12c2@secret.pythonware.com> Message-ID: On Fri, 17 Dec 1999 11:28:16 +0100, Fredrik Lundh wrote: >I the only one here who has a brain equipped >with a 2D pattern matcher? ;-) Nope; this may be why I find Haskell syntax so natural to me ... (Ah, if only Haskell had Python's libraries and Monads actually made sense ...) >how about: > >import fileinput >for line in fileinput.input(): The funny thing is that if Python had been /less/ intuitive, he'd have stumbled over this class in the documentation in the course of digging up file management. In fact, if he'd decided to just keep fiddling with it for another half hour out of sheer bloody-mindedness, he would have found it. -- Alexander Williams (thantos at gw.total-web.net) "In the end ... Oblivion Always Wins." From paul.m at yale.edu Wed Dec 1 15:40:19 1999 From: paul.m at yale.edu (Paul M) Date: Wed, 1 Dec 1999 15:40:19 -0500 Subject: WinNT and python as text filter... References: <3842f32d.30322451@news.concentric.net> Message-ID: <82414c$dqn$1@news.ycc.yale.edu> Toby Dickenson wrote in message ... >>If so, there is a bug in the NT command prompt - you need to specify the >>full path to Python.exe on the command line, and it will work... > >As a point of good news, this is fixed in Windows 2000. > >(so I might upgrade after all ;-) > Wow! Talk about value-added! ;-) --Paul From tismer at appliedbiometrics.com Sun Dec 19 15:19:28 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sun, 19 Dec 1999 21:19:28 +0100 Subject: LISTS: Extract every other element - SUMMARY References: Message-ID: <385D3DD0.E7493ABA@appliedbiometrics.com> Mike Fletcher wrote: > > Not with my testing on the code-as-given (incidentally, code as given had a > nameerror on p in the second loop setup). I get: Oops, I really thought a loop initilizes its variable always. Thanks! :-) > > 1.098 -- algo7 > 1.052 -- for with multiply > 1.134 -- for with divide > 0.421 -- matrix step-slice > 0.428 -- matrix reshape > 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 >>> H??h? Stunned-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 mal at lemburg.com Mon Dec 13 08:59:33 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 13 Dec 1999 14:59:33 +0100 Subject: Python and regexp efficiency.. again.. :) References: <38518D51.4A32C685@lemburg.com> Message-ID: <3854FBC5.758C2C15@lemburg.com> Markus Stenberg wrote: > > "M.-A. Lemburg" writes: > >> .. snipped my own comment > > Hmm, have you tried mxTextTools ? As an example, the HTML parser > > provided as example can easily handle 900kB HTML/sec. on a > > K6/266 machine. > > Yes; but the tagging language seemed to be somewhat limited compared to > regexps. Hmm, wonder if it's possible to write regexp->tag definition > converter.. :) I would argue that it can do far more than regular regexp engines: the fact that makes me think so is that you can code your own matching functions and place them right next to the fast low-level builtin ones. Also, feature like callbacks, etc. provide a pretty wide range of applications, e.g. your can write event driven parsers just as well as DOM style ones. Note that you can even add regexp matching functions to the Tagging Engine. > > There are some nice tools available to help build the needed > > Tagging Tables. More infos are available on my Python Pages, > > including pointers to those tools. > > Meta-language link didn't work and EBNF is bit too low-level for my liking > - rewriting 150+ and growing rapidly definitions of "interesting" log lines > in EBNF is not my idea of fun :P. Of course, I could just do some really > ugly m4 hacking to do that, but I'd prefer to avoid that. Note that the package has tag-table writer which handles this case (you may have to adapt it probably, but the basic idea should be clear): def word_in_list(l): """ Creates a lookup table that matches the words in l """ ... (You can find it in TextTools.py) Given that your parsing requirements are rather simple this approach should be ideal for your case. -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 18 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From kantel at mpiwg-berlin.mpg.de Tue Dec 28 04:16:37 1999 From: kantel at mpiwg-berlin.mpg.de (Jörg Kantel) Date: Tue, 28 Dec 1999 10:16:37 +0100 Subject: configuring 1.5.2c1 on Mac for Tkinter ? References: <3867F0AD.361B33D1@ctrvax.vanderbilt.edu> Message-ID: <281219991016377819%kantel@mpiwg-berlin.mpg.de> In article <3867F0AD.361B33D1 at ctrvax.vanderbilt.edu>, Allen W. Ingling wrote: > 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". Unfortunately the installer seems to be broken - it was working well with 1.5.1 :-( At first you have to look for some shared libs - I found them for unknown reasons in the imaging folder within the Extensions folder. Drag these libs into the PlugIns Folder within the Mac Folder. After that you have to run the EditPythonPrefs Applet and add the following line "$(PYTHON):Lib:lib-tk" to your sys path. Now you can run your python scripts with Tkinter. Unfortunately there is a second bug and I know no workaround for that. You can't work with Tkinter interactively form the interpreter. After the statement "import Tkinter" and the first "pack" command the interpreter hangs. Writing your script in a texteditor and run it works however. I'm very unhappy about that but it seems that there is at the moment no one at the MacPython community who is able to support the Tk-stuff. (They all working at the IDE and the Toolbox calls.) I by myself have no time, too :-( But I think it's important, that we have a platform independet GUI Toolkit on the Mac also... HTH J"org Pls excuse my bad (d)english From Gaetan_Corneau at baan.com Thu Dec 16 09:27:04 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Thu, 16 Dec 1999 09:27:04 -0500 Subject: C++ Message-ID: <816010E2456BD111A48700805FBBE2EEFDF91E@ex-quebec-u1.baan.com> Guys, I have been programming in C++ for eight years now, and I was on the standard committee from '94 to '96, so I *really* don't need to be reminded of the language's virtues and flaws. And I won't be dragged in a flame war. Could we just get back to Python now? :) ______________________________________________________ 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 dnagata at creo.com Wed Dec 1 01:06:35 1999 From: dnagata at creo.com (Dale Nagata) Date: Tue, 30 Nov 1999 22:06:35 -0800 Subject: compile time constant to differentiate 1.5.2 from 1.5.1? Message-ID: <3844BAEB.41F4@creo.com> Hi, 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. For now I made up my own macro, PYTHON_VERSION_1_5_1, which gets the job done for now, but I would like to make use of a more "standard" technique if one is available. Thanks in advance, -- Dale Nagata | tel : +1 604.451.2700 ext. 2254 (UTC-0800) Software Developer | fax : +1 604.437.9891 Creo Products Inc. | pgr : +1 604.691.8279 Burnaby BC Canada | http://www.creo.com/ From gerrit.holl at pobox.com Tue Dec 21 09:51:08 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 21 Dec 1999 15:51:08 +0100 Subject: shelve In-Reply-To: <14430.25553.576208.661666@dolphin.mojam.com>; from skip@mojam.com on Mon, Dec 20, 1999 at 11:13:53AM -0600 References: <14430.25553.576208.661666@dolphin.mojam.com> Message-ID: <19991221155108.A2087@stopcontact.palga.uucp> Skip Montanaro wrote: > for k in db.keys(): > print db[k] What about: for k in db.values(): print k ...? -- "The move was on to 'Free the Lizard'" -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates) 3:50pm up 17 min, 2 users, load average: 0.00, 0.03, 0.10 From bowman at montana.com Sat Dec 4 21:01:52 1999 From: bowman at montana.com (bowman) Date: Sun, 05 Dec 1999 02:01:52 GMT Subject: Tkinter 1.5.2 ?? References: <38499F30.54313C44@interaccess.com> Message-ID: Clyde Davidson wrote: >Where can I find Tkinter 1.5.2 for Linux? I would prefer an RPM. I have not had satifactory results installing Python (or Perl, or any number of other distros) from RH RPMs. Get the source, and build the package yourself. You will be guaranteed of the latest, untweaked code. The default will install to /usr/local while the RH stuff lives in /usr. If you are feeling timid, go with the default, and link back to it. I prefer to use the path option to configure and install over the RH. Be forewarned some of RH's Python apps will break. They can be easily fixed, From zessin at my-deja.com Thu Dec 2 12:31:15 1999 From: zessin at my-deja.com (Uwe Zessin) Date: Thu, 02 Dec 1999 17:31:15 GMT Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> Message-ID: <826acr$i8b$1@nnrp1.deja.com> In article <199912020003.TAA13009 at eric.cnri.reston.va.us>, Guido van Rossum wrote: > Did you ever wonder what Tim Peters looks like? A _date_ with Tim ?? Ah, got it: you want to attract women to the conference ;-) -- Uwe Zessin (male, and doesn't have time to attend, so the other attractions don't work, too, sorry :-( ) Sent via Deja.com http://www.deja.com/ Before you buy. From tismer at appliedbiometrics.com Sun Dec 19 16:27:41 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Sun, 19 Dec 1999 22:27:41 +0100 Subject: LISTS: Extract every other element - SUMMARY References: Message-ID: <385D4DCD.2B081168@appliedbiometrics.com> Mike Fletcher wrote: Here I see a problem: > 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, The timing must be outside the loop. Better adjust the loop with a clear run. But calls into windows cause much uncertaincy, better avoid them. I run all my stuff in a small apply loop which is adjusted against a dry run with apply(len) counted as 0. def timing(func, args=None, n=1, **keywords) : import time time=time.time appl=apply if args is None: args = () if type(args) != type(()) : args=(args,) rep=range(n) dummyarg = ("",) dummykw = {} dummyfunc = len if keywords: before=time() for i in rep: res=appl(dummyfunc, dummyarg, dummykw) empty = time()-before before=time() for i in rep: res=appl(func, args, keywords) else: before=time() for i in rep: res=appl(dummyfunc, dummyarg) empty = time()-before before=time() for i in rep: res=appl(func, args) after = time() return round(after-before-empty,4), res ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From badzen at yifan.net Fri Dec 17 02:36:10 1999 From: badzen at yifan.net (dj trombley) Date: Fri, 17 Dec 1999 07:36:10 GMT Subject: python constructor overloading References: <3859904B.631359C8@EarthLink.Net> Message-ID: <3859E76C.FA02A1CC@yifan.net> Greg Copeland wrote: > > 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 ) > That is perfectly valid - except for one error - you need to pass the instance as the first argument to the (unbound) constructor method. For example: base.__init__(self, arg1, arg2, arg3) If you really do want to overload a constructor method, you may do so by simply assigning an appropriate initializer function to the class's __init__ attribute. I am not sure exactly what you mean by a 'container class', but if you don't already know, Python supports multiple inheritence. For example: class foo(bar, baz): def __init__(self): bar.__init__(self, ) baz.__init__(self, ) Hope this helps. -dj Dave Trombley From gmcm at hypernet.com Thu Dec 23 23:22:26 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 23 Dec 1999 23:22:26 -0500 Subject: Super-rexex? In-Reply-To: <19991223214353.A8069@stopcontact.palga.uucp> References: <1266159968-30845431@hypernet.com>; from gmcm@hypernet.com on Thu, Dec 23, 1999 at 10:36:55AM -0500 Message-ID: <1266114036-33608253@hypernet.com> > Gerrit Holl asked: > [Super rexec for execfile() with strings only?] > > Fred L. Drake, Jr. answered: > [ConfigParser module] > > Gordon McMillan reacted: > [shlex module] > > They both don't seem to be what I want. > I'm reinventing the wheel if I use them. *All* I want is having a > dictionairy with the same string rules Python uses. Not many > users will need to see the file: only translators will. You _did_ ask for something completely safe. Perhaps this will suit your needs: g = {'__builtins__' : None} execfile(file, g) del g['__builtins__'] - Gordon From jkraai at murl.com Thu Dec 23 01:25:20 1999 From: jkraai at murl.com (jim kraai) Date: Thu, 23 Dec 1999 00:25:20 -0600 Subject: httplib vs. urllib Message-ID: <3861C050.E8EAD05@murl.com> Why is the output of: python httplib.py www.ni.dk so _vastly_ different than the output of: python urllib http://www.ni.dk This has me _completely_ stumped. Thanks! --jim From kpn at tome.neutralgood.org Sun Dec 19 17:38:47 1999 From: kpn at tome.neutralgood.org (Kevin P. Neal) Date: 19 Dec 1999 22:38:47 GMT Subject: Linux.Com References: Message-ID: <83jmpn$pmr$1@tome.neutralgood.org> In article , Jeffrey Kunce wrote: >It looks like PHP is good for writing a form-submission-bot So is Python. How else do you think I ended up at 3rd place on the Time Magazine Man of the Year poll? Numbers one and two were a wrestler and Matthew Sheppard. How, how I ended up on the Interesting Person of the Year poll is beyond me. I never even saw it, but I'm told I ended up at 2nd or 3rd. -- Kevin P. Neal http://www.pobox.com/~kpn/ "You know, I think I can hear the machine screaming from here... \ 'help me! hellpp meeee!'" - Heather Flanagan, 14:52:23 Wed Jun 10 1998 From fdrake at acm.org Tue Dec 14 17:11:29 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Tue, 14 Dec 1999 17:11:29 -0500 (EST) Subject: Documentation Translations In-Reply-To: <99121412574105.00954@quadra.teleo.net> References: <14422.42955.688108.522178@weyr.cnri.reston.va.us> <99121412574105.00954@quadra.teleo.net> Message-ID: <14422.49297.914530.300630@weyr.cnri.reston.va.us> Patrick Phalen writes: > This sounds like a lot of extra work for you Fred. Why don't we just > standardize on Dutch? We could do that. The catch is that while I can read & speak Dutch, I can't type it. I'm a member of the VCP (Vowel Conservation Program), so my keyboards are all running VMOS (the Vowel Minimization Operating System). So I can't write and documents in Dutch. Since Dutch is so popular among most Python programmers, that may not be a problem. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From fredrik at pythonware.com Wed Dec 1 09:00:00 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 1 Dec 1999 15:00:00 +0100 Subject: Plotting a single pixel (possible newbie question) References: <821sd5$7h0$1@mirv.unsw.edu.au> Message-ID: <005c01bf3c04$5d40b240$f29b12c2@secret.pythonware.com> Simon Evans wrote: > 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! assuming that you're drawing more than one pixel per update, you can get decent results by com- bining PIL [1] with Tkinter. just draw the data into a PIL image memory, and display it using Tkinter and PIL's ImageTk module. 1) http://www.pythonware.com/products/pil From fraley at usfca.edu Mon Dec 6 21:32:04 1999 From: fraley at usfca.edu (Michael Fraley) Date: 7 Dec 1999 02:32:04 GMT Subject: Please Critique Message-ID: 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~~~ Here's my script. I'd really appreciate any pointers on how to improve it. scracc.py ----------------------------------------------------------- import string screenfile = open('scracc.txt') newfile = open('scrnew.txt', "w") for line in screenfile.readlines(): mydict = {} trimline = line[4:-1] start = 0 length = len(trimline) while start < length: end = start + 4 startkey = start + 1 mydict[trimline[startkey:end]] = trimline[start:end] start = end sortkeys = mydict.keys() sortkeys.sort() mylist = [] for key in sortkeys: mylist.append(mydict[key]) newline = line[0:4] + string.joinfields(mylist, "") + "\n" newfile.write(newline) screenfile.close() newfile.close() -- Michael Fraley fraley at usfca.edu http://www.usfca.edu/~fraley From mlh at vier.idi.ntnu.no Wed Dec 22 09:22:04 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 22 Dec 1999 15:22:04 +0100 Subject: Need a recursion lesson References: <83pdbe$5fj$1@news07.btx.dtag.de> Message-ID: "Eide" writes: > Hello, > I would like to do a search for file types, and I figure a good way to do it > would be with recursion... compare a sliced 'file[:-6]' of each item in > list from a directory. And if there is another directory in that list to do > a listdir on it and .... My head is spinning already. > I have no clue what I'm doing. Does anyone have any pointers to about how to > walk through something like this? Any help would be a lot. I see you have gotten an answer to your problem at hand - but it seems you also wanted some pointers on recursion in general, or am I mistaken? Most programming books have some explanations on the subject - I would just like to offer a tip that I have used in explaining recursion to students... I think it can be helpful to envision each method call as some sort of "agent" (a little goblin or whatever ) receiving a request of some sort. This agent, in turn, may ask other agents for help in the matter, waiting for their response etc. The function definition describes the behaviour of all of them... At least what seems to me as potentially confusing is the notion that the function calls "itself". Envisioning it as calling another function (with the same definition) might be clarifying... Oh, well... Rambling as usual. :) > > Nick > > -- Magnus Lie Hetland From mikael at isy.liu.se Thu Dec 23 02:24:21 1999 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 23 Dec 1999 08:24:21 +0100 (MET) Subject: Equivalent to (a ? b : c) ? In-Reply-To: <86aen2o25s.fsf@g.local> Message-ID: On 23-Dec-99 Gareth McCaughan wrote: > "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. FWIW, Isaac Asimov used "egghead" in one of his shortstories. It was used by people who were trained to have an extremely good memory, about those who were not. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-Dec-99 Time: 08:17:26 This message was sent by XF-Mail. ----------------------------------------------------------------------- From a.eyre at optichrome.com Fri Dec 17 08:28:49 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Fri, 17 Dec 1999 13:28:49 -0000 Subject: Need help with Tuples In-Reply-To: <828n42$10ma$1@rtpnews.raleigh.ibm.com> Message-ID: <004501bf4892$a6fd33a0$3acbd9c2@peridot.optichrome.com> > if(!PyArg_ParseTuple(nobj, "i", &val)){ // fails every stinking time. > appcallback()->messageBox("not again"); > } nobj is not a tuple, it's just an single value. If you can safely assume it's an integer, you can use: long val = PyInt_AsLong(nobj); -------------------------------------------- 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 aahz at netcom.com Fri Dec 24 10:23:09 1999 From: aahz at netcom.com (Aahz Maruch) Date: 24 Dec 1999 15:23:09 GMT Subject: Patch: httplib.py default timeout References: <83r0lh$mj6$1@nntp6.atl.mindspring.net> <38634ba8.3512711@news.iol.ie> Message-ID: <84034t$cki$1@nntp1.atl.mindspring.net> In article <38634ba8.3512711 at news.iol.ie>, Sean Mc Grath wrote: >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. This requires that the platform support threads. Given the current lack of universal support for threads, I think this is a non-starter. The other option, of course, is to use non-blocking sockets, but I think polling is a bad idea for a universal solution. -- --- 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 Roberto.Lupi at ascu.unian.it Wed Dec 8 11:46:51 1999 From: Roberto.Lupi at ascu.unian.it (Roberto Lupi) Date: Wed, 8 Dec 1999 17:46:51 +0100 Subject: difference between invocation of python script on unix and microsoft? References: <000201bf3ff0$f34bdf40$3acbd9c2@peridot.optichrome.com> Message-ID: In article <000201bf3ff0$f34bdf40$3acbd9c2 at peridot.optichrome.com>, a.eyre at optichrome.com says... > > I recently installed perl to my laptop with NT, the README says that > > redirection won't work with the standard shell (CMD.EXE on NT, > > COMMAND.COM on Win9x). > > Odd. Works fine here (NT4 - SP4 - cmd.exe): Sorr,y I haven't expressed my tought cleanly. The ActivePerl FAQ says: ---- 8< ---- CUT HERE ---- 8< ---- For Windows NT 4.0, the coolest method is to use associated file types (see How do I associate Perl scripts with perl?). If you've associated Perl scripts with the .pl extension, you can just type the name of your file at the command line and Windows NT will launch perl.exe for you. If you change the PATHEXT environment variable to include .pl files, like this: SET PATHEXT=.pl;%PATHEXT% you can just type the file name without an extension, and Windows NT will find the first .pl file in your path with that name. You may want to set PATHEXT in the System control panel rather than on the command line. Otherwise, you'll have to re-enter it each time the command prompt window closes. Given this setup, you can have a Perl script called cat.pl that looks like this: while ( <> ) { print; } and you can invoke it on the command line like this: cat myfile.txt However, you can't invoke it with I/O redirection, like this: cat < myfile.txt cat myfile.txt | more although it looks like you should be able to (this is a limitation of Windows NT). Your script can be in your path or you can provide a path to the file. ---- 8< ---- CUT HERE ---- 8< ---- The last part is particularly interesting. -- Roberto Lupi From mlh at vier.idi.ntnu.no Sun Dec 12 19:27:42 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 13 Dec 1999 01:27:42 +0100 Subject: Locking files? n stuff References: Message-ID: _martin_ writes: > Hi all, > [...] > > > So can anybody help me with this? > > I'm writing a guestbook (and eventually counters) And eventually counters? Counters are much easier than guestbooks... > 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. ?) If you want all this done automatically, I suggest you check out the shelve module. It allows you to store python objects in a simple database-file which behaves like a dictionary. All the file locking is implemented by the DB-system. So, if you use an object to represent the guestbook, with all its entries etc. (It could even be just a list or something) you could do something like this: import shelve shelf = shelve.open("guestbook.dat") shelf["guestbook"] = guestbook shelf.close() And to read it in: import shelve shelf = shelve.open("guestbook.dat") guestbook = shelf["guestbook"] # (do stuff, put the guestbook "back in") shelf.close() Just remember to create an empty file with the name of guestbook.dat which the web-server is given writing-access to. Or make sure that it has writing-access to the relevant directory. (Then it can create the file itself.) > [Using latest perl and RH6] > What does perl have to do with anything? ;) > > Also, while I'm here, is it possible to flush the output of html? As I > originally wanted to have one script that handles adding and viewing the > guestbook. ie > initial view = a form with Add and View buttons > When Add is pressed, the page clears and the Add form is displayed > When View is pressed, the page clears and the guestbook entries are > displayed. What does this have to do with flushing? Which part is it that you have problems implementing? > Another query I have, is what datatype to use to store and retrieve the data? > It's gonna be a separate file (so's I can monitor it), I thought about just > writing $trings to the data file. Or should I use lists, or tuples? If you use a shelf, like above, you can do whatever you want. You could make one class for guestbook entries, and one class for the guestbook, etc., and make it really object-oriented. It really needs very little code if you do it right. > Any help is most appreciated -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From xyzmats at laplaza.org Wed Dec 29 11:11:06 1999 From: xyzmats at laplaza.org (Mats Wichmann) Date: Wed, 29 Dec 1999 16:11:06 GMT Subject: Bug in python startup on linux? [Was: Wrong Executable? or something] References: <87d7s05upg.fsf@baal.winnegan.de> Message-ID: <386a322d.9055751@news.laplaza.org> On 21 Dec 1999 21:47:27 +0100, Bernhard Herzog wrote: >Siggy Brentrup writes: > >> Clarence Gardner writes: >> >> > This is a problem I've seen on many linux systems. They're all RedHat or >> > Mandrake (extended RedHat). >> >> Same holds for Debian slink aka 2.1 >> >> I did a little more testing and found out that results depend on your >> PATH setting. >> >> Calling scripts with an empty PATH gives the expected results >[snip proof] >> I suspect a bug in the python startup routine, since sys.prefix >> and sys.exec_prefix are determined at configuration time. > >Python tries to initialize sys.path based on the location of the python >executable. If argv[0] contains no '/' python searches $PATH for the >executable and starts from there. > >On Linux it seems that a program called by the #! mechanism only gets >the basename of the file in argv[0], i.e. there's no '/' and therefore >python searches through the directories in $PATH, so it might get the >wrong one. > >I'm not sure whether this is to be considered a bug in Linux or Python, >but Python could perhaps work around this on a Linux system by using >/proc/self/exe (which is a symbolic link to the executable of the >process) as reference when it searches $PATH for the file. How about not a bug in either? #! has eluded all efforts to be "standardized" in the UNIX universe. Hard to say what the correct behavior should be in the absence of an actual standard. Since installation of tools is up to the user in many cases, and there's nothing "wrong" with installing Python in a completely different place (say, "/opt/bin/" instead of "/usr/local/bin" - it's just a single change at configure time), a script with a full pathname is not particularly portable. There's been some talk of devising a two-level mechanism where a file called /etc/interpreters or some such contains the full paths to #! interpereters on the target system, so that #!python would do the right thing and you don't need so say - non-portably - #!/usr/local/bin/python.... Mats Wichmann (Anti-spam stuff: to reply remove the "xyz" from the address xyzmats at laplaza.org. Not that it helps much...) From aahz at netcom.com Wed Dec 22 12:10:09 1999 From: aahz at netcom.com (Aahz Maruch) Date: 22 Dec 1999 17:10:09 GMT Subject: Patch: httplib.py default timeout Message-ID: <83r0lh$mj6$1@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'. The background is that we've been (okay, foolishly) trying to use urllib in a production environment. We've also been using httplib directly when urllib's behavior is inappropriate. In both cases we've been having hangs in our programs; we fixed the latter problem by manipulating HTTP.socket directly. That's not an option for urllib, and we'd rather not dump urllib because we've already put in a fair amount of time subclassing urllib to fix its behavior. Jeremy's urllib2 isn't the answer, either, because it doesn't address the timeout problem. I don't think subclassing HTTP would help. ;-) 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. -- --- 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 kern at caltech.edu Tue Dec 28 01:27:57 1999 From: kern at caltech.edu (Robert Kern) Date: Tue, 28 Dec 1999 06:27:57 GMT Subject: Basic extension questions. References: Message-ID: <386856db.18493314@news.erols.com> On 27 Dec 1999 13:45:28 GMT, joakim at login1.styx.net (Joakim Ziegler) wrote: [snip] >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? http://starship.python.net/crew/arcege/extwriting/pyext.html is exactly that. >-- >Joakim Ziegler - styx research director - joakim at styx.net >FIX sysop - FIXmud admin - FIDEL & Conglomerate developer Robert Kern kern at caltech.edu From dr10009 at cl.cam.ac.uk Fri Dec 10 09:52:44 1999 From: dr10009 at cl.cam.ac.uk (Dickon Reed) Date: 10 Dec 1999 14:52:44 GMT Subject: string interpolation syntactic sugar References: <82ogb2$db2$1@pegasus.csx.cam.ac.uk> <14415.57793.278683.360085@goon.cnri.reston.va.us> Message-ID: <82r43s$6cj$1@pegasus.csx.cam.ac.uk> In article <14415.57793.278683.360085 at goon.cnri.reston.va.us>, Jeremy Hylton wrote: >When I have complicated formats, I usually turn to dictionaries rather >than trying to match up format strings with a tuple of values: > >"a %(x)s b %(y)s" % { 'x': math.log(0), > 'y': y } > >I'm not sure that the suggested approach of putting some kind of >special delimiters to mark eval-able parts of strings is much of an >improvement. I didn't know that about this aspect of %. The only difference is one of readability. I think that: interpolate("a {math.log(0)} b {y}") is more readable than your code. The readability becomes more important the longer the string gets. It's a question really about whether the decoupling in your approach is worse than the extra knowledge required (ie understanding what interpolate or some syntactic sugar to do the same thing does). It seems borderline to me. Dickon From gerglery at usa.net Thu Dec 16 06:20:33 1999 From: gerglery at usa.net (Alternative Fluffy) Date: 16 Dec 1999 06:20:33 -0500 Subject: Python complaints References: <3858C226.949FC9C6@udel.edu> Message-ID: <87puw7dtdq.fsf@meowhost.meow.invalid> Charles Boncelet wrote: [...] > If Python is a typeless language, Python is not a typeless language, it's a dynamically typed language. the distinction might seem small, but it does explain all the points that are troubling you in how functions behave. > then shouldn't all functions make a reasonable effort at promotion > to try to do something reasonable? (E.g., the Numeric ufuncs > generally do this correctly.) There are places where the documentation could be more precise, and Fred Drake does make frequent appeals for contributions toward that end. That said, it would not be a great idea to go overboard with verbosity, since there do from time to time arrive new types (a recent example being buffer objects) that start working with older functions and methods. Then the complaints move to "how come function x works on buffers, but the docs say it's only for strings?" Damned if you do, damned if you don't. > 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)? Yeah, and you're not alone in thinking that. See the Types SIG archive on Python.org and the meta-SIG where the reasons for its proposed retirement was recently discussed for an overview of the problem, possible solutions and the general pain-in-the-buttness of it all. From skip at mojam.com Fri Dec 3 07:37:06 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 3 Dec 1999 06:37:06 -0600 (CST) Subject: python 3D graphics In-Reply-To: <38475965.E80E77FB@trojanslair.zzn.com> References: <38475965.E80E77FB@trojanslair.zzn.com> Message-ID: <14407.47474.662254.827212@dolphin.mojam.com> >> I am wondering if anybody has any useful information on programing in >> 3D in python. i would appreciate it very much Aside from the several obvious references to OpenGL, if you are interested in something a bit higher level and are doing visualization (you didn't mention your application), you should check out VTK at http://www.kitware.com/ It has a set of Python bindings and a large set of useful algorithm and data classes. 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 worldwin at liii.com Fri Dec 17 01:44:02 1999 From: worldwin at liii.com (dj trombley) Date: Fri, 17 Dec 1999 06:44:02 GMT Subject: "for k in keys().sort()" -- Beyond the FAQ References: <19991202164009.A2121538@vislab.epa.gov> Message-ID: <3859DB33.E584D7B5@liii.com> A slightly less wordy sort: sort = lambda x: (x.sort(), x)[1] -dj From abrahams at mediaone.net Thu Dec 30 11:37:17 1999 From: abrahams at mediaone.net (abrahams at mediaone.net) Date: Thu, 30 Dec 1999 16:37:17 GMT Subject: The Don Beaudry/Jim Fulton hack References: <9GHa4.1682$wG6.149869@ndnws01.ne.mediaone.net> Message-ID: <84g13m$p03$1@nnrp1.deja.com> In article , neelk at alum.mit.edu wrote: > Dave Abrahams wrote: > > > > 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"? > > Read GvR's essay, "Metaclass Programming in Python 1.5" at > > http://www.python.org/doc/essays/metaclasses/ > > I have to admit that you are more hardcore than me -- I never bothered > looking at the C source once I had found this essay. :) Thanks! I forgot that you can also put an attribute calle '__class__' on an object of type class, not just of type instance. Duh. Now I'm trying to get MESS to compile and have run into a couple of seemingly insurmountable obstacles: parts of the Python API used to implement MESS seem to be missing (?!). They are: PyAccess_Check PyAccess_AsValue PyAccess_SetValue PyAccess_SetOwner Does anybody have a clue where these bits can be found (or explained - I'd happily adjust the MESS code if I had a clue what it was doing)? TIA, Dave Sent via Deja.com http://www.deja.com/ Before you buy. From mhammond at skippinet.com.au Wed Dec 8 17:29:53 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 08 Dec 1999 22:29:53 GMT Subject: Python and ASP References: <_ji34.8719$523.343739@news.chello.at> Message-ID: William Burrow wrote in message ... >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? No - you can do Python in ASP. > Is there any place >with details? Is VB involved in any way, shape, manner or form No. > (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?) Not really. Python programs running under ASP make extensive use of the ASP object model, and hence won't work outside an ASP environment. Just like VBScript or JScript code designed for ASP wont work outside of ASP. >A copy to email would be nice as well, but remove the anti-spam first. Sorry - I refuse to do that. If I can live with the spam, so can you. In fact, last week I recieved a total of _4_ spams direct to me (ie, not including those sent to mailing lists). 4 spams per week, and I have been using a unprotected email address on Usenet for years and years. What exactly are you afraid of? Mark. From fredrik at pythonware.com Wed Dec 1 18:57:06 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 2 Dec 1999 00:57:06 +0100 Subject: __builtins_ weirdness References: <02121999.2@sanctum.jae> Message-ID: <003701bf3c57$c65e3fb0$f29b12c2@secret.pythonware.com> Juergen A. Erhard joins the "if I don't understand it, it has to be a bug" crowd: > 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. it's spelled "__builtin__", and you have to import it before you can use it. __builtins__ is an implementation detail. don't use it unless you know exactly what you're doing. period. > Or some *very* good explanation. why? I'm pretty sure nobody here told you to use __builtins__ instead of __builtin__, right? From goodswell at mail.com Sun Dec 12 20:43:39 1999 From: goodswell at mail.com (goodswell at mail.com) Date: Sunday, 12 Dec 1999 19:43:39 -0600 Subject: Want certifies internet business Web sites Message-ID: <12129919.4339@mail.com> We are creating a Internet Store, and want some company to Certifies our internet store. Safety Store!! Anybody could tell me which web site have that services.. Please e-mail me..!! E-mail : goodswell at mail.com Thanks you so much.. Stephen reg. From mhammond at skippinet.com.au Fri Dec 17 22:41:01 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 18 Dec 1999 03:41:01 GMT Subject: MultiProcessor and Win32 threads References: <83droq$ocp$1@news.wrc.xerox.com> Message-ID: "Jos? Manuel Esteve G?mez" wrote in message news:83droq$ocp$1 at news.wrc.xerox.com... > 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. Correct. > Is win32 process threading dependant on this central lock ??? No - it just executes Python, which is dependant on it - ie, win32process does nothing special with the lock, but it is enforced very deep in Python itself. > Is there in fact a central lock that prevents parallel processing on a > multiprocessor NT environment ?? Yes. > Is there any way to avoid that ??? No :-( [Apart from using multiple processes] > On the other hand the function SetThreadIdealprocessor from win32process > seems to be broken. In what way? Mark. From robin at jessikat.demon.co.uk Thu Dec 30 11:01:23 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 30 Dec 1999 16:01:23 +0000 Subject: FINANCIAL MODELLING PACKAGE IN PYTHON? References: <841d0c$j0n$1@violet.singnet.com.sg> <387f6d37.25522789@news.demon.co.uk> <19991230065516.A778039@vislab.epa.gov> Message-ID: In article <19991230065516.A778039 at vislab.epa.gov>, Randall Hopper writes >Andy Robinson: > |Anyone who wants to discuss this, come join the python-finance list at > |www.egroups.com/group/python-finance/. It's been a bit quiet of late > |but that's where my stuff and Kevin's is being discussed.. > >Will do. You ought to get the list sited on: > > http://www.python.org/psa/MailingLists.html > >This is the first I'd heard of it. > I have some good analytics for Markowitz risk/return optimisation. Does this come into the area? -- Robin Becker From gerrit.holl at pobox.com Tue Dec 7 11:11:02 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Tue, 7 Dec 1999 17:11:02 +0100 Subject: lemmings In-Reply-To: <82j6o3$jc6$1@news.qub.ac.uk>; from stuarty@excite.co.uk on Tue, Dec 07, 1999 at 02:48:35PM +0000 References: <82j6o3$jc6$1@news.qub.ac.uk> Message-ID: <19991207171102.A8067@stopcontact.palga.uucp> 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 -- "The IETF motto is 'rough consensus and running code'" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 5:10pm up 1:31, 10 users, load average: 0.23, 0.24, 0.52 From thomas.heller at ion-tof.com Wed Dec 1 11:02:11 1999 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Wed, 1 Dec 1999 17:02:11 +0100 Subject: wish: multiline comments References: <000b01bf3c10$4faf3910$3acbd9c2@peridot.optichrome.com> <018801bf3c12$d9722e80$f29b12c2@secret.pythonware.com> Message-ID: <009901bf3c15$6d5c5290$4500a8c0@thomasnotebook> > 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. AFAIK, python chokes on source files with more than 32767 lines (or was it 65536)? But I never tried it. Thomas Heller From skodela at my-deja.com Wed Dec 1 05:30:08 1999 From: skodela at my-deja.com (Sindh) Date: Wed, 01 Dec 1999 10:30:08 GMT Subject: Help Please - Need a module for Audio programming Message-ID: <822tbg$2v7$1@nnrp1.deja.com> Dear pythoners I am looking for a way to produce noise on my linux/python box. I tried the standard modules but could not find a way to produce sound through python [may be me !]. All I want is a way to produce sound by eg:- make_sound(length_of_time,freq) sort of function. Anyone know of something with that facility or something like that. I want to create a simple module on top of this function. Any reply will be much appreciated Thanks sreekant -- A man needs to sleep for 36 hours a day atleast. Sent via Deja.com http://www.deja.com/ Before you buy. From skip at mojam.com Tue Dec 28 09:08:56 1999 From: skip at mojam.com (Skip Montanaro) Date: Tue, 28 Dec 1999 08:08:56 -0600 (CST) Subject: Super Tuples In-Reply-To: <38687C8C.DAAB9513@prescod.net> References: <386745A6.9B671DBF@prescod.net> <14439.35987.402193.17280@anthem.cnri.reston.va.us> <14440.14505.603625.329128@dolphin.mojam.com> <38687C8C.DAAB9513@prescod.net> Message-ID: <14440.50296.863546.583770@dolphin.mojam.com> Paul> Unreadable tuple-based code like this: Paul> j = mytuple[11] Paul> Of course the usual way to work around this is to do this: Paul> j = mytuple[someconstantpool.someconstant] Paul> But now you have to memorize the location of the constant pool (if Paul> available!) and your execution is slowed by all of the lookups. Ah, what you want are the equivalent of C's enumerated types. Why not abstract that into a distinct feature so you can use the same technique with lists and dicts? >> What's the result of >> >> time = (hour=24, minute=00, second=00) >> point = (x=1, y=2, z=3) >> >> time = point Paul> "time" is an alias for "point"! Python doesn't do type checking of Paul> assignments. It doesn't matter whether time and point are tuples, Paul> super-tuples, classes or integers. Yes, I realized that shortly after hitting "send". 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 ljz at asfast.com Thu Dec 2 13:16:23 1999 From: ljz at asfast.com (Lloyd Zusman) Date: 02 Dec 1999 13:16:23 -0500 Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <87puwpg7kp.fsf@freddy.page.street> <826a3f$32jc@f1n1.spenet.wfu.edu> Message-ID: jlouder at wfu.edu (Joe Louderback) writes: > Phil Mayes (nospam at bitbucket.com) wrote: > > 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. > > To be fair, we Fortran programmers can start arrays with any index, so even > the 4 BC problem can be solved ;-) But can you cause FORTRAN to think that there is no integer between -1 and +1? :) -- Lloyd Zusman ljz at asfast.com From mryan at netaxs.com Fri Dec 17 16:22:14 1999 From: mryan at netaxs.com (Michael W. Ryan) Date: 17 Dec 1999 21:22:14 GMT Subject: python constructor overloading References: <1266675828-4948460@hypernet.com> <385A768B.F61C80F7@EarthLink.Net> Message-ID: On Fri, 17 Dec 1999 17:44:43 +0000, Greg Copeland wrote: >Thanks for spelling this out. I had, however, already read about this >issue. My objects will be explicitly collected (at least, my intent is >to). Err, rather, I assume that 'sys.exc_traceback = None' will do this >after the contained have lived their life? I poorly expressed my self >here as I didn't believe it to be central to my point of contention. >Thanks. I'll pay more attention next time! :) If you're talking about circular references (which I think you are), reference counts get messed up, and it has nothing to do with the traceback. David Beazly explained it well in "Python Essential Reference" (pg. 19). Given the following code: a = {} b = {} a['b'] = b # a contains reference to b b['a'] = a # b contains reference to a del a del b In this example, the del statements decrease the reference count of a and b and destroy the names used to refer to the underlying objects. However, because each object contains a reference to the other, the reference count doesn't drop to zero and the objects are not garbage collected. As a result, the objects remain allocated even though there's no longer any way for the interpreter to access them (that is, the names used to refer to the objects are gone). The best solution in this case, is to use your own cleanup method either in the container or the contents and have them explicitely remove the reference to the other. >Hmmm. I'll try again. I guess it was something I was doing wrong. I >was getting an unbound method error. As for the constructor/initializer >reference. To me, it looks like python's equivalent to a C++ >constructor, so that's what I called it. Is "initializer" the correct >terminology for python? Yes, it's the correct term. When you want to call the __init__ method of a super class, you need to call it explicitely: superclass.__init__(self, args) -- 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 ventrego at yahoo.com Wed Dec 15 01:46:50 1999 From: ventrego at yahoo.com (ventrego at yahoo.com) Date: Tue, 14 Dec 1999 22:46:50 -0800 Subject: Timing in MacPython? Message-ID: 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 From aa8vb at yahoo.com Thu Dec 30 16:07:23 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 30 Dec 1999 16:07:23 -0500 Subject: wxPython glcanvas build on SGI a no-go Message-ID: <19991230160723.A6725@vislab.epa.gov> The identifier "glColorTableEXT" is undefined. The identifier "glGetColorTableEXT" is undefined. The identifier "GL_COLOR_INDEX12_EXT" is undefined. The identifier "GL_COLOR_INDEX16_EXT" is undefined. The identifier "GL_COLOR_INDEX1_EXT" is undefined. The identifier "GL_COLOR_INDEX2_EXT" is undefined. The identifier "GL_COLOR_INDEX4_EXT" is undefined. The identifier "GL_COLOR_INDEX8_EXT" is undefined. The identifier "GL_COLOR_TABLE_ALPHA_SIZE_EXT" is undefined. The identifier "GL_COLOR_TABLE_BLUE_SIZE_EXT" is undefined. The identifier "GL_COLOR_TABLE_FORMAT_EXT" is undefined. The identifier "GL_COLOR_TABLE_GREEN_SIZE_EXT" is undefined. The identifier "GL_COLOR_TABLE_INTENSITY_SIZE_EXT" is undefined. The identifier "GL_COLOR_TABLE_LUMINANCE_SIZE_EXT" is undefined. The identifier "GL_COLOR_TABLE_RED_SIZE_EXT" is undefined. The identifier "GL_COLOR_TABLE_WIDTH_EXT" is undefined. The identifier "GL_EXT_paletted_texture" is undefined. I'm guessing these are wgl'isms? Do we need: #ifdef WIN32 /* if this is a Windows operating system, get the function pointer*/ glColorTable = (PFNGLCOLORTABLEEXTPROC) wglGetProcAddress("glColorTableEXT"); if (glColorTable == NULL) { printf("glColorTableEXT not found\n"); } #endif etc. SGI IRIX 6.5.6f. No glColorTableEXT to be found (for example). But there is a glColorTable(). The latter is documented in the Red book BTW (3rd ed, OpenGL 1.2). Randall -------------- next part -------------- cc-1174 CC: WARNING File = gtk/glcanvas.cpp, Line = 61 The variable "o3" was declared but never referenced. PyObject* o3; ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 391 The identifier "glColorTableEXT" is undefined. glColorTableEXT(_arg0,_arg1,_arg2,_arg3,_arg4,_arg5); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 420 The identifier "glGetColorTableEXT" is undefined. glGetColorTableEXT(_arg0,_arg1,_arg2,_arg3); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9686 The identifier "GL_COLOR_INDEX12_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_INDEX12_EXT", PyInt_FromLong((long) GL_COLOR_INDEX12_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9687 The identifier "GL_COLOR_INDEX16_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_INDEX16_EXT", PyInt_FromLong((long) GL_COLOR_INDEX16_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9688 The identifier "GL_COLOR_INDEX1_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_INDEX1_EXT", PyInt_FromLong((long) GL_COLOR_INDEX1_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9689 The identifier "GL_COLOR_INDEX2_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_INDEX2_EXT", PyInt_FromLong((long) GL_COLOR_INDEX2_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9690 The identifier "GL_COLOR_INDEX4_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_INDEX4_EXT", PyInt_FromLong((long) GL_COLOR_INDEX4_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9691 The identifier "GL_COLOR_INDEX8_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_INDEX8_EXT", PyInt_FromLong((long) GL_COLOR_INDEX8_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9697 The identifier "GL_COLOR_TABLE_ALPHA_SIZE_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_TABLE_ALPHA_SIZE_EXT", PyInt_FromLong((long) GL_COLOR_TABLE_ALPHA_SIZE_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9698 The identifier "GL_COLOR_TABLE_BLUE_SIZE_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_TABLE_BLUE_SIZE_EXT", PyInt_FromLong((long) GL_COLOR_TABLE_BLUE_SIZE_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9699 The identifier "GL_COLOR_TABLE_FORMAT_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_TABLE_FORMAT_EXT", PyInt_FromLong((long) GL_COLOR_TABLE_FORMAT_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9700 The identifier "GL_COLOR_TABLE_GREEN_SIZE_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_TABLE_GREEN_SIZE_EXT", PyInt_FromLong((long) GL_COLOR_TABLE_GREEN_SIZE_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9701 The identifier "GL_COLOR_TABLE_INTENSITY_SIZE_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_TABLE_INTENSITY_SIZE_EXT", PyInt_FromLong((long) GL_COLOR_TABLE_INTENSITY_SIZE_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9702 The identifier "GL_COLOR_TABLE_LUMINANCE_SIZE_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_TABLE_LUMINANCE_SIZE_EXT", PyInt_FromLong((long) GL_COLOR_TABLE_LUMINANCE_SIZE_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9703 The identifier "GL_COLOR_TABLE_RED_SIZE_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_TABLE_RED_SIZE_EXT", PyInt_FromLong((long) GL_COLOR_TABLE_RED_SIZE_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9704 The identifier "GL_COLOR_TABLE_WIDTH_EXT" is undefined. PyDict_SetItemString(d,"GL_COLOR_TABLE_WIDTH_EXT", PyInt_FromLong((long) GL_COLOR_TABLE_WIDTH_EXT)); ^ cc-1020 CC: ERROR File = gtk/glcanvas.cpp, Line = 9765 The identifier "GL_EXT_paletted_texture" is undefined. PyDict_SetItemString(d,"GL_EXT_paletted_texture", PyInt_FromLong((long) GL_EXT_paletted_texture)); ^ cc-1174 CC: WARNING File = gtk/glcanvas.cpp, Line = 117 The variable "wxStringErrorMsg" was declared but never referenced. static char* wxStringErrorMsg = "string type is required for parameter"; ^ cc-1552 CC: WARNING File = gtk/glcanvas.cpp, Line = 9590 The variable "SWIG_globals" is set but never used. static PyObject *SWIG_globals; ^ 17 errors detected in the compilation of "gtk/glcanvas.cpp". From jeff at parlant.com Thu Dec 2 16:05:36 1999 From: jeff at parlant.com (jeff) Date: Thu, 2 Dec 1999 14:05:36 -0700 Subject: Environment variables References: <19991202205512.A8481@stopcontact.palga.uucp> Message-ID: Thanks, that's what I was afraid of. Looks like I am stuck writing a batch/shell script. "Gerrit Holl" wrote in message news:19991202205512.A8481 at stopcontact.palga.uucp... > jeff wrote: > > How do I set environment variables outside the python script? > > os.environ["PATH"] = "/bin:/usr/bin:/usr/local/bin" > > > 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). > > Not possible. The Python script is started as a child. You can't set > environment variables for a parent. > > > I need this for both Linux and NT/Win2k. > > I don't know how it works on NT, but on Linux, you could output this, > like dircolors does: > > export VARNAME=VARCONTENT; > export ANOTHERVARNAME=ANOTHERVARCONTENT > > you could make a shell script: > #!/bin/sh > > eval $(script.py $*) > > > Have fun! > > > -- > "Open Standards, Open Documents, and Open Source" > > -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) > 8:52pm up 7:25, 14 users, load average: 1.35, 1.19, 1.06 > > From gtcopeland at EarthLink.Net Fri Dec 17 10:54:00 1999 From: gtcopeland at EarthLink.Net (Greg Copeland) Date: Fri, 17 Dec 1999 15:54:00 +0000 Subject: python constructor overloading References: <3859904B.631359C8@EarthLink.Net> Message-ID: <385A5C98.1BEB9873@EarthLink.Net> Darrell wrote: > > 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. In this particular case, I wouldn't expect this to happen. Since the container should technically live longer than the contained. In short, if the container is gone, everything within it should also be gone. No memory leaked. > > 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. Ouch! Horrors or horrors. I can't believe this. I'd rather implement a non-OO concept (have floating global functions and vars) than to have to implement trickery, smoke, and least not, mirrors. > > Here's some example code. > > Code from Jesse Sweeney: > Subject: Re: How can I make my assertions smarter? [code and Greg's ramblings removed] Elsewhere, in another thread, I saw someone talking about has-a and is-a. These, IMOHO, are fundamental OO-concepts. Let's say that I have a car. The car has an ("has-a") engine, ("has-a") transmission, and a ("has-a") guage-panel. Let's say that the engine needs to pass vaccum data to the transmission. Furthermore, let's say that the transmission needs to pass rpm data to the gauge-panel. To me, the obvious solution would be to do this: class car: __init__( self ): g = guage(self) t = transmission( self ) e = engine( self ) Now: def engine.tranny_event( x ) car.t.set_vaccume( x ) Whereby, g, t and e are keeping a reference to car. I think you get the idea. This works well (in theory) as long as I'm creating the engine and transmission classes. What if I want to use someone else's engine, but add a turbo changer to it? Now, assume the original engine class doesn't allow the container reference. # Yes, I know that a turbo is not a ("is-a") engine. For the sake of example, we'll assume that if it directly bolts to it, it's part of the engine object. class turboEngine( engine ): def __init__( self, container, boost, stuff ): self.container = container self.turbo( boost ) self.engine.__init__( stuff ) # Do do you do this??? def turbo( boost ): self.hp = log( boost ) # snicker Obviously, I want to keep all of the existing engine's functionality, but simply extend it with the turbo's boost methods. As I understand it, you can't do this?!?!? If I understand you correctly, I have to re-implement engine's constructor and extend it in the turboEngine's constructor. If that's the case, I greatly condom the OO-implementation of python. So it isn't so. If this is that case, I'd say the python authors have been using MFC way too much! :P~ To continue my original rants, if you can't do this, the next obvious solution is to make the gauge a global and remove it entirely from the has-a concept (i.e. it is no longer contained - rather, "it-is"). This, in one shot, defeats one of the fundamental OOD philosophies. Help me out, Greg From mwh21 at cam.ac.uk Sat Dec 4 19:26:33 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 05 Dec 1999 00:26:33 +0000 Subject: "%(a)s ... %(b)s" % {'a': foo, 'b': '%(b)s'} References: <19991204161814.A5289@stopcontact.palga.uucp> <19991204230919.A1360@stopcontact.palga.uucp> Message-ID: Gerrit Holl writes: > >>> s='%% sign, %%(email)s, %(version)s, %%%% sign' > >>> s2=s % {'version': 1} > >>> print s2 > % sign, %(email)s, 1, %% sign > >>> print s2 % {'email': 'gerrit at nl.linux.org'} > {'email': 'gerrit at nl.linux.org'}ign, gerrit at nl.linux.org, 1, % sign > > kan lead to very unexspected things ;-) > > This can lead to ugly Quoting hell! Oh yes, it's not a robust neat solution. It's simple and works as well as it does, if you get what I mean. > But _why_ isn't this permitted: > >>> print '%(a)s, %(b)s' % {'a': 'aaaa'} > Traceback (innermost last): > File "", line 1, in ? > KeyError: b > > Can't Python automatticaly detect there's no B so leave it blank? > Why doesn't Python do this? Well, you could claim that if you were writing a CGI script, you be annoyed if you got it wrong and your web pages had Welcome %(uname)s! I hope you find my site useful! all over them... I mean, there's no obvious "right" solution, so Python picks one. As usual it is flexible enough to let you use the other if you want it. Cheers, Michael From greg.ewing at compaq.com Thu Dec 2 08:12:26 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 03 Dec 1999 02:12:26 +1300 Subject: performance of tuple-less Python? References: <199911302244.XAA22802@axil.hvision.nl> Message-ID: <3846703A.1187865A@compaq.com> Hans Nowak wrote: > > I haven't seen > any features from stack-based languages yet, though. I was thinking about what a Forth/Python hybrid might look like a while ago. Maybe something like def a b c quadroot : b dup * 4 a c * * - -> d d 0 >= if : ( b neg d sqrt + 2 a * / b neg d sqrt - 2 a * / ) else : ( ) Yuck, sorry, that looks gross. Greg From quinn at pyro.ugcs.caltech.edu Fri Dec 3 22:50:59 1999 From: quinn at pyro.ugcs.caltech.edu (Quinn Dunkan) Date: 4 Dec 1999 03:50:59 GMT Subject: Very useful message -- Hah! References: Message-ID: On Fri, 03 Dec 1999 22:30:51 -0500, Dan Grassi wrote: >It seems that by design python, by design, is not to be used as a cgi >scripting language -- otherwise why would it produce this very meaningful >message at the slightest syntax error: > > >Internal Server Error > >The server encountered an internal error or misconfiguration and was unable >to complete your request. >Please contact the server administrator, webmaster at xxxx and inform them of >the time the error occurred, and anything you might have done that may have >caused the error. >Premature end of script headers: /usr/home/xxxxx/calculate.py > > >Personally I've about had it, at least PHP provides reasonable error >messages. > >Dan I apologize in advance if this followup sounds annoyed, but... you deserve it for having an attitude but no clue to back it up. That error, as stated by its title, is a server error and has nothing to do with python. Any cgi script will produce this if it doesn't print the proper http headers. I advise you read the documentation for the cgi.py module, paying especially close attention to the 'Debugging CGI scripts' part. From mspal at sangria.harvard.edu Thu Dec 16 09:54:32 1999 From: mspal at sangria.harvard.edu (Michael Spalinski) Date: 16 Dec 1999 09:54:32 -0500 Subject: DNS lookup Message-ID: Is there a module which would let me do something like nslookup('132.151.1.90') and get the string 'parrot.python.org'? M. From skaller at maxtal.com.au Thu Dec 16 13:11:22 1999 From: skaller at maxtal.com.au (skaller) Date: Fri, 17 Dec 1999 05:11:22 +1100 Subject: Python complaints References: <3858C226.949FC9C6@udel.edu> Message-ID: <38592B4A.9CB86B0E@maxtal.com.au> Charles Boncelet wrote: > However there is nothing in the function declaration that specifies > the type of its arguments. In many cases, the way one finds out > what types are allowed is by experimentation: call the function and > see if you get an error. > > E.g., the doc string for math.sin is "sin(x) return the sine of x". > Nowhere does it tell me that "x" should be a number, not a list. Basically, the Python documentation is not yet of Standards quality. It leaves a whole lot of issues unresolved. But it is (now) not too bad. > 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)? At least in part, the answer is that the developers continue to use old fashioned technology instead of literate programming tools. This makes it inconvenient to maintain documentation, and leaves the developers with the mindset that documentation is a separate task from programming. Unfortunately, new technology supporting literate programming is generally fairly arcane, hard to use, and slow (and my literate programming tool, interscript, while probably the best available tool, is no exception) Python itself makes a small advance in this area (doc strings) and Perl has POD (Plain Old Documentation). But the truth is that no one really knows how to integrate documentation and code in a reasonable manner. -- 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 digitome at iol.ie Sat Dec 18 10:00:22 1999 From: digitome at iol.ie (Sean Mc Grath) Date: Sat, 18 Dec 1999 15:00:22 GMT 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: <385b97d3.9676704@news.iol.ie> On Sat, 18 Dec 1999 11:35:01 +0000, Robin Becker wrote: >Can someone explain in simple terms what the real advantages of XML as >an intermediate language are? > >I understand that it's a data description language, but aren't there >other more compact languages for data description? > >Almost all modern programming languages have some means for describing >data items or objects or classes or whatever. Why don't we have a >derivative of C++ or python or whatever for data description? > You are right that there are lots of ways to achieve what XML achieves - an intermediate data interchange format. Personally, I have used Python for this purpose many times. There is something beautiful about reading data into an application by simply saying: from InterchangeFormat import config where config is some rich Python data structure represented in plain text. This piggy back on Python's ability to parse its own data structures (duh!) to avoid hand-crafting any type of data interchange notation parser. Lispers of course do this kind of thing all the time with s-expressions. XML does the same thing but does it in a language independent notation. The intent of Pyxie is to provide a Pythonic interface to this language independent notation so that you can think in terms of Python data structures and control flows without worrying too much about the underlying syntax. The SAX and DOM APIs also serve as buffers between the programmer and the raw notation but both of these are language indepdent APIs. As a result, they cannot take advantage of Python features we all know and love. I do basically all my XML work in Python/Pyxie. I and am not terribly worried about maintaining a language independent mind-set for XML processing. Pyxie is not for everyone by any stretch of the imagination. There is an undeniable benefit from a management perspective of being able to source expertise at the SAX/DOM level and know that that expertise can become productive quickly whatever the programming environment - C++, Java, Python whatever. Pyxie is unashamedly wedded to Python. My long term goal with it is to layer SAX and DOM on top of it so that developers would be able to choose between a Pythonic interface and a language independent interface for their Python/XML work. I have said this before but I will say it again. Python IMHO beats that pants off both Java and Perl for XML processing. I believe XML presents a real opportunity for the Python community. Between the XML-SIG materials, Pyxie, Zope/XML, f-bots XML-RPC, Greg Steins qp_xml Python is becoming a real contender for XML application development. Side note : At XML'99 in Philadelphia last week, Henry Thompson announced that he had written the hard bits of an XML Schema implementation in Python in just a couple of weeks. Nobody batted an eyelid! Everybody *knew* what Python is and what it is capable of. There were two full day Python tutorials at XML'99. Both Paul Prescod and I had the same experience : developed at these tutorials already knew about Python and wanted to get straight to the details of using it for XML processing. This constrasts dramatically with one year ago when nobody at my tutorial knew anything about Python. In the space of one year, Python-awareness in the XML world has skyrocketed. regards, From billtut at microsoft.com Fri Dec 17 17:38:44 1999 From: billtut at microsoft.com (Bill Tutt) Date: Fri, 17 Dec 1999 14:38:44 -0800 Subject: pythoncom and MTS Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BCB5A@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? > From aahz at netcom.com Thu Dec 30 14:58:59 1999 From: aahz at netcom.com (Aahz Maruch) Date: 30 Dec 1999 19:58:59 GMT Subject: HTMLParser bug? References: Message-ID: <84gdi3$ovv$1@nntp9.atl.mindspring.net> In article , Matt Gushee wrote: > >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? I'm not sure, but I always create a new parser instance. I don't think it costs you anything. -- --- 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 hnowak at cuci.nl Sun Dec 12 15:54:02 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Sun, 12 Dec 1999 21:54:02 +0100 Subject: Suitability of Python for a Big Application? In-Reply-To: <830vic$r2t$1@nnrp1.deja.com> Message-ID: <199912122056.VAA20573@dionysus.fw.cuci.nl> On 12 Dec 99, at 20:11, bobyu5 at mailcity.com wrote: > This application has to run on multiple OSes, Sounds just like a job for Python. :) > access various major > relational databases, Possible, using database modules. There are quite a few of them. > and internet enabled, meaning that it can FTP or > send e-mails as part of its feature. That's easy too. Those modules are in the standard library and very easy to use. > Plus it has to be very easily > extensible and modifiable because modification to the requirements will > occur very frequently. Another thing Python excels at. > Also, it has to be blazingly fast. Well, that's a different bowl of soup, really. You may need to optimize parts of your application. However, when programmed cleverly, speed is usually not a problem. And you can always code certain parts in C. > 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. You could try wxPython... its "look and feel" is more like VB's and Delphi's. > 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? There's Numeric, a sophisticated math library which is said to be very fast. > 3) Heavy duty text processing using regexp (at least > 40MB big)- I know Perl is really fast in this regard; is Python as fast? The short answer: no. The long answer: It depends. I don't know enough of regexen to tell you more, though. I do know that the re library is kinda slow compared to Perl and the (older and deprecated) regex library. > 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! To me, the best approach seems to be: start testing today! Take three days (or, if you're more proficient to Python, 3 hours <0.5 wink>) to experiment with Python in those three areas you mention. Try a fat regex and see how well Python does... is it acceptable for your application? Do heavy-duty tests for Numeric, try wxPython or any other GUIs you want to test, and if needed, talk about improving the results to people in the newsgroup. Python's strong prototyping aptitude allows you to do such tests in a very short time. If Python is not the tool you need, you will know so very quickly... and if it is, you have a working prototype for you application very quickly. Hope this helps a bit, --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 nate at hfd.com Wed Dec 22 07:00:15 1999 From: nate at hfd.com (Nathaniel Haas) Date: Wed, 22 Dec 1999 07:00:15 -0500 Subject: strptime on Unix systems References: <19991222110107.A972@Ridcully.home> Message-ID: <3860BD40.1A539EAC@hfd.com> I'd personally recommend using Marc-Andr? Lemburg's mxDateTime . For time zone support, use a DateTime intstance's .tz attribute. Though I can't vouch for it's strptime on non-Unix platforms. Nathaniel 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? > > Cheers, > Malcolm Tredinnick > > -- > Telepath required. You know where to apply... From gang.li at compuware.com Wed Dec 1 16:41:31 1999 From: gang.li at compuware.com (Gang Li) Date: Wed, 1 Dec 1999 14:41:31 -0700 Subject: use Userdict for class __dict__ Message-ID: <38458474@199.186.16.51> 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. From robin at jessikat.demon.co.uk Thu Dec 9 12:24:05 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Thu, 9 Dec 1999 17:24:05 +0000 Subject: FORTRAN (was Re: indentation) References: <65118AEEFF5AD3118E8300508B124877073CC6@webmail.altiris.com> <944741966.933486@cdwork.cvt.stuba.sk> Message-ID: In article <944741966.933486 at cdwork.cvt.stuba.sk>, Radovan Garabik writes >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. > > Please let's not ask who's the oldest. -- Robin Becker From jeremy at cnri.reston.va.us Fri Dec 3 12:37:05 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Fri, 3 Dec 1999 12:37:05 -0500 (EST) Subject: A Date With Tim Peters... In-Reply-To: <38479F07.110BAC47@corrada.com> References: <199912020003.TAA13009@eric.cnri.reston.va.us> <825nbt$p50@mail.psy.uva.nl> <38479F07.110BAC47@corrada.com> Message-ID: <14407.65473.929570.13611@goon.cnri.reston.va.us> >>>>> "AC" == andres writes: AC> Ionel Simionescu wrote: >> 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. AC> Speech recognition technology is presently not able to AC> transcribe natural speech of unknown speakers. This would only AC> work by having audio recorded and webcast. You are so true. I think a better solution than audio recording and Webcast (which sounds expensive to me) is to get volunteers to act as scribes for particular sessions or talks. If we can get enough volunteers to cover everything, we could put together a pretty nice conference report. Usenix has been doing this for its conferences, and I really like the results. Any volunteers? I'd be happy to coordinate. Jeremy From tseaver at starbase.neosoft.com Mon Dec 6 22:39:58 1999 From: tseaver at starbase.neosoft.com (Tres Seaver) Date: 7 Dec 1999 03:39:58 GMT Subject: A Date With Tim Peters... References: <199912020003.TAA13009@eric.cnri.reston.va.us> <826a3f$32jc@f1n1.spenet.wfu.edu> Message-ID: <8896A98247CD6C6E.947A4F75CB4B059F.612EA19A444D5899@lp.airnews.net> In article , Lloyd Zusman wrote: >jlouder at wfu.edu (Joe Louderback) writes: > >> Phil Mayes (nospam at bitbucket.com) wrote: >> > 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. >> >> To be fair, we Fortran programmers can start arrays with any index, so even >> the 4 BC problem can be solved ;-) > >But can you cause FORTRAN to think that there is no integer between >-1 and +1? :) 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 :) A-zero-by-any-other-sign'ly, Tres. -- --------------------------------------------------------------- Tres Seaver tseaver at palladion.com 713-523-6582 Palladion Software http://www.palladion.com From Friedrich.Dominicus at inka.de Sat Dec 4 03:21:29 1999 From: Friedrich.Dominicus at inka.de (Friedrich Dominicus) Date: Sat, 04 Dec 1999 09:21:29 +0100 Subject: Tutorial for a NEWBIE References: Message-ID: <3848CF09.54793677@inka.de> Nasshi wrote: > > 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 You were at teh righ place there is an extra point documentation. I would look there. Regards Friedrich From prestonlanders at my-deja.com Wed Dec 15 16:32:34 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Wed, 15 Dec 1999 21:32:34 GMT Subject: Merging dictionaries Message-ID: <8391di$l4a$1@nnrp1.deja.com> Hello all, I've got a program that works with large data structures in the form of nested dictionaries. The task at hand is to 'merge' two dictionaries with a special merge_function() called for items that exist in both dictionaries. This is defined simply as putting 'missing' items from one into the other. If an item exists in both, then the merge_function() function is called, and the result of that is used as the value. In my case, the merge_function() is simple addition lambda. I've got a recursive implementation posted below that works fine. Its output is correct. However, it is unbearably slow. I have up to seven levels of nesting, and lots and lots of items. The reason I'm posting is to find out if there is an iterative solution. "Mastering Algorithms With Perl" said nothing about this problem, unfortunately. ;-) Any ideas? If I can't come up with anything I'm afraid I'm going to have to look for and alternate approach to the overall problem and abandon these nested dictionaries. BTW I am aware of the limitations of the function I present below (mainly, the two parameters must be similar in structure, number of nested levels, etc) but it does the job I need. Sorry if the formatting is messed up, too. thanks, ---Preston import types def merge_dicts(left_dict, right_dict, merge_function): """merge two dictionaries, returning the combination. recursively operates on dicts within dicts. You must supply a function that accepts two parameters and returns a conceptually 'merged' value. All type checking must be done by the merge_function you supply.""" return_dict = right_dict.copy() # check that we actually have a function if type(merge_function) != types.FunctionType: raise TypeError, "The merge_function supplied was not a valid function." # cache the key lists right_dict_keys = right_dict.keys() for left_key in left_dict.keys(): if left_key in right_dict_keys: # cache the values left_value = left_dict[left_key] right_value = right_dict[left_key] # recurse on dictionaries if type(left_value) == type({}): return_dict[left_key] = merge_dicts(left_value, right_value, merge_function) continue # apply the merge function return_dict[left_key] = merge_function(left_value, right_value) else: return_dict[left_key] = left_dict[left_key] return return_dict d1 = {"foo" : {"x": 1, "y": {"apple": 912.2, "banana": 11.8}}, "bar" : {"x": 1, "y": 2}} d2 = {"foo" : {"x": 1, "y": {"apple": 87.8, "banana": 0.2, "pear": 12}}, "biff" : {"x": 1, "y": 2}} print merge_dicts(d1,d2, lambda x,y:x+y) # should print: # {'foo': {'x': 2, 'y': {'banana': 12.0, 'pear': 12, 'apple': 1000.0}}, 'bar': {'x': 1, 'y': 2}, 'biff': {'x': 1, 'y': 2}} -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From bbosware at vic.bigpond.net.au Sun Dec 12 07:08:45 1999 From: bbosware at vic.bigpond.net.au (John Leach) Date: Sun, 12 Dec 1999 12:08:45 GMT Subject: What do we call ourselves? References: <3850734D.FD1D7A2C@callware.com> Message-ID: This is getting totally off the point, but did Red Hat name one of their distributions Hedwig after Harry Potter's owl or was it named for something else? John Leach pythonista-manque Ivan Van Laningham wrote in message <3850734D.FD1D7A2C at callware.com>... >Hi All-- >There's been some discussion over the last couple of years over the >matter of how to refer to those who write Python for love, money or the >greater glory of Monty. > >I have always favored Pythonista, because of its "attacking from the >bushes" flavor ("nobody expects the Spanish Inquisition"), but others >have offered Pythoneer, Pythonist, and several others which I cannot now >remember. > >This evening, however, I was struck by a thought (our cat Harley is >occasionally "struck by a thought," too, rather visibly--her eyes go >blank, her ears go straight up, and she stares off into space with her >mouth slightly open). I seemed to remember something from the middle >Harry Potter book, _Harry Potter and the Chamber of Secrets_. I dug it >out from underneath several occupation layers, and leafed through it. >Ah, yes. There it is: page 194. > >"...the snake, instead of vanishing, flew ten feet into the air and fell >back to the floor with a loud smack. Enraged, hissing furiously, it >slithered straight toward Justin Finch-Fletchley and raised itself >again, fangs exposed, poised to strike. > >"Harry wasn't sure what made him do it. He wasn't even aware of >deciding to do it. All he knew was that his legs were carrying him >forward as though he was on casters and that he had shouted stupidly at >the snake, "Leave him alone!" And miraculously--inexplicably--the snake >slumped to the floor, docile as a thick, black garden hose, its eyes now >on Harry. Harry felt the fear drain out of him. He knew the snake >wouldn't attack anyone now, though how he knew it, he couldn't have >explained. ... > >"[Ron and Hermione] pushed Harry into and armchair and said, 'You're a >Parselmouth. Why didn't you tell us?' > >"'I'm a what?' said Harry. > >"'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! > >-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 parkw at better.net Thu Dec 9 02:45:38 1999 From: parkw at better.net (William Park) Date: Thu, 9 Dec 1999 02:45:38 -0500 Subject: Passing variable to python from a url In-Reply-To: <385000DD.EE770B2D@yahoo.com> References: <385000DD.EE770B2D@yahoo.com> Message-ID: <19991209024538.A344@better.net> On Thu, Dec 09, 1999 at 02:19:57PM -0500, Tekhir wrote: > I think I'm pretty good with python now, not a master but i can do most of the > stuff I want without looking for help now. But one thing I do need help on is > passing a variable in a url like so "script.py?variable=1" Is there a way to do > this in python and can someone point me to an example or the library needed for > this. > > > Thanks, > Jeremy "Tekhir" Misavage > -- > http://www.python.org/mailman/listinfo/python-list That's GET method of CGI. Read 'cgi.py' module in the standard documentation. From didier.rano at wanadoo.fr Sat Dec 4 00:34:07 1999 From: didier.rano at wanadoo.fr (Didier Rano) Date: Sat, 04 Dec 1999 06:34:07 +0100 Subject: Problem with HP-UX 10.20 Message-ID: <3848A7CF.DF641F3C@wanadoo.fr> Hello, I have a problem with dynamic (shared) library in python 1.5.2 and HP-UX 10.20. First => Python don't create libpython in shared mode (*.sl) Second => Module TkInter cannot be compiled in shared mode (Unresolved symbol, adress fault at ...) I have try many options of compiler HP (cc ansi), but nothing ot function. If i have success to create a shared library for my module, it doesn't run in python with import because it missed the function init.... But this function is in the library. My module run correctly on a Del Unix. Someone knows this problem Didier Rano Arakne From prestonlanders at my-deja.com Fri Dec 3 11:19:04 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Fri, 03 Dec 1999 16:19:04 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> Message-ID: <828qhj$bb1$1@nnrp1.deja.com> In article <828n3e$8kp$1 at nnrp1.deja.com>, ajmayo at my-deja.com wrote: > 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 PLEASE HELP ME LEARN TO PROGRAM! D00DZ! ;-) > 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 ifI > want to continue a line of code over multiple physical lines? x = "This is a \ line of code \ spanning multiple \ lines" As far as dynamically generating code, yes, AFAIK you do have to produce the correct indentation. I haven't played around much with dynamically generated code, someone else on the newsgroup could probably tell you more. There may be module libraries to help you in generating complex code. Like I said I haven't played with this much. > 1. Will I get over my initial confusion?. (can I use braces, or > BEGIN/END - I presume not) I think you will get over your confusion if you actually sit down and produce a little working code. You're right, braces and BEGIN/END are not part of the language. When I first came to Python from a C background, more than a year ago, I was also thrown off by indentation being syntactically significant. However, I soon came to like it. It really does make the code *look* good, nice and clear and understandable in my opinion. Overall, I think it is a good thing. That you're even thinking about these issues shows that you have the capacity to adjust, I think. BTW If you use a 'real' editor like (X)Emacs then the editor's python mode will largely keep track of indentation issues; it will know to dedent after typing a return statement, for instance. > > 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!) Yes, it does. A simple example: planders at gandalf:~$ python Python 1.5.2 (#11, Apr 22 1999, 09:00:30) [GCC egcs-2.91.57 19980901 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> def foo(): ... prin "z" File "", line 2 prin "z" It prints the file, line number and offending text. > 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. Well, you can certainly approximate it: class my_struct: pass instance = my_struct() instance.name = "bill" instance.cheese = "feta" If you want to enforce rigid type checking, you're using the wrong language. > > 4. Is anyone here also using Zope. What do you think of it? I'm just getting started with Zope myself. I don't have an honest evaluation of it yet. It seems very good and very powerful. In the next few months I'm going to be developing some serious web content in Zope. > 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). No, sorry, not as far as I know. There may or may not be some commercial product that implements this. ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From lull at acm.org Sat Dec 4 12:04:35 1999 From: lull at acm.org (John Lull) Date: Sat, 04 Dec 1999 09:04:35 -0800 Subject: How to create cross between __getattr__() and __getitem__()? References: Message-ID: <55ii4so0ljj78e6lb2tjv0s7ien861iaps@4ax.com> (posted & mailed) In the waning years of the 20th century, "Darrell" wrote (with possible deletions): > Assuming I understand, this might help. Perhaps I didn't express myself well. > attrs={'dog':1, 'cat':2} > > class A: > def __getattr__(self, name): ... > print a.dog > print a.dog This is standard __getattr__() usage, and does not accomplish what I need. I have a procedure queryRemoteDatabase(name, index=-1) which is my sole means of accessing a remote database. That database is not under my control, and queryRemoteDatabase() is very slow, especially when retrieving a tuple. In that database, "dog" is the integer 1, and "cat" is the tuple [3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3]. The following all work: print queryRemoteDatabase(dog) 1 (this takes 20 mS) print queryRemoteDatabase(cat,4) 2 (this takes 20 mS) print queryRemoteDatabase(cat) [3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3] (this takes 360 mS since "cat" is a tuple of 18 integers, and it takes the remote database 20 mS to retrieve *each* element of the tuple) There is no way to find out whether "cat" or "dog" is an integer or a tuple other than a call to queryRemoteDatabase(). Each such call requires a minimum 20 mS, *even if it fails*, and specifying an index when retrieving "dog" will cause it to fail. 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. Regards, John From scoobysnax5336 at my-deja.com Sat Dec 25 10:05:43 1999 From: scoobysnax5336 at my-deja.com (scoobysnax5336 at my-deja.com) Date: Sat, 25 Dec 1999 15:05:43 GMT Subject: calling functions from Tk Message-ID: <842ma7$u2u$1@nnrp1.deja.com> 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. 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() Sent via Deja.com http://www.deja.com/ Before you buy. From mlh at vier.idi.ntnu.no Sun Dec 12 19:12:04 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 13 Dec 1999 01:12:04 +0100 Subject: Dot product? References: <3852B91D.6EE31805@math.okstate.edu> <3854CBFF.85A69AA@compaq.com> Message-ID: Greg Ewing writes: > "David C. Ullrich" wrote: > > My preferred backward-compatible candidate for this is: > > for x and y in list1, list2: 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?) And is for x,y in list1, list2: ruled out because of anything except aesthetic preference? (In that case, I would like to state my preference as being in favour of the latter, due to its consitency ;) -- 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 Thu Dec 16 18:49:43 1999 From: rurban at xarch.tu-graz.ac.at (Reini Urban) Date: Thu, 16 Dec 1999 23:49:43 GMT Subject: Declaring COM-interfaces in Python? References: <38562ebd.0@pandora.research.kpn.com> <3856bffe.121727274@judy> Message-ID: <385977ec.51164630@judy> Marc Battyani wrote: >Reini Urban wrote in message >news:3856bffe.121727274 at judy... > >> 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. > >What Lisp are you using ? >Don't forget to tell us about this in comp.lang.lisp when it works... any. no in fact Corman Common Lisp because it doesn't has it yet. And it is by far the simpliest to start with Corman Lisp. I'm not sure for ACL but I suspect that franz already supports similar functionality. Then also for my own AutoLISP FFI (alpha) and maybe later for Visual Lisp because those guys will need (and pay for it) at most :) No PropertyPages and Persistency, so no full OLE control, but almost a control. Events are the big deal which pays. Also for the perl Win32::OLE module but this is Jan Dubois' field then. For the perl OLE server there're no sources. (ActiveState development sponsored by MS) With pythin it would be much easier than for perl is my guess. Marc has a lot of experience there. In fact I mostly use python's OLE typeinfo browser. For perl/python we would need some sort of very complicated cross-platform trampoline there, but Bruno Haible already has that in the clisp sources. (creating assembler functions on the fly, even closures) With IDispatch it's quite easy, for vtables a little bit harder, but much faster then. My worst problem with IDispatch is probably to persuade the automation client to read/update the typeinfo for those dynamic objects/methods/events dynamically. Haven't checked that yet, but all the work would be meaningless if "some" clients will be too stupid. (python, perl and others could be patched, but the mass...) -- Reini Urban http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html From wclodius at lanl.gov Thu Dec 9 18:47:37 1999 From: wclodius at lanl.gov (William B. Clodius) Date: Thu, 09 Dec 1999 16:47:37 -0700 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: <38503F7E.66E9D5BD@lanl.gov> Christian Tismer wrote: > > I'm 43, and I learned FORTRAN IV right after Algol 64 in the late 70s. > Can't remember if it was this, or an earlier Fortran version which > had no dynamic variables but just statics? > 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 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 cite a reference at this time.) While Fortran could be statically allocated it did not require this, and some code would rely on such tricks as statically defining arrays significantly larger than needed knowing that the processor would allocate the memory for the arrays on demand, i.e., the system would implement reallocation up to the defined size of the arrays or the system capability, whichever was smaller. As a side point, dynamic languages can also be implemented statically with defined limits on depth of recursion or sizes of dynamic entities, it is just wasteful of computer memory and implementor's time to make that an implementation goal on current user systems (there have been user systems in the past that only allowed static allocation and of course micro-controllers usually require static allocation). From: Preston Landers Newsgroups: comp.lang.python Subject: Re: some random reflections of a "Python newbie": (2) language issues Date: Thu, 09 Dec 1999 23:32:59 GMT Organization: Deja.com - Before you buy. Lines: 85 Message-ID: <82pe7b$q76$1 at nnrp1.deja.com> References: <82o0to$6eq$1 at serv1.iunet.it> <82od57$i7n$1 at serv1.iunet.it> NNTP-Posting-Host: 205.238.143.132 To: alex at magenta.com X-Article-Creation-Date: Thu Dec 09 23:32:59 1999 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt) X-Http-Proxy: 1.1 x30.deja.com:80 (Squid/1.1.22) for client 205.238.143.132 X-MyDeja-Info: XMYDJUIDprestonlanders Path: news!uunet!ffx.uu.net!newsfeed.mathworks.com!howland.erols.net!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail Xref: news comp.lang.python:78033 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 In article <82od57$i7n$1 at serv1.iunet.it>, "Alex Martelli" wrote: > 3. "dictionary locking" in lieu of declarations > Given Python's powers of "introspection", I > bet some prototype for this could already be > hacked up, by subclassing the dictionary and > playing with __getattr__, __setattr__, and > __delattr__ -- but, as a newbie, I'm somewhat > reluctant to start along this path myself, in > particular since these dictionaries seem to be > somewhat "magical" (a much beloved term in > Perl, of course, not in Python...:-). But that is You're on the right track with this. There's nothing "magical" about the __getitem__ and __setitem__ methods of dictionary-like or sequence- like objects. (That's what you want in this case, not the attr methods.) You could easily implement what you describe in a Python class. If you really need the speed of built in Python dictionaries, you could implement it as a C/C++ module. I will leave it to you as a learning exercise rather than writing out all the code for you. It's probably a lot easier than you're imagining. I will refer you to: http://www.python.org/doc/current/ref/sequence-types.html and nearby chapters for a reference. The safest thing to do is implement all of those 'special' methods unless you know you won't need one. 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. If you are still stuck, write me and I will walk you through what you need to do. > 4. why can't I overload "in" to have the > expected semantics and maybe be fast...? You don't need to 'overload' the 'in' keyword. Just define the __getitem__ method in your class. This works for me: class foo: def __init__(self): self.data = [1, 2, 3, 4, 5] def __getitem__(self, index): return self.data[index] myfoo = foo() # will print all elements in order for index in myfoo: print index # will print yes if 1 in myfoo: print "yes it is" # will print nope if 7 in myfoo: print "7 is present" else: print "nope, 7 is not there" cheers, ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From tim_one at email.msn.com Wed Dec 1 03:14:59 1999 From: tim_one at email.msn.com (Tim Peters) Date: Wed, 1 Dec 1999 03:14:59 -0500 Subject: automatic "lotjes trekken" In-Reply-To: Message-ID: <000101bf3bd4$291af000$542d153f@tim> ]Fran?ois Pinard] > Strange. I was imagining you rather slim. Are you? :-) The adjective most people come up with first isn't "slim", but "shiny" -- such is the life of a bot. BTW, I picture you as rather slim, since that's how you picture me . > By the way, I do not remember any standard library helper to enumerate > all permutations (or combinations, or arrangements) of a given list > (or tuple). Ideally one at a time, of course. Would this be useful? It would (of course), and I don't know of any ready-made pkg either. I've likely got all the most useful algorithms coded up already (from permutations of n things taken k at a time, to partitions of an integer, in lexicographic or "Grey code" orderings). They were written haphazardly as needed over many years, though, and are inconsistent in their calling conventions. Several have been posted to c.l.py or one of the SIGs in response to individual queries. Someday I expect to clean 'em all up. There is a particular irritation inherent in your natural generalization from list to "list (or tuple)": you should really add "(or sequence)", including strings and user-defined sequence types. A polymorphic generator has to be written very carefully to work with all those types! It also has to be written inefficiently, since it can't assume the base sequence type is mutable. That is, about the only usable things all sequence types can be expected to have in common are support for addition (+) and slicing (seq[i:j]), so building up each intermediate result is generally quadratic-time (repeated +). In recent years, I've tended to ignore all that and write routines that *just* work on lists. Being able to mutate an indexed position can make things much zippier, and having a notation for empty sequences ("[]") and singletons ("[thing]") makes the code easier to follow. Let's make that concrete. I'll attach a CombGen class that works with any sequence type, and where CombGen.get generates k-combinations one at a time in lexicographic order, returning None after all possibilities have been generated. This is how it works: >>> def exhaust(seq, k): g = CombGen(seq, k).get while 1: next = g() if next is None: break print next >>> exhaust([1, 2, 3, 4], 3) [1, 2, 3] [1, 2, 4] [1, 3, 4] [2, 3, 4] >>> exhaust((1, 2, 3, 4), 3) (1, 2, 3) (1, 2, 4) (1, 3, 4) (2, 3, 4) >>> exhaust("1234", 3) 123 124 134 234 >>> That is, it dutifully returns k-combinations of the same sequence type as the CombGen constructor's argument, but the code to achieve that is a bit painful. A CombGen that works only on lists can be much more efficient. Another irritation is that the for/__getitem__ protocol isn't really suited to this kind of application: it's unnatural to index this kind of generator by an integer. So I write a lot of __getitem__ methods that ignore their argument <0.5 wink>: >>> def __getitem__(self, i): # all-purpose xxxGen __getitem__ result = self.get() if result is None: raise IndexError return result >>> CombGen.__getitem__ = __getitem__ >>> for comb in CombGen("abcd", 3): print comb abc abd acd bcd >>> overly-general-ly y'rs - tim class CombGen: def __init__(self, seq, k): n = self.n = len(seq) if not 1 <= k <= n: raise ValueError("k must be in 1.." + `n` + ": " + `k`) self.k = k self.seq = seq self.empty = seq[0:0] # an empty sequence of this type self.indices = range(k) # Trickery to make the first .get() call work. self.indices[-1] = self.indices[-1] - 1 def get(self): n, k, indices = self.n, self.k, self.indices lasti, limit = k-1, n-1 while lasti >= 0 and indices[lasti] == limit: lasti = lasti - 1 limit = limit - 1 if lasti < 0: return None newroot = indices[lasti] + 1 indices[lasti:] = range(newroot, newroot + k - lasti) # Build the result. result = self.empty seq = self.seq for i in indices: # There is no general way to spell "append an element to a # sequence"; addition requires two sequence arguments. result = result + seq[i:i+1] return result From ullrich at math.okstate.edu Sat Dec 18 13:23:35 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Sat, 18 Dec 1999 12:23:35 -0600 Subject: __rcall__??? Message-ID: <385BD126.CB698A38@math.okstate.edu> So why isn't there a magic __rcall__, that would go with __call__ like the other __rop__'s go with __op__? It seems useful to me to allow x to alter the way f behaves when you call f(x); in some situations it seems much cleaner (cleaner than insisting that f have advance knowledge of all the possible sorts of x's that could ever be passed to it, and requiring that the source code for f be modified when a new type of argument is added.) A few examples where it's useful are below. My Function and Data objects do have __rcall__ methods, inserted by hand - a builtin one would work better. (Also then I wouldn't feel so evil spelling it "__rcall__"...) DU For example: An instance of the Function class encapsulates a function. The point to the whole project is a Python math gizmo/thingie, where the _value_ of an expression defining a function actually _is_ the function, or rather the Function. So you can define functions in standard mathematical notation, plot them, etc, all without ever actually parsing the function definition explicitly. Function has a subclass Composition that encapsulates the composition of two functions. Function has a __call__ method roughly like so: def __call__(self, x): if callable(x): return Composition(self, x) else: return self._eval(x) So that Sin(pi) is just 0.0, while Sin(Sin) is another function, is the point. That's the way it started - then I found myself adding many more special cases to Function.__call__. For example Curve is a Data object - if F is a Function (from the plane to the plane, say) and C is a Curve then F(C) is supposed to be another Curve. And Function has a subclass Const; if c is a Const then we want F(c) to be another Const, not a Composition. And so on - I found Function.__call__ getting more complicated with each new feature. Then I revised it to def __call__(self, x): try: let_x_do_it = x.query_rcall() except: let_x_do_it = 0 print 'Sorry, Tim...' if let_x_do_it: return x.__rcall__(self) else: return self.do_call(x) def do_call(self, x): if callable(x): return Composition(self, x) else: return self._eval(x) I hope nobody thinks that's supposed to be designed for maximum performance. The point is that that version of Function.__call__ has remained unchanged through several versions of the project; I get Functions to do the right thing when applied to Curves and Consts just by giving those classes appropriate query_rcall and __rcall__ methods. Other sorts of arguments are coming soon... (Yes, it all gets very slow. Doesn't matter much, all this stuff only gets used when the user wants to define a new Function - that only happens once in a while. Loops where a Function gets evaluated millions of times happen elsewhere, in compiled code.) From neelk at brick.cswv.com Sat Dec 25 20:14:50 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 26 Dec 1999 01:14:50 GMT Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <38656610.E4DA287B@maxtal.com.au> Message-ID: skaller wrote: >Alex Martelli wrote: > >> 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! This is a failure of data structure, not of syntax. What's needed is a way to write for foo in file.readlines(): ... without allocating an entire list. IOW, we want to write: for foo in file.xreadlines(): ... just like we currently write for i in xrange(100): ... So the hypothetical xreadlines() method should return an object that reads one additional line from the file each time it is called. 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.) >Unfortunately, new control structures are easy to introduce, >but we don't want to litter the language with TOO many. >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] > .. In Cpython, there is the items() method on dictionaries, so you can write: for key, val in dict.items() ... There's nothing like it for tuples and lists, but that should be fixed. Digression: As a general rule, syntax is a bad thing, to be avoided whenever possible. Calls for additional syntax are typically a sign that one of the basic operations of the semantics needs generalization. Additional syntax adds cruft that makes that generalization doubly harder to see. One, the immediate sop silences the people being bothered, so you won't think any more about the problem until it crops up again in a seemingly-different context. Two, adding special syntax makes it harder to build the appropriate generalization, because the special syntax reduces the regularity of the language. Neel From Alex.Martelli at think3.com Thu Dec 23 09:28:58 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Thu, 23 Dec 1999 15:28:58 +0100 Subject: How to read lines from end of a file? Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D78@pces.cadlab.it> Alexander Williams wrote: > 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 > I am pretty sure that the given Perl idiom also has to slurp the whole file into memory, plus, since Perl's 'reverse' returns a reversed copy of the list rather than reversing in-place, that should consume _twice_ as much memory as the in-place reversing that your Python equivalent does... (some of us recent-ex-Perl-hackers are some of the most enthusiastic Python newbies, I guess:-). Alex From amitp at Xenon.Stanford.EDU Tue Dec 28 22:04:56 1999 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 29 Dec 1999 03:04:56 GMT Subject: obj in list and list ids the same References: <84a8k4$puq$1@nnrp1.deja.com> Message-ID: <84btoo$mem$1@nntp.Stanford.EDU> 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]. - Amit From morse at harborcom.net Wed Dec 22 01:47:15 1999 From: morse at harborcom.net (Kevin Dahlhausen) Date: Wed, 22 Dec 1999 01:47:15 -0500 Subject: ANN: pyhints - for VIM Message-ID: <386073F2.E8BD11EB@harborcom.net> Pyhints scans one or more Python source files and produces a VIM 'hint' script. When sourced, this script displays the function signature after you type the function name. This idea is from Dr. Cambell's flist program (http://users.erols.com/astronaut/vim/), which does the same for C/C++. http://www.geocities.com/SiliconValley/Peaks/4673/python.html#pyhints -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Kevin Dahlhausen kdahlhaus at yahoo.com http://www.geocities.com/SiliconValley/peaks/4673 "'Do' or 'do not.' There is not 'try.' -Yoda From tim_one at email.msn.com Mon Dec 13 17:11:41 1999 From: tim_one at email.msn.com (Tim Peters) Date: Mon, 13 Dec 1999 17:11:41 -0500 Subject: Python complaints In-Reply-To: <38553B8B.822488D3@callware.com> Message-ID: <000601bf45b7$08a18cc0$96a2143f@tim> [Ivan Van Laningham] > ... [buncha code] ... > 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;-) > > 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? lambda is never needed. Where you have ... lambda args: xxx ... today, def _(args): return xxx ... _ ... was usable the day before lambda was introduced . The uses of lambda in your code are exactly why lambda was introduced: as a minor convenience -- but no more than that. tm.add_command(label=elements[ne], command=lambda m=elements[ne]:setimage(m)) vs def _(m=elements[ne]): return setimage(m) tm.add_command(label=elements[ne], command=_) If people *stuck* to trivial uses like that, Guido wouldn't have come up with the delightful characterization of Python's lambda/map/etc as "minor nuisances" . BTW, the 2nd (pre-lambda) form above is, to me, significantly more readable! In large part because of the clumsiness introduced by abusing the default argument mechanism to sneak "elements[ne]" across the scope boundary. Spreading that tomfoolery across stmts makes it easier to see what's going on. The Python lambda is mostly a hack -- albeit one that does add minor convenience . [Fran?ois Pinard] >> Guido could keep `map', `reduce' and `filter', and get rid of `lambda'. >> I guess it might solve the bigger part of the political problem. :-) I doubt he'll get rid of anything; but adding list comprehensions would provide a way for people without a Lispish background to avoid most uses of map and filter, and hence for non-GUI people also most uses of lambda. People with a Lispish background would like them too, despite their certain a priori claim to despise and abhor them . unreadable-isn't-*always*-better-ly y'rs - tim From ullrich at math.okstate.edu Mon Dec 13 13:37:01 1999 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Mon, 13 Dec 1999 12:37:01 -0600 Subject: Dot product? References: <3852B91D.6EE31805@math.okstate.edu> <3854CBFF.85A69AA@compaq.com> <3854F1EE.3CA02CD6@compaq.com> <3854C1E4.624F7E3A@udel.edu> Message-ID: <38553CCD.3EF08E5B@math.okstate.edu> Charles Boncelet wrote: > 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. Yes, if I'd seen "tuples" in the docs I woulda known that that was what I was looking for. But the only reason I didn't know that map was what I wanted was that I didn't _read_ the part about map when I was hunting for "tuples". I didn't read it because I already knew what map did. (not) I don't think you're gonna have much luck designing a language so it can be used by a bozo like me who skips part of the docs, is my point - if I'd just read that paragraph I woulda known map was what I wanted. > 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. Thanks. I was actually aware of Numeric, at least dimly. The actual things I'm doing are more abstract than that - in email someone has confirmed my impression that Numeric is really more appropriate for numeric things. Dot was not the best possible example, what I really wanted was Transpose. (The _actual_ Dot looks more like def Dot(X,Y): res = AbsoluteZero for (x,y) in Transpose((X,Y)): res = res + x*y return res , where AbsoluteZero is a special object with the property that AbsoluteZero + x = x for absolutely any object x whatever.) > > -- > Charles Boncelet > University of Delaware > Newark DE 19716 USA > http://www.eecis.udel.edu/~boncelet/ From boncelet at udel.edu Mon Dec 20 06:49:22 1999 From: boncelet at udel.edu (Charles Boncelet) Date: Mon, 20 Dec 1999 11:49:22 +0000 Subject: LISTS: Extract every other element - SUMMARY References: <19991216131341.A153923@vislab.epa.gov> <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> Message-ID: <385E17C2.B69A3C98@udel.edu> Randall Hopper wrote: > > Thanks for the suggestions. Many of these are really novel ideas I > hadn't thought of. Here's one more (using mxTools): >>>import NewBuiltins >>>lst2=extract(lst,trange(0,len(lst),2)) On my machine, I do approach #1 10 times in 2.38 secs and the mxTools approach in 0.65 secs. I don't know why mxTools are not more widely used (ie. part of the standard distribution). --Charlie > > I coded each of these up, working with the same list of 100,000 > integers. Here are the results. > > To my amazement, the simple for loop approach is pretty decent, as > Mike mentioned. Numeric will get you a little improvement (30-35%) if you > use the shape-change column-selection approach Mike suggested. > > RESULTS: > > Using range() Using xrange() > ----------------------------------------------------------- > APPROACH #1 | 100.00% (2.13357 sec) | 100.00% (2.03318 sec) * > APPROACH #1b | 96.91% (2.0677 sec) | 98.20% (1.9965 sec) * > APPROACH #2 | 690.97% (14.7423 sec) | 719.24% (14.6235 sec) * > APPROACH #3 | 121.29% (2.58789 sec) | 122.02% (2.48094 sec) * > APPROACH #4 | 308.55% (6.58309 sec) | 323.81% (6.58367 sec) > APPROACH #4b | 705.80% (15.0587 sec) | 740.94% (15.0646 sec) > APPROACH #5 | 104.58% (2.23128 sec) | 105.42% (2.14335 sec) * > APPROACH #6 | 66.42% (1.41702 sec) | 70.39% (1.43119 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 #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] ) > ----------------------------------------------------------------------------- > > -- > Randall Hopper > aa8vb at yahoo.com -- Charles Boncelet University of Delaware Newark DE 19716 USA http://www.eecis.udel.edu/~boncelet/ From boud at rempt.xs4all.nl Wed Dec 29 15:10:20 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 29 Dec 1999 20:10:20 GMT Subject: Which grid widget? References: <38623573.0@news.cyberway.com.sg> <83tuqo$csb$1@news1.xs4all.nl> <386a2038.0@news.cyberway.com.sg> Message-ID: <84dprc$mao$1@news1.xs4all.nl> Ng Pheng Siong wrote: > 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. Well, point 3. is not entirely correct - Qt has always been available for Windows - and I think that if you were to ask Troll Tech you could still buy the older 1.44 version. Although, if you were to go the PyQt route, you might want to approach Phil on the subject of his 2,x bindings. >> 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. You won't get anything extra from GTK when accessing it via WxWindows - after all, that's what a cross-platform toolkit is about, conformity, uniformity: the smallest common denominator. Curiously enough, when this post arrived on my ISP's servers, I was working on extending the standard Qt grid with editable cells and comboboxes - in Python. It's early hours still: I'm taking the C++ EditableTableListBox from KMySQL as a guide, although I intend to keep it to the straight and narrow of just the Qt widgets. It should be fairly easy, I estimate. I'm planning editable cells, in-place comboboxes (with datakeys) and perhaps outlining. -- Boudewijn Rempt | http://denden.conlang.org From anders.eriksson at morateknikutveckling.se Mon Dec 20 09:11:34 1999 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Mon, 20 Dec 1999 15:11:34 +0100 Subject: shelve Message-ID: Hello! How do you print out (on screen) all the 'records' in a shelve? // Anders From martinp at mincom.com Tue Dec 21 03:49:54 1999 From: martinp at mincom.com (Martin Pool) Date: Tue, 21 Dec 1999 18:49:54 +1000 Subject: Pipe error codes off by a factor of 256 References: <83ba4k$9ia$1@nnrp1.deja.com> <385939BF.7B21C26E@bioreason.com> Message-ID: <385F3F32.3074AF98@mincom.com> Mitch Chapman wrote: > > 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). And it can be useful to look at the low byte: IIRC it tells you whether the program exited on a signal, which is often useful information. For example you might opt to terminate yourself immediately if the user interrupted the program you called. -- /\\\ 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 jcw at equi4.com Fri Dec 31 15:54:23 1999 From: jcw at equi4.com (Jean-Claude Wippler) Date: Fri, 31 Dec 1999 21:54:23 +0100 Subject: CHANGED website bookmarks for *-URL! and more Message-ID: <386D17FF.959D74EA@equi4.com> For the past couple of days (!), my mini.net site has been inaccessible. It is hosted by CI Host, see Slashdot for some very gory details: http://slashdot.org/articles/99/12/31/0919221.shtml If you were looking for the Python-URL! archive, please use this link: http://purl.org/thecliff/python/url.html If you were looking for the Tcl-URL! archive, please use this link: http://purl.org/thecliff/tcl/url.html If you were looking for the Tcl'ers Wiki, please use either of these: http://purl.org/thecliff/tcl/wiki/ http://purl.org/tcl/wiki These "Persistent URLs" will be reset to use proper domain names once all issues have been resolved. In other words, the above links will work now and in the future (no matter how badly ISP's foul up). As the hours of 1999 are ticking away, this sort of trouble is quite a telling example of where computing and the internet stands today... Best wishes everyone - let's hope "I.T." grows up in the next millenium. -- Jean-Claude From skip at mojam.com Thu Dec 2 17:27:34 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 2 Dec 1999 16:27:34 -0600 (CST) Subject: Python Type-Inference based LINT.. (pylint.py) In-Reply-To: <38466D02.BAC4A1F6@compaq.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> Message-ID: <14406.62038.707967.348914@dolphin.mojam.com> >> 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: Looks interesting. I suggest two small changes: 1. Use the names from the types module to save having to declare a bunch of new keywords (which would probably not pass Guido's scrutiny): from types import * ... def frobnicate(x as IntType, y as [StringType], z as {(IntType,IntType):SomeClass}) as SomeOtherClass: If that's not acceptable, then perhaps enclosing the type specifiers in quotes would do the trick: def frobnicate(x as "int", y as "[string]", z as "{(int,int):SomeClass}") as "SomeOtherClass": 2. I'd add a few meta types that correspond to the API behaviors (e.g., "number", "sequence", "mapping", ...). That would allow the type inferencer to make assumptions about the behavior of an argument without the programmer enumerating all the possible objects that could fill the bill. These fake types could be added to the types module and set equal to None. All you'd really be interested in is the names anyway (I think). def frobnicate(x as IntType, y as SequenceType, z as {(IntType,IntType):SomeClass}) as SomeOtherClass: 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 keving at primenet.nospam.com Fri Dec 17 00:23:23 1999 From: keving at primenet.nospam.com (Kevin) Date: Fri, 17 Dec 1999 00:23:23 -0500 Subject: Python complaints References: <3858C226.949FC9C6@udel.edu> <14425.4841.291880.269618@weyr.cnri.reston.va.us> Message-ID: <62ij5sov45demdte805irtg48hd0eu8m3o@4ax.com> On Thu, 16 Dec 1999 11:27:21 -0500 (EST), "Fred L. Drake, Jr." wrote: >> 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)? > > 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. -Kevin From cgw at fnal.gov Thu Dec 16 14:57:24 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Thu, 16 Dec 1999 13:57:24 -0600 (CST) Subject: Byte to integer conversion In-Reply-To: <38593499.5BD58BD1@ithaca.dbnet.ece.ntua.gr> References: <38593499.5BD58BD1@ithaca.dbnet.ece.ntua.gr> Message-ID: <14425.17444.750167.930304@buffalo.fnal.gov> Elefterios Stamatogiannakis writes: > 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. >>> l = [1,2,3] >>> reduce(lambda x,y: x*256+y, l) 66051 > I don't care about big, little endian problems If you sudenly start to care about this, you can just reverse/reorder the list as needed. From neelk at brick.cswv.com Wed Dec 8 19:50:29 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 9 Dec 1999 00:50:29 GMT Subject: Newbie: switch question in Python References: <384605BC.56EAB34E@wjk.mv.com> <3847D902.EC9E3243@compaq.com> <82e90l$pp5$1@nntp9.atl.mindspring.net> Message-ID: Aahz Maruch wrote: >In article <3847D902.EC9E3243 at compaq.com>, >Greg Ewing wrote: >> >>But unless you really need the speed, it's a lot clearer still just to >>write a series of if...elifs. > >Maybe, unless you're loading code from a database, in which case the >dict-based switch will be clearer *and* more efficient. It's also clearer to use the dict if you need to do something that needs double-dispatch. Then you can some variation of this: class Foo: ... def binarymethod(self, other): return BinaryMethods[other.__class__](self, other) This can reduce the number of places you need to change your code when you add a class to the hierarchy. It's not as elegant as real multiple dispatch, but it's not too bad... Neel From gerrit.holl at pobox.com Sun Dec 26 12:10:26 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Sun, 26 Dec 1999 18:10:26 +0100 Subject: tutorial questions (examples fail). In-Reply-To: <386625AE.C88C4992@dial.pipex.com>; from peche@dial.pipex.com on Sun, Dec 26, 1999 at 02:26:54PM +0000 References: <386625AE.C88C4992@dial.pipex.com> Message-ID: <19991226181026.A4648@stopcontact.palga.uucp> Keith White wrote: > am running 1.5.2 > have printed the tutorial,and got as far as page 17. > here things go wrong. > in Defining functions the fibonacci example > fails both in interactive mode and if created as a script > with such things as > > myfish at peche:~ > python > Python 1.5.2 (#3, Dec 26 1999, 13:32:19) [GCC egcs-2.91.66 19990314 > (egcs-1.1.2 on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> def fib(n): # write Fibonacci series up to n > ... "Print a Fibonacci series up to n" > File "", line 2 > "Print a Fibonacci series up to n" Python blocks are based on indentation. Try: >>> def fib(n): # write Fibonacci series up to n ... "print a Fibonacci series up to n" ... # your code here regards, Gerrit. -- "The world is beating a path to our door" -- Bruce Perens, (Open Sources, 1999 O'Reilly and Associates) 5:33pm up 7:04, 16 users, load average: 0.09, 0.03, 0.01 From wtopa at dmcom.net Sat Dec 11 14:04:50 1999 From: wtopa at dmcom.net (Wayne Topa) Date: Sat, 11 Dec 1999 14:04:50 -0500 Subject: Error confusing a newbie In-Reply-To: <19991211111707.A20613@quark.emich.edu>; from Jeff on Sat, Dec 11, 1999 at 11:17:07AM -0500 References: <19991210100320.B18389@dmcom.net> <19991211105659.A23924@dmcom.net> <19991211111707.A20613@quark.emich.edu> Message-ID: <19991211140450.B27756@dmcom.net> Subject: Re: Error confusing a newbie Date: Sat, Dec 11, 1999 at 11:17:07AM -0500 In reply to:Jeff Quoting Jeff(jam at 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). Yes Jeff, that is the only way it _does_ work. as I described in my original post. >| >| 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? As I have been burned before, using tabs, I now uses spaces only, for indentation. >| >| 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? Originallly I wrote it using vim and just checked it with Jed, spaces and no tabs. I just ran tabpolice.py on net_time.py and it didn't complain so I am 99.999% sure that I have only spaces. >| >| 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')? running ' python net_time.py' works correctly no matter if the header line is #!/usr/bin/python or #!/usr/bin/env python. It gives the error VT3 root-Deb-Slink:/program/Python# ./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')' with either version and it is executable VT3 root-Deb-Slink:/program/Python# ls -l net_time.py -rwxr-xr-x 1 root root 839 Dec 11 13:39 net_time.py The complete script is included in my first post of this problem. >| >| hope that helps.. please keep us advised of your progress. >| Well it didn't help but then again it didn't hurt either. You did make me wonder so I went and re-checked all of your points. This one os a stinker! Thanks Jeff Regards Wayne -- Cannot load Windows 95, Incorrect DOS Version. _______________________________________________________ From paul.m at yale.edu Thu Dec 9 10:59:18 1999 From: paul.m at yale.edu (Paul M) Date: Thu, 9 Dec 1999 10:59:18 -0500 Subject: some random reflections of a "Python newbie": (2) language issues References: <82o0to$6eq$1@serv1.iunet.it> <82od57$i7n$1@serv1.iunet.it> Message-ID: <82ojmf$sgn$1@news.ycc.yale.edu> Alex, If I read your post correctly, what you're looking forward is already in python. You can make your own objects sequence like by defining the special sequence operator methods (__len__, __getitem__, __setitem__, __delitem__) in the class definition. See section 3.3 of the Python Reference Manual for more info. In the following example I define the __getitem__ method of my object so that a call of "for item in seq" iterates backwards over the internal data list. It would be easy to come up with an example where the internal data didn't involve a sequence at all. seqlike.py ---------- class sequence_like: def __init__(self): self.data = [] def __getitem__(self, key): return self.data[-(key+1)] Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam IDLE 0.5 -- press F1 for help >>> import seqlike >>> a = seqlike.sequence_like() >>> a.data = range(20) >>> for i in a: print i, 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 >>> The python documentation and FAQ is chock full of good stuff waiting to be found. Read 'em and absorb 'em! --Paul Alex Martelli wrote in message <82od57$i7n$1 at serv1.iunet.it>... > >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"...!). > >It's a pity to have to write, say, > if X.hasElement(a): >rather than the natural > if a in X >and it's a net loss of polymorphism, without >any compensating gain that I can see. > >The way I envision this -- if X chooses to >implement a method __contains__, then, >for an "a in X" test, that method is called, >with a as an argument, and its return >value is taken as the test's result. If X >has no such method, then we're back to >the current semantics of "if a in X", i.e., >X must be a sequence, etc etc. [snip] From hweaver at pinetel.com Sat Dec 18 18:33:16 1999 From: hweaver at pinetel.com (Harold Weaver) Date: Sat, 18 Dec 1999 15:33:16 -0800 Subject: Idle install - no module time References: <3857EB77.BA02A2CF@pinetel.com> <38594300.8D88CDE2@pinetel.com> <00da01bf4868$ac397ab0$f29b12c2@secret.pythonware.com> Message-ID: <385C19BC.2DDC46E5@pinetel.com> Fredrik Lundh wrote: > 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) > ... The *shared* line was commented out in the Setup file. That's all there was to it! Thanks to your analysis, the Python installation is now complete. Much obliged. -- Hal From mlh at vier.idi.ntnu.no Mon Dec 6 19:42:45 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 07 Dec 1999 01:42:45 +0100 Subject: Video analysis with numpy... References: <007601bf3fe5$6f11c740$f29b12c2@secret.pythonware.com> Message-ID: "Fredrik Lundh" writes: > Travis Oliphant wrote: [...] > > Packaged with that module is another tool that I use frequently called > > numpyio. It reads arbitrary binary data directly into numpy > arrays. Sounts quite interesting... (Then I just have to convert some image/video format into numpy array format ;) > > > > You didn't mention what format your files are in. Any format, I guess. If I can get the frames stored as separate images, I can just use ImageMagick (or PythonMagick) to convert them. > > I have used the PIL to > > read and write various image data formats before. It would be really nice > > if the PIL interoperated even more smoothly with NumPy arrays Yes... > > an interesting exercise would be to write an image > loader that used PIL's "tile descriptor" mechanism > together with numpyio to read data directly into a > numpy array. I quess that would be something of great use to me... Maybe that makes me a likely candidate for implementing it... But I'm sure there are people out there who know this module better than me, and would need less work to make it... As an aside - maybe there should be a Python pixmap-format? The xpm format writes pixmaps in C syntac, which makes it possible to include the images directly in the code... Maybe it would be interesting to do something like that in Python? (A parallel to the xpm would be quite simple, I guess...) At least then you wouldn't need any modules to read the images. Oh, well... > > but you can > > always go back and forth between the two using the fromstring() functions > > and the tostring() methods of the two packages. IC. > it would be *very* nice if the multiarray module was > added to the python core... Yes, yes, yessss! (Now *that* would be somtething to brag about tho those P**l-guys ;) > (any volunteers?) Err... > > > -- Magnus Echelon jamming noise: Lie FBI CIA NSA Handgun Assault Bomb Drug Terrorism Hetland Special Forces Delta Force AK47 Hillary Clinton From edwardam at home.com Wed Dec 1 21:42:28 1999 From: edwardam at home.com (Edward Muller) Date: Thu, 02 Dec 1999 02:42:28 GMT Subject: Exposing COM via XML-RPC or Something Else References: <38435919.D88B4EC0@home.com> Message-ID: <3845DC91.79286A6C@home.com> Well, one of my thoughts was to pack things in documented Python Dictionaries. I could then do a lot of stuff on the client side (sorting, etc,) without having to do something like calling a function to get a bit of info from the server, do something, get a bit more etc. etc.... There are two problems with this. 1) I'm stuck in Python. Since the datascructures that Python is sending is a 'python' type it will be sent back to the client. That was If I publish (and I hope to) the XML-RPC spec as well as reference source code for server and client. If someone wanted to write a MAPI client (or access to some other COM object that has been wrapped by an XML-RPC api) in JAVA or perl or C they could using my published XML-RPC spec. Don't get me wrong, Python is a great Language, but LOTS of people know Java and C. Not everyone know Python (although an experienced programmer could pick up the basics in about 10 min) and after a week of working with it should be fairly happy to never look elsewhere for a language. 2) XML-RPC can't directly map something like this....I can't think of anyway to wrap this in XML-RPC so that session(DOT)Outbox(DOT)Messages(DOT)Add() means something like Object.SubObject.SubObject.Method().... message = session.Outbox.Messages.Add() My Goals Are: Cross Platform Cross Language I think this leaves three options: 1) Write my own wrapper library, port to every language (and on top of that in a cross platform way) or.... 2) use CORBA, or 3) write an XML-RPC Server/API for each COM component I want to 'expose'. Toby Dickenson wrote: > Edward Muller wrote: > > >I'm playing around with a way to expose Windows COM object via > >XML-RPC (or something else). > > ... > > >OR should I shot for the stars and try to write > >an abtraction layer allowing us to expose MS COM objects with something > >like Corba, ILU or PYRO? This (if it worked) would allow us all to use > >COM objects from other platforms that support whatever library I've used > >to abstract/expose the COM object(s). This all assumes someone is > >running a COM server on the machine the client would connect to... > > I've written a general purpose gateway going the other direction (ie > exposing xmlrpc objects in an IDispatch disguise) by mixing pythoncom > and xmlrpclib.py. > > Assuming you don't mind the mismatch in capabilities (xmlrpc can > return 'structures', IDispatch has named parameters) its a > straightforward exercise. > > hth, > > Toby Dickenson > htrd90 at zepler.org From chapman at bioreason.com Wed Dec 8 19:00:57 1999 From: chapman at bioreason.com (Mitch Chapman) Date: Thu, 09 Dec 1999 00:00:57 +0000 Subject: FORTRAN (was Re: indentation) References: <65118AEEFF5AD3118E8300508B124877073CC6@webmail.altiris.com> Message-ID: <384EF139.91ACD637@bioreason.com> Mike Steed wrote: > > From: aahz at netcom.com [mailto:aahz at netcom.com] > > ... > > 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. Thanks for making me feel like both an old man and a member of a 12-step program: I'm Mitch, I'm 35, and I used Fortran eight years ago. We once had a programmer who thought C was a dialect of Fortran. He wrote the second 1000+-line C function I'd ever seen. (The first was an interrupt service routine (!) from Ultrix, for the Vaxstation console device. Unfortunately, I've seen many examples since then.) -- Mitch From aa8vb at yahoo.com Wed Dec 1 10:20:49 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Wed, 1 Dec 1999 10:20:49 -0500 Subject: Help finding Matt Conyway's tutorial In-Reply-To: <38436A58.98FEA03@pivot.net> References: <38436A58.98FEA03@pivot.net> Message-ID: <19991201102049.A2019327@vislab.epa.gov> Wayne: |I'm trying to find an address for Matt Conway. I understand he has |a tutorial called "A Tkinter Life Preserver" that I would like to |down load. If there is any other tutorial out there that someone |can point me to I be happy for the info. To the latter: http://www.pythonware.com/people/fredrik/tkintrobook.htm An Introduction to Tkinter (Lundh) - Draft http://www.python.org/topics/tkinter/doc.html Python.org Tkinter Doc Index http://www.pythonware.com/library.htm Pythonware Tkinter Doc Index http://uvacs.cs.virginia.edu/~mjc4y/tkinter_examples Tkinter examples (down right now) To the former, from the Life Preserver index.html: * This manual was written by Matt Conway (http://www.research.microsoft.com/research/ui/mconway/home.html) at the University of Virginia. ... * ...FrameMaker version by Ken Manheimer (mailto:klm at python.org), ... * Fredrik Lundh (mailto:Fredrik.Lundh at image.combitech.se) elaborated... The links and e-mails are 2 years old though. Do a few web searches (yahoo, dejanews, etc.). Fredrik Lundh will probably know. Randall From s323140 at student.uq.edu.au Tue Dec 21 12:12:53 1999 From: s323140 at student.uq.edu.au (Rob Hodges) Date: 22 Dec 1999 03:12:53 +1000 Subject: Question about a regular expression References: <385F67E7.B5E4E83@ikb.mavt.ethz.ch> Message-ID: Yoav I H Parish writes: > Hello, > > 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 would like to extract the parameters within the parantheses. > The values ought to be separated. What kind of regular expression > for re.split could I use? I have tried several, but can't seem to get it > right... I'd use a regexp (.*?) to grab the entire contents of each paren pair, and then extract the parameters from there with string.split. IMO, once regexps become too difficult to formulate, you are better off taking a different approach if you can. -Rob From skip at mojam.com Thu Dec 16 13:52:41 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 16 Dec 1999 12:52:41 -0600 (CST) Subject: LISTS: Extract every other element In-Reply-To: <19991216131341.A153923@vislab.epa.gov> References: <19991216131341.A153923@vislab.epa.gov> Message-ID: <14425.13561.91576.602473@dolphin.mojam.com> Randall> I want to take a large list: Randall> [ 1,2,3,4,5,6,7,... ] Randall> and build a list with every other element: Randall> [ 1,3,5,7,... ] Randall> Is there a faster way than looping over indices?: I'm pretty sure you can do this with NumPy. I'm not a NumPy user though, so I'll have to defer to the rocket scientists... ;-) 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 martin.frost at excite.co.uk Wed Dec 15 08:12:21 1999 From: martin.frost at excite.co.uk (_martin_) Date: Wed, 15 Dec 1999 13:12:21 GMT Subject: Locking files? n stuff References: Message-ID: <83843j$u28$1@nnrp1.deja.com> In article , mlh at vier.idi.ntnu.no (Magnus L. Hetland) wrote: > _martin_ writes: > > > I'm writing a guestbook (and eventually counters) > > And eventually counters? Counters are much easier than guestbooks... I thought writing a guestbook would be more challenging! > > What does perl have to do with anything? ;) Arghh, python NOT perl. Tho' I will have to some of that as well. ;( > > > > Also, while I'm here, is it possible to flush the output of html? As I > > originally wanted to have one script that handles adding and viewing the > > guestbook. ie > > initial view = a form with Add and View buttons > > When Add is pressed, the page clears and the Add form is displayed > > When View is pressed, the page clears and the guestbook entries are > > displayed. > > What does this have to do with flushing? Which part is it that you > have problems implementing? What happens is: 2 buttons on an inital form(I'm just passing a query_string for which guestbook to pick) - Add and View, When I click on the buttons, the next lot of html appears underneath. [I'm guessing maybe using sys.exit() to return control back to the browser, so when I make another request, the script is called afresh??] Thanks for all the help Magnus, I'll try the shelf later. (I've been having trouble writing to a file from the script, using lists or tuples.) -- _martin_ @work yorkshire pagan, tull listenin rocker. born, bred, studying in yorkshire replyto:martin at fronbow.force9.co.uk '71 M Y* L++ U KQ C c- B p+ Sh s++R H+ I++ FC(The Moor) R(S11) N(S) Sent via Deja.com http://www.deja.com/ Before you buy. From os at webinspace.de Sat Dec 18 08:19:15 1999 From: os at webinspace.de (Oliver Scheel) Date: Sat, 18 Dec 1999 14:19:15 +0100 Subject: Servlets in JPython Message-ID: <385B89D3.B381F4C0@webinspace.de> Is it possible to develop JAVA-Servlets with JPython? If so, are there any examples on the net. My first tries were not very successful... Oliver -- Oliver Scheel | Tel.: 089 / 74665206 Zenettistr. 45a | Fax: 089 / 74665208 80337 Muenchen | Handy: 0179 / 2958559 Email: os at webinspace.de | http://www.webinspace.de/os/ From warlock at eskimo.com Sat Dec 25 01:02:45 1999 From: warlock at eskimo.com (Jim Richardson) Date: Fri, 24 Dec 1999 22:02:45 -0800 Subject: Tkinter and sliders Message-ID: *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 sposhua at my.pc Mon Dec 20 10:21:19 1999 From: sposhua at my.pc (Sposhua) Date: Mon, 20 Dec 1999 15:21:19 +0000 Subject: Very Stupid Newbie Question Regarding Databases In-Reply-To: <83jr9s$tco$1@nnrp1.deja.com> References: <83jr9s$tco$1@nnrp1.deja.com> Message-ID: On Sun, 19 Dec 1999 55wgm_guy at my-deja.com wrote: > Okay, Im obviously new to the Python world, but I have a project Im > working on that will require databases. In particular, I want to store > multiple records in the format: > > Name: > Email: > Phone Number: > (etc) > > Im starting to look at the gdbm, dbm, and anydbm modules. However, it > seems to me that to store records in the above format would require > some sort of key to retrieve a particular record. How can the *dbm > modules do this? I'd use shelve. Then all you do is create a dictionary like d = {"Eric Idle":["eric at monty.com","(01)5678",...],"John Cleese":[john at circus.com","(01)2345",...]...} and save to a dbm file using shelve. From jam at quark.emich.edu Wed Dec 15 08:28:14 1999 From: jam at quark.emich.edu (Jeff) Date: Wed, 15 Dec 1999 08:28:14 -0500 Subject: smtp and the From header field In-Reply-To: <63AD1AC95D52D311AEB700500483F00009A997@malle.grm.hia.no> References: <63AD1AC95D52D311AEB700500483F00009A997@malle.grm.hia.no> Message-ID: <19991215082814.E26450@quark.emich.edu> On Wed, Dec 15, 1999 at 02:11:15PM +0100, Asle Pedersen wrote: > Yes, there is a RFC822 module. And I have checked with DejaNews on this one > without any success. Any suggestions for the query to put on Deja ?? > > regards, > Asle > hmm.. good question.. I've seen posts with almost this exact query many times in the newsgroup, which is why I made the suggestion. perhaps the easiest solution is to simply look at 'valid' email messages (send yourself a few ;)).. is the smtp module rejecting your messages? is that the problem? when I was dabbling in this for a project at a former employer, I would telnet to the smtp port (25) on a machine known to be running a correctly configured server, and try it out to see what it accepts, and then model the code to do the same thing... this solution may work for you. if you're still having trouble, send along the errors the server is spitting out. regards, J -- || visit gfd || psa member -- || New Image Systems & Services, Inc. From linden at win.tue.nl Mon Dec 13 18:51:50 1999 From: linden at win.tue.nl (Bas van der Linden) Date: Mon, 13 Dec 1999 23:51:50 GMT Subject: GTK choking on wxPython References: Message-ID: <385586DF.5153D1F0@win.tue.nl> Matt Gushee wrote: > Platform: Red Hat Linux 5.2 (kernel 2.0.36, glibc 2.0.7) > GTK: 1.2.1 > Python: 1.5.2 > wxWindows: wxGTK 2.1.11 > wxPython: 2.1.11 > > The problem seems to be wxPython specific, since all the wxGTK demos > run fine. > > Has anybody seen this before? > > Please don't tell me I have to upgrade GTK (unless it's true ;-). I > hate upgrading GTK. > I don't want to spoil your day, but on the wxWindows mailing list they were discussing an error in the configure scripts: it requires only gtk 1.2.1 but some code it uses can actually only be found in the more recent editions of gtk. I am not sure this will cure your problems... Just say to yourself: upgrading gtk is fun, upgrading gtk is fun and maybe you have a good time at it :-) Bas van der Linden From yosef at adsc.com Wed Dec 8 05:09:37 1999 From: yosef at adsc.com (yosef at adsc.com) Date: Wed, 08 Dec 1999 10:09:37 GMT Subject: TK tree control Message-ID: <82lap0$sa4$1@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 kaweh at frodo.sil.at Mon Dec 27 10:00:38 1999 From: kaweh at frodo.sil.at (Kaweh Kazemi) Date: Mon, 27 Dec 1999 15:00:38 GMT Subject: How do I make a Python .bat executable file? References: <38670537.FDBC1785@postoffice.pacbell.net> Message-ID: "Robert Shockley" wrote: > 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~ maybe this is a litte bit OT, but you could use the PATHEXT environment var. PATHEXT=.COM;.EXE;.BAT;.CMD;.PY;.PYW if you add the python extension(s) to it, you can call every *.py/*.pyw without extension (like any other executable) from the 'command prompt'. i've only tested this with NT4/2000. kaweh From fredrik at pythonware.com Thu Dec 16 06:29:12 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 16 Dec 1999 12:29:12 +0100 Subject: C++ (was RE: Python suitability) References: <1266856018-8846450@hypernet.com> Message-ID: <014301bf47b8$c7ab7380$f29b12c2@secret.pythonware.com> Gordon McMillan wrote: > Look at "Design Patterns". Most of those patterns are directly > expressible in Python. So much so, that if you translate the > UML into Python and use that, the result will be needlessly > complex and stilted. fwiw, ORA has put a cat on the cover on the UML book, and a mouse on the cover of Learning Python... From fredrik at pythonware.com Wed Dec 15 09:57:09 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 15 Dec 1999 15:57:09 +0100 Subject: exceptions? References: <8388m7$1ii$1@nnrp1.deja.com> Message-ID: <00e001bf470c$a9ea56b0$f29b12c2@secret.pythonware.com> > Could anyone please point me to a good explanation how exceptions can be > handled, new created and used, how I can check for a special exception and so > on...? http://www.python.org/doc/current/tut/node10.html http://www.python.org/doc/current/lib/module-exceptions.html http://www.python.org/doc/current/ref/try.html From sendzimir at earthlink.net Wed Dec 29 13:03:05 1999 From: sendzimir at earthlink.net (Alexander Sendzimir) Date: Wed, 29 Dec 1999 13:03:05 -0500 Subject: newbie question... References: <3869229B.C06B94E5@earthlink.net> <3869298b.8634305@news.isomedia.com> <00a901bf51f3$499c8340$f29b12c2@secret.pythonware.com> Message-ID: <386A4CD9.D9D87FC6@earthlink.net> Fredrik, You're right. Your approach is more elegant. Hintsize and fileinput module are listed in following threads. I'm putting together a summary of what I've learned here from yourself, Eugene and others. I will post it later today when I'm done testing and writing. (This is a good way for me to learn )(or was that just ?). abs From tjreedy at udel.edu Sat Dec 4 17:41:14 1999 From: tjreedy at udel.edu (Terry Reedy) Date: 4 Dec 1999 22:41:14 GMT Subject: including column information when an exception occurs References: <384957FA.164010A6@mikemccandless.com> Message-ID: <82c5aa$bdu$1@news.udel.edu> To get line numbers in tracebacks, line numbers must be compiled into the Pycode. This makes the result a bit longer than it would otherwise be, but more useful when we goof. Given that the source is read a line at a time, or that '\n' must be special-cased anyway, this is easily done. Adding column numbers would make compilation and execution time and bytecode space even more. Improving messages is probably a better direction to go (such as giving the out-of-range index). I believe this is in progress. TJR In article <384957FA.164010A6 at mikemccandless.com>, mail at mikemccandless.com says... >When a Python exception occurs, the interpreter shows you the stack >traceback to the line where the error occurred. Why, when it gets down >to the actual line, does it not also report, eg, the column or >subexpression in which the error occurs? >This would be useful when you have lines that have a fair number of >operations such that the exception could have come from more than one >sub-expression. >EG, in the following program: > def test0(tup, i0, i1): > test1(tup, i0, i1) > def test1(tup, i0, i1): > return tup[i0] + tup[i1] > test0((1, 2, 3), 2, 4) >This exception is generated: > Traceback (innermost last): > File "test2.py", line 7, in ? > test0((1, 2, 3), 2, 4) > File "test2.py", line 2, in test0 > test1(tup, i0, i1) > File "test2.py", line 5, in test1 > return tup[i0] + tup[i1] > IndexError: tuple index out of range >But, it's unclear which tuple reference caused the IndexError... >Mike From nospam at bitbucket.com Tue Dec 28 01:31:36 1999 From: nospam at bitbucket.com (Phil Mayes) Date: Mon, 27 Dec 1999 22:31:36 -0800 Subject: Patch: httplib.py default timeout References: <840anc$9j8$1@nntp8.atl.mindspring.net> Message-ID: Aahz Maruch wrote in message <840anc$9j8$1 at nntp8.atl.mindspring.net>... > >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 > [big snip] > 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 ) Winsock v1.1 doesn't support SO_RCVTIMEO: BSD options not supported for setsockopt() are: Value Type Meaning SO_ACCEPTCONN BOOL Socket is listening SO_ERROR int Get error status and clear SO_RCVLOWAT int Receive low water mark SO_RCVTIMEO int Receive timeout SO_SNDLOWAT int Send low water mark SO_SNDTIMEO int Send timeout SO_TYPE int Type of the socket IP_OPTIONS Set options field in IP header. Winsock v2 does: Socket Option for NT 4.0 and Win95 [This is preliminary documentation and subject to change.] Details on SO_SNDTIMEO and SO_RCVTIMEO Quotes are from the MSDN CD-ROM. Not being an expert on cross-platform socket implementations, I don't know how much of a problem this is, if any. -- Phil Mayes pmayes AT olivebr DOT com From ansible at typhoon.xnet.com Tue Dec 28 20:59:36 1999 From: ansible at typhoon.xnet.com (James Graves) Date: 29 Dec 1999 01:59:36 GMT Subject: Problem Compiling Python on OpenBSD. References: <271219990853502764%petro@bounty.org> <3868CADA.846D83AC@home.com> Message-ID: <84bpu8$dmp$1@flood.xnet.com> Yesss!!! ... ahem. I was about to try porting 1.5.2 to OBSD, but I'm glad someone beat me to it. Did anyone else see some massive warnings involving GNU readline during the compilation? It seems to run OK though. I'll run the regression tests tonight. Later, James Graves -- _______________________________________________________________________________ http://www.xnet.com/~ansible Rapture. Be Pure. - Blondie From slinkp at angelfire.com Wed Dec 29 14:54:38 1999 From: slinkp at angelfire.com (Paul Winkler) Date: Wed, 29 Dec 1999 14:54:38 -0500 Subject: midi stuff? References: Message-ID: <386A66FE.10ACFE24@angelfire.com> Will Ware wrote: > > 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. I have yet to figure out what to do with it since I can't seem to get the documentation to compile... but there is a midi module on the python.org site: http://www.python.org/download/Contributed.html and do a search for "midi". I am using python in a different musical fashion: generating csound scores. I hope to eventually make my "pysco" module support multiple types of output including midi devices and midi files (to do that I will probably use the above-mentioned midi module once I figure it out). http://www.ulster.net/~abigoo/pw_linux/code.html - ................ 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 olipt at mayo.edu Sun Dec 5 23:49:13 1999 From: olipt at mayo.edu (Travis Oliphant) Date: Sun, 5 Dec 1999 22:49:13 -0600 Subject: Video analysis with numpy... In-Reply-To: References: Message-ID: > > Does anyone have any general advice on using python/numpy (or some > other module) for this purpose? I have a module called signaltools that may be of interest to you. It is at http://oliphant.netpedia.net Packaged with that module is another tool that I use frequently called numpyio. It reads arbitrary binary data directly into numpy arrays. You didn't mention what format your files are in. I have used the PIL to read and write various image data formats before. It would be really nice if the PIL interoperated even more smoothly with NumPy arrays, but you can always go back and forth between the two using the fromstring() functions and the tostring() methods of the two packages. There are lots of ways to do it. Which one you choose will probably depend on what format your videos are in. Regards, Travis O. From artymiak at safenet.pl Thu Dec 30 10:53:14 1999 From: artymiak at safenet.pl (Jacek Artymiak) Date: Thu, 30 Dec 1999 15:53:14 GMT Subject: Seccond week using Python. WOW! References: <3869A508.48BDB57A@netscape.net> Message-ID: <386B8634.9A21B5F2@safenet.pl> > 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. Don't forget to register at the Python Users Counter! (details below) Jacek Artymiak ------------------------------------------------------------------- See how many people have registered at the Python Users Counter! http://www.wszechnica.safenet.pl/cgi-bin/checkpythonuserscounter.py ------------------------------------------------------------------- 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 Mon Dec 6 07:28:40 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 6 Dec 1999 13:28:40 +0100 Subject: Video analysis with numpy... References: Message-ID: <007601bf3fe5$6f11c740$f29b12c2@secret.pythonware.com> Travis Oliphant wrote: > > Does anyone have any general advice on using python/numpy (or some > > other module) for this purpose? > > I have a module called signaltools that may be of interest to you. It is > at http://oliphant.netpedia.net > > Packaged with that module is another tool that I use frequently called > numpyio. It reads arbitrary binary data directly into numpy arrays. > > You didn't mention what format your files are in. I have used the PIL to > read and write various image data formats before. It would be really nice > if the PIL interoperated even more smoothly with NumPy arrays an interesting exercise would be to write an image loader that used PIL's "tile descriptor" mechanism together with numpyio to read data directly into a numpy array. see http://www.pythonware.com/library/pil/handbook/decoder.htm for more info on tile descriptors. > but you can > always go back and forth between the two using the fromstring() functions > and the tostring() methods of the two packages. it would be *very* nice if the multiarray module was added to the python core... (any volunteers?) From mgushee at havenrock.com Mon Dec 13 21:57:56 1999 From: mgushee at havenrock.com (Matt Gushee) Date: 13 Dec 1999 21:57:56 -0500 Subject: GTK choking on wxPython References: <385586DF.5153D1F0@win.tue.nl> Message-ID: Bas van der Linden writes: > I don't want to spoil your day, but on the wxWindows mailing list they > were discussing an error in the configure scripts: it requires only gtk > 1.2.1 but some code it uses can actually only be found in the more recent > editions of gtk. I am not sure this will cure your problems... Just say > to yourself: upgrading gtk is fun, upgrading gtk is fun and maybe you > have a good time at it :-) Oh. Well, thanks for the info. I will do my best to have fun with it. -- Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ From gmcm at hypernet.com Thu Dec 30 22:13:49 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 30 Dec 1999 22:13:49 -0500 Subject: The Don Beaudry/Jim Fulton hack In-Reply-To: Message-ID: <1265513352-7039728@hypernet.com> Dave Abrahams wrote: > 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. Misunderstanding. I thought you meant "in Python". There was an earlier hook that allowed you to do this stuff in C. The current hook works for both, of course, but AFAIK, only 2 people have used the hook in C, and only one implementation works with Python 1.5. It's most popular use is for "acquisition", which is not only possible in pure Python, it's possible to do it with proxies instead of metaclasses. > > 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. I meant the hook was (and is) experimental. Python 2 is likely to have a completely different object model in which types and classes are merged, and metaclasses have play a part in the object model. To date, the only known use for this stuff is to do hidden getattr and setattr tricks. - Gordon From garry at sage.att.com Fri Dec 3 15:41:11 1999 From: garry at sage.att.com (Garrett G. Hodgson) Date: Fri, 3 Dec 1999 20:41:11 GMT Subject: split this newsgroup? References: <38473B4E.9050DF4D@callware.com> Message-ID: <38482AE7.185FC0C3@sage.att.com> Ivan Van Laningham wrote: > "Max M. Stalnaker" wrote: > > > > The volume on this newgroup might justify splitting the newgroup. Comments? > > > > No. i disagree. the answer is: NO! -- 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 Gaetan_Corneau at baan.com Tue Dec 21 11:32:03 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Tue, 21 Dec 1999 11:32:03 -0500 Subject: Equivalent to (a ? b : c) ? Message-ID: <816010E2456BD111A48700805FBBE2EEFDF93A@ex-quebec-u1.baan.com> > (Perl anyone?) Thanks, but no, thanks. > But really, I think it's a bit much to ask for a > readable version of ?: since the original construct is itself a bit of > a disaster for readability IMO... It's really not that bad if you don't imbricate them. And "?" is very useful in ctor initialisation lists. But I don't miss the operator that much in Python. I can live with a little function that emulates it, even if it can't do short-circuit evaluation. ______________________________________________________ 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 mlh at vier.idi.ntnu.no Thu Dec 30 18:19:55 1999 From: mlh at vier.idi.ntnu.no (Magnus L. Hetland) Date: 31 Dec 1999 00:19:55 +0100 Subject: Regex problem with JPython 1.1b4 and Java 1.2.1 References: Message-ID: mlh at vier.idi.ntnu.no (Magnus L. Hetland) writes: > I See they have PerlTools 1.2 out, specifically supporting Java > 1.2... Maybe I'll try that... I tried using OROMatcher 1.1 (the newest) and had the same problem. (I don't know if that's the version that is bundled with JPython). ORO Inc. say that it is Java 1.2 compatible... Hm. I tried it again (with this new installation) with Java 1.1.7B - there I got a syntax error in the pyclbr.py file (but it didn't hang, as it had with java 1.2.1). Although that might not be *that* interesting, the syntax error was: Traceback (innermost last): File "", line 1, in ? File "/home/stud/f/mlh/java/JPython-1.1beta4/Lib/pyclbr.py", line 66 \""" [^"\\]* (?: ^ SyntaxError: invalid syntax This line was part of the following expression: _getnext = re.compile(r""" (?P \""" [^"\\]* (?: (?: \\. | "(?!"") ) [^"\\]* )* \""" (more expression down here...) -- Magnus Lie Hetland From ivanlan at callware.com Thu Dec 30 18:49:45 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 30 Dec 1999 16:49:45 -0700 Subject: [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: <386BEF99.423F1FC4@callware.com> Hi All-- Kendall Clark wrote: > [snip] > But, hey, a Python autodidact can hope! > You're the prof, so you can pick any book you want;-) > Any signs that Python is getting used by CS profs/depts as a first language? > There was a charming presentation by a CS prof at the O'Reilly Open Source Conference back in August at Monterey. I think you can still order the slide CD from O'Reilly, and someone is producing audiotapes of the presentations. The URL for the audiotaper was posted on this newsgroup in September sometime. IIRC, he used Python instead of Java in a Junior College, but I could be wrong about the JC part. Coulda been high school. ... > 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? > Oh, that's easy. Python 2.0. >Honesty subverts! -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 nospam.python at scoobysnacks.com Mon Dec 13 06:12:14 1999 From: nospam.python at scoobysnacks.com (Shaggy) Date: Mon, 13 Dec 1999 11:12:14 GMT Subject: Newbie: need help with control loop References: <38543b80.289200819@news-server> <8321cu$i1h$1@news.udel.edu> Message-ID: <3854d1ca.327680172@news-server> 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... >> >>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) 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. P.S. Thanks for all the other pointers, and that is a real email address. I usually use marshall@ but eitherway it will be delivered. It's just easier to filter all addresses on nospam if there were a problem. From JamesL at Lugoj.Com Wed Dec 1 01:15:37 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Tue, 30 Nov 1999 22:15:37 -0800 Subject: Python complaints References: <81bmmi$279$1@nnrp1.deja.com> <3841EE77.6B5D6AC9@wjk.mv.com> <38435C43.B238EC15@mindspring.com> Message-ID: <3844BD09.53B39078@Lugoj.Com> Will Ware wrote: > > 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. Something like this could be accomplished > by tinkering with Python's parser, but that wouldn't be a great idea. > A lot of work for something that would never find wide acceptance. An alternate view (possibly incorrect, but I suspect it is close to correct): The "++" method doesn't belong to the underlying object (e.g. the number 3 or the string "xyzzy"), but to the reference "i". After all, at a certain point in execution the "i" may reference any possible value. The execution frame resolves the meaning of "i++" first by looking at the *class* of object referenced by "i" _at that moment_ and if it then makes sense (exception if not) uses the currently referenced object to find the next object to be referenced. I think any OO execution model that can't account for something as basic as assignment may lead to erroneous conclusions about what can and can not be considered valid operations. And this is what it boils down to after all. Maybe I'm missing something, (or maybe others are), but I can't see how adding the "++" operator suddenly makes numbers mutable. No one is asking for 2 to become 3, merely that *REFERENCES* be mutable. You couldn't accomplish a whole hell of a lot of computation if references always pointed to the same values for all time! This message delivered on behalf of the Mutable Reference Liberation Front! Long live references! From gmcm at hypernet.com Sat Dec 4 16:18:45 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 4 Dec 1999 16:18:45 -0500 Subject: Exposing COM via XML-RPC or Something Else In-Reply-To: Message-ID: <1267780385-12582932@hypernet.com> Bernhard Reiter wrote: [snip a huge pile of links] > >CORBA is NOT a component standard -- it's an interoperability > >standard. > Well AFAI understand it COM also is an interoperability standard, > but I might just miss the point here. "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. 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 extensions do so well). The equivalent CORBA stuff (dynamic 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. > >>The big part of the microsoft COM platform is the MTS > >>(microsoft transaction server) if you want to do to distributed > >>objects. > > > >Um -- that's true for COM+, but COM doesn't need it to operate. > Well if you don't want distributed computing... MTS provides transaction services. That's not part of core CORBA either. Distributed computing is DCOM, which is COM plus some marshalling. > I do not habe much experience about it, I admit, but technically > they also seem to have the same complexity. I just do not believe > that COM is easier to code. Well this is, what the articles > support, too. It all depends on what you're doing and what tools you use. 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. - Gordon From frank.sergeant at redneck.net Mon Dec 27 11:39:30 1999 From: frank.sergeant at redneck.net (Frank Sergeant) Date: 27 Dec 1999 10:39:30 -0600 Subject: Py2K wishes References: <38675B72.18A139FF@prescod.net> Message-ID: <87ogbcuym5.fsf@den.home.net> 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'. However, for "parallel construction", you might consider them both nouns. -- Frank From andrei at ispi.net Tue Dec 14 18:28:04 1999 From: andrei at ispi.net (Andrei Zmievski) Date: Tue, 14 Dec 1999 23:28:04 GMT Subject: Python/cgi Was: Very useful message -- Hah! References: <199912052201.RAA11142@mail3.mia.bellsouth.net> <3854a300.15783926@news.demon.co.uk> Message-ID: <836jpv$sra$1@nnrp1.deja.com> In article <3854a300.15783926 at news.demon.co.uk>, andy at robanal.demon.co.uk (Andy Robinson) wrote: > 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? Hi, PHP provides a header() function you can call to set any header you want. If it's not called then the content type is assumed to be text/html. -Andrei Sent via Deja.com http://www.deja.com/ Before you buy. From tim_one at email.msn.com Thu Dec 30 01:09:25 1999 From: tim_one at email.msn.com (Tim Peters) Date: Thu, 30 Dec 1999 01:09:25 -0500 Subject: Equivalent to (a ? b : c) ? In-Reply-To: Message-ID: <000301bf528c$6c10c280$a02d153f@tim> [Rob Hodges, about (a and [b] or [c])[0] and friends] > ... > which I guess is what idiomatic means -- an idiocy so common that > recognising it quickly becomes automatic. (Thereby making it seem > less of an idiocy.) Na, this isn't idiomatic Python. I blessed the Python world with this construct in the early 90's (see FAQ 4.16), in a light-hearted thread that just wondered whether it could be *done*. I've never used it in a real program, and am not sure I've seen anyone else use it except for playful obfuscation. > ... > Out of curiosity, is there any advantage to using singleton tuples > rather than lists? And is there any advantage in using the > seemingly-redundant parens? There's no advantage in using any flavor of this silliness. much-less-in-discussing-it-ly y'rs - tim From kcazabon at home.com Thu Dec 9 15:26:53 1999 From: kcazabon at home.com (Kevin Cazabon) Date: Thu, 09 Dec 1999 20:26:53 GMT Subject: Tk Listbox Question References: <384FC9F6.1521A533@earth.ox.ac.uk> Message-ID: It's actually pretty simple... most of what you need can be found in Fred's "Introduction to Tkinter" at: http://www.pythonware.com/library/tkinter/introduction Here's a quickie though. It's in a class wrapper because I've build myself a 'standard' set of compound widgits that I use. You could call this by simply calling: "list = display_list(parent, items_in_list)" ####################################################################### class display_list(Frame): def __init__(self, parent, items, height = 15, width = 20): self.frame = Frame(parent) self.frame.pack(side = TOP, expand = NO) self.listbox = Listbox(self.frame, height = height, width = width) self.listbox.pack(side = LEFT, expand = NO, fill = X) self.scrollbar = Scrollbar(self.frame) self.scrollbar.pack(side = RIGHT, expand = NO, fill = Y) self.listbox.config(yscrollcommand=self.scrollbar.set, relief = SUNKEN) self.scrollbar.config(command = self.listbox.yview, relief = SUNKEN) for item in items: self.listbox.insert(items.index(item)+1, str(items.index(item)+1) + '. ' + item) self.listbox.update_idletasks() #Here's the bindings self.listbox.bind('', self.do_this) self.listbox.bind('', self.do_that) self.listbox.bind('', self.do_something_else) def do_this(self): pass def do_that(self): pass def do_something_else(self): pass ############################################################################ ### "Nick Belshaw" wrote in message news:384FC9F6.1521A533 at earth.ox.ac.uk... > Calling Tk wizards- > > Could anyone (/F?) tell me if it's possible to modify - without too much > difficulty - the bindings on a Tk Listbox. What I would like to do is > select an item with either Left or Right Mouse Buttons but with > different actions on depending on which was used. > > doable or too tricky? > > or dead easy and I'm thick! > > thanks for any ideas > Nick/Oxford > > > From Ruelaz at aol.com Wed Dec 22 17:35:31 1999 From: Ruelaz at aol.com (Ruelaz at aol.com) Date: Wed, 22 Dec 1999 17:35:31 EST Subject: (no subject) Message-ID: <0.bfc75669.2592ac33@aol.com> From claird at aftershock.neosoft.com Fri Dec 31 11:19:17 1999 From: claird at aftershock.neosoft.com (Cameron Laird) Date: 31 Dec 1999 10:19:17 -0600 Subject: [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: <2881B3B392F6F1D6.245633A232601BA7.19E9E2260D812F76@lp.airnews.net> In article <14443.59621.975171.406252 at cmpu.net>, 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? . . . Dutch. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From aahz at netcom.com Sun Dec 26 12:06:50 1999 From: aahz at netcom.com (Aahz Maruch) Date: 26 Dec 1999 17:06:50 GMT Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> <38656610.E4DA287B@maxtal.com.au> <006c01bf4f82$a39bc220$bf2b2bc1@martelli> <3866376F.72E62E79@maxtal.com.au> Message-ID: <845hva$op2$1@nntp8.atl.mindspring.net> In article <3866376F.72E62E79 at maxtal.com.au>, skaller wrote: > >I'm not sure. I also have no candidate syntax for defining the >labels. Labelled breaks give me an uneasy feeling. Hmmm.... I had a weird idea: how about "break " where simply returns a positive integer representing the number of levels to break? -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 TEOTWAWKI -- 6 days and counting! From claird at starbase.neosoft.com Sun Dec 19 07:26:58 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Dec 1999 12:26:58 GMT Subject: Multi-User non Client/Server database References: Message-ID: <7DE1F51DE6EF8DE2.FEF18A6AB6E94830.57F6A00E6C02B0D3@lp.airnews.net> In article , Anders M Eriksson wrote: . . . >So to recap: I need a database that must be Multi-user with record >locking, but NOT Client/Server. ANYONE? . . . You'll want to read the recent MetaKit announcement . MetaKit plays very well with Python, does locking right, and doesn't require sockets. While it doesn't embody account-based security, I'm not sure what you have in mind for multi-user-edness, so perhaps it'll fit. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From Alex.Martelli at think3.com Wed Dec 15 04:30:55 1999 From: Alex.Martelli at think3.com (Alex Martelli) Date: Wed, 15 Dec 1999 10:30:55 +0100 Subject: C++ (was RE: Python suitability) Message-ID: <6D8A17398E28D3119F860090274DD7DB4B3D43@pces.cadlab.it> Grant writes: > About twice as long as it would take for a Modula-3 or > Smalltalk programmer. ;) I've never thought C++ was a > particularly decent example of an object-oriented language, but > maybe that's because I learned Smalltalk and M3 first. > > The whole virtual-function-method thing has always struck me as > very obtuse. You apparently have to guess ahead of time which > methods somebody might, at some point in the future, want to > override, and declare them differently from the non-overridable > ones... > Or, to put it another way: you have to DESIGN, rather than just start hacking. Specifically, if you follow the advice of Scott Meyers, in his excellent "Effective C++" (CD Edition): never inherit from a concrete class. If you do all of your inheritance from abstract classes, and use better (although somewhat more boilerplatey:-) schemes for code reuse (mainly containment-and-delegation -- I just wish C++ had a smooth way to express delegation, sigh), you're _forced_ to design-rather-than-hack -- which is one big plus -- and you get better componentization, modularity, and scalability (cfr Lakos' "Large Scale C++" -- what he calls "protocol classes" are exactly abstract classes, or Java "interface"'s if you wish; cfr Martin's books, and the papers on his side -- his "dependency inversion" transformation is one way to refactor a design with bad dependencies, and it does so by introducing inheritance-from-abstract-classes). 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. One key difference is that, in C++, you _can_ design and maintain huge and flexible projects -- the language does not hinder, and gives you almost all the tools you need for that ("almost": it misses language-level, standard support for such key packaging/deployment issues such as packaging into separate "libraries", threading and IPC issues, network access, GUIs, DBs -- you have to turn to other standards for these; on the plus side, C++, having no built-in idea of how any of those should work, will never hinder you from integrating with any other existing architecture you may need). C++ does not _constrain_ you to do your homework, and design (and design _well_) -- it does not even really make any serious attempts at so constraining -- letting you do just about anything means giving you by far "enough rope to shoot yourself in the foot". This means most developers are NOT suited for the language (or vice-versa:-), because they lack the professional discipline, or the skill to apply it successfully, for the kind of projects for which C++ makes sense (either HUGE ones, or ones with really, TRULY tight constraints of performance, where every microsecond does matter). But I doubt any language would make such developers truly more productive at such tasks of extreme difficulty. I've seen quite a few try to, and none truly succeed. 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. Alex From hnowak at cuci.nl Thu Dec 2 16:49:24 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Thu, 2 Dec 1999 22:49:24 +0100 Subject: use Userdict for class __dict__ In-Reply-To: <38458474@199.186.16.51> Message-ID: <199912022151.WAA01296@dionysus.fw.cuci.nl> On 1 Dec 99, at 14:41, Gang Li wrote: > 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. Hmm... assuming that your MyUserDict still uses the dictionary called 'data' internally, you can use that: Foo.__dict__ = MyUserDict(Foo.__dict__).data I don't know if it will have the desired result though. =/ --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 kdart at pacbell.net Sat Dec 11 23:18:55 1999 From: kdart at pacbell.net (Keith Dart) Date: Sat, 11 Dec 1999 20:18:55 -0800 Subject: Error confusing a newbie In-Reply-To: <19991211161917.C27756@dmcom.net> References: <19991210100320.B18389@dmcom.net> <19991211161917.C27756@dmcom.net> Message-ID: On Sat, 11 Dec 1999, Wayne Topa wrote: > > >| 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. > > No, as a matter of fact, I had 'not' noticed. As soon as I deleted the > first blank line it worked! If you hadn't mentioned it I would not have > found that. Line 7 was line 7 in vim and I let vim to do the counting. > Darn, was that stupid of me!! Interesting. I had a similiar problem once. I once got a script that had been "tainted" by being on an NT box. It had ^M's at the end of the line. The latest VIM tries to be "smart", and doesn't show these to you by default, so I had no idea. The script refused to run, because the OS was looking for the executable named "/usr/bin/python^M" and couldn't find it. This is interesting. I put the following in a file and made it executable. ----------------------cut----------------- echo "This runs!" ----------------------cut----------------- 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... /___\\|//__//// \ (+ +) \\\\ -- --------------------oOOo~(_)~oOOo---------------------------------------- Keith Dart ============================================================================ From rodzilla2000 at my-deja.com Mon Dec 13 19:17:16 1999 From: rodzilla2000 at my-deja.com (rodzilla2000 at my-deja.com) Date: Tue, 14 Dec 1999 00:17:16 GMT Subject: Need help with Tkinter Message-ID: <8342a8$1td$1@nnrp1.deja.com> I'm trying to learn python/Tkinter... I tried modifying the hello.py script that guido included in the 1.5.2 source. Here's what I was trying to do (to learn while tinkering...) Change the "Hello World" button a "Add Exit Button" that would put another button on the screen to allow exiting the program. Add the additional exit button... Here's the code: =========START OF CODE # Button test... import sys from Tkinter import * #main routine def main(): root=Tk() btnAddButton=Button(root) btnAddButton['text']='Add Exit Button' btnAddButton['command']=subAddButton(root) # See below btnAddButton.pack() #start mainloop root.mainloop def subAddButton(parent): btnExitButton=Button(parent) btnExitButton['text']='Exit Program' btnExitButton['command']=subExit #see below btnExitButton.pack() def subExit(): sys.exit(0) #execute the main routine main() ==========END OF CODE When I run this code, the exit button is already displayed. The "Add Exit Button" button seems to do nothing, I would have thought it would keep adding more exit buttons... I ran the code through the debugger and it looks like the "Exit" button gets drawn even before the "Add Exit Button" button gets drawn... Cany anybody enlighten me? Thanx... Sent via Deja.com http://www.deja.com/ Before you buy. From usenet-mm-yyyy at julesallen.com Wed Dec 29 22:24:06 1999 From: usenet-mm-yyyy at julesallen.com (Jules Allen) Date: Thu, 30 Dec 1999 03:24:06 GMT Subject: dump 8IPC question References: Message-ID: <386AD04C.6996D463@julesallen.com> Hello Will. Let me start by saying I admire your open cheapness (sort of like "open source" but costs less) :-) There is a $129 per night rate available: http://www.python.org/workshops/2000-01/hotel.html If I were you, I'd check out the B&B options. Have a look at the Arlington & Alexandria B&B network: http://www.aabbn.com/ Chances are you'll deal with a chap by the name of Les. He's dry as July in the desert and quite wonderful to deal with. Cheers, Jules Will Ware wrote: > 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 -- Put the current month and year in my address to reply via email. From timmuddletin at news.vex.net Fri Dec 10 19:39:15 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 11 Dec 1999 00:39:15 GMT Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <82o0to$6eq$1@serv1.iunet.it> Message-ID: <82s6fj$1e4e$1@news.tht.net> alex at magenta.com (Alex Martelli) wrote: >as Python scripts would mean any interested >users would have to install Python -- and, with My favorite recommendation... it's a little hacky, but works very well for me... can create 'stand alone' EXE package for WinXX... or various other neat little packages to distribute... http://starship.python.net/crew/gmcm/install.html >Python 1.5.2, on Windows98, I keep getting >strange crashes and blocks (with any of IDLE, Hmmm, no strange crashes or blocks here. That is, none that have not proven to be my own fault (besides of course the usual regular crashes microsoft bundles with their OS for us at no extra charge). (-: ... From tismer at appliedbiometrics.com Thu Dec 9 18:08:59 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Fri, 10 Dec 1999 00:08:59 +0100 Subject: FORTRAN (was Re: indentation) References: <65118AEEFF5AD3118E8300508B124877073CC6@webmail.altiris.com> <384EF139.91ACD637@bioreason.com> <38500A94.FB6EF7DE@be-research.ucsd.edu> Message-ID: <3850368B.F104F1D9@appliedbiometrics.com> While we are at it :-) Curtis Jensen wrote: > > Mitch Chapman wrote: > > > > Mike Steed wrote: > > > > From: aahz at netcom.com [mailto:aahz at netcom.com] > > > > ... > > > > 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. > > > > Thanks for making me feel like both an old man and a member of a > > 12-step program: I'm Mitch, I'm 35, and I used Fortran eight years ago. > > > > We once had a programmer who thought C was a dialect of Fortran. > > He wrote the second 1000+-line C function I'd ever seen. > > (The first was an interrupt service routine (!) from Ultrix, > > for the Vaxstation console device. Unfortunately, I've seen many > > examples since then.) > > > > -- > > Mitch > > I'm 22, I've been working on a 15+ year old legacy program in Fortran, > for the past six months. There is a another guy here who just turned 22 > and he has been working on this program for over a year and a half. > It's a huge Finite Element Modeling program. I ended up turning a 2000 > line Fortran function into 11000+ lines. We've shrunk it to 7000 now. > I'm not sure how many lines and files there are total, but it's probably > over 25000 lines. The entire program is currently a mix of C and > Fortran. We're mixing in Python now. We're planning on eventualy > converting the entire thing to C and Python. > You can visit our web page at: > http://cmrg.ucsd.edu/modelling/modelling.html I'm 43, and I learned FORTRAN IV right after Algol 64 in the late 70s. Can't remember if it was this, or an earlier Fortran version which had no dynamic variables but just statics? Well, this is now also possible in Python. With version 0.5 of my continuations module, you can do brain dead stuff like this: def rectest(n=3): this = continuation.current() k = this.update(n) if n: n=n-1 print n, k this.call(k+1) n=n+1 print n return return k >>> rectest() 2 3 1 4 0 5 1 2 3 >>> What that is?? That is a single incarnation of that function rectest(), and its current continuation is captured in "this", which in turn is a callable object by itself. The line "k = this-update.n" is the entry point into the running frame of rectest, at that place. k receives the current value of the expression. And I call this same bound frame recursively, by this.call(k+1). Why I tell this? Since the fast local variables are shared between all the incarnations of this frame, they appear as globals in this context, and so I think we are back in Fortran. Of course this was not my primary goal to write continuations. :) Last but not least it is some percent faster than the proper recursive formulation with a function. ciao - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF we're tired of banana software - shipped green, ripens at home From: Preston Landers Newsgroups: comp.lang.python Subject: Re: exchanging data btwn Python and lesser languages Date: Thu, 09 Dec 1999 22:53:42 GMT Organization: Deja.com - Before you buy. Lines: 24 Message-ID: <82pbtl$of4$1 at nnrp1.deja.com> References: <82jau6$e72$1 at nnrp1.deja.com> NNTP-Posting-Host: 205.238.143.132 To: Dom.Mitchell at palmerharvey.co.uk X-Article-Creation-Date: Thu Dec 09 22:53:42 1999 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt) X-Http-Proxy: 1.1 x41.deja.com:80 (Squid/1.1.22) for client 205.238.143.132 X-MyDeja-Info: XMYDJUIDprestonlanders Path: news!uunet!ffx.uu.net!newsfeed.mathworks.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail Xref: news comp.lang.python:78027 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 In article , Dominic Mitchell wrote: > 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. That is a pretty interesting idea. It's kinda cool, but unfortunately I was looking for a language independent way to do it. Thanks for the idea, though. > "vi has two modes the one in which it beeps and the one in which it doesnt." > -- Anon. Hilarious! -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From: Preston Landers Newsgroups: comp.lang.python Subject: Re: some random reflections of a "Python newbie": (1) books, and free sites Date: Thu, 09 Dec 1999 23:06:43 GMT Organization: Deja.com - Before you buy. Lines: 40 Message-ID: <82pcm0$p6t$1 at nnrp1.deja.com> References: <82o0to$6eq$1 at serv1.iunet.it> NNTP-Posting-Host: 205.238.143.132 To: alex at magenta.com X-Article-Creation-Date: Thu Dec 09 23:06:43 1999 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt) X-Http-Proxy: 1.1 x30.deja.com:80 (Squid/1.1.22) for client 205.238.143.132 X-MyDeja-Info: XMYDJUIDprestonlanders Path: news!uunet!ffx.uu.net!newsfeed.mathworks.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail Xref: news comp.lang.python:78030 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 In article <82o0to$6eq$1 at serv1.iunet.it>, "Alex Martelli" wrote: > 1. what put me off Python for so long? > Short answer: the book "Programming Python" did. "Programming Python" indeed sucks. I hear a revised edition is in the works, but don't hold your breath. Avoid this book like the plague. I'm sorry it put you off Python. No one needs a turgid, out of date rehash of the material on python.org. I recently aquired Beazley's "Essential Python Reference." I've been using it quite a bit over the last week, and I'll be posting a fuller review shortly. 2 cent review: it's pretty much a rehash of the material on python.org with a few little goodies that make it worthwhile for me. They say as much in the preface, so I'm not faulting anyone. It's not bad, but not compelling either. If you are on a tight budget, give it a miss, otherwise check it out. 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. ---Preston -- || Preston Landers || Sent via Deja.com http://www.deja.com/ Before you buy. From Gaetan_Corneau at baan.com Fri Dec 3 12:00:26 1999 From: Gaetan_Corneau at baan.com (Gaetan Corneau) Date: Fri, 3 Dec 1999 12:00:26 -0500 Subject: Using open() under Window 97 (French) Message-ID: <816010E2456BD111A48700805FBBE2EEFDF8B2@ex-quebec-u1.baan.com> Julien, C'est le message d'erreur ?mit quand "open" ne trouve pas le fichier. Si tu es sous UNIX, n'oublie pas que le r?pertoire courant n'est peut-?tre pas dans ton PATH. Dans un shell, peux-tu ?crire "vi sol.txt" ou bien dois-tu ?crire "vi ./sol.txt" pour charger ton fichier dans vi? Tu devrais donc ?crire: f=open('./sol.txt','r') Si ?a ne fonctionne toujours pas, essaie de sp?cifier le nom du fichier au complet. Bonne chance, ______________________________________________________ Gaetan Corneau Software Developer (Quality Assurance Team) 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" > -----Original Message----- > From: Julien Kahn [mailto:kahn at cena.dgac.fr] > Sent: Friday, December 03, 1999 11:44 AM > To: python-list at python.org > Subject: Using open() under Window 97 > > > 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 > > > > -- > http://www.python.org/mailman/listinfo/python-list > From mstenber at cc.Helsinki.FI Sat Dec 11 06:21:52 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 11 Dec 1999 13:21:52 +0200 Subject: Python and regexp efficiency.. again.. :) References: <38518D51.4A32C685@lemburg.com> Message-ID: "M.-A. Lemburg" writes: >> .. snipped my own comment > Hmm, have you tried mxTextTools ? As an example, the HTML parser > provided as example can easily handle 900kB HTML/sec. on a > K6/266 machine. Yes; but the tagging language seemed to be somewhat limited compared to regexps. Hmm, wonder if it's possible to write regexp->tag definition converter.. :) > There are some nice tools available to help build the needed > Tagging Tables. More infos are available on my Python Pages, > including pointers to those tools. Meta-language link didn't work and EBNF is bit too low-level for my liking - rewriting 150+ and growing rapidly definitions of "interesting" log lines in EBNF is not my idea of fun :P. Of course, I could just do some really ugly m4 hacking to do that, but I'd prefer to avoid that. -Markus -- I am no more or less human than any of my fellows. I can be possessed as easily by love as despair, by fear as by hatred. Yet it is my fate to fight forever and to possess peace but briefly, for I am the Champion Eternal, at once a defender of justice and it's destroyer. -Eternal Champion, volume II (by Michael Moorcock) From tbryan at python.net Fri Dec 3 20:16:16 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Fri, 03 Dec 1999 20:16:16 -0500 Subject: Tutorial for a NEWBIE References: Message-ID: <38486B60.FD8E97E4@python.net> Nasshi wrote: > > 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 http://members.xoom.com/alan_gauld/tutor/tutindex.htm or the tutorial at http://www.python.org/doc/ ---Tom From claird at starbase.neosoft.com Thu Dec 30 14:48:21 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 30 Dec 1999 19:48:21 GMT Subject: [OT] OpenSource Python Books? References: <84g70v$tcq$1@nnrp1.deja.com> Message-ID: In article <84g70v$tcq$1 at nnrp1.deja.com>, wrote: >Hello, > >I know this is off topic but I represent LinuxPorts.Com and I have been >approached by a printer to help them publish OpenSource books. What we >were wondering is if there is a desire for the Python documentation in >printed form? We would also include a CD with the Python binary Yes. Guido will probably be in touch with you to say that he's asked this every N megaseconds. >distributions on it and any extra Python software that we can. I'm a bit touchy about those words. While it might surprise an outsider to Python, there would be a GREAT difference in the quality of the product that results from these two sample processes: 1. LinuxPorts.Com workers copy Python- looking stuff from whichever Linux distribution looks most recent; and 2. A domain expert compiles a list of Pythonesque stuff that should be CD-ROMed, and reviews his selections with other Python heavyweights. > >We have also decided that if we print these books that we will be giving >a portion of the Gross profits back to the OpenSource community >and would like to know "who" that community is when it comes to >Python... The Python Consortium and Python Software Activity are the two canonical choices. I trust Guido will tell you that, too. > >Please go to http://www.linuxports.com/ and cast your vote for the >Python book if you are interested. My answers to your questions do not constitute an endorsement of your project. My allegiance is to Python; *Python: The complete reference* could be a benefit, but I'm not yet convinced. . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From nielsenjf at my-deja.com Mon Dec 27 18:53:19 1999 From: nielsenjf at my-deja.com (John Nielsen) Date: Mon, 27 Dec 1999 23:53:19 GMT Subject: newbie win32 stuff References: Message-ID: <848tpj$tdf$1@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 robin at alldunn.com Fri Dec 3 15:09:01 1999 From: robin at alldunn.com (Robin Dunn) Date: Fri, 3 Dec 1999 12:09:01 -0800 Subject: Using wxPython in Tkinter? References: <01bf3d92$45925240$1c41c3d1@Cyberus.cyberus.ca> Message-ID: <%rV14.1$773.262482@news.randori.com> > > Is it possible that both Tk and wx can co-exist in the same application > with both parts of the interface functioning as they should? > It hasn't been done yet and I doubt that it is possible. The trouble is that neither is happy when the other's mainloop is running. You might be able to get past this by running them in separate threads, but then you run into the problem of how do you make a Tkinter frame be the parent of a wxWindow... -- Robin Dunn Software Craftsman robin at AllDunn.com http://AllDunn.com/robin/ http://AllDunn.com/wxPython/ Check it out! From fredrik at pythonware.com Mon Dec 13 04:01:58 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 13 Dec 1999 10:01:58 +0100 Subject: Suitability of Python for a Big Application? References: <199912122056.VAA20573@dionysus.fw.cuci.nl> Message-ID: <005901bf4548$b752ec10$f29b12c2@secret.pythonware.com> Hans Nowak wrote: > The short answer: no. The long answer: It depends. I don't know > enough of regexen to tell you more, though. I do know that the re > library is kinda slow compared to Perl and the (older and deprecated) > regex library. an even longer answer: 're' has more initial call overhead than 'regex', but runs much faster. if you apply many small regular expressions to the same string, regex is faster. if you use more com- plicated regular expressions, or work with large strings, 're' can be much faster. $ python re_bench.py 0 5 50 250 1000 5000 25000 ----- ----- ----- ----- ----- ----- ----- ----- search for Python|Perl in Perl -> re 0.097 0.097 0.101 0.103 0.118 0.175 0.480 regex 0.007 0.007 0.009 0.020 0.059 0.271 1.320 search for (Python|Perl) in Perl -> re 0.110 0.104 0.111 0.115 0.125 0.184 0.559 regex 0.006 0.006 0.009 0.019 0.057 0.285 1.432 search for Python in Python -> re 0.107 0.097 0.105 0.102 0.118 0.175 0.511 regex 0.009 0.008 0.010 0.018 0.036 0.139 0.708 search for .*Python in Python -> re 0.102 0.108 0.119 0.183 0.400 1.545 7.284 regex 0.013 0.019 0.072 0.318 1.231 8.035 45.366 search for .*Python.* in Python -> re 0.103 0.108 0.119 0.184 0.418 1.685 8.378 regex 0.013 0.020 0.073 0.326 1.264 9.961 46.511 search for .*(Python) in Python -> re 0.108 0.107 0.134 0.240 0.637 2.765 13.395 regex 0.026 0.112 3.820 87.322 (skipped) search for .*P.*y.*t.*h.*o.*n.* in Python -> re 0.112 0.121 0.195 0.521 1.747 8.298 40.877 regex 0.026 0.048 0.248 1.148 4.550 24.720 (skipped) (the number above each column is the padding size; a junk string of that length is added to each side of the target string) and yes, this will most likely be fixed in 1.6... From neelk at brick.cswv.com Wed Dec 29 17:58:48 1999 From: neelk at brick.cswv.com (Neel Krishnaswami) Date: 29 Dec 1999 22:58:48 GMT Subject: obj in list and list ids the same References: <84a8k4$puq$1@nnrp1.deja.com> Message-ID: rdudfield at my-deja.com 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. This happens >when I am trying to copy a list of objects (sheets ) in the current object >into a object which is also in a list( not the same one). Then I try to copy >a object (shape) from a global list into a list inside a sheet object which >is inside a list in the node object. If the id()'s are the same, then you have managed to create a circular reference in your list. Eg: Python 1.5.2 (#8, May 12 1999, 17:46:31) [GCC 2.7.2.1] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> x = [] >>> x.append(x) # create a circular reference >>> id(x) 135060792 >>> id(x[0]) 135060792 Double-check your code to make sure that the list assignments can never reference themselves (unless that's what it's supposed to do, of course). Lots of can't-happen cases turn out to actually be possible when the code is run. :( Note that circular references can't be automatically garbage-collected under CPython -- only Viper and JPython can currently gc circular references. This isn't normally a problem unless you create a *lot* of circular garbage, or if the script will run for a long time (like as a daemon process). Neel From mccoyg at marinemwr.or.jp Sat Dec 25 00:14:06 1999 From: mccoyg at marinemwr.or.jp (Gregory A McCoy) Date: Sat, 25 Dec 1999 14:14:06 +0900 Subject: Tkinter documentation? Message-ID: <841k01$n16$1@news1.konnect.net> Hello, I am trying to locate any documentation on tkinter. 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? I would appreciate any pointers to docs that I am missing. Perhaps a small demonstration program, eh??? From joakim at login1.styx.net Mon Dec 27 08:45:28 1999 From: joakim at login1.styx.net (Joakim Ziegler) Date: 27 Dec 1999 13:45:28 GMT Subject: Basic extension questions. Message-ID: We develop a C utility library called Flux ( http://projects.simplemente.net/flux/ , used in, amongst other things, the Conglomerate document system, http://www.conglomerate.org/ ). Recently, we've been looking at making Python wrappers for Flux, which would allow us to embed Python and use it as a standard way of extending applications like Conglomerate. Python seems perfectly suited for this use. However, with my decent understanding of both Python and C, there are a few concepts I'm not sure I've picked up. Specifically, it has to do with how to define new objects in Python using C. Flux is buitl around a few core data structures which are used for everything, the main one being the token tree, reminiscent of a Lisp list. Now, the Python/C API reference manual seems to be unfinished on the exact spot I need, chapter 9, Defining new object types. I need to wrap a pointer to a token tree structure in a python object, and then add some methods to that object. 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? -- Joakim Ziegler - styx research director - joakim at styx.net FIX sysop - FIXmud admin - FIDEL & Conglomerate developer From alex at magenta.com Thu Dec 30 03:01:02 1999 From: alex at magenta.com (Alex Martelli) Date: Thu, 30 Dec 1999 09:01:02 +0100 Subject: random number generation: the newbie asks for advice References: <6D8A17398E28D3119F860090274DD7DB4B3D91@pces.cadlab.it> Message-ID: <005001bf529c$75a84100$c02b2bc1@martelli> Neel Krishnaswami writes: > 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 Thanks for the pointer -- it does seem just about what I needed, yes! > Unfortunately, I don't think it has a Python wrapper yet. It should be > easy to implement, though, since there's only a pair of very small C > functions to wrap. True -- there seem to be quite a few versions, with differences of detail (only a F90 version seems to implement persistence, although it would seem straightforward to add to the C ones too) -- so it will take a moment to select exactly what C functionality to wrap, but actually doing so would seem to be even within a newbie's compass of abilities (although packaging it in the standard Python way may well be beyond them -- we'll see:-). Tx again, Alex From andrew at starmedia.net Wed Dec 29 18:46:52 1999 From: andrew at starmedia.net (Andrew Csillag) Date: Wed, 29 Dec 1999 18:46:52 -0500 Subject: Before I go with python ... References: <385C20B4.87FACEED@esoterica.pt> Message-ID: <386A9D6C.29B5D541@starmedia.net> Paulo da Silva wrote: > > I'm considering to use python after reading > some docs about it. I have a doubt I couldn't > get responded until now. > Is it possible to have assynchronous I/O, > for example continuing a program while > another task is wainting on a socket? > > How is taht achieved? Multithread? Just > a call after the socket has data? > Your choice. Python can do threads, and if you are on Unix (maybe windows, but I don't know) you can also use the select module. With the select module you can say "let me know if 1) there is data ready for reading on a 'waitable object' (sockets, files, etc.) 2) a 'waitable object' is ready to be written to or 3) if there is out-of-band data on a socket". You can also set a timeout on the select so if you want to wait a certain amount of time (or indefinitely) for something to happen, you can, or you can have it return immediately. See http://www.python.org/doc/current/lib/module-select.html or the select(2) manpage for details. Cheers, Drew -- import string,sys;t=string;f=t.index;j=t.join;print(lambda s:j(map(lambda x,s=s:x[:f(x,':')+2]+j(map(lambda y:'%02X'%ord(y),x[f(x,':')+2:]),' '),map (lambda i,s=s:("%04X: "% i)+s[i:i+16],range(0,len(s),16))),'\n'))(open(sys. argv[1]).read()) From pinard at iro.umontreal.ca Tue Dec 7 14:29:51 1999 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 07 Dec 1999 14:29:51 -0500 Subject: tiny python In-Reply-To: Noel Burton-Krahn's message of "7 Dec 1999 17:44:30 -0000" References: <19991207174430.7096.qmail@burton-krahn.com> Message-ID: Noel Burton-Krahn writes: > I would like to make the smallest python interpreter possible. 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. :-) The precise rules for such a context might rather difficult to establish, however. If we need a big interpreter in some other language to run a Python interpreter in that language, we are not reaching the goal. We should consider the overall size of the thing. And more importantly, how do we define `Python'? We would also need a validation suite just to establish what Python means. > Is it possible to build a python interpreter which just reads byte code? To spare lexing/scanning sources? Contest rules should tell what input format is acceptable. It could be real sources, `.pyc' as produced by C Python, or maybe some other representation (like a Scheme-readable tree), but the representation could be chosen to convey part of the interpreter: I'm not sure where cheating would begin. Just thinking loud. Do not read this message :-) [Only now he says it?] -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From gstein at lyra.org Thu Dec 23 13:26:44 1999 From: gstein at lyra.org (Greg Stein) Date: Thu, 23 Dec 1999 10:26:44 -0800 (PST) Subject: Please test new dynamic load behavior In-Reply-To: <38620B04.7CC64485@trema.com> Message-ID: On Thu, 23 Dec 1999, Harri Pasanen wrote: > 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? 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 -- Greg Stein, http://www.lyra.org/ From paul at prescod.net Thu Dec 30 04:44:04 1999 From: paul at prescod.net (Paul Prescod) Date: Thu, 30 Dec 1999 04:44:04 -0500 Subject: Super Tuples References: <386A1037.C6D458B3@prescod.net> <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <84dh0i$17io$1@nntp6.u.washington.edu> Message-ID: <386B2964.DAEE01CA@prescod.net> Donn Cave wrote: > > ... > > What if the compiler could convert names to indices at compile time? For this to work you would probably need tuple pre-declaration to set up the namespace. Once you start pre-declaring you are basically into the world of object instances. Paul Prescod From fredrik at pythonware.com Wed Dec 1 04:17:07 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 1 Dec 1999 10:17:07 +0100 Subject: how to do *simple* syntax checking? References: <821nss$99v$1@nnrp1.deja.com> Message-ID: <00f401bf3bdc$d87cba80$f29b12c2@secret.pythonware.com> Preston Landers wrote: > I thought that Python's compile() function would be what I want, > because I thought that the SyntaxError exception was thrown when making > bytecode. But that's not the case, unless I was notably un-thorough in > my investigation. >>> compile(""" ... it's supposed to work ... maybe: ... you should try again? ... """, "", "exec") Traceback (innermost last): File "", line 1, in ? File "", line 2 it's supposed to work ^ SyntaxError: invalid token From fdrake at acm.org Thu Dec 23 15:13:22 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 23 Dec 1999 15:13:22 -0500 (EST) Subject: Patch: httplib.py default timeout In-Reply-To: <83tvef$h6u$1@nntp9.atl.mindspring.net> References: <83r0lh$mj6$1@nntp6.atl.mindspring.net> <83trp0$ubi$1@nntp8.atl.mindspring.net> <14434.30162.38117.637290@weyr.cnri.reston.va.us> <83tvef$h6u$1@nntp9.atl.mindspring.net> Message-ID: <14434.33378.436117.278484@weyr.cnri.reston.va.us> Aahz Maruch writes: > And I think you'd agree that httplib is the most common case for urllib. > > Is that clearer? Yes; I'd lost too much context (I've looked at C code this week ;). That makes a lot of sense, and I agree. (On the other hand, I'm also happy to let someone more interested in urllib/httplib do the work! ;) -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From gtcopeland at EarthLink.Net Thu Dec 16 20:22:19 1999 From: gtcopeland at EarthLink.Net (Greg Copeland) Date: Fri, 17 Dec 1999 01:22:19 +0000 Subject: python constructor overloading Message-ID: <3859904B.631359C8@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  From hnowak at cuci.nl Thu Dec 2 16:37:25 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Thu, 2 Dec 1999 22:37:25 +0100 Subject: SyntaxError: can't assign to function call win32com. Message-ID: <199912022139.WAA00632@dionysus.fw.cuci.nl> On 2 Dec 99, Hans Nowak wrote: > On 1 Dec 99, at 18:35, tiddlerdeja at my-deja.com wrote: > > > I'm trying to mirror this VB code (which works) with python code: > > > > objUser.DynamicProperty("BILLING_ADDRESS2") = "3 The Street" > > > > This code works in VB but in python I get the error: > > > > SyntaxError: can't assign to function call > > > > Can you tell me what syntax I need to use for python? > > > > Any help greatly appreciated. I don't want to have to use VB! Oops, I didn't see the 'call win32com.client' part in the message header. =/ I was assuming you wanted to mimick VB-like behavior in Python, rather than calling VB stuff from Python. Still, the idea applies (well, somewhat ;-)... you can try to write a wrapper class which uses a dictionary-like approach to assign to, and read from, properties. You'll need __getattr__ and __setattr__ for this though. Hmm... it's probably best to stick with the other reply I saw. ^_^ --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 ngps at madcap.dyn.ml.org Fri Dec 10 09:30:35 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 10 Dec 99 14:30:35 GMT Subject: X509 certificate References: <38502A0B.969E3BFD@hp.com> Message-ID: <38510e8b.0@news.cyberway.com.sg> According to Meera : > How can I extract certificate DN (distinguished name) and issuer DN from > a X.509 certificate in python ? Is the cert coming over SSL as part of handshaking, or are you reading it from a file or some other clear-text stream? If the former, your SSL library should have a way to let you extract said info from the SSL connection. (I think M2Crypto is quite close, (maybe my development version), but doesn't yet do it all.) If the latter, your crypto library should have a way to allow loading and parsing of said certificate, whether in PEM or DER format. (Ditto M2Crypto comment.) Now, if you were talking about PGP packets... ;-) -- Ng Pheng Siong * http://www.post1.com/home/ngps From jbauer at rubic.com Sat Dec 18 14:51:13 1999 From: jbauer at rubic.com (Jeff Bauer) Date: Sat, 18 Dec 1999 13:51:13 -0600 Subject: Script to add passwords References: Message-ID: <385BE5B1.80A48C80@rubic.com> Bruno, You may consider using Paul Sheer's python Expect module to perform this kind of task. His example even includes a script demonstrating how to set a Unix password. ftp.obsidian.co.za/pub/expect It does use interactive mode, but from your message I'm inferring your main concern is how to accomplish Unix password assignment via a cgi script. Jeff Bauer Rubicon Research > 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. From ivnowa at hvision.nl Sat Dec 4 16:19:29 1999 From: ivnowa at hvision.nl (Hans Nowak) Date: Sat, 4 Dec 1999 22:19:29 +0100 Subject: Tkinter question: image on canvas Message-ID: <199912042118.WAA05461@axil.hvision.nl> Howdy y'all, I have been trying to do something fairly straightforward in Tkinter, viz. putting an image on a canvas. This code, however, doesn't work: -----------begin code--------- from Tkinter import * class MemoryFrame (Frame): def __init__(self, master=None): Frame.__init__(self, master) self.createWidgets() def createWidgets(self): self.canvas = Canvas(self, width=400, height=400, background='white') self.canvas.pack(side=TOP) self.createImage() def createImage(self): img = PhotoImage(file="c:/001.gif") print img id = self.canvas.create_image(40, 40, image=img, anchor=NW) print id if __name__ == "__main__": mf = MemoryFrame() mf.pack() mf.mainloop() ----------end code--------------------- It doesn't raise any errors, but doesn't show the image either! I've checked if it's a valid image, I've checked if 'img' and 'id' print sensible values... everything seems normal except for what I see on the screen. I've tried to put other things (rectangles and such) on the canvas... works fine. The strange thing is, if I simply make a script which roughly does the following: root = Tk() canvas = Canvas(...) canvas.create_image(...) root.mainloop() then it does work. >_< Even stranger, the first approach worked in a different program... so I took that file, snipped some seemingly unrelated code, and ta-da! It didn't work anymore. I'm clueless. =( What am I missing? --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 s.schwarzer at ndh.net Sun Dec 26 12:47:48 1999 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Sun, 26 Dec 1999 18:47:48 +0100 Subject: "Message file not found" References: <3865594C.1AB35459@ndh.net> <87so0qt59f.fsf@baal.winnegan.de> Message-ID: <386654C4.1CC0CF02@ndh.net> Hi Siggy, thank you for your reply. Siggy Brentrup schrieb: > > 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 I would be glad, if only this would have been my mistake ;-) > 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 I tried that: Python 1.5.2 (#0, Jun 27 1999, 11:23:01) [VisualAge C/C++] on os2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import errno >>> try: ... open('spam','r') ... except IOError, x: ... if x.errno == errno.ENOENT: ... print 'Oops' ... else: raise ... Traceback (innermost last): File "", line 2, in ? IOError: [Errno 10] Message file not found.: 'spam' > btw: To get the symbol for an error number use: > > >>> errno.errorcode[2] > 'ENOENT' My errno.errorcode is >>> errno.errorcode {13: 'ENOMEM', 25: 'EMFILE', 24: 'EACCES', 23: 'ENOENT', 53: 'E2BIG', 52: 'EILSE Q', 16: 'EEXIST', 45: 'ENOSPC', 44: 'EXDEV', 43: 'EBADF', 38: 'EAGAIN', 37: 'ENO EXEC', 36: 'EINVAL', 35: 'EINTR', 34: 'ECHILD', 1: 'EDOM', 2: 'ERANGE'} 10 isn't even in the list (and ENOENT corresponds to 23). So I still think, here Python can't find the file with which the error codes are mapped to the full messages. Unfortunately, error 10 is issued "before" the "real" error, so it seems I have not even a workaround to determine the origin of a I/O failure? Stefan From b_michel at pacwan.frNOSPAM Wed Dec 8 11:08:36 1999 From: b_michel at pacwan.frNOSPAM (Bernard MICHEL) Date: Wed, 08 Dec 1999 17:08:36 +0100 Subject: Need RS232 PYTHON's library running on NT4.0 SP5 Message-ID: <384E8284.CDD90A1B@pacwan.frNOSPAM> Hi, all is in the title. Could you help me, thanks. -- Remove 'NOSPAM' before sending your answer, thank you ;-) From gerrit.holl at pobox.com Thu Dec 23 15:54:14 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Thu, 23 Dec 1999 21:54:14 +0100 Subject: When to use input()? In-Reply-To: ; from dworkin@ccs.neu.edu on Thu, Dec 23, 1999 at 11:08:16AM -0500 References: <19991222210125.A1195@stopcontact.palga.uucp> Message-ID: <19991223215414.B8069@stopcontact.palga.uucp> Justin Sheehy wrote: > 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. Why should it be? The only situation I can think of where it is what you want, is when writing a Python interpreter. Like idle does. When you actually *want* eval(raw_input()). > 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. Okay, non-dangerous, but it can lead to very unexspected results. > However, there are plenty of situations where input() is convenient, > useful and safe. Convenient? I can't think of a situation where it's convenient, except when writing a Python shell. Can you give another example? Useful? When? Only for arbitrary Python commands. And that's almost never. I think it's the least used builtin function. Safe, ok. regards, Gerrit. From wtopa at dmcom.net Sat Dec 11 16:19:18 1999 From: wtopa at dmcom.net (Wayne Topa) Date: Sat, 11 Dec 1999 16:19:18 -0500 Subject: Error confusing a newbie In-Reply-To: ; from Bernhard Herzog on Sat, Dec 11, 1999 at 08:08:22PM +0100 References: <19991210100320.B18389@dmcom.net> Message-ID: <19991211161917.C27756@dmcom.net> Subject: Re: Error confusing a newbie Date: Sat, Dec 11, 1999 at 08:08:22PM +0100 In reply to:Bernhard Herzog Quoting Bernhard Herzog(herzog at online.de): >| Wayne Topa writes: >| >| [...] >| > 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')' >| > >| > Here is the script >| > --------------------------------------------- >| > #!/usr/bin/env python >| > >| > import string,sys >| > from DateTime import * >| > >| > input = open('/var/log/totalppp', 'r') >| > times=input.readlines() >| > input.close() >| [snip rest of script] >| >| 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. No, as a matter of fact, I had 'not' noticed. As soon as I deleted the first blank line it worked! If you hadn't mentioned it I would not have found that. Line 7 was line 7 in vim and I let vim to do the counting. Darn, was that stupid of me!! Well I hope to never get burned by 'that' again. Many, many thanks to all who tried to find 'my' mistake. Bernhard, where do I send the cigars? Thank you!!! Tschuess Wayne -- Our OS who art in CPU, UNIX be thy name. Thy programs run, thy syscalls done, In kernel as it is in user! _______________________________________________________ From homunq at my-deja.com Fri Dec 17 19:57:06 1999 From: homunq at my-deja.com (homunq at my-deja.com) Date: Sat, 18 Dec 1999 00:57:06 GMT Subject: Stack overflow Message-ID: <83em51$krl$1@nnrp1.deja.com> 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. From thor at localhost.localdomain Thu Dec 30 09:19:41 1999 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 30 Dec 1999 14:19:41 GMT Subject: Problems With stringformating... URGEND References: <386c66fc.6336922@news.carinthia.com> Message-ID: On Thu, 30 Dec 1999 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 > >""" %emailrec, markt_alt, markt, markt, id As a side note, I'd never write such a big string. For debugging purposes it's "viel besser" something like: part_one = """ 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: """ part_two = """Genau diese Inserate k?nnen Sie unter folgender Adresse abrufen: """ + str(whatever) And so you can get the exact error easily. -- Manolo From johnm at magnet.com Mon Dec 6 11:30:24 1999 From: johnm at magnet.com (John Mitchell) Date: Mon, 6 Dec 1999 11:30:24 -0500 Subject: "%(a)s ... %(b)s" % {'a': foo, 'b': '%(b)s'}: SOLUTION In-Reply-To: Message-ID: On 5 Dec 1999, Michael Hudson wrote: > Gerrit Holl writes: > > > >>> s='%% sign, %%(email)s, %(version)s, %%%% sign' > > >>> s2=s % {'version': 1} > > >>> print s2 > > % sign, %(email)s, 1, %% sign > > >>> print s2 % {'email': 'gerrit at nl.linux.org'} > > {'email': 'gerrit at nl.linux.org'}ign, gerrit at nl.linux.org, 1, % sign Try this: from UserDict import UserDict class FormatDict(UserDict): default = '' def __getitem__(self, key): return self.data.get(key, self.default) d = FormatDict() d.update( {'name': 'John'} ) print 'You, %(name)s, rule.' % d # output: "You, John, rule." del d['name'] d.default = "MISSING" print 'You, %(name)s, rule.' % d # output: "You, MISSING, rule." This type of solution is also useful for combining multiple dictionaries into one, or other types of convenient trickery. - j It is difficult to produce a television documentary that is both incisive and probing when every twelve minutes one is interrupted by twelve dancing rabbits singing about toilet paper. --Rod Serling From skaller at maxtal.com.au Sat Dec 25 19:49:20 1999 From: skaller at maxtal.com.au (skaller) Date: Sun, 26 Dec 1999 11:49:20 +1100 Subject: "sins" (aka, acknowledged language problems) References: <6D8A17398E28D3119F860090274DD7DB4B3D51@pces.cadlab.it> Message-ID: <38656610.E4DA287B@maxtal.com.au> Alex Martelli wrote: > So, maybe I can move down a notch and try fishing > for Python things which at least "annoy" a "vast" > (carefully vague term:-) number of Pythonistas, > without compensating advantages to "many" others. > > 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!-) Available in Viper and JPython. > The type/class split has been mentioned (it does > not affect most people, it helps none, it hinders, > albeit slightly, most of those who are trying to > do certain advanced things). Available in Jpython. Unification via a different route in Viper. > Would this also apply, to a weaker but broader > extent, to the lack of assigning-operators, Available in Viper. [Story of how easy it was to implement a simply idea simply in python ..] > And YET... human nature being what it is... > I cannot help but keep staring at the result: :-) > 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! > OK, OK, this is no doubt the kind of thing > that can be classified as a very pet peeve, > rather than as a "deadly sin"!-). Actually, I disagree. I think this is a deadly sin. It manifests in python, where a lot of extraneous variables and statements are needed which actually make code harder to read because you need to read lots of simple bits and reason how they fit togther, insead of just 'seeing' it. > 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. > 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 > on an example such as these, such warts > as having to take 4 lines for such a very > common idiom may stand out sharply by > contrast, particularly since single-line > idioms for this sort of thing are so common > in languages otherwise far less powerful, > AND since Python itself would easily allow > a single-line idiom if the semantics was > a slightly different one of roughly similar > frequency. 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. Unfortunately, new control structures are easy to introduce, but we don't want to litter the language with TOO many. 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] .. or, worse, for i in len(seq): v = seq[i] or even: 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 'break' in python isn't labelled, and there is no goto, so you end up having to use exceptions ... Uggghhhh. 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. :-) -- 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 malraux at my-deja.com Mon Dec 20 10:04:35 1999 From: malraux at my-deja.com (malraux at my-deja.com) Date: Mon, 20 Dec 1999 15:04:35 GMT Subject: Question about map() and class methods Message-ID: <83lgi0$t$1@nnrp1.deja.com> Hi all, I was attempting to use a class method with map() the other day, and failed miserably. Basically, if I have a class foo: class foo: def bar(self): return(whatever) and I try to do this: x = map(foo.bar, someListOfFoos) The interpreter complains that foo.bar requires a class as its argument. Obviously, if it would only continue with the call, it would discover that yes, indeed, it has a whole list of them to chew on. I got around the problem by doing this: def mapFooBar(self): foo.bar(self) map(mapFooBar, someListOfFoos) Which of course works fine. What am I missing here? Thanks, -scott Sent via Deja.com http://www.deja.com/ Before you buy. From wtanksle at hawking.armored.net Wed Dec 22 14:56:41 1999 From: wtanksle at hawking.armored.net (William Tanksley) Date: 22 Dec 1999 19:56:41 GMT Subject: __rcall__??? References: <002101bf4a98$01eda860$922d153f@tim> <385E74B8.CC2CFFC8@math.okstate.edu> <5A7D006DE6BA7FF7.9D85F69C1855DCF4.4E8922E4E6A266A3@lp.airnews.net> <3861199C.316253C5@math.okstate.edu> Message-ID: On Wed, 22 Dec 1999 12:34:05 -0600, David C. Ullrich wrote: >Tres Seaver wrote: >> [...] >> * double dispatch >> selecting the method to be called based on the classes of both objects >> involved (as distinct from single dispatch, like a virtual function in >> C++, >> * multimethods (Lisp and derivatives) >> all arguments contribute to the selection algorithm. >> * Visitor >> a design pattern [1] used to implement double dispatch in languages >> which don't have multimethods as a native construct. >> [1] "design pattern" is the meme to use when searching: try hillside.net for >> starters > Thanks. (Searching on "LISP + Visitor" turned up fascinating stuff about >the Knights of the Lambda Calculus, Chaitin's Omega, etc, but I not what >I was looking for.) That's right -- Lisp doesn't need the Visitor pattern, because it has full multiple dispatch. You can find info about Visitors for almost any other language, but not Lisp. >DU -- -William "Billy" Tanksley, in hoc signo hack From thor at localhost.localdomain Sat Dec 25 10:08:37 1999 From: thor at localhost.localdomain (Manuel Gutierrez Algaba) Date: 25 Dec 1999 15:08:37 GMT Subject: [INSIST] Python ring Message-ID: Yeah, it exists and it can increase your web page visits, in fact, it does, come on, join us, it's easy and fun! The web page of it is: http://www.ctv.es/USERS/irmina/pythonring.html It's supported by webring. http://www.webring.com Happy Christmas -- Manolo From fdrake at acm.org Thu Dec 30 16:24:50 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 30 Dec 1999 16:24:50 -0500 (EST) Subject: [OT] OpenSource Python Books? In-Reply-To: <386BC2A4.628D9C9A@callware.com> References: <84g70v$tcq$1@nnrp1.deja.com> <386BC2A4.628D9C9A@callware.com> Message-ID: <14443.52642.848176.312416@weyr.cnri.reston.va.us> Ivan Van Laningham writes: > I was under the impression that the words "The toExcel Bookstore offers > printed copies of the Python Library Reference, Language Reference and > Tutorial. Royalties go to the PSA" on http://www.python.org/doc/ (the > documentation main page) meant that we already had, or could obtain, the > Python documentation in printed form. Perhaps LinuxPorts.com might be > adding value, but that's not clear from the note above. And, except for That's correct. Their product is a little out of date (by one documentation release), but that's not bad by print standards. I'm hoping to have some time (eventually) to determine just what's needed to be able to send an update that can be used easily by people interested in "publishing on demand" people (like toExcel/iUniverse). If we can get them to always print the latest release, *that* would be good. It's more a matter of determining what is needed and not just doing a bunch of work for a single publishers benefit. But I think it would be valuable to all Python users if you could always buy a copy of the latest release of the documentation in a nicely printed form. > there, too), higher math with Python, Astronomy with Python, Python & > Com, and on and on and on. ... I understand that calendrical calculations are big as well; is anyone planning to write a Python book on that topic? > As Cameron already pointed out, this is not a good plan. We already > have as much of this as we want with Redhat's distros, etc. 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). > -ly > y'rs, > Ivan (and I'll have a lot of customers, too);-) Add "humbug!" and you'll have another! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From aahz at netcom.com Fri Dec 31 10:49:52 1999 From: aahz at netcom.com (Aahz Maruch) Date: 31 Dec 1999 15:49:52 GMT Subject: Error in inserting blob into ORACLE using ODBC.Windows References: <386c0577.107657473@news.phoenix.com> <386CD167.8525C821@roguewave.com> Message-ID: <84ijb0$u46$1@nntp8.atl.mindspring.net> In article <386CD167.8525C821 at roguewave.com>, Bjorn Pettersen wrote: > >For the second error, you probably want to open your icon file in binary mode, >i.e. f=open(icon_path, 'r+b') (or is that 'rb', I forget...) That's a good point, but it shouldn't cause the error -- after all, Oracle doesn't know what kind of binary this is. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Eighth Virtual Anniversary -- today! From rdudfield at my-deja.com Tue Dec 28 12:22:05 1999 From: rdudfield at my-deja.com (rdudfield at my-deja.com) Date: Tue, 28 Dec 1999 17:22:05 GMT Subject: obj in list and list ids the same References: <84a8k4$puq$1@nnrp1.deja.com> Message-ID: <84ar5o$6n4$1@nnrp1.deja.com> In article , Laurence Tratt wrote: > In message <84a8k4$puq$1 at nnrp1.deja.com> > rdudfield at my-deja.com wrote: > > > 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(). > > If you're using CPython, then this is *very* unlikely (I can't speak for the > other implementations); id() returns the memory address of a given object > and unless malloc or something has gone wrong then id() will always return > unique numbers for different objects[0]. > > So if you've genuinely got a list with something inside the list with the > same id, you've probably append'ed your list into itself. > > Laurie > > [0] With the - obvious, given the implementation - caveat that objects with > different lifetimes may have the same id Forgot to mention, I'm using python 1.5.2 on linux 2.2.12, on a cyrix 266, and a celron system, same problems on both. I don't know about the lifetime problem, but I'm not appending the list into itself, the object in there is a instance of a shape object. Could the problem be with copy.copy maybe? The library reference docs don't sound to reassuring. I might try moving the method out of the object into a function. But that will take a while, and should use up heaps more memory :( Thanks for your reply. Sent via Deja.com http://www.deja.com/ Before you buy. From python at teleo.net Fri Dec 24 18:24:55 1999 From: python at teleo.net (Patrick Phalen) Date: Fri, 24 Dec 1999 15:24:55 -0800 Subject: Looking for Zope/Python suggestions In-Reply-To: References: Message-ID: <99122415342200.01314@quadra.teleo.net> [Nick Henderson, on Fri, 24 Dec 1999] :: Hello, :: :: I am new to python and zope. I want to make a dynamic data-base oriented :: website. I am wondering where I should start. Should I learn python first? :: I've already ordered "Learning Python." Then go on to zope? You don't need to know any Python to get started with Zope, but it will help you as you seek to do more sophisticated things. Zope features a reporting language, DTML, which is easy to learn and quite powerful. :: Also, I have been looking into Zope lately and have had some problems (the :: main one is that I do not know python :). What is the best way to deal with :: data in Zope. Is it better to use persistent data in the ZODB or connect to :: a relational database? And what is easier to learn? ZODB is easy to use, but whether you need to also work with a RDBMS will be determined by the nature of your data. ZODB is consistent with the heterogeneous data found in typical Web content. If your data will be highly structured, then you may want to also use a RDBMS. :: I must sound really silly asking these questions, but I'd really appreciate :: any help. Not silly at all. I'd recommend you subscribe to the Zope mailing list via www.zope.org. People there are more familiar with Zope specifics. From python-list at teleo.net Mon Dec 27 15:06:00 1999 From: python-list at teleo.net (Patrick Phalen) Date: Mon, 27 Dec 1999 12:06:00 -0800 Subject: Scalability Research (Was Re: Python suitability) In-Reply-To: <1e9c01bf509d$6a76a070$0100a8c0@rochester.rr.com> References: <38549DEA.B0157D0@iqsoft.hu> <38664525.1D26C3D4@maxtal.com.au> <1e9c01bf509d$6a76a070$0100a8c0@rochester.rr.com> Message-ID: <99122712553106.01988@quadra.teleo.net> [Darrell, on Mon, 27 Dec 1999] :: 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. The subject of Python suitabililty for large projects seems to come up more frequently of late. Prior to Developer's Day 1998, Jim Fulton floated a pre-proposal for Python "interfaces" (aka Scarecrow), which stimulated heavy initial discussion on the types-sig. Why the types-sig? Probably simply because that's where the Grand Masters were hanging out. In any case, earlier this month, GvR slapped every body around on that sig for not posting and threatened to dissolve it. Tim complained that Guido was actually at fault, because, like Joyce's God, he was off paring his fingernails and not participating in and validating the discussions. Jim Fulton (rightly, IMO) pointed out that momentum had tended to waver, due to the tripartite nature of the threads: * 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? Quoting the back cover of _Learning Python_: "Python is an object-oriented language for writing standalone programs, quick scripts, and prototypes of complex applications." This is, undoubtedly, a succinct, accurate depiction of Guido's original intentions for the language. The problem is that he designed such an attractive little prototyping language that an increasing number of people are calling on it to do considerably more. In his latest Regular Expressions, Cameron Laird predicts that Zope and HP's e-speak will be killer apps for Python and that Python may achieve critical mass next year. Sounds right to me. The question then is, shouldn't IPC8 be a time to address these issues and summarize them for us plebes? Managing large-scale development isn't easy in any language and much research effort goes into evolving new ways of grappling with the problems. I wouldn't like to think that thinking and research into making Python safe for the large-scale project world was losing momentum. From prestonlanders at my-deja.com Mon Dec 20 16:47:45 1999 From: prestonlanders at my-deja.com (Preston Landers) Date: Mon, 20 Dec 1999 21:47:45 GMT Subject: Equivalent to (a ? b : c) ? References: <83lgkq$2q$1@nnrp1.deja.com> Message-ID: <83m860$i1k$1@nnrp1.deja.com> In article <83lgkq$2q$1 at nnrp1.deja.com>, malraux at my-deja.com wrote: > 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? Hey, Please correct me if I'm wrong, but there is no ternary conditional operator in Python. It would be kinda nice, but it's just syntactic sugar. Of course, there's nothing wrong with: if a: b else: c Though this works too: a and c or b cheers, ---Preston Sent via Deja.com http://www.deja.com/ Before you buy. From infotechsys at pivot.net Wed Dec 15 22:37:16 1999 From: infotechsys at pivot.net (Wayne) Date: Wed, 15 Dec 1999 22:37:16 -0500 Subject: Packer Message-ID: <38585E6C.E286051B@pivot.net> Hello, I'm have a screen layout that looks like this. Well, I want it to look like this! Name of the window item 1 item 2 item 3 item 4 item 5 item 6 __________________ item 7 item 8 item 9 item 10 item 11 item 12 I tried using the various option with pack, but I haven't had any luck. My next coarse of action will be to build frames and dump these slaves into the frames and then use packer to layout the frame. Is this the best way of doing this or can I use packer to layout the slaves in the master? By the way each item is a checkbutton. TIA. Wayne From tbryan at python.net Sat Dec 4 11:11:38 1999 From: tbryan at python.net (Thomas A. Bryan) Date: Sat, 04 Dec 1999 11:11:38 -0500 Subject: Tutorial for a NEWBIE References: <5650A1190E4FD111BC7E0000F8034D26A0F187@huina.oceanic.com> Message-ID: <38493D3A.8E9F8736@python.net> Doug Stanfield wrote: > > I just checked and found no 4.92. I'd also suggest this FAQ should be in > the "1.General Info" section. Strange. Perhaps the main FAQ page is generated and saved every evening so that the FAQ Wizard doesn't have to generate it on demand every time. If you go to the FAQ Wizard page, then you'll see it. I also added the question to section 1, where it belongs. I wish that it were possible to delete FAQ Wizard entries. I'll have to look at how it's implemented some day and see whether such a thing is feasible. ---Tom From emuller at painewebber.com Wed Dec 15 09:09:44 1999 From: emuller at painewebber.com (emuller at painewebber.com) Date: Wed, 15 Dec 1999 14:09:44 GMT Subject: win32ver module References: <833pct$r5b$1@nnrp1.deja.com> <3855E63B.54E2@creo.com> Message-ID: <8387f4$kk$1@nnrp1.deja.com> In article <3855E63B.54E2 at creo.com>, dnagata at creo.com wrote: > 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... Is the windll module stable? > > -- > 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/ > Sent via Deja.com http://www.deja.com/ Before you buy. From jblack at one.net Mon Dec 6 17:28:26 1999 From: jblack at one.net (Jeremy Black) Date: Mon, 6 Dec 1999 17:28:26 -0500 Subject: C++ calling a Python extension module Message-ID: <384c396b_1@news2.one.net> Is there a limitation or bug in the NT version of Python that disallows importing python extension modules from C++? I am having difficulty importing a python module from C++ that imports a python extension module written in C. The code (listed below) fails on the very last line where it calls PyImport_ImportModule and returns NULL. Note that PyImport_ImportModule ONLY fails if the module that I am attempting to import is dependent on an extension module written in C. i.e. If I take my JPBFile.py module and remove the statement that imports the extension module, PyImport_ImportModule works fine. In my case my extension module is a pyd file. The extension module has been tested and works fine if used from a Python script. As a test, I changed the last line to import "Tkinter" which (you guessed it) also fails since it is dependent on the _tkinter.pyd file. I am running all these tests on Windows NT using VC++ v5.0. The python interpreter installed is v1.5.2. Here is the code that I am using: // Initialize python if necessary if (!Py_IsInitialized()) Py_Initialize(); // Import the python module PyObject* filemodule; const char* homeDir = getenv ("JPB_HOME"); if (homeDir) { // Just in case the JPB_HOME is not already in the python module source // path, add it and then import the module. PyRun_SimpleString("import sys"); char buffer[200]; sprintf(buffer, "sys.path.append('%s')", homeDir); PyRun_SimpleString(buffer); filemodule = PyImport_ImportModule ("JPBFile"); Thanks! Jeremy Black jblack at one.net From cjc26 at nospam.cornell.edu Thu Dec 30 22:01:57 1999 From: cjc26 at nospam.cornell.edu (Cliff Crawford) Date: 31 Dec 1999 03:01:57 GMT Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <386A1037.C6D458B3@prescod.net> Message-ID: <84h6b5$da1$1@news01.cit.cornell.edu> Pada 30 Dec 1999 15:49:45 +0100, Magnus L. Hetland bilang: | | I guess these things in Python have a lot to do with the underlying | C-implementation, since tuples in many circumstances are quite | efficient, and one-element tuples may be used to be consistent | sometimes. I thought that lists and tuples had the same underlying implementation (C arrays). The only difference is that lists are mutable while tuples aren't. Actually, this has always bugged me--you'd think that "lists" would be similar to lists in Lisp (i.e. constant time insertions and deletions), but they're not. It seems to me it would make more sense to implement mutable sequences using a linked list rather than an array. -- cliff crawford http://www.people.cornell.edu/pages/cjc26/ -><- "You and your stupid orthography" -- Mark From gregm at iname.com Thu Dec 9 07:23:42 1999 From: gregm at iname.com (Greg McFarlane) Date: Thu, 9 Dec 1999 23:23:42 +1100 Subject: Class definition example question In-Reply-To: ; from Grant Edwards on 07 Dec 1999 at 07:53:37PM References: Message-ID: <19991209232342.51448@nms.otc.telstra.com.au> I think you could turn stdoutHandler() into a normal (private) method and then pass it into createfilehandler, like this: class execWindow(Pmw.ScrolledText): def run(self,progPath): ... Tkinter.tkinter.createfilehandler(self.__child.fromchild, Tkinter.tkinter.READABLE, self._stdoutHandler) def _stdoutHandler(self, file, mask): ... Or am I missing something? On 7 Dec, Grant Edwards wrote: > [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 > -- > http://www.python.org/mailman/listinfo/python-list > -- Greg McFarlane INMS Telstra Australia gregm at iname.com From edcjones at erols.com Wed Dec 22 13:50:31 1999 From: edcjones at erols.com (Edward C. Jones) Date: Wed, 22 Dec 1999 13:50:31 -0500 Subject: Sorting large files Message-ID: <38611D77.68DFD3C0@erols.com> A Python program of mine generates a large number of tuples of ten integers each. I need to sort this collection of tuples. If there weren't so many tuples, I could make a Python list of these tuples and use sort(). Currently I write the tuples out to a file in ASCII and use the UNIX sort command. Is there a faster way to sort these tuples? Sort them in blocks using Python then merge using the UNIX sort? Are there any faster sort programs (perhaps in database systems)? From kc5tja at garnet.armored.net Fri Dec 17 00:25:18 1999 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 17 Dec 1999 05:25:18 GMT Subject: Generic COM for Linux References: <83b5lq$5tr$1@nnrp1.deja.com> Message-ID: In article , Mark Hammond wrote: >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. Speaking of bugs... ;) I've just completed the GCOM website. Mark, if you can take the time to review the website and its contents, I'd appreciate any comments you may have. I also posted my work in progress of GCOM to the site. http://www.armored.net/gcom/ GCOM has trouble building on many Linux boxes because I've not a clue as to how to use libtool. I've downloaded the package, and tried using it, but it just failed miserably. Maybe someone else on this newsgroup can help out in that area? See the website for more details. :-) -- KC5TJA/6, DM13, QRP-L #1447 Samuel A. Falvo II Oceanside, CA From aahz at netcom.com Wed Dec 29 21:23:55 1999 From: aahz at netcom.com (Aahz Maruch) Date: 30 Dec 1999 02:23:55 GMT Subject: pull data from a web page as text References: <84ecvh$mh2$1@nnrp1.deja.com> Message-ID: <84efnr$rgl$1@nntp9.atl.mindspring.net> In article <84ecvh$mh2$1 at nnrp1.deja.com>, wrote: > >Is there a way in python to pull data from a web page as text. A method >that would exclude html code and bring back text? Use urllib and htmllib. You'll probably have to subclass HTMLParser() to completely get rid of tags. -- --- 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 jeremy at cnri.reston.va.us Mon Dec 20 13:29:51 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Mon, 20 Dec 1999 13:29:51 -0500 (EST) Subject: Question about map() and class methods In-Reply-To: <83lgi0$t$1@nnrp1.deja.com> References: <83lgi0$t$1@nnrp1.deja.com> Message-ID: <14430.30111.838643.643070@goon.cnri.reston.va.us> >>>>> "S" == Scott writes: S> Basically, if I have a class foo: S> class foo: S> def bar(self): S> return(whatever) S> and I try to do this: S> x = map(foo.bar, someListOfFoos) S> The interpreter complains that foo.bar requires a class as its S> argument. Obviously, if it would only continue with the call, it S> would discover that yes, indeed, it has a whole list of them to S> chew on. I expect that "someListOfFoos" is actually a list containing something other than foos. I ran your code (with a couple trivial tweaks) and it worked without exception: >>> class foo: ... def bar(self): ... return(whatever) ... >>> whatever = 12 >>> x = map(foo.bar, [foo(), foo(), foo()]) >>> x [12, 12, 12] If one of the elements of the list isn't an instance of class foo, then you'll get the error you reported. The obvious way to figure out what is going on is: someListOfFoos = [foo(), 12, foo()] for elt in someListOfFoos: try: foo.bar(elt) except TypeError, msg: print "bad foo: %s: %s" % (elt, msg) Jeremy From m.faassen at vet.uu.nl Thu Dec 2 16:28:28 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 Dec 1999 21:28:28 GMT 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: <826o9s$h4k$9@newshost.accu.uu.nl> 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. Hah, but this year it looks I'm going to be there! Not that I've missed that many conferences, I only discovered Python a few months before the last one. :) Perhaps I can write up a report or something.. Not that I'm good at keeping notes! >> 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. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From aa8vb at yahoo.com Mon Dec 13 13:14:28 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Mon, 13 Dec 1999 13:14:28 -0500 Subject: wxPython on IRIX - Build Tips Message-ID: <19991213131428.A93568@vislab.epa.gov> After seeing yet another interesting tool written to wxPython (the Pixie XML tree editor), I decided to try building wxPython on SGI IRIX again. Success. Attached is a script that does the work, avoiding the gotchas that I bumped into. Set the variables at the top of the script and in the 'build.local' config file section, build wxWindows, and then run the script to build and install wxPython. -- Randall Hopper aa8vb at yahoo.com -------------- next part -------------- A non-text attachment was scrubbed... Name: wxPython.BUILD.sh Type: application/x-sh Size: 3235 bytes Desc: not available URL: From tescoil at rtpro.net Sat Dec 25 22:03:02 1999 From: tescoil at rtpro.net (Tesla Coil) Date: Sat, 25 Dec 1999 21:03:02 -0600 Subject: Anyone else making music with python? References: <386115AB.A0DD3F6@angelfire.com> <01bf4e90$25820b80$053abcc3@brancusi.pro-net.co.uk> Message-ID: <38658566.A1BAF806@rtpro.net> On 25 Dec 1999, Jason Cunliffe replied to Paul Winkler: > 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... > > I've been working on a module to help me do exactly that. > [...] > 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. >> >> No not crazy at all - it is a shame that there is so little >> media or art being done in Python. It could easily become artists' language of choice. Insofar as the discovery is a bit delayed, I believe many incorrectly anticipate disappointments they've encountered exploring other languages. A little advocacy directed toward artists, it mostly just needs brought to their attention (and Paul, ya *gotta* announce pysco on the Linart list). Also important that it sees more demonstration as an extension scripting language with graphics apps like Sketch, newly moved to http://sketch.sourceforge.net and Gimp-Python, found at http://www.daa.com.au/~james/pygimp/. My platform is showing...any apps for others using Python thusly? From news at dorb.com Wed Dec 8 09:31:53 1999 From: news at dorb.com (Darrell) Date: Wed, 8 Dec 1999 09:31:53 -0500 Subject: Converting a Shell Script to run under Python References: Message-ID: They are automagically closed, but I would hesitate before copying that 1Gig file. -- --Darrell "Mikael Olofsson" wrote in message > I've always thought that I should close my files when I'm done. I can't > see how that should/could be done using this paradigm. What if I want to > reaccess any of the files? Doesn't that cause problems? Or will the files > be automagically closed since I haven't bound them to any variable? > From markus.oberhumer at jk.uni-linz.ac.at Tue Dec 21 19:58:59 1999 From: markus.oberhumer at jk.uni-linz.ac.at (Markus F.X.J. Oberhumer) Date: Wed, 22 Dec 1999 01:58:59 +0100 Subject: [ANNOUNCE] PySol 3.10 - a solitaire game collection Message-ID: <19991222015859.A9045@laetitia.oberhumer.com> -----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----- From bhoel at server.python.net Sat Dec 11 06:56:27 1999 From: bhoel at server.python.net (Berthold =?iso-8859-1?q?H=F6llmann?=) Date: 11 Dec 1999 12:56:27 +0100 Subject: How to get C and python functions into the same namespace? In-Reply-To: Wojciech Zabolotny's message of "Sat, 11 Dec 1999 12:09:33 +0100" References: Message-ID: Wojciech Zabolotny writes: > Hi All, > > I'm preparing a python extension module which is partially implemented as > in "C" (cmymodule.c), and partially in python (mymodule.py). > I'd like to have functions defined in both files in the same namespace. > Let's assume, that the functions are defined as follows: > cmymodule.c: > open, read, write, close > mymodule.py: > info, encrypt > > If I import both extensions into the user program, the functions should be > called as cmy.open(), cmy.read(),... but my.info(), my.encrypt(). > If I include the "import cmy" into mymodule.py, then syntax will be even > worse: my.cmy.open() and so on. > Due to performace reasons I don't want to add the python "wrappers" > in mymodule.py for C functions. > > How can I locate both C and python functions in the same namespace? > Please Cc the answer to my e-mail (given below). Hello, How about using: from cmymodule import open, read, write, close or from cmymodule import * in mymodule.py, or in mymodule writing: import cmymodule open = cmymodule.open read = cmymodule.read write = cmymodule.write close = cmymodule.close Cheers Berthold -- bhoel at starship.python.net / http://starship.python.net/crew/bhoel/ It is unlawful to use this email address for unsolicited ads (USC Title 47 Sec.227). I will assess a US$500 charge for reviewing and deleting each unsolicited ad. From s323140 at student.uq.edu.au Tue Dec 21 11:14:52 1999 From: s323140 at student.uq.edu.au (Rob Hodges) Date: 22 Dec 1999 02:14:52 +1000 Subject: Equivalent to (a ? b : c) ? References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> <83lnq7$c9d$1@news1.tele.dk> Message-ID: Justin Sheehy writes: > "Jesper Hertel" writes: > > > > ((a and (b,)) or (c,))[0] > > > I hope this was a joke. That kind of constructions is impossible to read for > > other programmers, making the program hard to maintain. (Perl anyone?) But really, I think it's a bit much to ask for a readable version of ?: since the original construct is itself a bit of a disaster for readability IMO... Someone mentioned that this is idiomatic Python, but actually it is idiomatic lisp. So if the other programmers you mention happen to be lisp programmers, they'll recognise it right off the bat! And in truth, if they are Python programmers with any significant experience, they will too... which I guess is what idiomatic means -- an idiocy so common that recognising it quickly becomes automatic. (Thereby making it seem less of an idiocy.) > > I like maxm's function much better, because you can easily understand what > > the meaning is. Or at least, you can understand the intention... ;) Out of curiosity, is there any advantage to using singleton tuples rather than lists? And is there any advantage in using the seemingly-redundant parens? Is not (a and [b] or [c])[0] exactly equivalent to the above snippet? Or is there a speed disadvantage or obscure special case to shoot me down? I just dislike singleton tuples; they look awkward... and the mix of bracket styles would, in spite of what I already said, help readability when function calls were involved -- ie, out of ((parrot(x) and (parrot(y),)) or (parrot(z),))[0] (parrot(x) and (parrot(y),) or (parrot(z),))[0] (parrot(x) and [parrot(y)] or [parrot(z)])[0] mentally matching the brackets gets easier as you go down. Provided you actually know the precedence rules, you can mentally treat the `and' as binding its arguments together -- which is easier than scanning across looking for a paren that matches. -Rob From anders.eriksson at morateknikutveckling.se Tue Dec 21 06:20:35 1999 From: anders.eriksson at morateknikutveckling.se (Anders M Eriksson) Date: Tue, 21 Dec 1999 12:20:35 +0100 Subject: PYTHONPATH Message-ID: <9mBfONcXjnSNEDSMbOcLzJW8BG+Q@4ax.com> Hello! I'm a beginner 'Pythonneer' and I'm trying to get Python to work on my Internet account. The ISP has installed Python 1.5.1 so the 'core' is there and I've got it working but now I want to use HTMLgen to create some html pages. Since the ISP hasn't installed HTMLgen I did on my local account but I dont know how to change/create PYTHONPATH! Can I change it in my script (???.py) or is there a unix command (Solaris 5.6) to set it. I think that I preferred if it would be possible to set it in the script. Then I could set it to just the directories that this script needs. This could however be very stupid, so please advice! // Anders From thantos at chancel.org Wed Dec 22 05:51:39 1999 From: thantos at chancel.org (Alexander Williams) Date: Wed, 22 Dec 1999 10:51:39 GMT Subject: List comprehensions References: Message-ID: On 22 Dec 1999 10:28:52 GMT, Albert Hofkamp wrote: >If it is that easy to construct a list of tuples, then I'd think to drop >parallel iteration if only to prevent cluttering of the semantics of the >list comprehension. The ease of constructing lists of tuples (and the ambiguity of parallel constructions /within/ List Comprehensions) help explain why Haskell, certainly one of the reigning princess of List Comprehension, has the zip() function which operates exactly like map(None) in Python. >>> [ x>6, x>5 ] >>> >>Easy, a two element list consisting of two Boolean values dependent on >>whether or not the pre-defined value x makes said statement true. :) > >ROFL ! > >Does this lead to the conclusion that there are some syntactical >problems with list comprehension ? Not really. Its exactly the same answer you get in Python /without/ LCs. Keep in mind, the > and < operators are Boolean and return 0 or 1 based on whether the truth value is true or false (in Haskell, one has pre-defined Boolean True and False instead. What you have above, properly, isn't an LC at all but simple list /construction/, creating a two element list from the results of executing the two tests. Interestingly, it does /exactly/ the same thing in Haskell. More properly, you don't have an LC /until/ (given the syntax we've been using) you have the [ | ] construct, the 'extraction bar' being absolutely necessary to distinguish simple construction from LC. > i := 30 > ys := [ 4 ] > xs := [ i ] + [ i+15, for i in ys ] + [ i+1 ] > >is well-defined. >I'd like to have xs == [ 30, 19, 31 ] at the end, but I am too new to >Python to say anything useful about scoping. >Is this what you'd expect, and is it feasible ? Certainly; I don't expect scoping in the LCs will be much of an issue. The above mock-up should be completely defined under present scoping rules. -- 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 michael.stroeder at inka.de Wed Dec 1 06:15:35 1999 From: michael.stroeder at inka.de (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 01 Dec 1999 12:15:35 +0100 Subject: Looking for sshlib.py References: Message-ID: <38450357.67DE1BEE@inka.de> John Leach wrote: > > Is there an ssh lib for Python. Or anything similar. I'm looking for > something more secure than telnet. You might wanna use ssh's port-forwarding mechanism. There's also a SSL module based on OpenSSL (http://www.openssl.org/) for Python called M2Crypto. You could protect your telnet by a SSL wrapper and use M2Crypto for connecting to the service. Ciao, Michael. From andrew at andrewcooke.free-online.co.uk Thu Dec 16 11:57:45 1999 From: andrew at andrewcooke.free-online.co.uk (Andrew Cooke) Date: Thu, 16 Dec 1999 16:57:45 GMT Subject: Announce: Pyxie - an Open Source XML Processing Library for Python References: <3854711d.4263700@news.iol.ie> Message-ID: <83b5m7$5tv$1@nnrp1.deja.com> In article <3854711d.4263700 at news.iol.ie>, digitome at iol.ie (Sean Mc Grath) wrote: > 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. 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! Thanks, Andrew Sent via Deja.com http://www.deja.com/ Before you buy. From gmcm at hypernet.com Tue Dec 14 11:47:56 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: 14 Dec 1999 10:47:56 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Dec 14) Message-ID: <1E147F0B88DF93D5.02C3A41A15A03EB7.F18D660F4BAA998B@lp.airnews.net> David Beazley announces that bugs found in his "Python Essential Reference" (New Riders) can earn $20 for the PSA: http://www.deja.com/getdoc.xp?AN=557827647 Irmen de Jong announces PYRO version 0.7 - a Python-only distributed object system (reminiscent of Java's RMI): http://www.deja.com/getdoc.xp?AN=558940469 Math freaks may get turned on by Robert Harrison's Python interface to the C Global Arrays library (parallel processing and all that good stuff): http://www.deja.com/getdoc.xp?AN=558940468 Christian Scholz releases version 0.1 of his davserver: http://www.deja.com/getdoc.xp?AN=558937851 Tim Peters posts some code for generating combinations (demonstrating once again that a "simple" problem isn't simple): http://www.deja.com/[ST_rn=ps]/getdoc.xp?AN=558836665 A number of posts seen on the newsgroup and through the mail / news gateway have not appeared on Deja news. Among these was the announcement by Paul Magwene that DISLIN (a multiplatform plotting package) now comes with a Python interface (pxDislin) on certain platforms. See the DISLIN page for more info: http://www.linmpi.mpg.de/dislin/ ======================================================================== 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 aahz at netcom.com Sat Dec 25 23:40:59 1999 From: aahz at netcom.com (Aahz Maruch) Date: 26 Dec 1999 04:40:59 GMT Subject: Python newbie References: <38549DEA.B0157D0@iqsoft.hu> <113901bf470c$cb236f60$0100a8c0@rochester.rr.com> <38654F5C.378F8338@maxtal.com.au> <002601bf4f42$58e98cc0$49294b0c@amd> Message-ID: <84468r$9v6$1@nntp1.atl.mindspring.net> In article <002601bf4f42$58e98cc0$49294b0c at amd>, John Ratcliff wrote: > >Is it easy to build a version of the source that contains *only* the byte >code interpreter, and not the run time parser and compiler? Much of the >Python stuff seems geared towards the interactive command line interface, >which is nice if that's what you need, but I want to use the standard model >of compile source to byte code, and then run only that byte code in my >virtual machine. While it's possible to set things up so that you only use the .pyc files, you can't remove the parser from Python. At best, you can only only remove standard Python modules that you don't need (e.g. httplib if you're not doing HTTP connections). >Is Python virtually linked? How does it resolve links between various >python object modules? At run time? Essentially, though "link" is a misnomer for what happens in Python. You generally have to explicitly import Python modules/packages in each module that uses them (which makes up for a lot of the problem with lack of static typing, IMO). >When you create a variable in Python how is it typed? Is it a float, an >int, etc? It appears to be dynamically typed, which is syntacticaly simple >for the novice I suppose, but I am anal enough that I do like strong typing. Might happen for Python 2.0 (likely to appear some time in 2001 or 2002), but not earlier than that. Yes, it's pure dynamic typing -- you can't even predeclare variables. >More to the point, while I don't plan to put my ultra-high performance code >in Python, I can't afford for it to be outrageously slow either. What are >the performance characteristics of the Python VM? Well, it uses ref-counting, so you're guaranteed that there's no garbage collection. OTOH, if you make a mistake you can leak memory. Other than that, it's hard to make generalizations about Python performance -- one of the truisms of Pythonistas is that programming is so much easier in Python that you get the opportunity to try several algorithms to see what gives you the best performance. As a programmer with your experience knows, algorithmic improvements can give you order-of-magnitude increases in performance. Then, if Python still isn't fast enough, it's pretty easy to hook Python to straight C code. >When I used the Python GUI interface there was no option on the menu to just >'compile' a piece of python source. When I issued the command line option >to compile a piece of source i.e. "compile foo" where 'foo' represents a >Python source file on disk, it gives me an error message. Yup. Python really is an interpreted language; the fact that it "compiles" to byte-code is an interesting optimization that is irrelevant to actual language functioning. (This comment isn't completely true, but you should treat it as if it were true.) Side note: there really isn't a Python GUI interface. It's an IDE written in Python (and Tk -- see the Tcl programming language for more info) that provides no facilities other than what the langauge itself does. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Eighth Virtual Anniversary -- 6 days and counting! From mhammond at skippinet.com.au Fri Dec 3 09:30:44 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 03 Dec 1999 14:30:44 GMT Subject: SyntaxError: can't assign to function call win32com.client References: <823ppg$o2b$1@nnrp1.deja.com> Message-ID: tiddlerdeja at my-deja.com wrote in message <823ppg$o2b$1 at nnrp1.deja.com>... >I'm trying to mirror this VB code (which works) with python code: > >objUser.DynamicProperty("BILLING_ADDRESS2") = "3 The Street" As Stefan suggested, it could be "SetDynamicProperty(...)", or it may be DynamicProperty(...).Value = "3 The Street" Mark. From python-list at teleo.net Thu Dec 30 23:57:34 1999 From: python-list at teleo.net (Patrick Phalen) Date: Thu, 30 Dec 1999 20:57:34 -0800 Subject: XML-RPC Server in Python In-Reply-To: <386C2D38.BE2BDFA8@home.com> References: <386C2D38.BE2BDFA8@home.com> Message-ID: <99123021001508.03415@quadra.teleo.net> [Edward Muller, on Thu, 30 Dec 1999] :: 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..... see http://pythonware.com/products/xmlrpc includes sample code for Medusa also see http://www.zope.org/Members/Amos/XML-RPC From fredrik at pythonware.com Mon Dec 27 04:36:51 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 27 Dec 1999 10:36:51 +0100 Subject: Memory leaks and reference counter of an object References: <38672f18.3391606@news.atnet.at> Message-ID: <01d001bf504d$ea42bf50$f29b12c2@secret.pythonware.com> Manfred Pisecky wrote: > Is there a way to get the value of the reference counter of an > arbitrary object from within Python code - of course immutable? sys.getrefcount(object) for details, see http://www.python.org/doc/current/lib/module-sys.html From claird at starbase.neosoft.com Sun Dec 19 12:43:22 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 19 Dec 1999 17:43:22 GMT Subject: python apache module? References: <3823D45F.CF78E6E7@mindspring.com> Message-ID: 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. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From claird at starbase.neosoft.com Fri Dec 24 17:24:51 1999 From: claird at starbase.neosoft.com (Cameron Laird) Date: 24 Dec 1999 22:24:51 GMT Subject: Multi-User non Client/Server database References: <7DE1F51DE6EF8DE2.FEF18A6AB6E94830.57F6A00E6C02B0D3@lp.airnews.net> <3862473B.E8133933@equi4.com> Message-ID: In article <3862473B.E8133933 at equi4.com>, Jean-Claude Wippler wrote: >piet at cs.uu.nl wrote: >> >> >>>>> claird at starbase.neosoft.com (Cameron Laird) (CL) writes: >> CL> You'll want to read the recent MetaKit announcement >> CL> . MetaKit >> CL> plays 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. > >Those two statements are not mutually-exclusive. >At the file-locking level, locking works fine. > >-jcw There's a general-purpose need in our domain for labels to distinguish You can't do X; the system will block, and only permit you to do X', which of course is safe. and You can't do X; the system's behavior is undefined in that circumstance, and probably hazardous. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From smigowsky at dspace.de Thu Dec 2 05:26:06 1999 From: smigowsky at dspace.de (Stefan Migowsky) Date: Thu, 2 Dec 1999 11:26:06 +0100 Subject: SyntaxError: can't assign to function call win32com.client Message-ID: <326536345498D311B3BC00105A39802A074506@newsintern.dspace.de> Hi, properties with parameters are only supported in Python if you use the generated wrapper (makepy.py) dynamic generated code will fail. With the wrapper your call would look like : objUser.SetDynamicProperty("BILLING_ADDRESS2", "3 The Street") you could check if you have wrapper support with a one liner: >>> objUser # No Wrapper support >>> objUser # Wrapper support Stefan >-----Original Message----- >From: tiddlerdeja at my-deja.com [mailto:tiddlerdeja at my-deja.com] >Sent: Wednesday, December 01, 1999 7:35 PM >To: python-list at python.org >Subject: SyntaxError: can't assign to function call win32com.client > > >I'm trying to mirror this VB code (which works) with python code: > >objUser.DynamicProperty("BILLING_ADDRESS2") = "3 The Street" > >This code works in VB but in python I get the error: > >SyntaxError: can't assign to function call > >Can you tell me what syntax I need to use for python? > >Any help greatly appreciated. I don't want to have to use VB! > >Kieran Breen > > >Sent via Deja.com http://www.deja.com/ >Before you buy. > >-- >http://www.python.org/mailman/listinfo/python-list > From roy at popmail.med.nyu.edu Sat Dec 18 12:34:12 1999 From: roy at popmail.med.nyu.edu (Roy Smith) Date: Sat, 18 Dec 1999 12:34:12 -0500 Subject: circular references? References: <385B1AE9.DD4F8ED3@yifan.net> Message-ID: To follow up on my own question, I've changed my main loop to look something like: [code to set func to the right subclass] page = apply (func, (self,)) page.show() page.cleanup() The page.cleanup() call is the new part, and the last thing to get executed before page drops out of scope (i.e. the enclosing function returns). Cleanup just breaks the circular references: class new_domain (netdbpage): def cleanup (self): self.record_set = None netdbpage.cleanup (self) 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 :-) 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? From shouldbe at message.com Wed Dec 8 12:20:00 1999 From: shouldbe at message.com (Arinte) Date: Wed, 8 Dec 1999 12:20:00 -0500 Subject: Help need with tuples??? References: <000501bf419a$37b21550$3acbd9c2@peridot.optichrome.com> Message-ID: <82m3le$11u2$1@rtpnews.raleigh.ibm.com> They answered my other question, which was the same as this. TIA (the A stands for anyways.) From bjorn at roguewave.com Fri Dec 10 13:44:42 1999 From: bjorn at roguewave.com (bjorn) Date: Fri, 10 Dec 1999 11:44:42 -0700 Subject: httplib problem References: <385195FD.D4E81815@iwr.uni-heidelberg.de> Message-ID: <38514A19.F92328BD@roguewave.com> try print form['data'].value as the last line. -bjorn Dirk Engelmann wrote: > Hi! > > I want to transfer data by http betweeen a http-server (cgi-script) and > > a client (httplib). > I tried this using httplib on the client side and transfering data > to a cgi-script, but it failed. > I appended a litele sample - which didn?t work and I can?t find > a solution. > Is there another easier way to do this ? > > Thanks for any help! > > Cheers, > Dirk Engelmann > > #------------- http-client ------------------- > import httplib > from string import joinfields > # sample data which should be transfered to the cgi-script port.py > data = "testdata" > # header: > hdr = [] > part = [] > hdr.append('Content-Disposition: form-data; name="data"') > hdr.append('Content-Type: application/octet-stream') > hdr.append('Content-Length: %d' % len(data)) > part.append("%s\n\n%s" % (joinfields(hdr,'\n'), data)) > > # st contains header and data > st = joinfields(part, '') > > # open httplib and execute cgi-script port.py > h = httplib.HTTP('localhost') > boundary= '%s%s_%s_%s' % \ > ('-----', int(time()), os.getpid(), randint(1,10000)) > contentType = 'multipart/form-data; boundary=%s' % boundary > h.putrequest('POST', '/cgi-bin/port.py') > h.putheader('Accept', '*/*') > h.putheader('Content-Type', contentType) > h.putheader('Content-Length', str(len(st))) > > # transfer the data to cgi-script port.py > h.endheaders() > h.send(st) > errcode, errmsg, headers = h.getreply() > data = h.getfile().read() # Get the raw HTML > print data > > #--------------- port.py : cgi-script on server ----------------- > import cgi > form = cgi.FieldStorage() > print form['data'] > > -- > http://www.python.org/mailman/listinfo/python-list From robin at jessikat.demon.co.uk Sat Dec 11 21:36:32 1999 From: robin at jessikat.demon.co.uk (Robin Becker) Date: Sun, 12 Dec 1999 02:36:32 +0000 Subject: some random reflections of a "Python newbie": (1) books, and free sites References: <6D8A17398E28D3119F860090274DD7DB4B3D04@pces.cadlab.it> <384F8E63.95B75B21@corrada.com> Message-ID: <4E1vGBAwowU4Ew+N@jessikat.demon.co.uk> In article , Jim Richardson writes ... >> >>how do people support 'free' sites? Via advertising? >>-- > >That's one method, also by tracking where you go (market >research, the "evil twin" of advertising :) > >Or they give away a basic service and hope to tempt you to buy >the "full" service pack. Or basic service is free, but any extras >cost money. > Over here a friend reports that currentbun.com has an IE customised so that you can't actually enter a URL directly; you have to use their search engine and all the while adverts are flashing up and telephone time is ticking over. Apparently freeserve, btconnect et al aren't quite so nasty, but all are getting kickbacks on the telephone time. -- Robin Becker From mgushee at havenrock.com Thu Dec 23 00:29:10 1999 From: mgushee at havenrock.com (Matt Gushee) Date: Thu, 23 Dec 99 05:29:10 GMT Subject: New Python Stuff Page Message-ID: And now for something completely different ... NOT! But I thought I'd let everyone know anyway. I have posted a new page of miscellaneous Python modules, snippets, hints, etc. Basically, anything I do in Python that isn't an application or a substantial library, and that I think may be useful to others (if only as an example of what NOT to do), will go on this page. The URL is: http://www.havenrock.com/softlab/pystuff/index.html Not much there yet. So far there's a TrueFalseSwitch -- a customized version of the Tkinter Checkbutton class. But it will definitely grow. By the way, can I get in trouble for mixing Pythonisms with Saturday-Night-Liveisms? Dreading-the-Spanish-Inquisition-ly yours, == Matt Gushee Portland, Maine, USA mgushee at havenrock.com http://www.havenrock.com/ -- ----------- 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 cfelling at iae.nl Wed Dec 22 15:46:19 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 22 Dec 1999 21:46:19 +0100 Subject: Bad programming style? References: Message-ID: <83rdar$1qr$1@vvs.superst.iae.nl> Grant Edwards wrote: > In article , Sposhua wrote: >>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. > Yes, you can do this in Python by creating the string "r = > 'ff'" and then executing it with "exec" or eval(). Any > language that can execute data can do this -- Lisp is probably > the most (in)famous example. It's an extremely powerful tool. Why not use the following: >>> locals()['r'] = 'ff' >>> print r ff 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:) > [TNT is an extremely power tool. But, if you're planting -- groetjes, carel From t.middleten at news.vex.net Sat Dec 4 03:26:21 1999 From: t.middleten at news.vex.net (t. middleten) Date: 4 Dec 1999 08:26:21 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> <828qhj$bb1$1@nnrp1.deja.com> Message-ID: <82aj7d$2dl9$2@hub.org> On Fri, 03 Dec 1999 16:19:04 GMT, Preston Landers wrote: >> want to continue a line of code over multiple physical lines? > >x = "This is a \ > line of code \ > spanning multiple \ > lines" Although the original poster asked about code spanning lines, and the above example, while in a string, demonstrates the concept, i want to point out that the above string will produce... "This is a line of code spanning multiple lines" (For that ugly effect you might as well use multi-line quotes... x = """This is a line of code spanning multiple lines""" ) However, to demonstrate the concept of multi-line code AND keep the spacing nice in our string, this works best... x = "This is a " \ "line of code " \ "spanning multiple " \ "lines" From thamelry at vub.ac.be Fri Dec 3 11:47:44 1999 From: thamelry at vub.ac.be (Thomas Hamelryck) Date: 3 Dec 1999 16:47:44 GMT Subject: Be gentle with me.... References: <828n3e$8kp$1@nnrp1.deja.com> Message-ID: <828s7g$d4f$1@mach.vub.ac.be> ajmayo at my-deja.com wrote: [snip] : 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? [snip] The use of indentation is IMO indeed a (very) weak point of python. Many people however who use python 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. Hey, no language is perfect! You might even start to like as many python users do... About your last question: anything in between ( and ) can span multile lines, fortunately. -- Cheers, ------------------------------------------------ Thomas Hamelryck//Free University Brussels (VUB) Intitute for Molecular Biology// ULTR Department Paardestraat 65//1640 Sint-Gensius-Rode//Belgium ------------------------------------------------ From tim_one at email.msn.com Sat Dec 4 17:12:17 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 4 Dec 1999 17:12:17 -0500 Subject: map versus the 'for' loop In-Reply-To: <82b7gn$qut@mail.psy.uva.nl> Message-ID: <000101bf3ea4$a0206720$df2d153f@tim> [Ionel Simionescu] > In some situations, the use of map() can speed up things, which would > normally be done in a loop. > > --- e.g. > > # > y = map(func, x) > > # vs. > > # > y = [None]* len(x) > for k in range(x): y[k] = func(x[k]) > > --- > > I hereby ask those with knowledge about the interpreter's > internals what the trade-offs/cavets are. If func is None, map is much faster. If func is a Python function, map saves only loop overhead, and is a minor gain (typically no more than a few percent). If func is some builtin operation (like "+" or "len") spelled at least roughly the same way in both cases, it depends on the precise operation, but map will usually be significantly faster (it again saves only loop overhead, but when the operation is implemented in C the loop overhead is a much bigger relative burden). The funny ones are where someone takes a perfectly fine Python loop like: for i in xrange(len(x)): z[i] = x[i] * y[i] and converts it to a lambda-slinging map: z = map(lambda a, b: a*b, x, y) under the assumption that "map must be faster". map is significantly slower if you have to *introduce* a lambda (or any other spelling of a Python function) to get it to work (you've then added the expense of a Python-level function call to each result computed, that the explicit Python loop avoided). > The speed gain brought by map() might have a cost (e.g. space) > that I'm not aware of, and which could bite in certain situations. Not in general. If you restrict your use of map to cases where it improves *clarity*, you'll rarely go wrong. provided-i'm-the-sole-judge-of-clarity-ly y'rs - tim From wzab at ise.pw.edu.pl Fri Dec 10 08:49:01 1999 From: wzab at ise.pw.edu.pl (Wojciech Zabolotny) Date: Fri, 10 Dec 1999 14:49:01 +0100 Subject: How to parse (in the C code) a tuple not sent as an argument? Message-ID: Hi All, I have to parse in my C extension module a rather complicated tuple, which is not send as an argument. Is it correct and safe to use the PyArg_ParseTuple for this purpose? -- TIA Wojciech M. Zabolotny http://www.ise.pw.edu.pl/~wzab <--> wzab at ise.pw.edu.pl http://www.gnupg.org Gnu Privacy Guard - protect your mail & data with the FREE cryptographic system From milek at task.gda.pl Fri Dec 10 10:59:19 1999 From: milek at task.gda.pl (Robert Milkowski) Date: Fri, 10 Dec 1999 16:59:19 +0100 Subject: Enviroment In-Reply-To: <013401bf4324$e51ed530$f29b12c2@secret.pythonware.com> Message-ID: On Fri, 10 Dec 1999, Fredrik Lundh wrote: > Robert Milkowski wrote: > > I call the program in Python as CGI. > > I need to set up LD_LIBRARY_PATH enviroment to > "/usr/lib:/lib:/mnt/1/NSIN/lib:/mnt/1/NSIN/egcs-libs:" before importing some modules. > > How can I do it in Python? > os.putennv(LD_LIBRARY_PATH,"/usr/lib:/lib:/mnt/1/NSIN/lib:/mnt/1/NSIN/egcs-libs:/mnt/1/NSIN/linux-li > bs:") > > doesn't work. > > afaik, there's no error message in Python > that just says "doesn't work". :))) > anyway, the correct syntax is: > > os.environ["LD_LIBRARY_PATH"] = "/usr/lib etc hmmmm but it makes no use of it while importing. If I made a script #!/bin/sh export LD_LIBRARY_PATH="/opt/SUNWspro/lib:/usr/openwin/lib:/usr/ucblib:/usr/local/lib:\ /opt/IC/lib:/usr/lib:/lib:/mnt/1/NSIN/lib:" /usr/local/bin/python test then it works. But if I do os.environ["LD_LIBRARY_PATH"] = "/opt/SUNWspro/lib:/usr/openwin/lib: \ /usr/ucblib:/usr/local/lib:/opt/IC/lib:/usr/lib:/lib:/mnt/1/NSIN/lib:" and run directly python script, it doesn't work. Traceback (innermost last): File "/usr/local/apache/share/cgi-bin/test", line 14, in ? from aa import * File "/mnt/1/NSIN/python/aa.py", line 2, in ? import wqw ImportError: ld.so.1: /usr/local/bin/python: fatal: libQWE.so.3.2: open failed: No such file or directory [Fri Dec 10 16:56:50 1999] [error] Premature end of script headers: /usr/local/apache/share/cgi-bin/test_query The library libQWE.so.3.2 is in /mnt/1/NSIN/lib. So how can I inform system directly from python to make use of this directory while searching libs? -- Robert Milkowski milek at task.gda.pl From arcege at shore.net Wed Dec 1 08:25:14 1999 From: arcege at shore.net (Michael P. Reilly) Date: Wed, 01 Dec 1999 13:25:14 GMT Subject: PyArg_ParseTuple() and oprtional remaining argument lists References: <000c01bf3a70$ae184ec0$3acbd9c2@peridot.optichrome.com> Message-ID: <_k914.622$3N2.155189@news.shore.net> Adrian Eyre wrote: :> I also have trouble using PyArg_ParseTuple(...) with a single item, :> e.g. :> if (PyArg_Parse(args,"i",&index) && (index >= 0)) { :> is ok, but :> if (PyArg_ParseTuple(args,"i",&index) && (index >= 0)) { : Aha. That's the clue. Make sure that your PyMethodDef struct is like : this: : static struct PyMethodDef methods[] = { : { "method1", method1, 1 }, : { "method2", method2, 1 }, : { NULL, NULL, 0 } : }; It might be better to use METH_VARARGS instead of 1, in case the value changes in a future release. -Arcege From amitp at Xenon.Stanford.EDU Tue Dec 28 21:53:20 1999 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 29 Dec 1999 02:53:20 GMT Subject: Python newbie References: <38549DEA.B0157D0@iqsoft.hu> <113901bf470c$cb236f60$0100a8c0@rochester.rr.com> <38654F5C.378F8338@maxtal.com.au> <002601bf4f42$58e98cc0$49294b0c@amd> Message-ID: <84bt30$mb0$1@nntp.Stanford.EDU> John Ratcliff wrote: | | My goal is that I will have a core engine on the client and on the server | side. The basic game logic should all be written in some kind of general | purpose scripting langauge which can be modified to invoke any of my native | methods as if they were extensions to the language itself. My reasons for | this are primarily as follows: | | (3) Game content is not static. In a multiplayer environment this is | absolutely critical. If you buy a single player game and it provides a | certain amount of content for your money, that's just fine. But, in a | pay-for-play multliplayer game, players demand and expect a constant flow of | new content. Moreover, game balance must constantly be monitored and | changed as a game world evolves in an online environment shaped by hundreds | of thousands of people. | | Having all of the game logic represented as compiled byte code means you can | easily download and patch the gaming system, even as it's running, on | demand. While it is true that ultimately you could simply download new | pieces of game logic as compiled code, as either DLL's or simply patches to | an executable, this doesn't work very well when your product targets | multiple processors and operating systems. Hi John, I've been thinking about scripting languages for games as well, and one of the issues that you may need to be careful about is the potential for users to patch the gaming system themselves. Being able to download game logic is a great idea, but in a multiplayer game there's some incentive for highly motivated individuals to change the local rules on their client and affect the server in some way. (I had to deal with a lot of cheating in multiplayer BBS games I worked on.) With Python bytecode, it's even easier because users can get their hands on the bytecode format without spending time reverse engineering. What I ended up designing (but never implementing, alas) was client-side code for interacting with the player -- bringing up dialog boxes, displaying information, preparing a transaction, and sending messages to the server -- but server-side code for verifying that changes to the database were legal. That way, Python code that was downloaded (and possibly modified) in the client can't change the rules of the game. I tried to make each message to the server preserve correctness regardless of the parameters passed. For example, instead of set-money() and set-tanks() messages, I used buy-tanks(amount). If the buy could not proceed (perhaps because the amount of money had changed in that time, or the price of tanks had gone up), the server would return an error flag. If the user hacked the bytecode, he wouldn't be able to do anything terrible, because the server doesn't depend on the parameters being consistent with any other data. (In fact, if your client-server protocol is protected in this way, you could open up the protocol so that people can write third party clients...) | Is it easy to build a version of the source that contains *only* the byte | code interpreter, and not the run time parser and compiler? Much of the | Python stuff seems geared towards the interactive command line interface, | which is nice if that's what you need, but I want to use the standard model | of compile source to byte code, and then run only that byte code in my | virtual machine. I think the last time I looked, Python took up 500k of run-time, but some people were able to get it down to 350k-400k by removing modules. It'd be nice if there was only a byte code interpreter, but I don't think it's been done. When I last looked at this, 500k was a big deal, but it doesn't seem to be a big deal on PCs anymore. - Amit From jblaine at shell2.shore.net Mon Dec 20 17:51:28 1999 From: jblaine at shell2.shore.net (Jeff Blaine) Date: Mon, 20 Dec 1999 22:51:28 GMT Subject: ANN: PyGCS 1.3.8 (chat server) Message-ID: It's been a bit since I announced this here and the whole thing has stabilized to a near standstill (meaning the "product" is finally right how I wanted it). This version was actually released on Freshmeat and the PyGCS homepage on 12/7/1999. PyGCS is a very stripped down MUD-like chat-server written entirely in Python. It has a single "room" and no large database to keep in memory and on disk. PyGCS has no embedded programming language. PyGCS is ideally meant to be a small multi-user real-time chat system for people who have a need to talk to more than one person at a time online. It fits somewhere in between the setup IRC uses (no walking between rooms so to speak) and the MUCK/MUSH/MOO style of server. Homepage: http://www.sourceforge.net/project/?form_grp=378 Download: http://www.sourceforge.net/download.php?fileid=718 Alt Download: ftp://ftp.shore.net/members2/j/jblaine/Source/ Bug Reporting: http://www.sourceforge.net/bugs/?group_id=378 Mailing List: http://lists.sourceforge.net/mailman/listinfo/pygcs-announce From amcguire at coastalnet.com Thu Dec 16 16:00:01 1999 From: amcguire at coastalnet.com (Andrew N. McGuire) Date: Thu, 16 Dec 1999 15:00:01 -0600 Subject: Newbie Getopts Question Message-ID: <385952D1.AB04A9FF@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 timmuddletin at news.vex.net Wed Dec 8 03:36:04 1999 From: timmuddletin at news.vex.net (tim muddletin) Date: 8 Dec 1999 08:36:04 GMT Subject: lemmings References: <82j6o3$jc6$1@news.qub.ac.uk> <19991207171102.A8067@stopcontact.palga.uucp> <384D65B8.BF333D3D@callware.com> <19991207213845.A11288@stopcontact.palga.uucp> Message-ID: <82l59j$srg$1@hub.org> Not that it functionally matters, but just to let anyone who wants to know, the Vaults of Parnassus url has been simplified a little. You can now access it with www.vex.net/parnassus No more need of little squiggles and x's. The old url will continue to work fine as well. Barry had suggested this little shortening when he put the link up on the python.org module page.... http://www.python.org/download/Contributed.html A small thing, but a good thing, and thus it was done. Your humble lemming ... From fredrik at pythonware.com Mon Dec 13 04:27:17 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 13 Dec 1999 10:27:17 +0100 Subject: XML parsing References: <945048362snz@vision25.demon.co.uk> Message-ID: <00d501bf454c$4268f8f0$f29b12c2@secret.pythonware.com> Phil Hunt wrote: > I am parsing some XML input using the xmllib module. > > 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? raising an exception is sensible, and in accordance with the XML 1.0 specification: "Processors may signal an error if they receive documents labeled with versions they do not support." > Or do I have to write my own XML parser? if you can find the XML 1.1 specification (I cannot, and I don't think there is one...), go ahead. (but it's probably easier to tell your data provider to stop using bogus version numbers...) From m.faassen at vet.uu.nl Fri Dec 3 19:24:44 1999 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Dec 1999 00:24:44 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: <829n0c$ide$2@newshost.accu.uu.nl> Fred L. Drake, Jr. 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? ;) I started with those (though not x86 assembly; Z80 assembly instead). And also with a bit of Lisp and Prolog. and even Perl but that start was quickly aborted upon my discovery of Python. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From cgw at fnal.gov Mon Dec 20 12:13:05 1999 From: cgw at fnal.gov (Charles G Waldman) Date: Mon, 20 Dec 1999 11:13:05 -0600 (CST) Subject: Equivalent to (a ? b : c) ? In-Reply-To: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> References: <6D8A17398E28D3119F860090274DD7DB4B3D62@pces.cadlab.it> Message-ID: <14430.25505.208191.570692@buffalo.fnal.gov> > 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? > > Here's a somewhat bizarre version, posted mainly for entertainment value: {0:b, 1:c}[not a] or if you don't like the truth-values being inverted that way: {1:b, 0:c}[not not a] According to the language reference (which I just checked), "not" always returns either 0 or 1, so it can be used to turn any object into a boolean value. From emuller at painewebber.com Mon Dec 13 16:45:03 1999 From: emuller at painewebber.com (emuller at painewebber.com) Date: Mon, 13 Dec 1999 21:45:03 GMT Subject: win32ver module Message-ID: <833pct$r5b$1@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 jsight at mindspring.com Mon Dec 6 21:26:02 1999 From: jsight at mindspring.com (Jesse D. Sightler) Date: Mon, 06 Dec 1999 21:26:02 -0500 Subject: Python/cgi Was: Very useful message -- Hah! References: <199912052201.RAA11142@mail3.mia.bellsouth.net> Message-ID: <384C703A.35824F5E@mindspring.com> dgrassi wrote: > > On 12/5/99 4:25 PM Fredrik Lundh wrote: > >> There is a solution albeit rather nasty. Fork python and add a few simple > >> web-friendly features. Is that the best solution? > > >hmm. python comes with over 200 support modules. you > >happen to think that one of them doesn't do what you want. > >why not change that module instead? you have the sources, > >and I'm pretty sure you can figure out how it works without > >too much effort. > > 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. Hmm, either that or a PythonCGI shell script that wraps all results in a HTTP header if Python returns a non-zero exit code. > >if you're not up for the programming task, write a wishlist > >and post it here. chances are that you'll find someone > >willing to help you implement the changes. > > Well, I could probably do the programming including an upgrade to the > pyApache code, but will it get rolled into the product? I'm not against > writing the code but all I keep hearing here is that things are fine as > they are. With that attitude what is the change that my changes would be > accepted? Who cares. A simple shell script wrapper would be all that's needed. There's nothing at all wrong with that, and it would have ZERO impact on "backwards compatibility". :-) > >or just keep using your own version until the end of days. > > Can't do that, then I have non-standard code that I can't provide to > others. Er, no, you'll just have a non-standard script for your debugging versions. The distribution product won't have syntax errors, and will therefore obviously have no need for such silliness. :-) > >maybe people don't think it's hard to use? maybe you should > >spend some of the effort trying to figure out how they do things, > >instead of assuming that "if I don't understand it at once, it's use- > >less"... > > Perhaps it _is_ difficult to use for cgi. Just possibly? Or perhaps CGI is just difficult in and of itself. I don't believe that anyone ever occused CGI of being a great development environment for web applications. > Consider, no matter how many times you tell a person it is easy the > telling does not actually make it easy. Well, I can't disagree with that. :-) > >> I just don't get it. > > > >hint: don't assume that everyone is doing exactly the same > >things as you are, in exactly the same way. > > Hint, perhaps many do. Do you think that there are 10x6 sites using > python for the same function as php? If not why? Because Python is a general purpose programming language. PHP is a special purpose language for web-development. >Is php a better > language? Has php been available longer? If not these reasons _why_ > not? Oh, perhaps one had better not try and answer this question. Have you ever seen any client side applications written in PHP. Or how about any that use PHP/TK. :-) Seriously, why don't you quit comparing Apples and Oranges, and start comparing Zopes and PHPs? > But, wouldn't it be great if python _was_ as easy to use as php? No, because then it would be useless as a client-side language. That would be truly sad. -- --------------- Jesse D. Sightler http://www.biddin.com/ From trosen at activmedia.com Wed Dec 29 01:13:54 1999 From: trosen at activmedia.com (trosen) Date: Wed, 29 Dec 1999 06:13:54 GMT Subject: wxPython Message-ID: <84c8au$6ia$1@nnrp1.deja.com> Does anyone know how to make boxes that you can click on and drag to a different size using wxPython? Is it possible? For example, I create a box of a particular size in a window. I want to change the length of the box, so I click on one side of the box, and drag it to make it larger. Thanks, -- Michael Trosen ActivMedia Robotics www.activrobots.com trosen at activmedia.com Sent via Deja.com http://www.deja.com/ Before you buy. From DNagata at creo.com Thu Dec 2 00:47:24 1999 From: DNagata at creo.com (Dale Nagata) Date: Wed, 1 Dec 1999 21:47:24 -0800 Subject: compile time constant to differentiate 1.5.2 from 1.5.1? Message-ID: <3FCBBA86D50FD211AD3600A0C9AB2CA203DEC35D@msgcreo1.creo.bc.ca> On Wednesday, December 01, 1999 12:04 AM, Fredrik Lundh [SMTP:fredrik at pythonware.com] 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. > > > > PYTHON_API_VERSION > Hmm, for 1.5.1 modsupport.h says #define PYTHON_API_VERSION 1007 #define PYTHON_API_STRING "1007" and for 1.5.2 it says #define PYTHON_API_VERSION 1007 #define PYTHON_API_STRING "1007" Now that I have a 1.5.2 source tree to look at, I see that patchlevel.h defines some new macros that didn't exist before: This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL was available. To test for presence of the scheme, test for defined(PY_MAJOR_VERSION). Thanks, -- 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 parkw at better.net Fri Dec 10 00:29:09 1999 From: parkw at better.net (William Park) Date: Fri, 10 Dec 1999 00:29:09 -0500 Subject: some random reflections of a "Python newbie": (1) books, and free sites In-Reply-To: References: <82o0to$6eq$1@serv1.iunet.it> <82pcm0$p6t$1@nnrp1.deja.com> Message-ID: <19991210002909.A685@better.net> On Fri, Dec 10, 1999 at 04:58:28PM +0000, Brett g Porter wrote: > > "Grant Edwards" wrote in message > news:slrn8524tl.jcd.grant at grante.comtrol.com... > > What I'd like is a good intermediate level book written for an > > audience that already knows the basics of programming and > > language theory. > Hear, hear. I'm on my second go-through of "Programming Python," and > continue to shake my head -- I've been programming professionally for close > to 10 years now, and this book has the rare ability to make me feel that I > know less after reading it than I did before. > > Also, I already own all the scripts to Python (Monty), and don't need to get > them in a programming text. > > I was looking for a 'little' language and almost bought a Perl book instead > (before I looked at enough Perl code to realize that it looks like the > bastard stepchild of awk & Basic). I wasn't expecting the depth that I'm > finding in Python. Try "The Quick Python Book" by Ken McDonald from Manning Publications. I saw them in bookstore, yesterday, beside O'Reilly's "Programming Python" and "Learning Python". > > What I'd _really_ like is the Python equivalent of Bruce Eckel's "Thinking > in..." series -- I know that Bruce is going to throw a Python seminar soon, > so maybe... From ngps at madcap.dyn.ml.org Thu Dec 16 10:20:11 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 16 Dec 99 15:20:11 GMT Subject: download web page with python References: <83a3m4$diq$1@nnrp1.deja.com> <3859024e.0@news.cyberway.com.sg> Message-ID: <3859032b.0@news.cyberway.com.sg> According to Ng Pheng Siong : > import urllib > > url = "http://www.symantec.com/avcenter/cgi-bin/navsarc.cgi" > post_data = urllib.urlencode({"PROD":"N95", "LANG":"US"}) > url_obj = urlopen(url, post_data) Ouch! I meant the following, of course: url_obj = urllib.urlopen(url, post_data) > print url_obj.readlines() -- Ng Pheng Siong * http://www.post1.com/home/ngps From billtut at microsoft.com Wed Dec 15 11:56:49 1999 From: billtut at microsoft.com (Bill Tutt) Date: Wed, 15 Dec 1999 08:56:49 -0800 Subject: win32api question Message-ID: <4D0A23B3F74DD111ACCD00805F31D8101D8BCB44@RED-MSG-50> > -----Original Message----- > From: tony roth [mailto:roth at teleport.com] > > I do the following > > import win32api > import win32con > rk=win32api.RegConnectRegistry('blmw2ktr',win32con.HKEY_LOCAL_MACHINE) > test=win32api.RegQueryValueEx(rk,"software") > This happens because "HKLM\Software" is a key, and not a value. If you want the default value assigned to the Software key, then use RegQueryValue(). If you want to get an HKEY for the Software key then use RegOpenKeyEx(). Bill From cjensen at be-research.ucsd.edu Thu Dec 9 15:01:24 1999 From: cjensen at be-research.ucsd.edu (Curtis Jensen) Date: Thu, 09 Dec 1999 12:01:24 -0800 Subject: FORTRAN (was Re: indentation) References: <65118AEEFF5AD3118E8300508B124877073CC6@webmail.altiris.com> <384EF139.91ACD637@bioreason.com> Message-ID: <38500A94.FB6EF7DE@be-research.ucsd.edu> Mitch Chapman wrote: > > Mike Steed wrote: > > > From: aahz at netcom.com [mailto:aahz at netcom.com] > > > ... > > > 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. > > Thanks for making me feel like both an old man and a member of a > 12-step program: I'm Mitch, I'm 35, and I used Fortran eight years ago. > > We once had a programmer who thought C was a dialect of Fortran. > He wrote the second 1000+-line C function I'd ever seen. > (The first was an interrupt service routine (!) from Ultrix, > for the Vaxstation console device. Unfortunately, I've seen many > examples since then.) > > -- > Mitch I'm 22, I've been working on a 15+ year old legacy program in Fortran, for the past six months. There is a another guy here who just turned 22 and he has been working on this program for over a year and a half. It's a huge Finite Element Modeling program. I ended up turning a 2000 line Fortran function into 11000+ lines. We've shrunk it to 7000 now. I'm not sure how many lines and files there are total, but it's probably over 25000 lines. The entire program is currently a mix of C and Fortran. We're mixing in Python now. We're planning on eventualy converting the entire thing to C and Python. You can visit our web page at: http://cmrg.ucsd.edu/modelling/modelling.html -- Curtis Jensen cjensen at be-research.ucsd.edu FAX (425) 740-1451 From dworkin at ccs.neu.edu Tue Dec 7 16:00:09 1999 From: dworkin at ccs.neu.edu (Justin Sheehy) Date: 07 Dec 1999 16:00:09 -0500 Subject: Python type checking? References: <82j9u8$da7$1@nnrp1.deja.com> Message-ID: Arinte writes: > 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. Your description is a little ambiguous, since you don't say what to do if `value' is neither an int or a string. The simplest thing would be: def setValue(self, value): try: self.argvalue = long(value) except: self.argvalue = value But if you wanted something to do exactly what you described, it could look a little more like: def setValue(self, value): if type(value) == type(0): self.argvalue = long(value) elif type(value) == type(''): self.argvalue = value else: whatever you want to do if value is neither an int or a string -Justin From: Aaron J Reichow Newsgroups: comp.lang.python Subject: Re: Is there a database in Zope? Date: Tue, 7 Dec 1999 14:57:43 -0600 Organization: University of Minnesota, Duluth Lines: 14 Message-ID: References: <82iv6c$fis$1 at newshost.accu.uu.nl> NNTP-Posting-Host: bulldog5.d.umn.edu Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII To: Martijn Faassen In-Reply-To: <82iv6c$fis$1 at newshost.accu.uu.nl> Path: news!uunet!ffx.uu.net!finch!logbridge.uoregon.edu!newshub.tc.umn.edu!hardy.tc.umn.edu!news.d.umn.edu!bulldog5.d.umn.edu!reic0024 Xref: news comp.lang.python:77839 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 > 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. I second the mention of gadfly. I found it quite easy to set it up for a simple name/address/phone/IM/phone/email/add'l info DB for any contacts and friends. About 15 lines of CGI in two different python CGI scripts for users to view and add entries. Very little time to set it up. Deleting and modifying entries will be a little harder, but not excrutiatingly so. Aaron From tomhs at austin.ibm.com Fri Dec 17 16:06:54 1999 From: tomhs at austin.ibm.com (Tom Smith) Date: Fri, 17 Dec 1999 15:06:54 -0600 Subject: tkinter on AIX Message-ID: <385AA5EE.6B31BDA1@austin.ibm.com> Sorry if this has already been asked. I couldn't find it anywhere on dejanews... When trying to compile python on AIX 4.3.3 with either gcc or cc_r I get: 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. Anyone have any help/advice for an admitted tcl, tk, AND python newbie?... Thanks, Tom -- |---------------------------------------------------------| | 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 mhammond at skippinet.com.au Tue Dec 7 08:09:42 1999 From: mhammond at skippinet.com.au (Mark Hammond) Date: Tue, 07 Dec 1999 13:09:42 GMT Subject: Help with tuples please? References: <82ivrl$744$1@rtpnews.raleigh.ibm.com> Message-ID: Arinte wrote in message <82ivrl$744$1 at rtpnews.raleigh.ibm.com>... > 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"); > } As you saw from the code, PyArg_ParseTuple requires a tuple. If it almost certain that nobj is not a tuple, but a string. [Just saw the .py code below - _definately_ a string :-) You probably want: nobj = PyObject_GetAttrString(tobj,"argname"); <-successful, nobj not null if(!PyString_Check(nobj)) { appcallback()->messageBox("not a string"); getout! } vstr = PyString_AsString(nobj); Mark. From skip at mojam.com Fri Dec 3 07:32:07 1999 From: skip at mojam.com (Skip Montanaro) Date: Fri, 3 Dec 1999 06:32:07 -0600 (CST) Subject: split this newsgroup? In-Reply-To: References: Message-ID: <14407.47175.756017.615152@dolphin.mojam.com> Max> The volume on this newgroup might justify splitting the newgroup. Max> Comments? A reasonable indicator that a newsgroup needs to be split is that the volume grows too large (this isn't that big, actually) *and* that there is some obvious pattern to the messages that would suggest a natural way to split the group. I don't see either indicator being met. If you're having trouble wading through the newsgroup here are a couple suggestions: 1. Look at the features your newsreader supports for reading large newsgroups (threading, killfiles, etc). Perhaps you can filter out messages based upon subject or content (e.g., Windows-related terms like DLL, COM, etc). You might also find it useful to pick a personal "reviewer" and only follow threads in which that person participates. 2. If your newsreader is found wanting, find another one and repeat #1. 3. If you're still SOL, try switching to the mailing list (python-list at python.org) and repeat #1 and #2, replacing "newsreader" with "mail user agent" and "newsgroup" with "mailing list". I find using GNU Emacs' VM mailreader with its threading support sufficient to keep up (and use procmail to sort incoming Python messages into their own inbox). It can still be a bit daunting to see several hundred unread messages if I haven't read the group for a couple days. 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 artymiak at safenet.pl Thu Dec 30 10:50:37 1999 From: artymiak at safenet.pl (Jacek Artymiak) Date: Thu, 30 Dec 1999 15:50:37 GMT Subject: Python - CGI script References: <19991230.3584900@negrita.brunner.org> Message-ID: <386B8595.6F559C82@safenet.pl> > 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. There is an example of just such a program mentioned somewhere on the Python.org site (http://www.python.org ). Jacek Artymiak ------------------------------------------------------------------- See how many people have registered at the Python Users Counter! http://www.wszechnica.safenet.pl/cgi-bin/checkpythonuserscounter.py ------------------------------------------------------------------- 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 lhughes at lakenet.com Tue Dec 28 10:13:25 1999 From: lhughes at lakenet.com (Lee Hughes) Date: Tue, 28 Dec 1999 09:13:25 -0600 Subject: KOALA 0.9.0 released: A database `microsoft access'-4GL-like backend for PostGreSQL References: Message-ID: Is there an HTML-based interface to this system? Paul Sheer wrote in message news:E122Hlq-00031d-00 at cericon.obsidian.co.za... > > SOFTWARE RELEASE ANNOUNCEMENT > ============================= > > KOALA - Version 0.9.0 > --------------------- > > Availability: > ------------- > > ftp://ftp.obsidian.co.za/pub/koala/ > > > What is this package: > ===================== > > This is an object-database / GUI / database-backend / > data-widget / Microsoft-Access thingie for postgres. > > It allows you to create any type of incredibly complicated > interlinked set of database tables without typing a single line of > code. It supports every kind of postgres type corresponding > to every type of gnome/gtk widget. > > You all do it from within a GUI. And the GUI form layouts are also > stored within the database in their own table. > > Koala gives a form and dialog backend to any postgres > database. > > Koala is written in Python with gnome-python (thanks James) for the > interface. > > Koala is distributed under the GNU General Public License. > > > ---------------------------------- > Paul Sheer > > > README.koala>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > > Koala's user reference: > Theory and practical for creating GUI tables. > ============================================= > > > This documentation is by no means a comprehensive description of > what is going on. It is to be read in combination with running > the demos. Between the two, is all of what you may need to know > to create tables and dialogs from within the GUI. > > `Koalii' is the plural of `koala'. > > A dialog is a form with lots of widgets inside it that usually need > filling in. > > What is a koala: A koala is a widget in a dialog that corresponds > to a column in a database table. It is hence a DATA WIDGET > (term used in some circles). The dialog itself corresponds to the > whole table. A particular instance of the dialog corresponds to a > particular row of the table. A koala is also an python object that > knows how to create that widget as well as format that data for > the particular column in SQL. > > Koalii usually hold strings, integers, dates etc - like a persons > name or his shoe size. A `compound' koala is a koala that holds > only an integer where the integer is a reference to a row id of > another table. For instance, a dialog of personal details may > contain a string koala that holds the persons preferred brand of > cologne. It would be better to rather have a table of all brands of > cologne and then just store the particular row id of the brand > instead of storing a string of the full name of the brand (This > allows all brands to be accounted for and makes it impossible to > input a non-existing, but similar sounding brand name into the > widget). The table of all known colognes would have its own > koalii: such as a string containing the name, another for > manufacturer etc. These strings are called sub-koalii of the > integer koala for this cologne. In postgres (the SQL server), row > id's are actually called oid's (Object ID's) and are unique across > the entire database. > > So we may have an oid referring to a person. The person has a > row containing a lot of strings and integers describing them. > One these integers is an oid, and is a reference to a row in > another table of cologne brands. The cologne brand row will > contain strings, integers etc describing it, and possibly some > oid's linked to other tables of manufacturers, ingredients... and > so on. In fact, the manufacturer may contain a list of employees > which link all the way back to the persons table: in this way, the > database can circular. > > A compound koala can hence be displayed in two ways: as a form > with all its sub-koala represented as widgets (checkboxes, > entry widgets etc.); or, when it itself is a sub-koala, as > a widget inside the form of its parent-koala. > > The form has to be laid out neatly so that many sub-koala can be > represented. This is actually quite tricky when you are dealing > with a table of fifty fields. To do this neatly we group > associated koala, displaying each group on a separate page of a > gtk notebook. So for example, a `person' koala would have one > page for his identity (first name, last name, title), and > another page for his address (street, city, country, zip) and so > on. > > In the code, these are called `pages', and there might be only one > of them if there are only three or four fields. > > The form of each page is described by a formatting language, so > that a form of a checkbox with an entry widget above it may look > like this: > ( %Cf / %Exf )f > > The details of these forms are as per the gtk_dialog_cauldron.3 > man page, or the gnome sgml documentation of the > gtk_dialog_cauldron() C function. There is one change however: > You may mostly use %X instead of an actual format specifier, > because the code will test the type of the koala being passed to > that format specifier and then substitute the %X for an > appropriate widget type. An exception is the checkbox (%C) and > radiobutton (%R) widgets. There is no way to tell them apart > because the are both `boolean' koalii. Instead of %X you should > explicitly specify %R or %C as the case may be. > > The complete list of user widgets is as follows: > > koala_string > > This is the most basic type. It is a Gnome entry widget (%Eg) in > the form and a `text' postgres type. > > koala_int > > A number entry widget, and an `int' postgres type. This has > a calculator button to bring up a calculator even if it is > totally inapplicable to the purpose of the data. The > calculator also doesn't work, because it fails to add a grab > or something - Gnome bug. > > koala_float > > Same but for a `float' postgres type. > > koala_floatrange > > Spin button widget and `float' type. > > koala_intrange > > Spin button widget and `int' type. > > koala_text > > Editor widget and `text' type. > > koala_largetext > > Same but with scrollbars. > > koala_bool > > Checkbox or radio button as explained, and a `bool' type. > > koala_date > > Gnome date edit widget and a `date' type. > > koala_datetime > > Gnome date edit widget with 24 hours and a `date' type. > > koala_time > > Three spin buttons with 0-23, 0-59 and 0-59, time sql type. > > koala_minutes > > Two spin buttons with 0-23 and 0-59, time sql type. > > koala_money > > Gtk entry widget with format of 999999.99 and `float' type. > Note: One of the libpg (postgres library) or _pg (python > postgres module) libraries has a bug that causes a segfault > when using the `money' sql type. Hence the money koala now > uses the float type in tables. > > koala_null > > If you read the gtk_dialog_cauldron.3 man page, you will see > that some tokens in the format string require an argument > merely for display purposes (such as a title to a frame). > You can use the null koala for this, which does not > represent a column in the table. > > koala_password > > An entry widget. This is NOT a password entry of the > tradition type where asterisks replace characters. It is for > storing passwords so that they can only be read by trusted > users. The widget has a check button to the right that, when > depressed, decrypts the text and then encrypts it again > when raised. The encryption is done with triple-DES. This > koala might be used, for instance, in a service IT business > that has a database of customers machines that they > administer. Each machine has a root password which you > can safely store using this koala, only the encrypted text is > transfered to the database. The key used to do the > encryption is a hash of a password entered with the > do_passwd() dialog. A few characters of the intermediate > hash can be passed as the second argument to verify that > the typed password is correct. > > koala_mutable > > This is the compound entity explained above. The widget is a > Gnome entry widget that contains text that refers to the > first sub-koala on the first page (i.e. the first column in > the table). For instance a cologne koala would have the > brand name as the first sub-koala, so the brand name would > appear in an entry widget in the parent dialog. Next to the > entry widget are two buttons, [?] and [^]. The first brings > up a list box of possible values that may appear in the > entry widget - it does a search through the table. The > second displays the full dialog of the koala - the notebook > with all its pages. > > Two extra pages appear in the notebook besides the ones > containing sub-koala widgets. The are the `Edit' and > `Access' pages. The Access page allows the user `postgres' > to restrict or allow access to the particular koala in > various ways. > > koala_auto > > This is just like the mutable koala, but the dialog is > automatically created from a pre-existing table. This can be > used in intermediate stages where you quickly want to create > some kind of access to a table, where it doesn't have to > look pretty. Type is `oid' like mutable. > > koala_mutablearray > > This widget is gtk clist - i.e. a table with column headings > for each field. The table has `Add', `New', `Edit' and > `Delete' buttons. The `Edit' button brings up a dialog just > like the mutable koala, from where pages can be added and > edited. New entities that are created within the form editor > will appear as new columns in the table. The sql type is > `text'. This is the one koala that uses more than one row. > The table itself has an extra column `_key'. All `_key' with > the same value belong together. > > koala_mutablestring > > Above we said that compound koala's have an oid value that > indexed a row. Mutablestring is a mutable koalii that has a > string as the index instead of an oid of the row. The string > represents the first koala on the first page - which must be > of sql type `text' - and would be the first column of the > table. Note that there is not yet protection of duplicate > entries. The user should make sure that two rows do not have > the same index. > > koala_mutableint > > This is the same as mutablestring, but with an integer as an > index. > > > > Note on editing pages: > ---------------------- > > When you edit a page from within the GUI, it will not appear > immediately in the notebook. You have to first test the page by > clicking the `Test' button and then `Cancel' the dialog and then > `Cancel' the parent dialog. Only then are the previous form > layouts cleared from memory. > > The method append_mutable_page appends koala that do not appear > in the page table. If koala already exist, no action is taken, > even if the column types or form layout differs. This means that > once you have created a page with append_mutable_page you can > only alter it from within the GUI. Alternatively you can do a > > DELETE FROM table_pagearray WHERE _key = 'my_table'; > > Which will clear out the form and reference to any koalii. Stale > (unlinked) koalii from this page will remain in > table_entityarray, but these may be ignored. > > > Note on date style: > ------------------- > > Postgress outputs dates as 4/28/1984 or 28/4/1984 depending on > the locale. I force my date to european style (28/4/1984) by > using, > > postmaster -o -e ... > > in my init script (see postmaster(1) and postgres(1)). If you > use non-european style, set, > > european_date_style = 0 > > in object_bases.py. This has nothing to do with the way that the > date will display in the widget, which is has to do with Gnome > and not with me. > > Be absolutely sure about what date style postgres is outputting, > by actually creating a table with dates in it and doing a SELECT > on them. Koala cannot autodetect this and will read the date > incorrectly. > > > Note on quotation marks: > ------------------------ > > At the moment, the python code replaces all ' with ` before > committing any string value to a table. > > > How to jump in and create a database: > ------------------------------------- > > There are two ways: one is to just run extended_bases.py as the main > program (i.e. > > > su postgres > python extended_bases.py > > > ) and then begin creating tables with the `New' button. Follow this > example as a tutorial. Here we create a table of motor vehicles. > > 0. Postgres should be set up so that a user `postgres' can access > a database called postgres and create and delete tables. > See the postgres documentation about installing and > configuring postgres. > > 1. run > su postgres > python extended_bases.py > > 2. Click on `New' > > 3. Enter `table_vehicles' > > 4. A notepad will appear with two pages: `Edit' and `Access' > Raise the `Edit' page and click on `New'. > > 5. Enter `Identity' on the Title page, `100' in the `Order' > field on the `Form' page. Now enter your form in the text > area: > ( (Registration Number:) %Xxf )f / > ( (Make:) %Xxf )f / > ( (Model:) %Xxf )f / > ( (Year:) %Xxf )f > It would be wise to read the full gtk_dialog_cauldron(3) > man page. Note that newlines are completely ignored. > > 6. Now raise the `Koalii' page and read the message their. > > 7. Click on `Ok' > > 8. Click on `Edit' and go back to the `Koalii' page. > > 9. Click on `New' in the `Koalii' page. > > 10. A Koalii dialog will appear, enter: > `Registration Number' in the `Title' field, > `10' in the `Order' field, > `string' in the `Type' field, > `ident_registration' in the `Table column' field, > and leave the rest blank. > > 11. Now repeat steps 9 and 10 for each of make, model and > year. In each case, the `Table column' MUST be different > and the `Title' field must be something descriptive. > The `Order' field should indicate the order that the > koalii appear in the form, preferably with large gaps > in case you need to add new ones later, eg 20 for make, > 30 for model, and 40 for year. > > 12. In the `Koalii' page of the `Pages' dialog, check > A: that you have four entries > B: that each entry has a different Column field > C: that each entry has a properly descriptive Title field > D: that each entry has a type of `string' > E: that the order of the entries matches the order within > the form > > 13. Hit `Ok' to go back to the `Edit' page of the `table_car' > dialog. > > 14. You will notice that under `Enabled' is an `f'. Click on > `Test' to test the page and then `Close' the test dialog. > If there was something wrong with the form string, an > appropriate error message may be printed (see > README.patch_first). You may also get error > messages that are very cryptic. Don't scratch your > head trying to understand them, just double check all > your koalii and your form string and try to make the > page simpler. > > 15. `Cancel' the `table_car' dialog. > > 16. You will now notice a new button on the main menu: > `table_car'. click on this button. > > 17. You can continue to add other pages to the notebook. > Though do not ever delete pages and then reuse column > names. Postgres lacks the `DROP COLUMN' feature (its > also dangerous to use in this case) so stale columns > will hang around. You can drop them by recreating > the table, but this must be done with psql on the > command line. > > > > Other way to create a table: > ---------------------------- > > The other way to create a table is to program it in python. > Here is a python script that does the same: > > #!/usr/bin/python > > from extended_bases import * > > class koala_car (koala_mutable): > def widget_create (self, *args): > self.append_mutable_page ("Identity", > "( (Registration Number:) %Xxf )f /" > "( (Make:) %Xxf )f /" > "( (Model:) %Xxf )f /" > "( (Year:) %Xxf )f", > (("string", "ident_registration", "Registration Number", ""), > ("string", "ident_make", "Make", ""), > ("string", "ident_model", "Model", ""), > ("string", "ident_year", "Year", ""))) > return koala_mutable.widget_create (self) > > def do_table (heading, table): > a = koala_mutable ("", heading, "", db, table) > a.widget_create () > s = search_dialog ("Search: " + heading) > if s: > a.list (heading, s[0]) > > db = initialise_bases ("postgres", "localhost", 5432) > init_mutable_table (koala_car, db, "table_car") > do_table ("Cars", "table_car") > > --------- > > Above, the last arguments were always left blank (i.e. ""). > These are the default values for the field. In the above cases > there is no entry that is more likely than any other, so we > left them blank. > > Now that the form has been created, goto the `Access' page and add > some groups so that others besides the postgres login can use > the table. You must first create users and groups as explained in > README.groups. You need only create one group. > > Then edit the `Identity' page again and goto `Access'. Here again > you must add a group to the list. > > That concludes a trivial database. To create a complex database > with links requires very little more effort... > > Here we are going to add an owner to the car. First we need to > create a `table_person' table. (There may already be one as > an example). > > Add a new page to your car notepad like this: > Title: Owner > Form: ( (Owner:) %Xxf )f / ( (Date of purchase:) %Xxf ) > Entities: > > Title Order Type Column Table > --------------- ------- --------------- --------------- ------------ > Owner 10 mutable owner_owner table_person > Date Purchased 20 date owner_date > > > The entry widget next to `Owner' will have two buttons to select > from a list of people and to add a new person to the list, > respectively. You should beware of adding duplicate entries > because these are perfectly allowable with a mutable koala, but > may create confusion in the database. If there would never be a > duplicate entry for the table you have created, then you can use > mutablestring instead of mutable which indexes the table by the > first column and does not allow duplicate entries. For > table_person, the first column contains only the last name of > the person. Since there can be many people with the same last > name, mutable is used instead of mutablestring. > > Note that the mutable koala does not automatically insert a > default value for a new instance of the dialog. Mutablestring > does insert such a value if defined. > > ---------- > > > -- > -----BEGIN PGP PUBLIC KEY BLOCK----- > Version: 2.6.3i > > mQCNAzdiRpAAAAEEANPUPC/Lrs4OCJOjWaIWaCYTzTIY1p73uPY+8ZOJH5fc4QNp > IAX+EFQ/yZ3RMOLg8yy++HufzBwDoePO4W0MKwyVFCcNIIjsY6JCXWdbpQXsY1LL > OASlGexQnEQ4mfc7ThOAKWSgPyiMv5vDJ6S0EL8rdIFL7fVv56BAxnN042FRAAUR > tCJQYXVsIFNoZWVyIDxwc2hlZXJAb2JzaWRpYW4uY28uemE+iQCVAwUQN2JGkKBA > xnN042FRAQF5CAP/Y0TaguqCpYiTEBHxZPpT/dliInVRBzryi4gdlgX6CCLDRRGH > ATP4ac8aiATegc4ev4+vcdn4fBwc6fQ2AP6hd25ZI93vShxztM/bQlGWy0zp79Uo > +69uGdJhdvgYpIsTCqppM/yjeXAJEqq5TG2Gy4pqHY235rspmeA/fX7kgIo= > =aX4m > -----END PGP PUBLIC KEY BLOCK----- > > Cellular . . . +27 83 604 0615 . . . . Land . . . +27 21 761 7224 > Obsidian Systems . . . . Linux installations, support, networking > info at obsidian.co.za . . . . . . . . . . Tel . . +27 21 448 9265 > http://www.obsidian.co.za . . . . . . . Jhb . . . +27 11 792 6500 > L I N U X . . . . . . . . . . . . . The Choice of a GNU Generation > > > From gerrit.holl at pobox.com Fri Dec 3 11:31:53 1999 From: gerrit.holl at pobox.com (Gerrit Holl) Date: Fri, 3 Dec 1999 17:31:53 +0100 Subject: Mailinglist about Dutch Python users group. Message-ID: <19991203173153.A7422@stopcontact.palga.uucp> Hello, I've made a mailinglist where the Dutch users can discuss about a Dutch Python users group, because there are so many Dutch users who'll never go to a Python conference because it's so far away. If you're interested, send an email to Majordomo at nl.linux.org with in the body: subscribe python regards, Gerrit. -- "The IETF motto is 'rough consensus and running code'" -- Scott Bradner (Open Sources, 1999 O'Reilly and Associates) 5:29pm up 5:03, 15 users, load average: 1.22, 0.79, 0.73 From zsoltman at my-deja.com Thu Dec 16 16:43:22 1999 From: zsoltman at my-deja.com (zsoltman at my-deja.com) Date: Thu, 16 Dec 1999 21:43:22 GMT Subject: exceptions? References: <8388m7$1ii$1@nnrp1.deja.com> Message-ID: <83bmdq$i8a$1@nnrp1.deja.com> Mike, I noticed someone pointed you to some good documentation. The most basic is try: do_something() catch do_something_else() The problem is, what if you don't want your program to stop, but you would like to capture the stack trace for future analysis. I just recently figured out how to do this, so I will share. Keep in mind, there are probably more eloquent ways of handling this. sys.exc_info()[2] is the traceback object that you can capture at error time (or any time you want) Printing it out is a little screwy, but not that difficult. ______________________________________________________________ Example: def HandleTraceBack(excinfo2,msg): import traceback tb=traceback.format_list(traceback.extract_tb(excinfo2)) for each in tb: msg=msg + each raise ValueError,msg ####In the main program (or other functions) use import sys try: do_function() except: HandleTraceBack(sys.exc_info()[2], '****ERROR attempting do_function\n') ___________________________________________________________ In article <8388m7$1ii$1 at nnrp1.deja.com>, moonseeker at my-deja.com wrote: > Hi! > > Could anyone please point me to a good explanation how exceptions can be > handled, new created and used, how I can check for a special exception and so > on...? > > Thanks, > Mike > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From ngps at madcap.dyn.ml.org Wed Dec 22 09:55:08 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 22 Dec 99 14:55:08 GMT Subject: How to access Oracle? References: <945811978.70442@sj-nntpcache-4.cisco.com> <3860BA0E.87FAE4BA@bam.com> Message-ID: <3860e64c.0@news.cyberway.com.sg> According to Bill Scherer : > You want DCOracle: > http://www.zope.org/Products/DCOracle I use CPython on FreeBSD. Some Linux. I am rather tempted to embed a Java VM into the CPython interpreter just so I can use all those type 4 JDBC packages. ;-) Anyone done this before? -- Ng Pheng Siong * http://www.post1.com/home/ngps From boud at rempt.xs4all.nl Mon Dec 13 16:36:20 1999 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 13 Dec 1999 21:36:20 GMT Subject: Python suitability References: <38549DEA.B0157D0@iqsoft.hu> <38556449.903DA931@iqsoft.hu> Message-ID: <833osk$52j$1@news1.xs4all.nl> >> From: >> boud at rempt.xs4all.nl (Boudewijn Rempt) >> >> If you really need to use a variety of databases, then you probably >> can't rely on stored procedures/packages to do the server-side work, >> because there isn't a database where those work in the same way. And >> even so, support for, say Oracle packages, is skimpy outside Oracles >> own tools. I'm going to install Oracle next week to try whether they >> can be accessed from Python, though. >> >> You really need some middle man, if you go the various databases >> route, and designing decent middleware is difficult, in my experience. >> > Do you have a more precise idea? I am also interested in using middlemen > (middleware). I evaluated Fnorb and found it perfect. I haven't done anything with Fnorb yet - it's an orb, isn't it?, but what I mean is that you've got to have some part to your application that ties together all the information and works with it - whether that is to calculate discounts, to determine customer profiles or calculate the dioxin contents of a chicken. When you write that part in a proprietary database, you lose database independence. Just using an ORB doesn't solve it - you still need to write the code and determine where it resides. Making it a separate Python application your interface talks to using Fnorb (or a webserver) could work very well, I guess. >> >> I don't think TK is really suitable - > I am very sad! Then why there are any effort to support TK by Python? I don't know ;-). I think Tk has had it, it's ugly, hasn't got a lot of features and is difficult to use effectively - in my experience, at least. > I used Qt (but not PyQt) and it is a fantastic library, not only GUI but > general purpose C++ object library (or rather framework). I would go for > it. It all depends on the application you need - if it's an e-commerce app, you can't use Qt, I fear. But check the bindings out, by all means, they are extremely neat! >> >> I do find Zope a bit slow - even when I browse a Zope database on a >> machine on my local network. >> > Again I am very sad! I wanted to start a new department in our company > developing ecommerce applications. I am on the point of selecting a > development environment. Untill now I would voted for Apache+SSL + Zope > 2.1, but I am also thinking of using Apache+SSL + PHP or ApacxheSSL + > mod_perl. > Do you not think Zope would be a good platform for our projects? Zope is perfect for e-commerce applications - it's a domain it's well suited for, especially if you don't try to imitate a local app interface with it. That's a matter of raising wrong expectations. If a user sees a picture that resembles the widgets his common apps are built with, he will expect the same responsiveness. And you won't get that from a webserver, not even on the local intranet. But it really depends on the project, on the type of app you're making. > Do you have more arguments for not taking WxPython enterprise-ready? The > lack of database-ready widgets does not bother me, as I access databases > through CORBA (Fnorb) servers. Well, it's multi-platform, but requires a non-standard version of GTK to build on Unix - meaning that simple-minded users have to jump through all kinds of hoops to install your app. And I somehow don't think Windows users are all that ready to install another extra library - but if your group of users can support it, then it's worth trying. > How many time (days or weeks) do you think is needed for a good C++ > programmer to become a good Python programmer? Not many weeks, a month or so, I guess - but that's just a guess. I've never seen more than two good C++ programmers in the same room! So, if you've got a bunch of them, hold them tight and don't let them go. They might baulk if they have to use a sissy script language, though ;-). > We have at our company a department using Microsoft tools. They produce > loss for five years. I am a bit afraid of using any Microsoft tool. > However, our department uses no Microsoft development tools at all: we > produce outstanding revenues for five years. Microsoft tools create revenue > only for Microsoft! It's only a tool... Look closely at the development process, and the quality of the personnel. If your department is staffed with people who can work with Qt and C++, it's no small wonder they can write code in time, in budget and with a good quality - most VB shops are staffed with beginning programmers, and inexperience costs money. >> >> I've never seen C++ or Java used for large-scale database applications. >> Most projects I've seen use Oracle Forms, Visual Basic or Powerbuilder >> or things like that. > I was also involved several of this kind of projects: never again! I would > never use again any proprietary language or development tool. Oh, horses for courses - if you want that e-commerce application running within half a year, I'd go for Oracle 8i, and get it over with. Sure, it's proprietary as hell, but it works. Or Zope, but Oracle has a gentler learning curve... Though that's not saying much. But there are very, very nice sites built with Zope. The KDE news site: www.kdeforum.org is responsive, attractive and a good all-round example, I think. > This sounds interesting! I am also interested in PyQt. Try it - it's free ;-). http://www.river-bank.demon.co.uk/software/ is the address for the bindings. > This is quite serious to be only a hobby project. Several corporations > would pay a lot of money having a programmer being capable of designing and > implementing an application using this architecture. > I guess yoiu have to create VB programs during work hours! Poor man, I > would not do that! You should change your employer! I'm not saying I can pull it off! I'm just _trying_ to get it to work. I know it's the right way to go, though. I've been through enough client=server and three-tier debacles to have finally found the Right Way. >> My bosses don't want >> another programming tool in the shop, after the debacle with VB 5.0. > Your bosses may be complete idiots! VB5 and any other VB are rubish! I can see their point. They've just made a mistake that cost about five million dollars, a mistake they need some seriously expensive external consultants to force them to admit they made it, and they are very, very shy of making another decision. Better say it's a no go. What doesn't happen can't go wrong... > A company using VB would not be a competitor for us. I am sure we are not > the only company focusing on leading edge technology. My company isn't exactly innovative... Nor competritive. After the recent debacle the mantra is 'we're not a software company, we don't have to strive for excellence in systems development, it's not our core business'. -- Boudewijn Rempt | http://denden.conlang.org From hniksic at iskon.hr Tue Dec 21 03:43:07 1999 From: hniksic at iskon.hr (Hrvoje Niksic) Date: 21 Dec 1999 09:43:07 +0100 Subject: mxODBC - paramstyle - how to change default References: Message-ID: <9t9ln6o65wk.fsf@mraz.iskon.hr> "Marshall" writes: > I am enjoying using Marc Lemburg's mxODBC modules for database work. > The paramstyle setting is set to 'qmark' by default, how can a > newbie like me change this setting? Or is this not a really > changable letting? The paramstyle thing is not really settable AFAIK. The idea is that a piece of user code intended to be portable can check the value of paramstyle and form the queries related to that. From phil at geog.ubc.ca Thu Dec 9 13:49:46 1999 From: phil at geog.ubc.ca (Phil Austin) Date: 09 Dec 1999 10:49:46 -0800 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 at netcom.com (Aahz Maruch) writes: > In article <14411.53378.154350.793014 at weyr.cnri.reston.va.us>, > Fred L. Drake, Jr. wrote: > >Mark Jackson writes: > >> > >> And Fortran. Don't forget Fortran. > > > > I guess I got lucky; having never learned Fortran, I don't have to > >forget it. ;-) > > 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. > -- > --- Aahz (@netcom.com) > Since I've done fewer than my normal quota of futile things this week, I thought I'd post to remind people that: 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: ftp://ftp-icf.llnl.gov/pub/OBF90/ 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 a working implementation of the export keyword, and allows us to compile a 100 line Blitz++ program in less than 5 minutes on a 233 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. Regards, Phil -- Phil Austin Associate Professor Atmospheric Sciences Programme Department of Earth and Ocean Sciences Geography #217 University of British Columbia 1984 W Mall Vancouver, BC V6T 1Z2 CANADA From fredrik at pythonware.com Tue Dec 14 03:25:20 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 14 Dec 1999 09:25:20 +0100 Subject: Need help with Tkinter References: <8342a8$1td$1@nnrp1.deja.com> Message-ID: <011201bf460d$3a8d4840$f29b12c2@secret.pythonware.com> rodzilla2000 at my-deja.com wrote: > Change the "Hello World" button a "Add Exit Button" that would put > another button on the screen to allow exiting the program. > > Add the additional exit button... > > Here's the code: > > =========START OF CODE > # Button test... > > import sys > from Tkinter import * > > #main routine > def main(): > root=Tk() > btnAddButton=Button(root) > btnAddButton['text']='Add Exit Button' > btnAddButton['command']=subAddButton(root) # See below this *calls* the subAddButton, and assigns the return value as the button command. Tkinter should really complain about that, but it doesn't -- after all, your function might be returning a valid Tcl command... try changing: > btnAddButton['command']=subAddButton(root) # See below to: def cb(root=root): subAddButton(root) btnAddButton['command'] = cb also consider using keyword syntax to initialize the widgets. see http://www.pythonware.com/library/tkinter/introduction/widget-configuration.htm for more info. > btnAddButton.pack() > > #start mainloop > root.mainloop > > def subAddButton(parent): > btnExitButton=Button(parent) > btnExitButton['text']='Exit Program' > btnExitButton['command']=subExit #see below > btnExitButton.pack() > > def subExit(): > sys.exit(0) > > > #execute the main routine > main() From bitbucket at isomedia.com Thu Dec 30 18:34:42 1999 From: bitbucket at isomedia.com (Eugene Goodrich) Date: Thu, 30 Dec 1999 23:34:42 GMT Subject: Python Database Connectivity References: <386AA8C1.EAD7DD3B@exceptionalminds.com> <84ea64$pkt$1@nntp8.atl.mindspring.net> Message-ID: <386bebca.157198229@news.isomedia.com> Or use ADO COM objects, included with Microsoft IIS, I believe. But I can't think of a much lower-performance way for local databases... :) -Eugene On 30 Dec 1999 00:49:08 GMT, aahz at netcom.com (Aahz Maruch) wrote: >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! import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==') From wtopa at dmcom.net Sat Dec 11 10:57:00 1999 From: wtopa at dmcom.net (Wayne Topa) Date: Sat, 11 Dec 1999 10:57:00 -0500 Subject: Error confusing a newbie In-Reply-To: ; from Keith Dart on Sat, Dec 11, 1999 at 02:39:29AM -0800 References: <19991210100320.B18389@dmcom.net> Message-ID: <19991211105659.A23924@dmcom.net> Subject: Re: Error confusing a newbie Date: Sat, Dec 11, 1999 at 02:39:29AM -0800 In reply to:Keith Dart Quoting Keith Dart(kdart at pacbell.net): >| On Fri, 10 Dec 1999, Wayne Topa wrote: >| >| Your script is definitely being interpreted by a command shell, and not >| the python interpreter. Why this is happening is hard to tell from the >| information given. In any case, that is not really a python >| problem. I think it may a problem concerning python, but it might be that I I am doing something wrong, again. Note: VT2 root-Deb-Slink:/program/Python# nicinfo.py eth0: sent 82658432 bytes; received 14218741 bytes ppp0: sent 57164 bytes; received 113488 bytes dummy0: sent 0 bytes; received 0 bytes lo: sent 25350775 bytes; received 25350775 bytes VT2 root-Deb-Slink:/program/Python# grep /usr/bin nicinfo.py #!/usr/bin/env python VT2 root-Deb-Slink:/program/Python# platform.py Linux-2.2.12-i586-with-debian-2.1 VT2 root-Deb-Slink:/program/Python# grep /usr/bin platform.py #!/usr/bin/python VT2 root-Deb-Slink:/program/Python# 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')' VT2 root-Deb-Slink:/program/Python# grep /usr/bin net_time.py #!/usr/bin/python And changing it back to /usr/bin/env python, doesn't work either. VT2 root-Deb-Slink:/program/Python# 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')' VT2 root-Deb-Slink:/program/Python# grep /usr/bin net_time.py #!/usr/bin/env python >| >| I notice you are invoking the script without a "./". That is, as Yes, I am guilty! Have been doing this for years and only got burned once :-( , so far. >| >| Perhaps you have another net_time.py script that is in your PATH? >| No other net_time.py, and I have, as you see, moved it over with all my other python scripts, now. I only 'wish' it was something as simple as that. nicinfo.py and platform.py are in this Dir, are the only copies on the system. I don't understand 'what' shell is giving me the "/var/spool/mail/DateTime" error, when that is not anywhere in my program? 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 -- Computers can never replace human stupidity. _______________________________________________________ From pinard at IRO.UMontreal.CA Fri Dec 3 17:49:30 1999 From: pinard at IRO.UMontreal.CA (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 03 Dec 1999 17:49:30 -0500 Subject: indentation In-Reply-To: thamelry@vub.ac.be's message of "3 Dec 1999 21:35:02 GMT" References: <828n3e$8kp$1@nnrp1.deja.com> <828s7g$d4f$1@mach.vub.ac.be> <19991203211232.A11045@stopcontact.palga.uucp> <829d26$s4d$1@mach.vub.ac.be> Message-ID: thamelry at vub.ac.be (Thomas Hamelryck) writes: > : 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? > Funny, that doesn't bother me one bit. [...] Note that `self' is nothing more than a convention: you may use any name, as long as you use it consistently within the routine. Just write things like: class A: def __init__(I_will_never_forget_that_variable_anymore): ... very consistently in all your things, and soon, I'd bet you will feel strange whenever you will see a mere '()' as an argument list to a class def! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From bitbucket at isomedia.com Wed Dec 29 13:33:59 1999 From: bitbucket at isomedia.com (Eugene Goodrich) Date: Wed, 29 Dec 1999 18:33:59 GMT Subject: Super Tuples References: <386745A6.9B671DBF@prescod.net> <3869337E.996B9BAE@prescod.net> <38693e89.14008172@news.isomedia.com> <386A1037.C6D458B3@prescod.net> Message-ID: <386a43e3.48679477@news.isomedia.com> Well, that does answer my question. I guess I'm on the side for immutable dictionaries, too, but I'll be at the back of the room for that one because I'm wary of asking for pandora's box to be opened. (I really don't know how tough it would be, you see.) 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) ->>> import types class tuplish: def __init__ (self): self._data = ['alpha', 100, 'charlie'] self._props = ['header', 'body', 'footer'] self._propMap = {} # appologies for any hurt eyes on this next part. It _does_ separate the hide from the cat, tho. for iCounter in range (len (self._props)): (sProp, unkVal) = (self._props [iCounter], self._data [iCounter]) exec 'def fFunc (self, unkVal): self.%s = unkVal' % sProp fFunc (self, unkVal) exec "self._propMap [%d] = 'self.%s'" % (iCounter, sProp) def __len__ (self): return (len (self._data)) def __getitem__ (self, iIndex): return (self._data [iIndex]) def __setitem__ (self, iIndex, unkNewVal): self._data [iIndex] = unkNewVal exec ('def fFunc (self, unkVal): %s = unkVal' % self._propMap [iIndex]) fFunc (self, unkNewVal) return (unkNewVal) def __str__ (self): return (str (tuple (self._data))) def foo (tTuple): print 'foo will now rifle through what it thinks is a tuple...' for iCounter in range (len (tTuple)): print '\t%d: %s' % (iCounter, tTuple [iCounter]), print for unkThingie in tTuple: print '\t', unkThingie, # test the class o = tuplish () print 'Converted to tuple: %s' % str (tuple (o)) print 'Making some changes...' for iCounter in range (len (o)): unkVal = o [iCounter] if type (unkVal) == types.IntType: unkVal = unkVal * 3.145 else: unkVal = unkVal + '!' o [iCounter] = unkVal print 'As string: %s' % o print 'Methods:' for sProp in dir (o): if sProp [0] == '_': continue print '\t.%s: \t%s' % (sProp, str (eval ('o.%s' % sProp))) foo (o) <<<- -Eugene P.S. please consider the above a prototype, not something I would necessarily be proud of using. I'm sure keeping each datum in 2 places and creating temporary functions with exec () all the time is not a good thing... :) On Wed, 29 Dec 1999 08:44:23 -0500, Paul Prescod wrote: >Eugene Goodrich wrote: >> >> When I started in Python, my PyMentor described tuples as immutable >> lists. When they start acting like much more than that, isn't it time >> to use an object? > >I agree that tuples in Python are often used merely as immutable lists. >This bothers me for several reasons: > > * that isn't what "tuple" means in mathematics. In most mathematics >EVERYTHING is immutable. Tuples and lists are still distinct > > * why does Python need an immutable list type but not an immutable >dictionary? > > * isn't immutability more a property of where an object is used than >the objects actual type? For example, don't you sometimes want to pass a >list to a function but guarantee that the list won't be modified? > > * it is because of this abuse that the "one-item tuple" problem arises >so often. There is no such problem in mathematics because a one-item >tuple does not make sense. > >In Python world we most often use tuples as mathematicians do. Really, a >tuple is supposed to be a collection of things where the sender and the >recieiver have agreed on the number of items in advance, and every item >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 . > >If you use tuples as mathematicians do then single-item tuples can never >arise because senders and recievers would never agree on a "protocol" >(used loosely) that involves 1 length tuples (why use a tuple!). > > Paul Prescod > import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==') From sendzimir at earthlink.net Tue Dec 28 00:16:53 1999 From: sendzimir at earthlink.net (Alexander Sendzimir) Date: Tue, 28 Dec 1999 00:16:53 -0500 Subject: why? References: Message-ID: <386847C5.3CEB812F@earthlink.net> What type of languages do you currently employ? From ivanlan at callware.com Thu Dec 16 16:11:53 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 16 Dec 1999 14:11:53 -0700 Subject: Newbie Getopts Question References: <385952D1.AB04A9FF@coastalnet.com> Message-ID: <38595599.B8CA2A63@callware.com> Hi All-- "Andrew N. McGuire" wrote: > > 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. > Give my getargs.py module a try: http://www.pauahtun.org/ftp.html You may like it, and it is pretty well documented. (Or, you may hate it. Some people do.) There are other modifications and extensions out there, too; if you hate them all, write your own;-) -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 wware at world.std.com Fri Dec 31 23:10:18 1999 From: wware at world.std.com (Will Ware) Date: Sat, 1 Jan 2000 04:10:18 GMT Subject: fun with stock quotes Message-ID: I recently discovered that Yahoo's stock-quote-serving web page is now offering historical stock data in machine-friendly form. The following scripts will pull in a bunch of stock data and format it as a C module. Then you can back-test any silly investment algorithms you come up with. Nerdy greedy fun for the whole family. --------------------- begin ------------------------------------ #!/bin/sh # This is a shell archive (produced by shar 3.50) # To extract the files from this archive, save it to a file, remove # everything above the "!/bin/sh" line above, and type "sh file_name". # # made 01/01/2000 04:02 UTC by wware at world # Source directory /tmp/var-tmp/wware/foo # # existing files will NOT be overwritten unless -c is specified # # This shar contains: # length mode name # ------ ---------- ------------------------------------------ # 397 -r--r--r-- Makefile # 3182 -rw------- buildc.py # 6856 -r--r--r-- stockp.c # 194 -r--r--r-- stocks.h # # ============= Makefile ============== if test -f 'Makefile' -a X"$1" != X"-c"; then echo 'x - skipping Makefile (File already exists)' else echo 'x - extracting Makefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'Makefile' && CFLAGS = -Wall -O2 -I/usr/include/python1.5 all: stockp.so X .SUFFIXES: .c .o .so X .c.o: X gcc $(CFLAGS) -c -o $@ $(@:.o=.c) X stockp.so: stockp.o stocks.o X gcc $(CFLAGS) -shared -o stockp.so stocks.o stockp.o X stockp.o: stockp.c stocks.h stocks.o: stocks.c stocks.h X clean: X rm -f *.o *.so stockp* X tgz: X (cd ..; tar cf - stocks/*.c stocks/Makefile stocks/*.h \ X stocks/foo.py | gzip > stockc.tgz) SHAR_EOF chmod 0444 Makefile || echo 'restore of Makefile failed' Wc_c="`wc -c < 'Makefile'`" test 397 -eq "$Wc_c" || echo 'Makefile: original size 397, current size' "$Wc_c" fi # ============= buildc.py ============== if test -f 'buildc.py' -a X"$1" != X"-c"; then echo 'x - skipping buildc.py (File already exists)' else echo 'x - extracting buildc.py (Text)' sed 's/^X//' << 'SHAR_EOF' > 'buildc.py' && '''The other day I discovered that quote.yahoo.com now offers historical stock data. Delightful! The obvious next thing was to write a Python class that fetches the historical data off the web and tries to make some money with it. My feeble attempt follows. This is not an endorsement for any investment style or particular investment. Your money, and your innate God-given stupidity, are entirely your own.''' X import urllib, string, normalDate, math, regex, sys, os X masterList = [ X # tech stocks X 'MSFT', 'AMZN', 'INTC', 'RHAT', 'DELL', 'GTW', X 'CSCO', 'AAPL', 'AOL', 'COMS', 'CPQ', 'LCOS', 'LU', X 'ORCL', 'SUNW', 'TXN', 'YHOO', X # single-letters and blue chips X 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', X 'J', 'K', 'L', 'N', 'O', 'P', 'R', X 'U', 'W', 'X', 'Y', 'Z', X # Dow Jones stocks X 'AA', 'AXP', 'T', 'BA', 'CAT', 'CHV', 'KO', X 'DIS', 'DD', 'EK', 'GE', 'GM', 'GT', 'HWP', X 'IBM', 'IP', 'JNJ', 'MCD', 'MRK', 'MMM', 'JPM', X 'MO', 'PG', 'S', 'TRV', 'UK', 'WMT', X # biotech X 'AFFX', 'BIOM', 'CRA', 'ENMD', 'HGSI', X 'MATX', 'MLNM', 'RGEN', 'SAFS', 'DNA', 'GENE', X 'INCY', 'GLGC', 'PFE', X 'AVXT', 'CTIC', 'CRXA', 'GZMO', 'IDPH', X 'ILXO', 'ISIP', 'RZYM', 'SUPG', 'TGEN', 'VICL', X # retailers, general interest X 'BBY', 'COST', 'UPS', 'HD', X ] X # just do a quick test for now masterList = masterList[:12] X def fetchRange(symbol, first, last): X '''go to Yahoo and fetch a range of historical stock X data, where 'first' and 'last' are normalDates''' X key = (first, last) X url = 'http://chart.yahoo.com/table.csv?s=%s' \ X '&a=%d&b=%d&c=%d&d=%d&e=%d&f=%d&g=d&q=q&y=0&z=%s' \ X '&x=.csv' % (symbol, X first.month(), first.day(), first.year(), X last.month(), last.day(), last.year(), X symbol) X lst = [ ] X for x in urllib.URLopener().open(url).readlines()[1:]: X x = string.split(x, ',') X date, closingPrice = x[0], x[4] X date = string.split(date, '-') X date[0] = eval(date[0]) X date[2] = eval(date[2]) X closingPrice = eval(closingPrice) X if date[2] > 90: year = date[2] + 1900 X else: year = date[2] + 2000 X month = ['Jan', 'Feb', 'Mar', X 'Apr', 'May', 'Jun', X 'Jul', 'Aug', 'Sep', X 'Oct', 'Nov', 'Dec'].index(date[1]) + 1 X date = normalDate.ND(year * 10000 + X month * 100 + date[0]) X lst.append(date, closingPrice) X lst.reverse() # Yahoo gives reverse time order X if len(lst) == 0: X raise 'ouch' X return lst X start = normalDate.ND(19950101) finish = normalDate.ND() # today X print '#include "Python.h"' print '#include "stocks.h"' print X sizes = { } for s in masterList: X L = fetchRange(s, start, finish) X print 'static struct closing_price %s_dat[] = {' % s X sizes[s] = len(L) X for (x, y) in L: X print ' {%d, %f},' % (x, y) X print '};' X print X print 'struct stock_data_entry stock_data[] = {' for s in masterList: X print ' {"%s", %s_dat, %d},' % (s, s, sizes[s]) print ' {NULL, NULL, 0}' print '};' SHAR_EOF chmod 0600 buildc.py || echo 'restore of buildc.py failed' Wc_c="`wc -c < 'buildc.py'`" test 3182 -eq "$Wc_c" || echo 'buildc.py: original size 3182, current size' "$Wc_c" fi # ============= stockp.c ============== if test -f 'stockp.c' -a X"$1" != X"-c"; then echo 'x - skipping stockp.c (File already exists)' else echo 'x - extracting stockp.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'stockp.c' && /* Python code for interfacing the big honkin' historical stock data library */ X #include #include #include "Python.h" #include "stocks.h" X static PyObject *StockpError; X static PyObject * symbolList(PyObject *self, PyObject *args) { X struct stock_data_entry *p; X PyObject *q; X if (!PyArg_ParseTuple(args, "")) X return NULL; X q = PyList_New(0); X for (p = stock_data; p->name != NULL; p++) X PyList_Append(q, Py_BuildValue("s", p->name)); X return q; } X /* Maybe it makes sense to rewrite "lookup" as a __getitem__ method. X * That could be done in a Python wrapper, don't bother here. X */ X static struct closing_price * last_price_before(struct closing_price *array, X int arraysize, X int date) { X struct closing_price *q; X q = array + arraysize - 1; X while (1) X { X if (q->date == date) X return q; X if (q == array) X return NULL; /* stock didn't exist at that date */ X /* handle weekends and holidays, pick up the last X * closing price prior to the date arg X */ X if ((q-1)->date <= date && q->date > date) X return q - 1; X q--; X } } X static PyObject * lookup(PyObject *self, PyObject *args) { X char *symbol; X int date; X struct stock_data_entry *p; X struct closing_price *q; X PyObject *nd; /* this is a normalDate */ X if (!PyArg_ParseTuple(args, "sO", &symbol, &nd)) X return NULL; X date = PyInt_AsLong(PyObject_GetAttrString(nd, "normalDate")); X for (p = stock_data; p->name != NULL; p++) X if (strcmp(p->name, symbol) == 0) X { X q = last_price_before(p->data, p->size, date); X if (q == NULL) X { X PyErr_SetString(StockpError, "no data for that date"); X return NULL; X } X else X return Py_BuildValue("f", q->price); X } X PyErr_SetString(StockpError, "no such stock symbol"); X return NULL; } X static int subRange(struct stock_data_entry *p, X int first, int last, X struct closing_price **first_closing_price, X struct closing_price **last_closing_price) { X int i; X struct closing_price *q = p->data; X if (last < first) X return 1; /* bad range */ X if (last < q[0].date) X return 2; /* range is before all stock data */ X if (first > q[p->size-1].date) X return 3; /* range is after all stock data */ X /* discard anything off the end of the range */ X if (first < q[0].date) X first = q[0].date; X if (last > q[p->size-1].date) X last = q[p->size-1].date; X /* Find first in the array. If first lands on a weekend or X * holiday, pick the next valid date. If you fall off the X * end of the array, return an error code. X */ X for (i = 0; ; i++) X { X if (i == p->size) /* fell off the end of the array */ X return 3; X if (q[i].date >= first) X break; X } X *first_closing_price = &p->data[i]; X for (i = p->size - 1; ; i--) X { X if (i == -1) /* fell off the end of the array */ X return 2; X if (q[i].date <= last) X break; X } X *last_closing_price = &p->data[i]; X return 0; /* no error */ } X static PyObject * fetchRange(PyObject *self, PyObject *args) { X char *symbol; X int first, last; X struct stock_data_entry *p; X struct closing_price *s, *t; X PyObject *r; X PyObject *nd1, *nd2; X if (!PyArg_ParseTuple(args, "sOO", &symbol, &nd1, &nd2)) X return NULL; X first = PyInt_AsLong(PyObject_GetAttrString(nd1, "normalDate")); X last = PyInt_AsLong(PyObject_GetAttrString(nd2, "normalDate")); X for (p = stock_data; p->name != NULL; p++) X if (strcmp(p->name, symbol) == 0) X { X r = PyList_New(0); X if (subRange(p, first, last, &s, &t) != 0) X { X PyErr_SetString(StockpError, "bad range"); X return NULL; X } X for ( ; s != t + 1; s++) X PyList_Append(r, Py_BuildValue("(if)", s->date, s->price)); X return r; X } X PyErr_SetString(StockpError, "no such stock symbol"); X return NULL; } X /* Date calculations lifted from normalDate.py */ X static int daysInMonthNormal[] = {31,28,31,30,31,30,31,31,30,31,30,31}; static int daysInMonthLeapYear[] = {31,29,31,30,31,30,31,31,30,31,30,31}; X static int isLeapYear(int year) { X if ((year % 4) != 0) return 0; X if ((year % 100) != 0) return 1; X if ((year % 400) != 0) return 0; X return 1; } X static int dateToInt(int date) { X /* days since Jan 1, 1900 */ X int year, month, day, leapAdjust, i, *p; X year = date / 10000; X month = (date - 10000 * year) / 100; X day = date - 10000 * year - 100 * month; X leapAdjust = (year + 3) / 4; X leapAdjust -= (year + 99 - 1600) / 100 + (year + 399 - 1600) / 400; X day += year * 365 + leapAdjust - 693972; X /* figure leap years to figure days per month */ X if (isLeapYear(year)) X p = daysInMonthLeapYear; X else X p = daysInMonthNormal; X for (i = 0; i < month - 1; i++) X day += p[i]; X return day; } X static PyObject * pyDateToInt(PyObject *self, PyObject *args) { X /* this will make it possible to do regression tests on the X * dateToInt function, which is easily hairy enough to have X * a bug in it X */ X int first; X PyObject *nd; X if (!PyArg_ParseTuple(args, "O", &nd)) X return NULL; X first = PyInt_AsLong(PyObject_GetAttrString(nd, "normalDate")); X return Py_BuildValue("i", dateToInt(first)); } X static PyObject * linearRegression(PyObject *self, PyObject *args) { X char *symbol; X int first, last, N; X double A, B, C, D, E, F, G, sigma; X struct stock_data_entry *p; X struct closing_price *s, *t; X PyObject *nd1, *nd2; X if (!PyArg_ParseTuple(args, "sOO", &symbol, &nd1, &nd2)) X return NULL; X first = PyInt_AsLong(PyObject_GetAttrString(nd1, "normalDate")); X last = PyInt_AsLong(PyObject_GetAttrString(nd2, "normalDate")); X for (p = stock_data; p->name != NULL; p++) X if (strcmp(p->name, symbol) == 0) X { X if (subRange(p, first, last, &s, &t) != 0) X { X PyErr_SetString(StockpError, "bad range"); X return NULL; X } X C = D = E = F = G = 0.0; X N = 0; X for ( ; s != t + 1; s++) X { X double x, y; X x = (double) dateToInt(s->date); X y = log(s->price); X N++; X C += x * y; X D += x * x; X E += x; X F += y; X G += y * y; X } X if (N == 0) X { X PyErr_SetString(StockpError, "bad range"); X return NULL; X } X A = (N * C - E * F) / (D * N - E * E); X B = (D * F - C * E) / (D * N - E * E); X sigma = sqrt((G + A*A*D + 2*A*B*E + B*B*N - 2*A*C - 2*B*F) / N); X return Py_BuildValue("(ddd)", A, B, sigma); X } X PyErr_SetString(StockpError, "no such stock symbol"); X return NULL; } X X static PyMethodDef stockp_methods[] = { X {"symbolList", symbolList, 1}, X {"lookup", lookup, 1}, X {"fetchRange", fetchRange, 1}, X {"dateToInt", pyDateToInt, 1}, X {"linearRegression", linearRegression, 1}, X {NULL, NULL} }; X void initstockp(void) { X PyObject *m, *d; X m = Py_InitModule("stockp", stockp_methods); X d = PyModule_GetDict(m); X StockpError = PyErr_NewException("stockp.error", NULL, NULL); X if (StockpError != NULL) X PyDict_SetItemString(d, "error", StockpError); } SHAR_EOF chmod 0444 stockp.c || echo 'restore of stockp.c failed' Wc_c="`wc -c < 'stockp.c'`" test 6856 -eq "$Wc_c" || echo 'stockp.c: original size 6856, current size' "$Wc_c" fi # ============= stocks.h ============== if test -f 'stocks.h' -a X"$1" != X"-c"; then echo 'x - skipping stocks.h (File already exists)' else echo 'x - extracting stocks.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'stocks.h' && struct closing_price { X unsigned int date; X float price; }; X struct stock_data_entry { X char *name; X struct closing_price *data; X int size; }; X extern struct stock_data_entry stock_data[]; SHAR_EOF chmod 0444 stocks.h || echo 'restore of stocks.h failed' Wc_c="`wc -c < 'stocks.h'`" test 194 -eq "$Wc_c" || echo 'stocks.h: original size 194, current size' "$Wc_c" fi exit 0 ---------------------- end ----------------------------------- -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com