From paul at boddie.net Wed Apr 17 11:39:36 2002 From: paul at boddie.net (Paul Boddie) Date: 17 Apr 2002 08:39:36 -0700 Subject: Python-2.2.1, Solaris7, make test fails... References: Message-ID: <23891c90.0204170739.ec18eb1@posting.google.com> Hugh Sasse Staff Elec Eng wrote in message news:... > On Tue, 16 Apr 2002, P. Alejandro Lopez-Valencia wrote: > > > > And while you are at it... You have not compiled python itself as PIC > > code. No, gcc -shared *doesn't* work in Solaris unless you are using GNU > > Binutils instead of the native linker and assembler, something *not > > recommended at all*. Solaris' linker can't bild a dynamic loading > > library/module using object code compiled in position dependent mode. I first came up against this with GNU Bayonne on Solaris 7. However, wxPython also brought up some similar issues in the past, too: http://groups.google.com/groups?th=610b65907f740e28 > I ran configure. I have tried running configure with --enable-gnu-ld > and this didn't help, even with the latest binutils, so I have used the > sun ld. As far as I remember, you really do need to use binutils if you start to experience the linking problems that you described. Before, that didn't seem to be necessary with Python, but I'd guess that this has somehow become the case in the past two years - I haven't really used Solaris for about a year now, however. Paul From scarblac at pino.selwerd.nl Thu Apr 4 02:09:43 2002 From: scarblac at pino.selwerd.nl (Remco Gerlich) Date: 4 Apr 2002 07:09:43 GMT Subject: How best to write this try/except block? References: Message-ID: David Eppstein wrote in comp.lang.python: > In article , > Chris Liechti wrote: > > > if d.has_key(key): > > foo = stuff(d[key]) > > else: > > foo = otherStuff(key) > > I've seen a couple responses suggesting this. > > Is there a reason why in modern Python versions one should still use > has_key? I like the syntax "if key in d" better. Are you sure you have the newest Python everywhere you want to use it? I'm not. Why make your programs incompatible with such a trivial change? -- Remco Gerlich From johnroth at ameritech.net Sat Apr 27 20:15:25 2002 From: johnroth at ameritech.net (John Roth) Date: Sat, 27 Apr 2002 20:15:25 -0400 Subject: inline assignments in conditionals References: <2143388891-BeMail@sugoi> Message-ID: "Michael Gilfix" wrote in message news:mailman.1019937169.5421.python-list at python.org... > On Sat, Apr 27 @ 12:33, jaf wrote: > > Writing things that way is really unnatural, at least for English > > speakers. It makes the intent of the code harder to understand (at > > least for me). For example, if you were talking to a friend, you > > woudn't say: > > > > "If today is Sunday, I'm going to go shopping" > > > > but rather: > > > > "If Sunday is today, I'm going to go shopping" > > > > and in any case, writing the constant first only protects in the case > > where one of the compared values is a constant. If you are doing > > > > if (a == b): > > > > then there is no way to protect yourself against actually writing '='. Unnatural and partial as it is, it is a recommended best practice to protect yourself from accidentally writing '=' when you meant '==' in C or C++. I don't have any objection to implementing assignment in expressions. I have a real objection to doing it in such a way that it makes silly mistakes easier, however. John Roth From clubdelpelosuperfluo at yahoo.it Tue Apr 23 03:29:14 2002 From: clubdelpelosuperfluo at yahoo.it (Stefano) Date: 23 Apr 2002 00:29:14 -0700 Subject: Numeric Python, COM and Eigenvalues References: <9e1f166b.0204220437.57a087de@posting.google.com> Message-ID: <9e1f166b.0204222329.6f5685a6@posting.google.com> Fernando P?rez wrote in message news:... > Stefano wrote: > > > I am working with Numpy and trying to create a COM server. > > I managed to call this server by Excel and get results like Inverse > > matrix or Cholesky decomposition but the server doesn't work as I ask > > for Eigenvalues/vectors (Excel does not respond anymore). > > Has anyone heard of a problem of this kind? > > Well, with zero example code and details provided that's going to be a hard > one to get help on ;) > > Do you know for a fact you're feeding it a diagonalizable matrix? Does numpy > compute the eigenvals/vects nicely if you test it with the same matrix on its > own (not via excel)? Start testing with a symmetric 2x2 real matrix for which > you can hand-compute the eigenvalues trivially, that might tell you where the > problem is. > > Good luck, > > f. I have already tried with a trivial matrix via Shell. The same matrix makes Excel freeze. I have walked two path to use numeric via com 1. making a client that talks with Mark Hammond's doubletalk (do you know?) 2. making a server and a client by my own (actually with the help of Poulsen) I have problems only with eigenvalues (I can invert, i can decompose ? la Cholesky...) with both the codes! 1. doubletalk server: http://starship.python.net/crew/mhammond/ppw32/ppw32_samples.zip chapter 6 the client: Const txtStartupScript = "" Public BookServer As Object ' public methods 'double', 'interpretString', # tries exec, then eval 'execFile', 'importFile', 'beginTrappingOutput', 'endTrappingOutput', 'getStandardOutput', 'getViewData', 'count', 'createTransaction', 'getTransaction','getTransactionString', 'getOneLineDescription', 'load', 'loadFromText', 'loadFromString', 'save', 'saveAsText', 'asString', 'edit','add', 'getAccountDetails', 'getAccountList', 'drawAccountChart', 'doDelphiCallbackDemo' Sub InitCOMServer() Dim startupScript As String 'called when the program starts On Error GoTo InitCOMServer_error Set BookServer = CreateObject("Doubletalk.BookServer", RemoteMachine) On Error GoTo 0 'tell it to capture output for the console BookServer.beginTrappingOutput 'if there is an init script, run it If txtStartupScript <> "" Then On Error GoTo InitCOMServer_StartupScriptError BookServer.execFile txtStartupScript On Error GoTo 0 End If 'grab any standard output for the console Exit Sub InitCOMServer_error: Dim msg As String msg = "There was an error trying to initialize the BookServer." + _ "Please check that it is properly registered and try the Python " + _ "test functions first. The program will now abort." MsgBox msg End InitCOMServer_StartupScriptError: MsgBox "An error occurred running your startup script '" + _ txtStartupScript + "'. " + _ "Please check it is present and correct." End Sub Sub CloseCOMServer() Set BookServer = Nothing End Sub Sub TestCOMServer() 'just to check it is alive Dim hopefully_four As Integer hopefully_four = BookServer.Double(2) MsgBox "2 x 2 = " & hopefully_four & ", so your server is alive" End Sub Sub ScriptRun(FileName) BookServer.execFile FileName On Error GoTo mnuScriptRun_Error: Exit Sub mnuScriptRun_Error: MsgBox "Error running script:" + vbCrLf + vbCrLf + Err.Description End Sub Sub ScriptImport(FileName) BookServer.importFile FileName End Sub Function ProcessPythonCode(expr As String) As String 'passes a chunk of text to the server's interpretString 'method, and returns the result. If an error occurs, 'returns the error message. On Error GoTo mnuProcessPythonCode_Error ProcessPythonCode = BookServer.interpretString(expr) Exit Function mnuProcessPythonCode_Error: ProcessPythonCode = Err.Description End Function Sub ProcessCommand(txtInput As String) 'gets a one-line string from the input text box. 'if there is a result, appends it to the output box. 'Also copy the input command to output to keep a command history Dim strInput As String Dim strResult As String Dim strStandardOutput As String Dim strOutText As String 'for building the final textbox data 'VB puts CRLF pairs in the input for multi-line 'statements; Python just wants line feeds strInput = Replace(txtInput, vbCrLf, vbLf) 'multi-line statements need a final line-feed; this is optional 'fopr one liners. WE'll add it anyway. If Right(strInput, 1) <> vbLf Then strInput = strInput + vbLf 'process it strResult = ProcessPythonCode(strInput) Debug.Print strResult 'get output strStandardOutput = BookServer.getStandardOutput() strStandardOutput = Replace(strStandardOutput, vbLf, vbCrLf) Debug.Print strStandardOutput End Sub Sub InitializeNumeric() Dim s As String s = "from LinearAlgebra import *" ProcessPythonCode s s = "from Numeric import *" ProcessPythonCode s End Sub Sub testNumerical() Call InitCOMServer Call InitializeNumeric Dim s As String s = "a = array(([2,1],[1,2]))" ProcessCommand s s = "inverse(a)" ' s = "eigenvalues(a)" Excel freezes ProcessCommand s CloseCOMServer End Sub 2. Python server (assigning the _reg_clsid_ with pythoncom, imported and then registered with win32com.server.register.UseCommandLine...) # PythonNumeric.py class PythonNumeric: _reg_clsid_ = "{E34C200E-D95A-49C6-A0F9-F29FF8FF903A}" _reg_desc_ = "Python Numeric COM Server" _reg_progid_ = "PythonNumeric.Utilities" #for external calling _reg_class_spec_ = "PythonNumeric.PythonNumeric" _public_methods_ = [ 'InvertMatrix', 'Eigenvalues' ] # Use "print pythoncom.CreateGuid()" to make a new one. def InvertMatrix(self, val): import Numeric import LinearAlgebra return (LinearAlgebra.inverse(Numeric.array(val))).tolist() def Eigenvalues(self, val): import Numeric import LinearAlgebra return (LinearAlgebra.eigenvalues(Numeric.array(val))).tolist() VBA Client Function NumpyMatInverse(mynum As Range) Dim numpy As Object Dim matrice As Variant Range2Array2 matrice, mynum Set numpy = CreateObject("PythonNumeric.Utilities") NumpyMatInverse = numpy.InvertMatrix(matrice) Set numpy = Nothing End Function Function NumpyMatEigen(mynum As Range) Dim numpy As Object Dim matrice As Variant Range2Array2 matrice, mynum Set numpy = CreateObject("PythonNumeric.Utilities") NumpyMatEigen = numpy.Eigenvalues(matrice) Set numpy = Nothing End Function Sub Range2Array2(arr As Variant, r As Range, Optional base As Integer) Dim n(1 To 2) As Integer, i As Integer, j As Integer, k As Integer n(1) = r.Rows.Count + (base - 1) n(2) = r.Columns.Count + (base - 1) Select Case n(2) Case 0 ReDim arr(base To n(1)) For i = base To n(1) arr(i) = r.Cells(i - base + 1, 1 - base + 1) Next i Case Else ReDim arr(base To n(1), base To n(2)) For i = base To n(1) For j = base To n(2) arr(i, j) = r.Cells(i - base + 1, j - base + 1) Next j Next i End Select End Sub From jessica at sonic.net Sun Apr 21 15:44:28 2002 From: jessica at sonic.net (jessica at sonic.net) Date: Sun, 21 Apr 2002 19:44:28 GMT Subject: Jessica Felix Designs - Art and all that Jazz Message-ID: I am mercilessly ugly, so I improve you. "ART AND ALL THAT JAZZ" is a gallery on the Healdsburg Plaza that incorporates the two passions of its owner, Jessica Felix - art and jazz. Jessica is an artist whose medium is jewelry. She creates what she calls "spirited art," specializing in images from indigenous cultures around the world. http://www.artandallthatjazz.com 119A Plaza Street Healdsburg, CA 95448 1-707-433-7900 Who will we open after Bernadette kicks the pathetic star's boat? We fear the polite gardner. From SBrunning at trisystems.co.uk Tue Apr 9 11:50:14 2002 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 9 Apr 2002 16:50:14 +0100 Subject: yet another "Here's to 1.5.2" post Message-ID: <31575A892FF6D1118F5800600846864DCBCF5B@intrepid> > From: Syver Enstad [SMTP:syver-en+usenet at online.no] > Am I the only one in the entire world that thinks '\t'.join(mylist) is > elegant and natural? Nope. Took a *little* getting used to, but it seems as natural as breathing to me now. Much like a number of Python's *other* idiosyncratic features, past, present and future... Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From Allen.Ingling at nyu.edu Tue Apr 2 16:50:06 2002 From: Allen.Ingling at nyu.edu (Allen W. Ingling) Date: Tue, 02 Apr 2002 16:50:06 -0500 Subject: how do I find a syntax error reported by Mac BuildApplet ? Message-ID: <3CAA278D.F484DB34@nyu.edu> How do I find a syntax error reported by the Mac Python BuildApplet utility ? I have the Python 2.2 distribution for Mac. I am running it on OS 9.2.1. It includes the BuildApplet utility. I have written a python script which executes in the Python interpreter without error. However, when I try to build an applet using BuildApplet I received a "syntax error" message and my script does not compile. BuildApplet does not report where in the script the error lies. Is there any fast way to automatically identify the line in my script which causes applet builder to report a syntax error ? I expect that there really is an error, and that its not reported in the interpreter because it lies along a conditional branch chain which is rarely executed. Having to examine the entire script myself to find a syntax error which the compiler detects but does not report feels incorrect. What don't I know, or what am I doing wrong here ? Best, Allen From fredrik at pythonware.com Tue Apr 9 05:20:27 2002 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 09 Apr 2002 09:20:27 GMT Subject: What has PEP 285 done to us? References: <20020408134207.1af35256.logiplexsoftware@earthlink.net> <3CB2AADF.9050908@mxm.dk> Message-ID: > So perhaps Guido need a little work with the people skills ;-) and the > rest of us need to act properly, which includes not getting upset when > others don't. "It's all about doing what's best for the little ones." http://www.theonion.com/onion3811/child-rearing_advice.html From msoulier at nortelnetworks.com_.nospam Tue Apr 9 17:31:30 2002 From: msoulier at nortelnetworks.com_.nospam (Michael P. Soulier) Date: 9 Apr 2002 21:31:30 GMT Subject: shutil.copytree - wishlist Message-ID: Hey people. So, I was just using the very helpful shutil.copytree function, documented like so: copytree(src, dst[, symlinks]) Recursively copy an entire directory tree rooted at src. The destination directory, named by dst, must not already exist; it will be created. Individual files are copied using copy2(). If symlinks is true, symbolic links in the source tree are represented as symbolic links in the new tree; if false or omitted, the contents of the linked files are copied to the new tree. Errors are reported to standard output. I had symlinks in the original directory that I copied. With the symlinks boolean turned on, this function created symlinks to the symlinks in the original directory. As a wishlist feature, I was wondering if an option of whether or not to perform a readlink of the symlinks can be done prior to creation of those symlinks, so that instead of pointing to the original directory, the symlinks would reference what the originals referenced instead. ie. A -> B copy A, we get C -> A -> B Optionally, it would be nice to have C -> B. Is there an official way to make such a wishlist request? Thanks as always, Mike -- Michael P. Soulier, QX41, SKY Tel: 613-765-4699 (ESN: 39-54699) Optical Networks, Nortel Networks, SDE Pegasus "...the word HACK is used as a verb to indicate a massive amount of nerd-like effort." -Harley Hahn, A Student's Guide to Unix From maciej at maciejsobczak.com Thu Apr 11 17:48:05 2002 From: maciej at maciejsobczak.com (Maciej Sobczak) Date: Thu, 11 Apr 2002 23:48:05 +0200 Subject: Communication between a Python process and a Python cgi script References: <3CB5E224.4E3DC5BA@olen.to> Message-ID: Hi, "Joonas Paalasmaa" wrote in message news:3CB5E224.4E3DC5BA at olen.to... > I have a Python program started by root that does some magic stuff > every 10 minutes. So the program in an infinite loop of sleep, do stuff, > sleep, do stuff... How can I make a cgi-script to end the process's > sleep phase and make it to "do stuff" immediately. For this kind of interprocess communication, you can try http://www.maciejsobczak.com/prog/yami/ and in particular: http://www.maciejsobczak.com/prog/yami/impl/index.html#python It can be used not only for communication, but also for synchronization. > I tried signals, but > it is propably too risky because the process is run as root. Any > suggestions? It's rather hard to come up with a scheme that will be really safe here. FIFO with rights properly set up would probably do, but this adds some complexity. Cheers, -- Maciej Sobczak http://www.maciejsobczak.com/ From nospam-readonly at getsoft.com Sun Apr 21 18:27:36 2002 From: nospam-readonly at getsoft.com (Neville Franks) Date: Mon, 22 Apr 2002 08:27:36 +1000 Subject: A simply newbie question about ndiff Message-ID: <3cc33cc2$0$15474$afc38c87@news.optusnet.com.au> Hi, I've just started trying to do some simple things with Python. I've read the Tutorial and other Doc's but I'm missing something obvious somewhere. All I want to do right now is run Tim Peter's ndiff program on some files and see it's output. I'm using Pyton 2.1.2 Jan 15 2002 on Windows XP using the Python command line. I enter 'import difflib' which I assume is necessary and get no complaints. Then if I type 'ndiff' I get: NameError: name 'ndiff' is not defined. If I type: 'ndiff file1 file2' I get: SyntaxError: invalid systax. I've also tried: >>> s = SequenceMatcher( None, "abcd", "bcde" ) and I get: NameError: name 'SequenceMatcher' is not defined. Thanks for your help with these most basic of questions. From tchur at optushome.com.au Sat Apr 6 18:06:27 2002 From: tchur at optushome.com.au (Tim Churches) Date: Sun, 07 Apr 2002 09:06:27 +1000 Subject: Pattern for permutations? Message-ID: <3CAF7F73.9C27F19D@optushome.com.au> This may be an elementary question but the solution is not obvious to me. I want to define a function which takes as its argument a list which contains one or more sequences, and then does stuff with every permutation of the elements of those sequences. For example, a function which works for a list containing three sequences: def nestedloops(list_of_sequences): for element0 in list_of_sequences[0]: for element1 in list_of_sequences[1]: for element2 in list_of_sequences[2]: # do stuff with each permutation print element0, element1, element2 nestedloops([(1,2,3),('one','two','three'),('isa','dalawa','tatlo')]) How does one generalise such a function so that it handles any number of sequences in the passed list of sequences i.e. a dynamic number of levels of nesting? It occurred to me that the function could emit dynamic code for the "for" loops and then eval() that, but that seems a bit messy and possibly slow. Is there a better way? Tim C From boud at valdyas.org Fri Apr 12 08:46:41 2002 From: boud at valdyas.org (Boudewijn Rempt) Date: Fri, 12 Apr 2002 14:46:41 +0200 Subject: ANN: Source code for GUI Programming with Python Using the Qt Toolkit References: <3cb60427$0$71652$e4fe514c@dreader4.news.xs4all.nl> Message-ID: <3cb6d785$0$85458$e4fe514c@dreader3.news.xs4all.nl> Boudewijn Rempt wrote: > > http://www.xs4all.nl/~bsarempt/python/pyqt_qt2.tgz > > Source for Python 2.x, Qt 3.x and PyQt 3.x. (Grab this > if you're current with the PyQt from > http://www.riverbankcomputing.co.uk > As Alex pointed out -- this is wrong. The right place is: http://www.xs4all.nl/~bsarempt/python/pyqt_qt3.tgz Sorry for the inconvenience... -- Boudewijn Rempt | http://www.valdyas.org From cliechti at gmx.net Wed Apr 3 14:06:04 2002 From: cliechti at gmx.net (Chris Liechti) Date: 3 Apr 2002 20:06:04 +0100 Subject: Bastion Documentation Error? References: Message-ID: jimd at vega.starshine.org (Jim Dennis) wrote in news:a8dsj3$1n4j$1 at news.idiom.com: > I'm a bit confused by the Bastion.Bastion() function. > From the documentation I read: > > """ > Protect the object object, returning a bastion for the object. Any > attempt to access one of the object's attributes will have to be > approved by the filter function; if the access is denied an > AttributeError exception will be raised. > """ it says also: """ It must always be used with the rexec module, in order to allow restricted-mode programs access to certain safe attributes of an object, while denying access to other, unsafe attributes. """ so you must use it within rexec to make it work... chris > ... but playing with it I find that it raises an AttributeError on > any attempt to access any class or instance variables. -- Chris From ak at silmarill.org Sat Apr 20 16:52:26 2002 From: ak at silmarill.org (Andrei Kulakov) Date: Sat, 20 Apr 2002 20:52:26 GMT Subject: Disappearing global variables Message-ID: Hello, When I run book.read() method, instances that were in global namespace disappear. I made a small function loc() that prints 0 if 'local' is in global namespace (the name has nothing to do with namespaces - it just means local list of books stored on hard drive). I run it right before calling book.read() and it prints 1, I run it from inside book.read() right after calling it, and it prints 0. I'm using python2.1. def loc(): print 'loc', print 'local' in globals().keys() # method of Book class def read(self): """Read the book.""" loc() arg = "" if self not in local.lst: # to scroll past gutenberg licence stuff.. if viewer.endswith("vim"): arg = "+/\*END\*" self.download() if last.lst and self != last.lst[-1]: last.compress() if self.gzip: self.uncompress() last.add(self) if viewer.endswith("vim"): # -N not fully vi-compat; -u use vimrc arg = " -N -u %s %s " % (VIMRC, arg) os.system(viewer + arg + self.l_fname) You can look at full program at silmarill.org/pybook/pybook.py - it's a little over 500 lines. I have to say I'm really puzzled. Any hints? - Andrei -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From emile at fenx.com Fri Apr 5 10:02:13 2002 From: emile at fenx.com (Emile van Sebille) Date: Fri, 05 Apr 2002 15:02:13 GMT Subject: newbie: declare function before definition? References: Message-ID: David Kramer > It appears to me that in Python, functions need to be defined before they > are called (physically in the file, I mean). This means any piddly little > utility functions have to be before my main routine, and the reader has to > wade through them before getting to the main routine. > > In some other languages, one can declare a function, and define it later, > and the compiler is happy. Is there a way to do this in Python? How about: #!/usr/remote/bin/python def MyFuncBefore (): print "In Before" def main(): print "Before" MyFuncBefore() print "After" MyFuncAfter() def MyFuncAfter (): print "In After" if __name__ == '__main__': main() -- Emile van Sebille emile at fenx.com --------- From benji_york at cknainc.com Fri Apr 26 15:22:43 2002 From: benji_york at cknainc.com (Benji York) Date: 26 Apr 2002 12:22:43 -0700 Subject: Asynchronous cgi that returns nothing. Possible? O:-) References: Message-ID: Fernando Rodr?uez wrote in message news:... > This cgi shouldn't return anything > and shouldn't change the contents of the browser. Is this possible? O:-) An excerpt from http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html: [Status Code] 204 No Content The server has fulfilled the request but does not need to return an entity-body, and might want to return updated metainformation. The response MAY include new or updated metainformation in the form of entity-headers, which if present SHOULD be associated with the requested variant. If the client is a user agent, it SHOULD NOT change its document view from that which caused the request to be sent. This response is primarily intended to allow input for actions to take place without causing a change to the user agent's active document view, although any new or updated metainformation SHOULD be applied to the document currently in the user agent's active view. The 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields. (end excerpt) This looks like what you want. --- Benji York From pyth at devel.trillke.net Wed Apr 17 12:09:58 2002 From: pyth at devel.trillke.net (holger krekel) Date: Wed, 17 Apr 2002 18:09:58 +0200 Subject: Simulating multi-dim array problem - OR - reference confusions In-Reply-To: References: <3CBC991C.7090202@nyu.edu> Message-ID: <20020417160958.GA17361@devel.trillke> > > means that the "name 'b' is bound to 'a[0]'". Internally > > the reference count of the object a[0] is incremented. > > > Well, newbies might avoid mis-perceptions by reading the Python as "name 'b' > is bound to the object currently bound to 'a[0]'", to avoid any belief that > anything in a changes as a result of the assignment. In strict terms, a[0] > doesn't *have* a reference count, as far as I can tell without reading the > interpreter code, though both a and the object bound to a[0] will have a > reference count. ok, so - 'a' is a name bound to a list object. - 'b=a[0]' binds 'b' to the object that 'a[0]' returns (because 'a[0]' is actually a method-call to the list object returning (a reference to) the first object of the list) No matter how the reference counts actually work, 'b' is a name. And this name is bound to an object. by issueing 'b=...' you don't change this object but just the binding. The best way to explore this is the prompt. by issueing >>> locals() you get the local name bindings. I must say that i *extremly* appreciate that for all variables, modules, packages, classes, functions etc ... you have means of binding a name to these objects. sorry if this was redundant and everyone knew this :-) holger From opengeometry at NOSPAM.yahoo.ca Tue Apr 16 11:03:58 2002 From: opengeometry at NOSPAM.yahoo.ca (William Park) Date: 16 Apr 2002 15:03:58 GMT Subject: ideas for the best way to do some math, please?? References: <693d5681.0204160516.541c0bfe@posting.google.com> Message-ID: Ben Carrington wrote: > i am a complete beginner with python, please be gentle :I > > i am trying to evaluate a reatively simple equation but i keep getting > this error: > > overflowError: math range error > > ...pointing to math.log(p) > ... > #part3 > part3 = 1 - math.e**part2 > p = abs(part3) > > #part4 > part4i = math.log(p) > part4ii = k*T*part4i Well, as you know, log(x) -> -infinity as x -> 0. So, 'p' and 'part2' are probably 0. -- William Park, Open Geometry Consulting, 8 CPU cluster, NAS, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Tin From bokr at oz.net Wed Apr 24 16:02:52 2002 From: bokr at oz.net (Bengt Richter) Date: 24 Apr 2002 20:02:52 GMT Subject: python and very large data sets??? References: Message-ID: On 24 Apr 2002 09:41:22 -0700, zaka07 at hotmail.com (Rad) wrote: >I am preparing myself to work on extracting data from 4 text files >(fixed width format) which combined size is about 80GB. Considering How wide a fixed with? I.e., how many records? How much duplicate or unused fluff is there in the records? How much will wind up in your output? Is this a one-time thing? >deadlines, costs, and my limited programming knowledge I thought using >Python/Windows for the job would be the best option for me. However, >I am worried about the speed in which Python (me and my hardware) will >be able to deal with these massive data sets but I am hoping that this >is still a quicker route then learning C. >I still haven't received above mentioned files so I can't test the Are you going to receive a hard disk with the files on it, or tapes, (or ~125 CDs ;-) ? Is the data pre-sorted in any way that might help you? What OS are you running? How much disk space and RAM do you have? What CPU? How many disks on your system? SCSI or IDE? If they give you a HD, will it be compatible physically & file system wise? Will your power supply hack it? >time needed to (for example) read a 15GB "file1", filter by few >variables, and write a resulting subset as a "sub_file1". Things >would afterwards get more complicated cause I will have to pullout >ID's from "sub_file1", remove duplicate ID's create >"no_dup_sub_file1", match those to ID's in remaining 3 main files and How many total unique IDs of what type/form? How much memory do you have or can you expand to? E.g., if the IDs would not make too big a dictionary (using all the same value of None for every key), then you might be able to eliminate duplicates as they happen in one pass, and create "no_dup_sub_file1" without first creating "sub_file1". >pullout data linked with those ID's. > Does this imply random access to data in those three files? Simultaneously? I.e., you might want to make an index of ID/file positions. And/or you might want to sort your access IDs by position so you can get everything in one pass. (OTOH, what ordering is required in your output? What you do might depend.) But whether you can do all this easily will depend on how much memory you have and the number of IDs. All this stuff will be re-inventing data base stuff, so you might want to consider going that route, as others have suggested. A flat fixed-width source sounds like an easy importing/loading problem. I haven't tried MySQL on windows, but on Linux is was not hard to get going, and it might be faster than a fully transactional DB like postgresql (I don't know any recent benchmarks). I would guess that you could beat the disk space requirements by writing a special-purpose program, though. >I have a few weeks to prepare myself before data arrives and my >question is: am I going the right way about the project, is Python >(with humanly written code) capable of doing this kind of staff >relatively quickly? > It doesn't sound that complex from what you've described. Just big. So it will be important to know how much state you have to accumulate to do the processing you need, and whether that will fit in memory. E.g., if you have a billion unique IDs, a naive directory approach is not likely to fly for detecting duplicates. How you then go about getting end results efficiently will depend on what the problem really is ;-) Your best bet on getting help with that (as well as solving it yourself) is to specify it as precisely and unambiguously as you can (while assiduously relegating pre-conceived solutions to footnotes or appendices). If you post a precise definition of the problem, someone might bite. Also, if you have any options on the way the data is delivered, you might want to get some opinions on that before it's too late. Regards, Bengt Richter From lenssen at hitnet.rwth-aachen.de Wed Apr 17 14:30:37 2002 From: lenssen at hitnet.rwth-aachen.de (Philipp Lenssen) Date: Wed, 17 Apr 2002 20:30:37 +0200 Subject: Trinary operator? References: Message-ID: "Andrew Dalke" wrote in message news:a9kebg$ub9$1 at slb5.atl.mindspring.net... > Philipp Lenssen: > >can I use something like > > verboseGender = (gender == 'm') ? 'male' : 'female' > >in Python? > > No. Search the archives for "ternary operator" for plenty of > past discussion. Google lists 65 posts for comp.lang.python. > Sorry. I actually did search but typed "trinary" instead of "ternary". Since I didn't know what either word means I got confused, and now that I checked an online translator to german I'm not even sure the word "trinary" exists. Oh well. > Besides, for this specific case you should have some error checking, > because there are genders other than 'male' and 'female' (eg, > asexual bacteria and hermaphradite earthworms). > > verboseGenderTable = { > "m": "male", > "f": "female", > } > verboseGender = verboseGenderTable[gender] > (I suppose while the bacteria get too frustrated to use my application, the hermaphrodites are busy playing with themselves.) From matt at greenroom.com.au Wed Apr 10 00:03:29 2002 From: matt at greenroom.com.au (Matthew Baulch) Date: Wed, 10 Apr 2002 14:03:29 +1000 Subject: Is Python Sticky? References: <3cb3a8dd$1@nntp01.splitrock.net> Message-ID: <3CB3B991.607@greenroom.com.au> ball at righty.eiu-newman.org wrote: > Hello! > > For a while "Learn Python" has been on my list of things to do. Right > now I have an application that could use some glue between a web based > interface (in its simplest form a single page with a couple of buttons > on it), and a shell script (I'm running NetBSD). Would Python be > suitable for this kind of thing? Are there other pieces of the puzzle > that I'll need? Any pointers would be most welcome. > > Regards, > - Andy Ball. > It sounds to me like python would not be neccessary at all if most of the work is done with the shell script. If this is the case then my advice would be to simply use a cgi interface through apache, or equivalent which would dramatically increase execution speed as the python interpreter would not need to be loaded unnecessarily. Good luck! Cheers, matt From westernsam at hotmail.com Mon Apr 15 14:55:55 2002 From: westernsam at hotmail.com (sam) Date: 15 Apr 2002 11:55:55 -0700 Subject: upgrading to python2.2 References: <292c8da4.0204150521.35d4a842@posting.google.com> Message-ID: <292c8da4.0204151055.6eb252e4@posting.google.com> WOW!! Six hours after reporting a bug it is fixed!!! You would never get that kind of response from a commercial software vendor Open Source rules Thanks a lot Roger Sam From max at alcyone.com Mon Apr 1 14:39:14 2002 From: max at alcyone.com (Erik Max Francis) Date: Mon, 01 Apr 2002 11:39:14 -0800 Subject: Root access with python References: <7x663krjtp.fsf@ruckus.brouhaha.com> <20020325123855.A1716@ibook.distro.conectiva> Message-ID: <3CA8B762.D17E7E4A@alcyone.com> Jim Dennis wrote: > As for your overall "advice." It's of little value to tell > someone: "don't do that" without offering any suggestion about > what he or she SHOULD try. > > Whenever discussing computer system security I avoid > proscriptive pronouncements like: "you can't do that" or > "no one should ..." You have a point, but it is still the case that there _are_ solutions and approaches which are so ill-advised that you are better off stopping them in their tracks before they go any further down the roads. Some approaches are so bad -- i.e., they have caused endless problems over the years -- that an expert, much less a novice, should avoid them like the plague. I'd say setuid scripts is pretty much up there. A better approach to just, "Don't do that," would be to discourage the current approach by suggesting that they go back to basics -- instead of asking how to do the approach they've come to, ask them what fundamental problem they're trying to solve. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Nationalism is an infantile sickness. \__/ Albert Einstein Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html A new, virtual planet, every day. From johnroth at ameritech.net Tue Apr 30 07:30:41 2002 From: johnroth at ameritech.net (John Roth) Date: Tue, 30 Apr 2002 07:30:41 -0400 Subject: Is it me or a python wart References: Message-ID: "Robin Becker" wrote in message news:Io2j9JAgacz8EwST at jessikat.fsnet.co.uk... > the one thing I think is that other languages eg pascal/modula have a > better/simpler grasp of what humans see in programs. Lexical scope ie > higher on the page and further left means precede is a 'good' rule. The > 'local' idea that anything that is assigned to is 'local' is much harder > since that can be realised very distantly. I assume there are reasons > for the current 'oddness', but they seem to be hidden from us poor > lusers. > -- > Robin Becker If you do that, you can get some very non-intuitive behavior. For example: c = 2 def foobar(a): b = c c = a In Python, the first assignment fails because 'c' is an undefined local variable. I've worked in languages where 'c' would be resolved as 2, and then suddenly change in the middle of the function to be resolved as the parameter 'a'. It's a very fertile source of bugs. Consider this loop: a = 2 for x in foobar: c = a a = x The first time through the loop, 'c' is set to a value global to the loop, the rest of the time, it's set to the loop variable (on the preceding pass!) This is also very non-intuitive behavior. However, I suspect the primary motivation for this is optimization. The variable 'dictionary' in functions is not a dictionary, but a structure that allows faster access. Given that, the 'if it's assigned to, its a local variable' rule is quite reasonable. In any case, any function or method that's big enough to cause a problem is probably too big. The 'one page rule' was in existence thirty years ago when we had to look at programs on paper! John Roth From paiarunk at yahoo.com Mon Apr 22 04:36:04 2002 From: paiarunk at yahoo.com (Arun KUmar) Date: 22 Apr 2002 01:36:04 -0700 Subject: Making Tk() as modal dialog Message-ID: <5e430dc.0204220036.3d25f9da@posting.google.com> hai, i want to make the Tkinter.Tk() instance as modal window : i.e: 1. It should not be resizable 2. It should not be movable on the screen 3. it should not be able to minimize or iconify how to do this? if any body has already got answers , please help me. bye arun From jb at cascade-sys.com Tue Apr 30 13:46:21 2002 From: jb at cascade-sys.com (James J. Besemer) Date: Tue, 30 Apr 2002 10:46:21 -0700 Subject: Third Draft: Pep for Deprecating Builtins References: Message-ID: <3CCED86D.C3173778@cascade-sys.com> Steve Holden wrote: > If you're talking about "from __future__ ...", these can only appear before > any other source lines, and so (bugs notwithstanding) they aren't as > difficult to detect as you believe. Remember that some imports from > __future__ modify how the compiler acts, so you can't just switch them on > and off at random. Good point. Thanks for the clarification. Nevertheless, having to look at the global context for basic things like how divison works is really screwey and such changes should not be employed gratuitiously. > But don't underestimate the cruft that has to be carried forward into new > implementations either. I appreciate what you're trying to say, but under > the hood there have been some radical changes in the last two releases. It's > amazing that such a small amount of code was broken as a result. I think there are two different things here: (a) bits of cruft carried forward and (b) necessary radical new features. The former is in the category of tempting, possibly irresistable but inconsequential nits that in all likelihood more trouble than it's worth. Plus they tend to be highly controversial, like removing map from builtins. We should never use "from future" for mere "cruft". The latter (with a few exceptions (like true division)) are highly desirable, well thought out new features, e.g., lexical scoping, which correct a SERIOUS shortcoming in the original language. Although a radical change that cannot help but break code, it's well worth the pain to move ahead. FWIW Regards --jb -- James J. Besemer 503-280-0838 voice http://cascade-sys.com 503-280-0375 fax mailto:jb at cascade-sys.com From pinard at iro.umontreal.ca Mon Apr 8 20:05:34 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 08 Apr 2002 20:05:34 -0400 Subject: Nested scopes hitch In-Reply-To: References: <1018044224.815568@cswreg.cos.agilent.com> <1018304015.46066@cswreg.cos.agilent.com> Message-ID: [Jeff Shannon] > If you want access to variables inside of a function, you should > pass those specific variables as arguments. If you've got lots > of arguments in common between lots of functions, assemble the > lot into a class. If neither of these is appropriate, then you > should redesign -- you're using a very ugly approach. I beg to disagree, a bit strongly. Something is not ugly just because you prefer something else. I have very, very neat applications which use globals() and locals(), and they will loose much if they use arguments all over, or get assembled into classes. It is possible that the evolution of Python forces me away of these nice ways, and I'll happily make necessary adjustments in the name of a greater good. But I resist the idea that we were wrong or ugly, before. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From Jeff.Dubois at westgroup.com Mon Apr 15 14:37:20 2002 From: Jeff.Dubois at westgroup.com (Dubois, Jeff) Date: Mon, 15 Apr 2002 13:37:20 -0500 Subject: Regular Expression Pattern Matching "State" Object Message-ID: I am looking for a regular expression object\algorithm that does something like the following: 1. Initialize the object with a regular expression pattern. 2. After initializing the object with a regular expression pattern you are able to "feed" the object a sequence of characters, one character at a time, where, after each character is fed to the object, the object indicates whether or not it is still in a "continuing to match" state, "not a match" state, or a "match complete" state. I am thinking that such a utility may be useful when searching for strings across DOM nodes for example. Thanks! Jeff From noah at noah.org Sun Apr 14 14:44:09 2002 From: noah at noah.org (Noah) Date: Sun, 14 Apr 2002 11:44:09 -0700 Subject: Pseudo-TTY (pty module) help! Message-ID: Does anyone have any experience or samples of use of the pty module? What I would like to do is fork a child that echos back every character, but converted to upper-case. The parent would write out characters then read back and print the results on STDOUT. I tried using pty.fork. Here is the behavior that I observed. I successfully get a Master (parent) and Slave (child). The Master can read and write, but everything it writes comes back in the read. The Slave can write, but blocks on all reads. 1. The Master gets a file descriptor (fd) for communication with the Slave. 2. The Master can write data to the fd. 3. The Slave can write to its STDOUT. 4. The Master can read the data on fd written by the Slave. 5. The Master alread reads all the data on fd that it wrote. it appears to be echoing back, but not from the slave. Even if I disable the slave from any writes, the Master's data still enchos back. 6. The Slave cannot read from STDIN at all. It blocks. I use os.write and os.read for all file descriptor operations. For the slave I use os.write(sys.stdout.fileno(), foo) which I think is the most correct way. I have been experimenting with pty, but to no avail. The documentation could only be briefer if it was absent. The test_pty.py that comes with the Python installation also does not fully test all the features, so it is hard to use that as starter code. Maybe I could try pty.spwan, but it isn't clear how to use it. I'm not quite sure how to use the master_read and stdin_read callback functions. Yours, Noah From hancock at anansispaceworks.com Mon Apr 29 13:44:02 2002 From: hancock at anansispaceworks.com (Terry Hancock) Date: Mon, 29 Apr 2002 10:44:02 -0700 Subject: Cookie encoding Message-ID: <3CCD8662.D8E542DC@anansispaceworks.com> Hi, I'm trying to put a builtin Python object into an HTTP cookie for saving state information in a Zope web app. Zope provides a simple means of doing the actual Cookie setting (RESPONSE.setCookie()), but it fails silently if the cookie contains illegal characters (or so it seems). The Zope docs are pretty hostile towards the idea of using general picklers in web apps, for security reasons, but there's a "MiniPickle" module that will only pickle "safe" data -- i.e. only a select set of Python objects, like lists and dictionaries are allowed. This seems to work fine, but the strings generated are apparently illegal as HTTP cookie values. So I need to encode the result into something safer. I've tried the uu.encode, base64.encode, etc. but I'm just taking shots in the dark (and these didn't work) -- I figure there has to be a standard answer to this problem. There is a "Cookie" module, which looks interesting, but it seems to want to make the whole HTTP set-cookie line, not just the legal value. So I'm not sure if I can make that play well with Zope. I picked through the Cookie.py code, and indeed there is an encoding/quoting function inside it, but it's a "private" method (begins with "_"), so I gather it would be unwise to use that directly. I'm sure I could actually write a custom encoder that would work, but I'd prefer to do it "right". Anyway, thanks for any advice on this! Terry -- ------------------------------------------------------ Terry Hancock hancock at anansispaceworks.com Anansi Spaceworks http://www.anansispaceworks.com ------------------------------------------------------ From eppstein at ics.uci.edu Sat Apr 6 19:25:56 2002 From: eppstein at ics.uci.edu (David Eppstein) Date: Sat, 06 Apr 2002 16:25:56 -0800 Subject: a problem with subclassing a dict References: Message-ID: In article , Rajarshi Guha wrote: > I was playing with some code from a tutorial by GvR ... > Traceback (most recent call last): > File "p2.py", line 22, in ? > print md[2] > KeyError: 2 Your modified __getitem__ function appears not to be called even for the successful accesses (e.g. if you put a print statement before the try, it never gets printed). The tutorial mentions a problem like this for local and global scope dictionaries, but doesn't say that it happens for other kinds of dictionaries too... Someone more expert than I can tell you why this doesn't work, but if you really need to define your own dictionary-lookalike class, you might also want to look at -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From hgs at dmu.ac.uk Mon Apr 15 09:02:16 2002 From: hgs at dmu.ac.uk (Hugh Sasse Staff Elec Eng) Date: Mon, 15 Apr 2002 14:02:16 +0100 (BST) Subject: Python-2.2.1, Solaris7, make test fails... In-Reply-To: Message-ID: On Sat, 13 Apr 2002, Michael Hudson wrote: > martin at v.loewis.de (Martin v. Loewis) writes: > > > Hugh Sasse Staff Elec Eng writes: > > > > > ImportError: ld.so.1: ./python: fatal: relocation error: file /home/hgs/Python-2.2.1/Modules/mathmodule.so: symbol PyExc_OverflowError: referenced symbol not found > > > > > > Could someone suggest how to proceed, please? > > > > Can you please report the command line option that was used to link > > the python binary? (delete it, and re-invoke make) PyExc_OverflowError > > ought to be exported from the Python binary, and there ought to be a > > gcc command line option to achieve that. > > But this is really strange; mathmodule.so must have imported at some > point, or setup.py would have deleted it... Hmm. I don't know. Anyway, here is the result of re-making the Python, but not the make test, after removing that file... Script started on Mon Apr 15 13:57:01 2002 neelix hgs 1 %> gmake gcc -shared Modules/mathmodule.o -o Modules/mathmodule.so case $MAKEFLAGS in \ *-s*) CC='gcc' LDSHARED='gcc -shared' OPT='-DNDEBUG -g -O3 -Wall -Wstrict-prototypes' ./python -E ./setup.py -q build;; \ *) CC='gcc' LDSHARED='gcc -shared' OPT='-DNDEBUG -g -O3 -Wall -Wstrict-prototypes' ./python -E ./setup.py build;; \ esac running build running build_ext building 'regex' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/regexmodule.c -o build/temp.solaris-2.7-sun4u-2.2/regexmodule.o gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/regexpr.c -o build/temp.solaris-2.7-sun4u-2.2/regexpr.o gcc -shared build/temp.solaris-2.7-sun4u-2.2/regexmodule.o build/temp.solaris-2.7-sun4u-2.2/regexpr.o -L/usr/local/lib -o build/lib.solaris-2.7-sun4u-2.2/regex.so WARNING: removing "regex" since importing it failed building 'pcre' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/pcremodule.c -o build/temp.solaris-2.7-sun4u-2.2/pcremodule.o gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/pypcre.c -o build/temp.solaris-2.7-sun4u-2.2/pypcre.o gcc -shared build/temp.solaris-2.7-sun4u-2.2/pcremodule.o build/temp.solaris-2.7-sun4u-2.2/pypcre.o -L/usr/local/lib -o build/lib.solaris-2.7-sun4u-2.2/pcre.so WARNING: removing "pcre" since importing it failed building '_hotshot' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/_hotshot.c -o build/temp.solaris-2.7-sun4u-2.2/_hotshot.o /home/hgs/Python-2.2.1/Modules/_hotshot.c: In function `get_version_string': /home/hgs/Python-2.2.1/Modules/_hotshot.c:1453: warning: subscript has type `char' gcc -shared build/temp.solaris-2.7-sun4u-2.2/_hotshot.o -L/usr/local/lib -o build/lib.solaris-2.7-sun4u-2.2/_hotshot.so WARNING: removing "_hotshot" since importing it failed building 'strop' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/stropmodule.c -o build/temp.solaris-2.7-sun4u-2.2/stropmodule.o /home/hgs/Python-2.2.1/Modules/stropmodule.c: In function `strop_atoi': /home/hgs/Python-2.2.1/Modules/stropmodule.c:769: warning: subscript has type `char' gcc -shared build/temp.solaris-2.7-sun4u-2.2/stropmodule.o -L/usr/local/lib -o build/lib.solaris-2.7-sun4u-2.2/strop.so WARNING: removing "strop" since importing it failed building 'rotor' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/rotormodule.c -o build/temp.solaris-2.7-sun4u-2.2/rotormodule.o gcc -shared build/temp.solaris-2.7-sun4u-2.2/rotormodule.o -L/usr/local/lib -o build/lib.solaris-2.7-sun4u-2.2/rotor.so WARNING: removing "rotor" since importing it failed building 'audioop' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/audioop.c -o build/temp.solaris-2.7-sun4u-2.2/audioop.o gcc -shared build/temp.solaris-2.7-sun4u-2.2/audioop.o -L/usr/local/lib -o build/lib.solaris-2.7-sun4u-2.2/audioop.so WARNING: removing "audioop" since importing it failed building 'imageop' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/imageop.c -o build/temp.solaris-2.7-sun4u-2.2/imageop.o gcc -shared build/temp.solaris-2.7-sun4u-2.2/imageop.o -L/usr/local/lib -o build/lib.solaris-2.7-sun4u-2.2/imageop.so WARNING: removing "imageop" since importing it failed building 'rgbimg' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/rgbimgmodule.c -o build/temp.solaris-2.7-sun4u-2.2/rgbimgmodule.o gcc -shared build/temp.solaris-2.7-sun4u-2.2/rgbimgmodule.o -L/usr/local/lib -o build/lib.solaris-2.7-sun4u-2.2/rgbimg.so WARNING: removing "rgbimg" since importing it failed building 'gdbm' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/gdbmmodule.c -o build/temp.solaris-2.7-sun4u-2.2/gdbmmodule.o gcc -shared build/temp.solaris-2.7-sun4u-2.2/gdbmmodule.o -L/usr/local/lib -lgdbm -o build/lib.solaris-2.7-sun4u-2.2/gdbm.so WARNING: removing "gdbm" since importing it failed building '_curses' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/_cursesmodule.c -o build/temp.solaris-2.7-sun4u-2.2/_cursesmodule.o In file included from /usr/include/curses.h:23, from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.3/include/curses.h:5, from /home/hgs/Python-2.2.1/Include/py_curses.h:8, from /home/hgs/Python-2.2.1/Modules/_cursesmodule.c:116: /usr/include/widec.h:42: warning: `getwc' redefined /usr/include/wchar.h:326: warning: this is the location of the previous definition /usr/include/widec.h:43: warning: `putwc' redefined /usr/include/wchar.h:329: warning: this is the location of the previous definition /usr/include/widec.h:44: warning: `getwchar' redefined /usr/include/wchar.h:327: warning: this is the location of the previous definition /usr/include/widec.h:45: warning: `putwchar' redefined /usr/include/wchar.h:330: warning: this is the location of the previous definition gcc -shared build/temp.solaris-2.7-sun4u-2.2/_cursesmodule.o -L/usr/local/lib -lcurses -ltermcap -o build/lib.solaris-2.7-sun4u-2.2/_curses.so WARNING: removing "_curses" since importing it failed building '_curses_panel' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/_curses_panel.c -o build/temp.solaris-2.7-sun4u-2.2/_curses_panel.o In file included from /usr/include/curses.h:23, from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.3/include/curses.h:5, from /home/hgs/Python-2.2.1/Include/py_curses.h:8, from /home/hgs/Python-2.2.1/Modules/_curses_panel.c:15: /usr/include/widec.h:42: warning: `getwc' redefined /usr/include/wchar.h:326: warning: this is the location of the previous definition /usr/include/widec.h:43: warning: `putwc' redefined /usr/include/wchar.h:329: warning: this is the location of the previous definition /usr/include/widec.h:44: warning: `getwchar' redefined /usr/include/wchar.h:327: warning: this is the location of the previous definition /usr/include/widec.h:45: warning: `putwchar' redefined /usr/include/wchar.h:330: warning: this is the location of the previous definition gcc -shared build/temp.solaris-2.7-sun4u-2.2/_curses_panel.o -L/usr/local/lib -lpanel -lcurses -ltermcap -o build/lib.solaris-2.7-sun4u-2.2/_curses_panel.so WARNING: removing "_curses_panel" since importing it failed building 'fpectl' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/fpectlmodule.c -o build/temp.solaris-2.7-sun4u-2.2/fpectlmodule.o gcc -shared build/temp.solaris-2.7-sun4u-2.2/fpectlmodule.o -L/usr/local/lib -o build/lib.solaris-2.7-sun4u-2.2/fpectl.so WARNING: removing "fpectl" since importing it failed building 'zlib' extension gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I. -I/home/hgs/Python-2.2.1/./Include -I/usr/local/include -IInclude/ -c /home/hgs/Python-2.2.1/Modules/zlibmodule.c -o build/temp.solaris-2.7-sun4u-2.2/zlibmodule.o gcc -shared build/temp.solaris-2.7-sun4u-2.2/zlibmodule.o -L/usr/local/lib -lz -o build/lib.solaris-2.7-sun4u-2.2/zlib.so WARNING: removing "zlib" since importing it failed running build_scripts not copying /home/hgs/Python-2.2.1/Tools/scripts/pydoc (up-to-date) neelix hgs 2 %> exit neelix hgs 3 %> script done on Mon Apr 15 13:58:14 2002 Hugh From phr-n2002a at nightsong.com Thu Apr 25 07:44:28 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 25 Apr 2002 04:44:28 -0700 Subject: Faster md5/1-way encryption? References: <20020424215752.GC15371@teich.Garten.DigitalProjects.com> <3CC7317B.3040208@rogers.com> Message-ID: <7xhem0vw83.fsf@ruckus.brouhaha.com> Alexander Skwar writes: > > myResults = string.join( myResults, os.linesep ) > > Yes, that makes sense. Thanks! > > > Which would save you creating and destroying huge numbers of (at the end > > of processing) very large strings. If you can avoid that last step > > Yes, I also noticed, that it gets slower and slower over the time. I don't understand this. Do you really want to accumulate a string containing 100,000 hash results (1.6 megabytes of hashes)? Or do you want to hash all the lines together and get one result? If you want to hash everything together, use d = md5.new() ... (in loop): d.update(zeile) result = d.digest() From JamesL at Lugoj.com Sat Apr 6 00:52:24 2002 From: JamesL at Lugoj.com (James Logajan) Date: 6 Apr 2002 05:52:24 GMT Subject: Booleans, integer division, backwards compatibility; where is Python going? References: <3CAE6DF8.9E655008@engcorp.com> Message-ID: Peter Hansen wrote: > Let me see if I'm clear on this. You are complaining about the entire > history of Python releases because of a problem you had with _Unicode_? _I_ didn't have any problem with Unicode. Python did. Python caused _forward_ incompatibilities, not just backward ones. > When was Unicode added to Python? That appears to be an irrelevant rhetorical question. One of the people using my program runs a Linux system running 1.5.2 and others seem to run 2.x versions on Windows. The Windows versions would get e-mail containing UTF-8 sequences and after being displayed in a Tkinter text widget, would, as far as I can tell, come out as Unicode. Whatever the case, the text couldn't be e-mailed on to anyone else because the POP module choked on trying to send it over a socket. > Did you really have such serious compatibility problems in other areas > that you were forced to abandon the language? There are other compatibility issues that gave me some problems. > Or was it just personal > distaste at the pace of change? Don't condemn the fast release cycle > just because you got screwed on one incompatibility. I condemn the growing number of versions that are proliferating. More versions invite a large probability of forward and backward compability problems. That is resulting in a Balkanization of the language. So I have concluded the fault is the fast release cycle. I can't change it, I didn't get any respectful responses when complaining about it a few months ago and still can't get any respectful responses this time around, so why is it so surprising that I should put aside the language after 4 some years? From cliechti at gmx.net Mon Apr 1 15:04:58 2002 From: cliechti at gmx.net (Chris Liechti) Date: 1 Apr 2002 21:04:58 +0100 Subject: readlines problems - Newbie References: Message-ID: "John Purser" wrote in news:k_1q8.146744$Yv2.44641 at rwcrnsc54: > I've got a little function: > def FindLine(Record): > im1_Dif.seek(0) > im1_Dif.readlines(Record - 1) > test = im1_Dif.readline() > print test > > When I call it I wind up with the same record in "test" whether I pass > it 1 or 10. The readlines line reads a huge chunk of text with no > regard for lines at all. I have no idea what is causing this. Where > can I find the documentation on the file methods? I can't find them > in the documentation. Can anyone tell me what's going on here? in the docs: http://www.python.org/doc/current/lib/bltin-file-objects.html you can see that this is a limit in bytes if even implemented. you can read all the lines in a buffer: >>> all = im1_Dif.readlines() and just work with the last one >>> test = all[-1] chris -- Chris From python at rcn.com Mon Apr 29 03:16:26 2002 From: python at rcn.com (Raymond Hettinger) Date: Mon, 29 Apr 2002 03:16:26 -0400 Subject: Comment on draft PEP for deprecating six builtins References: Message-ID: "Martin v. L?wis" wrote in message news:j4elgz9e9a.fsf at informatik.hu-berlin.de... > "Raymond Hettinger" writes: > > > The module additions would go into Python 2.3. All six > > functions would be left intact and raise deprecation warnings in > > Python 2.3 and 2.4. The six functions would be removed in Python > > 2.5 (having allowed two versions and a full year for code updates). > > I believe the phasing out of the old names should be even slower. In > 2.3, introduce the new names; leave the old names intact unchanged. In > 2.4 and 2.5, raise DeprecationWarnings; in 2.6, remove them. Agreed. From huaiyu at gauss.almadan.ibm.com Fri Apr 26 20:47:36 2002 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Sat, 27 Apr 2002 00:47:36 +0000 (UTC) Subject: Beyond __str__ and __repr__? (Was Re: Python doesn't know how to do math?) References: <1jvgcukdvfeakgq8lp284dofe3e8cnrla9@4ax.com> <3CC9C88A.9B447B18@alcyone.com> Message-ID: Erik Max Francis wrote: >Huaiyu Zhu wrote: > >> It appears that another display level is needed, somewhat between repr >> and >> str. Let's call it 'disp' here. It is intended to be used for >> display in a >> controlled way, esp for nested structures. > >Just derive a new class and override __str__ and/or __repr__ to do what >you want. > >Adding _another_ stringifying builtin function doesn't seem anywhere >near worth it. That's fine if the objects are user defined, but not when you build up structures from basic building blocks. - list, tuple and dict default to repr, so __str__ is out of the picture. - Overriding __repr__ deprives a handy means for identity-based display. - __repr__ for floats sucks for the purpose of display. There is no obvious way to define a stringifying function that automatically recurses over substructures (unlike str), works on builtins, and does not override __repr__. If we override __repr__, what is the best way to print the identity of an *arbitrary* object (not just id)? Huaiyu From emile at fenx.com Sat Apr 6 08:32:14 2002 From: emile at fenx.com (Emile van Sebille) Date: Sat, 06 Apr 2002 13:32:14 GMT Subject: single-quoted string conversion to triple-quoted string References: <%_Br8.20276$nt1.1661286@newsread2.prod.itd.earthlink.net> Message-ID: "robin and jim" wrote in message news:%_Br8.20276$nt1.1661286 at newsread2.prod.itd.earthlink.net... > > Gee, I thought it would be obvious why I was asking such a question ! > > As unit tests run, using the unittest module shipped with Python 2.2, the > default behavior is to display a one-line description of each test. The > default implementation displays the first line of the test method's > **docstring**, if available; otherwise the name of the test method (e.g., > "test_my_regular_expression") is displayed. Yes. This comes from the __doc__ attribute of the method. > > Well, yours truly thought he would be clever and add some additional > information to this docstring as it became available at run time via the % > placeholder mechanism. Alas, the result is a single-quoted string that > unittest does not recognize as a docstring so it displays the test method's > name (e.g., "test_my_regular_expression") instead. I, naively, think that if > the single quoted result can be re-converted to a triple-quoted string, it > will be recognized by unittest. > You could change the __doc__ attribute of the method before testing: import unittest class IntegerArithmenticTestCase(unittest.TestCase): def testAdd(self): ## test method names begin 'test*' self.assertEquals((1 + 2), 3) self.assertEquals(0 + 1, 1) def testMultiply(self): self.assertEquals((0 * 10), 0) self.assertEquals((5 * 8), 40) if __name__ == '__main__': testvals = [3,7,4,5] IntegerArithmenticTestCase.__dict__['testAdd'].__doc__ = 'testing with %s' % testvals unittest.main() HTH, -- Emile van Sebille emile at fenx.com --------- From rich at worldsinfinite.com Wed Apr 3 12:12:05 2002 From: rich at worldsinfinite.com (Rich Harkins) Date: Wed, 3 Apr 2002 12:12:05 -0500 Subject: How best to write this try/except block? In-Reply-To: References: Message-ID: <200204031713.g33HDM605101@cvg-65-27-138-13.worldsinfinite.com> On Wednesday 03 April 2002 12:10 pm, Jeff Youel wrote: > "Roy Smith" wrote in message > news:a8fba8$ln8$1 at panix2.panix.com... > > > I've got a dictionary d, which may or may not have a value I'm looking > > for. If it does, I want to do a few things. If it doesn't, I want to > > do a few other things. I could write: > > > > You can avoid the exception handler altogether with: > > value = d.get(key, None) > if value: > foo = stuff(value) > else: > foo = otherStuff(key) > > > Jeff One tweak on this if you want None to be allowed in your dictionary then do something like the following: def fn(d): MYBLANKVALUE='MYBLANKVALUE' obj=d.get(key,MYBLANKVALUE) if obj is MYBLANKVALUE: # Do something positive with obj else: # Do something else... Because of the is comparison even if "MYBLANKVALUE" is in d then this code will still work. Just don't intern whatever "MYBLANKVALUE" is (I frequently use undefined="UNDEFINED"). Rich From mwh at python.net Wed Apr 10 06:12:58 2002 From: mwh at python.net (Michael Hudson) Date: Wed, 10 Apr 2002 10:12:58 GMT Subject: big ints & elliptic curves References: Message-ID: "John" writes: > Is there any good library for multi-precision arithmetics in Python? Also > looking for elliptic curve implementations. In my experience you'll have a hard time getting acceptable performance for elliptic curve calculations using Python. I ended up using Haskell, I think... Cheers, M. -- ... Windows proponents tell you that it will solve things that your Unix system people keep telling you are hard. The Unix people are right: they are hard, and Windows does not solve them, ... -- Tim Bradshaw, comp.lang.lisp From roy at panix.com Mon Apr 8 10:47:02 2002 From: roy at panix.com (Roy Smith) Date: Mon, 08 Apr 2002 10:47:02 -0400 Subject: ACCEPTED: PEP 285 References: <3CAFAAA4.41EA7CF9@python.org> <+CcOX7A2gWs8EwPR@jessikat.fsnet.co.uk> <3CB1846B.5050109@geneva-link.ch> Message-ID: Boris Borcic wrote: > I'd rather note the typical elegance and economy of the BDFL's designs; > did you notice how he wrote "made my kill file" and not "made it to my > kill file" ? If he wanted to be truly elegant and economical, he'd have simply written "". From jimb417 at totalNOSPAMspeed.net Sat Apr 20 21:35:47 2002 From: jimb417 at totalNOSPAMspeed.net (Jim) Date: Sat, 20 Apr 2002 19:35:47 -0600 Subject: IDLE Help problem Message-ID: Hello to all, I'm running IDLE with Python 2.2.1. When I click on Help|Python Documentation, I get the following error: Exception in Tkinter callback Traceback (most recent call last): File "/usr/local/lib/python2.2/lib-tk/Tkinter.py", line 1292, in __call__ return apply(self.func, args) File "/usr/local/Python-2.2.1/Tools/idle/EditorWindow.py", line 304, in python_docs webbrowser.open(self.help_url) File "/usr/local/lib/python2.2/webbrowser.py", line 43, in open get().open(url, new, autoraise) File "/usr/local/lib/python2.2/webbrowser.py", line 38, in get raise Error("could not locate runnable browser") Error: could not locate runnable browser I have Opera, Konquerer, and Netscape available. What do I need to do to get rid of this error. I'm using Mandrake 8.0. Thanks in advance. Jim -- Registered Linux User #269187 http://counter.li.org/ From tdelaney at avaya.com Sun Apr 21 18:48:30 2002 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 22 Apr 2002 08:48:30 +1000 Subject: The Python Manual Index Message-ID: > From: Steve Holden [mailto:sholden at holdenweb.com] > > "Philip Swartzleonard" wrote in message > news:Xns91F5997F18E9ARASXnewsDFE1 at 130.133.1.4... > > > [Thomas Heller's new search interface] > > >> > > DeepBleu || Fri 19 Apr 2002 08:16:23a: > > > > > WOW! > > > Great Job! > > > > Indeed. Something like this needs to be added to the python.org > > interface... i've been wondering for a long time why they > don't have a > > document search function =). > > > Well, all they really needed to do was link to > > http://web.pydoc.org/ Not really - I just tried to use both systems to find the string formatting specifiers (something which I always have trouble finding in the standard docs). web.pydoc.org didn't find it for me (using "string format", "formatting", "format", etc). Thomas' system found it for me immediately using "formatting". Thomas - this is wonderful :) Tim Delaney From mwh at python.net Mon Apr 15 07:38:24 2002 From: mwh at python.net (Michael Hudson) Date: Mon, 15 Apr 2002 11:38:24 GMT Subject: Do you QA your Python? Was: 2.1 vs. 2.2 References: <7xr8lic2yb.fsf@ruckus.brouhaha.com> Message-ID: bokr at oz.net (Bengt Richter) writes: > Apparently 1.5.2 and 2.1.x and 2.2.x are semi-official baseline > versions. Is it/could it be official policy that > #!/usr/bin/python(15|21|22) links should exist if a site has the > identified version? If you run "make install" you should have $(prefix)/bin/python$(VERSION) where $(VERSION) is x.y (eg. 2.1, 1.5). Cheers, M. -- The Internet is full. Go away. -- http://www.disobey.com/devilshat/ds011101.htm From theller at python.net Tue Apr 16 13:13:36 2002 From: theller at python.net (Thomas Heller) Date: Tue, 16 Apr 2002 19:13:36 +0200 Subject: Newbie question References: Message-ID: "Ante" wrote in message news:a9hhbs$1ksn$1 at as201.hinet.hr... > from file 'dummy.py' > ---------------------------- > num = 0 > > def dummy(): > num += 1 > > dummy() > ---------------------------- > > now, in the interpreter: > > >>> import dummy > Traceback (most recent call last): > File "", line 1, in ? > File "C:\downloads\python2.2.1\dummy.py", line 6, in ? > dummy() > File "C:\downloads\python2.2.1\dummy.py", line 4, in dummy > num += 1 > UnboundLocalError: local variable 'num' referenced before assignment > > > Why does this happen? > If I replace num += 1 with print num, it prints 0 without an error. > I guess it scans the whole function and check if there's an assignment to a > name, > and if there is, assumes it's a local variable. But += isn't supposed to > move the > reference but instead change the same variable. Or what did I get wrong? > > Ante. > Take a look: C:\>python -OO Python 2.2.1 (#34, Apr 9 2002, 19:34:33) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> num = 1 >>> def f(): ... num += 100 ... >>> f() Traceback (most recent call last): File "", line 1, in ? File "", line 2, in f UnboundLocalError: local variable 'num' referenced before assignment >>> import dis >>> dis.dis(f) 0 LOAD_FAST 0 (num) 3 LOAD_CONST 1 (100) 6 INPLACE_ADD 7 STORE_FAST 0 (num) 10 LOAD_CONST 0 (None) 13 RETURN_VALUE >>> Behind the scenes, the value bound to 'num' is retrieved, 100 is added 'inplace', and the result will be stored back. It wouldn't work otherwise - integers are immutable in Python. Thomas From mlh at vier.idi.ntnu.no Mon Apr 8 03:47:07 2002 From: mlh at vier.idi.ntnu.no (Magnus Lie Hetland) Date: Mon, 8 Apr 2002 07:47:07 +0000 (UTC) Subject: PEP 285: Adding a bool type References: <3CB0495F.7010507@mxm.dk> Message-ID: In article , Lulu of the Lotus-Eaters wrote: [snip] >Of course, I'm sure I'll be justly condmened for preferring: > > fs = (can_be_moved, can_be_sized, can_be_stacked, > can_be_coloured, can_be_hidden) > major = len([1 for f in fs if f(o)])) > >to either :-). Why not... from operators impor add fs = ... major = reduce(add, [f(o) for f in fs]) OTOH, if you can write the tuple in the fs-assignment, writing a similar sum shouldn't be that hard ;) >Yours, Lulu... -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org From mwh at python.net Wed Apr 17 10:37:16 2002 From: mwh at python.net (Michael Hudson) Date: Wed, 17 Apr 2002 14:37:16 GMT Subject: Counterintuitive Python behavior References: Message-ID: Michael Hudson writes: > > The next time a co-worker asks a assignment/binding/references > > question I'm going to refer them to this message. > > I was hoping more people than the OP would find it useful. I'll > probably knock up a version for my web pages (when the starship > reappears...). I should say that Alex's answer is well worth referring to too. I wonder if he would mind me incorporating it into aforementioned webpage... Cheers, M. -- If a train station is a place where a train stops, what's a workstation? -- unknown (to me, at least) From brueckd at tbye.com Fri Apr 12 12:57:21 2002 From: brueckd at tbye.com (brueckd at tbye.com) Date: Fri, 12 Apr 2002 09:57:21 -0700 (PDT) Subject: Tuple comprehension In-Reply-To: <23328581.1018597365@[192.168.1.102]> Message-ID: On Fri, 12 Apr 2002, David Eppstein wrote: > On 4/12/02 8:20 AM -0700, brueckd at tbye.com wrote: > > The implication is that tuples group bits of often dissimilar but related > > information that, grouped together, represent a unique entity - sort of a > > poor man's object instance. > > But there's nothing preventing a list from holding inhomogeneous items, > either. Yes (and, once again, in that case the usefulness of comprehensions break down), but in the general sense they are most powerful when there *is* some common feature to the items in the list. Obviously the common ground can range from quite specific (a list of integers) to quite broad (a list of whatevers that this function is capable of processing). If the items don't have this sort of relation, why do you have them in a list anyway? > So I don't see how this is a difference between tuples and lists, > unless it's just one of standardized style. The essence of this discussion is that it *is* more than a difference of just standardized style - tuples were built for one thing and lists another, albeit with a certain amount of overlap. Tuples work well in the record-like or dictionary key scenario, while lists are more general purpose, for use when you need to apply similar processing to a lot of "stuff". If tuples don't seem to do all you want it *might* indicate that an enhancement to the language is in order, but maybe it means that a different data type would be more appropriate. Spoons and forks solve similar problems, and in many cases it doesn't matter which you choose to use even though they were designed to solve slightly different problems. If your ice cream refuses to cooperate with your fork it *might* mean you need a better fork, but maybe it means you should use a spoon (or a spork[1]). -Dave [1] http://www.sonic.net/~ian/Spork/spork.faq.html From anthony at interlink.com.au Wed Apr 10 09:55:14 2002 From: anthony at interlink.com.au (Anthony Baxter) Date: Wed, 10 Apr 2002 23:55:14 +1000 Subject: Easter Eggs In-Reply-To: Message from Kalle Svensson of "Wed, 10 Apr 2002 00:35:50 +0200." <20020409223550.GC16263@proton.lysator.liu.se> Message-ID: <200204101355.g3ADtEZ25492@mbuna.arbhome.com.au> >>> Kalle Svensson wrote > [Lulu of the Lotus-Eaters] > > Who can tell me what's in there. Someone on c.l.py recently let drop > > the hint about finding the Zen of Python at the interactive prompt in > > 2.2. I went so far as trying the command in Python versions 1.51, 1.52, > > 2.0, 2.1, 2.2 (it's only in 2.2)... but then promptly forgot what the > > magic command was. Can someone remind me, please? > "import this", IIRC. It's in 2.1.2, 2.1.3, 2.2, and 2.2.1. Anthony -- Anthony Baxter It's never too late to have a happy childhood. From jon+usenet at unequivocal.co.uk Fri Apr 19 22:41:53 2002 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Sat, 20 Apr 2002 02:41:53 -0000 Subject: Substitution with Hash Values References: Message-ID: In article , holger krekel wrote: > re.sub('\{\{(.*?)\}\}',lambda x: dict[x.group(1)], str) Need a raw string there, i.e. r"\{\{(.*?)\}\}" Plus 'str' is perhaps not the best choice of variable name ;-) From marklists at mceahern.com Thu Apr 11 17:22:44 2002 From: marklists at mceahern.com (Mark McEahern) Date: Thu, 11 Apr 2002 16:22:44 -0500 Subject: emacs python mode completion Message-ID: Python mode in emacs has the nice syntax coloring and all, but what would be really great is if I could press tab or something and have it complete statements. I found this thread where Guido replied and pointed out rlcompleter and the like for the interactive interpreter: http://groups.google.com/groups?hl=en&selm=199801111855.NAA21082%40eric.CNRI .Reston.Va.US Is there a tool for emacs that does Python command completion? Thanks, // mark From bellman at lysator.liu.se Sat Apr 6 21:41:16 2002 From: bellman at lysator.liu.se (Thomas Bellman) Date: Sun, 7 Apr 2002 02:41:16 +0000 (UTC) Subject: ACCEPTED: PEP 285 References: Message-ID: James Logajan writes: > Sorry, I meant to use "major" here as in "there are new features or > semantic changes in this release that if you use in your code, it wont run > at all or as you expect on previous releases". Doesn't matter what you call > it, if a 2.1 script can't run at all or as expected on 2.0, that is a major > change in the _colloquial_ sense. I consider the nature of the changes > between so-called "minor" releases and their frequency a major problem to > _me_. I don't think you can realistically "argue" those problems away. I am > hoping that you will try to accommodate my experiences into your Python > world view before brushing them off. I think your world-view is broken. If a program uses new features in a release, or even just assumes the bug-fixes in that release to be present, then the program *obviously* won't work the way it was intended if you run it in a release old enough to *lack* those features or bug-fixes. It doesn't matter if those new features involve the introduction of static typing, if it's a new library module not present in the older release, a new function, or just fixing a bug so that Python behaves as documented. The program which is written assuming those new features, won't work in a Python version old enough to not have them, irregardless of how small the changes are. If your definition of a minor release is that no program written for that new release will behave differently when run on the previous release, then it is a useless release, because it changes *nothing*, it does not even fix bugs. 100% *forward* compatibility can only be achieved by not changing anything at all. -- Thomas Bellman, Lysator Computer Club, Link?ping University, Sweden "God is real, but Jesus is an integer." ! bellman @ lysator.liu.se ! Make Love -- Nicht Wahr! From rjgruet at yahoo.com Thu Apr 18 16:59:49 2002 From: rjgruet at yahoo.com (Richard Gruet) Date: Thu, 18 Apr 2002 22:59:49 +0200 Subject: why no 'length' method in sequences ? References: Message-ID: Alex Well, this is a very impressive and learned argumentation and I don't doubt that using operators and built-in functions offer a better polymorphism. I just meant that to my human eyes, it is easier to memorize when everything is consistently object oriented and there are only methods (like in Java - and I prefer Python to Java :-), or the contrary, only functions. Then I have not to remember which functions are methods and which ones are built-in. I think this is because a mixed model is more complicated than a non-mixed one. And BTW, people would not to have implement any __len__ method if all the sequence types would derive from a common ancestor (sequence), in which the (in)famous method would be implemented. Would it be completely nonsensical ? I have been told that starting from 2.2, new style classes (including most built-in types) all derive from a common base class 'object'. NB: I am NOT setting a dispute, but just expressing my feeling from a user perspective. Richard "Alex Martelli" wrote in message news:zwFv8.36236$vF6.1097456 at news2.tin.it... > Richard Gruet wrote: > > > Hi all > > > > I wonder why there is no 'length' (or 'len') method - or attribute - in > > the sequences types. Having to use the built-in function len() doesn't > > sound very Object-Oriented to me. I understand that the built-in function > > len() must be kept for compatibility reasons, but why not to add also the > > method len() to the sequence types ? Is there a reason ? > > I would be a silly burden on people who want to implement a sequence > type, to make them define a method called len that is an exact synonym > for the existing special method __len__. And it would be an intolerable > burden, conceptually and in terms of performance, if looking up an > attribute named 'len' performed strange black-magic contortions (even > worse if those contortions were specialized for only the cases in which > said attribute is meant to be called -- remember Python does not draw > deep distinctions between attributes meant to be called, and others). > > It may not SOUND "very Object-Oriented", but having special methods > "clothed" by means of built-ins and operators is a clever and subtle > set-up, as I tried explaining in the other post to this thread. And Python > has always preferred the steak to the sizzle, whenever choice was needed: > part of what makes it such a great language. > > > Alex > From phr-n2002a at nightsong.com Sat Apr 13 13:52:20 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 13 Apr 2002 10:52:20 -0700 Subject: newbie-question: interfaces References: <3cb7f47e$0$360$9b622d9e@news.freenet.de> <3cb843d0$0$4068$9b622d9e@news.freenet.de> <82bscn4nvz.fsf@acropolis.localdomain> Message-ID: <7xr8lja3l7.fsf@ruckus.brouhaha.com> Patrick W writes: > Do you have a technical reason to actually want interfaces, or are you > simply experimenting with the concept? > > As far as I can see, which is admittedly not that far, interfaces > don't really serve a useful purpose in Python. If you want > polymorphism in statically typed OO languages like C++ and Java, you > need to design your functions and methods to accept only objects > descended from a known type. But in Python, the type need not > (actually cannot) be specified at design time, so what purpose would > an interface serve? Wouldn't it be better to just inherit > _implementation_ when necessary, rather than to inherit pure > interfaces? > > I ask this not to be a prick, but to find out if I'm missing something > important. The purposes of interfaces in java is mostly to provide a form of multiple inheritance. Java doesn't support multiple base classes, so interfaces are a workaround for that. Python supports multiple base classes directly so it doesn't need a workaround. From starx at pacbell.net Tue Apr 2 20:04:03 2002 From: starx at pacbell.net (Philip Swartzleonard) Date: 3 Apr 2002 01:04:03 GMT Subject: Someone using PyGtk References: <3ca9d7d1$1_2@news.uni-bielefeld.de> Message-ID: Jeff Shannon || Tue 02 Apr 2002 01:55:39p: > In article <3ca9d7d1$1_2 at news.uni-bielefeld.de>, mario at bio58.uni- > bielefeld.de says... > >> wxPython looked good, but it is so damn slow on my machine >> (PPro 200) even on very small programs (hello - world). > > Hm, wxPython seemed to perform adequately for me, on a (Win95) > P200 with only 64MB RAM. > > (Yeah, it's slow, but so is everything *else*, too! ;) ) > I use WX too, and it seems that you pretty much pay a fixed price for importing the modlue, no matter how much you need or how big your program is. I'd think most other frameworks would have the same problem, an easy way to tell would be something like: print "Loading wxPython...", from wxPython.wx import * print "done" ... I bet most of your execuation time for a hello world program would be between those prints. -- Philip Sw "Starweaver" [rasx] :: www.rubydragon.com From cepl.m at neu.edu Fri Apr 26 19:28:03 2002 From: cepl.m at neu.edu (Matej Cepl) Date: Fri, 26 Apr 2002 23:28:03 +0000 (UTC) Subject: iis: comparsion of two lists In-Reply-To: <20020426224924.GA1318@rehor.surfbest.net> References: <20020426224924.GA1318@rehor.surfbest.net> Message-ID: <20020426232802.GA1927@rehor.surfbest.net> On Fri, Apr 26, 2002 at 10:49:24PM +0000, Matej Cepl wrote: > erase = () > for msg in proc_old: > if not(msg in loc_old): > erase.append(msg) Oh, boy, I an answer myself. Sorry, for that. Am I correct, that mere erase = () erase = filter (lambda m: return not(m in loc_old), proc_old) would fly? Thanks Matej -- Matej Cepl, cepl.m at neu.edu 138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488 I believe in the power of prayer. It's been said: "I would rather stand against the cannons of the wicked than against the prayers of the righteous." The prayers of a friend are one of life's most gracious gifts. -- George W. Bush at the 2001 National Prayer Breakfast From jdhunter at nitace.bsd.uchicago.edu Mon Apr 22 22:11:46 2002 From: jdhunter at nitace.bsd.uchicago.edu (John Hunter) Date: Mon, 22 Apr 2002 21:11:46 -0500 Subject: flatten tuple References: Message-ID: >>>>> "Delaney," == Delaney, Timothy writes: >> I want to be able to create a new tuple, which is the expanded >> and flattened version x, so that if an element of x is a key of >> m, then the new list has that value instead of the key value . >> In the example Delaney> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/121294 Delaney> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/118845 Thanks for the tips -- these look helpful. It appears that I can not use the yield features of generators with 2.1.3. I tried 'from __future__ import generators' but still got a Syntax Error on each of the yield lines. Is this feature only supported in the 2.2 line, even with the __future__ ? It may be time to upgrade my python soon... Thanks, John Hunter From duncan at NOSPAMrcp.co.uk Tue Apr 30 05:11:50 2002 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 30 Apr 2002 09:11:50 +0000 (UTC) Subject: Cookie encoding References: Message-ID: Terry Hancock wrote in news:mailman.1020145372.5420.python-list at python.org: > I'm trying to put a builtin Python object into an HTTP > cookie for saving state information in a Zope web app. Can you not use SESSION.set() which would save your object locally and just put a session id in the cookie? -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From s328940 at student.uq.edu.au Tue Apr 30 00:42:54 2002 From: s328940 at student.uq.edu.au (Alejandro Dubrovsky) Date: Tue, 30 Apr 2002 14:42:54 +1000 Subject: how to pickle a lambda? References: <3ccc58db$0$14003$afc38c87@news.optusnet.com.au> <3CCC730A.FC60D13F@alcyone.com> <3ccd1ed9$0$15477$afc38c87@news.optusnet.com.au> <837kmqrvxl.fsf@panacea.canonical.org> <7xit6aqdz5.fsf@ruckus.brouhaha.com> Message-ID: <3cce1e79$0$15473$afc38c87@news.optusnet.com.au> On Tue, 30 Apr 2002 09:31:10 +1000, Paul Rubin wrote: >> Or you can just use named functions, especially if you don't have >> closure data. > > I thought a named function was just a variable whose value was a lambda: > > def square(x): return x*x > > is the same as > > square = lambda x: x*x > > Of course the syntax is different (you can't have control statements in > a lambda) but I'd have thought if you can't marshal a lambda, you also > can't marshal a named function. well, that's right, you can't. that's why i was pickling functions by storing their .__name__ Alejandro From aahz at pythoncraft.com Sat Apr 6 00:06:21 2002 From: aahz at pythoncraft.com (Aahz) Date: 6 Apr 2002 00:06:21 -0500 Subject: ACCEPTED: PEP 285 References: <3CADF01A.7F0974B2@python.org> Message-ID: In article , James Logajan wrote: >Guido van Rossum wrote: >> >> You could have typed the code in to Python 2.2 and gotten >> your answer. > >Therein lies the problem: I typed it into Python 2.1 and naturally it >didn't work. I loaded 2.1 onto my laptop mid-year last year to be "up to >date" and I see that less than a year later my version is out of date. (By >comparison, my Linux machine still has 1.5.2 so I can do version checks.) Python 2.1 (particularly 2.1.2) is a fine release. There's no compelling reason to upgrade unless you care about the type/class unification. But it's foolish at best to stick your nose into a thread about language changes without finding what the current state of the language is. You seem to make a habit of irresponsible posts. (Remember your actions in the comp.distributed brouhaha?) >Seriously Guido, how often will I need to check back to www.python.org to >keep up with the changes you are making? Do you have a schedule or some >constraints in place on how fast you are releasing major versions? The current standard is approximately one release every six months. -- Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/ "There are times when effort is important and necessary, but this should not be taken as any kind of moral imperative." --jdecker From eppstein at ics.uci.edu Wed Apr 10 20:10:41 2002 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 10 Apr 2002 17:10:41 -0700 Subject: looping throuhg a list 2 items at a time References: Message-ID: In article , Rajarshi Guha wrote: > I got this code to work: > > liter = iter(l) > while(1): > try: > print liter.next(), liter.next() > except StopIteration: > break > > Works fine - is it an efficient way to handle this situation? > (I could arrange the data into tuples if necessary) Does it work fine? What if the list has an odd number of items -- the last item won't be printed. In one situation I had a list of items that I wanted to handle three at a time, except that, if the number of items in the list was not a multiple of three, I wanted to handle the last two as a pair, or the first two and last two both as pairs. I ended up writing the part that handled pairs or triples as a separate function, calling it once for an initial pair (if any), then having a separate loop for the triples and final pair: if len(L) % 3 == 1: loopbody(L[:2]) L = L[2:] while len(L) > 0: loopbody(L[:3]) L = L[3:] this worked ok in my situation but is unsatisfactory as a general technique because all the slicing can be slow for long lists -- I guess you could use an index into your list instead: i = 0 while i < len(L): print L[i:i+2] i += 2 Unfortunately due to the non-functionalness of print, I don't see a way of writing one print statement that will give the same results as "print L[i],L[i+1]" without sometimes throwing an exception. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From cnd at ecn.purdue.edu Tue Apr 2 09:40:32 2002 From: cnd at ecn.purdue.edu (Christopher N. Deckard) Date: Tue, 02 Apr 2002 09:40:32 -0500 Subject: verifying ssl certificates References: <3CA88D15.140053DC@ecn.purdue.edu> <7x7knrdv9k.fsf@ruckus.brouhaha.com> Message-ID: <3CA9C2E0.EA8A2B15@ecn.purdue.edu> Paul Rubin wrote: > > "Christopher N. Deckard" writes: > > I was wondering if anyone has some sample code, or could point me at > > some documentation, to where I can see how to verify SSL > > certificates after making an SSL connection via sockets. Is it as > > simple as comparing the response of the server to that of something > > in a file? > > Usually you configure the SSL stack to do this for you. If the > certificate doesn't verify, the SSL connection won't even open, > so your application will never get to see an invalid cert. In other words: import socket cert = open('my_cert') s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('host', 'port')) ss = ssl(s, cert, None) That last line being the key. Does that do the certificate validation? -Chris From andersjm at dancontrol.dk Wed Apr 24 05:02:53 2002 From: andersjm at dancontrol.dk (Anders J. Munch) Date: Wed, 24 Apr 2002 11:02:53 +0200 Subject: String handling bug in Python References: <3cc5d5c8$1@news.nz.asiaonline.net> <3cc6036f$1@news.nz.asiaonline.net> Message-ID: <3cc67564$0$11927$edfadb0f@dspool01.news.tele.dk> wrote: > On Wed, Apr 24, 2002 at 12:57:02PM +1200, Colin Brown wrote: > > Thanks guys > > > > I did not think to look up this "documented feature", sorry. Not your fault, Colin, after all it's in the reference manual which the docs refers to as "for language lawyers". A lot of (most?) newbies trip over this. (Well I did anyway ;-) > > Well, how else would you suggest that "raw" strings should work? For > instance, if you want to let > r'\' == '\\' > how will you write the raw string that equals "\\'"? Python raw strings are delineated like this: A raw string ends at the first matching quote character which is not preceded by an odd number of consecutive backslashes. It would be great if I could have written this instead: A raw string ends at the first matching quote character. Much simpler, every bit as useful and - dare I say it - more pythonic than the current semantics. The paragraph Andrew quoted from the reference manual could then be shortened to: "When an `r' or `R' prefix is present, the backslash character is not subject to any kind of special interpretation." A raw string that equals "\\'"? I would write that r"\'". I-just-hope-MSOE-will-let-me-post-this-unmangled-ly-y'rs, Anders From mlh at vier.idi.ntnu.no Mon Apr 15 07:42:05 2002 From: mlh at vier.idi.ntnu.no (Magnus Lie Hetland) Date: Mon, 15 Apr 2002 11:42:05 +0000 (UTC) Subject: What is free software? [Re: Licenses and Open Source don't conflict.] References: <12bb92e6.0204091223.738e0798@posting.google.com> <1vKt8.21374$Kq4.896208@news2.calgary.shaw.ca> <87g01x1r6o.fsf@tleepslib.sk.tsukuba.ac.jp> <7xelhhmq5e.fsf@ruckus.brouhaha.com> Message-ID: In article <7xelhhmq5e.fsf at ruckus.brouhaha.com>, Paul Rubin wrote: [snip] >The non-GPL-ness of Python is a main reason I don't have much interest >in doing significant development work on the Python implementation >(though I'm willing to make smaller enhancements to fill my own >requirements, and send in the patches). On the other hand, Python's >non-GPL may have attracted some corporate development money, so it's a >trade-off. And of course some volunteers do contribute heavily. It's >a decision everyone has to make for themselves based on their own >priorities. Well -- the Python license is GPL-compatible, so couldn't you just release a GPL'ed version of it, if that would make you happy? Of course, the original would still be freely available without the added burden of the GPL restrictions, but if you're really interested in freedom, that shouldn't bother you... -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org From tdelaney at avaya.com Mon Apr 22 20:49:14 2002 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 23 Apr 2002 10:49:14 +1000 Subject: flatten tuple Message-ID: > From: John Hunter [mailto:jdhunter at nitace.bsd.uchicago.edu] > > I want to be able to create a new tuple, which is the expanded and > flattened version x, so that if an element of x is a key of m, then > the new list has that value instead of the key value . In the example http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/121294 http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/118845 Always check the cookbook http://aspn.activestate.com/ASPN/Python/Cookbook/ Tim Delaney From gtalvola at nameconnector.com Fri Apr 5 12:38:43 2002 From: gtalvola at nameconnector.com (Geoffrey Talvola) Date: Fri, 5 Apr 2002 12:38:43 -0500 Subject: Newbie's 1st Web App decisions! Message-ID: Scrumpy wrote: > I do like to separate style, layout, app and data and will > avoid using PSP, > Cheetah etc. completely or at least in ways which integrate > app code within > HTML pages. Webware's PSP certainly doesn't require you to mix app code into your pages. I use PSP extensively, but all of the app logic is contained in other Python modules -- either WebKit Servlets which are used as base classes for the PSP, or just as regular old reuseable Python modules. The only code I include in the PSP is simple presentation-level stuff like if statements, for loops, etc. that you need to render the page properly based on the data. It's all very natural and easy with Webware's PSP. I think that the *SP model got a bad reputation from Microsoft's Active Server Pages, where the methods for splitting out your app logic from your presentation logic require more labor-intensive techniques like writing the app logic into "middle-tier" compiled Visual Basic COM objects or writing "scriptlets" in a combination of VBScript and an unusual XML-ish wrapper. So many people wound up just including the app logic directly in the ASP pages because it was easier. But really, Webware's PSP's make it so easy and natural to separate out your app logic into Python modules that you can't use that as an argument against PSP. A better argument against PSP is that it isn't web-designer-friendly. That was a primary motiviation for creating Cheetah -- because its syntax is considered better for non-programmers than PSP's syntax. - Geoff From jiba at tuxfamily.org Tue Apr 2 06:21:32 2002 From: jiba at tuxfamily.org (Lamy Jean-Baptiste) Date: Tue, 02 Apr 2002 13:21:32 +0200 Subject: Romance object sharing Message-ID: Hi everyone ! I want to introduce Romance. Romance is an heterogeneous vision of programming / hacking. It relies on a light dynamic object sharing protocol for sharing between different programmic languages and programs (such as desktop applications). In the future Romance will be more than that. It may provide a full library, including even a graphic toolkit ! Romance is a free (GPL'ed) alternative to .NET, CORBA / Bonobo or XML-RPC. It allows to share objects between languages, but keeps the each language's interpreter (contrary to .NET) and look-and-feel (you code Python, not C#). Romance currently support Python, Guile (Scheme) and C. Future versions will support other scripts languages (Perl, Ruby, ...), Lisp / Scheme (ELisp, ...) and other dynamic languages (Smalltalk, OCaml)... Romance is available at : http://oomadness.tuxfamily.org/romance/en/index.html http://savannah.gnu.org/projects/romance The use of Romance in Python is totally transparent. Here is an example of a Romance server : # Step 1: import and init Romance ! import romance # Step 2: create our stuff : the Person factory class Person: def __init__(self, name, proof): self.name = name self.proof = proof def get_description(self): return "%s is a %s." % (self.name, self.proof) # Step 3: make it available to any Romance app as "romance.Person" romance.Person = Person # Step 4: wait for client ! romance.serve_forever() And the corresponding client : # Step 1: import and init Romance ! import romance # Step 2: access to Romance lib and data (and modify them if you want !!!) # Here, create me as a person ! jiba = romance.Person("Jiba", "hacker") print "My name is :", jiba.name print "More precision :", jiba.get_description() print print "Server is in %s" % jiba.__lang__() => My name is : Jiba => More precision : Jiba is a hacker. => => Server is in python The client is in Python too (because comp.lang.python !), but it can be Guile, or whatever "romantic" language ;-) Jiba From netzapper at magicstar.net Thu Apr 4 13:10:58 2002 From: netzapper at magicstar.net (A. Jones) Date: Thu, 04 Apr 2002 18:10:58 GMT Subject: turning a string into an object name References: <1017881888.857285@DS9.ai-lab.fh-furtwangen.de> <3cabf705.91920985@mammoth.usenet-access.com> Message-ID: <3cac943f.132176618@mammoth.usenet-access.com> On Thu, 04 Apr 2002 11:56:24 GMT, Alex Martelli wrote: >You cannot use ANY identifier safely after that exec >statement, as you have no idea any more what the >identifier can refer to. As a bonus, your code crawls, >since the Python compiler knows it does not know, and >therefore executes a full identifier look-up at runtime >rather than recognizing local variables at compile time. > >What kind of useful code can you write without being >able to use ANY identifier safely? WHY would you ever >WANT to trample all over your namespace to ensure every >identifier becomes an utter and total mystery? Beats me. I agree with you if it's an arbitrary string being passed to your exec call . However, if you have some idea of what the form of the string is going to be, it doesn't seem so dangerous. For instance: for x in range(0, 100): exec foo + `x` + " = " + "myClass()" allows you to easily make a large list of sequentially named variables, with no chance of stepping on a system call. Furthermore, you can wrap it inside a class. class test: def wrongHeaded(self, name, value): exec "self."+name+'='+repr(value) print vars() this produces no exceptions, and doesn't cause any problems, since vars is never defined... only self.vars is. Netzapper/Aubrey Jones -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==---------- http://www.newsfeeds.com The Largest Usenet Servers in the World! ------== Over 100,000 Newsgroups - Ulimited downloads - 19 servers ==----- From mats at laplaza.org Thu Apr 4 11:41:23 2002 From: mats at laplaza.org (Mats Wichmann) Date: Thu, 04 Apr 2002 16:41:23 GMT Subject: ACCEPTED: PEP 285 References: Message-ID: <3cac7f2d.137279317@news.laplaza.org> On Wed, 03 Apr 2002 17:32:52 -0500, Guido van Rossum wrote: :I believe this problem should be solved by education (the Zen master :hits the student on the head with a stick, and the student gets :enlightenment) rather than by holding back what I believe will be a :useful feature. As a sometime Python educator, I have a problem with this approach: it has become rather hard to carry the stick on airplanes, if necessary to fly to the venue. I'll have to wander down to the neighborhood stupa and ask the lama for alternative suggestions. grin :-) Mats Mats Wichmann From cnd at ecn.purdue.edu Mon Apr 1 11:38:45 2002 From: cnd at ecn.purdue.edu (Christopher N. Deckard) Date: Mon, 01 Apr 2002 11:38:45 -0500 Subject: verifying ssl certificates Message-ID: <3CA88D15.140053DC@ecn.purdue.edu> I was wondering if anyone has some sample code, or could point me at some documentation, to where I can see how to verify SSL certificates after making an SSL connection via sockets. Is it as simple as comparing the response of the server to that of something in a file? Thanks, -Chris -- -------------------------------------------------------------------- Christopher N. Deckard | Lead Web Systems Developer cnd at ecn.purdue.edu | Engineering Computer Network http://www.ecn.purdue.edu/ | Purdue University ---- zlib.decompress('x\234K\316Kq((-J)M\325KM)\005\000)"\005w') --- From gcash at luncheonmeat.cfl.rr.com Fri Apr 26 21:51:03 2002 From: gcash at luncheonmeat.cfl.rr.com (gcash) Date: Sat, 27 Apr 2002 01:51:03 GMT Subject: modifying classes used by other classes Message-ID: <1yd129kx.fsf@cfl.rr.com> OK, here's a rough question in OOP that I've been tangling with... I've tried googling about it, but I'm not even really sure of my terminology, so that's not been much help. So you've got a module that defines 2 classes: spam is the main class to be used by apps, and it instantiates a whole bunch of "eggs". class eggs: def __init__: ... def scramble: ... def drop: ... class spam: def __init__: ... def ham: ... ... The problem is you want to override methods of eggs. You can subclass eggs all you want, but since spam doesn't use your subclass, you're out of luck. You're reduced to ugly things like setting methods of eggs equal to functions you define. Should I pass the class for eggs as an argument to spam's __init__, which defaults to the eggs defined by the module? That seems rather clumsy in a lot of ways. A more concrete example: a tkinter tree widget class that creates a structure of a whole bunch of node instances, each node representing a folder in the tree. What would the best way for a user to alter the node class so it binds a certain mouse click to it's symbol when instantiated? Another example: a GPS class which creates lists of track, route, and waypoint instances - how do I best override the __repr__ for the track class, so it prints the way I want? What's the best OOP term for classes like "eggs", anyways? "Helper class"? It's definitely not a mix-in, obviously. "Helper class" didn't show up much on google, though. -gc -- It was pretty sad, really. When I heard him start to explain 56K, it was like watching someone try to explain quantum physics to a goat. At that point, though, he had no choice it was like the Titanic after the iceberg, just a matter of time until the people started screaming. From mlh at vier.idi.ntnu.no Tue Apr 30 14:35:51 2002 From: mlh at vier.idi.ntnu.no (Magnus Lie Hetland) Date: Tue, 30 Apr 2002 18:35:51 +0000 (UTC) Subject: Update locals() / resolved References: <20020427195725.GA16217@devel.trillke> <20020427150607.A2052@unpythonic.net> <20020427202326.GB16217@devel.trillke> Message-ID: In article , Steve Holden wrote: [snip] >> > Why use type({}) when you can use dict? >> >[ ... good reasons ...] >> >> 3. And 'dict' is something i often use in local definitions >> when working with dictionaries. >> >Yeah, well we all have to cut that out and start using "adict" or "thisdict" >pretty sharpish. This one bites now. How so? It only "bites" if you actually need access to the dict type in the same scope where you bind your variable... I've got plenty of code with stuff like file = open('foo.bar') and it doesn't bother me one bit (except in the cases where 'file' should have been something more descriptive, I guess ;) Thes names aren't reserved in any way... >regards > Steve -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org From aleax at aleax.it Thu Apr 11 11:44:54 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 11 Apr 2002 15:44:54 GMT Subject: A trivial question about print References: Message-ID: Ante Bagaric wrote: ... > BTW, i never wrote a single line in Python but it looks darn attractive > from what I have read so far. Just that this print behaviour brings some > reminiscence to Fortran output formatting where some thing just happen and > there's nothing you can do about it :) print is not really meant for "production-level" output, such as reporting and so on. It's meant to be handy for quick & dirty "let's see what this look like" things, and it is. > Sure in most cases this feature helps, you dont need zillion " " strings > between your variables :), but wouldnt it be nice if there was > python-simple way to just get around it? There IS -- it's sys.output.write (or more generally the write method of any file object). Does no formatting -- it emits a string, and that's all. The formatting you do by preparing the string. The % operator is most often what you want there. You don't get full control since it relies to some extent on the underlying C runtime library, for example how many digits you get for the exponent in exponential format is not directly controllable. However, Python is very good at string manipulation, so, once you've gotten "more or less" what you want, typically with operator %, you can (in the relatively rare cases where you need that) fine-tune things pretty easily. Formatting a string is one job; putting strings out to some file, another. They happen together frequently enough to warrant some shortcut for simple cases where nothing much is needed, which is just about what the print statement gives you. But for the fine tuning needs, working on strings (for example via regular expressions, but not necessarily) is a better idea than making the print statement more complicated in its "joint job". Alex From kzaragoza at attbi.com Mon Apr 1 17:38:39 2002 From: kzaragoza at attbi.com (Kris J. Zaragoza) Date: Mon, 01 Apr 2002 22:38:39 GMT Subject: PEP 285: Adding a bool type: yes, but not as int subtype References: <3CA62CD8.6ABD44D0@accessforall.nl> <3CA6F012.E2631003@accessforall.nl> <3CA79401.CFA41B65@python.org> Message-ID: In article , Bengt Richter wrote: > Of course the 'hidden property' is only rhetoric here, but why not > make this a clear and controllable unified mechanism instead of a > collection of special effects? I would like to see an overridable > __bool__ method (not actually a programmatic property) for the base > object class, perhaps making deprecation of __nonzero__ possible. Now this is an idea with some merit. I can see some real advantages to being able to define the truth value of a given object, or at least control its conversion to a bool. But then, Guido's PEP already shows this as possible when creating a bool. If you look at the __new__() constructor, it checks the truth value of the object when deciding which global value to return. If this is how things are implemented in the C code (and I haven't checked), then __nonzero__() (or __len__()) is called if defined. This gives us the control we're looking for. > Well, what do you think of the above? It certainly clarifies matters a bit, but I still have to wonder whether it's worth the effort. The way I see it, the mechanism for the customizations you describe is already present, albeit badly named. I certainly don't object to implementing the bool type. I guess I just don't see it as a significant advantage. Kris -- Kris J. Zaragoza | On the face of it, Microsoft complaining about kzaragoza at attbi.com | the source license used by Linux is like the | event horizon calling the kettle black. | -- Adam Barr, article on kuro5hin.org From doru-cat at ifi.uio.no Wed Apr 24 04:41:34 2002 From: doru-cat at ifi.uio.no (Doru-Catalin Togea) Date: Wed, 24 Apr 2002 10:41:34 +0200 Subject: Art and all that Jazz: are you ugly, I mean, attacking through outer powders In-Reply-To: <3CC62A08.77F6AC93@bellatlantic.net> References: <3CC5E850.3080903@ix.netcom.com> <3CC62A08.77F6AC93@bellatlantic.net> Message-ID: To begin with, I thought the postings from Jesica Felix were commercial adds from herself. As some have pointed out, her website claims that somebody is spamming in her name. Her website does indeed look professional, I really doubt it is a fake. However, as these messages keep coming in, I began to think that maybe she is spamming herself, poseing as a victim in order to, maybe, draw attention to her business. But who can tell? The world is full of lunatics, and the Internett is only providing another avenue for them to work through. I would rather believe the story told on her page, unless proven otherwise, that somebody is spamming in her name. For my own sanity's sake, if nothing else. :-) Catalin <<<< ================================== >>>> << We are what we repeatedly do. >> << Excellence, therefore, is not an act >> << but a habit. >> <<<< ================================== >>>> From claird at starbase.neosoft.com Sun Apr 28 16:21:28 2002 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Apr 2002 15:21:28 -0500 Subject: Scripting lanuages for laboratory tests References: Message-ID: In article , Alex Martelli wrote: . . . >> calling an arbitrary dll >> >> Neither Tcl nor Python supports calling an arbitrary dll. Tcl supports > >http://www.nightmare.com/~rushing/dynwin/calldll-2001-05-20.zip > -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From sholden at holdenweb.com Tue Apr 23 08:27:14 2002 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 23 Apr 2002 08:27:14 -0400 Subject: What is prefered: 'string' or "string"? (Should be in PEP8 ?) References: Message-ID: "Philipp Lenssen" wrote in message news:aa3fbk$pfb$1 at swifty.westend.com... > "Petr Prikryl" wrote in > message news:aa3dti$n0$1 at news.nextra.cz... > >.. > > In other words, should I prefer writing: > > s1 = 'first string' > > or > > s2 = "second string" > >.. > > For XHTML string output, I prefer single quotes because I don't have to > escape double-quotes within the string, e.g.: > s += '' > For XHTML and HTML output you would find the triple-quoted forms much easier. Then you can use EITHER quotes in your output, and include newlines as well, as in: s = """%s A comment""" % s regards Steve -- home: http://www.holdenweb.com/ Python Web Programming: http://pydish.holdenweb.com/pwp/ From max at alcyone.com Sat Apr 13 15:45:24 2002 From: max at alcyone.com (Erik Max Francis) Date: Sat, 13 Apr 2002 12:45:24 -0700 Subject: ANN: Munch 0.2 -- Embed Python in template text as markup (was ANN: Munch 0.1 ...) References: <3CB75C38.757A849D@alcyone.com> Message-ID: <3CB88AD4.F29D4F6E@alcyone.com> A new version is available: It supports specifying the prefix character to something other than @, and properly refusing to expand a None as an expression evaluation so that proper procedures (functions evaluated for side effects not return value) can be used. The full information follows. . Summary Munch is a system for embedding Python expressions and statements in template text (or any other unexecuted content); it takes source files, processes them, and produces output. These are done via expansions, which are snippets of Python code delimited by special characters involving a special character (by default the @ at sign), and are substituted in the output with the return value (for expressions) or with any in-Python printing to stdout that takes place (for both expressions and statements). If the value of an evaluated expression is None, nothing is expanded (that is, it acts like the interactive Python interpeter). Textual data not explicitly delimited in this way is sent unmolested to the output file, allowing Python to be used effectively as a markup language. Explicit expansion within Python code is possible. Also supported are m4-style diversions, where output can be systematically deferred and recalled. Expressions are embedded in text with the '@(...)' notation; as a shortcut, simple variables and expressions can be abbreviated as '@variable', '@object.attribute', '@array' [index], or '@function(arguments)'. Full-fledged statements are embedded with '@{...}'. Getting the software The software is available in a tarball here: http://www.alcyone.com/pyos/munch/munch-0.2.tar.gz. The official URL for this Web site is http://www.alcyone.com/pyos/munch/. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Nationalism is an infantile sickness. \__/ Albert Einstein Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html A new, virtual planet, every day. From borcis at geneva-link.ch Thu Apr 11 09:10:39 2002 From: borcis at geneva-link.ch (Boris Borcic) Date: Thu, 11 Apr 2002 15:10:39 +0200 Subject: Something or Nothing^H^H^H^H^H^H^HEmpty References: <3cb3fbc0$0$78808$edfadb0f@dspool01.news.tele.dk> <3cb57b6b$0$78750$edfadb0f@dspool01.news.tele.dk> <3CB5829C.4030305@geneva-link.ch> Message-ID: <3CB58B4F.9060908@geneva-link.ch> >> >>> >>>> [] and {} are objects, >>>> >>> Yes, as are None and 0. >>> > IOW you forgot the empty sequence () and the empty string "". Raises the interesting question of a locus of functionality of immutable objects that would be to dictionaries much like tuples are to lists. Mmmm... Maybe "name munching rules" could grow to first-class values, and unify with both function parameter binding "action objects" and with (compiled code for ?) destructuring-restructuring assignment statements (such as a,b = b,a). Some kind of algebra is clearly possible, and would justify these being values. Guess it means knowing the VM is part of a complete python education :( Boris -- "Art is a trigram" From fakeaddress at nowhere.org Wed Apr 24 23:50:59 2002 From: fakeaddress at nowhere.org (Bryan Olson) Date: Thu, 25 Apr 2002 03:50:59 GMT Subject: SHA-based encryption function in Python References: <7x3cxlk7qb.fsf@ruckus.brouhaha.com> <7xpu0pij41.fsf@ruckus.brouhaha.com> <7xsn5l6zn7.fsf@ruckus.brouhaha.com> <7xadrsslye.fsf@ruckus.brouhaha.com> <7x7kmwjx5h.fsf@ruckus.brouhaha.com> Message-ID: <3CC77D30.7030603@nowhere.org> Paul Rubin wrote: > Note that there's a trivial O(2**64) attack on my authentication since > I'm truncating the MAC to 8 bytes. So if a security difference > between HMAC and what I'm doing needs more than O(2**64) work to > exploit, it's not really useful to an attacker. Is that a reasonable > way to think of this? I don't think it's reasonable, no. The 2**64 attack is to try sending messages until the defender accepts one. It cannot be done off-line because the attacker cannot tell when he has the right MAC. It's not comparable to a 2**64 off-line work factor. --Bryan From aleax at aleax.it Tue Apr 9 12:43:01 2002 From: aleax at aleax.it (Alex Martelli) Date: Tue, 09 Apr 2002 16:43:01 GMT Subject: Bitwise/Binary operations in Python < 2.1 References: Message-ID: petro wrote: ... >>>def extractPriorityAndFacility(single32bitQuantity): >>> priority = single32bitQuantity & 7 >>> facility = (single32bitQuantity >> 3) & 0xFFFFFFF >>Depending on the meaning of "top" ... ^-- might need 4 here?? >>> return priority, facility >>Just a nit, but I suppose it could make a difference. > > 3 gives the right answers: > > <22> is generated by postfix, and gives 6 (info) for priority, and 2 > (SMTP) for facility. <62> is generated by Leafnode, and gives 6 for > priority, 7 (news) for facility. > > Thanks, that did the trick. > > Could one of you that to me? I don't really understand how that > worked. Operator >> shifts a number rightwards (looking at the number as a string of bit), and operator & applies a "mask" (a bit-by-bit AND). Are you familiar with bit manipulations at all? Alex From borcis at geneva-link.ch Mon Apr 15 06:52:39 2002 From: borcis at geneva-link.ch (Boris Borcic) Date: Mon, 15 Apr 2002 12:52:39 +0200 Subject: Py needs cust nwsclt for mngg eg nntp xrefs ? Message-ID: <3CBAB0F7.8020608@geneva-link.ch> Claims : (1) the PEP process augments the contrast along an axis of variation of purpose of c.l.p. messaging : pertaining to PEP-proposal-grade changes of the design of Python, or not. Some messages do better along that scale, others do less well. (2) such discussion relates typically many points, which need to be cross referenced for facilitating review of arguments. (3) part, but part only, of this cross-referencing is provided by the NNTP thread protocol as supported by news clients. (4) with batteries included, python is powerful enough to provide out-of-the-box a news client and special protocol tuned to needs of its communal development. (5) for particular discrete installation of such a special protocol, an implementation by a custom "transparent firewall" could be provided, providing eg local through-the-web interface along with further features; backside of course interfacing with current-world python "people's protocols". (6) *the* particular feature of that client protocol, we would like to have, is facilitating the construction of button interfaces to earlier messages, eg back-references, *not* having to follow from the NNTP threading protocol, even for people using news client UI designed under the opposite assumption. (7) the main claim being that *treedagging* is a natural primitive operation on reasonable contributions to pep processing. Treedagging is just a portmanteauname we construct to express an operation that takes forests as purest initial input (nntp threads form forests) and transputs/outputs DAGs - Directed Acyclic Graphs. (8) the purpose is that given such an uniformly distributed power to knot thread and thread branches, natural dagging experts will shine well enough, to a "recording representation" s.t. when ever the BDFL comes to the community as has been the case with PEP 285 ("I have enough feedback to last me for a lifetime") he will find it easier to demonstrate his decision not leaving people with the feeling that he missed a point. (9) as a consequence of purpose (8), people eg "ego-driven by the will of making themselves heard or approved by group hotshots", will themselves learn that "the system" proportions their visibility to the quality of their contribution to diagonal cross-referencing of newsgroups threads, and thus will themselves save a better attention to that factor. (10) a further python project would be that of the ngfaqbot. This means the perfected UI would allow newbies to gain system credit/weight by risking themselves to assert that point such-and-such is "#N by the ngfaqbot". This seems to mean that we should expect the PEP-list to map to a FAQ-list that would perhaps inherit some of its ordinals. (11) newbies would be competing with a standard distribution python AI and site, itself managing the mapping-to-faq of elementary interventions on the newsgroup using AI software technology implemented in standard python. Competing newbies would be rewarded any time an expert confirms that their intervention saved from a potential or actual AI error and deserves mention as a motivation to update the latter. (12) Couldn't this turn into a diatribe on it being below Python to see it's BDFL using so crude and unsubtle a kill file technology ? Kill files analogues are everybody's problem today ! It's Python's mission to provide the newbie user and the py community expert worker and designer as well, with a design for newsgroup effective bandwidth enhancement that's more up to date ! ;-) Boris Borcic -- "Art is a trigram" From jeff at ccvcorp.com Tue Apr 23 13:49:42 2002 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 23 Apr 2002 10:49:42 -0700 Subject: What is an import and where is it on the hard disk References: <3CC4A51A.A7D770ED@sympatico.ca> Message-ID: In article <3CC4A51A.A7D770ED at sympatico.ca>, francis049 at sympatico.ca says... > I receive an error message like : > > Traceback (innermost last) : > File : /usr/sbin/up2date, line 9, in ? > import rpm > Import error : No module named rpm > > > Anyone can tell me why is this error happening and give me some details > ... please ? As Geoff Gerrietts said, it's hard to tell exactly *why* this happened when there's no detail given about when or where this error occurred. For an explanation of what import is, and what it means, read the Python tutorial chapter on modules, here: http://www.python.org/doc/current/tut/node8.html The error you got implies that there is no rpm.py file in any of the directories in your sys.path. This could be because the file is missing, or it could be because your path is bad. Red Hat uses Python 1.5.2 for a number of its system utilities, and expects to be able to access that version from /usr/bin/python. Perhaps the most likely scenario here, is that you've upgraded Python so that /usr/bin/python is now Python 2.x, and the new version of Python doesn't search the old version's site-lib for Red Hat's tools. (Some of those tools are broken under 2.x anyhow...) You can verify this as Geoff suggested, by checking the version of python with this shell command: $ python -c "import sys; print sys.version" If this does not show version 1.5.2, then you'll want to remove the current version of python, restore 1.5.2 (which may be as simple as deleting /usr/bin/python and recreating it as a link to /usr/bin/python15, or may require reinstalling the RPM), and then installing the new version of python from Red Hat's latest python2 RPMs. This will create the new version as /usr/bin/python2, and both can coexist (though you'll need to run your scripts as 'python2 myscript.py'). -- Jeff Shannon Technician/Programmer Credit International From max at alcyone.com Thu Apr 25 18:39:58 2002 From: max at alcyone.com (Erik Max Francis) Date: Thu, 25 Apr 2002 15:39:58 -0700 Subject: Python doesn't know how to do math? References: <1jvgcukdvfeakgq8lp284dofe3e8cnrla9@4ax.com> Message-ID: <3CC885BE.28611B5@alcyone.com> Chris Spencer wrote: > Okay, I might not be a math genius, but this is most > definately WRONG. > What gives? Anyone have insight into this little "feature" of Python > floating > point operations? It's a feature of _all_ floating pointer operations. It has nothing to do with Python specifically. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Life is one long process of getting tired. \__/ Samuel Butler Interstelen / http://www.interstelen.com/ A multiplayer, strategic, turn-based Web game on an interstellar scale. From aleax at aleax.it Mon Apr 8 06:24:59 2002 From: aleax at aleax.it (Alex Martelli) Date: Mon, 08 Apr 2002 10:24:59 GMT Subject: newbie question about event based programming References: Message-ID: <%des8.59197$pT1.1704440@news1.tin.it> ashimali at btinternet.com wrote: > Hello All, > I'm wondering if there is a way to put an "event listener" (sorry for the > Java terminology), on a directory. What I'm trying to do is have a python > script be invoked on files whenever new file/s are copied/moved to a > particular directory. Any tips gratefully recieved! Cheers Adam That depends, first of all, on the functionality of your underlying operating system -- for example, Windows lets you do that (if your event loop is coded in a powerful enough way, but that's another issue). I don't believe there is any cross-platform way -- it's not up to the language, alas. The best you can achieve in most platforms would be to "poll", say every second, to see if the directory was modified. Even just getting a function of yours called every second is hard to arrange in a cross-platform way. Fine if you're using some given GUI toolkit, such as Tkinter (it has an .after method to schedule a function call, and you need to call it again in the scheduled function to get periodic repetitions), but there's no way that works across platforms and toolkits. Event-driven programming is a great thing, but it's not supported as well as it could and should be across every platform and toolkit in the world:-(. Alex From distrex at hotmail.com Sun Apr 7 15:56:42 2002 From: distrex at hotmail.com (distrex) Date: 7 Apr 2002 12:56:42 -0700 Subject: python newbie Message-ID: I'm trying my first script with a module and I can't get it to work right. I'm using the time module to make part of the game random and i just want the number to be at a whole number (no decimals) and I can't figure out how to make it do that. If someone needs me to post the script I'd be happy to but if you can help me just from memory that'd be great too. Thanx in advance. From sabren at manifestation.com Tue Apr 2 10:55:58 2002 From: sabren at manifestation.com (Michal Wallace) Date: Tue, 2 Apr 2002 10:55:58 -0500 (EST) Subject: ANN: Twisted 0.16.0 In-Reply-To: <3CA83409.8080401@itamarst.org> Message-ID: On Mon, 1 Apr 2002, Itamar Shtull-Trauring wrote: > For more information on how Twisted helps you run licensed, unpirated > Open-Source software, visit: > http://twistedmatrix.com/documents/howto/register Okay, I see this was posted yesterday (April Fools day), but the site's still up today. Is this for real? If so, why? How can piracy be a problem for an open source project? How does this licensing scheme prevent it? Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From hancock at anansispaceworks.com Tue Apr 30 16:43:34 2002 From: hancock at anansispaceworks.com (Terry Hancock) Date: Tue, 30 Apr 2002 13:43:34 -0700 Subject: Python vs. Perl, which is better to learn? References: <20020501052506.30164.5146.Mailman@mail.python.org> Message-ID: <3CCF01F6.8A812758@anansispaceworks.com> I was intrigued to find this was a serious discussion and not a flame war. :-) Cool -- I just learned a bit of Perl, which is probably the reverse of most people's experience. Note that Perl naivety is to be expected, therefore. However, I narcissistically suppose that a reverse perspective might be useful to somebody... My frustration with Perl was that "arrays" and "hashes" were very like "lists" and "dictionaries" except for one critical point -- they don't allow nesting! (There are more subtle differences too -- apparently Perl does pretty much everything "by value" instead of "by reference"). I'm not quite experienced enough with either to fully appreciate the consequences of this difference, but I know it must have interesting consequences. However, I've started calling dictionaries "hashes" in my head now -- I suppose that's not good, but it seems more intuitive to me. "Dictionary" has too strong a connection with the thing I use to look up words in (whether paper or electronic). Also, although Perl does apparently have "objects", they aren't so easy as in Python. All of this has led me to conclude that I will not be "switching" to Perl anytime soon. However, Perl does fill its "duct tape" roll pretty well -- it's possible to compactly write simple pieces of code to do quick fixes for various string and file manipulations. It also does some common tasks in nicely compact ways (such as the "process all lines in all files mentioned on the command line, or failing that, all the lines coming from stdin", which is basically what "<>" means). Basically, it seems to me that if all you ever do is write scripts of 200 lines or less, Perl may serve you very well. But if you're like me, and almost every program you write quickly grows beyond 1000 lines, because you can't resist adding new bells and whistles, or because you are actually fusing a lot of your programs into one or -- more often -- fusing a lot of other people's programs (i.e. modules / "the batteries") to do a job, then you'll quickly learn to love the objects, modules, and superior data structures of Python. (Actually Perl may have these structures, but they aren't obvious enough to have been taught to me in learning basic Perl -- whereas in Python you learn and use them right away). Which wording makes it clear that I took a class on Perl. This was the only way for me to learn it. I learned Python by myself in about a week, after which I was able to write useful (if not elegant) programs. With Perl I tried this and couldn't get over a fundamental resistence to learning what seemed like arcane and annoying syntax. I finally punted and signed up for a class, which I almost never do. I suppose Perl is now the first programming language I ever learned this way. Lists in Python finally made me appreciate what Lisp programmers were on about. As a long time number-crunching/ scientific applications programmer, in the Basic, Fortran, C, Pascal tradition, I had little understanding of the utility of things like lists, hashes or dictionaries, and so forth. Python really sold me on them, though. The regular expressions are nice too. There's a lot of useful tasks that can be solved much more quickly using them, "line noise" or no. Since I don't plan to switch languages for any major project, the main impact has been to increase my interest in using Python's "re" module to solve similar problems. Unfortunately, Python documenters seem to have a bit of a chip on their shoulder about regular expressions, whereas the main promoters of it have been long accustomed to Perl. So most of the RE explanations have a definite Perl bias. Python's implementation is a bit different, so it can be tricky to learn (i.e. using Perl-centric sources to learn Python's REs). Thus, while I'm sure Python's RE implementation is "good" it may not be "easy" by dent of being contrary to the only "texts" I can find to learn it from (but see comments below). Christopher Browne wrote: > Mind you, I have found that the "More Pythonic Way" of constructing > complex regexes by building components, like the following, to have > merit: > > digit = '[0-9]' > date = '\(' + digit + digit + digit + digit + '/' + digit + digit + '/' > date = date + digit + digit + '\)' > > By building the regex out of something with named components, I don't > have the horridness of line noise like: > if ($line =~ /.*\s+\d+.\d+\s+\d+.\d+\s+.\d+.\d+/) { > > Ultimately, the answer is that both approaches have their own merits > and demerits. The "Perl thing" tends to be shorter, while the "Python > thing" tends to be more readable. Thanks for the example -- I think there is some definite merit to this. It occurs to me that you might be both more clear and more compact (and equally pythonic?) to say: digit = '[0-9]' date = '\(' + 4*digit + '/' + 2*digit + '/' + 2*digit + '\)' for the regular expression, so you don't have to count the digits. That's starting to get kind of elegant, I like it. Somehow it always helps me to be able to pronounce my code. ;-D At the risk of being terribly Python-centric, I think Python feels like the "second implementation" of a solution, where you have the benefit of hindsight to help you design a simple, elegant, and powerful design from the start, which you got by using the old, less elegant solution which was simply the accumulation of patches to your old problems -- which is what Perl feels like. Given that Perl was indeed earlier, and that experience with it has no doubt driven Python's design, this may be no slight to Perl, in fact. My Perl teacher described Perl as being "like English", full of idioms and synonyms and ambiguities resolved by context -- an organic, naturally evolved solution to programming problems. If so, Python is probably like Esperanto -- artificial, clean, regular, and easy to learn, though perhaps not as creatively expressive in itself. One other odd observation -- I've noticed that Python is very popular among computer graphics/graphic artists, whereas Perl remains very popular among musicians. This is a very unscientific, unsupported observation -- but I noticed it when trying to find both for a project I was working on. I have some weird theories about why this might be so, but they're probably wrong. :-) Given that no one speaks computer languages natively, the huge difference in learning curve between Esperanto, which was designed for it, and English (I have only pity for those who are forced to learn it as a foreign language -- I've tried to do penance by studying Japanese, but frankly even that is more logical), is surely an argument in Python's favor. (In all fairness, I should admit that I've never actually tried to learn Esperanto, which is not so popular in America. Also, it will always be associated with Red Dwarf and Rimmer for me). IMHO, of course... Terry -- ------------------------------------------------------ Terry Hancock hancock at anansispaceworks.com Anansi Spaceworks http://www.anansispaceworks.com ------------------------------------------------------ From guido at python.org Fri Apr 12 14:49:17 2002 From: guido at python.org (Guido van Rossum) Date: Fri, 12 Apr 2002 18:49:17 GMT Subject: type() new style class instance says "class", not "ObjectType" References: <3cb4bd45$1_1@goliath.newsgroups.com> <3cb5bd03$1_6@goliath.newsgroups.com> Message-ID: <3CB72CE6.DFAD5C10@python.org> "David Mertz, Ph.D." wrote: > Unfortunately, there's more to it than this. There still is--and > presumably always will be--a difference between "instances" and other > types of things. For example, a list is a mutable sequence that has > some items in it. In contrast, an instance object--whether new style or > old style (and w/ or w/o __slots__)--is a thing that has some > attributes. The basic shape of the data will always be different. The > type/class unification doesn't change that. Hm... So after class C(list): def appendmany(self, *args): for arg in args: self.append(arg) Do you consider a C instance to be a list or an instance? You might look at the presence of a __dict__ attribute storing instance attributes as the distinguishing factor. But then what would you do after class D(list): __slots__ = ["foo"] List or instance? The shape of a D instance is the same as the shape of a list, but with an extra slot added. --Guido van Rossum (home page: http://www.python.org/~guido/) From gcordova at hebmex.com Mon Apr 15 16:31:22 2002 From: gcordova at hebmex.com (Gustavo Cordova) Date: Mon, 15 Apr 2002 15:31:22 -0500 Subject: String interpolation question Message-ID: > Hi group, > > [..snip..] > You could use: print "The value is: %(value)s" % { "value":y[i] } -gustavo From ajs at ix.netcom.com Tue Apr 9 09:51:01 2002 From: ajs at ix.netcom.com (Arthur Siegel) Date: Tue, 9 Apr 2002 09:51:01 -0400 Subject: What has PEP 285 done to us? Message-ID: <000001c1dfce$4a2ffb00$0334fea9@carol> > I do not think the PEP *did* damage - it only revealed that >our community has problems. I don't understand what >problems. In my view, something about the exception to the rule syndrome. Guido has expressed some welcome self-awareness and humility on a number of occasions by publicly admitting frustration at his own inability to articulate the basis for his design intuitions. But then seems to go off the wall frustrated when he opens things up for discussion based on those articulations and finds that folks don't get it. My contribution to the div operator discussion - and I tried to make that clear - was "I have *no* opinion on how a div operator should behave and understand myself unqualified to discuss the issue in general terms. I am *not* a peer." But - I felt very very strongly that the justifications being articulated did not hold water. Because the justifications were largely about "non-programmers*, *newbies* , etc and etc and pointed to evidence from specific projects about which I happened to have been quite familiar, the issue was *totally* outside the realm of the technical, I had the basis to consider myself a peer in that portion of the discussions and was *convinced* the evidence cited did provide the basis to draw the conclusions that were being drawn. So now a discussion of "/" is becoming in my mind an insult to scientific thinking. I still have *no* objection to the div operator decision and am at the same time more convinced than ever that a major articulated basis for it does not hold water. Where my own sensibilities happen to explode is when I perceive a good portion of the community defending Guido's position when it is based on thin evidence, is non-technical, and represents no more than one guy's take based on the amount of attention he happens to have been able to give the matter, as they do when it is based on an articulated position on technical matters - where I would agree the burden of proof most definitely shifts. And when I find there was a Zen masters' wand at our disposal all along. I certainly cannot discern *any* basis to understand when we are allowed to resort to it, and when not. So I grow to distrust not so much Guido, as the community. And at this point will be happy enough just to read the release notes. Art From boud at valdyas.org Thu Apr 18 10:58:44 2002 From: boud at valdyas.org (Boudewijn Rempt) Date: Thu, 18 Apr 2002 16:58:44 +0200 Subject: PyQt QTable References: Message-ID: <3cbedf88$0$305$e4fe514c@dreader1.news.xs4all.nl> Michael Melchert wrote: > Hello, > > I am having some difficulties using QTable (PyQt3.0-2.3.1) > in a python QDialog: > basically all I want to do is to connect the QTable.clicked() signal to > a python method [ > self.connect(qtb,SIGNAL('clicked(....)'),self.the_method)] my problem > arises from the parameters which are defined for > QTable.clicked(int,int,int,QPoint&). what would be the correct way to > write the connect() call, especially regarding the QPoint& reference? And > how would the connected python method be defined? > Haven't tested this -- busy studying for a blasted Java exam -- but you should be able to something like QObject.connect(qtb, SIGNAL("clicked(int, int, int, const QPoint &"), self.theMethod) Note the 'const' -- that's needed. You need to have either five parameters or a variable-number argument list to theMethod: def theMethod(self, row, col, button, point): bla or def theMethod(self, *args): bla or even (but I like to have at least an explicite self): def theMethod(*args): bla -- Boudewijn Rempt | http://www.valdyas.org From lumber at jack.com Mon Apr 22 02:29:05 2002 From: lumber at jack.com (Lumberjack) Date: 22 Apr 2002 06:29:05 GMT Subject: Programming as literature. Was: Python's Lisp heritage References: <20020420092101.19095.84453.Mailman@mail.python.org> <3CC3A2E0.B1AA0F70@tundraware.com> Message-ID: Tim Daneliuk wrote: > Carl Banks wrote: >> Computer programming is not science. > > Agreed - it is craft. Computer programming has all the properties of literature, including subjective analysis, the existence of "schools of thought," and genres, among other things. Me, I miss the beat era of programming. The bohemians really knew how to code some cool prose man. "The fact was I had the vision...I think everyone has...what we lack is the method." - Jack Kerouac From gcordova at hebmex.com Thu Apr 11 15:44:22 2002 From: gcordova at hebmex.com (Gustavo Cordova) Date: Thu, 11 Apr 2002 14:44:22 -0500 Subject: Communication between a Python process and a Python cgi scrip t Message-ID: > I have a Python program started by root that does some magic stuff > every 10 minutes. So the program in an infinite loop of > sleep, do stuff, > sleep, do stuff... How can I make a cgi-script to end the process's > sleep phase and make it to "do stuff" immediately. I tried > signals, but > it is propably too risky because the process is run as root. Any > suggestions? ?How can it be risky? If it's risky, and you're trying to activate it with a CGI, then maybe you shouldn't use a CGI to activate it. On the other hand, the process could wait for a SIGALRM (alarm). SO, now, your program can: 1. Setup alarm to signal after X seconds. 2. Sleep forever. 3. Catch alarm, do stuff. 4. Goto 1. Now, your CGI simply sends a SIGALRM to the process, which starts the cycle again. Kinda neato. -gustavo From jozef at jozef.joz Sat Apr 13 17:28:02 2002 From: jozef at jozef.joz (Jozef) Date: Sat, 13 Apr 2002 23:28:02 +0200 Subject: fp/lambda question References: Message-ID: "Alex Martelli" wrote: > You're clearly using Python 2.1.something and don't have a: > > from __future__ import nested_scopes > > at the very top of your module. Right! So my problem was already solved :-) > I like FP a lot, and I practise it -- but I eschew lambda in Python in > most cases: it's limited and goes much against the grain of the > language. All it boils down to is, give your functions a name -- in > most cases a well-chosen name will clarify your code. E.g., > > def relatively_prime(a, b): return gcd(a, b) == 1 Thats funny, I wanted to do that but I don't know how to use filter with a function that takes 2 variables. E.g., to get a list if all numbers less than 10 relatively prime to 3, I would write filter(relatively_prime, range(1, 10)) # aaah, where does the 3 go??? So I learned the lambda way. I also looked at Haskell recently, and there (relatively_prime 3) is a valid function that takes only 1 argument, so no problem there. Just a thought: a nice way to get rid of lambda's and save a little typing would be if for example filter(is_even, alist) and filter(is_even(_), alist) meant the same thing, and in filter(relatively_prime(3, _), alist) the list elements would be inserted at the '_'. It would of course just be short for filter(lambda x: relatively_prime(3, x), alist) I'm using Python for about a month so I know I can't be making any sense to real programmers, but anyway :-) And thx for the advice From offer at sgi.com Wed Apr 17 10:31:01 2002 From: offer at sgi.com (Nhi Vanye) Date: 17 Apr 2002 14:31:01 GMT Subject: 2.0*4 ==> Bus error on IRIX 6.5 References: Message-ID: $ from stever at bic.mni.mcgill.ca -#195338 | sed "1,$s/^/> /" > > >Hello, > >I just built python 2.1.3 on an IRIX 6.5 machine (Origin 200) using MIPSpro >compilers (Version 7.30) and the test suite fails. > >It turns out that multiplying a float by an integer causes a >bus error: > > $ ./python > Python 2.1.3 (#2, Apr 17 2002, 09:37:30) [C] on irix646 > Type "copyright", "credits" or "license" for more information. > >>> 2.0*4 > Bus error (core dumped) > > >[Oddly, it works if you multiply two floats or two integers] > >From the core dump, I see that the fault happens here: > > #0 0x1004fd7c in float_mul () at floatobject.c:382 > 382 CONVERT_TO_DOUBLE(v, a); > > >I looked on the python.org web pages, FAQs, etc and didn't >find any similar problem reported. I couldn't find the way to >search the python bug tracker, so I had a quick look at the >summary lines. There was one about alignment that caught my eye >(#472568) but the workaround suggested there does not ameliorate >the situation. > >Help? 2.1.1 from May release of Irix Freeware seems to work okay [ morgaine 6.5.16f-Apr01 ] python2 Python 2.1.1 (#1, Mar 25 2002, 11:44:01) [C] on irix6-n32 Type "copyright", "credits" or "license" for more information. >>> 2.0*4 8.0 >>> There are problems with the Feb release (some files were installed in the wrong places---seems to only affect the development of extensions), so that is also likely to be okay. If you really need the May version right now, mail me and I'll see if I can get a copy of the latest build to you... richard. -- ----------------------------------------------------------------------- Richard Offer Technical Lead, Trust Technology. "Specialization is for insects" __________________________________________http://reality.sgi.com/offer/ From paul.osman at sympatico.ca Tue Apr 16 12:18:12 2002 From: paul.osman at sympatico.ca (Paul Osman) Date: Tue, 16 Apr 2002 12:18:12 -0400 Subject: Newbie question References: Message-ID: <3CBC4EC4.4080401@sympatico.ca> Ante, do some reading about scope... add the following line to dummy.py: num = 0 def dummy(): global num num += 1 dummy() now in the interpretor: >>> import dummy >>> print dummy.num 1 >>> dummy.dummy() >>> print dummy.num 2 HTH, -Paul Osman Ante wrote: >from file 'dummy.py' >---------------------------- >num = 0 > >def dummy(): > num += 1 > >dummy() >---------------------------- > >now, in the interpreter: > >>>>import dummy >>>> >Traceback (most recent call last): > File "", line 1, in ? > File "C:\downloads\python2.2.1\dummy.py", line 6, in ? > dummy() > File "C:\downloads\python2.2.1\dummy.py", line 4, in dummy > num += 1 >UnboundLocalError: local variable 'num' referenced before assignment > > >Why does this happen? >If I replace num += 1 with print num, it prints 0 without an error. >I guess it scans the whole function and check if there's an assignment to a >name, >and if there is, assumes it's a local variable. But += isn't supposed to >move the >reference but instead change the same variable. Or what did I get wrong? > >Ante. > > > From logiplexsoftware at earthlink.net Tue Apr 16 16:18:52 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 16 Apr 2002 13:18:52 -0700 Subject: A little advice please? (Convert my boss to Python) In-Reply-To: <3CBB8ABB.57BAA189@engcorp.com> References: <3CBB8ABB.57BAA189@engcorp.com> Message-ID: <20020416131852.3a61b3ac.logiplexsoftware@earthlink.net> On Mon, 15 Apr 2002 22:21:47 -0400 Peter Hansen wrote: > Most of the time when someone concludes Python is not fast > enough, they have a situation where something is expected > to run once or twice a day, and it might take ten minutes > with Python and one minute with C, and they conclude that > is too slow... meanwhile the C version is buggy, took > four times longer to develop, and nobody likes to maintain > it because the code is five times longer than the Python > one would be. Especially when the money saved by developing in Python versus C could easily cover the cost of a faster PC (or two). It seems so bizarre that there are people who would spend $10,000 (or more) in developer time to optimize an in-house program rather than simply spend $1000 on a new PC. -- Cliff Wells, Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From mhammond at skippinet.com.au Fri Apr 26 21:41:59 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sat, 27 Apr 2002 11:41:59 +1000 Subject: Python.NET? Jython.NET? Ni! In-Reply-To: <3CC9EC6E.1030108@ActiveState.com> Message-ID: [David Ascher] > >Is ActiveState's Python for .NET dead? I can find no reference > to it on the > >ActiveState page, other than an old research build for .NET Beta 2. > > > >Seems to me the easiest place to start for a .NET version of > Python would be > >with Jython. I haven't looked at the Jython source code, but can someone > >who has done so comment? > > > "Dead" sounds so harsh, in this age of Buffy. The truth is that no one > is working on it from ActiveState, and as far as I know Mark isn't > either. There are a few people who are interested, however, so there's > always hope. I'm not doing all that much on it at the moment, but am keeping it up to date. I recently uploaded a version that should work with the release build of .NET. http://starship.python.net/crew/mhammond/dotnet is where the latest can be found. Mark. From stephen at xemacs.org Mon Apr 15 01:11:59 2002 From: stephen at xemacs.org (Stephen J. Turnbull) Date: 15 Apr 2002 14:11:59 +0900 Subject: What is free software? [Re: Licenses and Open Source don't conflict.] References: <12bb92e6.0204091223.738e0798@posting.google.com> <1vKt8.21374$Kq4.896208@news2.calgary.shaw.ca> Message-ID: <87g01x1r6o.fsf@tleepslib.sk.tsukuba.ac.jp> >>>>> "Chris" == Chris Gonnerman writes: >> A public domain software can be modified by anyone, and the >> result can be made available to someone else under a binding >> license. So, that software was indeed free, but that quality >> of being "free" was totally fragile... Chris> Exactly. MIT (X11) and BSD licenses exhibit similar Chris> fragility. Only if you identify modified forms of the software with the original. The original is forever free. You can't make the usual arguments about the non-invasiveness of GPL, and at the same time argue that the freedom of PD/MIT/BSD code is somehow "fragile", without being wide open to charges of sophistry. >> The GPL wants to help programs at being free in more permanent >> ways. The original code, as a unit, is still free even if it is not copyleft. Nothin "unpermanent" about it. It is available for anyone who wants to use it. The "problem", when one exists, is that nobody wants it, as something better or more compatible is available. But that doesn't make the code unfree. So PD/MIT/BSD is good enough protection of freedom for many developers. And the (rms-deprecated!) LGPL is surely good enough for anybody who only cares about freedom of their own code. So the GPL is an advocacy tool, pure and simple. It's all about affecting licensing decisions for code that others write, it has nothing to do with protecting freedom of yours. Chris> There are those (uniformly programmers) who hate the GPL Chris> because it restricts their ability to "hide" the source if Chris> they incorporate GPL'd code in their non-GPL programs. Consumers also dislike the GPL because it removes their freedom to sell their privilege of inspection of enhanced derivative software, a privilege most will never wish to exercise. They don't hate it the way Bill Gates does, of course; they just would rather not pay for it in higher prices and reduced functionality. (Whether an "intelligent" consumer would wish to sell the privilege in practice is another question, although it's trivial to demonstrate that in theory open source licensing can destroy the market for a given software product.) Aladdin Ghostscript shows that the set of programs where non-GPL licensing results in clear benefit to all concerned is non-empty. With the exception of those who would like to use Aladdin's code to harm Aladdin's interests without paying for it. Everybody else gets Ghostscript for free, including the most recent source code. (I understand why neither the OSD nor the FSF admits APFL as a free license. But I have never seen a coherent argument that the world would be a better place if Aladdin Ghostscript, and only Aladdin Ghostscript, had its licensing policy changed to GPL.) On the other hand, there are almost certainly other software packages which would make a much greater social contribution under AFPL terms than under the GPL---because their authors would actually choose to publically distribute them under the AFPL, while they keep them private under the GPL. -- Institute of Policy and Planning Sciences http://turnbull.sk.tsukuba.ac.jp University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN Don't ask how you can "do" free software business; ask what your business can "do for" free software. From Tom_Good1 at excite.com Fri Apr 12 18:03:34 2002 From: Tom_Good1 at excite.com (Tom Good) Date: 12 Apr 2002 15:03:34 -0700 Subject: How to avoid mutual imports References: Message-ID: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) wrote in message news:... > I need advice on how to handle the following situation: > > utils1.py: > a > b > c > if __name__ == '__main__': > from interface import data_initialization # circular [snip] >From your description I'm not sure what the problem is. That import is not actually circular because when utils1.py is imported from another module, ( _name__ == '__main__' ) will be false, so the import statement after it will not be executed. Am I missing something? Tom From tjreedy at udel.edu Wed Apr 24 16:57:49 2002 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 24 Apr 2002 20:57:49 GMT Subject: Stackless goes Limbo References: Message-ID: "Christian Tismer" wrote in message news:mailman.1019662503.1913.python-list at python.org... > Hi all, > > after some time of consideration, > I have decided to move the interface to Stackless > Python's multitasking towards the ideas behind > the Limbo Language. > > Besides the tasklets, there are "channel" objects, > which allow for communication between tasklets. > This approach is simple and powerful. Blocking of > tasklets takes place on writes when no tasklet > is listening, or on reads, when no data is available. Whatever else you do, please consider adding an iterator interface for reading channels: for item in channel: whatever() Also nice, but probably much harder, would be to hijack 'yield' to write to a channel (for tasklets that write to only one channel, or which have a default output channel). Terry J. Reedy From tony-clpy at lownds.com Wed Apr 17 22:16:04 2002 From: tony-clpy at lownds.com (Tony Lownds) Date: 17 Apr 2002 19:16:04 -0700 Subject: Darwin + Tkinter + Aqua-Tk? (Re: Macintosh Development) References: <3CBA5EDB.C60BF821@cosc.canterbury.ac.nz> <20020415144153325+0100@pc-62-30-160-65-hw.blueyonder.co.uk> <3CBB9217.8A54E272@cosc.canterbury.ac.nz> Message-ID: > In theory, it would seem that you could install Unix python > on Mac OS X together with the Aqua version of Tcl/Tk, and > run Tkinter stuff. > You sure can! AquaTk is very far along, probably 90%+ > When I tried this recently, however, it didn't work. I > got a Tkinter window, but it was "dead" -- it didn't > respond to mouse clicks. Tcl applications run using > wish worked, but it wouldn't work from Python for > some reason. > With the second alpha file release of the AquaTk stuff on http://tcl.sf.net, this won't happen. > I'd be interested if anyone happens to know how to > get this to work! Essentially, build Python.app according to Python-2.2/Mac/OSX after adding this to Python/Modules/Setup.local: _tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \ -framework Tcl -framework Tk \ # -DTK_FRAMEWORK \ -I/Library/Frameworks/Tcl.framework/Headers/ \ -I/Library/Frameworks/Tcl.framework/Versions/Current/PrivateHeaders/ \ -I/Library/Frameworks/Tk.framework/Headers/ \ -I/Library/Frameworks/Tk.framework/Versions/Current/PrivateHeaders/ \ -I/usr/X11R6/include/ The headers in AquaTk don't work with Darwin's way finding of finding them. If that gets fixed, then just the -DTK_FRAMEWORK option will be needed and not the -I options. -Tony From jon+usenet at unequivocal.co.uk Sun Apr 28 11:34:32 2002 From: jon+usenet at unequivocal.co.uk (Jon Ribbens) Date: Sun, 28 Apr 2002 15:34:32 -0000 Subject: Python Webpages References: Message-ID: In article , Johan Fredrik ?hman wrote: > I previously saw a posing named "Python vs Php" and sys atht > "... there are many packages you can download..." > > However, only one package is mentioned: jonpy Ah, that would be because I wrote that article and I wrote jonpy ;-) > What is the most popular and promising webpackages for python ? Obviously, I think mine is, but you can see a list of other packages at: http://thor.prohosting.com/~pboddie/Python/web_modules.html There is an updated list at: http://www.boddie.org.uk/python/web_frameworks.html but that web site is currently down. From fredp at mygale.org.nospam Fri Apr 12 12:32:10 2002 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 12 Apr 2002 16:32:10 GMT Subject: CGIHTTPServer, revisited Message-ID: Well, seeing there was little in response to my previous post ("Baffled by CGI cross-browser issues"), I went back to what I should have started with : doing my homework on Google Groups. And what do you know, I'm not alone : there's been over a hundred _threads_ on this topic just in the past two years. I read through quite a few of them, and although there was a lot of information to be found, I didn't feel there was a definitive answer to the question : is CGIHTTPServer somewhat broken under Win9x, even in Python 2.2? Some say it _does_ work, others it _should_ work, but many seem to be stuck just like me. I've tried a few of the hints found here and there : running scripts with 'python -u', hacking CGIHTTPServer.py to remove 'fork' and 'popen' detection, forcing it to run scripts 'in-process'... Although I'm still wondering what Tim Peters-ly-meant by 'having w9xpopen.exe in all the right places' :-) Right now, after upgrading to 2.2.1, I'm still left with the following unsatisfactory result : under Win98SE the very minimal script below (and its many variants) work fine in Gecko-based browsers (Mozilla, K-meleon), always generates a "Network error - connection reset by peer" in Netscape 4.x (with subsequent output sometimes truncated), and always fails totally on submit in MSIE 5.0 and 5.5 at least (server not found etc.). I'd really like to understand how/why this happens. Can't be just a browser-side issue, can it ?... #----------------------------- # test.py import cgi form = cgi.FieldStorage() s='' for name in form.keys(): s = s + "Input: " + name + " --> " + form[name].value + "

\n" print """ Test form


Front Back

%s """ % s #----------------------------- -- YAFAP : http://www.multimania.com/fredp/ From op73418 at mail.telepac.pt Mon Apr 1 14:30:33 2002 From: op73418 at mail.telepac.pt (Gonçalo Rodrigues) Date: Mon, 01 Apr 2002 20:30:33 +0100 Subject: None not None in Excel COM? Message-ID: Maybe someone can help me out here. Im using Excel via Python COM and have already run makepy on its type library. The problem is the following: Let sheet be a reference to an Excel worksheet and suppose sheet.Cells(row, 1) returns None for a given row > 1. The problem is that if I do sheet.Cells(row, 1) == None sheet.Cells(row, 1) is None both return 0. What am I doing wrong? Thanx for all the help, Gon?alo Rodrigues From Sibylle.Koczian at Bibliothek.Uni-Augsburg.de Wed Apr 10 08:09:26 2002 From: Sibylle.Koczian at Bibliothek.Uni-Augsburg.de (Sibylle Koczian) Date: Wed, 10 Apr 2002 14:09:26 +0200 Subject: Beginnger Question References: <57Ds8.284095$2q2.26316987@bin4.nnrp.aus1.giganews.com> <3CB3039C.3040108@greenroom.com.au> Message-ID: >I'm a newbie myself, so this is probably wrong, but wouldn't this be *even* >better? > >x = 2 >def wrong(num): > x = x+1 > print x > >wrong(x) >wrong(x) > > Just tested with Python 2.2: >>> x = 2 >>> def wrong(num): ... x = x + 1 ... print x ... >>> wrong(x) Traceback (most recent call last): File "", line 1, in ? File "", line 2, in wrong UnboundLocalError: local variable 'x' referenced before assignment I think the exception is new (result of nested scopes?), but it's quite probable you meant to write x = 2 def wrong(num): num = num + 1 print num Result: wrong(x) 3 wrong(x) 3 for the reason already stated: call by value, which works on a copy of the parameter inside the function and doesn't change the parameter itself. (Would be the same in C, by the way.) So the "return num + 1" is really crucial, if you want your x to change. HTH, Koczian -- Dr. Sibylle Koczian Universitaetsbibliothek , Abt. Naturwiss. D-86135 Augsburg e-mail : Sibylle.Koczian at Bibliothek.Uni-Augsburg.DE From neal at metaslash.com Sat Apr 20 18:59:49 2002 From: neal at metaslash.com (Neal Norwitz) Date: Sat, 20 Apr 2002 18:59:49 -0400 Subject: Problem embedding python on Red Hat Linux 7.2 References: Message-ID: <3CC1F2E5.11886F77@metaslash.com> Ronald Cole wrote: > > *newbie alert* > > I have a program that calls Py_Initialize() and I cannot compile it > because I cannot seem to find the python library (-lpython?) in > /usr/lib to link it with. Here's what Red Hat figured I needed: > > $ rpm -qa | grep python > python-xmlrpc-1.5.1-7.x.3 > python-1.5.2-35 > python-devel-1.5.2-35 > rpm-python-4.0.4-7x > python-popt-0.8.8-7.x.2 > > and I've scanned distribution cd's 1 and 2 looking for it but can't > seem to find any sign of a lib*.{a,so} in the rpms. > > Please, someone take pity and clue me! $ locate libpython should tell you it's in /usr/lib/python1.5/config/libpython1.5.a That's where mine is. Neal From jb at cascade-sys.com Tue Apr 30 15:59:06 2002 From: jb at cascade-sys.com (James J. Besemer) Date: Tue, 30 Apr 2002 12:59:06 -0700 Subject: Stackless goes Limbo References: <3CC6D07E.409@tismer.com> Message-ID: <3CCEF78A.44CD7849@cascade-sys.com> Magnus Lie Hetland wrote: > James J. Besemer wrote: > > > >Made me look. > > Gullible, anyone? Yup nailed me good on that one. I realized just AFTER pressing send. A little less coffee that day and I may have spared myself that minor embarrassment. Regards --jb -- James J. Besemer 503-280-0838 voice http://cascade-sys.com 503-280-0375 fax mailto:jb at cascade-sys.com From dsavitsk at e-coli.net Tue Apr 23 14:55:23 2002 From: dsavitsk at e-coli.net (dsavitsk) Date: Tue, 23 Apr 2002 18:55:23 GMT Subject: dictionary method question Message-ID: for some dictionary d is there any relationship between the returns from d.keys() and d.values()? that is, to get them in some arbitrary but matching order, do i need to loop over d.items() or can i count on a similarity of the above? in small tests this seems to be the case. thanks, -doug From skip at pobox.com Mon Apr 1 09:00:44 2002 From: skip at pobox.com (Skip Montanaro) Date: Mon, 1 Apr 2002 08:00:44 -0600 Subject: PyOS -- was: Re: ANN: cage 1.0 -- Cellular automata engine in Python In-Reply-To: <20020401100837.GA1536@blackscarab> References: <3CA5194E.D5AB00E1@alcyone.com> <20020401021435.GF333@lilith.hqd-internal> <20020401100837.GA1536@blackscarab> Message-ID: <15528.26636.26194.935490@12-248-41-177.client.attbi.com> sasoft> there was (the link is dead): "spyLinux" at sasoft> http://dilbert.physast.uga.edu/~andy/minilinux.html Try: http://bluesine.com/Projects/spylinux Courtesy of a little googling. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From bbollenbach at shaw.ca Thu Apr 11 21:52:57 2002 From: bbollenbach at shaw.ca (Brad Bollenbach) Date: Fri, 12 Apr 2002 01:52:57 GMT Subject: A trivial question about print References: Message-ID: In article , Alex Martelli wrote: > Ante Bagaric wrote: >> Sure in most cases this feature helps, you dont need zillion " " strings >> between your variables :), but wouldnt it be nice if there was >> python-simple way to just get around it? > > There IS -- it's sys.output.write (or more generally the write method > of any file object). Does no formatting -- it emits a string, and > that's all. Not to mention, sys.stdout.write() is considerably faster than print: _printspeed.py_ #!/usr/bin/python for i in range(1000000): print "hello, world" _writespeed.py_ #!/usr/bin/python import sys faster = sys.stdout.write for i in range(1000000): faster("hello, world\n") $ time ./printspeed.py [snip 1,000,000 lines of output] real 1m11.301s user 0m23.140s sys 0m6.620s $ time ./writespeed.py [snip 1,000,000 lines of output] real 0m54.578s user 0m12.250s sys 0m6.730s You probably won't care about this unless you working on large amounts of data, but it's worth keeping in mind. -- Brad Bollenbach From chris.gonnerman at newcenturycomputers.net Sat Apr 13 10:51:50 2002 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Sat, 13 Apr 2002 09:51:50 -0500 Subject: What is free software? [Re: Licenses and Open Source don't conflict.] References: <005001c1e2aa$3d554280$0101010a@local> <20020413052610.GA5561@lilith.my-fqdn.de> Message-ID: <005a01c1e2fa$d44249e0$0101010a@local> ----- Original Message ----- From: "Gerhard H?ring" > * Chris Gonnerman [2002-04-13 00:15 -0500]: > > Another reason often given (by the misinformed) is that GPL code can > > somehow "infect" non-GPL free code (BSD let's say); it goes something > > like this: Bob writes an excellent library and releases it under the > > BSD license. George has his previously mentioned GPL'd library, which > > is also most cool. Fred comes along, and writes a program which uses > > both Bob's and George's libraries, and for some reason Fred actually > > incorporates the library source in his project rather than expecting > > you to separately install it. Fred must release his program under the > > GPL (he has no choice in this matter). > > This is wrong. Fed must release his program under a Free Software > license (see the FSF page I mentioned in a previous posting for a > listing of those). So Fred can release his program under a > BSD/Python-like license, too. If Fred *incorporates* George's GPL code in his program, he must make the rest of his code GPL too... the license is pretty clear this way. Alternately, if he makes a binary release the linkage rule may require him to GPL the program. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. The point is, Bob's license can't be changes unilaterally by Fred. Chris Gonnerman -- chris.gonnerman at newcenturycomputers.net http://newcenturycomputers.net From varial at gmx.de Fri Apr 5 17:13:21 2002 From: varial at gmx.de (Robert Spielmann) Date: 5 Apr 2002 22:13:21 GMT Subject: crc32 function Message-ID: Hi, I have a program where I need to calculate the crc32 values of fibonacci numbers, is there a way to get the crc32 of int variables or do I need to first write the number to a file, then read it back as a string to do the crc32 stuff? Thanks for any help Robert Spielmann From gerhard at bigfoot.de Tue Apr 9 12:06:17 2002 From: gerhard at bigfoot.de (Gerhard =?iso-8859-15?Q?H=E4ring?=) Date: 9 Apr 2002 16:06:17 GMT Subject: yet another "Here's to 1.5.2" post References: Message-ID: Syver Enstad wrote in comp.lang.python: > "Fredrik Lundh" writes: > >> Sean 'Shaleh' Perry wrote: >> > " ".join(mylist) # is this perl or python? >> >> *why* string objects have join method has been explained >> over and over and over again, and should also be obvious for >> anyone with some knowledge how strings and sequences work >> in Python. >> >> > whoever decided this is the new style should be shot, a lot > > Am I the only one in the entire world that thinks '\t'.join(mylist) is > elegant and natural? Of course not. It's only that there's an unusual amount of complaining going on on c.l.p recently. Those who are happy with the development of the language, just use the new features and don't complain publicly. OTOH other users complain why 2.2 is so different from 1.5.2 instead of just sticking with 1.5.2 or even 1.5.2 features if they're happy with it. I fail to see the logic of that, if there is any. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id AD24C930 public key fingerprint: 3FCC 8700 3012 0A9E B0C9 3667 814B 9CAA AD24 C930 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From hgg9140 at seanet.com Fri Apr 5 20:12:13 2002 From: hgg9140 at seanet.com (Harry George) Date: 05 Apr 2002 17:12:13 -0800 Subject: Rule Engine in Python References: Message-ID: "Robert Oschler" writes: > Harry George wrote in message > news:m3u1qq3ma8.fsf at wilma.localdomain... > > A few lines of python doing > > regualr expressions and some text manipulation takes the palce of a > > page or so of prolog. That was all with ALS -- I've used SWI for a > > few simple examples, but never compared them for heavy processing. > > > > I don't want to misinterpret anything, but are you indicating that if you > had your druthers you'd replace the prolog code wth python code? > > thx > Yes, at least for our context. Out of perhaps 100 prolog modules, only 1 or 2 really have declarative rules which take advantage of backtracking. The others are procedural (usually enforced with cuts). For that python is a better choice. Either way, the heavy lifting for 3D graphics is in the underlying C/C++/OpenGL libraries. Prolog/Pyton are there to add intelligence. > > -- Harry George hgg9140 at seanet.com From hgg9140 at seanet.com Mon Apr 22 20:26:43 2002 From: hgg9140 at seanet.com (Harry George) Date: 22 Apr 2002 17:26:43 -0700 Subject: Lisp (sexpr) parsing? Message-ID: I've used the old sexpr v0.2 from starship for years, and recently saw an sexpr v0.2 from sourceforge. The old one was incomplete and I've yet to build the new one. I've also noticed an emacs library ("elib" I think). What do folks recommend for parsing lisp code? Just parsing data structures would be enough, but need to handle those oddities like maybe-a-number(3.14159XYZ), single-quote quoted lists, vectors, etc. -- Harry George hgg9140 at seanet.com From shalehperry at attbi.com Fri Apr 26 19:53:44 2002 From: shalehperry at attbi.com (Sean 'Shaleh' Perry) Date: Fri, 26 Apr 2002 16:53:44 -0700 (PDT) Subject: Removing dupes from a list In-Reply-To: <20020426212006.GY21205@teich.Garten.DigitalProjects.com> Message-ID: On 26-Apr-2002 Alexander Skwar wrote: > ?Sean 'Shaleh' Perry? sagte am 2002-04-26 um 13:56:30 -0700 : >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560 > > Thanks, but connections to activestate.com simply time out :( However, > a traceroute to aspn.activestate.com doesn't show any unusual long hops. > But AS is reachable from other networks. Strange. > > Anyhow, seems like uniquer() from the 1st comment is what I'm looking > for, because unique() also looses order just like my two "functions". > look in the comments, Alex Martelli discusses keeping the order. From duncan at NOSPAMrcp.co.uk Tue Apr 23 09:01:04 2002 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Tue, 23 Apr 2002 13:01:04 +0000 (UTC) Subject: flatten tuple References: Message-ID: John Hunter wrote in news:m2adrvnxiv.fsf at mother.paradise.lost: > The only hitch is that I want to be able to do this recursively, so > I could have for example > > m = { > 'where': ('was', 'somekey'), > 'somekey': 'someval', > 'someval': ('asking', 'really', 'silly', 'questions') > } > > and end up with > > > y = ( 'John', 'Hunter', 'was', 'asking', 'really', 'silly', > 'questions') > Without checkig for infinite recursion, here is one way to do it: >>> m = { 'where': ('was', 'somekey'), 'somekey': 'someval', 'someval': ('asking', 'really', 'silly', 'questions') } >>> x = ( 'John', 'Hunter', 'where' ) >>> def expand(aList, aDict): if isinstance(aList, tuple): aList = list(aList) result = [] while aList: head = aList.pop(0) if aDict.has_key(head): head = [aDict[head]] if isinstance(head, tuple) or isinstance(head, list): aList[:0] = list(head) else: result.append(head) return tuple(result) >>> print expand(x, m) ('John', 'Hunter', 'was', 'asking', 'really', 'silly', 'questions') >>> -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From gieSPAm at free.fr Thu Apr 4 05:29:27 2002 From: gieSPAm at free.fr (jm) Date: 04 Apr 2002 10:29:27 GMT Subject: ANN: SLiP and SLIDE References: Message-ID: <3cac2b07$0$21495$626a54ce@news.free.fr> Scott Sweeney writes: > Announcing... > > SLiP 0.1: a "Sorta Like Python" shorthand syntax for XML > SLIDE 0.1: a "Sorta Like an IDE" lightweight windows exe for SLiP editing > SLiPpy 0.1: a SLiP package for Python, including a SLiP->XML library > (sliplib.py) and source for SLIDE (slide.py) > > http://www.scottsweeney.com/projects/slip How different is Slip from SOX ? http://www.langdale.com.au/SOX/ -- jm From nhodgson at bigpond.net.au Thu Apr 25 20:08:27 2002 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Fri, 26 Apr 2002 00:08:27 GMT Subject: CallDLL Package References: Message-ID: <%T0y8.50035$o66.156124@news-server.bigpond.net.au> Rajat Chopra: > I am using MinGW32 (particularly GCC and the BINUTILS package) to > rebuild the Python library file. When I run the script to rebuild the > library file, however, I continuously get the error of "undefined > reference to LoadLibraryA, FreeLibrary, GetModuleHandleA, and > GetProcAddress functions". ... Try the -mwindows option to dllwrap. One peculiarity of the GNU linker is that the order of libs is significant so sometimes to satisfy all (particularly circular) dependencies you get to write things like: dllwrap x.o -lkernel32 -lmine -lkernel32 Neil From JamesL at Lugoj.com Sun Apr 14 02:26:16 2002 From: JamesL at Lugoj.com (James Logajan) Date: 14 Apr 2002 06:26:16 GMT Subject: Do you QA your Python? Was: 2.1 vs. 2.2 References: Message-ID: Tim Peters wrote: > A crushing amount of debate over "stability" has gone by on Python-Dev > the last week, and the one thing that strikes me over and over is that, > with just a few minor exceptions, nobody volunteers to *do* anything > except tell other people what to do. What are you willing to do to > make your desires a reality? If it doesn't involve contributing work, > time or money, you just want a free ride. But nobody owes anyone a > free ride, and open source can't change that fact of life either. Not sure, but I think you are close to describing what has been called the tragedy of the commons. Back when I was paid to do Python work, I contributed all of US$50 (I think; maybe it was $20) to the PSA (I think it was called) and tried to get the company I was consulting for to kick in a couple thousand (or a couple hundred at least). They never got around to that, alas. Unfortunately I'm not sure what would be gained by contributions to a strategy that I have specifically stated I don't agree with. Further, it is unclear how I can "contribute" to the slower pacing of releases that I'd like to see. I've overstayed my welcome here, but before I go I'd like to thank you for your efforts to advance Python and I wish you well in your endeavors. From elian at inbrief.net Mon Apr 22 11:45:55 2002 From: elian at inbrief.net (Edmund Lian) Date: Mon, 22 Apr 2002 11:45:55 -0400 Subject: Overriding methods in classes that use property() Message-ID: On Mon, 22 Apr 2002, Denis Otkidach wrote: >EL> class C(A): >EL> def setVal(self, value): >EL> self._val = 'Huh?' > >Simply add one line here: > val = property(getVal, setVal) Hmm... I tried this, and I get a NameError because getVal is not defined. However, things work if I redefine class C to: class C(A): def setVal(self, value): self._val = 'Huh?' def getVal(self): return super(C, self).getVal() val = property(getVal, setVal) However, this is messy since one would have to do this for every property() attribute in the base class that is not being overridden in a subclass! This is *not* intuitive, *not* expected, and doesn't seem Pythonic! Seems more like a bug to me!!! ...Edmund. From marklists at mceahern.com Wed Apr 3 16:35:09 2002 From: marklists at mceahern.com (Mark McEahern) Date: Wed, 3 Apr 2002 15:35:09 -0600 Subject: File opening In-Reply-To: Message-ID: [Salim Zayat] > But if you wanna import the module, then the path to the open statement > needs to be full path to the file. Is there a fix to this? Put it in a package and use __path__. Consider: /site-packages/ /a/ __init__.py # __init__.py pass This means you can do this: import a print a.__path__[0] // mark From ods at fep.ru Mon Apr 22 11:41:44 2002 From: ods at fep.ru (Denis S. Otkidach) Date: Mon, 22 Apr 2002 19:41:44 +0400 (MSD) Subject: Overriding methods in classes that use property() In-Reply-To: Message-ID: On Mon, 22 Apr 2002, Denis S. Otkidach wrote: DSO> EL> class A(object): DSO> EL> def __init__(self): DSO> EL> self._val = None DSO> EL> DSO> EL> def setVal(self, value): DSO> EL> self._val = value DSO> EL> DSO> EL> def getVal (self): DSO> EL> return self._val DSO> EL> DSO> EL> val = property(getVal, setVal) DSO> EL> DSO> EL> class B(A): DSO> EL> pass DSO> EL> DSO> EL> class C(A): DSO> EL> def setVal(self, value): DSO> EL> self._val = 'Huh?' DSO> DSO> Simply add one line here: DSO> val = property(getVal, setVal) Sorry, getVal is not in current scope. The following should be right: val = property(A.getVal, setVal) From robin at jessikat.fsnet.co.uk Thu Apr 11 03:49:26 2002 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 11 Apr 2002 08:49:26 +0100 Subject: Easter Eggs References: <14lsJVAUgMt8Ewk9@jessikat.fsnet.co.uk> Message-ID: In article , Cliff Wells writes >On Thu, 11 Apr 2002 00:17:40 +0100 >Robin Becker wrote: >> Am I the only person that finds the whole concept of Easter eggs a slap >> in the face from the developers. > >Maybe not, but probably the only one who got up on the wrong side of the bed >today. > > well I think I wrote that before going to bed and perhaps the beer wasn't good or something. -- Robin Becker From phr-n2002a at nightsong.com Thu Apr 4 09:45:01 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 04 Apr 2002 06:45:01 -0800 Subject: ACCEPTED: PEP 285 References: <7xbsd0qpmn.fsf@ruckus.brouhaha.com> <3CABABCA.EB446FEE@python.org> <7x7kno5isl.fsf@ruckus.brouhaha.com> <3CAC6205.39B5E01B@python.org> Message-ID: <7x4rirjzf6.fsf@ruckus.brouhaha.com> Guido van Rossum writes: > The array object is an old-style type object. That's not the same as an > old-style class (it's totally unrelated). But new-style type objects are > the same as new-style classes (that's what new-style classes are all > about) and it's easy enough to convert an old-style type to a new-style > type. Then the new-style type will allow subtyping, so you can write a > subtype that implements bit elements. Thanks. I still don't fully understand this, but I'm probably best off reading the code before asking further questions about it here. > > Anyway, I'll put it on my list, but don't hold your breath. > > I won't, but I'll remind you that if you give, you'll get more back. Fair enough. From m.faassen at vet.uu.nl Thu Apr 25 18:44:46 2002 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 25 Apr 2002 22:44:46 GMT Subject: Python doesn't know how to do math? References: <1jvgcukdvfeakgq8lp284dofe3e8cnrla9@4ax.com> Message-ID: Chris Spencer wrote: > I tested this using the Python command interpreter on a Windows XP box > running: > Python 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. >>>> float(5)/float(100) > 0.050000000000000003 >>>> 5.0/100.0 > 0.050000000000000003 > Okay, I might not be a math genius, but this is most definately WRONG. > What gives? Anyone have insight into this little "feature" of Python floating > point operations? Heh. The timbot will be with you shortly. If you're impatient, do a google groups search and find things like this: http://groups.google.com/groups?hl=en&selm=000501be0ac4%2433c3f2a0%2418a22299%40tim&rnum=4 http://groups.google.com/groups?q=IEEE+group:comp.lang.python+author:Tim+author:Peters&start=10&hl=en&scoring=d&selm=mailman.991512844.1883.python-list%40python.org&rnum=11 Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From starx at pacbell.net Wed Apr 10 02:32:00 2002 From: starx at pacbell.net (Philip Swartzleonard) Date: 10 Apr 2002 06:32:00 GMT Subject: Problem with packages and modules References: <117880a1.0204090542.258f0f51@posting.google.com> <3CB2FA14.1050708@mxm.dk> <117880a1.0204092207.7e51ff80@posting.google.com> Message-ID: J?rgen Hansen || Tue 09 Apr 2002 11:07:37p: > Max M wrote in message news:<3CB2FA14.1050708 at mxm.dk>... >> J?rgen Hansen wrote: >> >> > This is an example of directory hierachy: > [ Snip some other stuff ] >> > Further if I typed in: >> > >>> import company >> > >> > I would assume that I could access all subpackages and their >> > modules with a dotted name (company.plot.figure.Figure() for >> > instance), but this is obviously not the case. >> > >> >> You would need to import the modul in company/__init__.py: >> import plot >> >> to do: >> >> import company >> fig = company.plot.figure.Figure() >> >> >> Hmm... I hope this helps a bit. > > It does. Thanks a lot. After I wrote, I got thinking, that my approach > would have meant that I would import the entire hierachy. Not very > smart if the hierachy, where larger. > > Well thanks again, for the prompt answer. > > regards > Jorgen > No one's mentioned this particular permutation; if you want to use 'plot' as a logical module in your code, you can just do 'from company import plot' =). -- Philip Sw "Starweaver" [rasx] :: www.rubydragon.com From martin at v.loewis.de Fri Apr 12 16:20:32 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 12 Apr 2002 22:20:32 +0200 Subject: Python-2.2.1, Solaris7, make test fails... References: Message-ID: Hugh Sasse Staff Elec Eng writes: > ImportError: ld.so.1: ./python: fatal: relocation error: file /home/hgs/Python-2.2.1/Modules/mathmodule.so: symbol PyExc_OverflowError: referenced symbol not found > > Could someone suggest how to proceed, please? Can you please report the command line option that was used to link the python binary? (delete it, and re-invoke make) PyExc_OverflowError ought to be exported from the Python binary, and there ought to be a gcc command line option to achieve that. If you know what nm(1) is, please verify that the symbol is exported. Regards, Martin From db3l at fitlinxx.com Wed Apr 17 23:27:57 2002 From: db3l at fitlinxx.com (David Bolen) Date: 17 Apr 2002 23:27:57 -0400 Subject: listobject.c:101: bad argument to internal function References: Message-ID: "Jim Henry" writes: > I have gone over the C code, and it is VERY simple. (...) (...) > Any ideas? (please!) Post the code. It's hard to say without seeing something concrete. Are you consistently checking for errors on all of your Python library calls? -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From timr at probo.com Sat Apr 6 23:53:09 2002 From: timr at probo.com (Tim Roberts) Date: Sat, 06 Apr 2002 20:53:09 -0800 Subject: [Q] Python CGI Q References: <8Far8.36437$tg4.432342@vixen.cso.uiuc.edu> Message-ID: "John" wrote: > >Hi, I'm wondering if I can write a CGI that loads/edits/saves files on >server side.. (I don't need to worry about security concerns for this >application) Any starting point or open-source? EVERYTHING in a CGI script happens on the server side. You can create a